Thread assignment to tx queue has always been automatic and there
was no way to modify it. With this patch, it is now possible to use
the cli "set interface tx-queue" to change the thread assignment to
tx queue for vmxnet3 interface, thanks to the new tx infra.
Type: feature
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I1544e3557f70251d4bd423cc3d9f28ee1d44db4a
u16 space_left;
u16 n_left = frame->n_vectors;
vmxnet3_txq_t *txq;
u16 space_left;
u16 n_left = frame->n_vectors;
vmxnet3_txq_t *txq;
- u16 qid = vm->thread_index % vd->num_tx_queues, produce;
+ vnet_hw_if_tx_frame_t *tf = vlib_frame_scalar_args (frame);
+ u16 qid = tf->queue_id, produce;
if (PREDICT_FALSE (!(vd->flags & VMXNET3_DEVICE_F_LINK_UP)))
{
if (PREDICT_FALSE (!(vd->flags & VMXNET3_DEVICE_F_LINK_UP)))
{
}
txq = vec_elt_at_index (vd->txqs, qid);
}
txq = vec_elt_at_index (vd->txqs, qid);
- clib_spinlock_lock_if_init (&txq->lock);
+ if (tf->shared_queue)
+ clib_spinlock_lock (&txq->lock);
vmxnet3_txq_release (vm, vd, txq);
vmxnet3_txq_release (vm, vd, txq);
if (PREDICT_TRUE (produce != txq->tx_ring.produce))
vmxnet3_reg_write_inline (vd, 0, txq->reg_txprod, txq->tx_ring.produce);
if (PREDICT_TRUE (produce != txq->tx_ring.produce))
vmxnet3_reg_write_inline (vd, 0, txq->reg_txprod, txq->tx_ring.produce);
- clib_spinlock_unlock_if_init (&txq->lock);
+ if (tf->shared_queue)
+ clib_spinlock_unlock (&txq->lock);
return (frame->n_vectors - n_left);
}
return (frame->n_vectors - n_left);
}
#include <vnet/plugin/plugin.h>
#include <vpp/app/version.h>
#include <vnet/interface/rx_queue_funcs.h>
#include <vnet/plugin/plugin.h>
#include <vpp/app/version.h>
#include <vnet/interface/rx_queue_funcs.h>
+#include <vnet/interface/tx_queue_funcs.h>
#include <vmxnet3/vmxnet3.h>
#define PCI_VENDOR_ID_VMWARE 0x15ad
#include <vmxnet3/vmxnet3.h>
#define PCI_VENDOR_ID_VMWARE 0x15ad
vmxnet3_tx_stats *txs;
u32 size;
vmxnet3_tx_stats *txs;
u32 size;
- if (qid >= vd->num_tx_queues)
- {
- qid = qid % vd->num_tx_queues;
- txq = vec_elt_at_index (vd->txqs, qid);
- if (txq->lock == 0)
- clib_spinlock_init (&txq->lock);
- vd->flags |= VMXNET3_DEVICE_F_SHARED_TXQ_LOCK;
- return 0;
- }
+ vec_validate_aligned (vd->txqs, qid, CLIB_CACHE_LINE_BYTES);
+ txq = vec_elt_at_index (vd->txqs, qid);
+ clib_memset (txq, 0, sizeof (*txq));
+ clib_spinlock_init (&txq->lock);
vec_validate (vd->tx_stats, qid);
txs = vec_elt_at_index (vd->tx_stats, qid);
clib_memset (txs, 0, sizeof (*txs));
vec_validate (vd->tx_stats, qid);
txs = vec_elt_at_index (vd->tx_stats, qid);
clib_memset (txs, 0, sizeof (*txs));
- vec_validate_aligned (vd->txqs, qid, CLIB_CACHE_LINE_BYTES);
- txq = vec_elt_at_index (vd->txqs, qid);
- clib_memset (txq, 0, sizeof (*txq));
txq->size = qsz;
txq->reg_txprod = qid * 8 + VMXNET3_REG_TXPROD;
txq->size = qsz;
txq->reg_txprod = qid * 8 + VMXNET3_REG_TXPROD;
if (txq->tx_desc == 0)
return vlib_physmem_last_error (vm);
if (txq->tx_desc == 0)
return vlib_physmem_last_error (vm);
- memset (txq->tx_desc, 0, size);
+ clib_memset (txq->tx_desc, 0, size);
size = qsz * sizeof (*txq->tx_comp);
txq->tx_comp =
size = qsz * sizeof (*txq->tx_comp);
txq->tx_comp =
{
clib_error_t *error = 0;
u32 ret, i, size;
{
clib_error_t *error = 0;
u32 ret, i, size;
- vlib_thread_main_t *tm = vlib_get_thread_main ();
/* Quiesce the device */
vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_QUIESCE_DEV);
/* Quiesce the device */
vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_QUIESCE_DEV);
- for (i = 0; i < tm->n_vlib_mains; i++)
+ for (i = 0; i < vd->num_tx_queues; i++)
{
error = vmxnet3_txq_init (vm, vd, i, args->txq_size);
if (error)
{
error = vmxnet3_txq_init (vm, vd, i, args->txq_size);
if (error)
vmxnet3_rxq_refill_ring0 (vm, vd, rxq);
vmxnet3_rxq_refill_ring1 (vm, vd, rxq);
}
vmxnet3_rxq_refill_ring0 (vm, vd, rxq);
vmxnet3_rxq_refill_ring1 (vm, vd, rxq);
}
+
+ vec_foreach_index (qid, vd->txqs)
+ {
+ vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, qid);
+ txq->queue_index =
+ vnet_hw_if_register_tx_queue (vnm, vd->hw_if_index, qid);
+ }
+ for (u32 i = 0; i < vlib_get_n_threads (); i++)
+ {
+ u32 qi = vd->txqs[i % vd->num_tx_queues].queue_index;
+ vnet_hw_if_tx_queue_assign_thread (vnm, qi, i);
+ }
vnet_hw_if_update_runtime_data (vnm, vd->hw_if_index);
vd->flags |= VMXNET3_DEVICE_F_INITIALIZED;
vnet_hw_if_update_runtime_data (vnm, vd->hw_if_index);
vd->flags |= VMXNET3_DEVICE_F_INITIALIZED;
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
u16 size;
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
u16 size;
u32 reg_txprod;
clib_spinlock_t lock;
u32 reg_txprod;
clib_spinlock_t lock;