get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 129919,
    "url": "http://patchwork.dpdk.org/api/patches/129919/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230805083627.8681-5-liudongdong3@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": "<20230805083627.8681-5-liudongdong3@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230805083627.8681-5-liudongdong3@huawei.com",
    "date": "2023-08-05T08:36:26",
    "name": "[4/5] net/hns3: fix TM thread safety risk",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "5ab7fc0de9ee9a4f284938f2fb72909cd4378775",
    "submitter": {
        "id": 2718,
        "url": "http://patchwork.dpdk.org/api/people/2718/?format=api",
        "name": "Dongdong Liu",
        "email": "liudongdong3@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/20230805083627.8681-5-liudongdong3@huawei.com/mbox/",
    "series": [
        {
            "id": 29116,
            "url": "http://patchwork.dpdk.org/api/series/29116/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29116",
            "date": "2023-08-05T08:36:24",
            "name": "net/hns3: some bugfixes for hns3",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/29116/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/129919/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/129919/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 9F03842FDE;\n\tSat,  5 Aug 2023 10:40:31 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id CB3B64326F;\n\tSat,  5 Aug 2023 10:40:05 +0200 (CEST)",
            "from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])\n by mails.dpdk.org (Postfix) with ESMTP id D57FD40A81;\n Sat,  5 Aug 2023 10:39:58 +0200 (CEST)",
            "from kwepemi500017.china.huawei.com (unknown [172.30.72.53])\n by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RHwwV3t5WzrSCT;\n Sat,  5 Aug 2023 16:38:50 +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.27; Sat, 5 Aug 2023 16:39:56 +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>",
        "Subject": "[PATCH 4/5] net/hns3: fix TM thread safety risk",
        "Date": "Sat, 5 Aug 2023 16:36:26 +0800",
        "Message-ID": "<20230805083627.8681-5-liudongdong3@huawei.com>",
        "X-Mailer": "git-send-email 2.22.0",
        "In-Reply-To": "<20230805083627.8681-1-liudongdong3@huawei.com>",
        "References": "<20230805083627.8681-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": "dggems702-chm.china.huawei.com (10.3.19.179) 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: Chengwen Feng <fengchengwen@huawei.com>\n\nThe driver-related TM (traffic management) info is implemented through\nthe linked list. The following threads are involved in the read and\nwrite of the TM info:\n\n1. main thread: invokes the rte_tm_xxx() API family to modify or read.\n2. interrupt thread: will read TM info in reset recover process.\n3. telemetry/proc-info thread: invoke rte_eth_dev_priv_dump() API to\n   read TM info.\n\nCurrently, thread safety protection of TM info is implemented only in\nthe following operations:\n1. some of the rte_tm_xxx() API's implementation.\n2. reset recover process.\n\nThread safety risks may exist in other scenarios, so fix by:\n1. make sure all the rte_tm_xxx() API's implementations protected by\n   hw.lock.\n2. make sure rte_eth_dev_priv_dump() API's implementation protected\n   by hw.lock.\n\nFixes: c09c7847d892 (\"net/hns3: support traffic management\")\nFixes: e4cfe6bb9114 (\"net/hns3: dump TM configuration info\")\nCc: stable@dpdk.org\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\nSigned-off-by: Dongdong Liu <liudongdong3@huawei.com>\n---\n drivers/net/hns3/hns3_dump.c |   8 +-\n drivers/net/hns3/hns3_tm.c   | 173 ++++++++++++++++++++++++++++++-----\n 2 files changed, 157 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c\nindex c0839380ea..67b45e6dc3 100644\n--- a/drivers/net/hns3/hns3_dump.c\n+++ b/drivers/net/hns3/hns3_dump.c\n@@ -918,6 +918,8 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)\n \tstruct hns3_adapter *hns = dev->data->dev_private;\n \tstruct hns3_hw *hw = &hns->hw;\n \n+\trte_spinlock_lock(&hw->lock);\n+\n \thns3_get_device_basic_info(file, dev);\n \thns3_get_dev_feature_capability(file, hw);\n \thns3_get_rxtx_queue_info(file, dev);\n@@ -927,8 +929,10 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)\n \t * VF only supports dumping basic info, feature capability and queue\n \t * info.\n \t */\n-\tif (hns->is_vf)\n+\tif (hns->is_vf) {\n+\t\trte_spinlock_unlock(&hw->lock);\n \t\treturn 0;\n+\t}\n \n \thns3_get_dev_mac_info(file, hns);\n \thns3_get_vlan_config_info(file, hw);\n@@ -936,6 +940,8 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)\n \thns3_get_tm_conf_info(file, dev);\n \thns3_get_flow_ctrl_info(file, dev);\n \n+\trte_spinlock_unlock(&hw->lock);\n+\n \treturn 0;\n }\n \ndiff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c\nindex e1089b6bd0..67402a700f 100644\n--- a/drivers/net/hns3/hns3_tm.c\n+++ b/drivers/net/hns3/hns3_tm.c\n@@ -1081,21 +1081,6 @@ hns3_tm_hierarchy_commit(struct rte_eth_dev *dev,\n \treturn -EINVAL;\n }\n \n-static int\n-hns3_tm_hierarchy_commit_wrap(struct rte_eth_dev *dev,\n-\t\t\t      int clear_on_fail,\n-\t\t\t      struct rte_tm_error *error)\n-{\n-\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n-\tint ret;\n-\n-\trte_spinlock_lock(&hw->lock);\n-\tret = hns3_tm_hierarchy_commit(dev, clear_on_fail, error);\n-\trte_spinlock_unlock(&hw->lock);\n-\n-\treturn ret;\n-}\n-\n static int\n hns3_tm_node_shaper_do_update(struct hns3_hw *hw,\n \t\t\t      uint32_t node_id,\n@@ -1195,6 +1180,148 @@ hns3_tm_node_shaper_update(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+static int\n+hns3_tm_capabilities_get_wrap(struct rte_eth_dev *dev,\n+\t\t\t      struct rte_tm_capabilities *cap,\n+\t\t\t      struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_capabilities_get(dev, cap, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_shaper_profile_add_wrap(struct rte_eth_dev *dev,\n+\t\t\t\tuint32_t shaper_profile_id,\n+\t\t\t\tstruct rte_tm_shaper_params *profile,\n+\t\t\t\tstruct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_shaper_profile_add(dev, shaper_profile_id, profile, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_shaper_profile_del_wrap(struct rte_eth_dev *dev,\n+\t\t\t\tuint32_t shaper_profile_id,\n+\t\t\t\tstruct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_shaper_profile_del(dev, shaper_profile_id, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_node_add_wrap(struct rte_eth_dev *dev, uint32_t node_id,\n+\t\t      uint32_t parent_node_id, uint32_t priority,\n+\t\t      uint32_t weight, uint32_t level_id,\n+\t\t      struct rte_tm_node_params *params,\n+\t\t      struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_node_add(dev, node_id, parent_node_id, priority,\n+\t\t\t       weight, level_id, params, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_node_delete_wrap(struct rte_eth_dev *dev,\n+\t\t\t uint32_t node_id,\n+\t\t\t struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_node_delete(dev, node_id, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_node_type_get_wrap(struct rte_eth_dev *dev,\n+\t\t\t   uint32_t node_id,\n+\t\t\t   int *is_leaf,\n+\t\t\t   struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_node_type_get(dev, node_id, is_leaf, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_level_capabilities_get_wrap(struct rte_eth_dev *dev,\n+\t\t\t\t    uint32_t level_id,\n+\t\t\t\t    struct rte_tm_level_capabilities *cap,\n+\t\t\t\t    struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_level_capabilities_get(dev, level_id, cap, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_node_capabilities_get_wrap(struct rte_eth_dev *dev,\n+\t\t\t\t   uint32_t node_id,\n+\t\t\t\t   struct rte_tm_node_capabilities *cap,\n+\t\t\t\t   struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_node_capabilities_get(dev, node_id, cap, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3_tm_hierarchy_commit_wrap(struct rte_eth_dev *dev,\n+\t\t\t      int clear_on_fail,\n+\t\t\t      struct rte_tm_error *error)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n+\n+\trte_spinlock_lock(&hw->lock);\n+\tret = hns3_tm_hierarchy_commit(dev, clear_on_fail, error);\n+\trte_spinlock_unlock(&hw->lock);\n+\n+\treturn ret;\n+}\n+\n static int\n hns3_tm_node_shaper_update_wrap(struct rte_eth_dev *dev,\n \t\t\t\tuint32_t node_id,\n@@ -1213,14 +1340,14 @@ hns3_tm_node_shaper_update_wrap(struct rte_eth_dev *dev,\n }\n \n static const struct rte_tm_ops hns3_tm_ops = {\n-\t.capabilities_get       = hns3_tm_capabilities_get,\n-\t.shaper_profile_add     = hns3_tm_shaper_profile_add,\n-\t.shaper_profile_delete  = hns3_tm_shaper_profile_del,\n-\t.node_add               = hns3_tm_node_add,\n-\t.node_delete            = hns3_tm_node_delete,\n-\t.node_type_get          = hns3_tm_node_type_get,\n-\t.level_capabilities_get = hns3_tm_level_capabilities_get,\n-\t.node_capabilities_get  = hns3_tm_node_capabilities_get,\n+\t.capabilities_get       = hns3_tm_capabilities_get_wrap,\n+\t.shaper_profile_add     = hns3_tm_shaper_profile_add_wrap,\n+\t.shaper_profile_delete  = hns3_tm_shaper_profile_del_wrap,\n+\t.node_add               = hns3_tm_node_add_wrap,\n+\t.node_delete            = hns3_tm_node_delete_wrap,\n+\t.node_type_get          = hns3_tm_node_type_get_wrap,\n+\t.level_capabilities_get = hns3_tm_level_capabilities_get_wrap,\n+\t.node_capabilities_get  = hns3_tm_node_capabilities_get_wrap,\n \t.hierarchy_commit       = hns3_tm_hierarchy_commit_wrap,\n \t.node_shaper_update     = hns3_tm_node_shaper_update_wrap,\n };\n",
    "prefixes": [
        "4/5"
    ]
}