blob: e54c7a29130e7d651f2155d2c90f83acf6813993 [file] [log] [blame]
Damjan Marion8bdc63b2016-11-02 14:48:21 +01001/*
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
Dave Barach3ae28732018-11-16 17:19:00 -050019#include <vppinfra/pcap.h>
Damjan Marion8bdc63b2016-11-02 14:48:21 +010020#include <vnet/l3_types.h>
21
22typedef enum
23{
John Loa60d4cb2016-12-17 03:09:58 -050024 VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT,
Damjan Marion8bdc63b2016-11-02 14:48:21 +010025 VNET_DEVICE_INPUT_NEXT_IP4_INPUT,
26 VNET_DEVICE_INPUT_NEXT_IP6_INPUT,
27 VNET_DEVICE_INPUT_NEXT_MPLS_INPUT,
28 VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT,
29 VNET_DEVICE_INPUT_NEXT_DROP,
Brian Russell7a29a2d2021-02-22 18:42:24 +000030
31 /* For tunnels */
32 VNET_DEVICE_INPUT_NEXT_IP4_DROP,
33 VNET_DEVICE_INPUT_NEXT_IP6_DROP,
34 VNET_DEVICE_INPUT_NEXT_PUNT,
35
Damjan Marion8bdc63b2016-11-02 14:48:21 +010036 VNET_DEVICE_INPUT_N_NEXT_NODES,
37} vnet_device_input_next_t;
38
Brian Russell7a29a2d2021-02-22 18:42:24 +000039#define VNET_DEVICE_INPUT_NEXT_NODES \
40 { \
41 [VNET_DEVICE_INPUT_NEXT_DROP] = "error-drop", \
42 [VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input", \
43 [VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT] = "ip4-input-no-checksum", \
44 [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = "ip4-input", \
45 [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = "ip6-input", \
46 [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = "mpls-input", \
47 [VNET_DEVICE_INPUT_NEXT_IP4_DROP] = "ip4-drop", \
48 [VNET_DEVICE_INPUT_NEXT_IP6_DROP] = "ip6-drop", \
49 [VNET_DEVICE_INPUT_NEXT_PUNT] = "punt-dispatch", \
50 }
Damjan Marion8bdc63b2016-11-02 14:48:21 +010051
Damjan Marionb3bb1012017-02-28 21:55:28 +010052typedef struct
53{
54 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
55
56 /* total input packet counter */
57 u64 aggregate_rx_packets;
58} vnet_device_per_worker_data_t;
59
60typedef struct
61{
62 vnet_device_per_worker_data_t *workers;
Damjan Marion586afd72017-04-05 19:18:20 +020063 uword first_worker_thread_index;
64 uword last_worker_thread_index;
65 uword next_worker_thread_index;
Damjan Marionb3bb1012017-02-28 21:55:28 +010066} vnet_device_main_t;
67
68extern vnet_device_main_t vnet_device_main;
Damjan Marion51327ac2016-11-09 11:59:42 +010069extern vlib_node_registration_t device_input_node;
Damjan Marion7dc41462016-11-15 19:47:58 +010070extern const u32 device_input_next_node_advance[];
Damjan Marionbd846cd2017-11-21 13:12:41 +010071extern const u32 device_input_next_node_flags[];
Damjan Marion51327ac2016-11-09 11:59:42 +010072
Damjan Marionb3bb1012017-02-28 21:55:28 +010073static inline u64
74vnet_get_aggregate_rx_packets (void)
75{
76 vnet_device_main_t *vdm = &vnet_device_main;
77 u64 sum = 0;
78 vnet_device_per_worker_data_t *pwd;
79
80 vec_foreach (pwd, vdm->workers) sum += pwd->aggregate_rx_packets;
81
82 return sum;
83}
84
85static inline void
Damjan Marion586afd72017-04-05 19:18:20 +020086vnet_device_increment_rx_packets (u32 thread_index, u64 count)
Damjan Marionb3bb1012017-02-28 21:55:28 +010087{
88 vnet_device_main_t *vdm = &vnet_device_main;
89 vnet_device_per_worker_data_t *pwd;
90
Damjan Marion586afd72017-04-05 19:18:20 +020091 pwd = vec_elt_at_index (vdm->workers, thread_index);
Damjan Marionb3bb1012017-02-28 21:55:28 +010092 pwd->aggregate_rx_packets += count;
93}
94
Damjan Marion8bdc63b2016-11-02 14:48:21 +010095#endif /* included_vnet_vnet_device_h */
96
97/*
98 * fd.io coding-style-patch-verification: ON
99 *
100 * Local Variables:
101 * eval: (c-set-style "gnu")
102 * End:
103 */