get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 127593,
    "url": "http://patches.dpdk.org/api/patches/127593/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230527021121.31647-3-lihuisong@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": "<20230527021121.31647-3-lihuisong@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230527021121.31647-3-lihuisong@huawei.com",
    "date": "2023-05-27T02:11:18",
    "name": "[V6,2/5] ethdev: fix skip valid port in probing callback",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "160ec1b3e00e6964c5be015abcbce90b3bd79360",
    "submitter": {
        "id": 2085,
        "url": "http://patches.dpdk.org/api/people/2085/?format=api",
        "name": "lihuisong (C)",
        "email": "lihuisong@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/20230527021121.31647-3-lihuisong@huawei.com/mbox/",
    "series": [
        {
            "id": 28215,
            "url": "http://patches.dpdk.org/api/series/28215/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28215",
            "date": "2023-05-27T02:11:19",
            "name": "app/testpmd: support multiple process attach and detach port",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/28215/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/127593/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/127593/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 9697F42BB0;\n\tSat, 27 May 2023 04:14:11 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E8FFE42D48;\n\tSat, 27 May 2023 04:13:51 +0200 (CEST)",
            "from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])\n by mails.dpdk.org (Postfix) with ESMTP id DE3CA40A7A\n for <dev@dpdk.org>; Sat, 27 May 2023 04:13:45 +0200 (CEST)",
            "from kwepemm600004.china.huawei.com (unknown [172.30.72.57])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QSlhM4MC6zTknp;\n Sat, 27 May 2023 10:13:39 +0800 (CST)",
            "from localhost.localdomain (10.28.79.22) by\n kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.23; Sat, 27 May 2023 10:13:43 +0800"
        ],
        "From": "Huisong Li <lihuisong@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<thomas@monjalon.net>, <ferruh.yigit@amd.com>,\n <andrew.rybchenko@oktetlabs.ru>, <liudongdong3@huawei.com>,\n <liuyonglong@huawei.com>, <fengchengwen@huawei.com>, <lihuisong@huawei.com>",
        "Subject": "[PATCH V6 2/5] ethdev: fix skip valid port in probing callback",
        "Date": "Sat, 27 May 2023 10:11:18 +0800",
        "Message-ID": "<20230527021121.31647-3-lihuisong@huawei.com>",
        "X-Mailer": "git-send-email 2.22.0",
        "In-Reply-To": "<20230527021121.31647-1-lihuisong@huawei.com>",
        "References": "<20220825024425.10534-1-lihuisong@huawei.com>\n <20230527021121.31647-1-lihuisong@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.28.79.22]",
        "X-ClientProxiedBy": "dggems704-chm.china.huawei.com (10.3.19.181) To\n kwepemm600004.china.huawei.com (7.193.23.242)",
        "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": "The event callback in application may use the macro RTE_ETH_FOREACH_DEV to\niterate over all enabled ports to do something(like, verifying the port id\nvalidity) when receive a probing event. If the ethdev state of a port is\nnot RTE_ETH_DEV_UNUSED, this port will be considered as a valid port.\n\nHowever, this state is set to RTE_ETH_DEV_ATTACHED after pushing probing\nevent. It means that probing callback will skip this port. But this\nassignment can not move to front of probing notification. See\ncommit be8cd210379a (\"ethdev: fix port probing notification\")\n\nSo this patch has to add a new state, RTE_ETH_DEV_ALLOCATED. Set the ethdev\nstate to RTE_ETH_DEV_ALLOCATED before pushing probing event and set it to\nRTE_ETH_DEV_ATTACHED after definitely probed. And this port is valid if its\ndevice state is 'ALLOCATED' or 'ATTACHED'.\n\nIn addition, the new state has to be placed behind 'REMOVED' to avoid ABI\nbreak. Fortunately, this ethdev state is internal and applications can not\naccess it directly. So this patch encapsulates an API, rte_eth_dev_is_used,\nfor ethdev or PMD to call and eliminate concerns about using this state\nenum value comparison.\n\nFixes: be8cd210379a (\"ethdev: fix port probing notification\")\nCc: stable@dpdk.org\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\n---\n drivers/net/bnxt/bnxt_ethdev.c |  3 ++-\n drivers/net/mlx5/mlx5.c        |  2 +-\n lib/ethdev/ethdev_driver.c     | 13 ++++++++++---\n lib/ethdev/ethdev_driver.h     | 12 ++++++++++++\n lib/ethdev/ethdev_pci.h        |  2 +-\n lib/ethdev/rte_class_eth.c     |  2 +-\n lib/ethdev/rte_ethdev.c        |  4 ++--\n lib/ethdev/rte_ethdev.h        |  4 +++-\n lib/ethdev/version.map         |  1 +\n 9 files changed, 33 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c\nindex ef7b8859d9..74ec0c88fb 100644\n--- a/drivers/net/bnxt/bnxt_ethdev.c\n+++ b/drivers/net/bnxt/bnxt_ethdev.c\n@@ -6053,7 +6053,8 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)\n \n \tPMD_DRV_LOG(DEBUG, \"Calling Device uninit\\n\");\n \n-\tif (eth_dev->state != RTE_ETH_DEV_UNUSED)\n+\n+\tif (rte_eth_dev_is_used(eth_dev->state))\n \t\tbnxt_dev_close_op(eth_dev);\n \n \treturn 0;\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex a75fa1b7f0..881425bf83 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -3145,7 +3145,7 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev)\n \twhile (port_id < RTE_MAX_ETHPORTS) {\n \t\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n \n-\t\tif (dev->state != RTE_ETH_DEV_UNUSED &&\n+\t\tif (rte_eth_dev_is_used(dev->state) &&\n \t\t    dev->device &&\n \t\t    (dev->device == odev ||\n \t\t     (dev->device->driver &&\ndiff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c\nindex 0be1e8ca04..29e9417bea 100644\n--- a/lib/ethdev/ethdev_driver.c\n+++ b/lib/ethdev/ethdev_driver.c\n@@ -50,8 +50,8 @@ eth_dev_find_free_port(void)\n \tfor (i = 0; i < RTE_MAX_ETHPORTS; i++) {\n \t\t/* Using shared name field to find a free port. */\n \t\tif (eth_dev_shared_data->data[i].name[0] == '\\0') {\n-\t\t\tRTE_ASSERT(rte_eth_devices[i].state ==\n-\t\t\t\t   RTE_ETH_DEV_UNUSED);\n+\t\t\tRTE_ASSERT(!rte_eth_dev_is_used(\n+\t\t\t\t\trte_eth_devices[i].state));\n \t\t\treturn i;\n \t\t}\n \t}\n@@ -208,11 +208,18 @@ rte_eth_dev_probing_finish(struct rte_eth_dev *dev)\n \tif (rte_eal_process_type() == RTE_PROC_SECONDARY)\n \t\teth_dev_fp_ops_setup(rte_eth_fp_ops + dev->data->port_id, dev);\n \n+\tdev->state = RTE_ETH_DEV_ALLOCATED;\n \trte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL);\n \n \tdev->state = RTE_ETH_DEV_ATTACHED;\n }\n \n+bool rte_eth_dev_is_used(uint16_t dev_state)\n+{\n+\treturn dev_state == RTE_ETH_DEV_ALLOCATED ||\n+\t\tdev_state == RTE_ETH_DEV_ATTACHED;\n+}\n+\n int\n rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)\n {\n@@ -221,7 +228,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)\n \n \teth_dev_shared_data_prepare();\n \n-\tif (eth_dev->state != RTE_ETH_DEV_UNUSED)\n+\tif (rte_eth_dev_is_used(eth_dev->state))\n \t\trte_eth_dev_callback_process(eth_dev,\n \t\t\t\tRTE_ETH_EVENT_DESTROY, NULL);\n \ndiff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h\nindex 367c0c4878..d5fd6e19ba 100644\n--- a/lib/ethdev/ethdev_driver.h\n+++ b/lib/ethdev/ethdev_driver.h\n@@ -1583,6 +1583,18 @@ int rte_eth_dev_callback_process(struct rte_eth_dev *dev,\n __rte_internal\n void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);\n \n+/**\n+ * Check if a Ethernet device state is used or not\n+ *\n+ * @param dev_state\n+ *   The state of the Ethernet device\n+ * @return\n+ *   - true if the state of the Ethernet device is allocated or attached\n+ *   - false if this state is neither allocated nor attached\n+ */\n+__rte_internal\n+bool rte_eth_dev_is_used(uint16_t dev_state);\n+\n /**\n  * Create memzone for HW rings.\n  * malloc can't be used as the physical address is needed.\ndiff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h\nindex 94b8fba5d7..23270ccd73 100644\n--- a/lib/ethdev/ethdev_pci.h\n+++ b/lib/ethdev/ethdev_pci.h\n@@ -164,7 +164,7 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev,\n \t * eth device has been released.\n \t */\n \tif (rte_eal_process_type() == RTE_PROC_SECONDARY &&\n-\t    eth_dev->state == RTE_ETH_DEV_UNUSED)\n+\t    !rte_eth_dev_is_used(eth_dev->state))\n \t\treturn 0;\n \n \tif (dev_uninit) {\ndiff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c\nindex b61dae849d..88e56dd9a4 100644\n--- a/lib/ethdev/rte_class_eth.c\n+++ b/lib/ethdev/rte_class_eth.c\n@@ -118,7 +118,7 @@ eth_dev_match(const struct rte_eth_dev *edev,\n \tconst struct rte_kvargs *kvlist = arg->kvlist;\n \tunsigned int pair;\n \n-\tif (edev->state == RTE_ETH_DEV_UNUSED)\n+\tif (!rte_eth_dev_is_used(edev->state))\n \t\treturn -1;\n \tif (arg->device != NULL && arg->device != edev->device)\n \t\treturn -1;\ndiff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c\nindex d46e74504e..c8f800bb12 100644\n--- a/lib/ethdev/rte_ethdev.c\n+++ b/lib/ethdev/rte_ethdev.c\n@@ -338,7 +338,7 @@ uint16_t\n rte_eth_find_next(uint16_t port_id)\n {\n \twhile (port_id < RTE_MAX_ETHPORTS &&\n-\t\t\trte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED)\n+\t       !rte_eth_dev_is_used(rte_eth_devices[port_id].state))\n \t\tport_id++;\n \n \tif (port_id >= RTE_MAX_ETHPORTS)\n@@ -397,7 +397,7 @@ rte_eth_dev_is_valid_port(uint16_t port_id)\n \tint is_valid;\n \n \tif (port_id >= RTE_MAX_ETHPORTS ||\n-\t    (rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED))\n+\t    !rte_eth_dev_is_used(rte_eth_devices[port_id].state))\n \t\tis_valid = 0;\n \telse\n \t\tis_valid = 1;\ndiff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h\nindex fe8f7466c8..d4de7942d0 100644\n--- a/lib/ethdev/rte_ethdev.h\n+++ b/lib/ethdev/rte_ethdev.h\n@@ -2002,10 +2002,12 @@ typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,\n enum rte_eth_dev_state {\n \t/** Device is unused before being probed. */\n \tRTE_ETH_DEV_UNUSED = 0,\n-\t/** Device is attached when allocated in probing. */\n+\t/** Device is attached when definitely probed. */\n \tRTE_ETH_DEV_ATTACHED,\n \t/** Device is in removed state when plug-out is detected. */\n \tRTE_ETH_DEV_REMOVED,\n+\t/** Device is allocated and is set before reporting new event. */\n+\tRTE_ETH_DEV_ALLOCATED,\n };\n \n struct rte_eth_dev_sriov {\ndiff --git a/lib/ethdev/version.map b/lib/ethdev/version.map\nindex 041f0da31f..673123dfb7 100644\n--- a/lib/ethdev/version.map\n+++ b/lib/ethdev/version.map\n@@ -317,6 +317,7 @@ INTERNAL {\n \trte_eth_dev_get_by_name;\n \trte_eth_dev_is_rx_hairpin_queue;\n \trte_eth_dev_is_tx_hairpin_queue;\n+\trte_eth_dev_is_used;\n \trte_eth_dev_probing_finish;\n \trte_eth_dev_release_port;\n \trte_eth_dev_internal_reset;\n",
    "prefixes": [
        "V6",
        "2/5"
    ]
}