From: Gregory Haskins <ghaskins@novell.com>
To: linux-kernel@vger.kernel.org
Cc: alacrityvm-devel@lists.sourceforge.net, netdev@vger.kernel.org
Subject: [PATCH 5/7] ioq: add driver-side vbus helpers
Date: Mon, 03 Aug 2009 13:17:56 -0400 [thread overview]
Message-ID: <20090803171756.17268.22133.stgit@dev.haskins.net> (raw)
In-Reply-To: <20090803171030.17268.26962.stgit@dev.haskins.net>
It will be a common pattern to map an IOQ over the VBUS shared-memory
interfaces. Therefore, we provide a helper function to generalize
the allocation and registration of an IOQ to make this use case
simple and easy.
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
---
drivers/vbus/bus-proxy.c | 64 +++++++++++++++++++++++++++++++++++++++++++
include/linux/vbus_driver.h | 7 +++++
2 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/drivers/vbus/bus-proxy.c b/drivers/vbus/bus-proxy.c
index 3177f9f..88cd904 100644
--- a/drivers/vbus/bus-proxy.c
+++ b/drivers/vbus/bus-proxy.c
@@ -150,3 +150,67 @@ void vbus_driver_unregister(struct vbus_driver *drv)
}
EXPORT_SYMBOL_GPL(vbus_driver_unregister);
+/*
+ *---------------------------------
+ * driver-side IOQ helper
+ *---------------------------------
+ */
+static void
+vbus_driver_ioq_release(struct ioq *ioq)
+{
+ kfree(ioq->head_desc);
+ kfree(ioq);
+}
+
+static struct ioq_ops vbus_driver_ioq_ops = {
+ .release = vbus_driver_ioq_release,
+};
+
+
+int vbus_driver_ioq_alloc(struct vbus_device_proxy *dev, int id, int prio,
+ size_t count, struct ioq **ioq)
+{
+ struct ioq *_ioq;
+ struct ioq_ring_head *head = NULL;
+ struct shm_signal *signal = NULL;
+ size_t len = IOQ_HEAD_DESC_SIZE(count);
+ int ret = -ENOMEM;
+
+ _ioq = kzalloc(sizeof(*_ioq), GFP_KERNEL);
+ if (!_ioq)
+ goto error;
+
+ head = kzalloc(len, GFP_KERNEL | GFP_DMA);
+ if (!head)
+ goto error;
+
+ head->magic = IOQ_RING_MAGIC;
+ head->ver = IOQ_RING_VER;
+ head->count = count;
+
+ ret = dev->ops->shm(dev, id, prio, head, len,
+ &head->signal, &signal, 0);
+ if (ret < 0)
+ goto error;
+
+ ioq_init(_ioq,
+ &vbus_driver_ioq_ops,
+ ioq_locality_north,
+ head,
+ signal,
+ count);
+
+ *ioq = _ioq;
+
+ return 0;
+
+ error:
+ kfree(_ioq);
+ kfree(head);
+
+ if (signal)
+ shm_signal_put(signal);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(vbus_driver_ioq_alloc);
diff --git a/include/linux/vbus_driver.h b/include/linux/vbus_driver.h
index c53e13f..9cfbf60 100644
--- a/include/linux/vbus_driver.h
+++ b/include/linux/vbus_driver.h
@@ -26,6 +26,7 @@
#include <linux/device.h>
#include <linux/shm_signal.h>
+#include <linux/ioq.h>
struct vbus_device_proxy;
struct vbus_driver;
@@ -70,4 +71,10 @@ struct vbus_driver {
int vbus_driver_register(struct vbus_driver *drv);
void vbus_driver_unregister(struct vbus_driver *drv);
+/*
+ * driver-side IOQ helper - allocates device-shm and maps an IOQ on it
+ */
+int vbus_driver_ioq_alloc(struct vbus_device_proxy *dev, int id, int prio,
+ size_t ringsize, struct ioq **ioq);
+
#endif /* _LINUX_VBUS_DRIVER_H */
next prev parent reply other threads:[~2009-08-03 17:19 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-03 17:17 [PATCH 0/7] AlacrityVM guest drivers Gregory Haskins
2009-08-03 17:17 ` [PATCH 1/7] shm-signal: shared-memory signals Gregory Haskins
2009-08-06 13:56 ` Arnd Bergmann
2009-08-06 15:11 ` Gregory Haskins
2009-08-06 20:51 ` Ira W. Snyder
2009-08-03 17:17 ` [PATCH 2/7] ioq: Add basic definitions for a shared-memory, lockless queue Gregory Haskins
2009-08-03 17:17 ` [PATCH 3/7] vbus: add a "vbus-proxy" bus model for vbus_driver objects Gregory Haskins
2009-08-03 17:17 ` [PATCH 4/7] vbus-proxy: add a pci-to-vbus bridge Gregory Haskins
2009-08-06 14:42 ` Arnd Bergmann
2009-08-06 15:59 ` Gregory Haskins
2009-08-06 17:03 ` Arnd Bergmann
2009-08-06 21:04 ` Gregory Haskins
2009-08-06 22:57 ` Arnd Bergmann
2009-08-07 4:42 ` Gregory Haskins
2009-08-07 14:57 ` Arnd Bergmann
2009-08-07 15:44 ` Gregory Haskins
2009-08-07 15:44 ` Gregory Haskins
2009-08-07 15:55 ` Ira W. Snyder
2009-08-07 18:25 ` Gregory Haskins
2009-08-03 17:17 ` Gregory Haskins [this message]
2009-08-03 17:18 ` [PATCH 6/7] net: Add vbus_enet driver Gregory Haskins
2009-08-03 18:30 ` Stephen Hemminger
2009-08-03 20:10 ` Gregory Haskins
2009-08-03 20:19 ` Stephen Hemminger
2009-08-03 20:24 ` Gregory Haskins
2009-08-03 20:29 ` Stephen Hemminger
2009-08-04 1:14 ` [PATCH v2] " Gregory Haskins
2009-08-04 2:38 ` David Miller
2009-08-04 13:57 ` [Alacrityvm-devel] " Gregory Haskins
2009-10-02 15:33 ` [PATCH v3] " Gregory Haskins
2009-08-03 17:18 ` [PATCH 7/7] venet: add scatter-gather/GSO support Gregory Haskins
2009-08-03 18:32 ` Stephen Hemminger
2009-08-03 19:30 ` Gregory Haskins
2009-08-03 18:33 ` Stephen Hemminger
2009-08-03 19:57 ` Gregory Haskins
2009-08-06 8:19 ` [PATCH 0/7] AlacrityVM guest drivers Reply-To: Michael S. Tsirkin
2009-08-06 10:17 ` Michael S. Tsirkin
2009-08-06 12:09 ` Gregory Haskins
2009-08-06 12:08 ` Gregory Haskins
2009-08-06 12:24 ` Michael S. Tsirkin
2009-08-06 13:00 ` Gregory Haskins
2009-08-06 12:54 ` Avi Kivity
2009-08-06 13:03 ` Gregory Haskins
2009-08-06 13:44 ` Avi Kivity
2009-08-06 13:45 ` Gregory Haskins
2009-08-06 13:57 ` Avi Kivity
2009-08-06 14:06 ` Gregory Haskins
2009-08-06 15:40 ` Arnd Bergmann
2009-08-06 15:45 ` Michael S. Tsirkin
2009-08-06 16:28 ` Pantelis Koukousoulas
2009-08-07 12:14 ` Gregory Haskins
2009-08-06 15:50 ` Avi Kivity
2009-08-06 16:55 ` Gregory Haskins
2009-08-09 7:48 ` Avi Kivity
2009-08-06 16:29 ` Gregory Haskins
2009-08-06 23:23 ` Ira W. Snyder
2009-08-06 13:59 ` Michael S. Tsirkin
2009-08-06 14:07 ` Gregory Haskins
2009-08-07 14:19 ` Anthony Liguori
2009-08-07 15:05 ` [PATCH 0/7] AlacrityVM guest drivers Gregory Haskins
2009-08-07 15:46 ` Anthony Liguori
2009-08-07 18:04 ` Gregory Haskins
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=20090803171756.17268.22133.stgit@dev.haskins.net \
--to=ghaskins@novell.com \
--cc=alacrityvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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.