Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/139230/?format=api
http://patchwork.dpdk.org/api/patches/139230/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20240411115841.2154-1-fengchengwen@huawei.com/", "project": { "id": 1, "url": "http://patchwork.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": "<20240411115841.2154-1-fengchengwen@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20240411115841.2154-1-fengchengwen@huawei.com", "date": "2024-04-11T11:58:41", "name": "[v2] ethdev: fix strict aliasing lead to link cannot be up", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "71cd12618ac38f112cba790f2077ad3e4d2569d6", "submitter": { "id": 2146, "url": "http://patchwork.dpdk.org/api/people/2146/?format=api", "name": "fengchengwen", "email": "fengchengwen@huawei.com" }, "delegate": { "id": 319, "url": "http://patchwork.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20240411115841.2154-1-fengchengwen@huawei.com/mbox/", "series": [ { "id": 31724, "url": "http://patchwork.dpdk.org/api/series/31724/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=31724", "date": "2024-04-11T11:58:41", "name": "[v2] ethdev: fix strict aliasing lead to link cannot be up", "version": 2, "mbox": "http://patchwork.dpdk.org/series/31724/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/139230/comments/", "check": "warning", "checks": "http://patchwork.dpdk.org/api/patches/139230/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 C95DB43E44;\n\tThu, 11 Apr 2024 14:00:59 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6D4774029C;\n\tThu, 11 Apr 2024 14:00:59 +0200 (CEST)", "from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255])\n by mails.dpdk.org (Postfix) with ESMTP id 6983D40268\n for <dev@dpdk.org>; Thu, 11 Apr 2024 14:00:57 +0200 (CEST)", "from mail.maildlp.com (unknown [172.19.88.105])\n by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VFdW61Dq5z1R5XD;\n Thu, 11 Apr 2024 19:58:10 +0800 (CST)", "from dggpeml500024.china.huawei.com (unknown [7.185.36.10])\n by mail.maildlp.com (Postfix) with ESMTPS id C54BF1400D1;\n Thu, 11 Apr 2024 20:00:54 +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; Thu, 11 Apr 2024 20:00:54 +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 v2] ethdev: fix strict aliasing lead to link cannot be up", "Date": "Thu, 11 Apr 2024 11:58:41 +0000", "Message-ID": "<20240411115841.2154-1-fengchengwen@huawei.com>", "X-Mailer": "git-send-email 2.17.1", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[10.50.165.33]", "X-ClientProxiedBy": "dggems705-chm.china.huawei.com (10.3.19.182) 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\n[1] Strict aliasing problem with rte_eth_linkstatus_set()\n https://marc.info/?l=dpdk-dev&m=171274148514777&w=3\n\nCc: stable@dpdk.org\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\nSigned-off-by: Dengdui Huang <huangdengdui@huawei.com>\n\n---\nv2: add RTE_ATOMIC(uint64_t) wrap which address Morten's comment.\n\n---\n lib/ethdev/ethdev_driver.h | 23 +++++++----------------\n lib/ethdev/rte_ethdev.h | 16 ++++++++++------\n 2 files changed, 17 insertions(+), 22 deletions(-)", "diff": "diff --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..ccf43e468a 100644\n--- a/lib/ethdev/rte_ethdev.h\n+++ b/lib/ethdev/rte_ethdev.h\n@@ -332,12 +332,16 @@ 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\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": [ "v2" ] }{ "id": 139230, "url": "