Skip to content

Commit

Permalink
net/hns3: fix Rx/Tx functions update
Browse files Browse the repository at this point in the history
[ upstream commit 96c33cf ]

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: bba6366 ("net/hns3: support Rx/Tx and related operations")
Fixes: 168b7d7 ("net/hns3: support set link up/down for PF")

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
  • Loading branch information
hushenggitcount authored and kevintraynor committed Feb 21, 2022
1 parent 581e547 commit e073f41
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
7 changes: 2 additions & 5 deletions drivers/net/hns3/hns3_mp.c
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
28 changes: 27 additions & 1 deletion drivers/net/hns3/hns3_rxtx.c
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

0 comments on commit e073f41

Please sign in to comment.