From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0E4DF1BA1C; Thu, 10 May 2018 11:36:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 May 2018 02:36:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,384,1520924400"; d="scan'208";a="44767519" Received: from dpdk9.bj.intel.com ([172.16.182.183]) by fmsmga002.fm.intel.com with ESMTP; 10 May 2018 02:36:21 -0700 From: zhiyong.yang@intel.com To: dev@dpdk.org, stable@dpdk.org Cc: tiwei.bie@intel.com, maxime.coquelin@redhat.com, ferruh.yigit@intel.com, Zhiyong Yang Date: Thu, 10 May 2018 17:36:23 +0800 Message-Id: <20180510093623.82588-1-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180509094936.62796-1-zhiyong.yang@intel.com> References: <20180509094936.62796-1-zhiyong.yang@intel.com> Subject: [dpdk-stable] [PATCH v2] net/virtio-user: fix multiple queues fail in server mode X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 09:36:27 -0000 This patch fixes multiple queues failure when virtio-user works in server mode. This patch adds feature negotiation in the processing of virtio-user reccnnection. Fixes: bd8f50a45d0f ("net/virtio-user: support server mode") Signed-off-by: Zhiyong Yang --- Changes in V2: 1. fix a comment typo. 2. add feature negotiation in the processing of reconnection. drivers/net/virtio/virtio_user/vhost_user.c | 3 +++ drivers/net/virtio/virtio_user/virtio_user_dev.c | 14 ++++++++++---- drivers/net/virtio/virtio_user_ethdev.c | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index a6df97a..93e4d92 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -263,6 +263,9 @@ struct hugepage_file_info { PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]); + if (dev->is_server && vhostfd < 0) + return -1; + msg.request = req; msg.flags = VHOST_USER_VERSION; msg.size = 0; diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 38b8bc9..b7e1915 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -447,10 +447,16 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) return -1; } - for (i = 0; i < q_pairs; ++i) - ret |= dev->ops->enable_qp(dev, i, 1); - for (i = q_pairs; i < dev->max_queue_pairs; ++i) - ret |= dev->ops->enable_qp(dev, i, 0); + /* Server mode can't enable queue pairs if vhostfd is invalid, + * always return 0 in this case. + */ + if (dev->vhostfd >= 0) { + for (i = 0; i < q_pairs; ++i) + ret |= dev->ops->enable_qp(dev, i, 1); + for (i = q_pairs; i < dev->max_queue_pairs; ++i) + ret |= dev->ops->enable_qp(dev, i, 0); + } else if (!dev->is_server) + ret = ~0; dev->queue_pairs = q_pairs; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 4e7b3c3..91a0c44 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -30,6 +30,7 @@ int ret; int flag; int connectfd; + uint64_t features = dev->device_features, status; struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id]; connectfd = accept(dev->listenfd, NULL, NULL); @@ -37,6 +38,25 @@ return -1; dev->vhostfd = connectfd; + if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES, + &dev->device_features) < 0) { + PMD_INIT_LOG(ERR, "get_features failed: %s", + strerror(errno)); + return -1; + } + + status = features & ~dev->device_features; + /* For following bits, vhost-user doesn't really need to know */ + status &= ~(1ull << VIRTIO_NET_F_MAC); + status &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN); + status &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR); + status &= ~(1ull << VIRTIO_NET_F_STATUS); + if (status) + PMD_INIT_LOG(ERR, "WARNING: Some features (0x%lx) are not supported by vhost-user!", + status); + + dev->features &= dev->device_features; + flag = fcntl(connectfd, F_GETFD); fcntl(connectfd, F_SETFL, flag | O_NONBLOCK); -- 1.8.3.1