Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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 | |
Damjan Marion | 7dc4146 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 16 | #include <vnet/vnet.h> |
Damjan Marion | 51327ac | 2016-11-09 11:59:42 +0100 | [diff] [blame] | 17 | #include <vnet/devices/devices.h> |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 18 | #include <vnet/feature/feature.h> |
Damjan Marion | 7dc4146 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 19 | #include <vnet/ip/ip.h> |
| 20 | #include <vnet/ethernet/ethernet.h> |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 21 | |
Damjan Marion | b3bb101 | 2017-02-28 21:55:28 +0100 | [diff] [blame] | 22 | vnet_device_main_t vnet_device_main; |
| 23 | |
Damjan Marion | 51327ac | 2016-11-09 11:59:42 +0100 | [diff] [blame] | 24 | static uword |
| 25 | device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 26 | vlib_frame_t * frame) |
| 27 | { |
| 28 | return 0; |
| 29 | } |
| 30 | |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 31 | /* *INDENT-OFF* */ |
Damjan Marion | 51327ac | 2016-11-09 11:59:42 +0100 | [diff] [blame] | 32 | VLIB_REGISTER_NODE (device_input_node) = { |
| 33 | .function = device_input_fn, |
| 34 | .name = "device-input", |
| 35 | .type = VLIB_NODE_TYPE_INPUT, |
| 36 | .state = VLIB_NODE_STATE_DISABLED, |
| 37 | .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, |
| 38 | .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, |
| 39 | }; |
| 40 | |
Damjan Marion | 7dc4146 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 41 | /* Table defines how much we need to advance current data pointer |
| 42 | in the buffer if we shortcut to l3 nodes */ |
| 43 | |
| 44 | const u32 __attribute__((aligned (CLIB_CACHE_LINE_BYTES))) |
| 45 | device_input_next_node_advance[((VNET_DEVICE_INPUT_N_NEXT_NODES / |
| 46 | CLIB_CACHE_LINE_BYTES) +1) * CLIB_CACHE_LINE_BYTES] = |
| 47 | { |
| 48 | [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = sizeof (ethernet_header_t), |
Sergio Gonzalez Monroy | 767b2f5 | 2016-12-20 15:20:32 +0000 | [diff] [blame] | 49 | [VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT] = sizeof (ethernet_header_t), |
Damjan Marion | 7dc4146 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 50 | [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = sizeof (ethernet_header_t), |
| 51 | [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = sizeof (ethernet_header_t), |
| 52 | }; |
| 53 | |
Dave Barach | 9f6186e | 2016-11-08 12:12:12 -0500 | [diff] [blame] | 54 | VNET_FEATURE_ARC_INIT (device_input, static) = |
| 55 | { |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 56 | .arc_name = "device-input", |
Damjan Marion | 51327ac | 2016-11-09 11:59:42 +0100 | [diff] [blame] | 57 | .start_nodes = VNET_FEATURES ("device-input"), |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 58 | .arc_index_ptr = &feature_main.device_input_feature_arc_index, |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | VNET_FEATURE_INIT (l2_patch, static) = { |
| 62 | .arc_name = "device-input", |
| 63 | .node_name = "l2-patch", |
| 64 | .runs_before = VNET_FEATURES ("ethernet-input"), |
| 65 | }; |
| 66 | |
| 67 | VNET_FEATURE_INIT (worker_handoff, static) = { |
| 68 | .arc_name = "device-input", |
| 69 | .node_name = "worker-handoff", |
| 70 | .runs_before = VNET_FEATURES ("ethernet-input"), |
| 71 | }; |
| 72 | |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 73 | VNET_FEATURE_INIT (span_input, static) = { |
| 74 | .arc_name = "device-input", |
| 75 | .node_name = "span-input", |
| 76 | .runs_before = VNET_FEATURES ("ethernet-input"), |
| 77 | }; |
| 78 | |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 79 | VNET_FEATURE_INIT (ethernet_input, static) = { |
| 80 | .arc_name = "device-input", |
| 81 | .node_name = "ethernet-input", |
| 82 | .runs_before = 0, /* not before any other features */ |
| 83 | }; |
| 84 | /* *INDENT-ON* */ |
| 85 | |
Damjan Marion | b3bb101 | 2017-02-28 21:55:28 +0100 | [diff] [blame] | 86 | static clib_error_t * |
| 87 | vnet_device_init (vlib_main_t * vm) |
| 88 | { |
| 89 | vnet_device_main_t *vdm = &vnet_device_main; |
| 90 | vlib_thread_main_t *tm = vlib_get_thread_main (); |
| 91 | |
| 92 | vec_validate_aligned (vdm->workers, tm->n_vlib_mains - 1, |
| 93 | CLIB_CACHE_LINE_BYTES); |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | VLIB_INIT_FUNCTION (vnet_device_init); |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 98 | /* |
| 99 | * fd.io coding-style-patch-verification: ON |
| 100 | * |
| 101 | * Local Variables: |
| 102 | * eval: (c-set-style "gnu") |
| 103 | * End: |
| 104 | */ |