Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/28054/?format=api
http://patches.dpdk.org/api/patches/28054/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20170829082601.30349-1-tiwei.bie@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": "<20170829082601.30349-1-tiwei.bie@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20170829082601.30349-1-tiwei.bie@intel.com", "date": "2017-08-29T08:26:01", "name": "[dpdk-dev] net/virtio: fix an incorrect behavior of device stop/start", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "a1024d1f0bc20456a413d13415ebd5ea32dd02ae", "submitter": { "id": 617, "url": "http://patches.dpdk.org/api/people/617/?format=api", "name": "Tiwei Bie", "email": "tiwei.bie@intel.com" }, "delegate": { "id": 355, "url": "http://patches.dpdk.org/api/users/355/?format=api", "username": "yliu", "first_name": "Yuanhan", "last_name": "Liu", "email": "yuanhan.liu@linux.intel.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20170829082601.30349-1-tiwei.bie@intel.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/28054/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/28054/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 5B1BE137C;\n\tTue, 29 Aug 2017 10:25:48 +0200 (CEST)", "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 2944111F5;\n\tTue, 29 Aug 2017 10:25:45 +0200 (CEST)", "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Aug 2017 01:25:44 -0700", "from debian-zgviawfucg.sh.intel.com ([10.67.104.214])\n\tby fmsmga004.fm.intel.com with ESMTP; 29 Aug 2017 01:25:43 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.41,444,1498546800\"; d=\"scan'208\";a=\"305574979\"", "From": "Tiwei Bie <tiwei.bie@intel.com>", "To": "dev@dpdk.org", "Cc": "yliu@fridaylinux.org,\n\tmaxime.coquelin@redhat.com,\n\tstable@dpdk.org", "Date": "Tue, 29 Aug 2017 16:26:01 +0800", "Message-Id": "<20170829082601.30349-1-tiwei.bie@intel.com>", "X-Mailer": "git-send-email 2.13.2", "Subject": "[dpdk-dev] [PATCH] net/virtio: fix an incorrect behavior of device\n\tstop/start", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <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": "After starting a device, the driver shouldn't deliver the\npackets that already existed in the device before it is\nstarted to the applications. This patch fixes this issue\nby flushing the Rx queues when starting the device.\n\nFixes: a85786dc816f (\"virtio: fix states handling during initialization\")\nCc: stable@dpdk.org\n\nSigned-off-by: Tiwei Bie <tiwei.bie@intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c | 6 ++++++\n drivers/net/virtio/virtio_rxtx.c | 2 +-\n drivers/net/virtio/virtqueue.c | 25 +++++++++++++++++++++++++\n drivers/net/virtio/virtqueue.h | 5 +++++\n 4 files changed, 37 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex e320811..6d60bc1 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -1737,6 +1737,12 @@ virtio_dev_start(struct rte_eth_dev *dev)\n \t\t}\n \t}\n \n+\t/* Flush the packets in Rx queues. */\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n+\t\trxvq = dev->data->rx_queues[i];\n+\t\tvirtqueue_flush(rxvq->vq);\n+\t}\n+\n \t/*Notify the backend\n \t *Otherwise the tap backend might already stop its queue due to fullness.\n \t *vhost backend will have no chance to be waked up\ndiff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c\nindex e30377c..5e5fcfc 100644\n--- a/drivers/net/virtio/virtio_rxtx.c\n+++ b/drivers/net/virtio/virtio_rxtx.c\n@@ -81,7 +81,7 @@ virtio_dev_rx_queue_done(void *rxq, uint16_t offset)\n \treturn VIRTQUEUE_NUSED(vq) >= offset;\n }\n \n-static void\n+void\n vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)\n {\n \tstruct vring_desc *dp, *dp_tail;\ndiff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c\nindex 9ad77b8..c3a536f 100644\n--- a/drivers/net/virtio/virtqueue.c\n+++ b/drivers/net/virtio/virtqueue.c\n@@ -59,3 +59,28 @@ virtqueue_detatch_unused(struct virtqueue *vq)\n \t\t}\n \treturn NULL;\n }\n+\n+/* Flush the elements in the used ring. */\n+void\n+virtqueue_flush(struct virtqueue *vq)\n+{\n+\tstruct vring_used_elem *uep;\n+\tstruct vq_desc_extra *dxp;\n+\tuint16_t used_idx, desc_idx;\n+\tuint16_t nb_used, i;\n+\n+\tnb_used = VIRTQUEUE_NUSED(vq);\n+\n+\tfor (i = 0; i < nb_used; i++) {\n+\t\tused_idx = vq->vq_used_cons_idx & (vq->vq_nentries - 1);\n+\t\tuep = &vq->vq_ring.used->ring[used_idx];\n+\t\tdesc_idx = (uint16_t)uep->id;\n+\t\tdxp = &vq->vq_descx[desc_idx];\n+\t\tif (dxp->cookie != NULL) {\n+\t\t\trte_pktmbuf_free(dxp->cookie);\n+\t\t\tdxp->cookie = NULL;\n+\t\t}\n+\t\tvq->vq_used_cons_idx++;\n+\t\tvq_ring_free_chain(vq, desc_idx);\n+\t}\n+}\ndiff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h\nindex 2e12086..9fffcd8 100644\n--- a/drivers/net/virtio/virtqueue.h\n+++ b/drivers/net/virtio/virtqueue.h\n@@ -304,6 +304,9 @@ void virtqueue_dump(struct virtqueue *vq);\n */\n struct rte_mbuf *virtqueue_detatch_unused(struct virtqueue *vq);\n \n+/* Flush the elements in the used ring. */\n+void virtqueue_flush(struct virtqueue *vq);\n+\n static inline int\n virtqueue_full(const struct virtqueue *vq)\n {\n@@ -312,6 +315,8 @@ virtqueue_full(const struct virtqueue *vq)\n \n #define VIRTQUEUE_NUSED(vq) ((uint16_t)((vq)->vq_ring.used->idx - (vq)->vq_used_cons_idx))\n \n+void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx);\n+\n static inline void\n vq_update_avail_idx(struct virtqueue *vq)\n {\n", "prefixes": [ "dpdk-dev" ] }{ "id": 28054, "url": "