From patchwork Fri Nov 20 11:27:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 84419 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A312A04DD; Fri, 20 Nov 2020 12:28:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D5685C908; Fri, 20 Nov 2020 12:27:34 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 8B6BBC87E for ; Fri, 20 Nov 2020 12:27:25 +0100 (CET) Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CcvQg1n5nz702y for ; Fri, 20 Nov 2020 19:27:07 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Fri, 20 Nov 2020 19:27:15 +0800 From: Lijun Ou To: CC: , Date: Fri, 20 Nov 2020 19:27:36 +0800 Message-ID: <1605871656-51819-5-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605871656-51819-1-git-send-email-oulijun@huawei.com> References: <1605871656-51819-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 4/4] net/hns3: fix FEC state query X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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: "Min Hu (Conor)" As FEC is not supported below 10 Gbps, CMD(0x031A) offered from Firmware read will return fail in 10 Gbps device. This patch will prevent read this CMD when below 10 Gbps, as this is non-sense. Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_ethdev.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index d6d3f03..faa7b0a 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -100,7 +100,7 @@ static int hns3_add_mc_addr(struct hns3_hw *hw, static int hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr); static int hns3_restore_fec(struct hns3_hw *hw); -static int hns3_query_dev_fec_info(struct rte_eth_dev *dev); +static int hns3_query_dev_fec_info(struct hns3_hw *hw); void hns3_ether_format_addr(char *buf, uint16_t size, const struct rte_ether_addr *ether_addr) @@ -3010,13 +3010,6 @@ hns3_get_capability(struct hns3_hw *hw) device_id == HNS3_DEV_ID_200G_RDMA) hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1); - ret = hns3_query_dev_fec_info(eth_dev); - if (ret) { - PMD_INIT_LOG(ERR, - "failed to query FEC information, ret = %d", ret); - return ret; - } - /* Get PCI revision id */ ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, HNS3_PCI_REVISION_ID); @@ -3148,8 +3141,15 @@ hns3_get_configuration(struct hns3_hw *hw) } ret = hns3_get_board_configuration(hw); - if (ret) + if (ret) { PMD_INIT_LOG(ERR, "failed to get board configuration: %d", ret); + return ret; + } + + ret = hns3_query_dev_fec_info(hw); + if (ret) + PMD_INIT_LOG(ERR, + "failed to query FEC information, ret = %d", ret); return ret; } @@ -5797,6 +5797,15 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) struct hns3_cmd_desc desc; int ret; + /* + * CMD(0x031A) read is not supported in device of link speed + * below 10 Gbps. + */ + if (hw->mac.link_speed < ETH_SPEED_NUM_10G) { + *state = 0; + return 0; + } + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CONFIG_FEC_MODE, true); req = (struct hns3_config_fec_cmd *)desc.data; ret = hns3_cmd_send(hw, &desc, 1); @@ -6003,14 +6012,15 @@ hns3_restore_fec(struct hns3_hw *hw) } static int -hns3_query_dev_fec_info(struct rte_eth_dev *dev) +hns3_query_dev_fec_info(struct hns3_hw *hw) { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); - struct hns3_pf *pf = &hns->pf; + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(hns); + struct rte_eth_dev *eth_dev; int ret; - ret = hns3_fec_get(dev, &pf->fec_mode); + eth_dev = &rte_eth_devices[hw->data->port_id]; + ret = hns3_fec_get(eth_dev, &pf->fec_mode); if (ret) hns3_err(hw, "query device FEC info failed, ret = %d", ret);