From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by dpdk.org (Postfix) with ESMTP id 891288E6C for ; Tue, 24 Nov 2015 07:45:47 +0100 (CET) Received: by pacej9 with SMTP id ej9so12090232pac.2 for ; Mon, 23 Nov 2015 22:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ru373oOWpQV5KIxU2aK2LkcA9NzmNC5pVr6tOu4Vtr4=; b=c/Bg9q5GrzOXrQFK8SmcxWZ/fRrOrjLbG7Cj+IRLbN6dm95xgq/Q8hdFd+KHqlpJdJ ZKn52kxR8izauqeOq4SekmA6LBNfm+GDavYVllM7FVLi+yq7twHTtrEVKDURTDVgbcGI qKAVMFGLCuGrdpufxtUSoOfXfL1uRPZTDXf8hUMdI+PYh/yZZwUNBiG3y6CPWAd5IpHg UEWKHV/ps0mm1OVFiSCPoF+0kTTYwDLqLSFuwmUCPaC691FWXTeT773DFg5cSgM/B0Rk jYPYLzVPj4tAu48WA+ch+gBSMMEkTJXRohezBjHBU9Jp3tYaY5xWB7kjNJzZ1QzHHPY6 lxgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ru373oOWpQV5KIxU2aK2LkcA9NzmNC5pVr6tOu4Vtr4=; b=hPrjCEadmVmc7yAaTfLds4/6qHf7UvXWcekPLSrvsymy4Tl3IgZxDbkPlnRlDJ1l/a UbhN2CPwQeEnDa+0Y/xpI0gaoDBd+VC9tgwxm4J9RCvAVFmKE8VLKsC7tOPpGZTw1U9p 4JDEXyWlZ25XRNiSYaeZnPRKB6u9dkPsopuj5HAUa6Oeza4JQK2baVrook/E0E5abIae 2/tzpJ9IIO1uU2DDzKHBJC+3tKoAQQYJQvRVLi1Rdso032dVH5YBOQLOKjFSRBYYrAf9 lbdey5jsPlyeRH7iWfQj31u8ptUYJONb2z12kFlJIaAOwqXaVTrQaO4WiU1GrLCRRO25 hOYg== X-Gm-Message-State: ALoCoQlN+fYiEqaks/B9Zg0zFp8ciHZ6O6zUk5NiExGHf6NLGlUNdKVpO1IgJ5pssuZT2HXvzhdZ X-Received: by 10.98.18.130 with SMTP id 2mr20584894pfs.114.1448347546883; Mon, 23 Nov 2015 22:45:46 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id h19sm12389613pfd.79.2015.11.23.22.45.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 22:45:46 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org, yuanhan.liu@linux.intel.com Date: Tue, 24 Nov 2015 15:45:35 +0900 Message-Id: <1448347535-8953-1-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447924020-26894-1-git-send-email-mukawa@igel.co.jp> References: <1447924020-26894-1-git-send-email-mukawa@igel.co.jp> Cc: ann.zhuangyanying@huawei.com Subject: [dpdk-dev] [PATCH v3] vhost: Fix reset_owner message handling not to clear callfd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2015 06:45:47 -0000 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 --- 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