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 0478FA0544 for ; Wed, 22 Jun 2022 05:10:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F31E440DDB; Wed, 22 Jun 2022 05:10:29 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 75CEE40151; Wed, 22 Jun 2022 05:10:26 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSSxs0zQvz1KBlW; Wed, 22 Jun 2022 11:08:17 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 22 Jun 2022 11:10:23 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , "Min Hu (Connor)" , Yisen Zhuang , Lijun Ou Subject: [PATCH V2 2/2] net/hns3: support backplane media type Date: Wed, 22 Jun 2022 11:09:57 +0800 Message-ID: <20220622030957.20615-1-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220611074227.30276-3-liudongdong3@huawei.com> References: <20220611074227.30276-3-liudongdong3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500017.china.huawei.com (7.221.188.110) 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 From: Chengwen Feng The 802.11 physical PMA sub-layer defines three media: copper, fiber and backplane. For PMD, the backplane is similar to the fiber, the main differences are that backplane doesn't have optical module. Because the interface of firmware fiber is also applicable to the backplane, this patch supports the backplane only through simple extension. Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- v1->v2: - document new 'backplane' media type support in release notes. --- doc/guides/rel_notes/release_22_07.rst | 4 ++ drivers/net/hns3/hns3_ethdev.c | 54 ++++++++++++++------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index dd371952c3..7884ecfd09 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -172,6 +172,10 @@ New Features * Added support for yt8531s PHY. +* **Updated HiSilicon hns3 driver.** + + * Added support for backplane media type. + * **Added Elliptic Curve Diffie-Hellman (ECDH) algorithm in cryptodev.** Added support for Elliptic Curve Diffie Hellman (ECDH) asymmetric diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 6c77c8b964..b17a3e8669 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2787,11 +2787,8 @@ hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type) } break; case HNS3_MEDIA_TYPE_FIBER: - ret = 0; - break; case HNS3_MEDIA_TYPE_BACKPLANE: - PMD_INIT_LOG(ERR, "Media type is Backplane, not supported."); - ret = -EOPNOTSUPP; + ret = 0; break; default: PMD_INIT_LOG(ERR, "Unknown media type = %u!", media_type); @@ -4244,14 +4241,11 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev) { struct hns3_adapter *hns = eth_dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - int ret = 0; if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) - ret = hns3_update_copper_link_info(hw); - else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) - ret = hns3_update_fiber_link_info(hw); + return hns3_update_copper_link_info(hw); - return ret; + return hns3_update_fiber_link_info(hw); } static int @@ -4544,11 +4538,13 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev) if (ret) return ret; - if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) { + if (mac->media_type == HNS3_MEDIA_TYPE_FIBER || + mac->media_type == HNS3_MEDIA_TYPE_BACKPLANE) { /* * Some firmware does not support the report of supported_speed, - * and only report the effective speed of SFP. In this case, it - * is necessary to use the SFP's speed as the supported_speed. + * and only report the effective speed of SFP/backplane. In this + * case, it is necessary to use the SFP/backplane's speed as the + * supported_speed. */ if (mac->supported_speed == 0) mac->supported_speed = @@ -4810,7 +4806,7 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds) if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) speed_bit = hns3_convert_link_speeds2bitmap_copper(link_speeds); - else if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) + else speed_bit = hns3_convert_link_speeds2bitmap_fiber(link_speeds); if (!(speed_bit & supported_speed)) { @@ -4954,6 +4950,19 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw, return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex); } +static const char * +hns3_get_media_type_name(uint8_t media_type) +{ + if (media_type == HNS3_MEDIA_TYPE_FIBER) + return "fiber"; + else if (media_type == HNS3_MEDIA_TYPE_COPPER) + return "copper"; + else if (media_type == HNS3_MEDIA_TYPE_BACKPLANE) + return "backplane"; + else + return "unknown"; +} + static int hns3_set_port_link_speed(struct hns3_hw *hw, struct hns3_set_link_speed_cfg *cfg) @@ -4968,18 +4977,15 @@ hns3_set_port_link_speed(struct hns3_hw *hw, #endif ret = hns3_set_copper_port_link_speed(hw, cfg); - if (ret) { - hns3_err(hw, "failed to set copper port link speed," - "ret = %d.", ret); - return ret; - } - } else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) { + } else { ret = hns3_set_fiber_port_link_speed(hw, cfg); - if (ret) { - hns3_err(hw, "failed to set fiber port link speed," - "ret = %d.", ret); - return ret; - } + } + + if (ret) { + hns3_err(hw, "failed to set %s port link speed, ret = %d.", + hns3_get_media_type_name(hw->mac.media_type), + ret); + return ret; } return 0; -- 2.22.0