Repair Doxygen build infrastructure
[vpp.git] / src / plugins / ioam / export / node.c
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/ip/ip.h>
20 #include <ioam/export-common/ioam_export.h>
21
22 typedef struct
23 {
24   u32 next_index;
25   u32 flow_label;
26 } export_trace_t;
27
28 /* packet trace format function */
29 static u8 *
30 format_export_trace (u8 * s, va_list * args)
31 {
32   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
33   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
34   export_trace_t *t = va_arg (*args, export_trace_t *);
35
36   s = format (s, "EXPORT: flow_label %d, next index %d",
37               t->flow_label, t->next_index);
38   return s;
39 }
40
41 vlib_node_registration_t export_node;
42
43 #define foreach_export_error \
44 _(RECORDED, "Packets recorded for export")
45
46 typedef enum
47 {
48 #define _(sym,str) EXPORT_ERROR_##sym,
49   foreach_export_error
50 #undef _
51     EXPORT_N_ERROR,
52 } export_error_t;
53
54 static char *export_error_strings[] = {
55 #define _(sym,string) string,
56   foreach_export_error
57 #undef _
58 };
59
60 typedef enum
61 {
62   EXPORT_NEXT_POP_HBYH,
63   EXPORT_N_NEXT,
64 } export_next_t;
65
66 always_inline void
67 copy3cachelines (void *dst, const void *src, size_t n)
68 {
69 #if 0
70   if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
71     {
72       /* Copy only the first 1/2 cache lines whatever is available */
73       if (n >= 64)
74         clib_mov64 ((u8 *) dst, (const u8 *) src);
75       if (n >= 128)
76         clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
77       return;
78     }
79   clib_mov64 ((u8 *) dst, (const u8 *) src);
80   clib_mov64 ((u8 *) dst + 64, (const u8 *) src + 64);
81   clib_mov64 ((u8 *) dst + 128, (const u8 *) src + 128);
82 #endif
83 #if 1
84
85   u64 *copy_dst, *copy_src;
86   int i;
87   copy_dst = (u64 *) dst;
88   copy_src = (u64 *) src;
89   if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
90     {
91       for (i = 0; i < n / 64; i++)
92         {
93           copy_dst[0] = copy_src[0];
94           copy_dst[1] = copy_src[1];
95           copy_dst[2] = copy_src[2];
96           copy_dst[3] = copy_src[3];
97           copy_dst[4] = copy_src[4];
98           copy_dst[5] = copy_src[5];
99           copy_dst[6] = copy_src[6];
100           copy_dst[7] = copy_src[7];
101           copy_dst += 8;
102           copy_src += 8;
103         }
104       return;
105     }
106   for (i = 0; i < 3; i++)
107     {
108       copy_dst[0] = copy_src[0];
109       copy_dst[1] = copy_src[1];
110       copy_dst[2] = copy_src[2];
111       copy_dst[3] = copy_src[3];
112       copy_dst[4] = copy_src[4];
113       copy_dst[5] = copy_src[5];
114       copy_dst[6] = copy_src[6];
115       copy_dst[7] = copy_src[7];
116       copy_dst += 8;
117       copy_src += 8;
118     }
119 #endif
120 }
121
122 static uword
123 ip6_export_node_fn (vlib_main_t * vm,
124                     vlib_node_runtime_t * node, vlib_frame_t * frame)
125 {
126   ioam_export_main_t *em = &ioam_export_main;
127   ioam_export_node_common(em, vm, node, frame, ip6_header_t, payload_length,
128                           ip_version_traffic_class_and_flow_label, 
129                           EXPORT_NEXT_POP_HBYH);
130   return frame->n_vectors;
131 }
132
133 /*
134  * Node for IP6 export
135  */
136 VLIB_REGISTER_NODE (export_node) =
137 {
138   .function = ip6_export_node_fn,
139   .name = "ip6-export",
140   .vector_size = sizeof (u32),
141   .format_trace = format_export_trace,
142   .type = VLIB_NODE_TYPE_INTERNAL,
143   .n_errors = ARRAY_LEN (export_error_strings),
144   .error_strings = export_error_strings,
145   .n_next_nodes = EXPORT_N_NEXT,
146   /* edit / add dispositions here */
147   .next_nodes =
148   {
149     [EXPORT_NEXT_POP_HBYH] = "ip6-pop-hop-by-hop"
150   },
151 };