get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 116354,
    "url": "https://patches.dpdk.org/api/patches/116354/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220915124522.5407-6-lihuisong@huawei.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20220915124522.5407-6-lihuisong@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220915124522.5407-6-lihuisong@huawei.com",
    "date": "2022-09-15T12:45:21",
    "name": "[V2,5/6] app/testpmd: support attach and detach port for MP",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "6cf30926f62161c2ad614b8a1cf25d2edbf3721c",
    "submitter": {
        "id": 2085,
        "url": "https://patches.dpdk.org/api/people/2085/?format=api",
        "name": "lihuisong (C)",
        "email": "lihuisong@huawei.com"
    },
    "delegate": {
        "id": 3961,
        "url": "https://patches.dpdk.org/api/users/3961/?format=api",
        "username": "arybchenko",
        "first_name": "Andrew",
        "last_name": "Rybchenko",
        "email": "andrew.rybchenko@oktetlabs.ru"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20220915124522.5407-6-lihuisong@huawei.com/mbox/",
    "series": [
        {
            "id": 24680,
            "url": "https://patches.dpdk.org/api/series/24680/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=24680",
            "date": "2022-09-15T12:45:18",
            "name": "app/testpmd: support attach and detach port for MP",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/24680/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/116354/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/116354/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 A5BBCA00C5;\n\tThu, 15 Sep 2022 14:47:25 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id AA46942847;\n\tThu, 15 Sep 2022 14:47:00 +0200 (CEST)",
            "from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])\n by mails.dpdk.org (Postfix) with ESMTP id 901C440223\n for <dev@dpdk.org>; Thu, 15 Sep 2022 14:46:55 +0200 (CEST)",
            "from dggemv703-chm.china.huawei.com (unknown [172.30.72.53])\n by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MSxgd6yZkzlVw2;\n Thu, 15 Sep 2022 20:42:53 +0800 (CST)",
            "from kwepemm600004.china.huawei.com (7.193.23.242) by\n dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2375.24; Thu, 15 Sep 2022 20:46:53 +0800",
            "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.2375.31; Thu, 15 Sep 2022 20:46:52 +0800"
        ],
        "From": "Huisong Li <lihuisong@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<thomas@monjalon.net>, <ferruh.yigit@xilinx.com>,\n <andrew.rybchenko@oktetlabs.ru>, <huangdaode@huawei.com>,\n <lihuisong@huawei.com>",
        "Subject": "[PATCH V2 5/6] app/testpmd: support attach and detach port for MP",
        "Date": "Thu, 15 Sep 2022 20:45:21 +0800",
        "Message-ID": "<20220915124522.5407-6-lihuisong@huawei.com>",
        "X-Mailer": "git-send-email 2.22.0",
        "In-Reply-To": "<20220915124522.5407-1-lihuisong@huawei.com>",
        "References": "<20220825024425.10534-1-lihuisong@huawei.com>\n <20220915124522.5407-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": "dggems702-chm.china.huawei.com (10.3.19.179) 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": "This patch supports attach and detach port in primary and secondary\nprocess.\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\nSigned-off-by: Dongdong Liu <liudongdong3@huawei.com>\n---\n app/test-pmd/testpmd.c                | 76 +++++++++++++++++----------\n app/test-pmd/testpmd.h                |  1 -\n drivers/net/bonding/bonding_testpmd.c |  1 -\n 3 files changed, 47 insertions(+), 31 deletions(-)",
    "diff": "diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex 1605e34f35..10b330e33c 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -3323,9 +3323,6 @@ reset_port(portid_t pid)\n void\n attach_port(char *identifier)\n {\n-\tportid_t pi;\n-\tstruct rte_dev_iterator iterator;\n-\n \tprintf(\"Attaching a new port...\\n\");\n \n \tif (identifier == NULL) {\n@@ -3337,24 +3334,6 @@ attach_port(char *identifier)\n \t\tTESTPMD_LOG(ERR, \"Failed to attach port %s\\n\", identifier);\n \t\treturn;\n \t}\n-\n-\t/* first attach mode: event */\n-\tif (setup_on_probe_event) {\n-\t\t/* new ports are detected on RTE_ETH_EVENT_NEW event */\n-\t\tfor (pi = 0; pi < RTE_MAX_ETHPORTS; pi++)\n-\t\t\tif (ports[pi].port_status == RTE_PORT_HANDLING &&\n-\t\t\t\t\tports[pi].need_setup != 0)\n-\t\t\t\tsetup_attached_port(pi);\n-\t\treturn;\n-\t}\n-\n-\t/* second attach mode: iterator */\n-\tRTE_ETH_FOREACH_MATCHING_DEV(pi, identifier, &iterator) {\n-\t\t/* setup ports matching the devargs used for probing */\n-\t\tif (port_is_forwarding(pi))\n-\t\t\tcontinue; /* port was already attached before */\n-\t\tsetup_attached_port(pi);\n-\t}\n }\n \n static void\n@@ -3377,7 +3356,6 @@ setup_attached_port(portid_t pi)\n \tports_ids[nb_ports++] = pi;\n \tfwd_ports_ids[nb_fwd_ports++] = pi;\n \tnb_cfg_ports = nb_fwd_ports;\n-\tports[pi].need_setup = 0;\n \tports[pi].port_status = RTE_PORT_STOPPED;\n \n \tprintf(\"Port %d is attached. Now total ports is %d\\n\", pi, nb_ports);\n@@ -3411,11 +3389,10 @@ detach_device(struct rte_device *dev)\n \t\tTESTPMD_LOG(ERR, \"Failed to detach device %s\\n\", dev->name);\n \t\treturn;\n \t}\n-\tremove_invalid_ports();\n \n \tprintf(\"Device is detached\\n\");\n-\tprintf(\"Now total ports is %d\\n\", nb_ports);\n \tprintf(\"Done\\n\");\n+\n \treturn;\n }\n \n@@ -3481,11 +3458,9 @@ detach_devargs(char *identifier)\n \t\treturn;\n \t}\n \n-\tremove_invalid_ports();\n-\n \tprintf(\"Device %s is detached\\n\", identifier);\n-\tprintf(\"Now total ports is %d\\n\", nb_ports);\n \tprintf(\"Done\\n\");\n+\n \trte_devargs_reset(&da);\n }\n \n@@ -3649,11 +3624,52 @@ rmv_port_callback(void *arg)\n \t\tstruct rte_device *device = dev_info.device;\n \t\tclose_port(port_id);\n \t\tdetach_device(device); /* might be already removed or have more ports */\n+\t\tremove_invalid_ports();\n+\t\tprintf(\"Now total ports is %d\\n\", nb_ports);\n \t}\n \tif (need_to_start)\n \t\tstart_packet_forwarding(0);\n }\n \n+static void config_attached_port(portid_t port_id)\n+{\n+\tstruct rte_dev_iterator iterator;\n+\tstruct rte_eth_dev_info dev_info;\n+\tportid_t pi;\n+\tint ret;\n+\n+\t/* first attach mode: event */\n+\tif (setup_on_probe_event) {\n+\t\t/* new ports are detected on RTE_ETH_EVENT_NEW event */\n+\t\tsetup_attached_port(port_id);\n+\t\treturn;\n+\t}\n+\n+\tret = eth_dev_info_get_print_err(port_id, &dev_info);\n+\tif (ret != 0) {\n+\t\tTESTPMD_LOG(ERR,\n+\t\t\t\"Failed to get device info for port %d, not detaching\\n\",\n+\t\t\tport_id);\n+\t\treturn;\n+\t}\n+\t/* second attach mode: iterator */\n+\tRTE_ETH_FOREACH_MATCHING_DEV(pi, dev_info.device->name, &iterator) {\n+\t\t/* setup ports matching the devargs used for probing */\n+\t\tif (port_is_forwarding(port_id))\n+\t\t\tcontinue; /* port was already attached before */\n+\t\tsetup_attached_port(port_id);\n+\t}\n+}\n+\n+static void\n+remove_invalid_ports_callback(void *arg)\n+{\n+\tRTE_SET_USED(arg);\n+\n+\tremove_invalid_ports();\n+\tprintf(\"Now total ports is %d\\n\", nb_ports);\n+}\n+\n /* This function is used by the interrupt thread */\n static int\n eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,\n@@ -3678,8 +3694,7 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,\n \n \tswitch (type) {\n \tcase RTE_ETH_EVENT_NEW:\n-\t\tports[port_id].need_setup = 1;\n-\t\tports[port_id].port_status = RTE_PORT_HANDLING;\n+\t\tconfig_attached_port(port_id);\n \t\tbreak;\n \tcase RTE_ETH_EVENT_INTR_RMV:\n \t\tif (rte_eal_alarm_set(100000,\n@@ -3690,6 +3705,9 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,\n \tcase RTE_ETH_EVENT_DESTROY:\n \t\tports[port_id].port_status = RTE_PORT_CLOSED;\n \t\tprintf(\"Port %u is closed\\n\", port_id);\n+\t\tif (rte_eal_alarm_set(100000, remove_invalid_ports_callback,\n+\t\t\t(void *)(intptr_t)port_id))\n+\t\t\tfprintf(stderr, \"Could not set up deferred device released\\n\");\n \t\tbreak;\n \tcase RTE_ETH_EVENT_RX_AVAIL_THRESH: {\n \t\tuint16_t rxq_id;\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex ddf5e21849..22261f20a2 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -278,7 +278,6 @@ struct rte_port {\n \tuint16_t                tx_vlan_id;/**< The tag ID */\n \tuint16_t                tx_vlan_id_outer;/**< The outer tag ID */\n \tvolatile uint16_t        port_status;    /**< port started or not */\n-\tuint8_t                 need_setup;     /**< port just attached */\n \tuint8_t                 need_reconfig;  /**< need reconfiguring port or not */\n \tuint8_t                 need_reconfig_queues; /**< need reconfiguring queues or not */\n \tuint8_t                 rss_flag;   /**< enable rss or not */\ndiff --git a/drivers/net/bonding/bonding_testpmd.c b/drivers/net/bonding/bonding_testpmd.c\nindex 3941f4cf23..ed1a278a44 100644\n--- a/drivers/net/bonding/bonding_testpmd.c\n+++ b/drivers/net/bonding/bonding_testpmd.c\n@@ -763,7 +763,6 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,\n \t\t\tport_id, rte_strerror(-ret));\n \n \tports[port_id].bond_flag = 1;\n-\tports[port_id].need_setup = 0;\n \tports[port_id].port_status = RTE_PORT_STOPPED;\n }\n \n",
    "prefixes": [
        "V2",
        "5/6"
    ]
}