get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/139480/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 139480,
    "url": "http://patches.dpdk.org/api/patches/139480/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240418072818.2074-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": "<20240418072818.2074-1-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240418072818.2074-1-fengchengwen@huawei.com",
    "date": "2024-04-18T07:28:18",
    "name": "[v7] ethdev: fix strict aliasing lead to link cannot be up",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "44018ca7e551aa6c6cec35ce640c960e93a35f37",
    "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/20240418072818.2074-1-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 31779,
            "url": "http://patches.dpdk.org/api/series/31779/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31779",
            "date": "2024-04-18T07:28:18",
            "name": "[v7] ethdev: fix strict aliasing lead to link cannot be up",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/31779/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/139480/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/139480/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 2C42D43E9C;\n\tThu, 18 Apr 2024 09:30:45 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E5591402D6;\n\tThu, 18 Apr 2024 09:30:44 +0200 (CEST)",
            "from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])\n by mails.dpdk.org (Postfix) with ESMTP id D254940042\n for <dev@dpdk.org>; Thu, 18 Apr 2024 09:30:38 +0200 (CEST)",
            "from mail.maildlp.com (unknown [172.19.88.194])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VKqCx29TZzYdqB;\n Thu, 18 Apr 2024 15:29:33 +0800 (CST)",
            "from dggpeml500024.china.huawei.com (unknown [7.185.36.10])\n by mail.maildlp.com (Postfix) with ESMTPS id 175FF1403D5;\n Thu, 18 Apr 2024 15:30:35 +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, 18 Apr 2024 15:30:34 +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 v7] ethdev: fix strict aliasing lead to link cannot be up",
        "Date": "Thu, 18 Apr 2024 07:28:18 +0000",
        "Message-ID": "<20240418072818.2074-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; charset=\"UTF-8\"",
        "Content-Transfer-Encoding": "8bit",
        "X-Originating-IP": "[10.50.165.33]",
        "X-ClientProxiedBy": "dggems702-chm.china.huawei.com (10.3.19.179) 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 };\nThe same error with qos_sched example:\n../examples/qos_sched/init.c:338:10: error: missing braces around\ninitializer [-Werror=missing-braces]\n   struct rte_eth_link link = {0};\nSo this commit replace { 0 } with memset in cxgbe and qos_sched.\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>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\n---\nv7: add rte_atomic_store_explicit to get link status which address\n    Morten's comment, and add Morten's acked-by.\nv6: fix DPDK CI compiler error with qos_sched.\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 drivers/net/cxgbe/cxgbe_ethdev.c |  3 ++-\n examples/qos_sched/init.c        |  3 ++-\n lib/ethdev/ethdev_driver.h       | 25 +++++++++----------------\n lib/ethdev/rte_ethdev.h          | 17 +++++++++++------\n 4 files changed, 24 insertions(+), 24 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/examples/qos_sched/init.c b/examples/qos_sched/init.c\nindex d8abae635a..32964fd57e 100644\n--- a/examples/qos_sched/init.c\n+++ b/examples/qos_sched/init.c\n@@ -335,7 +335,7 @@ int app_init(void)\n \tfor(i = 0; i < nb_pfc; i++) {\n \t\tuint32_t socket = rte_lcore_to_socket_id(qos_conf[i].rx_core);\n \t\tstruct rte_ring *ring;\n-\t\tstruct rte_eth_link link = {0};\n+\t\tstruct rte_eth_link link;\n \t\tint retry_count = 100, retry_delay = 100; /* try every 100ms for 10 sec */\n \n \t\tsnprintf(ring_name, MAX_NAME_LEN, \"ring-%u-%u\", i, qos_conf[i].rx_core);\n@@ -367,6 +367,7 @@ int app_init(void)\n \t\tapp_init_port(qos_conf[i].rx_port, qos_conf[i].mbuf_pool);\n \t\tapp_init_port(qos_conf[i].tx_port, qos_conf[i].mbuf_pool);\n \n+\t\tmemset(&link, 0, sizeof(link));\n \t\trte_eth_link_get(qos_conf[i].tx_port, &link);\n \t\tif (link.link_status == 0)\n \t\t\tprintf(\"Waiting for link on port %u\\n\", qos_conf[i].tx_port);\ndiff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h\nindex 0dbf2dd6a2..a7159cd1b1 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,10 @@ 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+\trte_atomic_store_explicit(&link->val64,\n+\t\t\t\t  rte_atomic_load_explicit(&dev->data->dev_link.val64,\n+\t\t\t\t\t\t\t   rte_memory_order_seq_cst),\n+\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": [
        "v7"
    ]
}