get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 35635,
    "url": "http://patches.dpdk.org/api/patches/35635/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180213092106.57996-3-zhihong.wang@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": "<20180213092106.57996-3-zhihong.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180213092106.57996-3-zhihong.wang@intel.com",
    "date": "2018-02-13T09:21:02",
    "name": "[dpdk-dev,v2,2/6] vhost: support selective datapath",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ba4822f0e86d97a010f77974a98ffbe35b780f9c",
    "submitter": {
        "id": 156,
        "url": "http://patches.dpdk.org/api/people/156/?format=api",
        "name": "Zhihong Wang",
        "email": "zhihong.wang@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/20180213092106.57996-3-zhihong.wang@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/35635/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/35635/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 808005F33;\n\tMon,  5 Mar 2018 10:20:26 +0100 (CET)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id C90325F2B\n\tfor <dev@dpdk.org>; Mon,  5 Mar 2018 10:20:24 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Mar 2018 01:20:23 -0800",
            "from unknown (HELO dpdk99.sh.intel.com) ([10.67.110.156])\n\tby fmsmga001.fm.intel.com with ESMTP; 05 Mar 2018 01:20:21 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.47,426,1515484800\"; d=\"scan'208\";a=\"35531739\"",
        "From": "Zhihong Wang <zhihong.wang@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "jianfeng.tan@intel.com, tiwei.bie@intel.com, maxime.coquelin@redhat.com, \n\tyliu@fridaylinux.org, cunming.liang@intel.com, xiao.w.wang@intel.com,\n\tdan.daly@intel.com, Zhihong Wang <zhihong.wang@intel.com>",
        "Date": "Tue, 13 Feb 2018 17:21:02 +0800",
        "Message-Id": "<20180213092106.57996-3-zhihong.wang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20180213092106.57996-1-zhihong.wang@intel.com>",
        "References": "<1517614137-62926-1-git-send-email-zhihong.wang@intel.com>\n\t<20180213092106.57996-1-zhihong.wang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 2/6] vhost: support selective datapath",
        "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://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch introduces support for selective datapath in DPDK vhost-user lib\nto enable various types of virtio-compatible devices to do data transfer\nwith virtio driver directly to enable acceleration. The default datapath is\nthe existing software implementation, more options will be available when\nnew engines are registered.\n\nAn engine is a group of virtio-compatible devices under a single address.\nThe engine driver includes:\n\n 1. A set of engine ops is defined in rte_vdpa_eng_ops to perform engine\n    init, uninit, and attributes reporting.\n    \n 2. A set of device ops is defined in rte_vdpa_dev_ops for virtio devices\n    in the engine to do device specific operations:\n\n     a. dev_conf: Called to configure the actual device when the virtio\n        device becomes ready.\n\n     b. dev_close: Called to close the actual device when the virtio device\n        is stopped.\n\n     c. vring_state_set: Called to change the state of the vring in the\n        actual device when vring state changes.\n\n     d. feature_set: Called to set the negotiated features to device.\n\n     e. migration_done: Called to allow the device to response to RARP\n        sending.\n\n     f. get_vfio_group_fd: Called to get the VFIO group fd of the device.\n\n     g. get_vfio_device_fd: Called to get the VFIO device fd of the device.\n\n     h. get_notify_area: Called to get the notify area info of the queue.\n\nSigned-off-by: Zhihong Wang <zhihong.wang@intel.com>\n---\nChanges in v2:\n\n 1. Add VFIO related vDPA device ops.\n\n lib/librte_vhost/Makefile   |   4 +-\n lib/librte_vhost/rte_vdpa.h | 120 ++++++++++++++++++++++++++++++++++++++++++\n lib/librte_vhost/vdpa.c     | 124 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 246 insertions(+), 2 deletions(-)\n create mode 100644 lib/librte_vhost/rte_vdpa.h\n create mode 100644 lib/librte_vhost/vdpa.c",
    "diff": "diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile\nindex 5d6c6abae..37044ac03 100644\n--- a/lib/librte_vhost/Makefile\n+++ b/lib/librte_vhost/Makefile\n@@ -22,9 +22,9 @@ LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_ethdev -lrte_net\n \n # all source are stored in SRCS-y\n SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := fd_man.c iotlb.c socket.c vhost.c \\\n-\t\t\t\t\tvhost_user.c virtio_net.c\n+\t\t\t\t\tvhost_user.c virtio_net.c vdpa.c\n \n # install includes\n-SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_vhost.h\n+SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_vhost.h rte_vdpa.h\n \n include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h\nnew file mode 100644\nindex 000000000..1bde36f7f\n--- /dev/null\n+++ b/lib/librte_vhost/rte_vdpa.h\n@@ -0,0 +1,120 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#ifndef _RTE_VDPA_H_\n+#define _RTE_VDPA_H_\n+\n+/**\n+ * @file\n+ *\n+ * Device specific vhost lib\n+ */\n+\n+#include <rte_pci.h>\n+#include \"rte_vhost.h\"\n+\n+#define MAX_VDPA_ENGINE_NUM 128\n+#define MAX_VDPA_NAME_LEN 128\n+\n+struct rte_vdpa_eng_addr {\n+\tunion {\n+\t\tuint8_t __dummy[64];\n+\t\tstruct rte_pci_addr pci_addr;\n+\t};\n+};\n+\n+struct rte_vdpa_eng_info {\n+\tstruct rte_vdpa_eng_addr *addr;\n+\tchar name[MAX_VDPA_NAME_LEN];\n+};\n+\n+struct rte_vdpa_eng_attr {\n+\tuint64_t features;\n+\tuint64_t protocol_features;\n+\tuint32_t queue_num;\n+\tuint32_t dev_num;\n+};\n+\n+/* register/remove engine */\n+typedef int (*vdpa_eng_init_t)(int eid, struct rte_vdpa_eng_addr *addr);\n+typedef int (*vdpa_eng_uninit_t)(int eid);\n+\n+/* query info of this engine */\n+typedef int (*vdpa_info_query_t)(int eid,\n+\t\tstruct rte_vdpa_eng_attr *attr);\n+\n+/* driver configure/close the port based on connection */\n+typedef int (*vdpa_dev_conf_t)(int vid);\n+typedef int (*vdpa_dev_close_t)(int vid);\n+\n+/* enable/disable this vring */\n+typedef int (*vdpa_vring_state_set_t)(int vid, int vring, int state);\n+\n+/* set features when changed */\n+typedef int (*vdpa_feature_set_t)(int vid);\n+\n+/* destination operations when migration done, e.g. send rarp */\n+typedef int (*vdpa_migration_done_t)(int vid);\n+\n+/* get the vfio group fd */\n+typedef int (*vdpa_get_vfio_group_fd_t)(int vid);\n+\n+/* get the vfio device fd */\n+typedef int (*vdpa_get_vfio_device_fd_t)(int vid);\n+\n+/* get the notify area info of the queue */\n+typedef int (*vdpa_get_notify_area_t)(int vid, int qid, uint64_t *offset,\n+\t\tuint64_t *size);\n+/* device ops */\n+struct rte_vdpa_dev_ops {\n+\tvdpa_dev_conf_t           dev_conf;\n+\tvdpa_dev_close_t          dev_close;\n+\tvdpa_vring_state_set_t    vring_state_set;\n+\tvdpa_feature_set_t        feature_set;\n+\tvdpa_migration_done_t     migration_done;\n+\tvdpa_get_vfio_group_fd_t  get_vfio_group_fd;\n+\tvdpa_get_vfio_device_fd_t get_vfio_device_fd;\n+\tvdpa_get_notify_area_t    get_notify_area;\n+};\n+\n+/* engine ops */\n+struct rte_vdpa_eng_ops {\n+\tvdpa_eng_init_t eng_init;\n+\tvdpa_eng_uninit_t eng_uninit;\n+\tvdpa_info_query_t info_query;\n+};\n+\n+struct rte_vdpa_eng_driver {\n+\tstruct rte_vdpa_eng_ops eng_ops;\n+\tstruct rte_vdpa_dev_ops dev_ops;\n+\tconst char *name;\n+} __rte_cache_aligned;\n+\n+struct rte_vdpa_engine {\n+\tstruct rte_vdpa_eng_info eng_info;\n+\tstruct rte_vdpa_eng_driver *eng_drv;\n+} __rte_cache_aligned;\n+\n+extern struct rte_vdpa_engine *vdpa_engines[];\n+extern uint32_t vdpa_engine_num;\n+\n+/* engine management */\n+int rte_vdpa_register_engine(const char *name, struct rte_vdpa_eng_addr *addr);\n+int rte_vdpa_unregister_engine(int eid);\n+\n+int rte_vdpa_find_engine_id(struct rte_vdpa_eng_addr *addr);\n+\n+int rte_vdpa_info_query(int eid, struct rte_vdpa_eng_attr *attr);\n+\n+/* driver register api */\n+void rte_vdpa_register_driver(struct rte_vdpa_eng_driver *drv);\n+\n+#define RTE_VDPA_REGISTER_DRIVER(nm, drv) \\\n+RTE_INIT(vdpainitfn_ ##nm); \\\n+static void vdpainitfn_ ##nm(void) \\\n+{ \\\n+\trte_vdpa_register_driver(&drv); \\\n+} \\\n+\n+#endif /* _RTE_VDPA_H_ */\ndiff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c\nnew file mode 100644\nindex 000000000..5d5ffe147\n--- /dev/null\n+++ b/lib/librte_vhost/vdpa.c\n@@ -0,0 +1,124 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+/**\n+ * @file\n+ *\n+ * Device specific vhost lib\n+ */\n+\n+#include <stdbool.h>\n+\n+#include <rte_malloc.h>\n+#include \"rte_vdpa.h\"\n+#include \"vhost.h\"\n+\n+static struct rte_vdpa_eng_driver *vdpa_drivers[MAX_VDPA_ENGINE_NUM];\n+static uint32_t vdpa_driver_num;\n+\n+struct rte_vdpa_engine *vdpa_engines[MAX_VDPA_ENGINE_NUM];\n+uint32_t vdpa_engine_num;\n+\n+static int is_same_eng(struct rte_vdpa_eng_addr *a, struct rte_vdpa_eng_addr *b)\n+{\n+\tif (a->pci_addr.domain != b->pci_addr.domain ||\n+\t\t\ta->pci_addr.bus != b->pci_addr.bus ||\n+\t\t\ta->pci_addr.devid != b->pci_addr.devid ||\n+\t\t\ta->pci_addr.function != b->pci_addr.function)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+void rte_vdpa_register_driver(struct rte_vdpa_eng_driver *driver)\n+{\n+\tif (vdpa_driver_num >= MAX_VDPA_ENGINE_NUM)\n+\t\treturn;\n+\n+\tvdpa_drivers[vdpa_driver_num] = driver;\n+\tvdpa_driver_num++;\n+}\n+\n+int rte_vdpa_register_engine(const char *name, struct rte_vdpa_eng_addr *addr)\n+{\n+\tstatic int engine_idx;\n+\n+\tstruct rte_vdpa_engine *eng;\n+\tstruct rte_vdpa_eng_driver *cur;\n+\tchar engine_name[MAX_VDPA_NAME_LEN];\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_VDPA_ENGINE_NUM; ++i) {\n+\t\teng = vdpa_engines[i];\n+\t\tif (eng && is_same_eng(eng->eng_info.addr, addr) == 0)\n+\t\t\treturn i;\n+\t}\n+\n+\tsprintf(engine_name, \"vdpa-%s-%d\", name, engine_idx++);\n+\teng = rte_zmalloc(engine_name, sizeof(struct rte_vdpa_engine),\n+\t\t\tRTE_CACHE_LINE_SIZE);\n+\tif (!eng)\n+\t\treturn -1;\n+\n+\tfor (i = 0; i < MAX_VDPA_ENGINE_NUM; ++i) {\n+\t\tcur = vdpa_drivers[i];\n+\t\tif (cur && 0 == strncmp(name, cur->name,\n+\t\t\t\t\tMAX_VDPA_NAME_LEN)) {\n+\t\t\teng->eng_drv = cur;\n+\t\t\tstrcpy(eng->eng_info.name, name);\n+\t\t\teng->eng_info.addr = addr;\n+\t\t\tfor (i = 0; i < MAX_VDPA_ENGINE_NUM; ++i) {\n+\t\t\t\tif (vdpa_engines[i])\n+\t\t\t\t\tcontinue;\n+\t\t\t\tvdpa_engines[i] = eng;\n+\t\t\t\tif (eng->eng_drv->eng_ops.eng_init)\n+\t\t\t\t\teng->eng_drv->eng_ops.eng_init(i, addr);\n+\t\t\t\tvdpa_engine_num++;\n+\t\t\t\treturn i;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn -1;\n+}\n+\n+int rte_vdpa_unregister_engine(int eid)\n+{\n+\tif (eid < 0 || eid >= MAX_VDPA_ENGINE_NUM || vdpa_engines[eid]\n+\t\t\t== NULL)\n+\t\treturn -1;\n+\n+\tif (vdpa_engines[eid]->eng_drv->eng_ops.eng_uninit)\n+\t\tvdpa_engines[eid]->eng_drv->eng_ops.eng_uninit(eid);\n+\n+\trte_free(vdpa_engines[eid]);\n+\tvdpa_engines[eid] = NULL;\n+\tvdpa_engine_num--;\n+\n+\treturn eid;\n+}\n+\n+int rte_vdpa_find_engine_id(struct rte_vdpa_eng_addr *addr)\n+{\n+\tstruct rte_vdpa_engine *eng;\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_VDPA_ENGINE_NUM; ++i) {\n+\t\teng = vdpa_engines[i];\n+\t\tif (eng && is_same_eng(eng->eng_info.addr, addr) == 0)\n+\t\t\treturn i;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+int rte_vdpa_info_query(int eid, struct rte_vdpa_eng_attr *attr)\n+{\n+\tif (eid < 0 || eid >= MAX_VDPA_ENGINE_NUM ||\n+\t\t\tvdpa_engines[eid] == NULL ||\n+\t\t\tvdpa_engines[eid]->eng_drv->eng_ops.info_query == NULL)\n+\t\treturn -1;\n+\n+\treturn vdpa_engines[eid]->eng_drv->eng_ops.info_query(eid, attr);\n+}\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "2/6"
    ]
}