blob: a5cbc35e682cbd53ed26c2f89ca5b73a768798a7 [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
19#include <vnet/unix/pcap.h>
20#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,
30 VNET_DEVICE_INPUT_N_NEXT_NODES,
31} vnet_device_input_next_t;
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", \
John Loa60d4cb2016-12-17 03:09:58 -050036 [VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT] = "ip4-input-no-checksum", \
37 [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = "ip4-input", \
Damjan Marion8bdc63b2016-11-02 14:48:21 +010038 [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = "ip6-input", \
39 [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = "mpls-input", \
40}
41
Damjan Marionb3bb1012017-02-28 21:55:28 +010042typedef struct
43{
44 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
45
46 /* total input packet counter */
47 u64 aggregate_rx_packets;
48} vnet_device_per_worker_data_t;
49
50typedef struct
51{
52 vnet_device_per_worker_data_t *workers;
53} vnet_device_main_t;
54
55extern vnet_device_main_t vnet_device_main;
Damjan Marion51327ac2016-11-09 11:59:42 +010056extern vlib_node_registration_t device_input_node;
Damjan Marion7dc41462016-11-15 19:47:58 +010057extern const u32 device_input_next_node_advance[];
Damjan Marion51327ac2016-11-09 11:59:42 +010058
Damjan Marionb3bb1012017-02-28 21:55:28 +010059static inline u64
60vnet_get_aggregate_rx_packets (void)
61{
62 vnet_device_main_t *vdm = &vnet_device_main;
63 u64 sum = 0;
64 vnet_device_per_worker_data_t *pwd;
65
66 vec_foreach (pwd, vdm->workers) sum += pwd->aggregate_rx_packets;
67
68 return sum;
69}
70
71static inline void
72vnet_device_increment_rx_packets (u32 cpu_index, u64 count)
73{
74 vnet_device_main_t *vdm = &vnet_device_main;
75 vnet_device_per_worker_data_t *pwd;
76
77 pwd = vec_elt_at_index (vdm->workers, cpu_index);
78 pwd->aggregate_rx_packets += count;
79}
80
Damjan Marion8bdc63b2016-11-02 14:48:21 +010081#endif /* included_vnet_vnet_device_h */
82
83/*
84 * fd.io coding-style-patch-verification: ON
85 *
86 * Local Variables:
87 * eval: (c-set-style "gnu")
88 * End:
89 */