From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org, yuanhan.liu@linux.intel.com
Cc: ann.zhuangyanying@huawei.com
Subject: [dpdk-dev] [PATCH v3] vhost: Fix reset_owner message handling not to clear callfd
Date: Tue, 24 Nov 2015 15:45:35 +0900 [thread overview]
Message-ID: <1448347535-8953-1-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1447924020-26894-1-git-send-email-mukawa@igel.co.jp>
The patch fixes reset_owner message handling not to clear callfd,
because callfd will be valid while connection is establihed.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_vhost/virtio-net.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 886c104..dc977b7 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -223,9 +223,9 @@ add_config_ll_entry(struct virtio_net_config_ll *new_ll_dev)
}
static void
-cleanup_vq(struct vhost_virtqueue *vq)
+cleanup_vq(struct vhost_virtqueue *vq, int destroy)
{
- if (vq->callfd >= 0)
+ if ((vq->callfd >= 0) && (destroy != 0))
close(vq->callfd);
if (vq->kickfd >= 0)
close(vq->kickfd);
@@ -236,7 +236,7 @@ cleanup_vq(struct vhost_virtqueue *vq)
* free any memory owned by a device.
*/
static void
-cleanup_device(struct virtio_net *dev)
+cleanup_device(struct virtio_net *dev, int destroy)
{
uint32_t i;
@@ -249,8 +249,8 @@ cleanup_device(struct virtio_net *dev)
}
for (i = 0; i < dev->virt_qp_nb; i++) {
- cleanup_vq(dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_RXQ]);
- cleanup_vq(dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_TXQ]);
+ cleanup_vq(dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_RXQ], destroy);
+ cleanup_vq(dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_TXQ], destroy);
}
}
@@ -278,17 +278,17 @@ rm_config_ll_entry(struct virtio_net_config_ll *ll_dev,
/* First remove the device and then clean it up. */
if (ll_dev == ll_root) {
ll_root = ll_dev->next;
- cleanup_device(&ll_dev->dev);
+ cleanup_device(&ll_dev->dev, 1);
free_device(ll_dev);
return ll_root;
} else {
if (likely(ll_dev_last != NULL)) {
ll_dev_last->next = ll_dev->next;
- cleanup_device(&ll_dev->dev);
+ cleanup_device(&ll_dev->dev, 1);
free_device(ll_dev);
return ll_dev_last->next;
} else {
- cleanup_device(&ll_dev->dev);
+ cleanup_device(&ll_dev->dev, 1);
free_device(ll_dev);
RTE_LOG(ERR, VHOST_CONFIG,
"Remove entry from config_ll failed\n");
@@ -322,6 +322,25 @@ init_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)
init_vring_queue(dev->virtqueue[base_idx + VIRTIO_TXQ], qp_idx);
}
+static void
+reset_vring_queue(struct vhost_virtqueue *vq, int qp_idx)
+{
+ int callfd;
+
+ callfd = vq->callfd;
+ init_vring_queue(vq, qp_idx);
+ vq->callfd = callfd;
+}
+
+static void
+reset_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)
+{
+ uint32_t base_idx = qp_idx * VIRTIO_QNUM;
+
+ reset_vring_queue(dev->virtqueue[base_idx + VIRTIO_RXQ], qp_idx);
+ reset_vring_queue(dev->virtqueue[base_idx + VIRTIO_TXQ], qp_idx);
+}
+
static int
alloc_vring_queue_pair(struct virtio_net *dev, uint32_t qp_idx)
{
@@ -362,7 +381,7 @@ reset_device(struct virtio_net *dev)
dev->flags = 0;
for (i = 0; i < dev->virt_qp_nb; i++)
- init_vring_queue_pair(dev, i);
+ reset_vring_queue_pair(dev, i);
}
/*
@@ -475,7 +494,7 @@ reset_owner(struct vhost_device_ctx ctx)
if (dev->flags & VIRTIO_DEV_RUNNING)
notify_destroy_device(dev);
- cleanup_device(dev);
+ cleanup_device(dev, 0);
reset_device(dev);
return 0;
}
--
2.1.4
next prev parent reply other threads:[~2015-11-24 6:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 6:23 [dpdk-dev] [PATCH] " Tetsuya Mukawa
2015-11-19 7:03 ` Yuanhan Liu
2015-11-19 7:12 ` Tetsuya Mukawa
2015-11-19 9:07 ` [dpdk-dev] [PATCH v2] " Tetsuya Mukawa
2015-11-20 11:21 ` Yuanhan Liu
2015-11-24 4:42 ` Tetsuya Mukawa
2015-11-24 6:45 ` Tetsuya Mukawa [this message]
2015-11-24 7:15 ` [dpdk-dev] [PATCH v3] " Yuanhan Liu
2015-11-24 19:04 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448347535-8953-1-git-send-email-mukawa@igel.co.jp \
--to=mukawa@igel.co.jp \
--cc=ann.zhuangyanying@huawei.com \
--cc=dev@dpdk.org \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).