diff mbox series

[4/4] net/hns3: supports disabling PFC by dev configure API

Message ID 1623553508-5478-5-git-send-email-humin29@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Andrew Rybchenko
Headers show
Series features for hns3 PMD | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-testing fail Testing issues
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) June 13, 2021, 3:05 a.m. UTC
From: Huisong Li <lihuisong@huawei.com>

If "dcb_capability_en" in "data->dev_conf" delivered from the dev_configure
does not have the ETH_DCB_PFC_SUPPORT flag, the user wants to disable PFC,
and only enable ETS. Therefore, this patch supports the function of
disabling PFC by the field. In addition, this patch updates
"current_fc_status" of the driver based on the flow control mode requested
by user so as to enable the flow control mode in multi-TC scenarios.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_dcb.c    | 61 +++++++++++++++++++++++-------------------
 drivers/net/hns3/hns3_ethdev.h |  1 +
 2 files changed, 34 insertions(+), 28 deletions(-)

Comments

Andrew Rybchenko June 14, 2021, 2:59 p.m. UTC | #1
On 6/13/21 6:05 AM, Min Hu (Connor) wrote:
> From: Huisong Li <lihuisong@huawei.com>
> 
> If "dcb_capability_en" in "data->dev_conf" delivered from the dev_configure
> does not have the ETH_DCB_PFC_SUPPORT flag, the user wants to disable PFC,
> and only enable ETS. Therefore, this patch supports the function of
> disabling PFC by the field. In addition, this patch updates
> "current_fc_status" of the driver based on the flow control mode requested
> by user so as to enable the flow control mode in multi-TC scenarios.
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

It looks like Clang 12 on Fedora 12 does not like the patch and
build fails. Please, take a look and fix it.
diff mbox series

Patch

diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 90c0d04..234a3e8 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -1427,10 +1427,12 @@  hns3_dcb_cfg_validate(struct hns3_adapter *hns, uint8_t *tc, bool *changed)
 	 * We ensure that dcb information can be reconfigured
 	 * after the hns3_priority_flow_ctrl_set function called.
 	 */
-	if (hw->requested_fc_mode != HNS3_FC_FULL)
+	if (hw->requested_fc_mode != HNS3_FC_FULL ||
+		hw->requested_fc_mode != HNS3_FC_NONE)
 		*changed = true;
 	pfc_en = RTE_LEN2MASK((uint8_t)dcb_rx_conf->nb_tcs, uint8_t);
-	if (hw->dcb_info.pfc_en != pfc_en)
+	if (hw->dcb_info.pfc_en != pfc_en || hw->dcb_info.dcb_capability_en !=
+		hw->data->dev_conf.dcb_capability_en)
 		*changed = true;
 
 	/* tx/rx queue number is reconfigured. */
@@ -1567,36 +1569,32 @@  hns3_dcb_hw_configure(struct hns3_adapter *hns)
 		hw->dcb_info.hw_pfc_map =
 				hns3_dcb_undrop_tc_map(hw, hw->dcb_info.pfc_en);
 
-		ret = hns3_buffer_alloc(hw);
-		if (ret)
-			goto buffer_alloc_fail;
-
 		hw->current_fc_status = HNS3_FC_STATUS_PFC;
 		hw->requested_fc_mode = HNS3_FC_FULL;
-		ret = hns3_dcb_pause_setup_hw(hw);
-		if (ret) {
-			hns3_err(hw, "setup pfc failed! ret = %d", ret);
-			goto pfc_setup_fail;
-		}
 	} else {
-		/*
-		 * Although dcb_capability_en is lack of ETH_DCB_PFC_SUPPORT
-		 * flag, the DCB information is configured, such as tc numbers.
-		 * Therefore, refreshing the allocation of packet buffer is
-		 * necessary.
-		 */
-		ret = hns3_buffer_alloc(hw);
-		if (ret)
-			return ret;
+		hw->current_fc_status = HNS3_FC_STATUS_NONE;
+		hw->requested_fc_mode = HNS3_FC_NONE;
+		hw->dcb_info.pfc_en = 0;
+		hw->dcb_info.hw_pfc_map = 0;
 	}
 
+	ret = hns3_buffer_alloc(hw);
+	if (ret)
+		goto cfg_fail;
+
+	ret = hns3_dcb_pause_setup_hw(hw);
+	if (ret) {
+		hns3_err(hw, "setup pfc failed! ret = %d", ret);
+		goto cfg_fail;
+	}
+
+	hw->dcb_info.dcb_capability_en = hw->data->dev_conf.dcb_capability_en;
+
 	return 0;
 
-pfc_setup_fail:
+cfg_fail:
 	hw->requested_fc_mode = requested_fc_mode;
 	hw->current_fc_status = fc_status;
-
-buffer_alloc_fail:
 	hw->dcb_info.pfc_en = pfc_en;
 	hw->dcb_info.hw_pfc_map = hw_pfc_map;
 
@@ -1781,15 +1779,21 @@  hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
 	uint16_t pause_time = pf->pause_time;
 	int ret;
 
-	pf->pause_time = pfc_conf->fc.pause_time;
-	hns3_get_fc_mode(hw, pfc_conf->fc.mode);
-	hw->current_fc_status = HNS3_FC_STATUS_PFC;
 	hw->dcb_info.pfc_en |= BIT(priority);
 	hw->dcb_info.hw_pfc_map =
 			hns3_dcb_undrop_tc_map(hw, hw->dcb_info.pfc_en);
 	ret = hns3_buffer_alloc(hw);
-	if (ret)
-		goto pfc_setup_fail;
+	if (ret) {
+		hns3_err(hw, "update packet buffer failed, ret = %d", ret);
+		goto buffer_alloc_fail;
+	}
+
+	pf->pause_time = pfc_conf->fc.pause_time;
+	hns3_get_fc_mode(hw, pfc_conf->fc.mode);
+	if (hw->requested_fc_mode == HNS3_FC_NONE)
+		hw->current_fc_status = HNS3_FC_STATUS_NONE;
+	else
+		hw->current_fc_status = HNS3_FC_STATUS_PFC;
 
 	/*
 	 * The flow control mode of all UPs will be changed based on
@@ -1807,6 +1811,7 @@  hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
 	hw->requested_fc_mode = old_fc_mode;
 	hw->current_fc_status = fc_status;
 	pf->pause_time = pause_time;
+buffer_alloc_fail:
 	hw->dcb_info.pfc_en = pfc_en;
 	hw->dcb_info.hw_pfc_map = hw_pfc_map;
 
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 5f448af..7ff8762 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -139,6 +139,7 @@  struct hns3_dcb_info {
 	struct hns3_tc_info tc_info[HNS3_MAX_TC_NUM];
 	uint8_t hw_pfc_map; /* Allow for packet drop or not on this TC */
 	uint8_t pfc_en; /* Pfc enabled or not for user priority */
+	uint32_t dcb_capability_en;
 };
 
 enum hns3_fc_status {