FD.io VPP  v18.01.2-1-g9b554f3
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 
38  vlib_node_runtime_t * node,
39  vlib_frame_t * from_frame)
40 {
41  u32 n_left_from, next_index, * from, * to_next;
42 
43  from = vlib_frame_vector_args (from_frame);
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 
76  /*
77  * header is in network order - flip it, we are about to
78  * consume it anyway
79  */
80  bier_hdr_ntoh(hdr0);
81  pproto0 = bier_hdr_get_proto_id(hdr0);
82  entropy0 = bier_hdr_get_entropy(hdr0);
83 
84  /*
85  * strip the header and copy the entropy value into
86  * the packets flow-hash field
87  * DSCP mumble mumble...
88  */
89  vlib_buffer_advance(b0, (vnet_buffer(b0)->mpls.bier.n_bytes +
90  sizeof(*hdr0)));
91  vnet_buffer(b0)->ip.flow_hash = entropy0;
92 
93  /*
94  * use the payload proto to dispatch to the
95  * correct stacked DPO.
96  */
97  dpo0 = &bde0->bde_fwd[pproto0].bde_dpo;
98  next0 = dpo0->dpoi_next_node;
99  vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
100  vnet_buffer(b0)->ip.rpf_id = bde0->bde_fwd[pproto0].bde_rpf_id;
101 
103  {
105  vlib_add_trace (vm, node, b0, sizeof (*tr));
106  tr->pproto = pproto0;
107  tr->rpf_id = vnet_buffer(b0)->ip.rpf_id;
108  }
109 
110  vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
111  n_left_to_next, bi0, next0);
112  }
113  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
114  }
115  return from_frame->n_vectors;
116 }
117 
118 static u8 *
119 format_bier_disp_dispatch_trace (u8 * s, va_list * args)
120 {
121  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
122  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
124 
125  t = va_arg (*args, bier_disp_dispatch_trace_t *);
126  s = format (s, "%U", format_bier_hdr_proto, t->pproto);
127 
128  return (s);
129 }
130 
131 static uword
133  vlib_node_runtime_t * node,
134  vlib_frame_t * frame)
135 {
136  return (bier_disp_dispatch_inline(vm, node, frame));
137 }
138 
140  .function = bier_disp_dispatch,
141  .name = "bier-disp-dispatch",
142  .vector_size = sizeof (u32),
143 
144  .format_trace = format_bier_disp_dispatch_trace,
145  .n_next_nodes = 1,
146  .next_nodes = {
147  [0] = "bier-drop",
148  }
149 };
#define CLIB_UNUSED(x)
Definition: clib.h:79
u32 bde_rpf_id
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
bier_dispositon : The BIER dispositon object
#define always_inline
Definition: clib.h:92
static uword bier_disp_dispatch(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u8 * format_bier_disp_dispatch_trace(u8 *s, va_list *args)
static uword bier_disp_dispatch_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:166
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:195
#define PREDICT_FALSE(x)
Definition: clib.h:105
static bier_disp_entry_t * bier_disp_entry_get(index_t bdi)
#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:218
#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:364
static bier_hdr_entropy_t bier_hdr_get_entropy(const bier_hdr_t *bier_hdr)
u16 n_vectors
Definition: node.h:344
vlib_main_t * vm
Definition: buffer.c:283
dpo_id_t bde_dpo
A struct to hold tracing information for the MPLS label imposition node.
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:93
struct bier_disp_dispatch_trace_t_ bier_disp_dispatch_trace_t
A struct to hold tracing information for the MPLS label imposition node.
enum bier_hdr_proto_id_t_ bier_hdr_proto_id_t
BIER header protocol payload types.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:454
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:456
unsigned int u32
Definition: types.h:88
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:208
bier_hdr_proto_id_t pproto
BIER payload protocol used to dispatch.
static bier_hdr_proto_id_t bier_hdr_get_proto_id(const bier_hdr_t *bier_hdr)
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
Definition: defs.h:47
A BIER header of variable length The encoding follows: https://tools.ietf.org/html/draft-ietf-bier-mp...
Definition: bier_types.h:373
struct bier_disp_entry_t_::@50 bde_fwd[BIER_HDR_N_PROTO]
The DPO contirubted from the per-payload protocol parents on cachline 1.
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:182
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:267
u32 rpf_id
RPF-ID packet is tagged with.
#define vnet_buffer(b)
Definition: buffer.h:326
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
vlib_node_registration_t bier_disp_dispatch_node
(constructor) VLIB_REGISTER_NODE (bier_disp_dispatch_node)
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:178
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:75
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
static void bier_hdr_ntoh(bier_hdr_t *bier_hdr)
u8 * format_bier_hdr_proto(u8 *s, va_list *ap)
Format the header length field.
Definition: bier_types.c:104