Skip to content

Commit

Permalink
dev: assign tx queue to all threads
Browse files Browse the repository at this point in the history
This patch assigns tx queue to all thread and enables tx queue
sharing if needed.

Type: fix

Signed-off-by: Monendra Singh Kushwaha <[email protected]>
Change-Id: I8cb561c29c2a508b8b478c646121b1caa61b8520
  • Loading branch information
kmonendra authored and Damjan Marion committed Jan 10, 2025
1 parent 9422381 commit 2704a58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/vnet/dev/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ vnet_dev_port_if_create (vlib_main_t *vm, vnet_dev_port_t *port, void *ptr)
vnet_dev_port_if_create_args_t *a = ptr;
vnet_dev_port_interfaces_t *ifs = port->interfaces;
vnet_dev_instance_t *di;
vnet_dev_tx_queue_t *txq, **qp;
vnet_dev_rv_t rv;
u16 ti = 0;

Expand Down Expand Up @@ -614,16 +615,19 @@ vnet_dev_port_if_create (vlib_main_t *vm, vnet_dev_port_t *port, void *ptr)
if ((rv = vnet_dev_tx_queue_alloc (vm, port, ifs->txq_sz)) != VNET_DEV_OK)
goto error;

foreach_vnet_dev_port_tx_queue (q, port)
for (ti = 0; ti < n_threads; ti++)
{
/* if consistent_qp is enabled, we start by assigning queues to workers
* and we end with main */
u16 real_ti = (ti + a->consistent_qp) % n_threads;
q->assigned_threads = clib_bitmap_set (q->assigned_threads, real_ti, 1);
qp = pool_elt_at_index (port->tx_queues, ti % ifs->num_tx_queues);
txq = qp[0];
txq->assigned_threads =
clib_bitmap_set (txq->assigned_threads, real_ti, 1);
log_debug (dev, "port %u tx queue %u assigned to thread %u",
port->port_id, q->queue_id, real_ti);
if (++ti >= n_threads)
break;
port->port_id, txq->queue_id, real_ti);
if (clib_bitmap_count_set_bits (txq->assigned_threads) > 1)
txq->lock_needed = 1;
}

pool_get (dm->dev_instances, di);
Expand Down

0 comments on commit 2704a58

Please sign in to comment.