From 941005336ee8cec614a856089f3d873f7d98135c Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 6 Nov 2020 23:25:57 +0100 Subject: interface: rx queue infra rework, part one Type: improvement Change-Id: I4008cadfd5141f921afbdc09a3ebcd1dcf88eb29 Signed-off-by: Damjan Marion --- src/plugins/avf/avf.h | 1 + src/plugins/avf/device.c | 24 ++++++++++++++++++------ src/plugins/avf/input.c | 25 +++++++++++++------------ 3 files changed, 32 insertions(+), 18 deletions(-) (limited to 'src/plugins/avf') diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h index 025fa6ea4e9..b3fcc259206 100644 --- a/src/plugins/avf/avf.h +++ b/src/plugins/avf/avf.h @@ -164,6 +164,7 @@ typedef struct u16 n_enqueued; u8 int_mode; u8 buffer_pool_index; + u32 queue_index; } avf_rxq_t; typedef struct diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index ffd372d7a56..139f1c99ebb 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -1373,6 +1374,7 @@ avf_irq_n_handler (vlib_main_t * vm, vlib_pci_dev_handle_t h, u16 line) vnet_main_t *vnm = vnet_get_main (); uword pd = vlib_pci_get_private_data (vm, h); avf_device_t *ad = avf_get_device (pd); + avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, line - 1); if (ad->flags & AVF_DEVICE_F_ELOG) { @@ -1396,8 +1398,8 @@ avf_irq_n_handler (vlib_main_t * vm, vlib_pci_dev_handle_t h, u16 line) line--; - if (ad->flags & AVF_DEVICE_F_RX_INT && ad->rxqs[line].int_mode) - vnet_device_input_set_interrupt_pending (vnm, ad->hw_if_index, line); + if (ad->flags & AVF_DEVICE_F_RX_INT && rxq->int_mode) + vnet_hw_if_rx_queue_set_int_pending (vnm, rxq->queue_index); avf_irq_n_set_state (ad, line, AVF_IRQ_STATE_ENABLED); } @@ -1415,7 +1417,6 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier) if (with_barrier) vlib_worker_thread_barrier_sync (vm); vnet_hw_interface_set_flags (vnm, ad->hw_if_index, 0); - vnet_hw_interface_unassign_rx_thread (vnm, ad->hw_if_index, 0); ethernet_delete_interface (vnm, ad->hw_if_index); if (with_barrier) vlib_worker_thread_barrier_release (vm); @@ -1660,11 +1661,22 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, ad->hw_if_index); hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE; - vnet_hw_interface_set_input_node (vnm, ad->hw_if_index, - avf_input_node.index); + vnet_hw_if_set_input_node (vnm, ad->hw_if_index, avf_input_node.index); for (i = 0; i < ad->n_rx_queues; i++) - vnet_hw_interface_assign_rx_thread (vnm, ad->hw_if_index, i, ~0); + { + u32 qi, fi; + qi = vnet_hw_if_register_rx_queue (vnm, ad->hw_if_index, i, + VNET_HW_IF_RXQ_THREAD_ANY); + + if (ad->flags & AVF_DEVICE_F_RX_INT) + { + fi = vlib_pci_get_msix_file_index (vm, ad->pci_dev_handle, i + 1); + vnet_hw_if_set_rx_queue_file_index (vnm, qi, fi); + } + ad->rxqs[i].queue_index = qi; + } + vnet_hw_if_update_runtime_data (vnm, ad->hw_if_index); if (pool_elts (am->devices) == 1) vlib_process_signal_event (vm, avf_process_node.index, diff --git a/src/plugins/avf/input.c b/src/plugins/avf/input.c index 85f97ca3e49..5041f6ef4e7 100644 --- a/src/plugins/avf/input.c +++ b/src/plugins/avf/input.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include @@ -473,17 +473,18 @@ VLIB_NODE_FN (avf_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 n_rx = 0; - 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) - { - avf_device_t *ad; - ad = avf_get_device (dq->dev_instance); - if ((ad->flags & AVF_DEVICE_F_ADMIN_UP) == 0) - continue; - n_rx += avf_device_input_inline (vm, node, frame, ad, dq->queue_id); - } + 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++) + { + avf_device_t *ad = avf_get_device (pv[i].dev_instance); + if ((ad->flags & AVF_DEVICE_F_ADMIN_UP) == 0) + continue; + n_rx += avf_device_input_inline (vm, node, frame, ad, pv[i].queue_id); + } + return n_rx; } -- cgit 1.2.3-korg