devices: vnet_get_aggregate_rx_packets should not be dpdk specific
Change-Id: I1152db4b7d1602653d7d8b2c6cb28cf5c526c4ca
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 476ccca..69fc11c 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -239,6 +239,7 @@
+ VNET_INTERFACE_COUNTER_RX,
os_get_cpu_number (), apif->hw_if_index, n_rx_packets, n_rx_bytes);
+ vnet_device_increment_rx_packets (cpu_index, n_rx_packets);
return n_rx_packets;
}
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index cd4386e..c81043c 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -19,6 +19,8 @@
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
+vnet_device_main_t vnet_device_main;
+
static uword
device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
@@ -82,6 +84,18 @@
};
/* *INDENT-ON* */
+static clib_error_t *
+vnet_device_init (vlib_main_t * vm)
+{
+ vnet_device_main_t *vdm = &vnet_device_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+
+ vec_validate_aligned (vdm->workers, tm->n_vlib_mains - 1,
+ CLIB_CACHE_LINE_BYTES);
+ return 0;
+}
+
+VLIB_INIT_FUNCTION (vnet_device_init);
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/devices/devices.h b/src/vnet/devices/devices.h
index c46dab9..a5cbc35 100644
--- a/src/vnet/devices/devices.h
+++ b/src/vnet/devices/devices.h
@@ -39,9 +39,45 @@
[VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = "mpls-input", \
}
+typedef struct
+{
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+
+ /* total input packet counter */
+ u64 aggregate_rx_packets;
+} vnet_device_per_worker_data_t;
+
+typedef struct
+{
+ vnet_device_per_worker_data_t *workers;
+} vnet_device_main_t;
+
+extern vnet_device_main_t vnet_device_main;
extern vlib_node_registration_t device_input_node;
extern const u32 device_input_next_node_advance[];
+static inline u64
+vnet_get_aggregate_rx_packets (void)
+{
+ vnet_device_main_t *vdm = &vnet_device_main;
+ u64 sum = 0;
+ vnet_device_per_worker_data_t *pwd;
+
+ vec_foreach (pwd, vdm->workers) sum += pwd->aggregate_rx_packets;
+
+ return sum;
+}
+
+static inline void
+vnet_device_increment_rx_packets (u32 cpu_index, u64 count)
+{
+ vnet_device_main_t *vdm = &vnet_device_main;
+ vnet_device_per_worker_data_t *pwd;
+
+ pwd = vec_elt_at_index (vdm->workers, cpu_index);
+ pwd->aggregate_rx_packets += count;
+}
+
#endif /* included_vnet_vnet_device_h */
/*
diff --git a/src/vnet/devices/dpdk/dpdk.h b/src/vnet/devices/dpdk/dpdk.h
index 79c694f..bf9f276 100644
--- a/src/vnet/devices/dpdk/dpdk.h
+++ b/src/vnet/devices/dpdk/dpdk.h
@@ -225,22 +225,6 @@
typedef struct
{
- CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
-
- /* total input packet counter */
- u64 aggregate_rx_packets;
-} dpdk_worker_t;
-
-typedef struct
-{
- CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
-
- /* total input packet counter */
- u64 aggregate_rx_packets;
-} dpdk_hqos_thread_t;
-
-typedef struct
-{
u32 device;
u16 queue_id;
} dpdk_device_and_queue_t;
@@ -360,12 +344,6 @@
/* vlib buffer free list, must be same size as an rte_mbuf */
u32 vlib_buffer_free_list_index;
- /* dpdk worker "threads" */
- dpdk_worker_t *workers;
-
- /* dpdk HQoS "threads" */
- dpdk_hqos_thread_t *hqos_threads;
-
/* Ethernet input node index */
u32 ethernet_input_node_index;
@@ -475,18 +453,6 @@
void dpdk_device_lock_init (dpdk_device_t * xd);
void dpdk_device_lock_free (dpdk_device_t * xd);
-static inline u64
-vnet_get_aggregate_rx_packets (void)
-{
- dpdk_main_t *dm = &dpdk_main;
- u64 sum = 0;
- dpdk_worker_t *dw;
-
- vec_foreach (dw, dm->workers) sum += dw->aggregate_rx_packets;
-
- return sum;
-}
-
void dpdk_rx_trace (dpdk_main_t * dm,
vlib_node_runtime_t * node,
dpdk_device_t * xd,
diff --git a/src/vnet/devices/dpdk/init.c b/src/vnet/devices/dpdk/init.c
index f470013..29423e1 100755
--- a/src/vnet/devices/dpdk/init.c
+++ b/src/vnet/devices/dpdk/init.c
@@ -277,9 +277,6 @@
vec_validate_aligned (dm->devices_by_cpu, tm->n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
- vec_validate_aligned (dm->workers, tm->n_vlib_mains - 1,
- CLIB_CACHE_LINE_BYTES);
-
dm->hqos_cpu_first_index = 0;
dm->hqos_cpu_count = 0;
@@ -296,9 +293,6 @@
vec_validate_aligned (dm->devices_by_hqos_cpu, tm->n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
- vec_validate_aligned (dm->hqos_threads, tm->n_vlib_mains - 1,
- CLIB_CACHE_LINE_BYTES);
-
nports = rte_eth_dev_count ();
if (nports < 1)
{
@@ -1756,8 +1750,6 @@
STATIC_ASSERT (offsetof (dpdk_device_t, cacheline1) ==
CLIB_CACHE_LINE_BYTES,
"Data in cache line 0 is bigger than cache line size");
- STATIC_ASSERT (offsetof (dpdk_worker_t, cacheline0) == 0,
- "Cache line marker must be 1st element in dpdk_worker_t");
STATIC_ASSERT (offsetof (frame_queue_trace_t, cacheline0) == 0,
"Cache line marker must be 1st element in frame_queue_trace_t");
diff --git a/src/vnet/devices/dpdk/node.c b/src/vnet/devices/dpdk/node.c
index bde9dfa..0d64ae0 100644
--- a/src/vnet/devices/dpdk/node.c
+++ b/src/vnet/devices/dpdk/node.c
@@ -556,8 +556,7 @@
+ VNET_INTERFACE_COUNTER_RX,
cpu_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
- dpdk_worker_t *dw = vec_elt_at_index (dm->workers, cpu_index);
- dw->aggregate_rx_packets += mb_index;
+ vnet_device_increment_rx_packets (cpu_index, mb_index);
return mb_index;
}
diff --git a/src/vnet/devices/netmap/node.c b/src/vnet/devices/netmap/node.c
index 19895e4..835209a 100644
--- a/src/vnet/devices/netmap/node.c
+++ b/src/vnet/devices/netmap/node.c
@@ -249,6 +249,8 @@
+ VNET_INTERFACE_COUNTER_RX,
os_get_cpu_number (), nif->hw_if_index, n_rx_packets, n_rx_bytes);
+ vnet_device_increment_rx_packets (cpu_index, n_rx_packets);
+
return n_rx_packets;
}
diff --git a/src/vnet/devices/ssvm/node.c b/src/vnet/devices/ssvm/node.c
index 3a695b1..a6c9dfd 100644
--- a/src/vnet/devices/ssvm/node.c
+++ b/src/vnet/devices/ssvm/node.c
@@ -287,6 +287,8 @@
+ VNET_INTERFACE_COUNTER_RX, cpu_index,
intfc->vlib_hw_if_index, rx_queue_index, n_rx_bytes);
+ vnet_device_increment_rx_packets (cpu_index, rx_queue_index);
+
return rx_queue_index;
}
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index c43f6e6..f490f0c 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -1819,6 +1819,8 @@
+ VNET_INTERFACE_COUNTER_RX,
os_get_cpu_number (), vui->sw_if_index, n_rx_packets, n_rx_bytes);
+ vnet_device_increment_rx_packets (cpu_index, n_rx_packets);
+
return n_rx_packets;
}
diff --git a/src/vpp/api/gmon.c b/src/vpp/api/gmon.c
index 20deb6a..b28608f 100644
--- a/src/vpp/api/gmon.c
+++ b/src/vpp/api/gmon.c
@@ -59,17 +59,9 @@
} gmon_main_t;
-#if DPDK == 0
-static inline u64
-vnet_get_aggregate_rx_packets (void)
-{
- return 0;
-}
-#else
#include <vlib/vlib.h>
#include <vnet/vnet.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#endif
+#include <vnet/devices/devices.h>
gmon_main_t gmon_main;