From: zhiyong.yang@intel.com
To: dev@dpdk.org
Cc: tiwei.bie@intel.com, ferruh.yigit@intel.com,
maxime.coquelin@redhat.com, stable@dpdk.org,
Zhiyong Yang <zhiyong.yang@intel.com>
Subject: [dpdk-stable] [PATCH v3] net/virtio-user: fix multiple queues fail in server mode
Date: Fri, 11 May 2018 10:12:47 +0800 [thread overview]
Message-ID: <20180511021247.12411-1-zhiyong.yang@intel.com> (raw)
In-Reply-To: <20180510093623.82588-1-zhiyong.yang@intel.com>
This patch fixes multiple queues failure when virtio-user works in
server mode.
This patch adds feature negotiation in the processing of virtio-user
connection and enables multiple-queue pairs.
Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
Cc: stable@dpdk.org
Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---
Changes in V3:
1. virtio_user_handle_mq is redefined as extern instead of static.
2. add to call virtio_user_handle_mq in virtio_user_server_reconnect.
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 | 18 ++++++++++------
drivers/net/virtio/virtio_user/virtio_user_dev.h | 1 +
drivers/net/virtio/virtio_user_ethdev.c | 27 ++++++++++++++++++++++++
4 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a6df97a00..93e4d9213 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
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 38b8bc90d..505f2ea5e 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -435,7 +435,7 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
unlink(dev->path);
}
-static uint8_t
+uint8_t
virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
{
uint16_t i;
@@ -447,11 +447,17 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
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;
return ret;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index ade727e46..784f4752e 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -48,4 +48,5 @@ int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
int cq, int queue_size, const char *mac, char **ifname);
void virtio_user_dev_uninit(struct virtio_user_dev *dev);
void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
+uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);
#endif
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 4e7b3c34f..e53d8f996 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -30,6 +30,7 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
int ret;
int flag;
int connectfd;
+ uint64_t features = dev->device_features;
struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
connectfd = accept(dev->listenfd, NULL, NULL);
@@ -37,6 +38,25 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
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;
+ }
+
+ features &= ~dev->device_features;
+ /* For following bits, vhost-user doesn't really need to know */
+ features &= ~(1ull << VIRTIO_NET_F_MAC);
+ features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
+ features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
+ features &= ~(1ull << VIRTIO_NET_F_STATUS);
+ if (features)
+ PMD_INIT_LOG(ERR, "WARNING: Some features 0x%" PRIx64 "are not supported by vhost-user!",
+ features);
+
+ dev->features &= dev->device_features;
+
flag = fcntl(connectfd, F_GETFD);
fcntl(connectfd, F_SETFL, flag | O_NONBLOCK);
@@ -44,6 +64,13 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
if (ret < 0)
return -1;
+ if (dev->queue_pairs > 1) {
+ ret = virtio_user_handle_mq(dev, dev->queue_pairs);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Fails to enable multi-queue pairs!");
+ return -1;
+ }
+ }
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
if (rte_intr_disable(eth_dev->intr_handle) < 0) {
PMD_DRV_LOG(ERR, "interrupt disable failed");
--
2.14.3
next prev parent reply other threads:[~2018-05-11 2:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 9:49 [dpdk-stable] [PATCH] " zhiyong.yang
2018-05-09 14:48 ` Ferruh Yigit
2018-05-10 0:48 ` Tiwei Bie
2018-05-10 1:28 ` Yang, Zhiyong
2018-05-10 1:38 ` Yang, Zhiyong
2018-05-10 2:47 ` [dpdk-stable] [dpdk-dev] " Tiwei Bie
2018-05-10 3:04 ` Yang, Zhiyong
2018-05-10 4:42 ` Tiwei Bie
2018-05-10 9:36 ` [dpdk-stable] [PATCH v2] " zhiyong.yang
2018-05-10 10:23 ` Tiwei Bie
2018-05-10 14:01 ` Yang, Zhiyong
2018-05-10 14:19 ` Tiwei Bie
2018-05-11 2:12 ` zhiyong.yang [this message]
2018-05-11 2:49 ` [dpdk-stable] [PATCH v3] " Tiwei Bie
2018-05-11 3:01 ` Yang, Zhiyong
2018-05-11 3:31 ` [dpdk-stable] [PATCH v4] " zhiyong.yang
2018-05-11 11:33 ` Ferruh Yigit
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=20180511021247.12411-1-zhiyong.yang@intel.com \
--to=zhiyong.yang@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--cc=tiwei.bie@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).