Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/125862/?format=api
http://patches.dpdk.org/api/patches/125862/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230408022740.14522-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": "<20230408022740.14522-3-liudongdong3@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230408022740.14522-3-liudongdong3@huawei.com", "date": "2023-04-08T02:27:34", "name": "[2/7] net/hns3: fix fec mode check error", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "1719b8f9da6909d18939f5fba2cc466e5f7d6dbb", "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/20230408022740.14522-3-liudongdong3@huawei.com/mbox/", "series": [ { "id": 27645, "url": "http://patches.dpdk.org/api/series/27645/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=27645", "date": "2023-04-08T02:27:32", "name": "add setting and querying of LLRS FEC mode", "version": 1, "mbox": "http://patches.dpdk.org/series/27645/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/125862/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/125862/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 F2E5F428E9;\n\tSat, 8 Apr 2023 04:29:38 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0FF8B42D16;\n\tSat, 8 Apr 2023 04:29:26 +0200 (CEST)", "from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])\n by mails.dpdk.org (Postfix) with ESMTP id E2C8440EE4;\n Sat, 8 Apr 2023 04:29:22 +0200 (CEST)", "from kwepemi500017.china.huawei.com (unknown [172.30.72.55])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PtfJ96hMvzKxMm;\n Sat, 8 Apr 2023 10:26:49 +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; Sat, 8 Apr 2023 10:29:20 +0800" ], "From": "Dongdong Liu <liudongdong3@huawei.com>", "To": "<dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,\n <andrew.rybchenko@oktetlabs.ru>", "CC": "<stable@dpdk.org>, <liudongdong3@huawei.com>, <haijie1@huawei.com>, Yisen\n Zhuang <yisen.zhuang@huawei.com>, Chengwen Feng <fengchengwen@huawei.com>,\n \"Wei Hu (Xavier)\" <xavier.huwei@huawei.com>, \"Min Hu (Connor)\"\n <humin29@huawei.com>, Chengchang Tang <tangchengchang@huawei.com>", "Subject": "[PATCH 2/7] net/hns3: fix fec mode check error", "Date": "Sat, 8 Apr 2023 10:27:34 +0800", "Message-ID": "<20230408022740.14522-3-liudongdong3@huawei.com>", "X-Mailer": "git-send-email 2.22.0", "In-Reply-To": "<20230408022740.14522-1-liudongdong3@huawei.com>", "References": "<20230408022740.14522-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": "dggems701-chm.china.huawei.com (10.3.19.178) 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: Jie Hai <haijie1@huawei.com>\n\nThe function is_fec_mode_one_bit_set() is used to check whether\nthe binary of the mode from user only contains one '1'. But it\nuses the bytes number this mode variable occupied to calculate\nthe count. So this patch uses __builtin_popcount() to replace it.\n\nThis patch also extracts the code for verifying mode parameter into\na function.\n\nFixes: 9bf2ea8dbc65 (\"net/hns3: support FEC\")\nCc: stable@dpdk.org\n\nSigned-off-by: Jie Hai <haijie1@huawei.com>\nSigned-off-by: Dongdong Liu <liudongdong3@huawei.com>\n---\n drivers/net/hns3/hns3_ethdev.c | 50 ++++++++++++++++------------------\n 1 file changed, 24 insertions(+), 26 deletions(-)", "diff": "diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c\nindex fbf2e5aa6c..9968518b2d 100644\n--- a/drivers/net/hns3/hns3_ethdev.c\n+++ b/drivers/net/hns3/hns3_ethdev.c\n@@ -6166,52 +6166,50 @@ get_current_speed_fec_cap(struct hns3_hw *hw, struct rte_eth_fec_capa *fec_capa)\n \treturn cur_capa;\n }\n \n-static bool\n-is_fec_mode_one_bit_set(uint32_t mode)\n-{\n-\tint cnt = 0;\n-\tuint8_t i;\n-\n-\tfor (i = 0; i < sizeof(mode); i++)\n-\t\tif (mode >> i & 0x1)\n-\t\t\tcnt++;\n-\n-\treturn cnt == 1 ? true : false;\n-}\n-\n static int\n-hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode)\n+hns3_fec_mode_valid(struct rte_eth_dev *dev, uint32_t mode)\n {\n #define FEC_CAPA_NUM 2\n \tstruct hns3_adapter *hns = dev->data->dev_private;\n \tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns);\n-\tstruct hns3_pf *pf = &hns->pf;\n \tstruct rte_eth_fec_capa fec_capa[FEC_CAPA_NUM];\n-\tuint32_t cur_capa;\n \tuint32_t num = FEC_CAPA_NUM;\n+\tuint32_t cur_capa;\n \tint ret;\n \n-\tret = hns3_fec_get_capability(dev, fec_capa, num);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\t/* HNS3 PMD only support one bit set mode, e.g. 0x1, 0x4 */\n-\tif (!is_fec_mode_one_bit_set(mode)) {\n-\t\thns3_err(hw, \"FEC mode(0x%x) not supported in HNS3 PMD, \"\n-\t\t\t \"FEC mode should be only one bit set\", mode);\n+\tif (__builtin_popcount(mode) != 1) {\n+\t\thns3_err(hw, \"FEC mode(0x%x) should be only one bit set\", mode);\n \t\treturn -EINVAL;\n \t}\n \n+\tret = hns3_fec_get_capability(dev, fec_capa, num);\n+\tif (ret < 0)\n+\t\treturn ret;\n \t/*\n \t * Check whether the configured mode is within the FEC capability.\n \t * If not, the configured mode will not be supported.\n \t */\n \tcur_capa = get_current_speed_fec_cap(hw, fec_capa);\n-\tif (!(cur_capa & mode)) {\n-\t\thns3_err(hw, \"unsupported FEC mode = 0x%x\", mode);\n+\tif ((cur_capa & mode) == 0) {\n+\t\thns3_err(hw, \"unsupported FEC mode(0x%x)\", mode);\n \t\treturn -EINVAL;\n \t}\n \n+\treturn 0;\n+}\n+\n+static int\n+hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode)\n+{\n+\tstruct hns3_adapter *hns = dev->data->dev_private;\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns);\n+\tstruct hns3_pf *pf = &hns->pf;\n+\tint ret;\n+\n+\tret = hns3_fec_mode_valid(dev, mode);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n \trte_spinlock_lock(&hw->lock);\n \tret = hns3_set_fec_hw(hw, mode);\n \tif (ret) {\n", "prefixes": [ "2/7" ] }{ "id": 125862, "url": "