DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jin Liu <jin.liu@corigine.com>
To: dev@dpdk.org
Cc: niklas.soderlund@corigine.com, Jin Liu <jin.liu@corigine.com>,
	Diana Wang <na.wang@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v4 10/13] net/nfp: add queue stop and close helper function
Date: Thu, 23 Jun 2022 04:26:12 +0200	[thread overview]
Message-ID: <20220623022615.3628093-11-jin.liu@corigine.com> (raw)
In-Reply-To: <20220623022615.3628093-1-jin.liu@corigine.com>

This commit does not introduce new features, just integrate some common
logic into helper functions to reduce the same logic and increase code
reuse, include queue stop and queue close logic, will be used when NFP
net stop and close.

queue stop: reset queue
queue close: reset and release queue

Modify NFP net stop and close function, use helper function to stop
and close queue instead of before logic.

Signed-off-by: Jin Liu <jin.liu@corigine.com>
Signed-off-by: Diana Wang <na.wang@corigine.com>
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_common.c    | 50 +++++++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_common.h    |  4 +++
 drivers/net/nfp/nfp_ethdev.c    | 27 +++---------------
 drivers/net/nfp/nfp_ethdev_vf.c | 29 +++----------------
 4 files changed, 62 insertions(+), 48 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 9903a1bd5a..755c5ec4d9 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -1320,6 +1320,56 @@ nfp_net_rss_config_default(struct rte_eth_dev *dev)
 	return ret;
 }
 
+void
+nfp_net_stop_rx_queue(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+	struct nfp_net_rxq *this_rx_q;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
+		nfp_net_reset_rx_queue(this_rx_q);
+	}
+}
+
+void
+nfp_net_close_rx_queue(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+	struct nfp_net_rxq *this_rx_q;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
+		nfp_net_reset_rx_queue(this_rx_q);
+		nfp_net_rx_queue_release(dev, i);
+	}
+}
+
+void
+nfp_net_stop_tx_queue(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+	struct nfp_net_txq *this_tx_q;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
+		nfp_net_reset_tx_queue(this_tx_q);
+	}
+}
+
+void
+nfp_net_close_tx_queue(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+	struct nfp_net_txq *this_tx_q;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
+		nfp_net_reset_tx_queue(this_tx_q);
+		nfp_net_tx_queue_release(dev, i);
+	}
+}
+
 RTE_LOG_REGISTER_SUFFIX(nfp_logtype_init, init, NOTICE);
 RTE_LOG_REGISTER_SUFFIX(nfp_logtype_driver, driver, NOTICE);
 /*
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 19e96414e3..6d917e4b4a 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -413,6 +413,10 @@ int nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 int nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 			      struct rte_eth_rss_conf *rss_conf);
 int nfp_net_rss_config_default(struct rte_eth_dev *dev);
+void nfp_net_stop_rx_queue(struct rte_eth_dev *dev);
+void nfp_net_close_rx_queue(struct rte_eth_dev *dev);
+void nfp_net_stop_tx_queue(struct rte_eth_dev *dev);
+void nfp_net_close_tx_queue(struct rte_eth_dev *dev);
 
 #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\
 	(&((struct nfp_net_adapter *)adapter)->hw)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 0d650efd27..e8a8368d0f 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -181,10 +181,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 static int
 nfp_net_stop(struct rte_eth_dev *dev)
 {
-	int i;
 	struct nfp_net_hw *hw;
-	struct nfp_net_txq *this_tx_q;
-	struct nfp_net_rxq *this_rx_q;
 
 	PMD_INIT_LOG(DEBUG, "Stop");
 
@@ -193,15 +190,9 @@ nfp_net_stop(struct rte_eth_dev *dev)
 	nfp_net_disable_queues(dev);
 
 	/* Clear queues */
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
-		nfp_net_reset_tx_queue(this_tx_q);
-	}
+	nfp_net_stop_tx_queue(dev);
 
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
-		nfp_net_reset_rx_queue(this_rx_q);
-	}
+	nfp_net_stop_rx_queue(dev);
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port down */
@@ -256,8 +247,6 @@ nfp_net_close(struct rte_eth_dev *dev)
 	struct nfp_net_hw *hw;
 	struct rte_pci_device *pci_dev;
 	struct nfp_pf_dev *pf_dev;
-	struct nfp_net_txq *this_tx_q;
-	struct nfp_net_rxq *this_rx_q;
 	int i;
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -277,17 +266,9 @@ nfp_net_close(struct rte_eth_dev *dev)
 	nfp_net_disable_queues(dev);
 
 	/* Clear queues */
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
-		nfp_net_reset_tx_queue(this_tx_q);
-		nfp_net_tx_queue_release(dev, i);
-	}
+	nfp_net_close_tx_queue(dev);
 
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
-		nfp_net_reset_rx_queue(this_rx_q);
-		nfp_net_rx_queue_release(dev, i);
-	}
+	nfp_net_close_rx_queue(dev);
 
 	/* Cancel possible impending LSC work here before releasing the port*/
 	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 2342f44523..56428814b7 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -145,24 +145,14 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 static int
 nfp_netvf_stop(struct rte_eth_dev *dev)
 {
-	struct nfp_net_txq *this_tx_q;
-	struct nfp_net_rxq *this_rx_q;
-	int i;
-
 	PMD_INIT_LOG(DEBUG, "Stop");
 
 	nfp_net_disable_queues(dev);
 
 	/* Clear queues */
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
-		nfp_net_reset_tx_queue(this_tx_q);
-	}
+	nfp_net_stop_tx_queue(dev);
 
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
-		nfp_net_reset_rx_queue(this_rx_q);
-	}
+	nfp_net_stop_rx_queue(dev);
 
 	return 0;
 }
@@ -185,9 +175,6 @@ static int
 nfp_netvf_close(struct rte_eth_dev *dev)
 {
 	struct rte_pci_device *pci_dev;
-	struct nfp_net_txq *this_tx_q;
-	struct nfp_net_rxq *this_rx_q;
-	int i;
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
@@ -204,17 +191,9 @@ nfp_netvf_close(struct rte_eth_dev *dev)
 	nfp_net_disable_queues(dev);
 
 	/* Clear queues */
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		this_tx_q =  (struct nfp_net_txq *)dev->data->tx_queues[i];
-		nfp_net_reset_tx_queue(this_tx_q);
-		nfp_net_tx_queue_release(dev, i);
-	}
+	nfp_net_close_tx_queue(dev);
 
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		this_rx_q =  (struct nfp_net_rxq *)dev->data->rx_queues[i];
-		nfp_net_reset_rx_queue(this_rx_q);
-		nfp_net_rx_queue_release(dev, i);
-	}
+	nfp_net_close_rx_queue(dev);
 
 	rte_intr_disable(pci_dev->intr_handle);
 
-- 
2.27.0


  parent reply	other threads:[~2022-06-23  2:28 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  1:52 [PATCH 00/14] Add support of NFP3800 chip and firmware with NFDk Jin Liu
2022-06-02  1:52 ` [PATCH 01/14] net/nfp: change the coding style Jin Liu
2022-06-02 22:52   ` Ferruh Yigit
2022-06-14  8:50     ` Kevin Liu
2022-06-02  1:52 ` [PATCH 02/14] net/nfp: remove unnecessary forward function declaration Jin Liu
2022-06-02  1:52 ` [PATCH 03/14] net/nfp: remove pessimistic limit Jin Liu
2022-06-02  1:52 ` [PATCH 04/14] net/nfp: rename set MAC function Jin Liu
2022-06-02  1:52 ` [PATCH 05/14] net/nfp: rename function and struct Jin Liu
2022-06-02  1:52 ` [PATCH 06/14] net/nfp: support NFP3800 card Jin Liu
2022-06-02 22:52   ` Ferruh Yigit
2022-06-14  8:50     ` Kevin Liu
2022-06-02  1:52 ` [PATCH 07/14] net/nfp: support NFDK firmware Jin Liu
2022-06-02 22:53   ` Ferruh Yigit
2022-06-14  8:49     ` Kevin Liu
2022-06-14  9:21       ` Ferruh Yigit
2022-06-14  9:30         ` Kevin Liu
2022-06-02  1:52 ` [PATCH 08/14] net/nfp: structure adjustment Jin Liu
2022-06-02 22:54   ` Ferruh Yigit
2022-06-14  8:49     ` Kevin Liu
2022-06-02  1:52 ` [PATCH 09/14] net/nfp: nfdk netdev option and queue function Jin Liu
2022-06-02  1:53 ` [PATCH 10/14] net/nfp: add queue stop and close helper function Jin Liu
2022-06-02  1:53 ` [PATCH 11/14] net/nfp: nfdk stop and close function Jin Liu
2022-06-02  1:53 ` [PATCH 12/14] net/nfp: move macro from C file to head file Jin Liu
2022-06-02  1:53 ` [PATCH 13/14] net/nfp: nfdk packet xmit function Jin Liu
2022-06-02  1:53 ` [PATCH 14/14] net/nfp: modify RSS logic Jin Liu
2022-06-02 22:56   ` Ferruh Yigit
2022-06-14  8:50     ` Kevin Liu
2022-06-02 22:51 ` [PATCH 00/14] Add support of NFP3800 chip and firmware with NFDk Ferruh Yigit
2022-06-14  8:48   ` Kevin Liu
2022-06-16  2:39 ` [PATCH v2 00/15] " Jin Liu
2022-06-16  2:39   ` [PATCH v2 01/15] doc: update release note Jin Liu
2022-06-16 15:04     ` Ferruh Yigit
2022-06-16  2:39   ` [PATCH v2 02/15] doc: update nfp documentation Jin Liu
2022-06-16 15:04     ` Ferruh Yigit
2022-06-16  2:39   ` [PATCH v2 03/15] net/nfp: change the coding style Jin Liu
2022-06-16  2:39   ` [PATCH v2 04/15] net/nfp: remove unnecessary forward function declaration Jin Liu
2022-06-16  2:39   ` [PATCH v2 05/15] net/nfp: remove pessimistic limit Jin Liu
2022-06-16  2:39   ` [PATCH v2 06/15] net/nfp: rename set MAC function Jin Liu
2022-06-16  2:39   ` [PATCH v2 07/15] net/nfp: rename function and struct Jin Liu
2022-06-16  2:39   ` [PATCH v2 08/15] net/nfp: support NFP3800 card Jin Liu
2022-06-16 15:04     ` Ferruh Yigit
2022-06-16  2:39   ` [PATCH v2 09/15] net/nfp: support firmware with NFDk Jin Liu
2022-06-16  2:39   ` [PATCH v2 10/15] net/nfp: structure adjustment Jin Liu
2022-06-16  2:39   ` [PATCH v2 11/15] net/nfp: nfdk netdev option and queue function Jin Liu
2022-06-16  2:39   ` [PATCH v2 12/15] net/nfp: add queue stop and close helper function Jin Liu
2022-06-16  2:39   ` [PATCH v2 13/15] net/nfp: move macro from C file to head file Jin Liu
2022-06-16  2:39   ` [PATCH v2 14/15] net/nfp: nfdk packet xmit function Jin Liu
2022-06-16  2:39   ` [PATCH v2 15/15] net/nfp: modify RSS logic Jin Liu
2022-06-16 15:06   ` [PATCH v2 00/15] Add support of NFP3800 chip and firmware with NFDk Ferruh Yigit
2022-06-17  9:34   ` [PATCH v3 00/13] " Jin Liu
2022-06-17  9:34     ` [PATCH v3 01/13] net/nfp: change the coding style Jin Liu
2022-06-17  9:34     ` [PATCH v3 02/13] net/nfp: remove unnecessary forward function declaration Jin Liu
2022-06-17  9:34     ` [PATCH v3 03/13] net/nfp: remove pessimistic limit Jin Liu
2022-06-17  9:34     ` [PATCH v3 04/13] net/nfp: rename set MAC function Jin Liu
2022-06-17  9:34     ` [PATCH v3 05/13] net/nfp: rename function and struct Jin Liu
2022-06-17  9:34     ` [PATCH v3 06/13] net/nfp: support NFP3800 card Jin Liu
2022-06-17  9:34     ` [PATCH v3 07/13] net/nfp: support firmware with NFDk Jin Liu
2022-06-17  9:34     ` [PATCH v3 08/13] net/nfp: structure adjustment Jin Liu
2022-06-17  9:34     ` [PATCH v3 09/13] net/nfp: nfdk netdev option and queue function Jin Liu
2022-06-17  9:34     ` [PATCH v3 10/13] net/nfp: add queue stop and close helper function Jin Liu
2022-06-17  9:34     ` [PATCH v3 11/13] net/nfp: move macro from C file to head file Jin Liu
2022-06-17  9:34     ` [PATCH v3 12/13] net/nfp: nfdk packet xmit function Jin Liu
2022-06-22 16:03       ` Thomas Monjalon
2022-06-22 16:29         ` Ferruh Yigit
2022-06-17  9:34     ` [PATCH v3 13/13] net/nfp: modify RSS logic Jin Liu
2022-06-17 13:33     ` [PATCH v3 00/13] Add support of NFP3800 chip and firmware with NFDk Ferruh Yigit
2022-06-23  2:26     ` [PATCH v4 " Jin Liu
2022-06-23  2:26       ` [PATCH v4 01/13] net/nfp: change the coding style Jin Liu
2022-06-23  2:26       ` [PATCH v4 02/13] net/nfp: remove unnecessary forward function declaration Jin Liu
2022-06-23  2:26       ` [PATCH v4 03/13] net/nfp: remove pessimistic limit Jin Liu
2022-06-23  2:26       ` [PATCH v4 04/13] net/nfp: rename set MAC function Jin Liu
2022-06-23  2:26       ` [PATCH v4 05/13] net/nfp: rename function and struct Jin Liu
2022-06-23  2:26       ` [PATCH v4 06/13] net/nfp: support NFP3800 card Jin Liu
2022-06-23  2:26       ` [PATCH v4 07/13] net/nfp: support firmware with NFDk Jin Liu
2022-06-23  2:26       ` [PATCH v4 08/13] net/nfp: structure adjustment Jin Liu
2022-06-23  2:26       ` [PATCH v4 09/13] net/nfp: nfdk netdev option and queue function Jin Liu
2022-06-23  2:26       ` Jin Liu [this message]
2022-06-23  2:26       ` [PATCH v4 11/13] net/nfp: move macro from C file to head file Jin Liu
2022-06-23  2:26       ` [PATCH v4 12/13] net/nfp: nfdk packet xmit function Jin Liu
2022-06-23  2:26       ` [PATCH v4 13/13] net/nfp: modify RSS logic Jin Liu
2022-06-23  9:11       ` [PATCH v4 00/13] Add support of NFP3800 chip and firmware with NFDk 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=20220623022615.3628093-11-jin.liu@corigine.com \
    --to=jin.liu@corigine.com \
    --cc=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=na.wang@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=peng.zhang@corigine.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).