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

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

From: Xia, Chenbo <hidden>
Date: 2021-01-06 12:02:09

Hi Maxime,
quoted hunk ↗ jump to hunk
-----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 28/40] net/virtio: add Virtio-user vring setting ops

This patch introduces new callbacks for setting
and getting vring state.

Signed-off-by: Maxime Coquelin <redacted>
---
 drivers/net/virtio/virtio_user/vhost.h        |   4 +
 drivers/net/virtio/virtio_user/vhost_kernel.c |  49 +++++++-
 drivers/net/virtio/virtio_user/vhost_user.c   | 114 +++++++++++++-----
 drivers/net/virtio/virtio_user/vhost_vdpa.c   |  40 ++++--
 .../net/virtio/virtio_user/virtio_user_dev.c  |   9 +-
 5 files changed, 168 insertions(+), 48 deletions(-)
diff --git a/drivers/net/virtio/virtio_user/vhost.h
b/drivers/net/virtio/virtio_user/vhost.h
index 0a582a6844..1385c1563b 100644
--- a/drivers/net/virtio/virtio_user/vhost.h
+++ b/drivers/net/virtio/virtio_user/vhost.h
@@ -107,6 +107,10 @@ struct virtio_user_backend_ops {
 	int (*get_protocol_features)(struct virtio_user_dev *dev, uint64_t
*features);
 	int (*set_protocol_features)(struct virtio_user_dev *dev, uint64_t
features);
 	int (*set_memory_table)(struct virtio_user_dev *dev);
+	int (*set_vring_enable)(struct virtio_user_dev *dev, struct
vhost_vring_state *state);
+	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 (*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 2d30f572b6..2f1b4840ee 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -219,12 +219,49 @@ vhost_kernel_set_memory_table(struct virtio_user_dev
*dev)
 	return -1;
 }

+static int
+vhost_kernel_set_vring(struct virtio_user_dev *dev, uint64_t req, struct
vhost_vring_state *state)
+{
+	int ret, fd;
+	uint32_t index = state->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_state.
+
+	/* Convert from queue index to queue-pair & offset */
+	fd = dev->vhostfds[state->index / 2];
+	state->index %= 2;
+
+	ret = vhost_kernel_ioctl(fd, req, state);
+	if (ret < 0) {
+		PMD_DRV_LOG(ERR, "Failed to set vring (request %lu)", req);
Seems David has also noticed here: better use PRIu64 here instead of %lu ?

Thanks,
Chenbo
+		return -1;
+	}
+
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help