Line data Source code
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/ip/ip.h>
19 : #include <vnet/vxlan-gpe/vxlan_gpe.h>
20 : #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
21 : #include <ioam/export-common/ioam_export.h>
22 :
23 : typedef struct
24 : {
25 : u32 next_index;
26 : u32 flow_label;
27 : } export_trace_t;
28 :
29 : /* packet trace format function */
30 : static u8 *
31 0 : format_export_trace (u8 * s, va_list * args)
32 : {
33 0 : CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
34 0 : CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
35 0 : export_trace_t *t = va_arg (*args, export_trace_t *);
36 :
37 0 : s = format (s, "EXPORT: flow_label %d, next index %d",
38 : t->flow_label, t->next_index);
39 0 : return s;
40 : }
41 :
42 : vlib_node_registration_t vxlan_export_node;
43 : extern vlib_node_registration_t export_node;
44 : extern ioam_export_main_t vxlan_gpe_ioam_export_main;
45 :
46 : #define foreach_export_error \
47 : _(RECORDED, "Packets recorded for export")
48 :
49 : typedef enum
50 : {
51 : #define _(sym,str) EXPORT_ERROR_##sym,
52 : foreach_export_error
53 : #undef _
54 : EXPORT_N_ERROR,
55 : } export_error_t;
56 :
57 : static char *export_error_strings[] = {
58 : #define _(sym,string) string,
59 : foreach_export_error
60 : #undef _
61 : };
62 :
63 : typedef enum
64 : {
65 : EXPORT_NEXT_VXLAN_GPE_INPUT,
66 : EXPORT_N_NEXT,
67 : } export_next_t;
68 :
69 : always_inline void
70 0 : copy3cachelines (void *dst, const void *src, size_t n)
71 : {
72 : #if 0
73 : if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
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 0 : copy_dst = (u64 *) dst;
91 0 : copy_src = (u64 *) src;
92 0 : if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
93 : {
94 0 : for (i = 0; i < n / 64; i++)
95 : {
96 0 : copy_dst[0] = copy_src[0];
97 0 : copy_dst[1] = copy_src[1];
98 0 : copy_dst[2] = copy_src[2];
99 0 : copy_dst[3] = copy_src[3];
100 0 : copy_dst[4] = copy_src[4];
101 0 : copy_dst[5] = copy_src[5];
102 0 : copy_dst[6] = copy_src[6];
103 0 : copy_dst[7] = copy_src[7];
104 0 : copy_dst += 8;
105 0 : copy_src += 8;
106 : }
107 0 : return;
108 : }
109 0 : for (i = 0; i < 3; i++)
110 : {
111 0 : copy_dst[0] = copy_src[0];
112 0 : copy_dst[1] = copy_src[1];
113 0 : copy_dst[2] = copy_src[2];
114 0 : copy_dst[3] = copy_src[3];
115 0 : copy_dst[4] = copy_src[4];
116 0 : copy_dst[5] = copy_src[5];
117 0 : copy_dst[6] = copy_src[6];
118 0 : copy_dst[7] = copy_src[7];
119 0 : copy_dst += 8;
120 0 : copy_src += 8;
121 : }
122 : #endif
123 : }
124 :
125 : static void
126 0 : vxlan_gpe_export_fixup_func (vlib_buffer_t * export_buf,
127 : vlib_buffer_t * pak_buf)
128 : {
129 : /* Todo: on implementing VXLAN GPE analyse */
130 0 : }
131 :
132 : static uword
133 0 : vxlan_gpe_export_node_fn (vlib_main_t * vm,
134 : vlib_node_runtime_t * node, vlib_frame_t * frame)
135 : {
136 0 : ioam_export_main_t *em = &vxlan_gpe_ioam_export_main;
137 0 : ioam_export_node_common (em, vm, node, frame, ip4_header_t, length,
138 : ip_version_and_header_length,
139 : EXPORT_NEXT_VXLAN_GPE_INPUT,
140 : vxlan_gpe_export_fixup_func);
141 0 : return frame->n_vectors;
142 : }
143 :
144 : /*
145 : * Node for VXLAN-GPE export
146 : */
147 : /* *INDENT-OFF* */
148 110920 : VLIB_REGISTER_NODE (vxlan_export_node) =
149 : {
150 : .function = vxlan_gpe_export_node_fn,
151 : .name = "vxlan-gpe-ioam-export",
152 : .vector_size = sizeof (u32),
153 : .format_trace = format_export_trace,
154 : .type = VLIB_NODE_TYPE_INTERNAL,
155 : .n_errors = ARRAY_LEN (export_error_strings),
156 : .error_strings = export_error_strings,
157 : .n_next_nodes = EXPORT_N_NEXT,
158 : /* edit / add dispositions here */
159 : .next_nodes =
160 : {[EXPORT_NEXT_VXLAN_GPE_INPUT] = "vxlan-gpe-pop-ioam-v4"},
161 : };
162 : /* *INDENT-ON* */
163 :
164 : /*
165 : * fd.io coding-style-patch-verification: ON
166 : *
167 : * Local Variables:
168 : * eval: (c-set-style "gnu")
169 : * End:
170 : */
|