FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
nsh_md2_ioam_node.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 <nsh/nsh.h>
21 #include <nsh/nsh_packet.h>
23 
24 typedef struct
25 {
27  u32 flow_label;
29 
32 /* packet trace format function */
33 static u8 *
34 format_export_trace (u8 * s, va_list * args)
35 {
36  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
37  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
38  export_trace_t *t = va_arg (*args, export_trace_t *);
39 
40  s = format (s, "EXPORT: flow_label %d, next index %d",
41  t->flow_label, t->next_index);
42  return s;
43 }
44 
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 
74  u64 *copy_dst, *copy_src;
75  int i;
76  copy_dst = (u64 *) dst;
77  copy_src = (u64 *) src;
79  {
80  for (i = 0; i < n / 64; i++)
81  {
82  copy_dst[0] = copy_src[0];
83  copy_dst[1] = copy_src[1];
84  copy_dst[2] = copy_src[2];
85  copy_dst[3] = copy_src[3];
86  copy_dst[4] = copy_src[4];
87  copy_dst[5] = copy_src[5];
88  copy_dst[6] = copy_src[6];
89  copy_dst[7] = copy_src[7];
90  copy_dst += 8;
91  copy_src += 8;
92  }
93  return;
94  }
95  for (i = 0; i < 3; 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 }
109 
110 static void
112  vlib_buffer_t * pak_buf)
113 {
114  /* Todo: on implementing analyse */
115 }
116 
117 static uword
120 {
123  ip_version_and_header_length,
126  return frame->n_vectors;
127 }
128 
129 /*
130  * Node for iOAM export
131  */
132 /* *INDENT-OFF* */
134 {
135  .function = nsh_md2_ioam_export_node_fn,
136  .name = "nsh-md2-ioam-export",
137  .vector_size = sizeof (u32),
138  .format_trace = format_export_trace,
140  .n_errors = ARRAY_LEN (export_error_strings),
141  .error_strings = export_error_strings,
142  .n_next_nodes = EXPORT_N_NEXT,
143  /* edit / add dispositions here */
144  .next_nodes =
145  {[EXPORT_NEXT_NSH_MD2_IOAM_INPUT] = "nsh-pop"},
146 };
147 /* *INDENT-ON* */
148 
149 /*
150  * fd.io coding-style-patch-verification: ON
151  *
152  * Local Variables:
153  * eval: (c-set-style "gnu")
154  * End:
155  */
export_trace_t::next_index
u32 next_index
Definition: node.c:26
vlib.h
ioam_export.h
EXPORT_NEXT_NSH_MD2_IOAM_INPUT
@ EXPORT_NEXT_NSH_MD2_IOAM_INPUT
Definition: nsh_md2_ioam_node.c:66
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
export_error_t
export_error_t
Definition: nsh_md2_ioam_node.c:50
EXPORT_N_ERROR
@ EXPORT_N_ERROR
Definition: nsh_md2_ioam_node.c:55
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
export_error_strings
static char * export_error_strings[]
Definition: nsh_md2_ioam_node.c:58
format_export_trace
static u8 * format_export_trace(u8 *s, va_list *args)
Definition: nsh_md2_ioam_node.c:34
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
export_node
vlib_node_registration_t export_node
(constructor) VLIB_REGISTER_NODE (export_node)
Definition: nsh_md2_ioam_node.c:31
export_next_t
export_next_t
Definition: nsh_md2_ioam_node.c:64
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vlib_frame_t
Definition: node.h:372
ip4_header_t
Definition: ip4_packet.h:87
ethernet.h
export_trace_t
Definition: node.c:24
EXPORT_N_NEXT
@ EXPORT_N_NEXT
Definition: nsh_md2_ioam_node.c:67
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
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
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
foreach_export_error
#define foreach_export_error
Definition: nsh_md2_ioam_node.c:47
src
vl_api_address_t src
Definition: gre.api:54
nsh_md2_ioam_export_node
vlib_node_registration_t nsh_md2_ioam_export_node
(constructor) VLIB_REGISTER_NODE (nsh_md2_ioam_export_node)
Definition: nsh_md2_ioam_node.c:45
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
copy3cachelines
static void copy3cachelines(void *dst, const void *src, size_t n)
Definition: nsh_md2_ioam_node.c:71
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
nsh_md2_ioam_export_node_fn
static uword nsh_md2_ioam_export_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nsh_md2_ioam_node.c:118
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
nsh.h
ip.h
u32
unsigned int u32
Definition: types.h:88
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
ioam_export_main_t
Definition: ioam_export.h:47
nsh_packet.h
length
char const int length
Definition: cJSON.h:163
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
u8
unsigned char u8
Definition: types.h:56
nsh_md2_ioam_export_main
ioam_export_main_t nsh_md2_ioam_export_main
Definition: nsh_md2_ioam_export.c:32
i
int i
Definition: flowhash_template.h:376
vnet.h
vlib_node_runtime_t
Definition: node.h:454
nsh_md2_ioam_export_fixup_func
static void nsh_md2_ioam_export_fixup_func(vlib_buffer_t *export_buf, vlib_buffer_t *pak_buf)
Definition: nsh_md2_ioam_node.c:111
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