* [PATCH 1/6] net/hns3: fix querying dummy function failed
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
@ 2023-02-11 9:18 ` Dongdong Liu
2023-02-11 9:18 ` [PATCH 2/6] net/hns3: add debug info for Rx/Tx dummy function Dongdong Liu
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Dongdong Liu @ 2023-02-11 9:18 UTC (permalink / raw)
To: dev, ferruh.yigit, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, liudongdong3, lihuisong
From: Huisong Li <lihuisong@huawei.com>
The rte_eth_rx/tx_burst_mode_get API will fail when Rx/Tx
function is dummy.
Fixes: 7ef933908f04 ("net/hns3: add simple Tx path")
Fixes: 521ab3e93361 ("net/hns3: add simple Rx path")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 38 ++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index f1163ce8a9..feef9e1c7b 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2786,6 +2786,7 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
{ hns3_recv_scattered_pkts, "Scalar Scattered" },
{ hns3_recv_pkts_vec, "Vector Neon" },
{ hns3_recv_pkts_vec_sve, "Vector Sve" },
+ { rte_eth_pkt_burst_dummy, "Dummy" },
};
eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
@@ -4272,24 +4273,31 @@ int
hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
struct rte_eth_burst_mode *mode)
{
+ static const struct {
+ eth_tx_burst_t pkt_burst;
+ const char *info;
+ } burst_infos[] = {
+ { hns3_xmit_pkts_simple, "Scalar Simple" },
+ { hns3_xmit_pkts, "Scalar" },
+ { hns3_xmit_pkts_vec, "Vector Neon" },
+ { hns3_xmit_pkts_vec_sve, "Vector Sve" },
+ { rte_eth_pkt_burst_dummy, "Dummy" },
+ };
+
eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
- const char *info = NULL;
-
- if (pkt_burst == hns3_xmit_pkts_simple)
- info = "Scalar Simple";
- else if (pkt_burst == hns3_xmit_pkts)
- info = "Scalar";
- else if (pkt_burst == hns3_xmit_pkts_vec)
- info = "Vector Neon";
- else if (pkt_burst == hns3_xmit_pkts_vec_sve)
- info = "Vector Sve";
-
- if (info == NULL)
- return -EINVAL;
+ int ret = -EINVAL;
+ unsigned int i;
- snprintf(mode->info, sizeof(mode->info), "%s", info);
+ for (i = 0; i < RTE_DIM(burst_infos); i++) {
+ if (pkt_burst == burst_infos[i].pkt_burst) {
+ snprintf(mode->info, sizeof(mode->info), "%s",
+ burst_infos[i].info);
+ ret = 0;
+ break;
+ }
+ }
- return 0;
+ return ret;
}
static bool
--
2.22.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/6] net/hns3: add debug info for Rx/Tx dummy function
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
2023-02-11 9:18 ` [PATCH 1/6] net/hns3: fix querying dummy function failed Dongdong Liu
@ 2023-02-11 9:18 ` Dongdong Liu
2023-02-11 9:18 ` [PATCH 3/6] net/hns3: remove debug condition for Tx prepare Dongdong Liu
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Dongdong Liu @ 2023-02-11 9:18 UTC (permalink / raw)
To: dev, ferruh.yigit, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, liudongdong3, lihuisong
From: Huisong Li <lihuisong@huawei.com>
Now dummy function can be report by rte_eth_rx/tx_burst_mode_get.
So this patch adds debug info for Rx/Tx dummy function.
Fixes: 7feb2aee0e2c ("net/hns3: log selected datapath")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index feef9e1c7b..2524f4c3c2 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4420,13 +4420,13 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
hns3_get_tx_function(eth_dev, &prep);
eth_dev->tx_pkt_prepare = prep;
eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status;
- hns3_trace_rxtx_function(eth_dev);
} else {
eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy;
eth_dev->tx_pkt_burst = rte_eth_pkt_burst_dummy;
eth_dev->tx_pkt_prepare = NULL;
}
+ hns3_trace_rxtx_function(eth_dev);
hns3_eth_dev_fp_ops_config(eth_dev);
}
--
2.22.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/6] net/hns3: remove debug condition for Tx prepare
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
2023-02-11 9:18 ` [PATCH 1/6] net/hns3: fix querying dummy function failed Dongdong Liu
2023-02-11 9:18 ` [PATCH 2/6] net/hns3: add debug info for Rx/Tx dummy function Dongdong Liu
@ 2023-02-11 9:18 ` Dongdong Liu
2023-02-11 9:18 ` [PATCH 4/6] net/hns3: separate tx prepare from getting Tx function Dongdong Liu
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Dongdong Liu @ 2023-02-11 9:18 UTC (permalink / raw)
To: dev, ferruh.yigit, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, liudongdong3, lihuisong
From: Huisong Li <lihuisong@huawei.com>
The Tx prepare in driver is always needed if RTE_LIBRTE_ETHDEV_DEBUG
is defined. But it doesn't matter with this macro. Let's remove it.
Fixes: d7ec2c076579 ("net/hns3: select Tx prepare based on Tx offload")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 2524f4c3c2..921d72d69d 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4311,11 +4311,6 @@ hns3_tx_check_simple_support(struct rte_eth_dev *dev)
static bool
hns3_get_tx_prep_needed(struct rte_eth_dev *dev)
{
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
- RTE_SET_USED(dev);
- /* always perform tx_prepare when debug */
- return true;
-#else
#define HNS3_DEV_TX_CSKUM_TSO_OFFLOAD_MASK (\
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
@@ -4333,7 +4328,6 @@ hns3_get_tx_prep_needed(struct rte_eth_dev *dev)
return true;
return false;
-#endif
}
eth_tx_burst_t
--
2.22.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/6] net/hns3: separate tx prepare from getting Tx function
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
` (2 preceding siblings ...)
2023-02-11 9:18 ` [PATCH 3/6] net/hns3: remove debug condition for Tx prepare Dongdong Liu
@ 2023-02-11 9:18 ` Dongdong Liu
2023-02-11 9:18 ` [PATCH 5/6] net/hns3: remove getting Tx function from head file Dongdong Liu
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Dongdong Liu @ 2023-02-11 9:18 UTC (permalink / raw)
To: dev, ferruh.yigit, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, liudongdong3, lihuisong
From: Huisong Li <lihuisong@huawei.com>
Separate getting tx prepare from hns3_get_tx_function by extracting
an independent function.
Fixes: d7ec2c076579 ("net/hns3: select Tx prepare based on Tx offload")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 32 ++++++++++++++------------------
drivers/net/hns3/hns3_rxtx.h | 3 +--
2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 921d72d69d..9b2bd02857 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4324,26 +4324,30 @@ hns3_get_tx_prep_needed(struct rte_eth_dev *dev)
RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO)
uint64_t tx_offload = dev->data->dev_conf.txmode.offloads;
+
if (tx_offload & HNS3_DEV_TX_CSKUM_TSO_OFFLOAD_MASK)
return true;
return false;
}
+static eth_tx_prep_t
+hns3_get_tx_prepare(struct rte_eth_dev *dev)
+{
+ return hns3_get_tx_prep_needed(dev) ? hns3_prep_pkts : NULL;
+}
+
eth_tx_burst_t
-hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep)
+hns3_get_tx_function(struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
bool vec_allowed, sve_allowed, simple_allowed;
- bool vec_support, tx_prepare_needed;
+ bool vec_support;
vec_support = hns3_tx_check_vec_support(dev) == 0;
vec_allowed = vec_support && hns3_get_default_vec_support();
sve_allowed = vec_support && hns3_get_sve_support();
simple_allowed = hns3_tx_check_simple_support(dev);
- tx_prepare_needed = hns3_get_tx_prep_needed(dev);
-
- *prep = NULL;
if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_VEC && vec_allowed)
return hns3_xmit_pkts_vec;
@@ -4351,19 +4355,14 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep)
return hns3_xmit_pkts_vec_sve;
if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_SIMPLE && simple_allowed)
return hns3_xmit_pkts_simple;
- if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_COMMON) {
- if (tx_prepare_needed)
- *prep = hns3_prep_pkts;
+ if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_COMMON)
return hns3_xmit_pkts;
- }
if (vec_allowed)
return hns3_xmit_pkts_vec;
if (simple_allowed)
return hns3_xmit_pkts_simple;
- if (tx_prepare_needed)
- *prep = hns3_prep_pkts;
return hns3_xmit_pkts;
}
@@ -4403,7 +4402,6 @@ 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;
- eth_tx_prep_t prep = NULL;
if (hns->hw.adapter_state == HNS3_NIC_STARTED &&
__atomic_load_n(&hns->hw.reset.resetting, __ATOMIC_RELAXED) == 0) {
@@ -4411,8 +4409,8 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
eth_dev->rx_descriptor_status = hns3_dev_rx_descriptor_status;
eth_dev->tx_pkt_burst = hw->set_link_down ?
rte_eth_pkt_burst_dummy :
- hns3_get_tx_function(eth_dev, &prep);
- eth_dev->tx_pkt_prepare = prep;
+ hns3_get_tx_function(eth_dev);
+ eth_dev->tx_pkt_prepare = hns3_get_tx_prepare(eth_dev);
eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status;
} else {
eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy;
@@ -4758,10 +4756,8 @@ hns3_stop_tx_datapath(struct rte_eth_dev *dev)
void
hns3_start_tx_datapath(struct rte_eth_dev *dev)
{
- eth_tx_prep_t prep = NULL;
-
- dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep);
- dev->tx_pkt_prepare = prep;
+ dev->tx_pkt_burst = hns3_get_tx_function(dev);
+ dev->tx_pkt_prepare = hns3_get_tx_prepare(dev);
hns3_eth_dev_fp_ops_config(dev);
if (rte_eal_process_type() == RTE_PROC_SECONDARY)
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index ea1a805491..38c3581312 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -740,8 +740,7 @@ int hns3_tx_burst_mode_get(struct rte_eth_dev *dev,
const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev);
void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev);
void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev);
-eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev,
- eth_tx_prep_t *prep);
+eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev);
uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id);
void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id,
--
2.22.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/6] net/hns3: remove getting Tx function from head file
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
` (3 preceding siblings ...)
2023-02-11 9:18 ` [PATCH 4/6] net/hns3: separate tx prepare from getting Tx function Dongdong Liu
@ 2023-02-11 9:18 ` Dongdong Liu
2023-02-11 9:18 ` [PATCH 6/6] net/hns3: extract common functions to set Rx/Tx Dongdong Liu
2023-02-14 11:54 ` [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Ferruh Yigit
6 siblings, 0 replies; 8+ messages in thread
From: Dongdong Liu @ 2023-02-11 9:18 UTC (permalink / raw)
To: dev, ferruh.yigit, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, liudongdong3, lihuisong
From: Huisong Li <lihuisong@huawei.com>
The hns3_get_tx_function() is an intrinsic function now and should
not be open to other files.
Fixes: 96c33cfb06cf ("net/hns3: fix Rx/Tx functions update")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 2 +-
drivers/net/hns3/hns3_rxtx.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 9b2bd02857..def22bcd30 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4337,7 +4337,7 @@ hns3_get_tx_prepare(struct rte_eth_dev *dev)
return hns3_get_tx_prep_needed(dev) ? hns3_prep_pkts : NULL;
}
-eth_tx_burst_t
+static eth_tx_burst_t
hns3_get_tx_function(struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index 38c3581312..1bdc124b7b 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -740,8 +740,6 @@ int hns3_tx_burst_mode_get(struct rte_eth_dev *dev,
const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev);
void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev);
void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev);
-eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev);
-
uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id);
void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id,
uint8_t gl_idx, uint16_t gl_value);
--
2.22.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/6] net/hns3: extract common functions to set Rx/Tx
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
` (4 preceding siblings ...)
2023-02-11 9:18 ` [PATCH 5/6] net/hns3: remove getting Tx function from head file Dongdong Liu
@ 2023-02-11 9:18 ` Dongdong Liu
2023-02-14 11:54 ` [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Ferruh Yigit
6 siblings, 0 replies; 8+ messages in thread
From: Dongdong Liu @ 2023-02-11 9:18 UTC (permalink / raw)
To: dev, ferruh.yigit, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, liudongdong3, lihuisong
From: Huisong Li <lihuisong@huawei.com>
Extract two common functions to set Rx/Tx function in order to
reduce duplicate codes.
Fixes: 23d4b61fee5d ("net/hns3: support multiple process")
Cc: stable@dpdk.org
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 ab565ce128..6babf67fce 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5052,8 +5052,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);
@@ -5131,12 +5130,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) {
@@ -5752,12 +5746,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 ||
@@ -5790,8 +5779,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 d3c1bdf2c5..d051a1357b 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1572,12 +1572,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) {
@@ -1731,8 +1726,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);
@@ -1902,11 +1896,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 ||
@@ -1938,8 +1928,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);
rte_eal_alarm_set(HNS3VF_KEEP_ALIVE_INTERVAL, hns3vf_keep_alive_handler,
eth_dev);
diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c
index 7184f9ad58..556f1941c6 100644
--- a/drivers/net/hns3/hns3_mp.c
+++ b/drivers/net/hns3/hns3_mp.c
@@ -89,12 +89,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 def22bcd30..4065c519c3 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4765,3 +4765,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 1bdc124b7b..fa39f6481a 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -773,5 +773,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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function
2023-02-11 9:18 [PATCH 0/6] net/hns3: some code optimization for Rx/Tx function Dongdong Liu
` (5 preceding siblings ...)
2023-02-11 9:18 ` [PATCH 6/6] net/hns3: extract common functions to set Rx/Tx Dongdong Liu
@ 2023-02-14 11:54 ` Ferruh Yigit
6 siblings, 0 replies; 8+ messages in thread
From: Ferruh Yigit @ 2023-02-14 11:54 UTC (permalink / raw)
To: Dongdong Liu, dev, thomas, andrew.rybchenko
Cc: stable, yisen.zhuang, lihuisong
On 2/11/2023 9:18 AM, Dongdong Liu wrote:
> This patchset is to do some code optimization for Rx/Tx function.
>
> Huisong Li (6):
> net/hns3: fix querying dummy function failed
> net/hns3: add debug info for Rx/Tx dummy function
> net/hns3: remove debug condition for Tx prepare
> net/hns3: separate tx prepare from getting Tx function
> net/hns3: remove getting Tx function from head file
> net/hns3: extract common functions to set Rx/Tx
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread