On Wed, Sep 11, 2019 at 10:38:39AM +0800, Jason Wang wrote:
On 2019/9/10 äå9:52, Michael S. Tsirkin wrote:I just realized, all these registers are just encoded so you
On Tue, Sep 10, 2019 at 09:13:02PM +0800, Jason Wang wrote:
On 2019/9/10 äå6:01, Michael S. Tsirkin wrote:Should we just reuse VIRTIO_PCI_COMMON_Q_XXX then?
Ok.+#ifndef _LINUX_VIRTIO_MDEV_HPls add a bit more content here. It's redundant to state these
+#define _LINUX_VIRTIO_MDEV_H
+
+#include <linux/interrupt.h>
+#include <linux/vringh.h>
+#include <uapi/linux/virtio_net.h>
+
+/*
+ * Ioctls
+ */
are ioctls. Much better to document what does each one do.
I admit this is hacky (casting).+Function pointer in an ioctl parameter? How does this ever make sense?
+struct virtio_mdev_callback {
+ irqreturn_t (*callback)(void *);
+ void *private;
+};
+
+#define VIRTIO_MDEV 0xAF
+#define VIRTIO_MDEV_SET_VQ_CALLBACK _IOW(VIRTIO_MDEV, 0x00, \
+ struct virtio_mdev_callback)
+#define VIRTIO_MDEV_SET_CONFIG_CALLBACK _IOW(VIRTIO_MDEV, 0x01, \
+ struct virtio_mdev_callback)
And can't we use a couple of registers for this, and avoid ioctls?Yes, how about something like interrupt numbers for each virtqueue and
config?
You mean something like VIRTIO_PCI_COMMON_Q_MSIX? Then it becomes a PCI
transport in fact. And using either MSIX or irq number is actually another
layer of indirection. So I think we can just write callback function and
parameter through registers.
can pass stuff through read/write. But it can instead be
just a normal C function call with no messy encoding.
So why do we want to do this encoding?