From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5C81342F65 for ; Fri, 28 Jul 2023 06:22:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 547324021E; Fri, 28 Jul 2023 06:22:16 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 2116D4021D for ; Fri, 28 Jul 2023 06:22:15 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RBvY440CFzLnsw; Fri, 28 Jul 2023 12:19:36 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 28 Jul 2023 12:22:13 +0800 From: Jie Hai To: , , "Min Hu (Connor)" , Yisen Zhuang , Lijun Ou Subject: [PATCH 21.11 2/2] net/hns3: get FEC capability from firmware Date: Fri, 28 Jul 2023 12:18:58 +0800 Message-ID: <20230728041858.49451-3-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230728041858.49451-1-haijie1@huawei.com> References: <20230728041858.49451-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit cd41a2715457aa65f234b08e81c2246be24274f2 ] Obtain the supported FEC capability from the firmware to enhance code compatibility. Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_cmd.h | 9 ++++++++- drivers/net/hns3/hns3_ethdev.c | 29 ++++++++++++++++++++++++++++- drivers/net/hns3/hns3_ethdev.h | 2 ++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h index ebe1a657d64d..79b902360235 100644 --- a/drivers/net/hns3/hns3_cmd.h +++ b/drivers/net/hns3/hns3_cmd.h @@ -785,6 +785,12 @@ struct hns3_sfp_type { #define HNS3_FIBER_LINK_SPEED_10M_BIT BIT(7) #define HNS3_FIBER_LINK_SPEED_200G_BIT BIT(8) +#define HNS3_FIBER_FEC_AUTO_BIT BIT(0) +#define HNS3_FIBER_FEC_BASER_BIT BIT(1) +#define HNS3_FIBER_FEC_RS_BIT BIT(2) +#define HNS3_FIBER_FEC_LLRS_BIT BIT(3) +#define HNS3_FIBER_FEC_NOFEC_BIT BIT(4) + struct hns3_sfp_info_cmd { uint32_t sfp_speed; uint8_t query_type; /* 0: sfp speed, 1: active */ @@ -794,7 +800,8 @@ struct hns3_sfp_info_cmd { uint8_t autoneg_ability; uint32_t supported_speed; /* speed supported by current media */ uint32_t module_type; - uint8_t rsv1[8]; + uint8_t fec_ability; /* supported fec modes, see HNS3_FIBER_FEC_XXX_BIT */ + uint8_t rsv1[7]; }; #define HNS3_MAC_CFG_FEC_AUTO_EN_B 0 diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 2afc0d0a9d36..ed85caa7bd55 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4058,6 +4058,7 @@ hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info) mac_info->support_autoneg = resp->autoneg_ability; mac_info->link_autoneg = (resp->autoneg == 0) ? RTE_ETH_LINK_FIXED : RTE_ETH_LINK_AUTONEG; + mac_info->fec_capa = resp->fec_ability; } else { mac_info->query_type = HNS3_DEFAULT_QUERY; } @@ -4140,7 +4141,7 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) mac->supported_speed = mac_info.supported_speed; mac->support_autoneg = mac_info.support_autoneg; mac->link_autoneg = mac_info.link_autoneg; - + mac->fec_capa = mac_info.fec_capa; return 0; } @@ -6149,11 +6150,37 @@ hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) return ret; } +static uint32_t +hns3_parse_hw_fec_capa(uint8_t hw_fec_capa) +{ + const struct { + uint32_t hw_fec_capa; + uint32_t fec_capa; + } fec_capa_map[] = { + { HNS3_FIBER_FEC_AUTO_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) }, + { HNS3_FIBER_FEC_BASER_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(BASER) }, + { HNS3_FIBER_FEC_RS_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(RS) }, + { HNS3_FIBER_FEC_NOFEC_BIT, RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) }, + }; + uint32_t capa = 0; + uint32_t i; + + for (i = 0; i < RTE_DIM(fec_capa_map); i++) { + if ((hw_fec_capa & fec_capa_map[i].hw_fec_capa) != 0) + capa |= fec_capa_map[i].fec_capa; + } + + return capa; +} + static uint32_t hns3_get_current_speed_fec_cap(struct hns3_mac *mac) { uint32_t i; + if (mac->fec_capa != 0) + return hns3_parse_hw_fec_capa(mac->fec_capa); + for (i = 0; i < RTE_DIM(speed_fec_capa_tbl); i++) { if (mac->link_speed == speed_fec_capa_tbl[i].speed) return speed_fec_capa_tbl[i].capa; diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index ff666c4979c7..3496be6f7374 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -216,6 +216,8 @@ struct hns3_mac { uint32_t advertising; /* advertised capability in the local part */ uint32_t lp_advertising; /* advertised capability in the link partner */ uint8_t support_autoneg; + /* current supported fec modes. see HNS3_FIBER_FEC_XXX_BIT */ + uint32_t fec_capa; }; struct hns3_fake_queue_data { -- 2.33.0