FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ioam_decap.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 #include <vppinfra/error.h>
16 #include <vppinfra/hash.h>
17 #include <vnet/vnet.h>
18 #include <vnet/ip/ip.h>
19 #include <vnet/ethernet/ethernet.h>
25 
26 /* Statistics (not really errors) */
27 #define foreach_vxlan_gpe_decap_ioam_v4_error \
28 _(DECAPSULATED, "good packets decapsulated")
29 
31 #define _(sym,string) string,
33 #undef _
34 };
35 
36 typedef enum
37 {
38 #define _(sym,str) VXLAN_GPE_DECAP_IOAM_V4_ERROR_##sym,
40 #undef _
43 
44 
45 always_inline void
48  vxlan_gpe_main_t * ngm,
49  vlib_buffer_t * b0, vlib_buffer_t * b1,
50  u32 * next0, u32 * next1)
51 {
53 
54  *next0 = *next1 = hm->decap_v4_next_override;
57  0 /* use_adj */ );
60  0 /* use_adj */ );
61 }
62 
63 
64 
65 static uword
69 {
70  u32 n_left_from, next_index, *from, *to_next;
73 
75  n_left_from = from_frame->n_vectors;
76 
77  next_index = node->cached_next_index;
78 
79  while (n_left_from > 0)
80  {
81  u32 n_left_to_next;
82 
83  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
84 
85  while (n_left_from >= 4 && n_left_to_next >= 2)
86  {
87  u32 bi0, bi1;
88  vlib_buffer_t *b0, *b1;
89  u32 next0, next1;
90 
91  next0 = next1 = hm->decap_v4_next_override;
92 
93  /* Prefetch next iteration. */
94  {
95  vlib_buffer_t *p2, *p3;
96 
97  p2 = vlib_get_buffer (vm, from[2]);
98  p3 = vlib_get_buffer (vm, from[3]);
99 
100  vlib_prefetch_buffer_header (p2, LOAD);
101  vlib_prefetch_buffer_header (p3, LOAD);
102 
103  CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
104  CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
105  }
106 
107  bi0 = from[0];
108  bi1 = from[1];
109  to_next[0] = bi0;
110  to_next[1] = bi1;
111  from += 2;
112  to_next += 2;
113  n_left_to_next -= 2;
114  n_left_from -= 2;
115 
116  b0 = vlib_get_buffer (vm, bi0);
117  b1 = vlib_get_buffer (vm, bi1);
118 
119 
121  -(word) (sizeof (udp_header_t) +
122  sizeof (ip4_header_t) +
123  sizeof (vxlan_gpe_header_t)));
125  -(word) (sizeof (udp_header_t) +
126  sizeof (ip4_header_t) +
127  sizeof (vxlan_gpe_header_t)));
128 
130  &next0, &next1);
131 
132 
134  n_left_to_next, bi0, bi1, next0,
135  next1);
136 
137  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
138  {
140  sizeof (*tr));
141  }
142  }
143 
144  while (n_left_from > 0 && n_left_to_next > 0)
145  {
146  u32 bi0;
147  vlib_buffer_t *b0;
148  u32 next0 = hm->decap_v4_next_override;
149 
150  bi0 = from[0];
151  to_next[0] = bi0;
152  from += 1;
153  to_next += 1;
154  n_left_from -= 1;
155  n_left_to_next -= 1;
156 
157  b0 = vlib_get_buffer (vm, bi0);
158 
159 
161  -(word) (sizeof (udp_header_t) +
162  sizeof (ip4_header_t) +
163  sizeof (vxlan_gpe_header_t)));
164 
165  next0 = hm->decap_v4_next_override;
167  &next0,
169  0 /* use_adj */ );
170 
171  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
172  {
174  sizeof (*tr));
175  }
177  n_left_to_next, bi0, next0);
178  }
179 
180  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
181  }
182 
183  return from_frame->n_vectors;
184 }
185 
186 
187 static uword
191 {
192  return vxlan_gpe_decap_ioam (vm, node, from_frame, 0);
193 }
194 
195 
196 /* *INDENT-OFF* */
198  .function = vxlan_gpe_decap_ioam_v4,
199  .name = "vxlan-gpe-decap-ioam-v4",
200  .vector_size = sizeof (u32),
201  .format_trace = format_vxlan_gpe_ioam_v4_trace,
203 
205  .error_strings = vxlan_gpe_decap_ioam_v4_error_strings,
206 
207  .n_next_nodes = VXLAN_GPE_DECAP_IOAM_V4_N_NEXT,
208 
209  .next_nodes = {
210  [VXLAN_GPE_DECAP_IOAM_V4_NEXT_POP] = "vxlan-gpe-pop-ioam-v4",
211  [VXLAN_GPE_DECAP_IOAM_V4_NEXT_DROP] = "error-drop",
212  },
213 };
214 /* *INDENT-ON* */
215 
216 
217 /*
218  * fd.io coding-style-patch-verification: ON
219  *
220  * Local Variables:
221  * eval: (c-set-style "gnu")
222  * End:
223  */
vxlan_gpe_decap_ioam_v4
static uword vxlan_gpe_decap_ioam_v4(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: ioam_decap.c:188
vxlan_gpe_encap_decap_ioam_v4_one_inline
static void vxlan_gpe_encap_decap_ioam_v4_one_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b0, u32 *next0, u32 drop_node_val, u8 use_adj)
Definition: vxlan_gpe_ioam_util.h:84
vlib_prefetch_buffer_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:231
VXLAN_GPE_DECAP_IOAM_V4_N_ERROR
@ VXLAN_GPE_DECAP_IOAM_V4_N_ERROR
Definition: ioam_decap.c:41
is_ipv6
bool is_ipv6
Definition: dhcp.api:202
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
VXLAN_GPE_DECAP_IOAM_V4_NEXT_POP
@ VXLAN_GPE_DECAP_IOAM_V4_NEXT_POP
Definition: vxlan_gpe_ioam.h:170
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
vxlan_gpe_ioam_packet.h
vxlan_gpe_ioam_main
vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main
Definition: vxlan_gpe_ioam.c:23
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
VXLAN_GPE_DECAP_IOAM_V4_NEXT_DROP
@ VXLAN_GPE_DECAP_IOAM_V4_NEXT_DROP
Definition: vxlan_gpe_ioam.h:171
vxlan_gpe_main_t
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:197
foreach_vxlan_gpe_decap_ioam_v4_error
#define foreach_vxlan_gpe_decap_ioam_v4_error
Definition: ioam_decap.c:27
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vxlan_gpe_decap_ioam_v4_error_strings
static char * vxlan_gpe_decap_ioam_v4_error_strings[]
Definition: ioam_decap.c:30
from_frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
Definition: esp_encrypt.c:1328
vxlan_gpe_decap_ioam_v4_error_t
vxlan_gpe_decap_ioam_v4_error_t
Definition: ioam_decap.c:36
vlib_frame_t
Definition: node.h:372
vxlan_gpe_ioam.h
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
ethernet.h
vxlan_gpe.h
VXLAN GPE definitions.
vxlan_gpe_decap_ioam
static uword vxlan_gpe_decap_ioam(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ipv6)
Definition: ioam_decap.c:66
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:76
hash.h
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
vxlan_gpe_decap_ioam_v4_two_inline
static void vxlan_gpe_decap_ioam_v4_two_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vxlan_gpe_main_t *ngm, vlib_buffer_t *b0, vlib_buffer_t *b1, u32 *next0, u32 *next1)
Definition: ioam_decap.c:46
error.h
vxlan_gpe_main
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.c:47
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
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
vxlan_gpe_ioam_main_::decap_v4_next_override
uword decap_v4_next_override
Definition: vxlan_gpe_ioam.h:80
uword
u64 uword
Definition: types.h:112
vxlan_gpe_ioam_util.h
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
VXLAN_GPE_DECAP_IOAM_V4_N_NEXT
@ VXLAN_GPE_DECAP_IOAM_V4_N_NEXT
Definition: vxlan_gpe_ioam.h:172
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
vxlan_gpe_ioam_v4_trace_t
Definition: vxlan_gpe_ioam_util.h:23
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
vxlan_gpe_ioam_main_
Definition: vxlan_gpe_ioam.h:38
ip.h
u32
unsigned int u32
Definition: types.h:88
vxlan_gpe_decap_ioam_v4_node
vlib_node_registration_t vxlan_gpe_decap_ioam_v4_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_decap_ioam_v4_node)
Definition: ioam_decap.c:197
vlib_main_t
Definition: main.h:102
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_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
word
i64 word
Definition: types.h:111
format_vxlan_gpe_ioam_v4_trace
static u8 * format_vxlan_gpe_ioam_v4_trace(u8 *s, va_list *args)
Definition: vxlan_gpe_ioam_util.h:31
vlib_validate_buffer_enqueue_x2
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
Definition: buffer_node.h:70
vnet.h
vxlan_gpe_header_t
VXLAN GPE Header definition.
Definition: vxlan_gpe_packet.h:94
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
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
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