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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
20 #include <vnet/vxlan-gpe/vxlan_gpe.h>
21 #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
22 #include <ioam/export-common/ioam_export.h>
30 /* packet trace format function */
32 format_export_trace (u8 * s, va_list * args)
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 *);
38 s = format (s, "EXPORT: flow_label %d, next index %d",
39 t->flow_label, t->next_index);
43 vlib_node_registration_t vxlan_export_node;
45 #define foreach_export_error \
46 _(RECORDED, "Packets recorded for export")
50 #define _(sym,str) EXPORT_ERROR_##sym,
56 static char *export_error_strings[] = {
57 #define _(sym,string) string,
64 EXPORT_NEXT_VXLAN_GPE_INPUT,
69 copy3cachelines (void *dst, const void *src, size_t n)
72 if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
74 /* Copy only the first 1/2 cache lines whatever is available */
76 clib_mov64 ((u8 *) dst, (const u8 *) src);
78 clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
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);
87 u64 *copy_dst, *copy_src;
89 copy_dst = (u64 *) dst;
90 copy_src = (u64 *) src;
91 if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
93 for (i = 0; i < n / 64; i++)
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];
108 for (i = 0; i < 3; i++)
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];
125 vxlan_gpe_export_fixup_func (vlib_buffer_t * export_buf,
126 vlib_buffer_t * pak_buf)
128 /* Todo: on implementing VXLAN GPE analyse */
132 vxlan_gpe_export_node_fn (vlib_main_t * vm,
133 vlib_node_runtime_t * node, vlib_frame_t * frame)
135 ioam_export_main_t *em = &vxlan_gpe_ioam_export_main;
136 ioam_export_node_common (em, vm, node, frame, ip4_header_t, length,
137 ip_version_and_header_length,
138 EXPORT_NEXT_VXLAN_GPE_INPUT,
139 vxlan_gpe_export_fixup_func);
140 return frame->n_vectors;
144 * Node for VXLAN-GPE export
147 VLIB_REGISTER_NODE (vxlan_export_node) =
149 .function = vxlan_gpe_export_node_fn,
150 .name = "vxlan-gpe-ioam-export",
151 .vector_size = sizeof (u32),
152 .format_trace = format_export_trace,
153 .type = VLIB_NODE_TYPE_INTERNAL,
154 .n_errors = ARRAY_LEN (export_error_strings),
155 .error_strings = export_error_strings,
156 .n_next_nodes = EXPORT_N_NEXT,
157 /* edit / add dispositions here */
159 {[EXPORT_NEXT_VXLAN_GPE_INPUT] = "vxlan-gpe-pop-ioam-v4"},
164 * fd.io coding-style-patch-verification: ON
167 * eval: (c-set-style "gnu")