get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 34872,
    "url": "http://patches.dpdk.org/api/patches/34872/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1517614137-62926-2-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-2-git-send-email-zhihong.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1517614137-62926-2-git-send-email-zhihong.wang@intel.com",
    "date": "2018-02-02T23:28:51",
    "name": "[dpdk-dev,1/7] vhost: make capabilities configurable",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8e6620135785c792a3a8305cce3cefeeb5c932c0",
    "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-2-git-send-email-zhihong.wang@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/34872/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/34872/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 B46F6A496;\n\tFri,  2 Feb 2018 12:33:46 +0100 (CET)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id CE94F2BBD\n\tfor <dev@dpdk.org>; Fri,  2 Feb 2018 12:33:44 +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:43 -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:42 -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=\"171132726\"",
        "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:51 -0500",
        "Message-Id": "<1517614137-62926-2-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 1/7] vhost: make capabilities configurable",
        "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 makes vhost device capabilities configurable to adopt new\ndevices, since different devices may have different capabilities, like\ndifferent combinations of supported features, or different number of\nqueues. APIs are introduced to let app configure these capabilities.\n\nSigned-off-by: Zhihong Wang <zhihong.wang@intel.com>\n---\n lib/librte_vhost/rte_vhost.h  | 50 ++++++++++++++++++++++++++++\n lib/librte_vhost/socket.c     | 77 +++++++++++++++++++++++++++++++++++++++++++\n lib/librte_vhost/vhost_user.c | 48 ++++++++++++++++++++-------\n 3 files changed, 164 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h\nindex d332069..12cf48f 100644\n--- a/lib/librte_vhost/rte_vhost.h\n+++ b/lib/librte_vhost/rte_vhost.h\n@@ -182,6 +182,56 @@ int rte_vhost_driver_unregister(const char *path);\n int rte_vhost_driver_set_features(const char *path, uint64_t features);\n \n /**\n+ * Get the protocol feature bits.\n+ *\n+ * @param path\n+ *  The vhost-user socket file path\n+ * @param protocol_features\n+ *  A pointer to store the queried protocol feature bits\n+ * @return\n+ *  0 on success, -1 on failure\n+ */\n+int rte_vhost_driver_get_protocol_features(const char *path,\n+\t\tuint64_t *protocol_features);\n+\n+/**\n+ * Set the protocol feature bits the vhost-user driver supports.\n+ *\n+ * @param path\n+ *  The vhost-user socket file path\n+ * @param protocol_features\n+ *  Supported protocol features\n+ * @return\n+ *  0 on success, -1 on failure\n+ */\n+int rte_vhost_driver_set_protocol_features(const char *path,\n+\t\tuint64_t protocol_features);\n+\n+/**\n+ * Get the queue number.\n+ *\n+ * @param path\n+ *  The vhost-user socket file path\n+ * @param queue_num\n+ *  A pointer to store the queried queue number\n+ * @return\n+ *  0 on success, -1 on failure\n+ */\n+int rte_vhost_driver_get_queue_num(const char *path, uint16_t *queue_num);\n+\n+/**\n+ * Set the queue number the vhost-user driver supports.\n+ *\n+ * @param path\n+ *  The vhost-user socket file path\n+ * @param queue_num\n+ *  Supported queue number\n+ * @return\n+ *  0 on success, -1 on failure\n+ */\n+int rte_vhost_driver_set_queue_num(const char *path, uint16_t queue_num);\n+\n+/**\n  * Enable vhost-user driver features.\n  *\n  * Note that\ndiff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c\nindex 6e3857e..e1d0036 100644\n--- a/lib/librte_vhost/socket.c\n+++ b/lib/librte_vhost/socket.c\n@@ -49,7 +49,10 @@ struct vhost_user_socket {\n \t * features negotiation.\n \t */\n \tuint64_t supported_features;\n+\tuint64_t supported_protocol_features;\n \tuint64_t features;\n+\tuint64_t protocol_features;\n+\tuint16_t queue_num;\n \n \tstruct vhost_device_ops const *notify_ops;\n };\n@@ -593,6 +596,75 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)\n \t}\n }\n \n+int rte_vhost_driver_set_protocol_features(const char *path,\n+\t\tuint64_t protocol_features)\n+{\n+\tstruct vhost_user_socket *vsocket;\n+\n+\tpthread_mutex_lock(&vhost_user.mutex);\n+\tvsocket = find_vhost_user_socket(path);\n+\tif (vsocket) {\n+\t\tvsocket->supported_protocol_features = protocol_features;\n+\t\tvsocket->protocol_features = protocol_features;\n+\t}\n+\tpthread_mutex_unlock(&vhost_user.mutex);\n+\n+\treturn vsocket ? 0 : -1;\n+}\n+\n+int\n+rte_vhost_driver_get_protocol_features(const char *path,\n+\t\tuint64_t *protocol_features)\n+{\n+\tstruct vhost_user_socket *vsocket;\n+\n+\tpthread_mutex_lock(&vhost_user.mutex);\n+\tvsocket = find_vhost_user_socket(path);\n+\tif (vsocket)\n+\t\t*protocol_features = vsocket->protocol_features;\n+\tpthread_mutex_unlock(&vhost_user.mutex);\n+\n+\tif (!vsocket) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"socket file %s is not registered yet.\\n\", path);\n+\t\treturn -1;\n+\t} else {\n+\t\treturn 0;\n+\t}\n+}\n+\n+int rte_vhost_driver_set_queue_num(const char *path, uint16_t queue_num)\n+{\n+\tstruct vhost_user_socket *vsocket;\n+\n+\tpthread_mutex_lock(&vhost_user.mutex);\n+\tvsocket = find_vhost_user_socket(path);\n+\tif (vsocket)\n+\t\tvsocket->queue_num = queue_num;\n+\tpthread_mutex_unlock(&vhost_user.mutex);\n+\n+\treturn vsocket ? 0 : -1;\n+}\n+\n+int rte_vhost_driver_get_queue_num(const char *path, uint16_t *queue_num)\n+{\n+\tstruct vhost_user_socket *vsocket;\n+\n+\tpthread_mutex_lock(&vhost_user.mutex);\n+\tvsocket = find_vhost_user_socket(path);\n+\tif (vsocket)\n+\t\t*queue_num = vsocket->queue_num;\n+\tpthread_mutex_unlock(&vhost_user.mutex);\n+\n+\tif (!vsocket) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"socket file %s is not registered yet.\\n\", path);\n+\t\treturn -1;\n+\t} else {\n+\t\treturn 0;\n+\t}\n+}\n+\n /*\n  * Register a new vhost-user socket; here we could act as server\n  * (the default case), or client (when RTE_VHOST_USER_CLIENT) flag\n@@ -655,6 +727,11 @@ rte_vhost_driver_register(const char *path, uint64_t flags)\n \t\tvsocket->features &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);\n \t}\n \n+\tvsocket->supported_protocol_features = VHOST_USER_PROTOCOL_FEATURES;\n+\tvsocket->protocol_features           = VHOST_USER_PROTOCOL_FEATURES;\n+\n+\tvsocket->queue_num = VHOST_MAX_QUEUE_PAIRS;\n+\n \tif ((flags & RTE_VHOST_USER_CLIENT) != 0) {\n \t\tvsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT);\n \t\tif (vsocket->reconnect && reconn_tid == 0) {\ndiff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex 1dd1a61..87ba267 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -127,6 +127,18 @@ vhost_user_reset_owner(struct virtio_net *dev)\n }\n \n /*\n+ * The supported queue num.\n+ */\n+static uint16_t\n+vhost_user_get_queue_num(struct virtio_net *dev)\n+{\n+\tuint16_t queue_num = 0;\n+\n+\trte_vhost_driver_get_queue_num(dev->ifname, &queue_num);\n+\treturn queue_num;\n+}\n+\n+/*\n  * The features that we support are requested.\n  */\n static uint64_t\n@@ -930,13 +942,17 @@ vhost_user_set_vring_enable(struct virtio_net *dev,\n \treturn 0;\n }\n \n-static void\n-vhost_user_get_protocol_features(struct virtio_net *dev,\n-\t\t\t\t struct VhostUserMsg *msg)\n+/*\n+ * The protocol features that we support are requested.\n+ */\n+\n+static uint64_t\n+vhost_user_get_protocol_features(struct virtio_net *dev)\n {\n-\tuint64_t features, protocol_features = VHOST_USER_PROTOCOL_FEATURES;\n+\tuint64_t features, protocol_features;\n \n \trte_vhost_driver_get_features(dev->ifname, &features);\n+\trte_vhost_driver_get_protocol_features(dev->ifname, &protocol_features);\n \n \t/*\n \t * REPLY_ACK protocol feature is only mandatory for now\n@@ -947,18 +963,27 @@ vhost_user_get_protocol_features(struct virtio_net *dev,\n \tif (!(features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))\n \t\tprotocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK);\n \n-\tmsg->payload.u64 = protocol_features;\n-\tmsg->size = sizeof(msg->payload.u64);\n+\treturn protocol_features;\n }\n \n-static void\n+static int\n vhost_user_set_protocol_features(struct virtio_net *dev,\n \t\t\t\t uint64_t protocol_features)\n {\n-\tif (protocol_features & ~VHOST_USER_PROTOCOL_FEATURES)\n-\t\treturn;\n+\tuint64_t vhost_protocol_features = 0;\n+\n+\trte_vhost_driver_get_protocol_features(dev->ifname,\n+\t\t\t&vhost_protocol_features);\n+\tif (protocol_features & ~vhost_protocol_features) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%d) received invalid negotiated protocol_features.\\n\",\n+\t\t\tdev->vid);\n+\t\treturn -1;\n+\t}\n \n \tdev->protocol_features = protocol_features;\n+\n+\treturn 0;\n }\n \n static int\n@@ -1391,7 +1416,8 @@ vhost_user_msg_handler(int vid, int fd)\n \t\tbreak;\n \n \tcase VHOST_USER_GET_PROTOCOL_FEATURES:\n-\t\tvhost_user_get_protocol_features(dev, &msg);\n+\t\tmsg.payload.u64 = vhost_user_get_protocol_features(dev);\n+\t\tmsg.size = sizeof(msg.payload.u64);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_PROTOCOL_FEATURES:\n@@ -1451,7 +1477,7 @@ vhost_user_msg_handler(int vid, int fd)\n \t\tbreak;\n \n \tcase VHOST_USER_GET_QUEUE_NUM:\n-\t\tmsg.payload.u64 = VHOST_MAX_QUEUE_PAIRS;\n+\t\tmsg.payload.u64 = vhost_user_get_queue_num(dev);\n \t\tmsg.size = sizeof(msg.payload.u64);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n",
    "prefixes": [
        "dpdk-dev",
        "1/7"
    ]
}