summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorMohammed Hawari <mohammed@hawari.fr>2020-12-18 16:29:45 +0100
committerDamjan Marion <dmarion@me.com>2021-01-22 09:06:15 +0000
commit85c1943e521a5c1289ee19d49d8e41012f8b7a99 (patch)
treed50aba5c637fcbe6a982ff655d9db013ad78cd6e /src/vnet/devices
parent313380f9501ad36637d32dd9801a75c1b668fdc3 (diff)
devices: adapt af_packet to new rxq framework
Change-Id: If8077280cef501599f810ad9255efa2a5a451ced Signed-off-by: Mohammed Hawari <mohammed@hawari.fr> Type: improvement
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c42
-rw-r--r--src/vnet/devices/af_packet/af_packet.h1
-rw-r--r--src/vnet/devices/af_packet/node.c21
3 files changed, 32 insertions, 32 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index 31d4df0c0e3..ba6bf3d5a46 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -31,6 +31,7 @@
#include <vlib/unix/unix.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/interface/rx_queue_funcs.h>
#include <vnet/devices/af_packet/af_packet.h>
@@ -99,8 +100,7 @@ af_packet_fd_read_ready (clib_file_t * uf)
clib_bitmap_set (apm->pending_input_bitmap, idx, 1);
/* Schedule the rx node */
- vnet_device_input_set_interrupt_pending (vnm, apif->hw_if_index, 0);
-
+ vnet_hw_if_rx_queue_set_int_pending (vnm, apif->queue_index);
return 0;
}
@@ -341,17 +341,6 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
if (tm->n_vlib_mains > 1)
clib_spinlock_init (&apif->lockp);
- {
- clib_file_t template = { 0 };
- template.read_function = af_packet_fd_read_ready;
- template.file_descriptor = fd;
- template.private_data = if_index;
- template.flags = UNIX_FILE_EVENT_EDGE_TRIGGERED;
- template.description = format (0, "%U", format_af_packet_device_name,
- if_index);
- apif->clib_file_index = clib_file_add (&file_main, &template);
- }
-
/*use configured or generate random MAC address */
if (hw_addr_set)
clib_memcpy (hw_addr, hw_addr_set, 6);
@@ -385,18 +374,30 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
sw = vnet_get_hw_sw_interface (vnm, apif->hw_if_index);
hw = vnet_get_hw_interface (vnm, apif->hw_if_index);
apif->sw_if_index = sw->sw_if_index;
- vnet_hw_interface_set_input_node (vnm, apif->hw_if_index,
- af_packet_input_node.index);
-
- vnet_hw_interface_assign_rx_thread (vnm, apif->hw_if_index, 0, /* queue */
- ~0 /* any cpu */ );
+ vnet_hw_if_set_input_node (vnm, apif->hw_if_index,
+ af_packet_input_node.index);
+ apif->queue_index = vnet_hw_if_register_rx_queue (vnm, apif->hw_if_index, 0,
+ VNET_HW_IF_RXQ_THREAD_ANY);
hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE;
vnet_hw_interface_set_flags (vnm, apif->hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
- vnet_hw_interface_set_rx_mode (vnm, apif->hw_if_index, 0,
- VNET_HW_IF_RX_MODE_INTERRUPT);
+ vnet_hw_if_set_rx_queue_mode (vnm, apif->queue_index,
+ VNET_HW_IF_RX_MODE_INTERRUPT);
+ vnet_hw_if_update_runtime_data (vnm, apif->hw_if_index);
+ {
+ clib_file_t template = { 0 };
+ template.read_function = af_packet_fd_read_ready;
+ template.file_descriptor = fd;
+ template.private_data = if_index;
+ template.flags = UNIX_FILE_EVENT_EDGE_TRIGGERED;
+ template.description =
+ format (0, "%U", format_af_packet_device_name, if_index);
+ apif->clib_file_index = clib_file_add (&file_main, &template);
+ }
+ vnet_hw_if_set_rx_queue_file_index (vnm, apif->queue_index,
+ apif->clib_file_index);
mhash_set_mem (&apm->if_index_by_host_if_name, host_if_name_dup, &if_index,
0);
@@ -439,7 +440,6 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
/* bring down the interface */
vnet_hw_interface_set_flags (vnm, apif->hw_if_index, 0);
- vnet_hw_interface_unassign_rx_thread (vnm, apif->hw_if_index, 0);
/* clean up */
if (apif->clib_file_index != ~0)
diff --git a/src/vnet/devices/af_packet/af_packet.h b/src/vnet/devices/af_packet/af_packet.h
index b4621f6f6d4..395f2d93fdf 100644
--- a/src/vnet/devices/af_packet/af_packet.h
+++ b/src/vnet/devices/af_packet/af_packet.h
@@ -47,6 +47,7 @@ typedef struct
u32 per_interface_next_index;
u8 is_admin_up;
+ u32 queue_index;
} af_packet_if_t;
typedef struct
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 61d4ce2d1f5..d444b3b6eea 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -23,7 +23,7 @@
#include <vlib/unix/unix.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/devices.h>
+#include <vnet/interface/rx_queue_funcs.h>
#include <vnet/feature/feature.h>
#include <vnet/ethernet/packet.h>
@@ -352,16 +352,15 @@ VLIB_NODE_FN (af_packet_input_node) (vlib_main_t * vm,
{
u32 n_rx_packets = 0;
af_packet_main_t *apm = &af_packet_main;
- vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
- vnet_device_and_queue_t *dq;
-
- foreach_device_and_queue (dq, rt->devices_and_queues)
- {
- af_packet_if_t *apif;
- apif = vec_elt_at_index (apm->interfaces, dq->dev_instance);
- if (apif->is_admin_up)
- n_rx_packets += af_packet_device_input_fn (vm, node, frame, apif);
- }
+ vnet_hw_if_rxq_poll_vector_t *pv;
+ pv = vnet_hw_if_get_rxq_poll_vector (vm, node);
+ for (int i = 0; i < vec_len (pv); i++)
+ {
+ af_packet_if_t *apif;
+ apif = vec_elt_at_index (apm->interfaces, pv[i].dev_instance);
+ if (apif->is_admin_up)
+ n_rx_packets += af_packet_device_input_fn (vm, node, frame, apif);
+ }
return n_rx_packets;
}