From 1bd6cbb7aeded36cca4402d0c970b593316c9d70 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 15 Apr 2021 13:12:51 +0200 Subject: interface: tx queue infra Type: improvement Change-Id: I415b2f980de10ca3154d2c8677c24792453eccd0 Signed-off-by: Damjan Marion --- src/plugins/avf/avf.h | 1 + src/plugins/avf/device.c | 12 ++++++++++-- src/plugins/avf/output.c | 12 +++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src/plugins/avf') diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h index ea931dc07c4..c03a7c252ae 100644 --- a/src/plugins/avf/avf.h +++ b/src/plugins/avf/avf.h @@ -191,6 +191,7 @@ typedef struct avf_tx_desc_t *tmp_descs; u32 *tmp_bufs; + u32 queue_index; } avf_txq_t; typedef struct diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index 70ea446432c..05946a4087d 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -303,8 +304,7 @@ avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size) { qid = qid % ad->num_queue_pairs; txq = vec_elt_at_index (ad->txqs, qid); - if (txq->lock == 0) - clib_spinlock_init (&txq->lock); + clib_spinlock_init (&txq->lock); ad->flags |= AVF_DEVICE_F_SHARED_TXQ_LOCK; return 0; } @@ -1748,6 +1748,14 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) } ad->rxqs[i].queue_index = qi; } + + for (i = 0; i < ad->n_tx_queues; i++) + { + u32 qi = vnet_hw_if_register_tx_queue (vnm, ad->hw_if_index, i); + vnet_hw_if_tx_queue_assign_thread (vnm, qi, i); + ad->txqs[i].queue_index = qi; + } + vnet_hw_if_update_runtime_data (vnm, ad->hw_if_index); if (pool_elts (am->devices) == 1) diff --git a/src/plugins/avf/output.c b/src/plugins/avf/output.c index 78043358e77..4cc9d5a49c1 100644 --- a/src/plugins/avf/output.c +++ b/src/plugins/avf/output.c @@ -375,16 +375,17 @@ VNET_DEVICE_CLASS_TX_FN (avf_device_class) (vlib_main_t * vm, { vnet_interface_output_runtime_t *rd = (void *) node->runtime_data; avf_device_t *ad = avf_get_device (rd->dev_instance); - u32 thread_index = vm->thread_index; - u8 qid = thread_index; - avf_txq_t *txq = vec_elt_at_index (ad->txqs, qid % ad->num_queue_pairs); + vnet_hw_if_tx_frame_t *tf = vlib_frame_scalar_args (frame); + u8 qid = tf->queue_id; + avf_txq_t *txq = vec_elt_at_index (ad->txqs, qid); u16 next; u16 mask = txq->size - 1; u32 *buffers = vlib_frame_vector_args (frame); u16 n_enq, n_left, n_desc, *slot; u16 n_retry = 2; - clib_spinlock_lock_if_init (&txq->lock); + if (tf->shared_queue) + clib_spinlock_lock (&txq->lock); n_left = frame->n_vectors; @@ -474,7 +475,8 @@ retry: AVF_TX_ERROR_NO_FREE_SLOTS, n_left); } - clib_spinlock_unlock_if_init (&txq->lock); + if (tf->shared_queue) + clib_spinlock_unlock (&txq->lock); return frame->n_vectors - n_left; } -- cgit 1.2.3-korg