DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <thomas@monjalon.net>
Subject: [PATCH 1/3] net/hns3: fix Rx/Tx when fast path operation introduced
Date: Mon, 17 Jan 2022 10:43:00 +0800	[thread overview]
Message-ID: <20220117024302.16006-2-humin29@huawei.com> (raw)
In-Reply-To: <20220117024302.16006-1-humin29@huawei.com>

When fast path operation is introduced, the Rx/Tx function is done by
object 'rte_eth_fp_ops'. So 'rte_eth_fp_ops' should be updated if
'fast-path functions' need to be changed, such as PMD receive function,
prepare function and so on.

This patch fixed receiving packets bug when fast path operation is
introduced.

Fixes: bba63669831 ("net/hns3: support Rx/Tx and related operations")
Fixes: 168b7d79dada ("net/hns3: support set link up/down for PF")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_mp.c   |  7 ++-----
 drivers/net/hns3/hns3_rxtx.c | 28 +++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c
index 999b407f7d..e74ddea195 100644
--- a/drivers/net/hns3/hns3_mp.c
+++ b/drivers/net/hns3/hns3_mp.c
@@ -74,7 +74,6 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	struct hns3_mp_param *res = (struct hns3_mp_param *)mp_res.param;
 	const struct hns3_mp_param *param =
 		(const struct hns3_mp_param *)mp_msg->param;
-	eth_tx_prep_t prep = NULL;
 	struct rte_eth_dev *dev;
 	int ret;
 
@@ -98,14 +97,12 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	case HNS3_MP_REQ_START_TX:
 		PMD_INIT_LOG(INFO, "port %u starting Tx datapath",
 			     dev->data->port_id);
-		dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep);
-		dev->tx_pkt_prepare = prep;
+		hns3_start_tx_datapath(dev);
 		break;
 	case HNS3_MP_REQ_STOP_TX:
 		PMD_INIT_LOG(INFO, "port %u stopping Tx datapath",
 			     dev->data->port_id);
-		dev->tx_pkt_burst = hns3_dummy_rxtx_burst;
-		dev->tx_pkt_prepare = NULL;
+		hns3_stop_tx_datapath(dev);
 		break;
 	default:
 		rte_errno = EINVAL;
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index d240e36e6a..c86aeb2366 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4408,7 +4408,21 @@ hns3_trace_rxtx_function(struct rte_eth_dev *dev)
 		 rx_mode.info, tx_mode.info);
 }
 
-void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
+static void
+hns3_eth_dev_fp_ops_config(const struct rte_eth_dev *dev)
+{
+	struct rte_eth_fp_ops *fpo = rte_eth_fp_ops;
+	uint16_t port_id = dev->data->port_id;
+
+	fpo[port_id].rx_pkt_burst = dev->rx_pkt_burst;
+	fpo[port_id].tx_pkt_burst = dev->tx_pkt_burst;
+	fpo[port_id].tx_pkt_prepare = dev->tx_pkt_prepare;
+	fpo[port_id].rx_descriptor_status = dev->rx_descriptor_status;
+	fpo[port_id].tx_descriptor_status = dev->tx_descriptor_status;
+}
+
+void
+hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
 {
 	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct hns3_adapter *hns = eth_dev->data->dev_private;
@@ -4429,6 +4443,8 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
 		eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst;
 		eth_dev->tx_pkt_prepare = NULL;
 	}
+
+	hns3_eth_dev_fp_ops_config(eth_dev);
 }
 
 void
@@ -4729,6 +4745,11 @@ hns3_stop_tx_datapath(struct rte_eth_dev *dev)
 {
 	dev->tx_pkt_burst = hns3_dummy_rxtx_burst;
 	dev->tx_pkt_prepare = NULL;
+	hns3_eth_dev_fp_ops_config(dev);
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return;
+
 	rte_wmb();
 	/* Disable tx datapath on secondary process. */
 	hns3_mp_req_stop_tx(dev);
@@ -4743,5 +4764,10 @@ hns3_start_tx_datapath(struct rte_eth_dev *dev)
 
 	dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep);
 	dev->tx_pkt_prepare = prep;
+	hns3_eth_dev_fp_ops_config(dev);
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return;
+
 	hns3_mp_req_start_tx(dev);
 }
-- 
2.33.0


  reply	other threads:[~2022-01-17  2:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  2:42 [PATCH 0/3] three bugfixes for hns3 PMD Min Hu (Connor)
2022-01-17  2:43 ` Min Hu (Connor) [this message]
2022-01-17  2:43 ` [PATCH 2/3] net/hns3: fix mailbox wait time uninitialization Min Hu (Connor)
2022-01-17  2:43 ` [PATCH 3/3] net/hns3: fix vector burst unsupported when PTP enable Min Hu (Connor)
2022-01-26 14:53 ` [PATCH 0/3] three bugfixes for hns3 PMD 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=20220117024302.16006-2-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /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).