patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Huisong Li <lihuisong@huawei.com>
To: <stable@dpdk.org>, <ktraynor@redhat.com>
Cc: <liudongdong3@huawei.com>, <huangdaode@huawei.com>,
	<liuyonglong@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH 21.11 05/17] net/hns3: extract common functions to set Rx/Tx
Date: Tue, 21 Mar 2023 17:22:54 +0800	[thread overview]
Message-ID: <20230321092306.16918-6-lihuisong@huawei.com> (raw)
In-Reply-To: <20230321092306.16918-1-lihuisong@huawei.com>

[ upstream commit 4ba28c957a16bbfe5b2a8d49dfda1c85387d7602 ]

Extract two common functions to set Rx/Tx function in order to
reduce duplicate codes.

Fixes: 23d4b61fee5d ("net/hns3: support multiple process")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    | 20 ++++----------------
 drivers/net/hns3/hns3_ethdev_vf.c | 19 ++++---------------
 drivers/net/hns3/hns3_mp.c        |  4 ++--
 drivers/net/hns3/hns3_rxtx.c      | 28 ++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  2 ++
 5 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index be6a92a313..fd82e98693 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5077,8 +5077,7 @@ hns3_dev_start(struct rte_eth_dev *dev)
 	rte_spinlock_unlock(&hw->lock);
 
 	hns3_rx_scattered_calc(dev);
-	hns3_set_rxtx_function(dev);
-	hns3_mp_req_start_rxtx(dev);
+	hns3_start_rxtx_datapath(dev);
 
 	/* Enable interrupt of all rx queues before enabling queues */
 	hns3_dev_all_rx_queue_intr_enable(hw, true);
@@ -5156,12 +5155,7 @@ hns3_dev_stop(struct rte_eth_dev *dev)
 	dev->data->dev_started = 0;
 
 	hw->adapter_state = HNS3_NIC_STOPPING;
-	hns3_set_rxtx_function(dev);
-	rte_wmb();
-	/* Disable datapath on secondary process. */
-	hns3_mp_req_stop_rxtx(dev);
-	/* Prevent crashes when queues are still in use. */
-	rte_delay_ms(hw->cfg_max_queues);
+	hns3_stop_rxtx_datapath(dev);
 
 	rte_spinlock_lock(&hw->lock);
 	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) {
@@ -5777,12 +5771,7 @@ hns3_stop_service(struct hns3_adapter *hns)
 		rte_eal_alarm_cancel(hns3_service_handler, eth_dev);
 		hns3_update_linkstatus_and_event(hw, false);
 	}
-
-	hns3_set_rxtx_function(eth_dev);
-	rte_wmb();
-	/* Disable datapath on secondary process. */
-	hns3_mp_req_stop_rxtx(eth_dev);
-	rte_delay_ms(hw->cfg_max_queues);
+	hns3_stop_rxtx_datapath(eth_dev);
 
 	rte_spinlock_lock(&hw->lock);
 	if (hns->hw.adapter_state == HNS3_NIC_STARTED ||
@@ -5815,8 +5804,7 @@ hns3_start_service(struct hns3_adapter *hns)
 	    hw->reset.level == HNS3_GLOBAL_RESET)
 		hns3_set_rst_done(hw);
 	eth_dev = &rte_eth_devices[hw->data->port_id];
-	hns3_set_rxtx_function(eth_dev);
-	hns3_mp_req_start_rxtx(eth_dev);
+	hns3_start_rxtx_datapath(eth_dev);
 	if (hw->adapter_state == HNS3_NIC_STARTED) {
 		/*
 		 * This API parent function already hold the hns3_hw.lock, the
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 0e66a82178..729c1477cc 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1619,12 +1619,7 @@ hns3vf_dev_stop(struct rte_eth_dev *dev)
 	dev->data->dev_started = 0;
 
 	hw->adapter_state = HNS3_NIC_STOPPING;
-	hns3_set_rxtx_function(dev);
-	rte_wmb();
-	/* Disable datapath on secondary process. */
-	hns3_mp_req_stop_rxtx(dev);
-	/* Prevent crashes when queues are still in use. */
-	rte_delay_ms(hw->cfg_max_queues);
+	hns3_stop_rxtx_datapath(dev);
 
 	rte_spinlock_lock(&hw->lock);
 	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) {
@@ -1778,8 +1773,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev)
 	rte_spinlock_unlock(&hw->lock);
 
 	hns3_rx_scattered_calc(dev);
-	hns3_set_rxtx_function(dev);
-	hns3_mp_req_start_rxtx(dev);
+	hns3_start_rxtx_datapath(dev);
 
 	/* Enable interrupt of all rx queues before enabling queues */
 	hns3_dev_all_rx_queue_intr_enable(hw, true);
@@ -1949,11 +1943,7 @@ hns3vf_stop_service(struct hns3_adapter *hns)
 	}
 	hw->mac.link_status = RTE_ETH_LINK_DOWN;
 
-	hns3_set_rxtx_function(eth_dev);
-	rte_wmb();
-	/* Disable datapath on secondary process. */
-	hns3_mp_req_stop_rxtx(eth_dev);
-	rte_delay_ms(hw->cfg_max_queues);
+	hns3_stop_rxtx_datapath(eth_dev);
 
 	rte_spinlock_lock(&hw->lock);
 	if (hw->adapter_state == HNS3_NIC_STARTED ||
@@ -1983,8 +1973,7 @@ hns3vf_start_service(struct hns3_adapter *hns)
 	struct rte_eth_dev *eth_dev;
 
 	eth_dev = &rte_eth_devices[hw->data->port_id];
-	hns3_set_rxtx_function(eth_dev);
-	hns3_mp_req_start_rxtx(eth_dev);
+	hns3_start_rxtx_datapath(eth_dev);
 	if (hw->adapter_state == HNS3_NIC_STARTED) {
 		hns3vf_start_poll_job(eth_dev);
 
diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c
index e74ddea195..c3005b943f 100644
--- a/drivers/net/hns3/hns3_mp.c
+++ b/drivers/net/hns3/hns3_mp.c
@@ -87,12 +87,12 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case HNS3_MP_REQ_START_RXTX:
 		PMD_INIT_LOG(INFO, "port %u starting datapath",
 			     dev->data->port_id);
-		hns3_set_rxtx_function(dev);
+		hns3_start_rxtx_datapath(dev);
 		break;
 	case HNS3_MP_REQ_STOP_RXTX:
 		PMD_INIT_LOG(INFO, "port %u stopping datapath",
 			     dev->data->port_id);
-		hns3_set_rxtx_function(dev);
+		hns3_stop_rxtx_datapath(dev);
 		break;
 	case HNS3_MP_REQ_START_TX:
 		PMD_INIT_LOG(INFO, "port %u starting Tx datapath",
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 305d8f3744..bf091a7500 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4784,3 +4784,31 @@ hns3_start_tx_datapath(struct rte_eth_dev *dev)
 
 	hns3_mp_req_start_tx(dev);
 }
+
+void
+hns3_stop_rxtx_datapath(struct rte_eth_dev *dev)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hns3_set_rxtx_function(dev);
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return;
+
+	rte_wmb();
+	/* Disable datapath on secondary process. */
+	hns3_mp_req_stop_rxtx(dev);
+	/* Prevent crashes when queues are still in use. */
+	rte_delay_ms(hw->cfg_max_queues);
+}
+
+void
+hns3_start_rxtx_datapath(struct rte_eth_dev *dev)
+{
+	hns3_set_rxtx_function(dev);
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return;
+
+	hns3_mp_req_start_rxtx(dev);
+}
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index c2876b3a11..a5260e8850 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -766,5 +766,7 @@ int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
 void hns3_tx_push_init(struct rte_eth_dev *dev);
 void hns3_stop_tx_datapath(struct rte_eth_dev *dev);
 void hns3_start_tx_datapath(struct rte_eth_dev *dev);
+void hns3_stop_rxtx_datapath(struct rte_eth_dev *dev);
+void hns3_start_rxtx_datapath(struct rte_eth_dev *dev);
 
 #endif /* _HNS3_RXTX_H_ */
-- 
2.22.0


  parent reply	other threads:[~2023-03-21  9:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  9:22 [PATCH 21.11 00/17] backport some patches for hns3 Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 01/17] net/hns3: separate Tx prepare from getting Tx function Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 02/17] net/hns3: make getting Tx function static Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 03/17] net/hns3: fix RSS key size compatibility Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 04/17] net/hns3: fix burst mode query with dummy function Huisong Li
2023-03-21  9:22 ` Huisong Li [this message]
2023-03-21  9:22 ` [PATCH 21.11 06/17] net/hns3: use hardware config to report hash key Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 07/17] net/hns3: use hardware config to report hash types Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 08/17] net/hns3: separate setting hash algorithm Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 09/17] net/hns3: separate setting hash key Huisong Li
2023-03-21  9:22 ` [PATCH 21.11 10/17] net/hns3: separate setting RSS types Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 11/17] net/hns3: use new RSS rule to configure hardware Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 12/17] net/hns3: save hash algo to RSS filter list node Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 13/17] net/hns3: remove unused structures Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 14/17] net/hns3: allow adding queue buffer size hash rule Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 15/17] net/hns3: separate flow RSS config from RSS conf Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 16/17] net/hns3: reimplement hash flow function Huisong Li
2023-03-21  9:23 ` [PATCH 21.11 17/17] net/hns3: add verification of RSS types Huisong Li
2023-03-21 16:21 ` [PATCH 21.11 00/17] backport some patches for hns3 Kevin Traynor

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=20230321092306.16918-6-lihuisong@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=huangdaode@huawei.com \
    --cc=ktraynor@redhat.com \
    --cc=liudongdong3@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=stable@dpdk.org \
    /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).