DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: "Min Hu (Connor)" <humin29@huawei.com>,
	Yisen Zhuang <yisen.zhuang@huawei.com>,
	Lijun Ou <oulijun@huawei.com>
Subject: [PATCH 3/5] net/hns3: refactor queue info dump
Date: Thu, 14 Apr 2022 21:00:54 +0800	[thread overview]
Message-ID: <20220414130056.37428-4-humin29@huawei.com> (raw)
In-Reply-To: <20220414130056.37428-1-humin29@huawei.com>

This patch refactor queue info dump.

Fixes: 6038c8a3f63c ("net/hns3: dump queue info")

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ethdev_dump.c | 133 +++++++++++++---------------
 1 file changed, 62 insertions(+), 71 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index 059a4d8644..9934e4e1cc 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -224,99 +224,94 @@ get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
 		dev->data->dev_conf.intr_conf.rxq);
 }
 
-/*
- * Note: caller must make sure queue_id < nb_queues
- *       nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
- *                           eth_dev->data->nb_tx_queues)
- */
 static struct hns3_rx_queue *
-get_rx_queue(struct rte_eth_dev *dev, unsigned int queue_id)
+get_rx_queue(struct rte_eth_dev *dev)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
-	unsigned int offset;
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq;
+	uint32_t queue_id;
 	void **rx_queues;
 
-	if (queue_id < dev->data->nb_rx_queues) {
+	for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) {
 		rx_queues = dev->data->rx_queues;
-		offset = queue_id;
-	} else {
-		/*
-		 * For kunpeng930, fake queue is not exist. But since the queues
-		 * are usually accessd in pairs, this branch may still exist.
-		 */
-		if (hns3_dev_get_support(hw, INDEP_TXRX))
+		if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
+			hns3_err(hw, "detect rx_queues is NULL!\n");
 			return NULL;
+		}
 
-		rx_queues = hw->fkq_data.rx_queues;
-		offset = queue_id - dev->data->nb_rx_queues;
-	}
+		rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
+		if (rxq->rx_deferred_start)
+			continue;
 
-	if (rx_queues != NULL && rx_queues[offset] != NULL)
-		return rx_queues[offset];
+		return rx_queues[queue_id];
+	}
 
-	hns3_err(hw, "Detect rx_queues is NULL!\n");
 	return NULL;
 }
 
-/*
- * Note: caller must make sure queue_id < nb_queues
- *       nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
- *                           eth_dev->data->nb_tx_queues)
- */
 static struct hns3_tx_queue *
-get_tx_queue(struct rte_eth_dev *dev, unsigned int queue_id)
+get_tx_queue(struct rte_eth_dev *dev)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
-	unsigned int offset;
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq;
+	uint32_t queue_id;
 	void **tx_queues;
 
-	if (queue_id < dev->data->nb_tx_queues) {
+	for (queue_id = 0; queue_id < dev->data->nb_tx_queues; queue_id++) {
 		tx_queues = dev->data->tx_queues;
-		offset = queue_id;
-	} else {
-		/*
-		 * For kunpeng930, fake queue is not exist. But since the queues
-		 * are usually accessd in pairs, this branch may still exist.
-		 */
-		if (hns3_dev_get_support(hw, INDEP_TXRX))
+		if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
+			hns3_err(hw, "detect tx_queues is NULL!\n");
 			return NULL;
-		tx_queues = hw->fkq_data.tx_queues;
-		offset = queue_id - dev->data->nb_tx_queues;
-	}
+		}
 
-	if (tx_queues != NULL && tx_queues[offset] != NULL)
-		return tx_queues[offset];
+		txq = (struct hns3_tx_queue *)tx_queues[queue_id];
+		if (txq->tx_deferred_start)
+			continue;
+
+		return tx_queues[queue_id];
+	}
 
-	hns3_err(hw, "Detect tx_queues is NULL!\n");
 	return NULL;
 }
 
 static void
 get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns);
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct hns3_rx_queue *rxq;
 	struct hns3_tx_queue *txq;
-	unsigned int queue_id;
-
-	if (dev->data->nb_rx_queues != dev->data->nb_tx_queues &&
-	    !hns3_dev_get_support(hw, INDEP_TXRX)) {
-		queue_id = RTE_MIN(dev->data->nb_rx_queues,
-				   dev->data->nb_tx_queues);
-		rxq = get_rx_queue(dev, queue_id);
-		if (rxq == NULL)
+	uint32_t queue_id = 0;
+	void **rx_queues;
+	void **tx_queues;
+
+	if (hns3_dev_get_support(hw, INDEP_TXRX))
+		return;
+
+	if (dev->data->nb_rx_queues < dev->data->nb_tx_queues) {
+		rx_queues = hw->fkq_data.rx_queues;
+		if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
+			hns3_err(hw, "detect rx_queues is NULL!\n");
 			return;
-		txq = get_tx_queue(dev, queue_id);
-		if (txq == NULL)
+		}
+		rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
+
+		fprintf(file,
+			"\t  -- first fake_queue info:\n"
+			"\t       Rx: port=%u nb_desc=%u free_thresh=%u\n",
+			rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh);
+	} else if (dev->data->nb_rx_queues > dev->data->nb_tx_queues) {
+		tx_queues = hw->fkq_data.tx_queues;
+		queue_id = 0;
+
+		if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
+			hns3_err(hw, "detect tx_queues is NULL!\n");
 			return;
+		}
+		txq = (struct hns3_tx_queue *)tx_queues[queue_id];
+
 		fprintf(file,
-			"\t  -- first fake_queue rxtx info:\n"
-			"\t       rx: port=%u nb_desc=%u free_thresh=%u\n"
-			"\t       tx: port=%u nb_desc=%u\n",
-			rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
+			"\t  -- first fake_queue info:\n"
+			"\t	  Tx: port=%u nb_desc=%u\n",
 			txq->port_id, txq->nb_tx_desc);
 	}
 }
@@ -422,23 +417,19 @@ get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
 {
 	struct hns3_rx_queue *rxq;
 	struct hns3_tx_queue *txq;
-	unsigned int queue_id = 0;
 
-	rxq = get_rx_queue(dev, queue_id);
+	rxq = get_rx_queue(dev);
 	if (rxq == NULL)
 		return;
-	txq = get_tx_queue(dev, queue_id);
+	txq = get_tx_queue(dev);
 	if (txq == NULL)
 		return;
 	fprintf(file, "  - Rx/Tx Queue Info:\n");
 	fprintf(file,
-		"\t  -- nb_rx_queues=%u nb_tx_queues=%u, "
-		"first queue rxtx info:\n"
-		"\t       rx: port=%u nb_desc=%u free_thresh=%u\n"
-		"\t       tx: port=%u nb_desc=%u\n"
+		"\t  -- first queue rxtx info:\n"
+		"\t       Rx: port=%u nb_desc=%u free_thresh=%u\n"
+		"\t       Tx: port=%u nb_desc=%u\n"
 		"\t  -- tx push: %s\n",
-		dev->data->nb_rx_queues,
-		dev->data->nb_tx_queues,
 		rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
 		txq->port_id, txq->nb_tx_desc,
 		txq->tx_push_enable ? "enabled" : "disabled");
-- 
2.33.0


  parent reply	other threads:[~2022-04-14 13:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 13:00 [PATCH 0/5] refactor for device " Min Hu (Connor)
2022-04-14 13:00 ` [PATCH 1/5] net/hns3: refactor adapter state dump Min Hu (Connor)
2022-04-14 13:00 ` [PATCH 2/5] net/hns3: refactor feature capability dump Min Hu (Connor)
2022-04-14 13:00 ` Min Hu (Connor) [this message]
2022-04-14 13:00 ` [PATCH 4/5] net/hns3: fix dump TM info Min Hu (Connor)
2022-04-14 13:00 ` [PATCH 5/5] net/hns3: fix dump device info Min Hu (Connor)
2022-05-05 16:28 ` [PATCH 0/5] refactor for device info dump Ferruh Yigit

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=20220414130056.37428-4-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=oulijun@huawei.com \
    --cc=yisen.zhuang@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;
as well as URLs for NNTP newsgroup(s).