From patchwork Mon Aug 3 17:17:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Haskins X-Patchwork-Id: 30608 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 5341CB6F31 for ; Tue, 4 Aug 2009 03:21:26 +1000 (EST) Received: by ozlabs.org (Postfix) id 31722DDDB6; Tue, 4 Aug 2009 03:21:26 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 9664EDDDA2 for ; Tue, 4 Aug 2009 03:21:25 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752795AbZHCRTY (ORCPT ); Mon, 3 Aug 2009 13:19:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752778AbZHCRTX (ORCPT ); Mon, 3 Aug 2009 13:19:23 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:50522 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752122AbZHCRSB (ORCPT ); Mon, 3 Aug 2009 13:18:01 -0400 Received: from dev.haskins.net (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by victor.provo.novell.com with ESMTP (TLS encrypted); Mon, 03 Aug 2009 11:17:58 -0600 Received: from dev.haskins.net (localhost [127.0.0.1]) by dev.haskins.net (Postfix) with ESMTP id A4CC7464233; Mon, 3 Aug 2009 13:17:56 -0400 (EDT) From: Gregory Haskins Subject: [PATCH 5/7] ioq: add driver-side vbus helpers To: linux-kernel@vger.kernel.org Cc: alacrityvm-devel@lists.sourceforge.net, netdev@vger.kernel.org Date: Mon, 03 Aug 2009 13:17:56 -0400 Message-ID: <20090803171756.17268.22133.stgit@dev.haskins.net> In-Reply-To: <20090803171030.17268.26962.stgit@dev.haskins.net> References: <20090803171030.17268.26962.stgit@dev.haskins.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/vbus/bus-proxy.c | 64 +++++++++++++++++++++++++++++++++++++++++++ include/linux/vbus_driver.h | 7 +++++ 2 files changed, 71 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 #include +#include 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 */