get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 47067,
    "url": "http://patches.dpdk.org/api/patches/47067/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181019020757.27698-7-thomas@monjalon.net/",
    "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": "<20181019020757.27698-7-thomas@monjalon.net>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181019020757.27698-7-thomas@monjalon.net",
    "date": "2018-10-19T02:07:57",
    "name": "[v6,6/6] ethdev: complete closing of port",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "d45118c5a70b2b85f963abe5a5a57fffb3ebd313",
    "submitter": {
        "id": 685,
        "url": "http://patches.dpdk.org/api/people/685/?format=api",
        "name": "Thomas Monjalon",
        "email": "thomas@monjalon.net"
    },
    "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/20181019020757.27698-7-thomas@monjalon.net/mbox/",
    "series": [
        {
            "id": 1984,
            "url": "http://patches.dpdk.org/api/series/1984/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1984",
            "date": "2018-10-19T02:07:51",
            "name": "ethdev port freeing",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/1984/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/47067/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/47067/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6F6831B176;\n\tFri, 19 Oct 2018 04:08:17 +0200 (CEST)",
            "from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com\n\t[66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 64C0D1B12E\n\tfor <dev@dpdk.org>; Fri, 19 Oct 2018 04:08:07 +0200 (CEST)",
            "from compute1.internal (compute1.nyi.internal [10.202.2.41])\n\tby mailout.nyi.internal (Postfix) with ESMTP id 119A7229F0;\n\tThu, 18 Oct 2018 22:08:07 -0400 (EDT)",
            "from mailfrontend2 ([10.202.2.163])\n\tby compute1.internal (MEProxy); Thu, 18 Oct 2018 22:08:07 -0400",
            "from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])\n\tby mail.messagingengine.com (Postfix) with ESMTPA id E9957102E4;\n\tThu, 18 Oct 2018 22:08:05 -0400 (EDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=\n\tfrom:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding; s=mesmtp; bh=yGIMgctg/o\n\tExi+jf21k4YVZ8LoWRiLvbEg/MgunrpEY=; b=lEu+DA9xfwGtkbFWkigl4GCr/J\n\tV9pNtC6+STs1D3nOswj7ovYhPKS1u3mOCNfic2PeUpFkF2VvSxVbK/fObPm+o/uY\n\tV3mBjyoan3JZeBh86GCFdJMIhb72r8PBCucxAiRVuGSyybfTPIzecal7d306mrkg\n\thnHYqqNdNxgY5RayE=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:content-transfer-encoding:date:from\n\t:in-reply-to:message-id:mime-version:references:subject:to\n\t:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=\n\tfm1; bh=yGIMgctg/oExi+jf21k4YVZ8LoWRiLvbEg/MgunrpEY=; b=O72YmKGy\n\tSQvtAWQ2l63k7ZNrGUh2wR8CehNH1ENV0RVV4SqFwLJlKl32giGgcb3UBg9wT+W6\n\tyyR8CkddH/jlND/Pl8I0bp3z60S2KkHibg2FwGVSJ3h9mDaIlFZ83WnH4Qk2bMor\n\tB5+po13OSXaglCWeS7TRUq66jQQDc6Ryo14oki0xoBmxQANzPfp8SOqJRGFNSo7g\n\t4CLxF3IfSuOdr4ZM0SBKg802hZWABJ3WYzXEFj8xo5nnPyFBFtKL+yf+I1Wwv1t2\n\t9cMY2OK3o/cqoJieUzTYzzUEQxiZMCT8F+0qIntZSXX95wAJjn2/5+afRAsrNdBm\n\tiubXI4HBMr7aEw=="
        ],
        "X-ME-Sender": "<xms:hjzJW4IARQyEclh_llK1M6xJOdN31SHiWiL-hsKoECIaP21DXRgyKw>",
        "X-ME-Proxy": "<xmx:hjzJW_9S-WPOuxoVV4yjvLNPFt_0L-oiq3UFlLNSLknbGee4o30A6w>\n\t<xmx:hjzJW9YfGxwTSw0PQ4PzXy8ZuMn9sdHo_C28gUbyNuzW3CplRBq-1g>\n\t<xmx:hjzJW8d3-bJ6XTOoJQHmgrOfwYJ9pz7c7nJiBbbgY5t679w7IYuQsw>\n\t<xmx:hjzJW1F_p5i8HGffwQr7l6kvcouLl1inH0fLZz_LHulB_5tC0fNDHA>\n\t<xmx:hjzJW3ONhsGfBZe2zI5232Q_EP90erPqb_IPo8TMoCGhO6JNqI0KCw>\n\t<xmx:hzzJW8UO-Zq2ZsxbR0KXgv2IyRApUCE8JndjNG_xLUkr6fg7ruEE1Q>",
        "From": "Thomas Monjalon <thomas@monjalon.net>",
        "To": "ferruh.yigit@intel.com,\n\tarybchenko@solarflare.com",
        "Cc": "dev@dpdk.org, ophirmu@mellanox.com, bernard.iremonger@intel.com,\n\trahul.lakkireddy@chelsio.com",
        "Date": "Fri, 19 Oct 2018 04:07:57 +0200",
        "Message-Id": "<20181019020757.27698-7-thomas@monjalon.net>",
        "X-Mailer": "git-send-email 2.19.0",
        "In-Reply-To": "<20181019020757.27698-1-thomas@monjalon.net>",
        "References": "<20180907233929.21950-1-thomas@monjalon.net>\n\t<20181019020757.27698-1-thomas@monjalon.net>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v6 6/6] ethdev: complete closing of port",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "After closing a port, it cannot be restarted.\nSo there is no reason to not free all associated resources.\n\nThe last step was done with rte_eth_dev_detach() which is deprecated.\nInstead of blindly removing the associated rte_device, the driver should\ncheck if no more port (ethdev, cryptodev, etc) is open for the device.\n\nThe last ethdev freeing which were done by rte_eth_dev_detach(),\nare now done at the end of rte_eth_dev_close() if the driver supports\nthe flag RTE_ETH_DEV_CLOSE_REMOVE.\nThere will be a transition period for PMDs to enable this new flag\nand migrate to the new behaviour.\nWhen enabling RTE_ETH_DEV_CLOSE_REMOVE, the PMD must free all its\nprivate resources for the port, in its dev_close function.\nIt is advised to call the dev_close function in the remove function\nin order to support removing a device without closing its ports.\n\nSome drivers does not allocate MAC addresses dynamically or separately.\nIn those cases, the pointer is set to NULL, in order to avoid wrongly\nfreeing them in rte_eth_dev_release_port().\n\nA closed port will have the state RTE_ETH_DEV_UNUSED which is\nconsidered as invalid by rte_eth_dev_is_valid_port().\nSo validity is not checked anymore for closed ports in testpmd.\n\nSigned-off-by: Thomas Monjalon <thomas@monjalon.net>\n---\n app/test-pmd/testpmd.c                 | 16 +++-------------\n doc/guides/rel_notes/release_18_11.rst |  5 +++++\n lib/librte_ethdev/rte_ethdev.c         | 10 ++++++++++\n lib/librte_ethdev/rte_ethdev.h         |  9 +++++++--\n 4 files changed, 25 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex d5a8a14af..b0b418424 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -1938,18 +1938,6 @@ port_is_started(portid_t port_id)\n \treturn 1;\n }\n \n-static int\n-port_is_closed(portid_t port_id)\n-{\n-\tif (port_id_is_invalid(port_id, ENABLED_WARN))\n-\t\treturn 0;\n-\n-\tif (ports[port_id].port_status != RTE_PORT_CLOSED)\n-\t\treturn 0;\n-\n-\treturn 1;\n-}\n-\n int\n start_port(portid_t pid)\n {\n@@ -2253,6 +2241,8 @@ close_port(portid_t pid)\n \t\t\tport_flow_flush(pi);\n \t\trte_eth_dev_close(pi);\n \n+\t\tremove_unused_fwd_ports();\n+\n \t\tif (rte_atomic16_cmpset(&(port->port_status),\n \t\t\tRTE_PORT_HANDLING, RTE_PORT_CLOSED) == 0)\n \t\t\tprintf(\"Port %d cannot be set to closed\\n\", pi);\n@@ -2343,7 +2333,7 @@ detach_port(portid_t port_id)\n \n \tprintf(\"Detaching a port...\\n\");\n \n-\tif (!port_is_closed(port_id)) {\n+\tif (ports[port_id].port_status != RTE_PORT_CLOSED) {\n \t\tif (ports[port_id].port_status != RTE_PORT_STOPPED) {\n \t\t\tprintf(\"Port not stopped\\n\");\n \t\t\treturn;\ndiff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst\nindex 3d5a34ed9..1cbc93d9d 100644\n--- a/doc/guides/rel_notes/release_18_11.rst\n+++ b/doc/guides/rel_notes/release_18_11.rst\n@@ -235,6 +235,11 @@ API Changes\n   functions were deprecated since 17.05 and are replaced by\n   ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``.\n \n+* ethdev: A call to ``rte_eth_dev_release_port()`` has been added in\n+  ``rte_eth_dev_close()``. As a consequence, a closed port is freed\n+  and seen as invalid because of its state ``RTE_ETH_DEV_UNUSED``.\n+  This new behaviour is enabled per driver for a migration period.\n+\n * A new device flag, RTE_ETH_DEV_NOLIVE_MAC_ADDR, changes the order of\n   actions inside rte_eth_dev_start regarding MAC set. Some NICs do not\n   support MAC changes once the port has started and with this new device\ndiff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c\nindex 178800a5b..0979c0c7b 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -1384,6 +1384,16 @@ rte_eth_dev_close(uint16_t port_id)\n \tdev->data->dev_started = 0;\n \t(*dev->dev_ops->dev_close)(dev);\n \n+\t/* check behaviour flag - temporary for PMD migration */\n+\tif ((dev->data->dev_flags & RTE_ETH_DEV_CLOSE_REMOVE) != 0) {\n+\t\t/* new behaviour: send event + reset state + free all data */\n+\t\trte_eth_dev_release_port(dev);\n+\t\treturn;\n+\t}\n+\tRTE_ETHDEV_LOG(DEBUG, \"Port closing is using an old behaviour.\\n\"\n+\t\t\t\"The driver %s should migrate to the new behaviour.\\n\",\n+\t\t\tdev->device->driver->name);\n+\t/* old behaviour: only free queue arrays */\n \tdev->data->nb_rx_queues = 0;\n \trte_free(dev->data->rx_queues);\n \tdev->data->rx_queues = NULL;\ndiff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h\nindex fb40c89e0..c4caf0642 100644\n--- a/lib/librte_ethdev/rte_ethdev.h\n+++ b/lib/librte_ethdev/rte_ethdev.h\n@@ -1259,6 +1259,11 @@ struct rte_eth_dev_owner {\n \tchar name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */\n };\n \n+/**\n+ * Port is released (i.e. totally freed and data erased) on close.\n+ * Temporary flag for PMD migration to new rte_eth_dev_close() behaviour.\n+ */\n+#define RTE_ETH_DEV_CLOSE_REMOVE 0x0001\n /** Device supports link state interrupt */\n #define RTE_ETH_DEV_INTR_LSC     0x0002\n /** Device is a bonded slave */\n@@ -1802,8 +1807,8 @@ int rte_eth_dev_set_link_down(uint16_t port_id);\n \n /**\n  * Close a stopped Ethernet device. The device cannot be restarted!\n- * The function frees all resources except for needed by the\n- * closed state. To free these resources, call rte_eth_dev_detach().\n+ * The function frees all port resources if the driver supports\n+ * the flag RTE_ETH_DEV_CLOSE_REMOVE.\n  *\n  * @param port_id\n  *   The port identifier of the Ethernet device.\n",
    "prefixes": [
        "v6",
        "6/6"
    ]
}