Skip to contentSkip to conversation

net/vmxnet3: fix mapping of mempools to queues

PATCH Applied Ronak Doshi 2 participants 4 messages Jul 9, 2025 – Jul 22, 2025

Subsystems (2)
lore
Share & tools
lore

Ronak Doshi

author maintainer
#0 lore raw

PATCH 1/1 net/vmxnet3: fix mapping of mempools to queues

Index bitmask variable used was uint8_t, too small for bitmask with 9 or more queues. This patch changes it to uint16_t for now, to be same as in the Vmxnet3_MemoryRegion structure. This way txQueues can be lesser than rxQueues and have correct mapping of memory regions.

Also, the patch fixes memory region check as 16 queues are allowed on both RX and TX.

Fixes 6a113992060e ("net/vmxnet3: add cmd to register memory region")
---
 drivers/net/vmxnet3/base/vmxnet3_defs.h |  3 +++
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 23 ++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/vmxnet3/base/vmxnet3_defs.h +3 -0
index a6bb281d8d..15d4d88c5c 100644
@@ -598,6 +598,9 @@ enum vmxnet3_intr_type {
 /* addition 1 for events */
 #define VMXNET3_MAX_INTRS      25
 
+/* Max number of queues that can request memreg, for both RX and TX. */
+#define VMXNET3_MAX_MEMREG_QUEUES  16
+
 /* Version 6 and later will use below macros */
 #define VMXNET3_EXT_MAX_TX_QUEUES  32
 #define VMXNET3_EXT_MAX_RX_QUEUES  32
drivers/net/vmxnet3/vmxnet3_ethdev.c +14 -9
index 15ca25b187..e19aa43888 100644
@@ -801,14 +801,15 @@ vmxnet3_dev_setup_memreg(struct rte_eth_dev *dev)
 	Vmxnet3_DriverShared *shared = hw->shared;
 	Vmxnet3_CmdInfo *cmdInfo;
 	struct rte_mempool *mp[VMXNET3_MAX_RX_QUEUES];
-	uint8_t index[VMXNET3_MAX_RX_QUEUES + VMXNET3_MAX_TX_QUEUES];
-	uint32_t num, i, j, size;
+	uint16_t index[VMXNET3_MAX_MEMREG_QUEUES];
+	uint16_t tx_index_mask;
+	uint32_t num, tx_num, i, j, size;
 
 	if (hw->memRegsPA == 0) {
 		const struct rte_memzone *mz;
 
 		size = sizeof(Vmxnet3_MemRegs) +
-			(VMXNET3_MAX_RX_QUEUES + VMXNET3_MAX_TX_QUEUES) *
+			(2 * VMXNET3_MAX_MEMREG_QUEUES) *
 			sizeof(Vmxnet3_MemoryRegion);
 
 		mz = gpa_zone_reserve(dev, size, "memRegs", rte_socket_id(), 8,
@@ -822,7 +823,9 @@ vmxnet3_dev_setup_memreg(struct rte_eth_dev *dev)
 		hw->memRegsPA = mz->iova;
 	}
 
-	num = hw->num_rx_queues;
+	num = RTE_MIN(hw->num_rx_queues, VMXNET3_MAX_MEMREG_QUEUES);
+	tx_num = RTE_MIN(hw->num_tx_queues, VMXNET3_MAX_MEMREG_QUEUES);
+	tx_index_mask = (uint16_t)((1UL << tx_num) - 1);
 
 	for (i = 0; i < num; i++) {
 		vmxnet3_rx_queue_t *rxq = dev->data->rx_queues[i];
@@ -857,13 +860,15 @@ vmxnet3_dev_setup_memreg(struct rte_eth_dev *dev)
 			(uintptr_t)STAILQ_FIRST(&mp[i]->mem_list)->iova;
 		mr->length = STAILQ_FIRST(&mp[i]->mem_list)->len <= INT32_MAX ?
 			STAILQ_FIRST(&mp[i]->mem_list)->len : INT32_MAX;
-		mr->txQueueBits = index[i];
 		mr->rxQueueBits = index[i];
+		/* tx uses same pool, but there may be fewer tx queues */
+		mr->txQueueBits = index[i] & tx_index_mask;
 
 		PMD_INIT_LOG(INFO,
 			     "index: %u startPA: %" PRIu64 " length: %u, "
-			     "rxBits: %x",
-			     j, mr->startPA, mr->length, mr->rxQueueBits);
+			     "rxBits: %x, txBits: %x",
+			     j, mr->startPA, mr->length,
+			     mr->rxQueueBits, mr->txQueueBits);
 		j++;
 	}
 	hw->memRegs->numRegs = j;
@@ -1087,8 +1092,8 @@ vmxnet3_dev_start(struct rte_eth_dev *dev)
 	}
 
 	/* Check memregs restrictions first */
-	if (dev->data->nb_rx_queues <= VMXNET3_MAX_RX_QUEUES &&
-	    dev->data->nb_tx_queues <= VMXNET3_MAX_TX_QUEUES) {
+	if (dev->data->nb_rx_queues <= VMXNET3_MAX_MEMREG_QUEUES &&
+	    dev->data->nb_tx_queues <= VMXNET3_MAX_MEMREG_QUEUES) {
 		ret = vmxnet3_dev_setup_memreg(dev);
 		if (ret == 0) {
 			VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
Signature · 1 line
2.45.2
author maintainer
#1 lore raw
Quoted 6 lines · Ronak Doshi

Index bitmask variable used was uint8_t, too small for bitmask with 9 or more queues. This patch changes it to uint16_t for now, to be same as in the Vmxnet3_MemoryRegion structure. This way txQueues can be lesser than rxQueues and have correct mapping of memory regions.

Quoted 8 lines

Also, the patch fixes memory region check as 16 queues are allowed on both RX and TX.

Fixes 6a113992060e ("net/vmxnet3: add cmd to register memory region")

---

Hello, Can we get a review on this patch?

Thanks,
Ronak

#2 lore raw
Quoted 16 lines · On Fri, 18 Jul 2025 09:24:31 -0700 Ronak Doshi <[email protected]> wrote:
Quoted 6 lines · Ronak Doshi

Index bitmask variable used was uint8_t, too small for bitmask with 9 or more queues. This patch changes it to uint16_t for now, to be same as in the Vmxnet3_MemoryRegion structure. This way txQueues can be lesser than rxQueues and have correct mapping of memory regions.

Quoted 8 lines

Also, the patch fixes memory region check as 16 queues are allowed on both RX and TX.

Fixes 6a113992060e ("net/vmxnet3: add cmd to register memory region")

---

Quoted 4 lines

Hello, Can we get a review on this patch?

Thanks,
Ronak

I planned to put it in next-net after 25.07 is released.

#3 lore raw
In reply to Ronak Doshi
Quoted 5 lines · On Wed, 9 Jul 2025 21:29:03 +0000 Ronak Doshi <[email protected]> wrote:

Index bitmask variable used was uint8_t, too small for bitmask with 9 or more queues. This patch changes it to uint16_t for now, to be same as in the Vmxnet3_MemoryRegion structure. This way txQueues can be lesser than rxQueues and have correct mapping of memory regions.

Quoted 8 lines

Also, the patch fixes memory region check as 16 queues are allowed on both RX and TX.

Fixes 6a113992060e ("net/vmxnet3: add cmd to register memory region")

---

Queued to next-net for 25.11