Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/139277/?format=api
http://patches.dpdk.org/api/patches/139277/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240413080440.19831-1-fengchengwen@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": "<20240413080440.19831-1-fengchengwen@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20240413080440.19831-1-fengchengwen@huawei.com", "date": "2024-04-13T08:04:40", "name": "[v5] ethdev: fix strict aliasing lead to link cannot be up", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b3be4b9c9d00490d63809c41e542756a704f3ff0", "submitter": { "id": 2146, "url": "http://patches.dpdk.org/api/people/2146/?format=api", "name": "fengchengwen", "email": "fengchengwen@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/20240413080440.19831-1-fengchengwen@huawei.com/mbox/", "series": [ { "id": 31736, "url": "http://patches.dpdk.org/api/series/31736/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31736", "date": "2024-04-13T08:04:40", "name": "[v5] ethdev: fix strict aliasing lead to link cannot be up", "version": 5, "mbox": "http://patches.dpdk.org/series/31736/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/139277/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/139277/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 95A9043E60;\n\tSat, 13 Apr 2024 10:07:00 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4FE7540294;\n\tSat, 13 Apr 2024 10:06:59 +0200 (CEST)", "from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190])\n by mails.dpdk.org (Postfix) with ESMTP id C2BD2400D6\n for <dev@dpdk.org>; Sat, 13 Apr 2024 10:06:56 +0200 (CEST)", "from mail.maildlp.com (unknown [172.19.163.44])\n by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VGmCy2Wgpz2CcMg;\n Sat, 13 Apr 2024 16:03:58 +0800 (CST)", "from dggpeml500024.china.huawei.com (unknown [7.185.36.10])\n by mail.maildlp.com (Postfix) with ESMTPS id CA9B51402CE;\n Sat, 13 Apr 2024 16:06:52 +0800 (CST)", "from localhost.localdomain (10.50.165.33) by\n dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.1.2507.35; Sat, 13 Apr 2024 16:06:52 +0800" ], "From": "Chengwen Feng <fengchengwen@huawei.com>", "To": "<thomas@monjalon.net>, <ferruh.yigit@amd.com>", "CC": "<dev@dpdk.org>, <huangdengdui@huawei.com>, <mb@smartsharesystems.com>,\n <stephen@networkplumber.org>, <roretzla@linux.microsoft.com>", "Subject": "[PATCH v5] ethdev: fix strict aliasing lead to link cannot be up", "Date": "Sat, 13 Apr 2024 08:04:40 +0000", "Message-ID": "<20240413080440.19831-1-fengchengwen@huawei.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20240411030749.41874-1-fengchengwen@huawei.com>", "References": "<20240411030749.41874-1-fengchengwen@huawei.com>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[10.50.165.33]", "X-ClientProxiedBy": "dggems706-chm.china.huawei.com (10.3.19.183) To\n dggpeml500024.china.huawei.com (7.185.36.10)", "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": "Fix a problem introduced by a compiler upgrade (from gcc10 to gcc12.3),\nwhich will lead the hns3 NIC can't link up. The root cause is strict\naliasing violation in rte_eth_linkstatus_set() with hns3 driver, see\n[1] for more details.\n\nThis commit use union to avoid such aliasing violation.\n\nNote: DPDK CI report compiler error (see [2] for more details):\n../drivers/net/cxgbe/cxgbe_ethdev.c:214:9: error: missing braces around\ninitializer [-Werror=missing-braces]\n struct rte_eth_link new_link = { 0 };\nSo this commit replace { 0 } with memset in cxgbe.\n\n[1] Strict aliasing problem with rte_eth_linkstatus_set()\n https://marc.info/?l=dpdk-dev&m=171274148514777&w=3\n[2] https://mails.dpdk.org/archives/test-report/2024-April/637966.html\n\nCc: stable@dpdk.org\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\nSigned-off-by: Dengdui Huang <huangdengdui@huawei.com>\n\n---\nv5: fix DPDK CI compiler error due to GCC extension [-Werror=pedantic]\nv4: fix DPDK CI compiler error with cxgbe.\nv3: fix checkpatch warning \"missing --in-reply-to\".\nv2: add RTE_ATOMIC(uint64_t) wrap which address Morten's comment.\n\n---\n drivers/net/cxgbe/cxgbe_ethdev.c | 3 ++-\n lib/ethdev/ethdev_driver.h | 23 +++++++----------------\n lib/ethdev/rte_ethdev.h | 17 +++++++++++------\n 3 files changed, 20 insertions(+), 23 deletions(-)", "diff": "diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c\nindex a27b9b266e..9b6a3651f9 100644\n--- a/drivers/net/cxgbe/cxgbe_ethdev.c\n+++ b/drivers/net/cxgbe/cxgbe_ethdev.c\n@@ -211,9 +211,9 @@ int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,\n \tunsigned int i, work_done, budget = 32;\n \tstruct link_config *lc = &pi->link_cfg;\n \tstruct adapter *adapter = pi->adapter;\n-\tstruct rte_eth_link new_link = { 0 };\n \tu8 old_link = pi->link_cfg.link_ok;\n \tstruct sge *s = &adapter->sge;\n+\tstruct rte_eth_link new_link;\n \n \tfor (i = 0; i < CXGBE_LINK_STATUS_POLL_CNT; i++) {\n \t\tif (!s->fw_evtq.desc)\n@@ -232,6 +232,7 @@ int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,\n \t\trte_delay_ms(CXGBE_LINK_STATUS_POLL_MS);\n \t}\n \n+\tmemset(&new_link, 0, sizeof(new_link));\n \tnew_link.link_status = cxgbe_force_linkup(adapter) ?\n \t\t\t RTE_ETH_LINK_UP : pi->link_cfg.link_ok;\n \tnew_link.link_autoneg = (lc->link_caps & FW_PORT_CAP32_ANEG) ? 1 : 0;\ndiff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h\nindex 0dbf2dd6a2..9d831d5c84 100644\n--- a/lib/ethdev/ethdev_driver.h\n+++ b/lib/ethdev/ethdev_driver.h\n@@ -1674,18 +1674,13 @@ static inline int\n rte_eth_linkstatus_set(struct rte_eth_dev *dev,\n \t\t const struct rte_eth_link *new_link)\n {\n-\tRTE_ATOMIC(uint64_t) *dev_link = (uint64_t __rte_atomic *)&(dev->data->dev_link);\n-\tunion {\n-\t\tuint64_t val64;\n-\t\tstruct rte_eth_link link;\n-\t} orig;\n-\n-\tRTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));\n+\tstruct rte_eth_link old_link;\n \n-\torig.val64 = rte_atomic_exchange_explicit(dev_link, *(const uint64_t *)new_link,\n-\t\t\t\t\trte_memory_order_seq_cst);\n+\told_link.val64 = rte_atomic_exchange_explicit(&dev->data->dev_link.val64,\n+\t\t\t\t\t\t new_link->val64,\n+\t\t\t\t\t\t rte_memory_order_seq_cst);\n \n-\treturn (orig.link.link_status == new_link->link_status) ? -1 : 0;\n+\treturn (old_link.link_status == new_link->link_status) ? -1 : 0;\n }\n \n /**\n@@ -1701,12 +1696,8 @@ static inline void\n rte_eth_linkstatus_get(const struct rte_eth_dev *dev,\n \t\t struct rte_eth_link *link)\n {\n-\tRTE_ATOMIC(uint64_t) *src = (uint64_t __rte_atomic *)&(dev->data->dev_link);\n-\tuint64_t *dst = (uint64_t *)link;\n-\n-\tRTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));\n-\n-\t*dst = rte_atomic_load_explicit(src, rte_memory_order_seq_cst);\n+\tlink->val64 = rte_atomic_load_explicit(&dev->data->dev_link.val64,\n+\t\t\t\t\t rte_memory_order_seq_cst);\n }\n \n /**\ndiff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h\nindex 147257d6a2..548fada1c7 100644\n--- a/lib/ethdev/rte_ethdev.h\n+++ b/lib/ethdev/rte_ethdev.h\n@@ -332,12 +332,17 @@ struct rte_eth_stats {\n /**\n * A structure used to retrieve link-level information of an Ethernet port.\n */\n-__extension__\n-struct __rte_aligned(8) rte_eth_link { /**< aligned for atomic64 read/write */\n-\tuint32_t link_speed; /**< RTE_ETH_SPEED_NUM_ */\n-\tuint16_t link_duplex : 1; /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */\n-\tuint16_t link_autoneg : 1; /**< RTE_ETH_LINK_[AUTONEG/FIXED] */\n-\tuint16_t link_status : 1; /**< RTE_ETH_LINK_[DOWN/UP] */\n+struct rte_eth_link {\n+\tunion {\n+\t\tRTE_ATOMIC(uint64_t) val64; /**< used for atomic64 read/write */\n+\t\t__extension__\n+\t\tstruct {\n+\t\t\tuint32_t link_speed;\t /**< RTE_ETH_SPEED_NUM_ */\n+\t\t\tuint16_t link_duplex : 1; /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */\n+\t\t\tuint16_t link_autoneg : 1; /**< RTE_ETH_LINK_[AUTONEG/FIXED] */\n+\t\t\tuint16_t link_status : 1; /**< RTE_ETH_LINK_[DOWN/UP] */\n+\t\t};\n+\t};\n };\n \n /**@{@name Link negotiation\n", "prefixes": [ "v5" ] }{ "id": 139277, "url": "