get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 111676,
    "url": "http://patches.dpdk.org/api/patches/111676/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1653360497-18080-5-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-5-git-send-email-andy.pei@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1653360497-18080-5-git-send-email-andy.pei@intel.com",
    "date": "2022-05-24T02:48:08",
    "name": "[v10,04/13] vdpa/ifc: add blk ops for ifc device",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "b104c4326ca180a6ed19e56629c926965d94a6ed",
    "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-5-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/111676/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/111676/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 21E0DA04FF;\n\tTue, 24 May 2022 05:35:52 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C33384281B;\n\tTue, 24 May 2022 05:35:38 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by mails.dpdk.org (Postfix) with ESMTP id 3CE56427F3\n for <dev@dpdk.org>; Tue, 24 May 2022 05:35:36 +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:35 -0700",
            "from dpdk-dipei.sh.intel.com ([10.67.110.238])\n by orsmga005.jf.intel.com with ESMTP; 23 May 2022 20:35:33 -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=1653363336; x=1684899336;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=g3XfAaB74qczc1WZCxnMa6HfmBrd1A/JzKVDLqxxM0E=;\n b=LTiEix/2u89GDJR4s5QMmWrvt5dMp/ONWGeFFoZJqugtpkRCSQNBqZEh\n zMeQCeCGZ6PzIXygGTdYYYesEgRZsz2jkF8fLXtPCwWXPgoplTB3QH3w7\n vkC/l8ArvXcScCG6iOL3aYfkY+wF/aKbqSGbYzRdtAAKsKHV6vrbMC49x\n Vo+j3i8SU71aBTP4zEJqqramNKURwH8tjQqi6URtuqAWPvxw2NgfBpn6I\n CNMdnOHlKM2NhIFr+DssfTQF1giD6lMiYo2NUmm0cs/naSgGz6gDCYOvk\n +BNCV8YmI8BeNg7cHVro+2mhV0yvDVus9JmurdRH8iQWTWosQWotE5HvR w==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6400,9594,10356\"; a=\"273533606\"",
            "E=Sophos;i=\"5.91,247,1647327600\"; d=\"scan'208\";a=\"273533606\"",
            "E=Sophos;i=\"5.91,247,1647327600\"; d=\"scan'208\";a=\"745046940\""
        ],
        "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 04/13] vdpa/ifc: add blk ops for ifc device",
        "Date": "Tue, 24 May 2022 10:48:08 +0800",
        "Message-Id": "<1653360497-18080-5-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": "For virtio blk device, re-use part of ifc driver ops.\nImplement ifcvf_blk_get_config for virtio blk device.\nSupport VHOST_USER_PROTOCOL_F_CONFIG feature for virtio\nblk device.\n\nSigned-off-by: Andy Pei <andy.pei@intel.com>\n---\n drivers/vdpa/ifc/base/ifcvf.h |  4 ++\n drivers/vdpa/ifc/ifcvf_vdpa.c | 96 ++++++++++++++++++++++++++++++++++++++++++-\n 2 files changed, 99 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h\nindex a761d49..b6fdfdb 100644\n--- a/drivers/vdpa/ifc/base/ifcvf.h\n+++ b/drivers/vdpa/ifc/base/ifcvf.h\n@@ -65,6 +65,10 @@\n #define IFCVF_32_BIT_MASK\t\t0xffffffff\n \n \n+#ifndef VHOST_USER_PROTOCOL_F_CONFIG\n+#define VHOST_USER_PROTOCOL_F_CONFIG\t9\n+#endif\n+\n struct ifcvf_pci_cap {\n \tu8 cap_vndr;            /* Generic PCI field: PCI_CAP_ID_VNDR */\n \tu8 cap_next;            /* Generic PCI field: next ptr. */\ndiff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c\nindex 1eed90b..10a4a25 100644\n--- a/drivers/vdpa/ifc/ifcvf_vdpa.c\n+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c\n@@ -1087,6 +1087,10 @@ struct rte_vdpa_dev_info {\n \t\t 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | \\\n \t\t 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | \\\n \t\t 1ULL << VHOST_USER_PROTOCOL_F_STATUS)\n+\n+#define VDPA_BLK_PROTOCOL_FEATURES \\\n+\t\t(1ULL << VHOST_USER_PROTOCOL_F_CONFIG)\n+\n static int\n ifcvf_get_protocol_features(struct rte_vdpa_device *vdev, uint64_t *features)\n {\n@@ -1199,6 +1203,96 @@ struct rte_vdpa_dev_info {\n \treturn device_id;\n }\n \n+static int\n+ifcvf_blk_get_config(int vid, uint8_t *config, uint32_t size)\n+{\n+\tstruct virtio_blk_config *dev_cfg;\n+\tstruct ifcvf_internal *internal;\n+\tstruct rte_vdpa_device *vdev;\n+\tstruct internal_list *list;\n+\tuint32_t i;\n+\tuint64_t capacity = 0;\n+\tuint8_t *byte;\n+\n+\tif (size != sizeof(struct virtio_blk_config)) {\n+\t\tDRV_LOG(ERR, \"Invalid len: %u, required: %u\",\n+\t\t\tsize, (uint32_t)sizeof(struct virtio_blk_config));\n+\t\treturn -1;\n+\t}\n+\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n+\tif (vdev == NULL) {\n+\t\tDRV_LOG(ERR, \"Invalid vDPA device vid: %d\", vid);\n+\t\treturn -1;\n+\t}\n+\n+\tlist = find_internal_resource_by_vdev(vdev);\n+\tif (list == NULL) {\n+\t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\n+\t\treturn -1;\n+\t}\n+\n+\tinternal = list->internal;\n+\n+\tfor (i = 0; i < sizeof(struct virtio_blk_config); i++)\n+\t\tconfig[i] = *((u8 *)internal->hw.blk_cfg + i);\n+\n+\tdev_cfg = (struct virtio_blk_config *)internal->hw.blk_cfg;\n+\n+\t/* cannot read 64-bit register in one attempt, so read byte by byte. */\n+\tfor (i = 0; i < sizeof(internal->hw.blk_cfg->capacity); i++) {\n+\t\tbyte = (uint8_t *)&internal->hw.blk_cfg->capacity + i;\n+\t\tcapacity |= (uint64_t)*byte << (i * 8);\n+\t}\n+\t/* The capacity is number of sectors in 512-byte.\n+\t * So right shift 1 bit  we get in K,\n+\t * another right shift 10 bits we get in M,\n+\t * right shift 10 more bits, we get in G.\n+\t * To show capacity in G, we right shift 21 bits in total.\n+\t */\n+\tDRV_LOG(DEBUG, \"capacity  : %\"PRIu64\"G\", capacity >> 21);\n+\n+\tDRV_LOG(DEBUG, \"size_max  : 0x%08x\", dev_cfg->size_max);\n+\tDRV_LOG(DEBUG, \"seg_max   : 0x%08x\", dev_cfg->seg_max);\n+\tDRV_LOG(DEBUG, \"blk_size  : 0x%08x\", dev_cfg->blk_size);\n+\tDRV_LOG(DEBUG, \"geometry\");\n+\tDRV_LOG(DEBUG, \"      cylinders: %u\", dev_cfg->geometry.cylinders);\n+\tDRV_LOG(DEBUG, \"      heads    : %u\", dev_cfg->geometry.heads);\n+\tDRV_LOG(DEBUG, \"      sectors  : %u\", dev_cfg->geometry.sectors);\n+\tDRV_LOG(DEBUG, \"num_queues: 0x%08x\", dev_cfg->num_queues);\n+\n+\tDRV_LOG(DEBUG, \"config: [%x] [%x] [%x] [%x] [%x] [%x] [%x] [%x]\\n\",\n+\t\tconfig[0], config[1], config[2], config[3], config[4],\n+\t\tconfig[5], config[6], config[7]);\n+\treturn 0;\n+}\n+\n+static int\n+ifcvf_blk_get_protocol_features(struct rte_vdpa_device *vdev,\n+\tuint64_t *features)\n+{\n+\tRTE_SET_USED(vdev);\n+\n+\t*features = VDPA_SUPPORTED_PROTOCOL_FEATURES;\n+\t*features |= VDPA_BLK_PROTOCOL_FEATURES;\n+\treturn 0;\n+}\n+\n+static struct rte_vdpa_dev_ops ifcvf_blk_ops = {\n+\t.get_queue_num = ifcvf_get_queue_num,\n+\t.get_features = ifcvf_get_vdpa_features,\n+\t.set_features = ifcvf_set_features,\n+\t.get_protocol_features = ifcvf_blk_get_protocol_features,\n+\t.dev_conf = ifcvf_dev_config,\n+\t.dev_close = ifcvf_dev_close,\n+\t.set_vring_state = ifcvf_set_vring_state,\n+\t.migration_done = NULL,\n+\t.get_vfio_group_fd = ifcvf_get_vfio_group_fd,\n+\t.get_vfio_device_fd = ifcvf_get_vfio_device_fd,\n+\t.get_notify_area = ifcvf_get_notify_area,\n+\t.get_config = ifcvf_blk_get_config,\n+};\n+\n struct rte_vdpa_dev_info dev_info[] = {\n \t{\n \t\t.features = (1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) |\n@@ -1211,7 +1305,7 @@ struct rte_vdpa_dev_info dev_info[] = {\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\t.ops = &ifcvf_blk_ops,\n \t},\n };\n \n",
    "prefixes": [
        "v10",
        "04/13"
    ]
}