get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87292,
    "url": "https://patches.dpdk.org/api/patches/87292/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210126101639.250481-6-maxime.coquelin@redhat.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": "<20210126101639.250481-6-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210126101639.250481-6-maxime.coquelin@redhat.com",
    "date": "2021-01-26T10:16:00",
    "name": "[v4,05/44] net/virtio: refactor virtio-user device",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "50eaeb6521505dc184fed02f7fd87b0bfb324b44",
    "submitter": {
        "id": 512,
        "url": "https://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210126101639.250481-6-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 14950,
            "url": "https://patches.dpdk.org/api/series/14950/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=14950",
            "date": "2021-01-26T10:15:55",
            "name": "net/virtio: Virtio PMD rework",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/14950/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/87292/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/87292/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 DE449A052A;\n\tTue, 26 Jan 2021 11:17:28 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 8F190141329;\n\tTue, 26 Jan 2021 11:17:06 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [63.128.21.124])\n by mails.dpdk.org (Postfix) with ESMTP id 570BF141324\n for <dev@dpdk.org>; Tue, 26 Jan 2021 11:17:03 +0100 (CET)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-590-6MymggqbPL-_C4zBuMC69w-1; Tue, 26 Jan 2021 05:17:00 -0500",
            "from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com\n [10.5.11.11])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3933107ACE6;\n Tue, 26 Jan 2021 10:16:59 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.36.110.31])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 0589872163;\n Tue, 26 Jan 2021 10:16:57 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1611656222;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=ZoYi0IGZNzUVUYRt6AEMckw5NnyD5xv+MTebYwlrCEk=;\n b=D8f9wloMQEJibxsAxloC7jc+466gxAXG/D581WTj63Qer1Nh0hAiFQIeMalTTfCEG+oGGG\n OhP+N9+2s6b/mVvpUjkE6OJMDethlxcQ0aL3dyoNhbI2i2Op64GNTSiQbcTFVycFTRyMzK\n QQDC6nAh6Uu7E5rW01WZPTbtLCm1bxc=",
        "X-MC-Unique": "6MymggqbPL-_C4zBuMC69w-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com,\n amorenoz@redhat.com, david.marchand@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Tue, 26 Jan 2021 11:16:00 +0100",
        "Message-Id": "<20210126101639.250481-6-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20210126101639.250481-1-maxime.coquelin@redhat.com>",
        "References": "<20210126101639.250481-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.11",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[dpdk-dev] [PATCH v4 05/44] net/virtio: refactor virtio-user device",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch moves the virtio_hw structure into the virtio_user_dev\nstructure, with the goal of making virtio_hw bus-agnostic.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c            |  2 +-\n drivers/net/virtio/virtio_pci.h               |  1 -\n .../net/virtio/virtio_user/virtio_user_dev.h  |  1 +\n drivers/net/virtio/virtio_user_ethdev.c       | 64 ++++++++-----------\n 4 files changed, 29 insertions(+), 39 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex 0ba10c274a..c8a01a46df 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -747,7 +747,7 @@ virtio_dev_close(struct rte_eth_dev *dev)\n \n #ifdef RTE_VIRTIO_USER\n \tif (hw->bus_type == VIRTIO_BUS_USER)\n-\t\tvirtio_user_dev_uninit(hw->virtio_user_dev);\n+\t\tvirtio_user_dev_uninit(dev->data->dev_private);\n \telse\n #endif\n \tif (dev->device) {\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex 6388f0a74d..b35a596169 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -277,7 +277,6 @@ struct virtio_hw {\n \tuint16_t    *notify_base;\n \tstruct virtio_pci_common_cfg *common_cfg;\n \tstruct virtio_net_config *dev_cfg;\n-\tvoid\t    *virtio_user_dev;\n \t/*\n \t * App management thread and virtio interrupt handler thread\n \t * both can change device state, this lock is meant to avoid\ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h\nindex 3b5b6bc3ae..b3776cc7a0 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h\n@@ -24,6 +24,7 @@ struct virtio_user_queue {\n };\n \n struct virtio_user_dev {\n+\tstruct virtio_hw hw;\n \tenum virtio_user_backend_type backend_type;\n \t/* for vhost_user backend */\n \tint\t\tvhostfd;\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex 441721b6ca..620ecb126c 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -26,13 +26,13 @@\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+#define virtio_user_get_dev(hwp) container_of(hwp, struct virtio_user_dev, hw)\n \n static void\n-virtio_user_reset_queues_packed(struct rte_eth_dev *dev)\n+virtio_user_reset_queues_packed(struct rte_eth_dev *eth_dev)\n {\n-\tstruct virtio_hw *hw = dev->data->dev_private;\n+\tstruct virtio_user_dev *dev = eth_dev->data->dev_private;\n+\tstruct virtio_hw *hw = &dev->hw;\n \tstruct virtnet_rx *rxvq;\n \tstruct virtnet_tx *txvq;\n \tuint16_t i;\n@@ -48,14 +48,14 @@ virtio_user_reset_queues_packed(struct rte_eth_dev *dev)\n \trte_delay_ms(1);\n \n \t/* Vring reset for each Tx queue and Rx queue. */\n-\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n-\t\trxvq = dev->data->rx_queues[i];\n+\tfor (i = 0; i < eth_dev->data->nb_rx_queues; i++) {\n+\t\trxvq = eth_dev->data->rx_queues[i];\n \t\tvirtqueue_rxvq_reset_packed(rxvq->vq);\n-\t\tvirtio_dev_rx_queue_setup_finish(dev, i);\n+\t\tvirtio_dev_rx_queue_setup_finish(eth_dev, i);\n \t}\n \n-\tfor (i = 0; i < dev->data->nb_tx_queues; i++) {\n-\t\ttxvq = dev->data->tx_queues[i];\n+\tfor (i = 0; i < eth_dev->data->nb_tx_queues; i++) {\n+\t\ttxvq = eth_dev->data->tx_queues[i];\n \t\tvirtqueue_txvq_reset_packed(txvq->vq);\n \t}\n \n@@ -69,7 +69,7 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)\n {\n \tint ret, connectfd, old_status;\n \tstruct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];\n-\tstruct virtio_hw *hw = eth_dev->data->dev_private;\n+\tstruct virtio_hw *hw = &dev->hw;\n \tuint64_t protocol_features;\n \n \tconnectfd = accept(dev->listenfd, NULL, NULL);\n@@ -605,21 +605,15 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev)\n \tstruct virtio_hw *hw;\n \tstruct virtio_user_dev *dev;\n \n-\teth_dev = rte_eth_vdev_allocate(vdev, sizeof(*hw));\n+\teth_dev = rte_eth_vdev_allocate(vdev, sizeof(*dev));\n \tif (!eth_dev) {\n \t\tPMD_INIT_LOG(ERR, \"cannot alloc rte_eth_dev\");\n \t\treturn NULL;\n \t}\n \n \tdata = eth_dev->data;\n-\thw = eth_dev->data->dev_private;\n-\n-\tdev = rte_zmalloc(NULL, sizeof(*dev), 0);\n-\tif (!dev) {\n-\t\tPMD_INIT_LOG(ERR, \"malloc virtio_user_dev failed\");\n-\t\trte_eth_dev_release_port(eth_dev);\n-\t\treturn NULL;\n-\t}\n+\tdev = eth_dev->data->dev_private;\n+\thw = &dev->hw;\n \n \thw->port_id = data->port_id;\n \tdev->port_id = data->port_id;\n@@ -634,17 +628,13 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev)\n \thw->use_vec_tx = 0;\n \thw->use_inorder_rx = 0;\n \thw->use_inorder_tx = 0;\n-\thw->virtio_user_dev = dev;\n+\n \treturn eth_dev;\n }\n \n static void\n virtio_user_eth_dev_free(struct rte_eth_dev *eth_dev)\n {\n-\tstruct rte_eth_dev_data *data = eth_dev->data;\n-\tstruct virtio_hw *hw = data->dev_private;\n-\n-\trte_free(hw->virtio_user_dev);\n \trte_eth_dev_release_port(eth_dev);\n }\n \n@@ -653,11 +643,12 @@ virtio_user_eth_dev_free(struct rte_eth_dev *eth_dev)\n  * Returns 0 on success.\n  */\n static int\n-virtio_user_pmd_probe(struct rte_vdev_device *dev)\n+virtio_user_pmd_probe(struct rte_vdev_device *vdev)\n {\n \tstruct rte_kvargs *kvlist = NULL;\n \tstruct rte_eth_dev *eth_dev;\n \tstruct virtio_hw *hw;\n+\tstruct virtio_user_dev *dev;\n \tenum virtio_user_backend_type backend_type = VIRTIO_USER_BACKEND_UNKNOWN;\n \tuint64_t queues = VIRTIO_USER_DEF_Q_NUM;\n \tuint64_t cq = VIRTIO_USER_DEF_CQ_EN;\n@@ -672,8 +663,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)\n \tchar *mac_addr = NULL;\n \tint ret = -1;\n \n+\tRTE_BUILD_BUG_ON(offsetof(struct virtio_user_dev, hw) != 0);\n+\n \tif (rte_eal_process_type() == RTE_PROC_SECONDARY) {\n-\t\tconst char *name = rte_vdev_device_name(dev);\n+\t\tconst char *name = rte_vdev_device_name(vdev);\n \t\teth_dev = rte_eth_dev_attach_secondary(name);\n \t\tif (!eth_dev) {\n \t\t\tPMD_INIT_LOG(ERR, \"Failed to probe %s\", name);\n@@ -687,12 +680,12 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)\n \t\t}\n \n \t\teth_dev->dev_ops = &virtio_user_secondary_eth_dev_ops;\n-\t\teth_dev->device = &dev->device;\n+\t\teth_dev->device = &vdev->device;\n \t\trte_eth_dev_probing_finish(eth_dev);\n \t\treturn 0;\n \t}\n \n-\tkvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_args);\n+\tkvlist = rte_kvargs_parse(rte_vdev_device_args(vdev), valid_args);\n \tif (!kvlist) {\n \t\tPMD_INIT_LOG(ERR, \"error when parsing param\");\n \t\tgoto end;\n@@ -832,14 +825,15 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)\n \t\t}\n \t}\n \n-\teth_dev = virtio_user_eth_dev_alloc(dev);\n+\teth_dev = virtio_user_eth_dev_alloc(vdev);\n \tif (!eth_dev) {\n \t\tPMD_INIT_LOG(ERR, \"virtio_user fails to alloc device\");\n \t\tgoto end;\n \t}\n \n-\thw = eth_dev->data->dev_private;\n-\tif (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,\n+\tdev = eth_dev->data->dev_private;\n+\thw = &dev->hw;\n+\tif (virtio_user_dev_init(dev, path, queues, cq,\n \t\t\t queue_size, mac_addr, &ifname, server_mode,\n \t\t\t mrg_rxbuf, in_order, packed_vq, backend_type) < 0) {\n \t\tPMD_INIT_LOG(ERR, \"virtio_user_dev_init fails\");\n@@ -912,7 +906,6 @@ static int virtio_user_pmd_dma_map(struct rte_vdev_device *vdev, void *addr,\n \tconst char *name;\n \tstruct rte_eth_dev *eth_dev;\n \tstruct virtio_user_dev *dev;\n-\tstruct virtio_hw *hw;\n \n \tif (!vdev)\n \t\treturn -EINVAL;\n@@ -923,8 +916,7 @@ static int virtio_user_pmd_dma_map(struct rte_vdev_device *vdev, void *addr,\n \tif (!eth_dev)\n \t\treturn 0;\n \n-\thw = (struct virtio_hw *)eth_dev->data->dev_private;\n-\tdev = hw->virtio_user_dev;\n+\tdev = eth_dev->data->dev_private;\n \n \tif (dev->ops->dma_map)\n \t\treturn dev->ops->dma_map(dev, addr, iova, len);\n@@ -938,7 +930,6 @@ static int virtio_user_pmd_dma_unmap(struct rte_vdev_device *vdev, void *addr,\n \tconst char *name;\n \tstruct rte_eth_dev *eth_dev;\n \tstruct virtio_user_dev *dev;\n-\tstruct virtio_hw *hw;\n \n \tif (!vdev)\n \t\treturn -EINVAL;\n@@ -949,8 +940,7 @@ static int virtio_user_pmd_dma_unmap(struct rte_vdev_device *vdev, void *addr,\n \tif (!eth_dev)\n \t\treturn 0;\n \n-\thw = (struct virtio_hw *)eth_dev->data->dev_private;\n-\tdev = hw->virtio_user_dev;\n+\tdev = eth_dev->data->dev_private;\n \n \tif (dev->ops->dma_unmap)\n \t\treturn dev->ops->dma_unmap(dev, addr, iova, len);\n",
    "prefixes": [
        "v4",
        "05/44"
    ]
}