From patchwork Sun Jun 13 03:05:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 94156 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E9E1A0C40; Sun, 13 Jun 2021 05:05:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E9D941102; Sun, 13 Jun 2021 05:05:38 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 44E504003F for ; Sun, 13 Jun 2021 05:05:33 +0200 (CEST) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4G2fWy4v4jzZgXY for ; Sun, 13 Jun 2021 11:02:38 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sun, 13 Jun 2021 11:05:31 +0800 From: "Min Hu (Connor)" To: CC: Date: Sun, 13 Jun 2021 11:05:08 +0800 Message-ID: <1623553508-5478-5-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623553508-5478-1-git-send-email-humin29@huawei.com> References: <1623553508-5478-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 4/4] net/hns3: supports disabling PFC by dev configure API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Huisong Li 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 Signed-off-by: Min Hu (Connor) --- 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 {