FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
vxlan_gpe_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 #include <vlib/vlib.h>
16 #include <vnet/vnet.h>
17 #include <vnet/pg/pg.h>
18 #include <vppinfra/error.h>
19 #include <vnet/ip/ip.h>
23 
24 typedef struct
25 {
26  u32 next_index;
27  u32 flow_label;
29 
30 /* packet trace format function */
31 static u8 *
32 format_export_trace (u8 * s, va_list * args)
33 {
34  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
35  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
36  export_trace_t *t = va_arg (*args, export_trace_t *);
37 
38  s = format (s, "EXPORT: flow_label %d, next index %d",
39  t->flow_label, t->next_index);
40  return s;
41 }
42 
44 
45 #define foreach_export_error \
46 _(RECORDED, "Packets recorded for export")
47 
48 typedef enum
49 {
50 #define _(sym,str) EXPORT_ERROR_##sym,
52 #undef _
55 
56 static char *export_error_strings[] = {
57 #define _(sym,string) string,
59 #undef _
60 };
61 
62 typedef enum
63 {
67 
68 always_inline void
69 copy3cachelines (void *dst, const void *src, size_t n)
70 {
71 #if 0
73  {
74  /* Copy only the first 1/2 cache lines whatever is available */
75  if (n >= 64)
76  clib_mov64 ((u8 *) dst, (const u8 *) src);
77  if (n >= 128)
78  clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
79  return;
80  }
81  clib_mov64 ((u8 *) dst, (const u8 *) src);
82  clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
83  clib_mov64 ((u8 *) dst + 128, (const u8 *) src + 128);
84 #endif
85 #if 1
86 
87  u64 *copy_dst, *copy_src;
88  int i;
89  copy_dst = (u64 *) dst;
90  copy_src = (u64 *) src;
92  {
93  for (i = 0; i < n / 64; i++)
94  {
95  copy_dst[0] = copy_src[0];
96  copy_dst[1] = copy_src[1];
97  copy_dst[2] = copy_src[2];
98  copy_dst[3] = copy_src[3];
99  copy_dst[4] = copy_src[4];
100  copy_dst[5] = copy_src[5];
101  copy_dst[6] = copy_src[6];
102  copy_dst[7] = copy_src[7];
103  copy_dst += 8;
104  copy_src += 8;
105  }
106  return;
107  }
108  for (i = 0; i < 3; i++)
109  {
110  copy_dst[0] = copy_src[0];
111  copy_dst[1] = copy_src[1];
112  copy_dst[2] = copy_src[2];
113  copy_dst[3] = copy_src[3];
114  copy_dst[4] = copy_src[4];
115  copy_dst[5] = copy_src[5];
116  copy_dst[6] = copy_src[6];
117  copy_dst[7] = copy_src[7];
118  copy_dst += 8;
119  copy_src += 8;
120  }
121 #endif
122 }
123 
124 
125 static uword
127  vlib_node_runtime_t * node, vlib_frame_t * frame)
128 {
130  ioam_export_node_common (em, vm, node, frame, ip4_header_t, length,
131  ip_version_and_header_length,
133  return frame->n_vectors;
134 }
135 
136 /*
137  * Node for VXLAN-GPE export
138  */
139 /* *INDENT-OFF* */
141 {
142  .function = vxlan_gpe_export_node_fn,
143  .name = "vxlan-gpe-ioam-export",
144  .vector_size = sizeof (u32),
145  .format_trace = format_export_trace,
147  .n_errors = ARRAY_LEN (export_error_strings),
148  .error_strings = export_error_strings,
149  .n_next_nodes = EXPORT_N_NEXT,
150  /* edit / add dispositions here */
151  .next_nodes =
152  {[EXPORT_NEXT_VXLAN_GPE_INPUT] = "vxlan-gpe-pop-ioam-v4"},
153 };
154 /* *INDENT-ON* */
155 
156 /*
157  * fd.io coding-style-patch-verification: ON
158  *
159  * Local Variables:
160  * eval: (c-set-style "gnu")
161  * End:
162  */
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define CLIB_UNUSED(x)
Definition: clib.h:79
static void clib_mov64(u8 *dst, const u8 *src)
Definition: memcpy_avx.h:70
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static uword vxlan_gpe_export_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
VXLAN GPE definitions.
u32 next_index
Definition: node.c:24
struct _vlib_node_registration vlib_node_registration_t
ioam_export_main_t vxlan_gpe_ioam_export_main
Definition: ioam_export.h:77
#define foreach_export_error
#define always_inline
Definition: clib.h:84
unsigned long u64
Definition: types.h:89
VXLAN GPE packet header structure.
#define ioam_export_node_common(EM, VM, N, F, HTYPE, L, V, NEXT)
Definition: ioam_export.h:455
static void copy3cachelines(void *dst, const void *src, size_t n)
#define PREDICT_FALSE(x)
Definition: clib.h:97
u32 flow_label
Definition: node.c:25
u16 n_vectors
Definition: node.h:344
#define ARRAY_LEN(x)
Definition: clib.h:59
vlib_node_registration_t vxlan_export_node
(constructor) VLIB_REGISTER_NODE (vxlan_export_node)
unsigned int u32
Definition: types.h:88
u64 uword
Definition: types.h:112
static char * export_error_strings[]
unsigned char u8
Definition: types.h:56
#define DEFAULT_EXPORT_SIZE
Definition: ioam_export.h:82
export_error_t
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
export_next_t
static u8 * format_export_trace(u8 *s, va_list *args)