From 5b96963f9d121cee0eaaa19c19eca0ddbeee73b7 Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Sun, 13 Jun 2021 10:31:55 +0800 Subject: [PATCH] net/hns3: fix maximum queues on configuration failure The "cfg_max_queues" maintains configured max queue numbers from user, and is equal to the maximum of "nb_rx_queues" and "nb_tx_queues" in "dev->data". From the ethdev layer framework, "nb_rx/tx_queues" in "dev->data" were set to zero in rte_eth_dev_configure() if ops.dev_configure in PMD fails to be executed, In addition, if ops.dev_configure in HNS3 PMD failed, the fake queues are also cleared on a device that does not support independent Rx/Tx queues. Therefore, the "cfg_max_queues" should be also set to zero when dev_configure fails. Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 2 ++ drivers/net/hns3/hns3_ethdev_vf.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index ff219b8b52..d4561ffd90 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2501,6 +2501,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); if (ret) { hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret); + hw->cfg_max_queues = 0; return ret; } @@ -2549,6 +2550,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) return 0; cfg_err: + hw->cfg_max_queues = 0; (void)hns3_set_fake_rx_or_tx_queues(dev, 0, 0); hw->adapter_state = HNS3_NIC_INITIALIZED; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index c5f320fc5b..e387cd6177 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -804,6 +804,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); if (ret) { hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret); + hw->cfg_max_queues = 0; return ret; } @@ -863,6 +864,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) return 0; cfg_err: + hw->cfg_max_queues = 0; (void)hns3_set_fake_rx_or_tx_queues(dev, 0, 0); hw->adapter_state = HNS3_NIC_INITIALIZED; -- 2.20.1