Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/8870/?format=api
https://patches.dpdk.org/api/patches/8870/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1447301441-10590-2-git-send-email-yuanhan.liu@linux.intel.com/", "project": { "id": 1, "url": "https://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": "<1447301441-10590-2-git-send-email-yuanhan.liu@linux.intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1447301441-10590-2-git-send-email-yuanhan.liu@linux.intel.com", "date": "2015-11-12T04:10:41", "name": "[dpdk-dev] vhost: reset device properly", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "1091492d03742583bda80484bedeac34a559e387", "submitter": { "id": 307, "url": "https://patches.dpdk.org/api/people/307/?format=api", "name": "Yuanhan Liu", "email": "yuanhan.liu@linux.intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1447301441-10590-2-git-send-email-yuanhan.liu@linux.intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/8870/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/8870/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id C29848E9F;\n\tThu, 12 Nov 2015 05:06:43 +0100 (CET)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 5D6228D39\n\tfor <dev@dpdk.org>; Thu, 12 Nov 2015 05:06:41 +0100 (CET)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga102.jf.intel.com with ESMTP; 11 Nov 2015 20:06:40 -0800", "from yliu-dev.sh.intel.com ([10.239.66.49])\n\tby fmsmga002.fm.intel.com with ESMTP; 11 Nov 2015 20:06:39 -0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.20,280,1444719600\"; d=\"scan'208\";a=\"849088226\"", "From": "Yuanhan Liu <yuanhan.liu@linux.intel.com>", "To": "dev@dpdk.org", "Date": "Thu, 12 Nov 2015 12:10:41 +0800", "Message-Id": "<1447301441-10590-2-git-send-email-yuanhan.liu@linux.intel.com>", "X-Mailer": "git-send-email 1.9.0", "In-Reply-To": "<1447301441-10590-1-git-send-email-yuanhan.liu@linux.intel.com>", "References": "<1447301441-10590-1-git-send-email-yuanhan.liu@linux.intel.com>", "Subject": "[dpdk-dev] [PATCH] vhost: reset device properly", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://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": "<http://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": "Currently, we reset all fields of a device to zero when reset\nhappens, which is wrong, since for some fields like device_fh,\nifname, and virt_qp_nb, they should be same and be kept after\nreset until the device is removed. And this is what's the new\nhelper function reset_device() for.\n\nAnd use rte_zmalloc() instead of rte_malloc, so that we could\navoid init_device(), which basically dose zero reset only so far.\nHence, init_device() is dropped in this patch.\n\nThis patch also removes a hack of using the offset a specific\nfield (which is virtqueue now) inside of `virtio_net' structure\nto do reset, which could be broken easily if someone changed the\nfield order without caution.\n\nCc: Tetsuya Mukawa <mukawa@igel.co.jp>\nCc: Xie Huawei <huawei.xie@intel.com>\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\n\n---\n\nThis patch is based on:\n\nhttp://dpdk.org/dev/patchwork/patch/8818/\n---\n lib/librte_vhost/virtio-net.c | 27 ++++++++++-----------------\n 1 file changed, 10 insertions(+), 17 deletions(-)", "diff": "diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex 39a6a5e..cc917da 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -204,6 +204,7 @@ cleanup_device(struct virtio_net *dev)\n \t\tmunmap((void *)(uintptr_t)dev->mem->mapped_address,\n \t\t\t(size_t)dev->mem->mapped_size);\n \t\tfree(dev->mem);\n+\t\tdev->mem = NULL;\n \t}\n \n \tfor (i = 0; i < dev->virt_qp_nb; i++) {\n@@ -306,20 +307,18 @@ alloc_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)\n }\n \n /*\n- * Initialise all variables in device structure.\n+ * Reset some variables in device structure, while keeping few\n+ * others untouched, such as device_fh, ifname, virt_qp_nb: they\n+ * should be same unless the device is removed.\n */\n static void\n-init_device(struct virtio_net *dev)\n+reset_device(struct virtio_net *dev)\n {\n-\tint vq_offset;\n \tuint32_t i;\n \n-\t/*\n-\t * Virtqueues have already been malloced so\n-\t * we don't want to set them to NULL.\n-\t */\n-\tvq_offset = offsetof(struct virtio_net, virtqueue);\n-\tmemset(dev, 0, vq_offset);\n+\tdev->features = 0;\n+\tdev->protocol_features = 0;\n+\tdev->flags = 0;\n \n \tfor (i = 0; i < dev->virt_qp_nb; i++)\n \t\tinit_vring_queue_pair(dev, i);\n@@ -336,7 +335,7 @@ new_device(struct vhost_device_ctx ctx)\n \tstruct virtio_net_config_ll *new_ll_dev;\n \n \t/* Setup device and virtqueues. */\n-\tnew_ll_dev = rte_malloc(NULL, sizeof(struct virtio_net_config_ll), 0);\n+\tnew_ll_dev = rte_zmalloc(NULL, sizeof(struct virtio_net_config_ll), 0);\n \tif (new_ll_dev == NULL) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"(%\"PRIu64\") Failed to allocate memory for dev.\\n\",\n@@ -344,9 +343,6 @@ new_device(struct vhost_device_ctx ctx)\n \t\treturn -1;\n \t}\n \n-\t/* Initialise device and virtqueues. */\n-\tinit_device(&new_ll_dev->dev);\n-\n \tnew_ll_dev->next = NULL;\n \n \t/* Add entry to device configuration linked list. */\n@@ -430,7 +426,6 @@ static int\n reset_owner(struct vhost_device_ctx ctx)\n {\n \tstruct virtio_net *dev;\n-\tuint64_t device_fh;\n \n \tdev = get_device(ctx);\n \tif (dev == NULL)\n@@ -439,10 +434,8 @@ reset_owner(struct vhost_device_ctx ctx)\n \tif (dev->flags & VIRTIO_DEV_RUNNING)\n \t\tnotify_ops->destroy_device(dev);\n \n-\tdevice_fh = dev->device_fh;\n \tcleanup_device(dev);\n-\tinit_device(dev);\n-\tdev->device_fh = device_fh;\n+\treset_device(dev);\n \treturn 0;\n }\n \n", "prefixes": [ "dpdk-dev" ] }{ "id": 8870, "url": "