[dpdk-dev] [PATCH 28/40] net/virtio: add Virtio-user vring setting ops
Xia, Chenbo
chenbo.xia at intel.com
Wed Jan 6 13:01:20 CET 2021
Hi Maxime,
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin at redhat.com>
> Sent: Monday, December 21, 2020 5:14 AM
> To: dev at dpdk.org; Xia, Chenbo <chenbo.xia at intel.com>; olivier.matz at 6wind.com;
> amorenoz at redhat.com; david.marchand at redhat.com
> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>
> 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 <maxime.coquelin at redhat.com>
> ---
> 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;
> + }
> +
More information about the dev
mailing list