FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
bier_disp_lookup_node.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
18 
19 /**
20  * @brief A struct to hold tracing information for the MPLS label imposition
21  * node.
22  */
24 {
25  /**
26  * BIER source BP used in the lookup - host order
27  */
29  /**
30  * BIER disp table
31  */
34 
35 /**
36  * Next nodes from BIER disposition lookup
37  */
39 {
43 #define BIER_DISP_LOOKUP_N_NEXT (BIER_DISP_LOOKUP_NEXT_DISPATCH+1)
44 
49 {
50  u32 n_left_from, next_index, * from, * to_next;
51 
53  n_left_from = from_frame->n_vectors;
54 
55  next_index = node->cached_next_index;
56 
57  while (n_left_from > 0)
58  {
59  u32 n_left_to_next;
60 
61  vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
62 
63  while (n_left_from > 0 && n_left_to_next > 0)
64  {
65  const bier_hdr_t *hdr0;
66  bier_hdr_src_id_t src0;
67  vlib_buffer_t * b0;
68  u32 bdei0, bdti0;
69  u32 next0, bi0;
70 
71  bi0 = from[0];
72  to_next[0] = bi0;
73  from += 1;
74  to_next += 1;
75  n_left_from -= 1;
76  n_left_to_next -= 1;
77 
78  b0 = vlib_get_buffer (vm, bi0);
79 
80  bdti0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
81  hdr0 = vlib_buffer_get_current(b0);
82 
83  /*
84  * lookup - source is in network order.
85  */
86  src0 = bier_hdr_get_src_id(hdr0);
88 
89  bdei0 = bier_disp_table_lookup(bdti0, src0);
90 
91  if (PREDICT_FALSE(INDEX_INVALID == bdei0))
92  {
93  /*
94  * if a specific match misses, try the default
95  */
96  bdei0 = bier_disp_table_lookup(bdti0, 0);
97 
98  if (PREDICT_FALSE(INDEX_INVALID == bdei0))
99  {
101  }
102  }
103 
104  vnet_buffer(b0)->ip.adj_index[VLIB_TX] = bdei0;
105 
106  if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
107  {
109  vlib_add_trace (vm, node, b0, sizeof (*tr));
110  tr->bp = clib_net_to_host_u16(bier_hdr_get_src_id(hdr0));
111  tr->bdti = bdti0;
112  }
113 
115  n_left_to_next, bi0, next0);
116  }
117  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
118  }
119  return from_frame->n_vectors;
120 }
121 
122 static u8 *
123 format_bier_disp_lookup_trace (u8 * s, va_list * args)
124 {
125  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
126  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
128 
129  t = va_arg (*args, bier_disp_lookup_trace_t *);
130  s = format (s, "tbl:%d src:%d", t->bdti, t->bp);
131 
132  return (s);
133 }
134 
138 {
139  return (bier_disp_lookup_inline(vm, node, frame));
140 }
141 
143  .name = "bier-disp-lookup",
144  .vector_size = sizeof (u32),
145 
146  .format_trace = format_bier_disp_lookup_trace,
147  .n_next_nodes = BIER_DISP_LOOKUP_N_NEXT,
148  .next_nodes = {
149  [BIER_DISP_LOOKUP_NEXT_DROP] = "bier-drop",
150  [BIER_DISP_LOOKUP_NEXT_DISPATCH] = "bier-disp-dispatch",
151  }
152 };
BIER_DISP_LOOKUP_NEXT_DROP
@ BIER_DISP_LOOKUP_NEXT_DROP
Definition: bier_disp_lookup_node.c:40
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
bier_hdr_src_id_t
u16 bier_hdr_src_id_t
An identifier of the sender of BIER packets this is the source of the 'tree' - the BFIR.
Definition: bier_types.h:307
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
bier_hdr_inlines.h
from_frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
Definition: esp_encrypt.c:1328
bier_bp_t
u32 bier_bp_t
A bit positon as assigned to egress PEs.
Definition: bier_types.h:294
vlib_frame_t
Definition: node.h:372
bier_disp_lookup_trace_t_
A struct to hold tracing information for the MPLS label imposition node.
Definition: bier_disp_lookup_node.c:23
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
uword
u64 uword
Definition: types.h:112
bier_disp_lookup_trace_t_::bp
bier_bp_t bp
BIER source BP used in the lookup - host order.
Definition: bier_disp_lookup_node.c:28
bier_disp_table.h
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
bier_disp_lookup_inline
static uword bier_disp_lookup_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: bier_disp_lookup_node.c:46
bier_disp_lookup_node
vlib_node_registration_t bier_disp_lookup_node
(constructor) VLIB_REGISTER_NODE (bier_disp_lookup_node)
Definition: bier_disp_lookup_node.c:142
vlib_validate_buffer_enqueue_x1
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:224
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
format
description fragment has unexpected format
Definition: map.api:433
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
u32
unsigned int u32
Definition: types.h:88
format_bier_disp_lookup_trace
static u8 * format_bier_disp_lookup_trace(u8 *s, va_list *args)
Definition: bier_disp_lookup_node.c:123
BIER_DISP_LOOKUP_N_NEXT
#define BIER_DISP_LOOKUP_N_NEXT
Definition: bier_disp_lookup_node.c:43
bier_disp_lookup_next_t_
bier_disp_lookup_next_t_
Next nodes from BIER disposition lookup.
Definition: bier_disp_lookup_node.c:38
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
u8
unsigned char u8
Definition: types.h:56
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
bier_disp_table_lookup
static index_t bier_disp_table_lookup(index_t bdti, bier_hdr_src_id_t src)
Definition: bier_disp_table.h:105
bier_disp_lookup_next_t
enum bier_disp_lookup_next_t_ bier_disp_lookup_next_t
Next nodes from BIER disposition lookup.
bier_hdr_t_
A BIER header of variable length The encoding follows: https://tools.ietf.org/html/draft-ietf-bier-mp...
Definition: bier_types.h:321
vlib_node_runtime_t
Definition: node.h:454
from
from
Definition: nat44_ei_hairpinning.c:415
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
vlib_get_next_frame
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:395
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
bier_disp_lookup_trace_t
struct bier_disp_lookup_trace_t_ bier_disp_lookup_trace_t
A struct to hold tracing information for the MPLS label imposition node.
bier_disp_lookup_trace_t_::bdti
index_t bdti
BIER disp table.
Definition: bier_disp_lookup_node.c:32
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
bier_hdr_get_src_id
static bier_hdr_src_id_t bier_hdr_get_src_id(const bier_hdr_t *bier_hdr)
Definition: bier_hdr_inlines.h:149
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
BIER_DISP_LOOKUP_NEXT_DISPATCH
@ BIER_DISP_LOOKUP_NEXT_DISPATCH
Definition: bier_disp_lookup_node.c:41