Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/127171/?format=api
http://patches.dpdk.org/api/patches/127171/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230522131740.30043-3-liudongdong3@huawei.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20230522131740.30043-3-liudongdong3@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230522131740.30043-3-liudongdong3@huawei.com", "date": "2023-05-22T13:17:37", "name": "[v2,2/5] net/hns3: add flow control autoneg for fiber port", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "5766c3cbf097816123a9e604b516f7593e471865", "submitter": { "id": 2718, "url": "http://patches.dpdk.org/api/people/2718/?format=api", "name": "Dongdong Liu", "email": "liudongdong3@huawei.com" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230522131740.30043-3-liudongdong3@huawei.com/mbox/", "series": [ { "id": 28114, "url": "http://patches.dpdk.org/api/series/28114/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28114", "date": "2023-05-22T13:17:35", "name": "net/hns3: add some features and bugfixes", "version": 2, "mbox": "http://patches.dpdk.org/series/28114/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/127171/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/127171/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 228D942B71;\n\tMon, 22 May 2023 15:20:08 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 85D1442D37;\n\tMon, 22 May 2023 15:20:03 +0200 (CEST)", "from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189])\n by mails.dpdk.org (Postfix) with ESMTP id 36A2E40EE5;\n Mon, 22 May 2023 15:19:59 +0200 (CEST)", "from kwepemi500017.china.huawei.com (unknown [172.30.72.54])\n by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QPygr0LRkzLmDh;\n Mon, 22 May 2023 21:18:32 +0800 (CST)", "from localhost.localdomain (10.28.79.22) by\n kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.23; Mon, 22 May 2023 21:19:57 +0800" ], "From": "Dongdong Liu <liudongdong3@huawei.com>", "To": "<dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,\n <andrew.rybchenko@oktetlabs.ru>, <fengchengwen@huawei.com>", "CC": "<stable@dpdk.org>, <lihuisong@huawei.com>, <liudongdong3@huawei.com>,\n <yisen.zhuang@huawei.com>, <huangdengdui@huawei.com>", "Subject": "[PATCH v2 2/5] net/hns3: add flow control autoneg for fiber port", "Date": "Mon, 22 May 2023 21:17:37 +0800", "Message-ID": "<20230522131740.30043-3-liudongdong3@huawei.com>", "X-Mailer": "git-send-email 2.22.0", "In-Reply-To": "<20230522131740.30043-1-liudongdong3@huawei.com>", "References": "<20230518112944.32276-1-liudongdong3@huawei.com>\n <20230522131740.30043-1-liudongdong3@huawei.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-Originating-IP": "[10.28.79.22]", "X-ClientProxiedBy": "dggems704-chm.china.huawei.com (10.3.19.181) To\n kwepemi500017.china.huawei.com (7.221.188.110)", "X-CFilter-Loop": "Reflected", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "From: Huisong Li <lihuisong@huawei.com>\n\nThis patch support flow control autoneg for fiber and backplane port.\nAnd it depends on the capability of firmware.\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\nSigned-off-by: Dongdong Liu <liudongdong3@huawei.com>\n---\n drivers/net/hns3/hns3_cmd.c | 30 +++++++++++++++++-\n drivers/net/hns3/hns3_cmd.h | 20 +++++++++++-\n drivers/net/hns3/hns3_dump.c | 1 +\n drivers/net/hns3/hns3_ethdev.c | 58 ++++++++--------------------------\n drivers/net/hns3/hns3_ethdev.h | 1 +\n 5 files changed, 63 insertions(+), 47 deletions(-)", "diff": "diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c\nindex d530650452..d0a3853656 100644\n--- a/drivers/net/hns3/hns3_cmd.c\n+++ b/drivers/net/hns3/hns3_cmd.c\n@@ -428,7 +428,8 @@ hns3_get_caps_name(uint32_t caps_id)\n \t\t{ HNS3_CAPS_UDP_TUNNEL_CSUM_B, \"udp_tunnel_csum\" },\n \t\t{ HNS3_CAPS_RAS_IMP_B, \"ras_imp\" },\n \t\t{ HNS3_CAPS_RXD_ADV_LAYOUT_B, \"rxd_adv_layout\" },\n-\t\t{ HNS3_CAPS_TM_B, \"tm_capability\" }\n+\t\t{ HNS3_CAPS_TM_B, \"tm_capability\" },\n+\t\t{ HNS3_CAPS_FC_AUTO_B, \"fc_autoneg\" }\n \t};\n \tuint32_t i;\n \n@@ -510,6 +511,8 @@ hns3_parse_capability(struct hns3_hw *hw,\n \t\thns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_RAS_IMP_B, 1);\n \tif (hns3_get_bit(caps, HNS3_CAPS_TM_B))\n \t\thns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TM_B, 1);\n+\tif (hns3_get_bit(caps, HNS3_CAPS_FC_AUTO_B))\n+\t\thns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_FC_AUTO_B, 1);\n }\n \n static uint32_t\n@@ -613,9 +616,31 @@ hns3_update_dev_lsc_cap(struct hns3_hw *hw, int fw_compact_cmd_result)\n \t}\n }\n \n+static void\n+hns3_set_fc_autoneg_cap(struct hns3_adapter *hns, int fw_compact_cmd_result)\n+{\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tstruct hns3_mac *mac = &hw->mac;\n+\n+\tif (mac->media_type == HNS3_MEDIA_TYPE_COPPER) {\n+\t\thns->pf.support_fc_autoneg = true;\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * Flow control auto-negotiation requires the cooperation of the driver\n+\t * and firmware.\n+\t */\n+\thns->pf.support_fc_autoneg = (hns3_dev_get_support(hw, FC_AUTO) &&\n+\t\t\t\t\tfw_compact_cmd_result == 0) ?\n+\t\t\t\t\ttrue : false;\n+}\n+\n static int\n hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result)\n {\n+\tstruct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);\n+\n \tif (result != 0 && hns3_dev_get_support(hw, COPPER)) {\n \t\thns3_err(hw, \"firmware fails to initialize the PHY, ret = %d.\",\n \t\t\t result);\n@@ -623,6 +648,7 @@ hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result)\n \t}\n \n \thns3_update_dev_lsc_cap(hw, result);\n+\thns3_set_fc_autoneg_cap(hns, result);\n \n \treturn 0;\n }\n@@ -642,6 +668,8 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init)\n \t\thns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0);\n \t\tif (hns3_dev_get_support(hw, COPPER))\n \t\t\thns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1);\n+\t\tif (hns3_dev_get_support(hw, FC_AUTO))\n+\t\t\thns3_set_bit(compat, HNS3_MAC_FC_AUTONEG_EN_B, 1);\n \t}\n \treq->compat = rte_cpu_to_le_32(compat);\n \ndiff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h\nindex 4abe0f1d13..d78c1b401e 100644\n--- a/drivers/net/hns3/hns3_cmd.h\n+++ b/drivers/net/hns3/hns3_cmd.h\n@@ -323,6 +323,7 @@ enum HNS3_CAPS_BITS {\n \tHNS3_CAPS_RAS_IMP_B,\n \tHNS3_CAPS_RXD_ADV_LAYOUT_B = 15,\n \tHNS3_CAPS_TM_B = 19,\n+\tHNS3_CAPS_FC_AUTO_B = 30,\n };\n \n /* Capabilities of VF dependent on the PF */\n@@ -666,6 +667,9 @@ enum hns3_promisc_type {\n #define HNS3_LINK_EVENT_REPORT_EN_B\t0\n #define HNS3_NCSI_ERROR_REPORT_EN_B\t1\n #define HNS3_FIRMWARE_PHY_DRIVER_EN_B\t2\n+\n+#define HNS3_MAC_FC_AUTONEG_EN_B\t6\n+\n struct hns3_firmware_compat_cmd {\n \tuint32_t compat;\n \tuint8_t rsv[20];\n@@ -680,6 +684,7 @@ struct hns3_firmware_compat_cmd {\n #define HNS3_PHY_LINK_MODE_AUTONEG_BIT\t\tBIT(6)\n #define HNS3_PHY_LINK_MODE_PAUSE_BIT\t\tBIT(13)\n #define HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT\tBIT(14)\n+#define HNS3_PHY_LINK_MODE_PAUSE_S\t\t13\n \n #define HNS3_PHY_PARAM_CFG_BD_NUM\t2\n struct hns3_phy_params_bd0_cmd {\n@@ -789,6 +794,17 @@ struct hns3_sfp_type {\n #define HNS3_FIBER_LINK_SPEED_10M_BIT\t\tBIT(7)\n #define HNS3_FIBER_LINK_SPEED_200G_BIT\t\tBIT(8)\n \n+/* Flags for pause status field */\n+#define HNS3_FIBER_LOCAL_PAUSE_BIT\tBIT(0)\n+#define HNS3_FIBER_LOCAL_ASYM_PAUSE_BIT\tBIT(1)\n+#define HNS3_FIBER_LP_PAUSE_BIT\t\tBIT(2)\n+#define HNS3_FIBER_LP_ASYM_PAUSE_BIT\tBIT(3)\n+#define HNS3_FIBER_LOCAL_PAUSE_MASK\t(HNS3_FIBER_LOCAL_PAUSE_BIT | \\\n+\t\t\t\t\t HNS3_FIBER_LOCAL_ASYM_PAUSE_BIT)\n+#define HNS3_FIBER_LP_PAUSE_MASK\t(HNS3_FIBER_LP_PAUSE_BIT | \\\n+\t\t\t\t\t HNS3_FIBER_LP_ASYM_PAUSE_BIT)\n+#define HNS3_FIBER_LP_PAUSE_S\t\t2\n+\n struct hns3_sfp_info_cmd {\n \tuint32_t sfp_speed;\n \tuint8_t query_type; /* 0: sfp speed, 1: active */\n@@ -798,7 +814,9 @@ struct hns3_sfp_info_cmd {\n \tuint8_t autoneg_ability;\n \tuint32_t supported_speed; /* speed supported by current media */\n \tuint32_t module_type;\n-\tuint8_t rsv1[8];\n+\tuint8_t rsv[2];\n+\tuint8_t pause_status;\n+\tuint8_t rsv1[5];\n };\n \n #define HNS3_MAC_CFG_FEC_AUTO_EN_B\t0\ndiff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c\nindex 0af3c2ce09..c0839380ea 100644\n--- a/drivers/net/hns3/hns3_dump.c\n+++ b/drivers/net/hns3/hns3_dump.c\n@@ -104,6 +104,7 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)\n \t\t{HNS3_DEV_SUPPORT_RAS_IMP_B, \"RAS IMP\"},\n \t\t{HNS3_DEV_SUPPORT_TM_B, \"TM\"},\n \t\t{HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, \"VF VLAN FILTER MOD\"},\n+\t\t{HNS3_DEV_SUPPORT_FC_AUTO_B, \"FC AUTO\"}\n \t};\n \tuint32_t i;\n \ndiff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c\nindex 8f819d5f23..5ef66f96c6 100644\n--- a/drivers/net/hns3/hns3_ethdev.c\n+++ b/drivers/net/hns3/hns3_ethdev.c\n@@ -3975,6 +3975,7 @@ static int\n hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info)\n {\n \tstruct hns3_sfp_info_cmd *resp;\n+\tuint32_t local_pause, lp_pause;\n \tstruct hns3_cmd_desc desc;\n \tint ret;\n \n@@ -4011,6 +4012,13 @@ hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info)\n \t\tmac_info->support_autoneg = resp->autoneg_ability;\n \t\tmac_info->link_autoneg = (resp->autoneg == 0) ? RTE_ETH_LINK_FIXED\n \t\t\t\t\t: RTE_ETH_LINK_AUTONEG;\n+\t\tlocal_pause = resp->pause_status & HNS3_FIBER_LOCAL_PAUSE_MASK;\n+\t\tlp_pause = (resp->pause_status & HNS3_FIBER_LP_PAUSE_MASK) >>\n+\t\t\t\t\t\tHNS3_FIBER_LP_PAUSE_S;\n+\t\tmac_info->advertising =\n+\t\t\t\tlocal_pause << HNS3_PHY_LINK_MODE_PAUSE_S;\n+\t\tmac_info->lp_advertising =\n+\t\t\t\tlp_pause << HNS3_PHY_LINK_MODE_PAUSE_S;\n \t} else {\n \t\tmac_info->query_type = HNS3_DEFAULT_QUERY;\n \t}\n@@ -4093,6 +4101,8 @@ hns3_update_fiber_link_info(struct hns3_hw *hw)\n \t\tmac->supported_speed = mac_info.supported_speed;\n \t\tmac->support_autoneg = mac_info.support_autoneg;\n \t\tmac->link_autoneg = mac_info.link_autoneg;\n+\t\tmac->advertising = mac_info.advertising;\n+\t\tmac->lp_advertising = mac_info.lp_advertising;\n \n \t\treturn 0;\n \t}\n@@ -4495,24 +4505,6 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev)\n \treturn 0;\n }\n \n-static void\n-hns3_get_fc_autoneg_capability(struct hns3_adapter *hns)\n-{\n-\tstruct hns3_mac *mac = &hns->hw.mac;\n-\n-\tif (mac->media_type == HNS3_MEDIA_TYPE_COPPER) {\n-\t\thns->pf.support_fc_autoneg = true;\n-\t\treturn;\n-\t}\n-\n-\t/*\n-\t * Flow control auto-negotiation requires the cooperation of the driver\n-\t * and firmware. Currently, the optical port does not support flow\n-\t * control auto-negotiation.\n-\t */\n-\thns->pf.support_fc_autoneg = false;\n-}\n-\n static int\n hns3_init_pf(struct rte_eth_dev *eth_dev)\n {\n@@ -4615,8 +4607,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)\n \t\tgoto err_supported_speed;\n \t}\n \n-\thns3_get_fc_autoneg_capability(hns);\n-\n \thns3_tm_conf_init(eth_dev);\n \n \treturn 0;\n@@ -5181,8 +5171,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev)\n }\n \n static void\n-hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause,\n-\t\t\t\t bool *tx_pause)\n+hns3_get_autoneg_rxtx_pause(struct hns3_hw *hw, bool *rx_pause, bool *tx_pause)\n {\n \tstruct hns3_mac *mac = &hw->mac;\n \tuint32_t advertising = mac->advertising;\n@@ -5193,8 +5182,7 @@ hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause,\n \tif (advertising & lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) {\n \t\t*rx_pause = true;\n \t\t*tx_pause = true;\n-\t} else if (advertising & lp_advertising &\n-\t\t HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) {\n+\t} else if (advertising & lp_advertising & HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) {\n \t\tif (advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT)\n \t\t\t*rx_pause = true;\n \t\telse if (lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT)\n@@ -5209,26 +5197,7 @@ hns3_get_autoneg_fc_mode(struct hns3_hw *hw)\n \tbool rx_pause = false;\n \tbool tx_pause = false;\n \n-\tswitch (hw->mac.media_type) {\n-\tcase HNS3_MEDIA_TYPE_COPPER:\n-\t\thns3_get_autoneg_rxtx_pause_copper(hw, &rx_pause, &tx_pause);\n-\t\tbreak;\n-\n-\t/*\n-\t * Flow control auto-negotiation is not supported for fiber and\n-\t * backplane media type.\n-\t */\n-\tcase HNS3_MEDIA_TYPE_FIBER:\n-\tcase HNS3_MEDIA_TYPE_BACKPLANE:\n-\t\thns3_err(hw, \"autoneg FC mode can't be obtained, but flow control auto-negotiation is enabled.\");\n-\t\tcurrent_mode = hw->requested_fc_mode;\n-\t\tgoto out;\n-\tdefault:\n-\t\thns3_err(hw, \"autoneg FC mode can't be obtained for unknown media type(%u).\",\n-\t\t\t hw->mac.media_type);\n-\t\tcurrent_mode = HNS3_FC_NONE;\n-\t\tgoto out;\n-\t}\n+\thns3_get_autoneg_rxtx_pause(hw, &rx_pause, &tx_pause);\n \n \tif (rx_pause && tx_pause)\n \t\tcurrent_mode = HNS3_FC_FULL;\n@@ -5239,7 +5208,6 @@ hns3_get_autoneg_fc_mode(struct hns3_hw *hw)\n \telse\n \t\tcurrent_mode = HNS3_FC_NONE;\n \n-out:\n \treturn current_mode;\n }\n \ndiff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h\nindex 8268dba788..88146f5054 100644\n--- a/drivers/net/hns3/hns3_ethdev.h\n+++ b/drivers/net/hns3/hns3_ethdev.h\n@@ -892,6 +892,7 @@ enum hns3_dev_cap {\n \tHNS3_DEV_SUPPORT_RAS_IMP_B,\n \tHNS3_DEV_SUPPORT_TM_B,\n \tHNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B,\n+\tHNS3_DEV_SUPPORT_FC_AUTO_B,\n };\n \n #define hns3_dev_get_support(hw, _name) \\\n", "prefixes": [ "v2", "2/5" ] }{ "id": 127171, "url": "