Skip to contentSkip to conversation

Some fixes on virtio-user/vhost

PATCH In review Jianfeng Tan 3 participants 6 messages Feb 12, 2018 – Feb 13, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

cover Some fixes on virtio-user/vhost

Patch 1: a trivial fix on reword a log message. Patch 2: fix the rxq interrupt mode when virtio-user is used
with vhost kernel.
Patch 3: a trivial fix on LSC fd init when virtio-user is used
with vhost kernel.

Jianfeng Tan (3):
net/vhost: fix incorrect log info net/virtio-user: fix not working with vhost kernel net/virtio-user: fix not proper initialized

 drivers/net/vhost/rte_eth_vhost.c                | 4 ++--
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 net/vhost: fix incorrect log info

The original words are not accurate. For example, as destroy_device callback gets called, it does not necessarily mean that the connection is closed.

Fixes ee584e9710b9 ("vhost: add driver on top of the library")
---
 drivers/net/vhost/rte_eth_vhost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/vhost/rte_eth_vhost.c +2 -2
index 4e541e3..3aae01c 100644
@@ -607,7 +607,7 @@ new_device(int vid)
 	rte_atomic32_set(&internal->dev_attached, 1);
 	update_queuing_status(eth_dev);
 
-	RTE_LOG(INFO, PMD, "New connection established\n");
+	RTE_LOG(INFO, PMD, "Vhost device %d created\n", vid);
 
 	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 
@@ -661,7 +661,7 @@ destroy_device(int vid)
 	state->max_vring = 0;
 	rte_spinlock_unlock(&state->lock);
 
-	RTE_LOG(INFO, PMD, "Connection closed\n");
+	RTE_LOG(INFO, PMD, "Vhost device %d destroyed\n", vid);
 
 	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 net/virtio-user: fix not working with vhost kernel

In reply to Jianfeng Tan

After reset owner in below patch, we failed to set owner before sending further vhost messages. It is OK with vhost user implemented DPDK/VPP/Contrail, but it sees "Operation not permitted" error when used with vhost kernel.

We fix this by setting owner every time the device is started.

Fixes 0d6a8752ac9d ("net/virtio-user: fix crash as features change")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/virtio/virtio_user/virtio_user_dev.c +4 -0
index 3b5f737..b5809ee 100644
@@ -99,6 +99,9 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	uint64_t features;
 	int ret;
 
+	/* Do not check return as already done in init, or reset in stop */
+	dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL);
+
 	/* Step 0: tell vhost to create queues */
 	if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
 		goto error;
@@ -332,6 +335,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 		PMD_INIT_LOG(ERR, "backend set up fails");
 		return -1;
 	}
+
 	if (dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL) < 0) {
 		PMD_INIT_LOG(ERR, "set_owner fails: %s", strerror(errno));
 		return -1;
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/3 net/virtio-user: fix not proper initialized

In reply to Jianfeng Tan

intr_handle->fd was wrongly initialized as 0 (usually as the stdio fd) when virtio-user is used with vhost-kernel. So the interrupt thread might wrongly treat stdin events as LSC interrupts.

Fixes 3d4fb6fd2505 ("net/virtio-user: support Rx interrupt")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/virtio/virtio_user/virtio_user_dev.c +1 -0
index b5809ee..f90fee9 100644
@@ -251,6 +251,7 @@ virtio_user_fill_intr_handle(struct virtio_user_dev *dev)
 	eth_dev->intr_handle->type = RTE_INTR_HANDLE_VDEV;
 	/* For virtio vdev, no need to read counter for clean */
 	eth_dev->intr_handle->efd_counter_size = 0;
+	eth_dev->intr_handle->fd = -1;
 	if (dev->vhostfd >= 0)
 		eth_dev->intr_handle->fd = dev->vhostfd;
 
Signature · 1 line
2.7.4
Reviewed-by on the v1 series
#4 lore raw
In reply to Jianfeng Tan
Quoted 6 lines · Jianfeng Tan

Patch 1: a trivial fix on reword a log message. Patch 2: fix the rxq interrupt mode when virtio-user is used
with vhost kernel.
Patch 3: a trivial fix on LSC fd init when virtio-user is used
with vhost kernel.

Quoted 9 lines

Jianfeng Tan (3):
net/vhost: fix incorrect log info net/virtio-user: fix not working with vhost kernel net/virtio-user: fix not proper initialized

  drivers/net/vhost/rte_eth_vhost.c                | 4 ++--
  drivers/net/virtio/virtio_user/virtio_user_dev.c | 5 +++++
  2 files changed, 7 insertions(+), 2 deletions(-)

For the series:

Thomas, I would suggest to pick this series for v18.02, as patch 2 fixes a bug introduced in this release cycle.

Thanks,
Maxime

#5 lore raw

13/02/2018 14:32, Maxime Coquelin:

Quoted 13 lines · Jianfeng Tan
Quoted 10 lines

Patch 1: a trivial fix on reword a log message. Patch 2: fix the rxq interrupt mode when virtio-user is used
with vhost kernel.
Patch 3: a trivial fix on LSC fd init when virtio-user is used
with vhost kernel.

Jianfeng Tan (3):
net/vhost: fix incorrect log info net/virtio-user: fix not working with vhost kernel net/virtio-user: fix not proper initialized

Quoted 5 lines

For the series:

Thomas, I would suggest to pick this series for v18.02, as patch 2 fixes a bug introduced in this release cycle.

Applied with these reworded titles:

net/vhost: fix log messages on create/destroy
net/virtio-user: fix start with kernel vhost
net/virtio-user: fix interrupts with kernel vhost