FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
devices.c
Go to the documentation of this file.
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 
16 #include <vnet/vnet.h>
17 #include <vnet/devices/devices.h>
18 #include <vnet/feature/feature.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/ethernet/ethernet.h>
21 
23 
24 static uword
27 {
28  return 0;
29 }
30 
31 /* *INDENT-OFF* */
33  .function = device_input_fn,
34  .name = "device-input",
35  .runtime_data_bytes = sizeof (vnet_hw_if_rx_node_runtime_t),
37  .state = VLIB_NODE_STATE_DISABLED,
38  .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
39  .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
40 };
41 
42 /* Table defines how much we need to advance current data pointer
43  in the buffer if we shortcut to l3 nodes */
44 
45 const u32 __attribute__((aligned (CLIB_CACHE_LINE_BYTES)))
48 {
53 };
54 
55 const u32 __attribute__((aligned (CLIB_CACHE_LINE_BYTES)))
58 {
59  [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
60  [VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
61  [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
62  [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
63 };
64 
65 VNET_FEATURE_ARC_INIT (device_input, static) =
66 {
67  .arc_name = "device-input",
68  .start_nodes = VNET_FEATURES ("device-input"),
69  .last_in_arc = "ethernet-input",
71 };
72 
73 VNET_FEATURE_INIT (l2_patch, static) = {
74  .arc_name = "device-input",
75  .node_name = "l2-patch",
76  .runs_before = VNET_FEATURES ("ethernet-input"),
77 };
78 
79 VNET_FEATURE_INIT (worker_handoff, static) = {
80  .arc_name = "device-input",
81  .node_name = "worker-handoff",
82  .runs_before = VNET_FEATURES ("ethernet-input"),
83 };
84 
85 VNET_FEATURE_INIT (span_input, static) = {
86  .arc_name = "device-input",
87  .node_name = "span-input",
88  .runs_before = VNET_FEATURES ("ethernet-input"),
89 };
90 
91 VNET_FEATURE_INIT (p2p_ethernet_node, static) = {
92  .arc_name = "device-input",
93  .node_name = "p2p-ethernet-input",
94  .runs_before = VNET_FEATURES ("ethernet-input"),
95 };
96 
97 VNET_FEATURE_INIT (ethernet_input, static) = {
98  .arc_name = "device-input",
99  .node_name = "ethernet-input",
100  .runs_before = 0, /* not before any other features */
101 };
102 /* *INDENT-ON* */
103 
104 static clib_error_t *
106 {
110  uword *p;
111 
114 
115  p = hash_get_mem (tm->thread_registrations_by_name, "workers");
116  tr = p ? (vlib_thread_registration_t *) p[0] : 0;
117  if (tr && tr->count > 0)
118  {
121  vdm->last_worker_thread_index = tr->first_index + tr->count - 1;
122  }
123  return 0;
124 }
125 
127 
128 /*
129  * fd.io coding-style-patch-verification: ON
130  *
131  * Local Variables:
132  * eval: (c-set-style "gnu")
133  * End:
134  */
vnet_device_main_t::last_worker_thread_index
uword last_worker_thread_index
Definition: devices.h:64
vnet_device_main
vnet_device_main_t vnet_device_main
Definition: devices.c:22
device_input_next_node_advance
const u32 device_input_next_node_advance[((VNET_DEVICE_INPUT_N_NEXT_NODES/CLIB_CACHE_LINE_BYTES)+1) *CLIB_CACHE_LINE_BYTES]
Definition: devices.c:47
device_input_node
vlib_node_registration_t device_input_node
(constructor) VLIB_REGISTER_NODE (device_input_node)
Definition: devices.c:32
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
device_input_fn
static uword device_input_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: devices.c:25
vnet_device_init
static clib_error_t * vnet_device_init(vlib_main_t *vm)
Definition: devices.c:105
VLIB_NODE_TYPE_INPUT
@ VLIB_NODE_TYPE_INPUT
Definition: node.h:76
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
vlib_frame_t
Definition: node.h:372
vlib_thread_registration_::count
u32 count
Definition: threads.h:38
ethernet.h
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
feature.h
VNET_DEVICE_INPUT_NEXT_IP6_INPUT
@ VNET_DEVICE_INPUT_NEXT_IP6_INPUT
Definition: devices.h:26
VNET_DEVICE_INPUT_NEXT_IP4_INPUT
@ VNET_DEVICE_INPUT_NEXT_IP4_INPUT
Definition: devices.h:25
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
vnet_device_main_t::workers
vnet_device_per_worker_data_t * workers
Definition: devices.h:62
device_input_next_node_flags
const u32 device_input_next_node_flags[((VNET_DEVICE_INPUT_N_NEXT_NODES/CLIB_CACHE_LINE_BYTES)+1) *CLIB_CACHE_LINE_BYTES]
Definition: devices.c:57
uword
u64 uword
Definition: types.h:112
ethernet_header_t
Definition: packet.h:52
vlib_thread_main_t::thread_registrations_by_name
uword * thread_registrations_by_name
Definition: threads.h:251
vlib_thread_registration_::first_index
u32 first_index
Definition: threads.h:44
VNET_DEVICE_INPUT_NEXT_MPLS_INPUT
@ VNET_DEVICE_INPUT_NEXT_MPLS_INPUT
Definition: devices.h:27
feature_main
vnet_feature_main_t feature_main
Definition: pnat_test_stubs.h:27
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT
@ VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT
Definition: devices.h:24
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
vnet_device_main_t::first_worker_thread_index
uword first_worker_thread_index
Definition: devices.h:63
VNET_DEVICE_INPUT_NEXT_NODES
#define VNET_DEVICE_INPUT_NEXT_NODES
Definition: devices.h:39
vnet_hw_if_rx_node_runtime_t
Definition: interface.h:752
VNET_DEVICE_INPUT_N_NEXT_NODES
@ VNET_DEVICE_INPUT_N_NEXT_NODES
Definition: devices.h:36
ip.h
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vlib_thread_main_t
Definition: threads.h:243
vlib_main_t
Definition: main.h:102
VNET_FEATURES
#define VNET_FEATURES(...)
Definition: feature.h:470
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
VNET_FEATURE_INIT
VNET_FEATURE_INIT(l2_patch, static)
devices.h
vnet.h
vlib_node_runtime_t
Definition: node.h:454
vlib_thread_registration_
Definition: threads.h:27
VNET_FEATURE_ARC_INIT
VNET_FEATURE_ARC_INIT(device_input, static)
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
vnet_device_main_t::next_worker_thread_index
uword next_worker_thread_index
Definition: devices.h:65
vnet_feature_main_t::device_input_feature_arc_index
u8 device_input_feature_arc_index
Feature arc index for device-input.
Definition: feature.h:112
vnet_device_main_t
Definition: devices.h:60
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169