Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 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 | |
| 16 | #include <vlib/vlib.h> |
| 17 | #include <vnet/vnet.h> |
| 18 | #include <vppinfra/error.h> |
| 19 | |
| 20 | #include <vnet/span/span.h> |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 21 | #include <vnet/l2/l2_input.h> |
| 22 | #include <vnet/l2/l2_output.h> |
| 23 | #include <vnet/l2/feat_bitmap.h> |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 24 | |
| 25 | #include <vppinfra/error.h> |
| 26 | #include <vppinfra/elog.h> |
| 27 | |
| 28 | vlib_node_registration_t span_node; |
| 29 | |
| 30 | /* packet trace format function */ |
| 31 | u8 * |
| 32 | format_span_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 | span_trace_t *t = va_arg (*args, span_trace_t *); |
| 37 | |
| 38 | vnet_main_t *vnm = &vnet_main; |
| 39 | s = format (s, "SPAN: mirrored %U -> %U", |
| 40 | format_vnet_sw_if_index_name, vnm, t->src_sw_if_index, |
| 41 | format_vnet_sw_if_index_name, vnm, t->mirror_sw_if_index); |
| 42 | |
| 43 | return s; |
| 44 | } |
| 45 | |
| 46 | #define foreach_span_error \ |
| 47 | _(HITS, "SPAN incomming packets processed") |
| 48 | |
| 49 | typedef enum |
| 50 | { |
| 51 | #define _(sym,str) SPAN_ERROR_##sym, |
| 52 | foreach_span_error |
| 53 | #undef _ |
| 54 | SPAN_N_ERROR, |
| 55 | } span_error_t; |
| 56 | |
| 57 | static char *span_error_strings[] = { |
| 58 | #define _(sym,string) string, |
| 59 | foreach_span_error |
| 60 | #undef _ |
| 61 | }; |
| 62 | |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 63 | static_always_inline void |
Pavel Kotucek | 077d6ae | 2017-01-24 08:33:38 +0100 | [diff] [blame] | 64 | span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0, |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 65 | vlib_buffer_t * b0, vlib_frame_t ** mirror_frames, |
| 66 | vlib_rx_or_tx_t rxtx, span_feat_t sf) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 67 | { |
| 68 | vlib_buffer_t *c0; |
Pavel Kotucek | 077d6ae | 2017-01-24 08:33:38 +0100 | [diff] [blame] | 69 | span_main_t *sm = &span_main; |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 70 | vnet_main_t *vnm = &vnet_main; |
| 71 | u32 *to_mirror_next = 0; |
| 72 | u32 i; |
| 73 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 74 | span_interface_t *si0 = vec_elt_at_index (sm->interfaces, sw_if_index0); |
| 75 | span_mirror_t *sm0 = &si0->mirror_rxtx[sf][rxtx]; |
Pavel Kotucek | 077d6ae | 2017-01-24 08:33:38 +0100 | [diff] [blame] | 76 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 77 | if (sm0->num_mirror_ports == 0) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 78 | return; |
| 79 | |
| 80 | /* Don't do it again */ |
Damjan Marion | 213b5aa | 2017-07-13 21:19:27 +0200 | [diff] [blame] | 81 | if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_SPAN_CLONE)) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 82 | return; |
| 83 | |
| 84 | /* *INDENT-OFF* */ |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 85 | clib_bitmap_foreach (i, sm0->mirror_ports, ( |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 86 | { |
| 87 | if (mirror_frames[i] == 0) |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 88 | { |
| 89 | if (sf == SPAN_FEAT_L2) |
| 90 | mirror_frames[i] = vlib_get_frame_to_node (vnm->vlib_main, l2output_node.index); |
| 91 | else |
| 92 | mirror_frames[i] = vnet_get_frame_to_sw_interface (vnm, i); |
| 93 | } |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 94 | to_mirror_next = vlib_frame_vector_args (mirror_frames[i]); |
| 95 | to_mirror_next += mirror_frames[i]->n_vectors; |
Dave Barach | 26cd8c1 | 2017-02-23 17:11:26 -0500 | [diff] [blame] | 96 | /* This can fail */ |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 97 | c0 = vlib_buffer_copy (vm, b0); |
Dave Barach | 26cd8c1 | 2017-02-23 17:11:26 -0500 | [diff] [blame] | 98 | if (PREDICT_TRUE(c0 != 0)) |
| 99 | { |
| 100 | vnet_buffer (c0)->sw_if_index[VLIB_TX] = i; |
Damjan Marion | 213b5aa | 2017-07-13 21:19:27 +0200 | [diff] [blame] | 101 | c0->flags |= VNET_BUFFER_F_SPAN_CLONE; |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 102 | if (sf == SPAN_FEAT_L2) |
| 103 | vnet_buffer (c0)->l2.feature_bitmap = L2OUTPUT_FEAT_OUTPUT; |
Dave Barach | 26cd8c1 | 2017-02-23 17:11:26 -0500 | [diff] [blame] | 104 | to_mirror_next[0] = vlib_get_buffer_index (vm, c0); |
| 105 | mirror_frames[i]->n_vectors++; |
Pavel Kotucek | 077d6ae | 2017-01-24 08:33:38 +0100 | [diff] [blame] | 106 | if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) |
| 107 | { |
| 108 | span_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 109 | t->src_sw_if_index = sw_if_index0; |
| 110 | t->mirror_sw_if_index = i; |
| 111 | } |
Dave Barach | 26cd8c1 | 2017-02-23 17:11:26 -0500 | [diff] [blame] | 112 | } |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 113 | })); |
| 114 | /* *INDENT-ON* */ |
| 115 | } |
| 116 | |
| 117 | static_always_inline uword |
| 118 | span_node_inline_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 119 | vlib_frame_t * frame, vlib_rx_or_tx_t rxtx, |
| 120 | span_feat_t sf) |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 121 | { |
| 122 | span_main_t *sm = &span_main; |
| 123 | vnet_main_t *vnm = &vnet_main; |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 124 | u32 n_left_from, *from, *to_next; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 125 | u32 n_span_packets = 0; |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 126 | u32 next_index; |
| 127 | u32 sw_if_index; |
| 128 | static __thread vlib_frame_t **mirror_frames = 0; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 129 | |
| 130 | from = vlib_frame_vector_args (frame); |
| 131 | n_left_from = frame->n_vectors; |
| 132 | next_index = node->cached_next_index; |
| 133 | |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 134 | vec_validate_aligned (mirror_frames, sm->max_sw_if_index, |
| 135 | CLIB_CACHE_LINE_BYTES); |
| 136 | |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 137 | while (n_left_from > 0) |
| 138 | { |
| 139 | u32 n_left_to_next; |
| 140 | |
| 141 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
| 142 | |
| 143 | while (n_left_from >= 4 && n_left_to_next >= 2) |
| 144 | { |
| 145 | u32 bi0; |
| 146 | u32 bi1; |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 147 | vlib_buffer_t *b0; |
| 148 | vlib_buffer_t *b1; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 149 | u32 sw_if_index0; |
Pavel Kotucek | e2e95ce | 2016-11-29 11:03:37 +0100 | [diff] [blame] | 150 | u32 next0 = 0; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 151 | u32 sw_if_index1; |
Pavel Kotucek | e2e95ce | 2016-11-29 11:03:37 +0100 | [diff] [blame] | 152 | u32 next1 = 0; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 153 | |
| 154 | /* speculatively enqueue b0, b1 to the current next frame */ |
| 155 | to_next[0] = bi0 = from[0]; |
| 156 | to_next[1] = bi1 = from[1]; |
| 157 | to_next += 2; |
| 158 | n_left_to_next -= 2; |
| 159 | from += 2; |
| 160 | n_left_from -= 2; |
| 161 | |
| 162 | b0 = vlib_get_buffer (vm, bi0); |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 163 | b1 = vlib_get_buffer (vm, bi1); |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 164 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[rxtx]; |
| 165 | sw_if_index1 = vnet_buffer (b1)->sw_if_index[rxtx]; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 166 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 167 | span_mirror (vm, node, sw_if_index0, b0, mirror_frames, rxtx, sf); |
| 168 | span_mirror (vm, node, sw_if_index1, b1, mirror_frames, rxtx, sf); |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 169 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 170 | switch (sf) |
| 171 | { |
| 172 | case SPAN_FEAT_L2: |
| 173 | if (rxtx == VLIB_RX) |
| 174 | { |
| 175 | next0 = vnet_l2_feature_next (b0, sm->l2_input_next, |
| 176 | L2INPUT_FEAT_SPAN); |
| 177 | next1 = vnet_l2_feature_next (b1, sm->l2_input_next, |
| 178 | L2INPUT_FEAT_SPAN); |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | next0 = vnet_l2_feature_next (b0, sm->l2_output_next, |
| 183 | L2OUTPUT_FEAT_SPAN); |
| 184 | next1 = vnet_l2_feature_next (b1, sm->l2_output_next, |
| 185 | L2OUTPUT_FEAT_SPAN); |
| 186 | } |
| 187 | break; |
| 188 | case SPAN_FEAT_DEVICE: |
| 189 | default: |
| 190 | vnet_feature_next (sw_if_index0, &next0, b0); |
| 191 | vnet_feature_next (sw_if_index1, &next1, b1); |
| 192 | break; |
| 193 | } |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 194 | |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 195 | /* verify speculative enqueue, maybe switch current next frame */ |
| 196 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, |
| 197 | to_next, n_left_to_next, |
| 198 | bi0, bi1, next0, next1); |
| 199 | } |
| 200 | while (n_left_from > 0 && n_left_to_next > 0) |
| 201 | { |
| 202 | u32 bi0; |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 203 | vlib_buffer_t *b0; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 204 | u32 sw_if_index0; |
Pavel Kotucek | e2e95ce | 2016-11-29 11:03:37 +0100 | [diff] [blame] | 205 | u32 next0 = 0; |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 206 | |
| 207 | /* speculatively enqueue b0 to the current next frame */ |
| 208 | to_next[0] = bi0 = from[0]; |
| 209 | to_next += 1; |
| 210 | n_left_to_next -= 1; |
| 211 | from += 1; |
| 212 | n_left_from -= 1; |
| 213 | |
| 214 | b0 = vlib_get_buffer (vm, bi0); |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 215 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[rxtx]; |
Pavel Kotucek | 077d6ae | 2017-01-24 08:33:38 +0100 | [diff] [blame] | 216 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 217 | span_mirror (vm, node, sw_if_index0, b0, mirror_frames, rxtx, sf); |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 218 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 219 | switch (sf) |
| 220 | { |
| 221 | case SPAN_FEAT_L2: |
| 222 | if (rxtx == VLIB_RX) |
| 223 | next0 = vnet_l2_feature_next (b0, sm->l2_input_next, |
| 224 | L2INPUT_FEAT_SPAN); |
| 225 | else |
| 226 | next0 = vnet_l2_feature_next (b0, sm->l2_output_next, |
| 227 | L2OUTPUT_FEAT_SPAN); |
| 228 | break; |
| 229 | case SPAN_FEAT_DEVICE: |
| 230 | default: |
| 231 | vnet_feature_next (sw_if_index0, &next0, b0); |
| 232 | break; |
| 233 | } |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 234 | |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 235 | /* verify speculative enqueue, maybe switch current next frame */ |
| 236 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, |
| 237 | n_left_to_next, bi0, next0); |
| 238 | } |
| 239 | |
| 240 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 241 | } |
| 242 | |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 243 | |
| 244 | for (sw_if_index = 0; sw_if_index < vec_len (mirror_frames); sw_if_index++) |
| 245 | { |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 246 | vlib_frame_t *f = mirror_frames[sw_if_index]; |
| 247 | if (f == 0) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 248 | continue; |
| 249 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 250 | if (sf == SPAN_FEAT_L2) |
| 251 | vlib_put_frame_to_node (vnm->vlib_main, l2output_node.index, f); |
| 252 | else |
| 253 | vnet_put_frame_to_sw_interface (vnm, sw_if_index, f); |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 254 | mirror_frames[sw_if_index] = 0; |
| 255 | } |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 256 | vlib_node_increment_counter (vm, span_node.index, SPAN_ERROR_HITS, |
| 257 | n_span_packets); |
| 258 | |
| 259 | return frame->n_vectors; |
| 260 | } |
| 261 | |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 262 | static uword |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 263 | span_device_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 264 | vlib_frame_t * frame) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 265 | { |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 266 | return span_node_inline_fn (vm, node, frame, VLIB_RX, SPAN_FEAT_DEVICE); |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | static uword |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 270 | span_device_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 271 | vlib_frame_t * frame) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 272 | { |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 273 | return span_node_inline_fn (vm, node, frame, VLIB_TX, SPAN_FEAT_DEVICE); |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 274 | } |
| 275 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 276 | static uword |
| 277 | span_l2_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 278 | vlib_frame_t * frame) |
| 279 | { |
| 280 | return span_node_inline_fn (vm, node, frame, VLIB_RX, SPAN_FEAT_L2); |
| 281 | } |
| 282 | |
| 283 | static uword |
| 284 | span_l2_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 285 | vlib_frame_t * frame) |
| 286 | { |
| 287 | return span_node_inline_fn (vm, node, frame, VLIB_TX, SPAN_FEAT_L2); |
| 288 | } |
| 289 | |
| 290 | #define span_node_defs \ |
| 291 | .vector_size = sizeof (u32), \ |
| 292 | .format_trace = format_span_trace, \ |
| 293 | .type = VLIB_NODE_TYPE_INTERNAL, \ |
| 294 | .n_errors = ARRAY_LEN(span_error_strings), \ |
| 295 | .error_strings = span_error_strings, \ |
| 296 | .n_next_nodes = 0, \ |
| 297 | .next_nodes = { \ |
| 298 | [0] = "error-drop" \ |
| 299 | } |
| 300 | |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 301 | /* *INDENT-OFF* */ |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 302 | VLIB_REGISTER_NODE (span_input_node) = { |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 303 | span_node_defs, |
| 304 | .function = span_device_input_node_fn, |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 305 | .name = "span-input", |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 306 | }; |
| 307 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 308 | VLIB_NODE_FUNCTION_MULTIARCH (span_input_node, span_device_input_node_fn) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 309 | |
| 310 | VLIB_REGISTER_NODE (span_output_node) = { |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 311 | span_node_defs, |
| 312 | .function = span_device_output_node_fn, |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 313 | .name = "span-output", |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 314 | }; |
| 315 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 316 | VLIB_NODE_FUNCTION_MULTIARCH (span_output_node, span_device_output_node_fn) |
Pavel Kotucek | 3a2a1c4 | 2016-12-06 10:10:10 +0100 | [diff] [blame] | 317 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 318 | VLIB_REGISTER_NODE (span_l2_input_node) = { |
| 319 | span_node_defs, |
| 320 | .function = span_l2_input_node_fn, |
| 321 | .name = "span-l2-input", |
| 322 | }; |
| 323 | |
| 324 | VLIB_NODE_FUNCTION_MULTIARCH (span_l2_input_node, span_l2_input_node_fn) |
| 325 | |
| 326 | VLIB_REGISTER_NODE (span_l2_output_node) = { |
| 327 | span_node_defs, |
| 328 | .function = span_l2_output_node_fn, |
| 329 | .name = "span-l2-output", |
| 330 | }; |
| 331 | |
| 332 | VLIB_NODE_FUNCTION_MULTIARCH (span_l2_output_node, span_l2_output_node_fn) |
| 333 | |
| 334 | clib_error_t *span_init (vlib_main_t * vm) |
| 335 | { |
| 336 | span_main_t *sm = &span_main; |
| 337 | |
| 338 | sm->vlib_main = vm; |
| 339 | sm->vnet_main = vnet_get_main (); |
| 340 | |
| 341 | /* Initialize the feature next-node indexes */ |
| 342 | feat_bitmap_init_next_nodes (vm, |
| 343 | span_l2_input_node.index, |
| 344 | L2INPUT_N_FEAT, |
| 345 | l2input_get_feat_names (), |
| 346 | sm->l2_input_next); |
| 347 | |
| 348 | feat_bitmap_init_next_nodes (vm, |
| 349 | span_l2_output_node.index, |
| 350 | L2OUTPUT_N_FEAT, |
| 351 | l2output_get_feat_names (), |
| 352 | sm->l2_output_next); |
| 353 | return 0; |
| 354 | } |
| 355 | |
| 356 | VLIB_INIT_FUNCTION (span_init); |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 357 | /* *INDENT-ON* */ |
| 358 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 359 | #undef span_node_defs |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 360 | /* |
| 361 | * fd.io coding-style-patch-verification: ON |
| 362 | * |
| 363 | * Local Variables: |
| 364 | * eval: (c-set-style "gnu") |
| 365 | * End: |
| 366 | */ |