From: Rusty Russell <rusty@rustcorp.com.au>
To: Ohad Ben-Cohen <ohad@wizery.com>
Cc: sjur@brendeland.net, "Linus Walleij" <linus.walleij@linaro.org>,
"Sjur Brændeland" <sjur.brandeland@stericsson.com>,
"Erwan Yvin" <erwan.yvin@stericsson.com>,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH vringh] virtio: Introduce vringh wrappers in virtio_config
Date: Wed, 06 Mar 2013 15:42:52 +1100 [thread overview]
Message-ID: <876215cf5f.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1362491468-16681-1-git-send-email-sjur.brandeland@stericsson.com>
sjur.brandeland@stericsson.com writes:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> Add wrappers for the host vrings to support loose
> coupling between the virtio device and driver.
>
> The functions find_vrhs() and del_vrhs() are added to
> struct virtio_config_ops to manage the host vrings.
> The function vringh_notify() is added so the guest
> can be kicked when buffers are added to the used-ring.
>
> This enables the virtio drivers to manage the virtio rings
> without knowledge of how the host vrings are managed.
Hmm, this is a bit weird.
> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
> index 29b9104..88dd5ae 100644
> --- a/include/linux/virtio_config.h
> +++ b/include/linux/virtio_config.h
> @@ -51,7 +51,17 @@
> * This returns a pointer to the bus name a la pci_name from which
> * the caller can then copy.
> * @set_vq_affinity: set the affinity for a virtqueue.
> + * @find_vrhs: find the host vrings and instantiate them
> + * vdev: the virtio_device
> + * nhvrs: the number of host vrings to find
> + * hvrs: on success, includes new host vrings
> + * callbacks: array of driver callbacks, for each host vring
> + * include a NULL entry for vqs that do not need a callback
> + * Returns 0 on success or error status
> + * @del_vrhs: free the host vrings found by find_vrhs().
> */
> +struct vringh;
> +typedef void vrh_callback_t(struct virtio_device *, struct vringh *);
> typedef void vq_callback_t(struct virtqueue *);
> struct virtio_config_ops {
> void (*get)(struct virtio_device *vdev, unsigned offset,
> @@ -70,6 +80,9 @@ struct virtio_config_ops {
> void (*finalize_features)(struct virtio_device *vdev);
> const char *(*bus_name)(struct virtio_device *vdev);
> int (*set_vq_affinity)(struct virtqueue *vq, int cpu);
> + int (*find_vrhs)(struct virtio_device *vdev, unsigned nhvrs,
> + struct vringh *vrhs[], vrh_callback_t *callbacks[]);
> + void (*del_vrhs)(struct virtio_device *vdev);
> };
>
> /* If driver didn't advertise the feature, it will never appear. */
It's weird that you conflate the host and guest ring sides in rpmsg, but
that might make sense if they're really bound together. However, in
general they are not: it's normal to be a guest or host, not both.
This implies that you need a struct vringh_config, to put this in.
> diff --git a/include/linux/vringh.h b/include/linux/vringh.h
> index ab41185..8156f51 100644
> --- a/include/linux/vringh.h
> +++ b/include/linux/vringh.h
> @@ -50,6 +50,12 @@ struct vringh {
>
> /* The vring (note: it may contain user pointers!) */
> struct vring vring;
> +
> + /* The function to call when buffers are available */
> + void (*notify)(struct vringh *);
> +
> + /* A pointer for the vringh clients to use. */
> + void *priv;
> };
Since the caller allocates the vringh, can it not use container_of()
instead of a priv pointer?
Thanks,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2013-03-06 4:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-05 13:51 [PATCH vringh] virtio: Introduce vringh wrappers in virtio_config sjur.brandeland
2013-03-06 4:42 ` Rusty Russell [this message]
2013-03-06 10:50 ` Sjur Brændeland
2013-03-06 12:16 ` Ohad Ben-Cohen
2013-03-06 12:37 ` Sjur Brændeland
2013-03-06 23:28 ` Sjur Brændeland
2013-03-06 4:46 ` [FYI] vringh fixes Rusty Russell
2013-03-06 4:53 ` [PATCH 1/2] Rusty Russell
2013-03-06 4:54 ` [PATCH 2/2] tools/virtio: make barriers stronger Rusty Russell
2013-03-06 10:20 ` Michael S. Tsirkin
2013-03-07 3:48 ` Rusty Russell
2013-03-07 9:29 ` Michael S. Tsirkin
2013-03-07 23:56 ` Rusty Russell
2013-03-06 4:57 ` [PATCH 1/3] vringh: host-side implementation of virtio rings (v2) Rusty Russell
2013-03-06 4:59 ` [PATCH 2/3] vringh: don't flag already listening Rusty Russell
2013-03-06 5:02 ` [PATCH 3/3] tools/virtio: add vring_test (v2) Rusty Russell
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=876215cf5f.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=erwan.yvin@stericsson.com \
--cc=linus.walleij@linaro.org \
--cc=ohad@wizery.com \
--cc=sjur.brandeland@stericsson.com \
--cc=sjur@brendeland.net \
--cc=virtualization@lists.linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.