get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 54401,
    "url": "http://patches.dpdk.org/api/patches/54401/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190605094342.17563-5-tiwei.bie@intel.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": "<20190605094342.17563-5-tiwei.bie@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190605094342.17563-5-tiwei.bie@intel.com",
    "date": "2019-06-05T09:43:41",
    "name": "[4/5] net/virtio: release port upon close",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "d793cf642ddf60bc38f426b716a4c823fb8bca7e",
    "submitter": {
        "id": 617,
        "url": "http://patches.dpdk.org/api/people/617/?format=api",
        "name": "Tiwei Bie",
        "email": "tiwei.bie@intel.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190605094342.17563-5-tiwei.bie@intel.com/mbox/",
    "series": [
        {
            "id": 4903,
            "url": "http://patches.dpdk.org/api/series/4903/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4903",
            "date": "2019-06-05T09:43:37",
            "name": "virtio: release port upon close",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/4903/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54401/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/54401/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 343E11BB21;\n\tWed,  5 Jun 2019 11:45:12 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 41B4A1B9CE\n\tfor <dev@dpdk.org>; Wed,  5 Jun 2019 11:45:05 +0200 (CEST)",
            "from orsmga006.jf.intel.com ([10.7.209.51])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Jun 2019 02:45:04 -0700",
            "from npg-dpdk-virtio-tbie-2.sh.intel.com ([10.67.104.151])\n\tby orsmga006.jf.intel.com with ESMTP; 05 Jun 2019 02:45:03 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Tiwei Bie <tiwei.bie@intel.com>",
        "To": "maxime.coquelin@redhat.com,\n\tzhihong.wang@intel.com,\n\tdev@dpdk.org",
        "Date": "Wed,  5 Jun 2019 17:43:41 +0800",
        "Message-Id": "<20190605094342.17563-5-tiwei.bie@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190605094342.17563-1-tiwei.bie@intel.com>",
        "References": "<20190605094342.17563-1-tiwei.bie@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 4/5] net/virtio: release port upon close",
        "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": "Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private\nresources for the port can be freed by rte_eth_dev_close().\n\nSigned-off-by: Tiwei Bie <tiwei.bie@intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c            | 42 ++++++++++++-------\n .../net/virtio/virtio_user/virtio_user_dev.h  |  1 -\n drivers/net/virtio/virtio_user_ethdev.c       | 12 ++----\n 3 files changed, 31 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex 46d2e4ac6..afb2ca209 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -35,6 +35,7 @@\n #include \"virtio_logs.h\"\n #include \"virtqueue.h\"\n #include \"virtio_rxtx.h\"\n+#include \"virtio_user/virtio_user_dev.h\"\n \n static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);\n static int  virtio_dev_configure(struct rte_eth_dev *dev);\n@@ -733,6 +734,17 @@ virtio_dev_close(struct rte_eth_dev *dev)\n \tvtpci_reset(hw);\n \tvirtio_dev_free_mbufs(dev);\n \tvirtio_free_queues(hw);\n+\n+#ifdef RTE_VIRTIO_USER\n+\tif (hw->virtio_user_dev)\n+\t\tvirtio_user_dev_uninit(hw->virtio_user_dev);\n+\telse\n+#endif\n+\tif (dev->device) {\n+\t\trte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(dev));\n+\t\tif (!hw->modern)\n+\t\t\trte_pci_ioport_unmap(VTPCI_IO(hw));\n+\t}\n }\n \n static void\n@@ -1645,10 +1657,8 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)\n \n \thw->weak_barriers = !vtpci_with_feature(hw, VIRTIO_F_ORDER_PLATFORM);\n \n-\tif (!hw->virtio_user_dev) {\n+\tif (!hw->virtio_user_dev)\n \t\tpci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);\n-\t\trte_eth_copy_pci_info(eth_dev, pci_dev);\n-\t}\n \n \t/* If host does not support both status and MSI-X then disable LSC */\n \tif (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS) &&\n@@ -1840,6 +1850,12 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \t\treturn 0;\n \t}\n \n+\t/*\n+\t * Pass the information to the rte_eth_dev_close() that it should also\n+\t * release the private port resources.\n+\t */\n+\teth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;\n+\n \t/* Allocate memory for storing MAC addresses */\n \teth_dev->data->mac_addrs = rte_zmalloc(\"virtio\",\n \t\t\t\tVIRTIO_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);\n@@ -1865,6 +1881,8 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \tif (ret < 0)\n \t\tgoto err_virtio_init;\n \n+\thw->opened = true;\n+\n \treturn 0;\n \n err_virtio_init:\n@@ -1882,8 +1900,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n static int\n eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)\n {\n-\tstruct virtio_hw *hw = eth_dev->data->dev_private;\n-\n \tPMD_INIT_FUNC_TRACE();\n \n \tif (rte_eal_process_type() == RTE_PROC_SECONDARY)\n@@ -1896,12 +1912,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)\n \teth_dev->tx_pkt_burst = NULL;\n \teth_dev->rx_pkt_burst = NULL;\n \n-\tif (eth_dev->device) {\n-\t\trte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));\n-\t\tif (!hw->modern)\n-\t\t\trte_pci_ioport_unmap(VTPCI_IO(hw));\n-\t}\n-\n \tPMD_INIT_LOG(DEBUG, \"dev_uninit completed\");\n \n \treturn 0;\n@@ -1963,7 +1973,13 @@ static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \n static int eth_virtio_pci_remove(struct rte_pci_device *pci_dev)\n {\n-\treturn rte_eth_dev_pci_generic_remove(pci_dev, eth_virtio_dev_uninit);\n+\tint ret;\n+\n+\tret = rte_eth_dev_pci_generic_remove(pci_dev, eth_virtio_dev_uninit);\n+\t/* Port has already been released by close. */\n+\tif (ret == -ENODEV)\n+\t\tret = 0;\n+\treturn ret;\n }\n \n static struct rte_pci_driver rte_virtio_pmd = {\n@@ -2123,8 +2139,6 @@ virtio_dev_configure(struct rte_eth_dev *dev)\n \t\t\t   DEV_RX_OFFLOAD_VLAN_STRIP))\n \t\thw->use_simple_rx = 0;\n \n-\thw->opened = true;\n-\n \treturn 0;\n }\n \ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h\nindex db7dc607a..ad8683771 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h\n@@ -9,7 +9,6 @@\n #include <stdbool.h>\n #include \"../virtio_pci.h\"\n #include \"../virtio_ring.h\"\n-#include \"vhost.h\"\n \n struct virtio_user_queue {\n \tuint16_t used_idx;\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex 893f48a5d..0a57db730 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -20,6 +20,7 @@\n #include \"virtqueue.h\"\n #include \"virtio_rxtx.h\"\n #include \"virtio_user/virtio_user_dev.h\"\n+#include \"virtio_user/vhost.h\"\n \n #define virtio_user_get_dev(hw) \\\n \t((struct virtio_user_dev *)(hw)->virtio_user_dev)\n@@ -697,8 +698,6 @@ virtio_user_pmd_remove(struct rte_vdev_device *vdev)\n {\n \tconst char *name;\n \tstruct rte_eth_dev *eth_dev;\n-\tstruct virtio_hw *hw;\n-\tstruct virtio_user_dev *dev;\n \n \tif (!vdev)\n \t\treturn -EINVAL;\n@@ -706,8 +705,9 @@ virtio_user_pmd_remove(struct rte_vdev_device *vdev)\n \tname = rte_vdev_device_name(vdev);\n \tPMD_DRV_LOG(INFO, \"Un-Initializing %s\", name);\n \teth_dev = rte_eth_dev_allocated(name);\n+\t/* Port has already been released by close. */\n \tif (!eth_dev)\n-\t\treturn -ENODEV;\n+\t\treturn 0;\n \n \tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n \t\treturn rte_eth_dev_release_port(eth_dev);\n@@ -715,12 +715,6 @@ virtio_user_pmd_remove(struct rte_vdev_device *vdev)\n \t/* make sure the device is stopped, queues freed */\n \trte_eth_dev_close(eth_dev->data->port_id);\n \n-\thw = eth_dev->data->dev_private;\n-\tdev = hw->virtio_user_dev;\n-\tvirtio_user_dev_uninit(dev);\n-\n-\trte_eth_dev_release_port(eth_dev);\n-\n \treturn 0;\n }\n \n",
    "prefixes": [
        "4/5"
    ]
}