FD.io VPP  v17.04-9-g99c0734
Vector Packet Processing
devices.h
Go to the documentation of this file.
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 #ifndef included_vnet_vnet_device_h
17 #define included_vnet_vnet_device_h
18 
19 #include <vnet/unix/pcap.h>
20 #include <vnet/l3_types.h>
21 
22 typedef enum
23 {
32 
33 #define VNET_DEVICE_INPUT_NEXT_NODES { \
34  [VNET_DEVICE_INPUT_NEXT_DROP] = "error-drop", \
35  [VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input", \
36  [VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT] = "ip4-input-no-checksum", \
37  [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = "ip4-input", \
38  [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = "ip6-input", \
39  [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = "mpls-input", \
40 }
41 
42 typedef struct
43 {
44  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
45 
46  /* total input packet counter */
49 
50 typedef struct
51 {
57 
58 typedef struct
59 {
64 
65 typedef struct
66 {
69 
72 extern const u32 device_input_next_node_advance[];
73 
74 static inline void
75 vnet_set_device_input_node (u32 hw_if_index, u32 node_index)
76 {
77  vnet_main_t *vnm = vnet_get_main ();
78  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
79  hw->input_node_index = node_index;
80 }
81 
82 void vnet_device_input_assign_thread (u32 hw_if_index, u16 queue_id,
83  uword cpu_index);
84 
85 static inline u64
87 {
89  u64 sum = 0;
91 
92  vec_foreach (pwd, vdm->workers) sum += pwd->aggregate_rx_packets;
93 
94  return sum;
95 }
96 
97 static inline void
99 {
102 
103  pwd = vec_elt_at_index (vdm->workers, cpu_index);
104  pwd->aggregate_rx_packets += count;
105 }
106 
109 {
110  vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
111  return rt->devices_and_queues;
112 }
113 
116  u16 queue_id)
117 {
118  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
119 
120  ASSERT (queue_id < vec_len (hw->input_node_cpu_index_by_queue));
121  u32 cpu_index = hw->input_node_cpu_index_by_queue[queue_id];
123  hw->input_node_index);
124 }
125 
126 #endif /* included_vnet_vnet_device_h */
127 
128 /*
129  * fd.io coding-style-patch-verification: ON
130  *
131  * Local Variables:
132  * eval: (c-set-style "gnu")
133  * End:
134  */
vlib_node_registration_t device_input_node
(constructor) VLIB_REGISTER_NODE (device_input_node)
Definition: devices.c:32
vnet_device_and_queue_t * devices_and_queues
Definition: devices.h:67
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:68
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:463
static u64 vnet_get_aggregate_rx_packets(void)
Definition: devices.h:86
uword first_worker_cpu_index
Definition: devices.h:53
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
Definition: node_funcs.h:181
PCAP utility definitions.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_device_per_worker_data_t * workers
Definition: devices.h:52
struct _vlib_node_registration vlib_node_registration_t
static_always_inline vnet_device_and_queue_t * vnet_get_device_and_queue(vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: devices.h:108
vlib_main_t ** vlib_mains
Definition: buffer.c:285
static void vnet_device_increment_rx_packets(u32 cpu_index, u64 count)
Definition: devices.h:98
#define static_always_inline
Definition: clib.h:85
static_always_inline void vnet_device_input_set_interrupt_pending(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
Definition: devices.h:115
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
unsigned long u64
Definition: types.h:89
uword last_worker_cpu_index
Definition: devices.h:54
vnet_device_input_next_t
Definition: devices.h:22
static void vnet_set_device_input_node(u32 hw_if_index, u32 node_index)
Definition: devices.h:75
vlib_main_t * vm
Definition: buffer.c:276
u32 * input_node_cpu_index_by_queue
Definition: interface.h:471
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
uword next_worker_cpu_index
Definition: devices.h:55
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vnet_device_input_assign_thread(u32 hw_if_index, u16 queue_id, uword cpu_index)
Definition: devices.c:106
vnet_device_main_t vnet_device_main
Definition: devices.c:22
#define vec_foreach(var, vec)
Vector iterator.
const u32 device_input_next_node_advance[]
Definition: devices.c:47