get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 34874,
    "url": "http://patches.dpdk.org/api/patches/34874/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1517614137-62926-4-git-send-email-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": "<1517614137-62926-4-git-send-email-zhihong.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1517614137-62926-4-git-send-email-zhihong.wang@intel.com",
    "date": "2018-02-02T23:28:53",
    "name": "[dpdk-dev,3/7] vhost: support selective datapath",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "4fb881b2dcac1db3e4c1ed418512e8386adfbcb1",
    "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/1517614137-62926-4-git-send-email-zhihong.wang@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/34874/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/34874/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 4B72C1B026;\n\tFri,  2 Feb 2018 12:33:50 +0100 (CET)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id ED8177CD8\n\tfor <dev@dpdk.org>; Fri,  2 Feb 2018 12:33:47 +0100 (CET)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t02 Feb 2018 03:33:47 -0800",
            "from unknown (HELO dpdk98.sh.intel.com) ([10.67.111.140])\n\tby orsmga004.jf.intel.com with ESMTP; 02 Feb 2018 03:33:45 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.46,448,1511856000\"; d=\"scan'208\";a=\"171132737\"",
        "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": "Fri,  2 Feb 2018 18:28:53 -0500",
        "Message-Id": "<1517614137-62926-4-git-send-email-zhihong.wang@intel.com>",
        "X-Mailer": "git-send-email 2.7.5",
        "In-Reply-To": "<1517614137-62926-1-git-send-email-zhihong.wang@intel.com>",
        "References": "<1517614137-62926-1-git-send-email-zhihong.wang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 3/7] 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\nSigned-off-by: Zhihong Wang <zhihong.wang@intel.com>\n---\n lib/librte_vhost/Makefile   |   4 +-\n lib/librte_vhost/rte_vdpa.h | 113 +++++++++++++++++++++++++++++++++++++++\n lib/librte_vhost/vdpa.c     | 125 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 240 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 5d6c6ab..37044ac 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 0000000..729849b\n--- /dev/null\n+++ b/lib/librte_vhost/rte_vdpa.h\n@@ -0,0 +1,113 @@\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_memory.h>\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+\n+struct rte_vdpa_eng_addr {\n+\tunion {\n+\t\tuint8_t __dummy[64];\n+\n+\t\tstruct {\n+\t\t\tstruct rte_pci_addr pci_addr;\n+\t\t};\n+\t};\n+};\n+\n+struct rte_vdpa_eng_info {\n+\tchar name[MAX_VDPA_NAME_LEN];\n+\tstruct rte_vdpa_eng_addr *addr;\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+/* 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+};\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+\tconst char *name;\n+\tstruct rte_vdpa_eng_ops eng_ops;\n+\tstruct rte_vdpa_dev_ops dev_ops;\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 0000000..1fc2d0b\n--- /dev/null\n+++ b/lib/librte_vhost/vdpa.c\n@@ -0,0 +1,125 @@\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 <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\t|| a->pci_addr.bus != b->pci_addr.bus\n+\t\t\t|| a->pci_addr.devid != b->pci_addr.devid\n+\t\t\t|| a->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 || vdpa_engines[eid]\n+\t\t\t== NULL)\n+\t\treturn -1;\n+\n+\tif (vdpa_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+}\n",
    "prefixes": [
        "dpdk-dev",
        "3/7"
    ]
}