DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jiacheng Ye <yejiacheng4@h-partners.com>
To: dev@dpdk.org
Cc: Feifei Wang <wangfeifei40@huawei.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [PATCH v4 22/27] net/hinic3: ensure queue depth and state consistency
Date: Fri, 23 Oct 2026 23:58:03 +0800	[thread overview]
Message-ID: <20261023155809.855-23-yejiacheng4@h-partners.com> (raw)
In-Reply-To: <20261023155809.855-1-yejiacheng4@h-partners.com>

The hardware tracks a single queue depth across all queues, so an rx or
tx queue configured with a different depth is rejected with -EINVAL
rather than silently coerced to the first queue's depth. Reset the rx/tx
queue states in dev_stop and the cached depths in dev_configure so the
queue state reflects the stopped device before the next start.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c | 41 ++++++++++++++++++++----------
 drivers/net/hinic3/hinic3_ethdev.h |  5 ++++
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 394ed08e8e..d67b33f7f7 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -316,8 +316,6 @@ hinic3_xstats_calc_num(struct hinic3_nic_dev *nic_dev)
 	}
 }
 
-#define HINIC3_MAX_QUEUE_DEPTH 16384
-#define HINIC3_MIN_QUEUE_DEPTH 128
 #define HINIC3_TXD_ALIGN       1
 #define HINIC3_RXD_ALIGN       1
 
@@ -737,6 +735,8 @@ hinic3_dev_configure(struct rte_eth_dev *dev)
 
 	nic_dev->num_sqs = dev->data->nb_tx_queues;
 	nic_dev->num_rqs = dev->data->nb_rx_queues;
+	nic_dev->rxq_depth = 0;
+	nic_dev->txq_depth = 0;
 
 	nic_dev->mtu_size =
 		(uint16_t)HINIC3_PKTLEN_TO_MTU(HINIC3_MAX_RX_PKT_LEN(dev->data->dev_conf.rxmode));
@@ -1082,16 +1082,8 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	/* Queue depth must be equal to queue 0 */
-	if (qid != 0 && nb_desc != nic_dev->rxqs[0]->q_depth) {
-		PMD_DRV_LOG(WARNING, "rxq%u depth:%u is not equal to queue0 depth:%u.",
-			    qid, nb_desc, nic_dev->rxqs[0]->q_depth);
-		nb_desc = nic_dev->rxqs[0]->q_depth;
-	}
-
 	/* Queue depth must be power of 2, otherwise will be aligned up. */
-	rq_depth = (nb_desc & (nb_desc - 1))
-			? ((uint16_t)(1U << (rte_log2_u32(nb_desc) + 1))) : nb_desc;
+	rq_depth = (uint16_t)rte_align32pow2(nb_desc);
 
 	/*
 	 * Validate number of receive descriptors.
@@ -1108,6 +1100,15 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		return -EINVAL;
 	}
 
+	/* Queue depth must be equal to first queue */
+	if (nic_dev->rxq_depth == 0) {
+		nic_dev->rxq_depth = rq_depth;
+	} else if (rq_depth != nic_dev->rxq_depth) {
+		PMD_DRV_LOG(ERR, "rxq%u depth:%u is not equal to first queue depth:%u.",
+			    qid, rq_depth, nic_dev->rxq_depth);
+		return -EINVAL;
+	}
+
 	/*
 	 * The RX descriptor ring will be cleaned after rxq->rx_free_thresh
 	 * descriptors are used or if the number of descriptors required
@@ -1317,8 +1318,7 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	hwdev = nic_dev->hwdev;
 
 	/* Queue depth must be power of 2, otherwise will be aligned up. */
-	sq_depth = (nb_desc & (nb_desc - 1))
-				? ((uint16_t)(1U << (rte_log2_u32(nb_desc) + 1))) : nb_desc;
+	sq_depth = (uint16_t)rte_align32pow2(nb_desc);
 
 	/*
 	 * Validate number of transmit descriptors.
@@ -1335,6 +1335,15 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		return -EINVAL;
 	}
 
+	/* Queue depth must be equal to first queue */
+	if (nic_dev->txq_depth == 0) {
+		nic_dev->txq_depth = sq_depth;
+	} else if (sq_depth != nic_dev->txq_depth) {
+		PMD_DRV_LOG(ERR, "txq%u depth:%u is not equal to first queue depth:%u.",
+			qid, sq_depth, nic_dev->txq_depth);
+		return -EINVAL;
+	}
+
 	/*
 	 * The TX descriptor ring will be cleaned after txq->tx_free_thresh
 	 * descriptors are used or if the number of descriptors required
@@ -2243,6 +2252,12 @@ hinic3_dev_stop(struct rte_eth_dev *dev)
 
 	/* Free mempool. */
 	hinic3_copy_mempool_uninit(nic_dev);
+
+	for (uint16_t i = 0; i < dev->data->nb_rx_queues; i++)
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	for (uint16_t i = 0; i < dev->data->nb_tx_queues; i++)
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+
 	return 0;
 }
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 2bc1d4a666..f6347b4082 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -15,6 +15,9 @@
 
 #define HINIC3_PMD_DRV_VERSION "B106"
 
+#define HINIC3_MAX_QUEUE_DEPTH         16384
+#define HINIC3_MIN_QUEUE_DEPTH         128
+
 #define PCI_DEV_TO_INTR_HANDLE(pci_dev) ((pci_dev)->intr_handle)
 
 #define HINIC3_PKT_RX_L4_CKSUM_BAD	RTE_MBUF_F_RX_L4_CKSUM_BAD
@@ -147,6 +150,8 @@ struct hinic3_nic_dev {
 	uint16_t max_sqs;
 	uint16_t max_rqs;
 
+	uint16_t rxq_depth;
+	uint16_t txq_depth;
 	uint16_t rx_buff_len;
 	uint16_t mtu_size;
 
-- 
2.33.0


  parent reply	other threads:[~2026-10-23 16:00 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 14:44 [PATCH v1 00/17] net/hinic3: add PMD features and fixes Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 01/17] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 02/17] net/hinic3: add CIR drop statistics and VF LAG support Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 03/17] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 04/17] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 05/17] net/hinic3: add COS mask and COS map support Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 06/17] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 07/17] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
2026-10-10 14:44 ` [PATCH v1 08/17] net/hinic3: update RSS hash type configuration Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 09/17] net/hinic3: refactor flow rule parsing Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 10/17] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 11/17] net/hinic3: add device kvargs parameters support Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 12/17] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 13/17] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 14/17] net/hinic3: split Tx burst function for compact CQE support Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 15/17] net/hinic3: add pseudo-header checksum calculation Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 16/17] net/hinic3: add per-tile prefetch/drop/CEQ cmdq ops Jiacheng Ye
2026-10-10 14:45 ` [PATCH v1 17/17] net/hinic3: add mbox count telemetry support Jiacheng Ye
2026-10-10 18:30 ` [PATCH v1 00/17] net/hinic3: add PMD features and fixes Stephen Hemminger
2026-10-14 14:39   ` jiachengye_123
2026-10-14 15:08 ` [PATCH v2 00/26] " Jiacheng Ye
2026-10-14 15:08   ` [PATCH v2 01/26] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
2026-10-14 15:08   ` [PATCH v2 02/26] net/hinic3: fix double removal in ethertype flow destroy Jiacheng Ye
2026-10-14 15:08   ` [PATCH v2 03/26] net/hinic3: fix VXLAN VNI spec and mask write Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 04/26] net/hinic3: fix vport enable null dereference Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 05/26] net/hinic3: attach ethdev and set ops in secondary process Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 06/26] net/hinic3: add NIC type identification Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 07/26] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 08/26] net/hinic3: add CIR drop statistics and VF LAG support Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 09/26] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 10/26] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 11/26] net/hinic3: add COS mask and COS map support Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 12/26] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 13/26] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 14/26] net/hinic3: update RSS hash type configuration Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 15/26] net/hinic3: refactor flow rule parsing Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 16/26] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 17/26] net/hinic3: add device kvargs parameters support Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 18/26] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 19/26] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 20/26] net/hinic3: split Tx burst function for compact CQE support Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 21/26] net/hinic3: ensure queue depth and state consistency Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 22/26] net/hinic3: add SP230 VF software statistics Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 23/26] net/hinic3: add Tx burst mode get Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 24/26] net/hinic3: expose Tx queue copied-mbuf statistics Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 25/26] net/hinic3: add pseudo-header checksum calculation Jiacheng Ye
2026-10-14 15:09   ` [PATCH v2 26/26] net/hinic3: add per-tile prefetch/drop/CEQ cmdq ops Jiacheng Ye
2026-10-14 17:13   ` [PATCH v2 00/26] net/hinic3: add PMD features and fixes Stephen Hemminger
2026-10-19 15:19   ` [PATCH v3 00/27] " Jiacheng Ye
2026-10-19 15:19     ` [PATCH 01/27] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
2026-10-19 15:19     ` [PATCH 02/27] net/hinic3: fix double removal in ethertype flow destroy Jiacheng Ye
2026-10-19 15:19     ` [PATCH 03/27] net/hinic3: fix TCAM index leak on ethertype flow set Jiacheng Ye
2026-10-19 15:19     ` [PATCH 04/27] net/hinic3: fix VXLAN VNI spec and mask write Jiacheng Ye
2026-10-19 15:19     ` [PATCH 05/27] net/hinic3: fix vport enable null dereference Jiacheng Ye
2026-10-19 15:19     ` [PATCH 06/27] net/hinic3: attach ethdev and set ops in secondary process Jiacheng Ye
2026-10-19 15:19     ` [PATCH 07/27] net/hinic3: add NIC type identification Jiacheng Ye
2026-10-19 15:19     ` [PATCH 08/27] net/hinic3: add SP230 Rx queue interrupt handling Jiacheng Ye
2026-10-19 15:19     ` [PATCH 09/27] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
2026-10-19 15:19     ` [PATCH 10/27] net/hinic3: add CIR drop statistics and VF LAG support Jiacheng Ye
2026-10-19 15:19     ` [PATCH 11/27] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
2026-10-19 15:19     ` [PATCH 12/27] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
2026-10-19 15:19     ` [PATCH 13/27] net/hinic3: add COS mask and COS map support Jiacheng Ye
2026-10-19 15:19     ` [PATCH 14/27] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
2026-10-19 15:19     ` [PATCH 15/27] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
2026-10-19 15:19     ` [PATCH 16/27] net/hinic3: update RSS hash type configuration Jiacheng Ye
2026-10-19 15:19     ` [PATCH 17/27] net/hinic3: refactor flow rule parsing Jiacheng Ye
2026-10-19 15:19     ` [PATCH 18/27] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
2026-10-19 15:19     ` [PATCH 19/27] net/hinic3: add device kvargs parameters support Jiacheng Ye
2026-10-19 15:19     ` [PATCH 20/27] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
2026-10-19 15:19     ` [PATCH 21/27] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
2026-10-19 15:19     ` [PATCH 22/27] net/hinic3: split Tx burst function for compact CQE support Jiacheng Ye
2026-10-19 15:19     ` [PATCH 23/27] net/hinic3: ensure queue depth and state consistency Jiacheng Ye
2026-10-19 15:19     ` [PATCH 24/27] net/hinic3: add SP230 VF software statistics Jiacheng Ye
2026-10-19 15:19     ` [PATCH 25/27] net/hinic3: add Tx burst mode get Jiacheng Ye
2026-10-19 15:19     ` [PATCH 26/27] net/hinic3: expose Tx queue copied-mbuf statistics Jiacheng Ye
2026-10-19 15:19     ` [PATCH 27/27] net/hinic3: add pseudo-header checksum calculation Jiacheng Ye
2026-10-19 16:52     ` [PATCH v3 00/27] net/hinic3: add PMD features and fixes Stephen Hemminger
2026-10-23 15:56       ` jiachengye_123
2026-10-23 15:57     ` [PATCH v4 " Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 01/27] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 02/27] net/hinic3: fix double removal in ethertype flow destroy Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 03/27] net/hinic3: fix TCAM index leak on ethertype flow set Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 04/27] net/hinic3: fix VXLAN VNI spec and mask write Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 05/27] net/hinic3: fix vport enable null dereference Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 06/27] net/hinic3: attach ethdev and set ops in secondary process Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 07/27] net/hinic3: add NIC type identification Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 08/27] net/hinic3: fix pseudo-header checksum calculation Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 09/27] net/hinic3: add SP230 Rx queue interrupt handling Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 10/27] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 11/27] net/hinic3: add CIR drop statistics and VF LAG support Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 12/27] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 13/27] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 14/27] net/hinic3: add COS mask and COS map support Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 15/27] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 16/27] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 17/27] net/hinic3: update RSS hash type configuration Jiacheng Ye
2026-10-23 15:57       ` [PATCH v4 18/27] net/hinic3: refactor flow rule parsing Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 19/27] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 20/27] net/hinic3: add device kvargs parameters support Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 21/27] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
2026-10-23 15:58       ` Jiacheng Ye [this message]
2026-10-23 15:58       ` [PATCH v4 23/27] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 24/27] net/hinic3: split Tx burst function for compact CQE support Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 25/27] net/hinic3: add SP230 VF software statistics Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 26/27] net/hinic3: add Tx burst mode get Jiacheng Ye
2026-10-23 15:58       ` [PATCH v4 27/27] net/hinic3: expose Tx queue copied-mbuf statistics Jiacheng Ye
2026-10-23 16:21       ` [PATCH v4 00/27] net/hinic3: add PMD features and fixes Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023155809.855-23-yejiacheng4@h-partners.com \
    --to=yejiacheng4@h-partners.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=wangfeifei40@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox