All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] virtio: Introduce vringh wrappers in virtio_config
@ 2013-03-08 10:08 sjur.brandeland
  2013-03-13 10:12 ` Sjur Brændeland
  0 siblings, 1 reply; 5+ messages in thread
From: sjur.brandeland @ 2013-03-08 10:08 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Rusty Russell
  Cc: sjur, Linus Walleij, Sjur Brændeland, Erwan Yvin, virtualization

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

Add wrappers for the host vrings to support loose
coupling between the virtio device and driver.

A new struct vringh_config_ops with the functions
find_vrhs() and del_vrhs() is added to the virtio_device
struct. This enables virtio drivers to manage virtio
host rings without detailed knowledge of how the
vrings are created and deleted.

The function vringh_notify() is added so vringh clients
can notify the other side that buffers are added to the
used-ring.

Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
---
Hi Rusty,

>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.

Weird or not, CAIF-virtio is design to use guest rings for TX traffic,
and host rings for RX traffic. The motivation for this design is to allow
zero-copy in the data-path on the remote-device/modem.

Changes since v1:
- Moved find_vrhs() and del_vrhs() to a separate struct vringh_config_ops.
- Moved definition of struct vringh_config_ops into vringh.h
- Added vringh_config field to struct virtio_device
- Removed priv pointer field from struct vringh

There are a number of different ways to do this, let me know if you
want this changed in any way.

Thanks,
Sjur


 include/linux/virtio.h |    3 +++
 include/linux/vringh.h |   29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 00ccc40..5b71fc1 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -8,6 +8,7 @@
 #include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/gfp.h>
+#include <linux/vringh.h>
 
 /**
  * virtqueue - a queue to register buffers for sending or receiving.
@@ -70,6 +71,7 @@ static inline unsigned int virtqueue_get_queue_index(struct virtqueue *vq)
  * @dev: underlying device.
  * @id: the device type identification (used to match it with a driver).
  * @config: the configuration ops for this device.
+ * @vringh_config: configuration ops for host vrings.
  * @vqs: the list of virtqueues for this device.
  * @features: the features supported by both driver and device.
  * @priv: private pointer for the driver's use.
@@ -79,6 +81,7 @@ struct virtio_device {
 	struct device dev;
 	struct virtio_device_id id;
 	struct virtio_config_ops *config;
+	struct vringh_config_ops *vringh_config;
 	struct list_head vqs;
 	/* Note that this is a Linux set_bit-style bitmap. */
 	unsigned long features[1];
diff --git a/include/linux/vringh.h b/include/linux/vringh.h
index ab41185..c7d9289 100644
--- a/include/linux/vringh.h
+++ b/include/linux/vringh.h
@@ -50,6 +50,28 @@ struct vringh {
 
 	/* The vring (note: it may contain user pointers!) */
 	struct vring vring;
+
+	/* The function to call to notify the guest about added buffers */
+	void (*notify)(struct vringh *);
+};
+
+/**
+ * struct vringh_config_ops - ops for creating a host vring from a virtio driver
+ * @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 virtio_device;
+typedef void vrh_callback_t(struct virtio_device *, struct vringh *);
+struct vringh_config_ops {
+	int (*find_vrhs)(struct virtio_device *vdev, unsigned nhvrs,
+			 struct vringh *vrhs[], vrh_callback_t *callbacks[]);
+	void (*del_vrhs)(struct virtio_device *vdev);
 };
 
 /* The memory the vring can access, and what offset to apply. */
@@ -182,4 +204,11 @@ void vringh_notify_disable_kern(struct vringh *vrh);
 
 int vringh_need_notify_kern(struct vringh *vrh);
 
+/* Notify the guest about buffers added to the used ring */
+static inline void vringh_notify(struct vringh *vrh)
+{
+	if (vrh->notify)
+		vrh->notify(vrh);
+}
+
 #endif /* _LINUX_VRINGH_H */
-- 
1.7.5.4

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCHv2] virtio: Introduce vringh wrappers in virtio_config
  2013-03-08 10:08 [PATCHv2] virtio: Introduce vringh wrappers in virtio_config sjur.brandeland
@ 2013-03-13 10:12 ` Sjur Brændeland
  2013-03-17 23:29   ` Ohad Ben-Cohen
  0 siblings, 1 reply; 5+ messages in thread
From: Sjur Brændeland @ 2013-03-13 10:12 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Rusty Russell
  Cc: sjur, Linus Walleij, Sjur Brændeland, Erwan Yvin, virtualization

Hi Ohad,

On Fri, Mar 8, 2013 at 11:08 AM,  <sjur.brandeland@stericsson.com> wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> Add wrappers for the host vrings to support loose
> coupling between the virtio device and driver.
>
> A new struct vringh_config_ops with the functions
> find_vrhs() and del_vrhs() is added to the virtio_device
> struct. This enables virtio drivers to manage virtio
> host rings without detailed knowledge of how the
> vrings are created and deleted.
>
> The function vringh_notify() is added so vringh clients
> can notify the other side that buffers are added to the
> used-ring.
>
> Cc: Ohad Ben-Cohen <ohad@wizery.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

As you have been pushing for this wrapper, could you please
add your Ack or Reviewed tag if you are happy with this patch?

Thanks,
Sjur
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCHv2] virtio: Introduce vringh wrappers in virtio_config
  2013-03-13 10:12 ` Sjur Brændeland
@ 2013-03-17 23:29   ` Ohad Ben-Cohen
  2013-03-18  0:07     ` Sjur Brændeland
  0 siblings, 1 reply; 5+ messages in thread
From: Ohad Ben-Cohen @ 2013-03-17 23:29 UTC (permalink / raw)
  To: Sjur Brændeland
  Cc: Sjur Brændeland, Linus Walleij, Erwan Yvin, virtualization,
	Sjur Brændeland

Hi Sjur,

Sorry for the delay - just got back from you know where :)

On Wed, Mar 13, 2013 at 12:12 PM, Sjur Brændeland <sjurbren@gmail.com> wrote:
>> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>>
>> Add wrappers for the host vrings to support loose
>> coupling between the virtio device and driver.
>>
>> A new struct vringh_config_ops with the functions
>> find_vrhs() and del_vrhs() is added to the virtio_device
>> struct. This enables virtio drivers to manage virtio
>> host rings without detailed knowledge of how the
>> vrings are created and deleted.
>>
>> The function vringh_notify() is added so vringh clients
>> can notify the other side that buffers are added to the
>> used-ring.
>>
>> Cc: Ohad Ben-Cohen <ohad@wizery.com>
>> Cc: Rusty Russell <rusty@rustcorp.com.au>
>> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> As you have been pushing for this wrapper, could you please
> add your Ack or Reviewed tag if you are happy with this patch?

I am happy with this patch: the caif virtio driver is now decoupled
from remoteproc which I think is great. Thanks for doing it!

To provide a Reviewed-by tag though I need to review it from a virtio
point of view, which I can try to do after I'll finish going through
my backlog of pending patches. Let me finish that pile of patches I
have, and if you or Rusty will still want me to provide a Reviewed-by
tag here I'll do it.

Thanks,
Ohad.

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

* Re: [PATCHv2] virtio: Introduce vringh wrappers in virtio_config
  2013-03-17 23:29   ` Ohad Ben-Cohen
@ 2013-03-18  0:07     ` Sjur Brændeland
  2013-03-18  8:52       ` Rusty Russell
  0 siblings, 1 reply; 5+ messages in thread
From: Sjur Brændeland @ 2013-03-18  0:07 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Linus Walleij, Erwan Yvin, virtualization

On Mon, Mar 18, 2013 at 12:29 AM, Ohad Ben-Cohen <ohad@wizery.com> wrote:
> Hi Sjur,
>
> Sorry for the delay - just got back from you know where :)
>
> On Wed, Mar 13, 2013 at 12:12 PM, Sjur Brændeland <sjurbren@gmail.com> wrote:
>>> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>>>
>>> Add wrappers for the host vrings to support loose
>>> coupling between the virtio device and driver.
>>>
>>> A new struct vringh_config_ops with the functions
>>> find_vrhs() and del_vrhs() is added to the virtio_device
>>> struct. This enables virtio drivers to manage virtio
>>> host rings without detailed knowledge of how the
>>> vrings are created and deleted.
>>>
>>> The function vringh_notify() is added so vringh clients
>>> can notify the other side that buffers are added to the
>>> used-ring.
>>>
>>> Cc: Ohad Ben-Cohen <ohad@wizery.com>
>>> Cc: Rusty Russell <rusty@rustcorp.com.au>
>>> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
>>
>> As you have been pushing for this wrapper, could you please
>> add your Ack or Reviewed tag if you are happy with this patch?
>
> I am happy with this patch: the caif virtio driver is now decoupled
> from remoteproc which I think is great. Thanks for doing it!
>
> To provide a Reviewed-by tag though I need to review it from a virtio
> point of view, which I can try to do after I'll finish going through
> my backlog of pending patches. Let me finish that pile of patches I
> have, and if you or Rusty will still want me to provide a Reviewed-by
> tag here I'll do it.

Hi Rusty,

Do you have what you need to apply this patch?
Please, let me know if any further changes are needed.
The informal ack above from Ohad is good enough for me :-)

Thanks,
Sjur
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCHv2] virtio: Introduce vringh wrappers in virtio_config
  2013-03-18  0:07     ` Sjur Brændeland
@ 2013-03-18  8:52       ` Rusty Russell
  0 siblings, 0 replies; 5+ messages in thread
From: Rusty Russell @ 2013-03-18  8:52 UTC (permalink / raw)
  To: sjur; +Cc: Linus Walleij, mst, Erwan Yvin, virtualization

Sjur Brændeland <sjur@brendeland.net> writes:
> On Mon, Mar 18, 2013 at 12:29 AM, Ohad Ben-Cohen <ohad@wizery.com> wrote:
>> Hi Sjur,
>>
>> Sorry for the delay - just got back from you know where :)
>>
>> On Wed, Mar 13, 2013 at 12:12 PM, Sjur Brændeland <sjurbren@gmail.com> wrote:
>>>> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>>>>
>>>> Add wrappers for the host vrings to support loose
>>>> coupling between the virtio device and driver.
>>>>
>>>> A new struct vringh_config_ops with the functions
>>>> find_vrhs() and del_vrhs() is added to the virtio_device
>>>> struct. This enables virtio drivers to manage virtio
>>>> host rings without detailed knowledge of how the
>>>> vrings are created and deleted.
>>>>
>>>> The function vringh_notify() is added so vringh clients
>>>> can notify the other side that buffers are added to the
>>>> used-ring.
>>>>
>>>> Cc: Ohad Ben-Cohen <ohad@wizery.com>
>>>> Cc: Rusty Russell <rusty@rustcorp.com.au>
>>>> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
>>>
>>> As you have been pushing for this wrapper, could you please
>>> add your Ack or Reviewed tag if you are happy with this patch?
>>
>> I am happy with this patch: the caif virtio driver is now decoupled
>> from remoteproc which I think is great. Thanks for doing it!
>>
>> To provide a Reviewed-by tag though I need to review it from a virtio
>> point of view, which I can try to do after I'll finish going through
>> my backlog of pending patches. Let me finish that pile of patches I
>> have, and if you or Rusty will still want me to provide a Reviewed-by
>> tag here I'll do it.
>
> Hi Rusty,
>
> Do you have what you need to apply this patch?
> Please, let me know if any further changes are needed.
> The informal ack above from Ohad is good enough for me :-)

I'm pretty happy, thanks.

Because there's so much churn, I've refreshed my "vringh" branch with
this in it.

So can you please check that branch works for you?

Thanks,
Rusty.
PS. Michael, you can see what I'm hacking on with vhost/net there too,
    though it's unfinished...
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

end of thread, other threads:[~2013-03-18  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-08 10:08 [PATCHv2] virtio: Introduce vringh wrappers in virtio_config sjur.brandeland
2013-03-13 10:12 ` Sjur Brændeland
2013-03-17 23:29   ` Ohad Ben-Cohen
2013-03-18  0:07     ` Sjur Brændeland
2013-03-18  8:52       ` Rusty Russell

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.