From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19E46A034F; Mon, 17 Jan 2022 03:43:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 23D32411CB; Mon, 17 Jan 2022 03:42:48 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id EC300410F7 for ; Mon, 17 Jan 2022 03:42:43 +0100 (CET) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Jcbh32bK6z1FCcd; Mon, 17 Jan 2022 10:38:59 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Mon, 17 Jan 2022 10:42:41 +0800 From: "Min Hu (Connor)" To: CC: , Subject: [PATCH 1/3] net/hns3: fix Rx/Tx when fast path operation introduced Date: Mon, 17 Jan 2022 10:43:00 +0800 Message-ID: <20220117024302.16006-2-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220117024302.16006-1-humin29@huawei.com> References: <20220117024302.16006-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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) --- 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