FD.io VPP  v21.10.1-2-g0a485f517
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 <vppinfra/error.h>
18 #include <vnet/ethernet/ethernet.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/ip/ip6_hop_by_hop.h>
22 
23 
24 typedef struct
25 {
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 
45 
46 #define foreach_export_error \
47 _(RECORDED, "Packets recorded for export")
48 
49 typedef enum
50 {
51 #define _(sym,str) EXPORT_ERROR_##sym,
53 #undef _
56 
57 static char *export_error_strings[] = {
58 #define _(sym,string) string,
60 #undef _
61 };
62 
63 typedef enum
64 {
68 
69 always_inline void
70 copy3cachelines (void *dst, const void *src, size_t n)
71 {
72 #if 0
74  {
75  /* Copy only the first 1/2 cache lines whatever is available */
76  if (n >= 64)
77  clib_mov64 ((u8 *) dst, (const u8 *) src);
78  if (n >= 128)
79  clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
80  return;
81  }
82  clib_mov64 ((u8 *) dst, (const u8 *) src);
83  clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
84  clib_mov64 ((u8 *) dst + 128, (const u8 *) src + 128);
85 #endif
86 #if 1
87 
88  u64 *copy_dst, *copy_src;
89  int i;
90  copy_dst = (u64 *) dst;
91  copy_src = (u64 *) src;
93  {
94  for (i = 0; i < n / 64; i++)
95  {
96  copy_dst[0] = copy_src[0];
97  copy_dst[1] = copy_src[1];
98  copy_dst[2] = copy_src[2];
99  copy_dst[3] = copy_src[3];
100  copy_dst[4] = copy_src[4];
101  copy_dst[5] = copy_src[5];
102  copy_dst[6] = copy_src[6];
103  copy_dst[7] = copy_src[7];
104  copy_dst += 8;
105  copy_src += 8;
106  }
107  return;
108  }
109  for (i = 0; i < 3; i++)
110  {
111  copy_dst[0] = copy_src[0];
112  copy_dst[1] = copy_src[1];
113  copy_dst[2] = copy_src[2];
114  copy_dst[3] = copy_src[3];
115  copy_dst[4] = copy_src[4];
116  copy_dst[5] = copy_src[5];
117  copy_dst[6] = copy_src[6];
118  copy_dst[7] = copy_src[7];
119  copy_dst += 8;
120  copy_src += 8;
121  }
122 #endif
123 }
124 
125 static void
127 {
128  ip6_header_t *ip6_temp =
129  (ip6_header_t *) (export_buf->data + export_buf->current_length);
130  u32 flow_label_temp =
131  clib_net_to_host_u32(ip6_temp->ip_version_traffic_class_and_flow_label)
132  & 0xFFF00000;
133  flow_label_temp |=
134  IOAM_MASK_DECAP_BIT((vnet_buffer(pak_buf)->l2_classify.opaque_index));
136  clib_host_to_net_u32(flow_label_temp);
137 }
138 
139 static uword
142 {
144  ioam_export_node_common(em, vm, node, frame, ip6_header_t, payload_length,
145  ip_version_traffic_class_and_flow_label,
147  return frame->n_vectors;
148 }
149 
150 /*
151  * Node for IP6 export
152  */
154 {
155  .function = ip6_export_node_fn,
156  .name = "ip6-export",
157  .vector_size = sizeof (u32),
158  .format_trace = format_export_trace,
160  .n_errors = ARRAY_LEN (export_error_strings),
161  .error_strings = export_error_strings,
162  .n_next_nodes = EXPORT_N_NEXT,
163  /* edit / add dispositions here */
164  .next_nodes =
165  {
166  [EXPORT_NEXT_POP_HBYH] = "ip6-pop-hop-by-hop"
167  },
168 };
export_trace_t::next_index
u32 next_index
Definition: node.c:26
vlib.h
ioam_export.h
export_error_t
export_error_t
Definition: node.c:49
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
EXPORT_N_NEXT
@ EXPORT_N_NEXT
Definition: node.c:66
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
export_node
vlib_node_registration_t export_node
(constructor) VLIB_REGISTER_NODE (export_node)
Definition: node.c:43
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ip6_export_node_fn
static uword ip6_export_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: node.c:140
vlib_frame_t
Definition: node.h:372
ethernet.h
export_trace_t
Definition: node.c:24
IOAM_MASK_DECAP_BIT
#define IOAM_MASK_DECAP_BIT(x)
Definition: ip6_hop_by_hop.h:32
ioam_export_main
ioam_export_main_t ioam_export_main
Definition: ioam_export.c:37
ioam_export_node_common
#define ioam_export_node_common(EM, VM, N, F, HTYPE, L, V, NEXT, FIXUP_FUNC)
Definition: ioam_export.h:470
error.h
ip6_hop_by_hop.h
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
format_export_trace
static u8 * format_export_trace(u8 *s, va_list *args)
Definition: node.c:32
uword
u64 uword
Definition: types.h:112
DEFAULT_EXPORT_SIZE
#define DEFAULT_EXPORT_SIZE
Definition: ioam_export.h:84
export_trace_t::flow_label
u32 flow_label
Definition: node.c:27
EXPORT_NEXT_POP_HBYH
@ EXPORT_NEXT_POP_HBYH
Definition: node.c:65
src
vl_api_address_t src
Definition: gre.api:54
export_next_t
export_next_t
Definition: node.c:63
EXPORT_N_ERROR
@ EXPORT_N_ERROR
Definition: node.c:54
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
ip6_export_fixup_func
static void ip6_export_fixup_func(vlib_buffer_t *export_buf, vlib_buffer_t *pak_buf)
Definition: node.c:126
copy3cachelines
static void copy3cachelines(void *dst, const void *src, size_t n)
Definition: node.c:70
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
ip.h
u32
unsigned int u32
Definition: types.h:88
export_error_strings
static char * export_error_strings[]
Definition: node.c:57
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
ioam_export_main_t
Definition: ioam_export.h:47
ip6_header_t
Definition: ip6_packet.h:294
clib_mov64
static void clib_mov64(u8 *dst, const u8 *src)
Definition: memcpy_avx2.h:78
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
u8
unsigned char u8
Definition: types.h:56
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
i
int i
Definition: flowhash_template.h:376
vnet.h
vlib_node_runtime_t
Definition: node.h:454
foreach_export_error
#define foreach_export_error
Definition: node.c:46
ip6_header_t::ip_version_traffic_class_and_flow_label
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:297
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169