get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 111673,
    "url": "http://patches.dpdk.org/api/patches/111673/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1653360497-18080-2-git-send-email-andy.pei@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": "<1653360497-18080-2-git-send-email-andy.pei@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1653360497-18080-2-git-send-email-andy.pei@intel.com",
    "date": "2022-05-24T02:48:05",
    "name": "[v10,01/13] vdpa/ifc: add support for virtio blk device",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "01b57b7afc3fd2b90033840a889e1d0d33f2c7b5",
    "submitter": {
        "id": 1185,
        "url": "http://patches.dpdk.org/api/people/1185/?format=api",
        "name": "Pei, Andy",
        "email": "andy.pei@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/1653360497-18080-2-git-send-email-andy.pei@intel.com/mbox/",
    "series": [
        {
            "id": 23108,
            "url": "http://patches.dpdk.org/api/series/23108/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=23108",
            "date": "2022-05-24T02:48:04",
            "name": "add virtio_blk device support to vdpa/ifc",
            "version": 10,
            "mbox": "http://patches.dpdk.org/series/23108/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/111673/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/111673/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 A5059A04FF;\n\tTue, 24 May 2022 05:35:34 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0341640E78;\n\tTue, 24 May 2022 05:35:32 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by mails.dpdk.org (Postfix) with ESMTP id 253194067B\n for <dev@dpdk.org>; Tue, 24 May 2022 05:35:29 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 23 May 2022 20:35:29 -0700",
            "from dpdk-dipei.sh.intel.com ([10.67.110.238])\n by orsmga005.jf.intel.com with ESMTP; 23 May 2022 20:35:27 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1653363330; x=1684899330;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=2Tdx7IwfX/Qw63wIoOlFxHv7o8sTmOGQ07N0SVk/roE=;\n b=LS8xMeTscn6z5v+IltsyVH6wJsLaTLAsY+VjwmiPoe/+uMsiAUODKsTi\n DPU5ZqPzMy0x1nYxMhU3HmnAswDCuNMbKs5rj9nGH24d8qDnzhPPOeZZ0\n gIyDz+kvATUUAnA7ytzeO09AXRtSCE7VjC79J4Pf67SehFkr2/dYffGAX\n +RQPOIekkivkVgewxWNPzPmTiH94Ohef0/+5F52YvN9jzGVPSrFGZRK5T\n 6nNOtvrN7nFBAjMke8vojusD/MvL6RbPMxRWmlW7apBxxOVOgvqFZrCgB\n iq/FJljKLM7UVTRAHkXDUAdGrCJXmOPG/2Lgl87TX71961XbzK4CxBHLI w==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6400,9594,10356\"; a=\"273533596\"",
            "E=Sophos;i=\"5.91,247,1647327600\"; d=\"scan'208\";a=\"273533596\"",
            "E=Sophos;i=\"5.91,247,1647327600\"; d=\"scan'208\";a=\"745046897\""
        ],
        "X-ExtLoop1": "1",
        "From": "Andy Pei <andy.pei@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "chenbo.xia@intel.com, maxime.coquelin@redhat.com, gang.cao@intel.com,\n changpeng.liu@intel.com, rosen.xu@intel.com, qimaix.xiao@intel.com",
        "Subject": "[PATCH v10 01/13] vdpa/ifc: add support for virtio blk device",
        "Date": "Tue, 24 May 2022 10:48:05 +0800",
        "Message-Id": "<1653360497-18080-2-git-send-email-andy.pei@intel.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1653360497-18080-1-git-send-email-andy.pei@intel.com>",
        "References": "<1643093258-47258-2-git-send-email-andy.pei@intel.com>\n <1653360497-18080-1-git-send-email-andy.pei@intel.com>",
        "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": "Re-use the vdpa/ifc code, distinguish blk and net device by pci_device_id.\nBlk and net device are implemented with proper feature and ops.\n\nSigned-off-by: Andy Pei <andy.pei@intel.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n drivers/vdpa/ifc/base/ifcvf.h | 22 +++++++---\n drivers/vdpa/ifc/ifcvf_vdpa.c | 95 ++++++++++++++++++++++++++++++++++++++-----\n 2 files changed, 102 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h\nindex 573a35f..a761d49 100644\n--- a/drivers/vdpa/ifc/base/ifcvf.h\n+++ b/drivers/vdpa/ifc/base/ifcvf.h\n@@ -5,12 +5,19 @@\n #ifndef _IFCVF_H_\n #define _IFCVF_H_\n \n+#include <linux/virtio_blk.h>\n #include \"ifcvf_osdep.h\"\n \n-#define IFCVF_VENDOR_ID\t\t0x1AF4\n-#define IFCVF_DEVICE_ID\t\t0x1041\n-#define IFCVF_SUBSYS_VENDOR_ID\t0x8086\n-#define IFCVF_SUBSYS_DEVICE_ID\t0x001A\n+#define IFCVF_NET\t0\n+#define IFCVF_BLK\t1\n+\n+#define IFCVF_VENDOR_ID                     0x1AF4\n+#define IFCVF_NET_DEVICE_ID                 0x1041\n+#define IFCVF_BLK_MODERN_DEVICE_ID          0x1042\n+#define IFCVF_BLK_TRANSITIONAL_DEVICE_ID    0x1001\n+#define IFCVF_SUBSYS_VENDOR_ID              0x8086\n+#define IFCVF_SUBSYS_DEVICE_ID              0x001A\n+#define IFCVF_BLK_DEVICE_ID                 0x0002\n \n #define IFCVF_MAX_QUEUES\t\t1\n \n@@ -126,13 +133,18 @@ struct ifcvf_hw {\n \tu8     notify_region;\n \tu32    notify_off_multiplier;\n \tstruct ifcvf_pci_common_cfg *common_cfg;\n-\tstruct ifcvf_net_config *dev_cfg;\n+\tunion {\n+\t\tstruct ifcvf_net_config *net_cfg;\n+\t\tstruct virtio_blk_config *blk_cfg;\n+\t\tvoid *dev_cfg;\n+\t};\n \tu8     *isr;\n \tu16    *notify_base;\n \tu16    *notify_addr[IFCVF_MAX_QUEUES * 2];\n \tu8     *lm_cfg;\n \tstruct vring_info vring[IFCVF_MAX_QUEUES * 2];\n \tu8 nr_vring;\n+\tint device_type;\n \tstruct ifcvf_pci_mem_resource mem_resource[IFCVF_PCI_MAX_RESOURCE];\n };\n \ndiff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c\nindex 9f05595..1eed90b 100644\n--- a/drivers/vdpa/ifc/ifcvf_vdpa.c\n+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c\n@@ -75,6 +75,12 @@ struct internal_list {\n \tstruct ifcvf_internal *internal;\n };\n \n+/* vdpa device info includes device features and devcic operation. */\n+struct rte_vdpa_dev_info {\n+\tuint64_t features;\n+\tstruct rte_vdpa_dev_ops *ops;\n+};\n+\n TAILQ_HEAD(internal_list_head, internal_list);\n static struct internal_list_head internal_list =\n \tTAILQ_HEAD_INITIALIZER(internal_list);\n@@ -1138,7 +1144,7 @@ struct internal_list {\n \treturn 0;\n }\n \n-static struct rte_vdpa_dev_ops ifcvf_ops = {\n+static struct rte_vdpa_dev_ops ifcvf_net_ops = {\n \t.get_queue_num = ifcvf_get_queue_num,\n \t.get_features = ifcvf_get_vdpa_features,\n \t.get_protocol_features = ifcvf_get_protocol_features,\n@@ -1167,6 +1173,48 @@ struct internal_list {\n \treturn 0;\n }\n \n+static int16_t\n+ifcvf_pci_get_device_type(struct rte_pci_device *pci_dev)\n+{\n+\tuint16_t pci_device_id = pci_dev->id.device_id;\n+\tuint16_t device_id;\n+\n+\tif (pci_device_id < 0x1000 || pci_device_id > 0x107f) {\n+\t\tDRV_LOG(ERR, \"Probe device is not a virtio device\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (pci_device_id < 0x1040) {\n+\t\t/* Transitional devices: use the PCI subsystem device id as\n+\t\t * virtio device id, same as legacy driver always did.\n+\t\t */\n+\t\tdevice_id = pci_dev->id.subsystem_device_id;\n+\t} else {\n+\t\t/* Modern devices: simply use PCI device id,\n+\t\t * but start from 0x1040.\n+\t\t */\n+\t\tdevice_id = pci_device_id - 0x1040;\n+\t}\n+\n+\treturn device_id;\n+}\n+\n+struct rte_vdpa_dev_info dev_info[] = {\n+\t{\n+\t\t.features = (1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) |\n+\t\t\t    (1ULL << VIRTIO_NET_F_CTRL_VQ) |\n+\t\t\t    (1ULL << VIRTIO_NET_F_STATUS) |\n+\t\t\t    (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) |\n+\t\t\t    (1ULL << VHOST_F_LOG_ALL),\n+\t\t.ops = &ifcvf_net_ops,\n+\t},\n+\t{\n+\t\t.features = (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) |\n+\t\t\t    (1ULL << VHOST_F_LOG_ALL),\n+\t\t.ops = NULL,\n+\t},\n+};\n+\n static int\n ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\tstruct rte_pci_device *pci_dev)\n@@ -1178,6 +1226,7 @@ struct internal_list {\n \tint sw_fallback_lm = 0;\n \tstruct rte_kvargs *kvlist = NULL;\n \tint ret = 0;\n+\tint16_t device_id;\n \n \tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n \t\treturn 0;\n@@ -1227,13 +1276,24 @@ struct internal_list {\n \tinternal->configured = 0;\n \tinternal->max_queues = IFCVF_MAX_QUEUES;\n \tfeatures = ifcvf_get_features(&internal->hw);\n-\tinternal->features = (features &\n-\t\t~(1ULL << VIRTIO_F_IOMMU_PLATFORM)) |\n-\t\t(1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) |\n-\t\t(1ULL << VIRTIO_NET_F_CTRL_VQ) |\n-\t\t(1ULL << VIRTIO_NET_F_STATUS) |\n-\t\t(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) |\n-\t\t(1ULL << VHOST_F_LOG_ALL);\n+\n+\tdevice_id = ifcvf_pci_get_device_type(pci_dev);\n+\tif (device_id < 0) {\n+\t\tDRV_LOG(ERR, \"failed to get device %s type\", pci_dev->name);\n+\t\tgoto error;\n+\t}\n+\n+\tif (device_id == VIRTIO_ID_NET) {\n+\t\tinternal->hw.device_type = IFCVF_NET;\n+\t\tinternal->features = features &\n+\t\t\t\t\t~(1ULL << VIRTIO_F_IOMMU_PLATFORM);\n+\t\tinternal->features |= dev_info[IFCVF_NET].features;\n+\t} else if (device_id == VIRTIO_ID_BLOCK) {\n+\t\tinternal->hw.device_type = IFCVF_BLK;\n+\t\tinternal->features = features &\n+\t\t\t\t\t~(1ULL << VIRTIO_F_IOMMU_PLATFORM);\n+\t\tinternal->features |= dev_info[IFCVF_BLK].features;\n+\t}\n \n \tlist->internal = internal;\n \n@@ -1245,7 +1305,8 @@ struct internal_list {\n \t}\n \tinternal->sw_lm = sw_fallback_lm;\n \n-\tinternal->vdev = rte_vdpa_register_device(&pci_dev->device, &ifcvf_ops);\n+\tinternal->vdev = rte_vdpa_register_device(&pci_dev->device,\n+\t\t\t\tdev_info[internal->hw.device_type].ops);\n \tif (internal->vdev == NULL) {\n \t\tDRV_LOG(ERR, \"failed to register device %s\", pci_dev->name);\n \t\tgoto error;\n@@ -1308,11 +1369,25 @@ struct internal_list {\n static const struct rte_pci_id pci_id_ifcvf_map[] = {\n \t{ .class_id = RTE_CLASS_ANY_ID,\n \t  .vendor_id = IFCVF_VENDOR_ID,\n-\t  .device_id = IFCVF_DEVICE_ID,\n+\t  .device_id = IFCVF_NET_DEVICE_ID,\n \t  .subsystem_vendor_id = IFCVF_SUBSYS_VENDOR_ID,\n \t  .subsystem_device_id = IFCVF_SUBSYS_DEVICE_ID,\n \t},\n \n+\t{ .class_id = RTE_CLASS_ANY_ID,\n+\t  .vendor_id = IFCVF_VENDOR_ID,\n+\t  .device_id = IFCVF_BLK_TRANSITIONAL_DEVICE_ID,\n+\t  .subsystem_vendor_id = IFCVF_SUBSYS_VENDOR_ID,\n+\t  .subsystem_device_id = IFCVF_BLK_DEVICE_ID,\n+\t},\n+\n+\t{ .class_id = RTE_CLASS_ANY_ID,\n+\t  .vendor_id = IFCVF_VENDOR_ID,\n+\t  .device_id = IFCVF_BLK_MODERN_DEVICE_ID,\n+\t  .subsystem_vendor_id = IFCVF_SUBSYS_VENDOR_ID,\n+\t  .subsystem_device_id = IFCVF_BLK_DEVICE_ID,\n+\t},\n+\n \t{ .vendor_id = 0, /* sentinel */\n \t},\n };\n",
    "prefixes": [
        "v10",
        "01/13"
    ]
}