summaryrefslogtreecommitdiffstats
path: root/src/plugins/memif/device.c
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2017-05-30 10:35:51 -0700
committerDave Wallace <dwallacelf@gmail.com>2017-05-31 02:27:45 +0000
commitc2ebcbb89bea719418fc3f896ae3de4302acaf6d (patch)
tree7b035f314305d100c1c1c482887581739d96f987 /src/plugins/memif/device.c
parent79ea7ec3b3c04d334a21107818c64d70c42b99ae (diff)
memif: multi-queues support
- Add rx-queues and tx-queues option to the create memif CLI - Add vlib_worker_thread_barrier_sync () to memif_conn_fd_read_ready () as the latter function may disconnect the ring and clean up the shared memory. - On transmit, write the rid (queue number) to the socket. - On receive, read the rid and trigger the interrupt for the corresponding thread. Change-Id: If1c7e26c7124174678f047909cbc33e931eaac8c Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/plugins/memif/device.c')
-rw-r--r--src/plugins/memif/device.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/memif/device.c b/src/plugins/memif/device.c
index 70bdb48ba9c..f496b17d416 100644
--- a/src/plugins/memif/device.c
+++ b/src/plugins/memif/device.c
@@ -91,16 +91,27 @@ memif_interface_tx_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame, memif_if_t * mif,
memif_ring_type_t type)
{
- u8 rid = 0;
- memif_ring_t *ring = memif_get_ring (mif, type, rid);
+ u8 rid;
+ memif_ring_t *ring;
u32 *buffers = vlib_frame_args (frame);
u32 n_left = frame->n_vectors;
u16 ring_size = 1 << mif->log2_ring_size;
u16 mask = ring_size - 1;
u16 head, tail;
u16 free_slots;
+ u32 thread_index = vlib_get_thread_index ();
+ u8 tx_queues = memif_get_tx_queues (mif);
- clib_spinlock_lock_if_init (&mif->lockp);
+ if (tx_queues < vec_len (vlib_mains))
+ {
+ rid = thread_index % tx_queues;
+ clib_spinlock_lock_if_init (&mif->lockp);
+ }
+ else
+ {
+ rid = thread_index;
+ }
+ ring = memif_get_ring (mif, type, rid);
/* free consumed buffers */