All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH 4/4] net/hns3: supports disabling PFC by dev configure API
Date: Sun, 13 Jun 2021 11:05:08 +0800	[thread overview]
Message-ID: <1623553508-5478-5-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1623553508-5478-1-git-send-email-humin29@huawei.com>

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(-)

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 {
-- 
2.7.4


  parent reply	other threads:[~2021-06-13  3:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13  3:05 [dpdk-dev] [PATCH 0/4] features for hns3 PMD Min Hu (Connor)
2021-06-13  3:05 ` [dpdk-dev] [PATCH 1/4] net/hns3: add query basic info support for VF Min Hu (Connor)
2021-06-13  3:05 ` [dpdk-dev] [PATCH 2/4] net/hns3: support for VF modify VLAN filter state Min Hu (Connor)
2021-06-13  3:05 ` [dpdk-dev] [PATCH 3/4] net/hns3: support multiple TC MAC pause Min Hu (Connor)
2021-06-13  3:05 ` Min Hu (Connor) [this message]
2021-06-14 14:59   ` [dpdk-dev] [PATCH 4/4] net/hns3: supports disabling PFC by dev configure API Andrew Rybchenko
2021-06-14 15:00 ` [dpdk-dev] [PATCH 0/4] features for hns3 PMD Andrew Rybchenko
2021-07-09  1:32   ` Min Hu (Connor)
2021-07-09  9:20     ` Andrew Rybchenko
2021-07-10  1:59       ` Min Hu (Connor)
2021-07-10  1:58 ` [dpdk-dev] [PATCH v2 0/3] " Min Hu (Connor)
2021-07-10  1:58   ` [dpdk-dev] [PATCH v2 1/3] net/hns3: add query basic info support for VF Min Hu (Connor)
2021-07-10  1:58   ` [dpdk-dev] [PATCH v2 2/3] net/hns3: support for VF modify VLAN filter state Min Hu (Connor)
2021-07-10  1:58   ` [dpdk-dev] [PATCH v2 3/3] net/hns3: support multiple TC MAC pause Min Hu (Connor)
2021-07-13  9:43   ` [dpdk-dev] [PATCH v2 0/3] features for hns3 PMD Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1623553508-5478-5-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.