virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* Wrappers for vringh (was Re: [PATCHv2 vringh 1/3] remoteproc: Add support for vringh (Host vrings))
@ 2013-02-27 12:01 Sjur Brændeland
  2013-02-28  3:19 ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Sjur Brændeland @ 2013-02-27 12:01 UTC (permalink / raw)
  To: Rusty Russell, Ohad Ben-Cohen
  Cc: Linus Walleij, virtualization, Ido Yariv, Erwan Yvin,
	Dmitry Tarnyagin

On Fri, Feb 22, 2013 at 1:42 AM, Rusty Russell <rusty@rustcorp.com.au> wrote:
> Ohad Ben-Cohen <ohad@wizery.com> writes:
>> On Thu, Feb 21, 2013 at 8:37 AM, Rusty Russell <rusty@rustcorp.com.au> wrote:
>> What do you think about creating some virtio-level wrappers for the
>> vringh handlers?
>>
>> I don't think we're going to stop with caif as the only vringh user,
>> and it could be nice if we follow the virtio spirit of decoupling the
>> drivers from the low level implementation. It sure did prove itself
>> when the remoteproc use cases started showing up, and it's neat.
>
> The problem space is a bit different.  My immediate concern is getting
> vhost (and thus vhost_net/blk) to use vringh: I wanted to unify the
> in-userspace and in-kernelspace ring implementations.  We don't have
> that issue in virtqueue.c.
>
> vhost is (will be) the higher abstraction for in-userspace rings,
> perhaps we want an equivalent for in-kernelspace rings.  I'm happy to
> look at patches, but I don't immediately see what it would look like...

I'm not sure if the tight binding between vringh and remoteproc is
a big problem. I think the most obvious use-case for kernel vringh is
when they are instantiated from remoteproc.

But if we where to make wrappers, how about something like this?

diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 29b9104..ca257d8 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -53,0 +54,8 @@
+ * @find_vrh: 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_vrh: free the host vrings found by find_vrh().
@@ -55,0 +64 @@ typedef void vq_callback_t(struct virtqueue *);
+typedef void vrh_callback_t(struct virtio_device *, struct vringh *);
@@ -72,0 +82,4 @@ struct virtio_config_ops {
+       int (*find_vrh) (struct virtio_device *, unsigned nhvrs,
+                        struct vringh *vrhs[],
+                        vrh_callback_t *callbacks[]);
+       int (*del_vrhs)(struct virtio_device *);
diff --git a/include/linux/vringh.h b/include/linux/vringh.h
index 4c4c918..78aecc9 100644
--- a/include/linux/vringh.h
+++ b/include/linux/vringh.h
@@ -52,0 +53,3 @@ struct vringh {
+
+       /* The function to call when buffers are available */
+       void (*notify)(struct vringh *);


diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index d4f339c..e657277 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -433,0 +434,2 @@ static int cfv_probe(struct virtio_device *vdev)
+       struct vringh *vrhs;
+       vrh_callback_t *vrh_cbs = cfv_recv;
@@ -446,2 +448,2 @@ static int cfv_probe(struct virtio_device *vdev)
-       cfv->vr_rx = rproc_virtio_new_vringh(vdev, RX_RING_INDEX, cfv_recv);
-       if (!cfv->vr_rx)
+       err = vdev->config->find_vrh(vdev, 1, &cfv->vr_rx, &vrh_cbs);
+       if (err)
@@ -504 +506 @@ static int cfv_probe(struct virtio_device *vdev)
-       rproc_virtio_kick_vringh(vdev, RX_RING_INDEX);
+       cfv->vr_rx->notify(cfv->vr_rx);
@@ -522 +524 @@ static void cfv_remove(struct virtio_device *vdev)
-       rproc_virtio_del_vringh(vdev, RX_RING_INDEX);
+       vdev->config->del_vrhs(cfv->vdev);

Thanks,
Sjur

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-03  5:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-27 12:01 Wrappers for vringh (was Re: [PATCHv2 vringh 1/3] remoteproc: Add support for vringh (Host vrings)) Sjur Brændeland
2013-02-28  3:19 ` Rusty Russell
2013-03-03  5:54   ` Ohad Ben-Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).