Thread (149 messages) 149 messages, 6 authors, 2021-01-18

Re: [dpdk-dev] [PATCH 29/40] net/virtio: add Virtio-user vring file ops

From: Maxime Coquelin <hidden>
Date: 2021-01-15 10:17:27


On 1/6/21 1:04 PM, Xia, Chenbo wrote:
Hi Maxime,
quoted
-----Original Message-----
From: Maxime Coquelin <redacted>
Sent: Monday, December 21, 2020 5:14 AM
To: dev@dpdk.org; Xia, Chenbo <redacted>; olivier.matz@6wind.com;
amorenoz@redhat.com; david.marchand@redhat.com
Cc: Maxime Coquelin <redacted>
Subject: [PATCH 29/40] net/virtio: add Virtio-user vring file ops

This patch introduces new callbacks for setting
vring files (kick and call).

Signed-off-by: Maxime Coquelin <redacted>
---
 drivers/net/virtio/virtio_user/vhost.h        |  2 +
 drivers/net/virtio/virtio_user/vhost_kernel.c | 41 +++++++++++++++--
 drivers/net/virtio/virtio_user/vhost_user.c   | 46 +++++++++++++++++--
 drivers/net/virtio/virtio_user/vhost_vdpa.c   | 18 ++++++--
 .../net/virtio/virtio_user/virtio_user_dev.c  |  4 +-
 5 files changed, 97 insertions(+), 14 deletions(-)
diff --git a/drivers/net/virtio/virtio_user/vhost.h
b/drivers/net/virtio/virtio_user/vhost.h
index 1385c1563b..b296ee215d 100644
--- a/drivers/net/virtio/virtio_user/vhost.h
+++ b/drivers/net/virtio/virtio_user/vhost.h
@@ -111,6 +111,8 @@ struct virtio_user_backend_ops {
 	int (*set_vring_num)(struct virtio_user_dev *dev, struct
vhost_vring_state *state);
 	int (*set_vring_base)(struct virtio_user_dev *dev, struct
vhost_vring_state *state);
 	int (*get_vring_base)(struct virtio_user_dev *dev, struct
vhost_vring_state *state);
+	int (*set_vring_call)(struct virtio_user_dev *dev, struct
vhost_vring_file *file);
+	int (*set_vring_kick)(struct virtio_user_dev *dev, struct
vhost_vring_file *file);
 	int (*send_request)(struct virtio_user_dev *dev,
 			    enum vhost_user_request req,
 			    void *arg);
diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c
b/drivers/net/virtio/virtio_user/vhost_kernel.c
index 2f1b4840ee..1805aee7f7 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -259,11 +259,44 @@ vhost_kernel_get_vring_base(struct virtio_user_dev *dev,
struct vhost_vring_stat
 	return vhost_kernel_set_vring(dev, VHOST_GET_VRING_BASE, state);
 }

+static int
+vhost_kernel_set_vring_file(struct virtio_user_dev *dev, uint64_t req,
+		struct vhost_vring_file *file)
+{
+	int ret, fd;
+	uint32_t index = file->index;
Better use 'unsigned int index' here? It can hardly cause problem but I think it's
better to use the type in struct vhost_vring_file.
Fixed.
quoted
+
+	/* Convert from queue index to queue-pair & offset */
+	fd = dev->vhostfds[file->index / 2];
+	file->index %= 2;
+
+	ret = vhost_kernel_ioctl(fd, req, file);
+	if (ret < 0) {
+		PMD_DRV_LOG(ERR, "Failed to set vring file (request %lu)", req);
Seems David has also noticed: better use PRIu64 here instead of %lu ?
Yes.
Thanks,
Maxime
Thanks,
Chenbo
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help