FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
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/ethernet/ethernet.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/ip/ip6_hop_by_hop.h>
23 
24 
25 typedef struct
26 {
30 
31 /* packet trace format function */
32 static u8 *
33 format_export_trace (u8 * s, va_list * args)
34 {
35  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
36  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
37  export_trace_t *t = va_arg (*args, export_trace_t *);
38 
39  s = format (s, "EXPORT: flow_label %d, next index %d",
40  t->flow_label, t->next_index);
41  return s;
42 }
43 
46 
47 #define foreach_export_error \
48 _(RECORDED, "Packets recorded for export")
49 
50 typedef enum
51 {
52 #define _(sym,str) EXPORT_ERROR_##sym,
54 #undef _
57 
58 static char *export_error_strings[] = {
59 #define _(sym,string) string,
61 #undef _
62 };
63 
64 typedef enum
65 {
69 
70 always_inline void
71 copy3cachelines (void *dst, const void *src, size_t n)
72 {
73 #if 0
75  {
76  /* Copy only the first 1/2 cache lines whatever is available */
77  if (n >= 64)
78  clib_mov64 ((u8 *) dst, (const u8 *) src);
79  if (n >= 128)
80  clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
81  return;
82  }
83  clib_mov64 ((u8 *) dst, (const u8 *) src);
84  clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
85  clib_mov64 ((u8 *) dst + 128, (const u8 *) src + 128);
86 #endif
87 #if 1
88 
89  u64 *copy_dst, *copy_src;
90  int i;
91  copy_dst = (u64 *) dst;
92  copy_src = (u64 *) src;
94  {
95  for (i = 0; i < n / 64; i++)
96  {
97  copy_dst[0] = copy_src[0];
98  copy_dst[1] = copy_src[1];
99  copy_dst[2] = copy_src[2];
100  copy_dst[3] = copy_src[3];
101  copy_dst[4] = copy_src[4];
102  copy_dst[5] = copy_src[5];
103  copy_dst[6] = copy_src[6];
104  copy_dst[7] = copy_src[7];
105  copy_dst += 8;
106  copy_src += 8;
107  }
108  return;
109  }
110  for (i = 0; i < 3; i++)
111  {
112  copy_dst[0] = copy_src[0];
113  copy_dst[1] = copy_src[1];
114  copy_dst[2] = copy_src[2];
115  copy_dst[3] = copy_src[3];
116  copy_dst[4] = copy_src[4];
117  copy_dst[5] = copy_src[5];
118  copy_dst[6] = copy_src[6];
119  copy_dst[7] = copy_src[7];
120  copy_dst += 8;
121  copy_src += 8;
122  }
123 #endif
124 }
125 
126 static void
128 {
129  ip6_header_t *ip6_temp =
130  (ip6_header_t *) (export_buf->data + export_buf->current_length);
131  u32 flow_label_temp =
132  clib_net_to_host_u32(ip6_temp->ip_version_traffic_class_and_flow_label)
133  & 0xFFF00000;
134  flow_label_temp |=
135  IOAM_MASK_DECAP_BIT((vnet_buffer(pak_buf)->l2_classify.opaque_index));
137  clib_host_to_net_u32(flow_label_temp);
138 }
139 
140 static uword
142  vlib_node_runtime_t * node, vlib_frame_t * frame)
143 {
145  ioam_export_node_common(em, vm, node, frame, ip6_header_t, payload_length,
146  ip_version_traffic_class_and_flow_label,
148  return frame->n_vectors;
149 }
150 
151 /*
152  * Node for IP6 export
153  */
155 {
156  .function = ip6_export_node_fn,
157  .name = "ip6-export",
158  .vector_size = sizeof (u32),
159  .format_trace = format_export_trace,
161  .n_errors = ARRAY_LEN (export_error_strings),
162  .error_strings = export_error_strings,
163  .n_next_nodes = EXPORT_N_NEXT,
164  /* edit / add dispositions here */
165  .next_nodes =
166  {
167  [EXPORT_NEXT_POP_HBYH] = "ip6-pop-hop-by-hop"
168  },
169 };
#define CLIB_UNUSED(x)
Definition: clib.h:83
unsigned long u64
Definition: types.h:89
export_next_t
Definition: node.c:64
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
u32 next_index
Definition: node.c:27
vl_api_address_t src
Definition: gre.api:51
int i
static u8 * format_export_trace(u8 *s, va_list *args)
Definition: node.c:33
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
unsigned char u8
Definition: types.h:56
#define always_inline
Definition: clib.h:99
unsigned int u32
Definition: types.h:88
static uword ip6_export_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: node.c:141
vl_api_fib_path_type_t type
Definition: fib_types.api:123
#define PREDICT_FALSE(x)
Definition: clib.h:112
u32 flow_label
Definition: node.c:28
static void copy3cachelines(void *dst, const void *src, size_t n)
Definition: node.c:71
vl_api_address_t dst
Definition: gre.api:52
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:397
vlib_main_t * vm
Definition: buffer.c:323
u8 data[]
Packet data.
Definition: buffer.h:181
#define ARRAY_LEN(x)
Definition: clib.h:63
struct _vlib_node_registration vlib_node_registration_t
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:370
VLIB buffer representation.
Definition: buffer.h:102
vlib_node_registration_t export_node
(constructor) VLIB_REGISTER_NODE (export_node)
Definition: node.c:44
#define ioam_export_node_common(EM, VM, N, F, HTYPE, L, V, NEXT, FIXUP_FUNC)
Definition: ioam_export.h:469
u64 uword
Definition: types.h:112
#define foreach_export_error
Definition: node.c:47
static char * export_error_strings[]
Definition: node.c:58
#define DEFAULT_EXPORT_SIZE
Definition: ioam_export.h:83
#define vnet_buffer(b)
Definition: buffer.h:365
#define IOAM_MASK_DECAP_BIT(x)
static void ip6_export_fixup_func(vlib_buffer_t *export_buf, vlib_buffer_t *pak_buf)
Definition: node.c:127
export_error_t
Definition: node.c:50
static void clib_mov64(u8 *dst, const u8 *src)
Definition: memcpy_avx2.h:78
ioam_export_main_t ioam_export_main
Definition: ioam_export.c:61