FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
bier_disp_dispatch_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 payload protocol used to dispatch
27  */
29 
30  /**
31  * RPF-ID packet is tagged with
32  */
35 
40 {
41  u32 n_left_from, next_index, * from, * to_next;
42 
44  n_left_from = from_frame->n_vectors;
45 
46  next_index = node->cached_next_index;
47 
48  while (n_left_from > 0)
49  {
50  u32 n_left_to_next;
51 
52  vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
53 
54  while (n_left_from > 0 && n_left_to_next > 0)
55  {
56  bier_hdr_proto_id_t pproto0;
57  bier_disp_entry_t *bde0;
58  u32 next0, bi0, bdei0;
59  const dpo_id_t *dpo0;
60  vlib_buffer_t * b0;
61  bier_hdr_t *hdr0;
62  u32 entropy0;
63 
64  bi0 = from[0];
65  to_next[0] = bi0;
66  from += 1;
67  to_next += 1;
68  n_left_from -= 1;
69  n_left_to_next -= 1;
70 
71  b0 = vlib_get_buffer (vm, bi0);
72  bdei0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
73  hdr0 = vlib_buffer_get_current(b0);
74  bde0 = bier_disp_entry_get(bdei0);
75  vnet_buffer(b0)->ip.adj_index[VLIB_RX] = BIER_RX_ITF;
76 
77  /*
78  * header is in network order - flip it, we are about to
79  * consume it anyway
80  */
81  bier_hdr_ntoh(hdr0);
82  pproto0 = bier_hdr_get_proto_id(hdr0);
83  entropy0 = bier_hdr_get_entropy(hdr0);
84 
85  /*
86  * strip the header and copy the entropy value into
87  * the packets flow-hash field
88  * DSCP mumble mumble...
89  */
90  vlib_buffer_advance(b0, (vnet_buffer(b0)->mpls.bier.n_bytes +
91  sizeof(*hdr0)));
92  vnet_buffer(b0)->ip.flow_hash = entropy0;
93 
94  /*
95  * use the payload proto to dispatch to the
96  * correct stacked DPO.
97  */
98  dpo0 = &bde0->bde_fwd[pproto0].bde_dpo;
99  next0 = dpo0->dpoi_next_node;
100  vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
101  vnet_buffer(b0)->ip.rpf_id = bde0->bde_fwd[pproto0].bde_rpf_id;
102 
103  if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
104  {
106  vlib_add_trace (vm, node, b0, sizeof (*tr));
107  tr->pproto = pproto0;
108  tr->rpf_id = vnet_buffer(b0)->ip.rpf_id;
109  }
110 
112  n_left_to_next, bi0, next0);
113  }
114  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
115  }
116  return from_frame->n_vectors;
117 }
118 
119 static u8 *
120 format_bier_disp_dispatch_trace (u8 * s, va_list * args)
121 {
122  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
123  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
125 
126  t = va_arg (*args, bier_disp_dispatch_trace_t *);
127  s = format (s, "%U", format_bier_hdr_proto, t->pproto);
128 
129  return (s);
130 }
131 
135 {
137 }
138 
140  .name = "bier-disp-dispatch",
141  .vector_size = sizeof (u32),
142 
143  .format_trace = format_bier_disp_dispatch_trace,
144  .n_next_nodes = 1,
145  .next_nodes = {
146  [0] = "bier-drop",
147  }
148 };
dpo_id_t_::dpoi_next_node
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:186
dpo_id_t_::dpoi_index
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:190
bier_disp_dispatch_node
vlib_node_registration_t bier_disp_dispatch_node
(constructor) VLIB_REGISTER_NODE (bier_disp_dispatch_node)
Definition: bier_disp_dispatch_node.c:139
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_disp_entry_t_::bde_rpf_id
u32 bde_rpf_id
Definition: bier_disp_entry.h:45
bier_disp_entry.h
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
BIER_RX_ITF
#define BIER_RX_ITF
The BIER inline functions acting on the bier header.
Definition: bier_hdr_inlines.h:32
bier_disp_dispatch_trace_t_::pproto
bier_hdr_proto_id_t pproto
BIER payload protocol used to dispatch.
Definition: bier_disp_dispatch_node.c:28
bier_hdr_get_proto_id
static bier_hdr_proto_id_t bier_hdr_get_proto_id(const bier_hdr_t *bier_hdr)
Definition: bier_hdr_inlines.h:169
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
bier_hdr_inlines.h
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
format_bier_hdr_proto
u8 * format_bier_hdr_proto(u8 *s, va_list *ap)
Format the header length field.
Definition: bier_types.c:104
from_frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
Definition: esp_encrypt.c:1328
vlib_frame_t
Definition: node.h:372
bier_disp_entry_t_::bde_fwd
struct bier_disp_entry_t_::@152 bde_fwd[BIER_HDR_N_PROTO]
The DPO contributed from the per-payload protocol parents on cacheline 1.
bier_hdr_ntoh
static void bier_hdr_ntoh(bier_hdr_t *bier_hdr)
Definition: bier_hdr_inlines.h:133
vlib_buffer_advance
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:276
bier_disp_entry_t_
bier_disposition : The BIER disposition object
Definition: bier_disp_entry.h:32
bier_disp_dispatch_trace_t_::rpf_id
u32 rpf_id
RPF-ID packet is tagged with.
Definition: bier_disp_dispatch_node.c:33
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:437
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
uword
u64 uword
Definition: types.h:112
bier_disp_entry_t_::bde_dpo
dpo_id_t bde_dpo
Definition: bier_disp_entry.h:44
bier_disp_dispatch_trace_t_
A struct to hold tracing information for the MPLS label imposition node.
Definition: bier_disp_dispatch_node.c:23
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
bier_hdr_proto_id_t
enum bier_hdr_proto_id_t_ bier_hdr_proto_id_t
BIER header protocol payload types.
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
bier_disp_dispatch_trace_t
struct bier_disp_dispatch_trace_t_ bier_disp_dispatch_trace_t
A struct to hold tracing information for the MPLS label imposition node.
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
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
format_bier_disp_dispatch_trace
static u8 * format_bier_disp_dispatch_trace(u8 *s, va_list *args)
Definition: bier_disp_dispatch_node.c:120
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_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
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
bier_disp_entry_get
static bier_disp_entry_t * bier_disp_entry_get(index_t bdi)
Definition: bier_disp_entry.h:81
vlib_node_runtime_t
Definition: node.h:454
from
from
Definition: nat44_ei_hairpinning.c:415
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_dispatch_inline
static uword bier_disp_dispatch_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: bier_disp_dispatch_node.c:37
bier_hdr_get_entropy
static bier_hdr_entropy_t bier_hdr_get_entropy(const bier_hdr_t *bier_hdr)
Definition: bier_hdr_inlines.h:77
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
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169