diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2021-09-30 09:28:07 +0000 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-10-04 18:27:58 +0000 |
commit | 3effb4e63068f625f6137cef665ed9783da8e542 (patch) | |
tree | 4a9c1eaac1f50082202535da24345a40b07f4d13 /src | |
parent | 41bc8615096b8a7d92707792dfd2b14ded40773e (diff) |
memif: integrate with new tx infra
Type: improvement
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I7c2b9891e269f23c3aa2a0abfee3cf0a0f1e2135
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/memif/device.c | 18 | ||||
-rw-r--r-- | src/plugins/memif/memif.c | 12 | ||||
-rw-r--r-- | src/plugins/memif/private.h | 2 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/plugins/memif/device.c b/src/plugins/memif/device.c index fc66420a6ad..94789223ea7 100644 --- a/src/plugins/memif/device.c +++ b/src/plugins/memif/device.c @@ -376,22 +376,19 @@ VNET_DEVICE_CLASS_TX_FN (memif_device_class) (vlib_main_t * vm, memif_main_t *nm = &memif_main; vnet_interface_output_runtime_t *rund = (void *) node->runtime_data; memif_if_t *mif = pool_elt_at_index (nm->interfaces, rund->dev_instance); + vnet_hw_if_tx_frame_t *tf = vlib_frame_scalar_args (frame); memif_queue_t *mq; + u32 qid = tf->queue_id; u32 *from, thread_index = vm->thread_index; memif_per_thread_data_t *ptd = vec_elt_at_index (memif_main.per_thread_data, thread_index); - u8 tx_queues = vec_len (mif->tx_queues); uword n_left; - if (tx_queues < vlib_get_n_threads ()) - { - ASSERT (tx_queues > 0); - mq = vec_elt_at_index (mif->tx_queues, thread_index % tx_queues); - } - else - mq = vec_elt_at_index (mif->tx_queues, thread_index); + ASSERT (vec_len (mif->tx_queues) > qid); + mq = vec_elt_at_index (mif->tx_queues, qid); - clib_spinlock_lock_if_init (&mif->lockp); + if (tf->shared_queue) + clib_spinlock_lock (&mq->lockp); from = vlib_frame_vector_args (frame); n_left = frame->n_vectors; @@ -405,7 +402,8 @@ VNET_DEVICE_CLASS_TX_FN (memif_device_class) (vlib_main_t * vm, n_left = memif_interface_tx_inline (vm, node, from, mif, MEMIF_RING_M2S, mq, ptd, n_left); - clib_spinlock_unlock_if_init (&mif->lockp); + if (tf->shared_queue) + clib_spinlock_unlock (&mq->lockp); if (n_left) vlib_error_count (vm, node->node_index, MEMIF_TX_ERROR_NO_FREE_SLOTS, diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c index 9bbbe7f9d89..55d9b84fd4c 100644 --- a/src/plugins/memif/memif.c +++ b/src/plugins/memif/memif.c @@ -36,6 +36,7 @@ #include <vnet/plugin/plugin.h> #include <vnet/ethernet/ethernet.h> #include <vnet/interface/rx_queue_funcs.h> +#include <vnet/interface/tx_queue_funcs.h> #include <vpp/app/version.h> #include <memif/memif.h> #include <memif/private.h> @@ -158,6 +159,7 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err) { memif_disconnect_free_zc_queue_buffer(mq, 0); } + clib_spinlock_free (&mq->lockp); } mq->ring = 0; } @@ -265,6 +267,7 @@ memif_connect (memif_if_t * mif) template.write_function = memif_int_fd_write_ready; /* *INDENT-OFF* */ + u32 n_threads = vlib_get_n_threads (); vec_foreach_index (i, mif->tx_queues) { memif_queue_t *mq = vec_elt_at_index (mif->tx_queues, i); @@ -275,6 +278,10 @@ memif_connect (memif_if_t * mif) err = clib_error_return (0, "wrong cookie on tx ring %u", i); goto error; } + mq->queue_index = + vnet_hw_if_register_tx_queue (vnm, mif->hw_if_index, i); + vnet_hw_if_tx_queue_assign_thread (vnm, mq->queue_index, i % n_threads); + clib_spinlock_init (&mq->lockp); } vec_foreach_index (i, mif->rx_queues) @@ -470,6 +477,7 @@ memif_init_regions_and_queues (memif_if_t * mif) err = clib_error_return_unix (0, "eventfd[tx queue %u]", i); goto error; } + mq->int_clib_file_index = ~0; mq->ring = memif_get_ring (mif, MEMIF_RING_S2M, i); mq->log2_ring_size = mif->cfg.log2_ring_size; @@ -797,7 +805,6 @@ memif_delete_if (vlib_main_t * vm, memif_if_t * mif) } /* free interface data structures */ - clib_spinlock_free (&mif->lockp); mhash_unset (&msf->dev_instance_by_id, &mif->id, 0); /* remove socket file */ @@ -952,9 +959,6 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args) if (args->secret) mif->secret = vec_dup (args->secret); - if (tm->n_vlib_mains > 1) - clib_spinlock_init (&mif->lockp); - if (mif->mode == MEMIF_INTERFACE_MODE_ETHERNET) { diff --git a/src/plugins/memif/private.h b/src/plugins/memif/private.h index 838651abc27..fec8506c023 100644 --- a/src/plugins/memif/private.h +++ b/src/plugins/memif/private.h @@ -123,6 +123,7 @@ typedef struct typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + clib_spinlock_t lockp; /* ring data */ memif_ring_t *ring; memif_log2_ring_size_t log2_ring_size; @@ -163,7 +164,6 @@ typedef enum typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); - clib_spinlock_t lockp; u32 flags; memif_interface_id_t id; u32 hw_if_index; |