[1/4] net/hns3: fix segment fault with the multi-TC

Message ID 1605871656-51819-2-git-send-email-oulijun@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series hns3 fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Lijun Ou Nov. 20, 2020, 11:27 a.m. UTC
  From: Huisong Li <lihuisong@huawei.com>

The HW and SW DCB configurations need to be updated only
after the DCB configuration information changed. But the
change of tx/rx queue number is ignored. If user decreases
the number of tx queue after configuring multi-TC, the queue
mapping information in hns3_tc_queue_info can not be updated.
And then accessing the released queue resource in
"hns3_init_tx_ring_tc" will trigger a segment fault.

Fixes: 62e3ccc2b94c ("net/hns3: support flow control")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_dcb.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index ab02c87..fb50179 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -1351,6 +1351,8 @@  hns3_dcb_cfg_validate(struct hns3_adapter *hns, uint8_t *tc, bool *changed)
 {
 	struct rte_eth_dcb_rx_conf *dcb_rx_conf;
 	struct hns3_hw *hw = &hns->hw;
+	uint16_t nb_rx_q = hw->data->nb_rx_queues;
+	uint16_t nb_tx_q = hw->data->nb_tx_queues;
 	uint8_t max_tc = 0;
 	uint8_t pfc_en;
 	int i;
@@ -1376,6 +1378,10 @@  hns3_dcb_cfg_validate(struct hns3_adapter *hns, uint8_t *tc, bool *changed)
 	pfc_en = RTE_LEN2MASK((uint8_t)dcb_rx_conf->nb_tcs, uint8_t);
 	if (hw->dcb_info.pfc_en != pfc_en)
 		*changed = true;
+
+	/* tx/rx queue number is reconfigured. */
+	if (nb_rx_q != hw->used_rx_queues || nb_tx_q != hw->used_tx_queues)
+		*changed = true;
 }
 
 static int