[PATCH 25/39] i2400m/USB: header for the USB bus driver

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Inaky Perez-Gonzalez
Date: Wednesday, November 26, 2008 - 3:40 pm

This contains the common function declaration and constants for the
USB driver for the 2400m Wireless WiMAX Connection, as well as the
debug level settings for the USB driver.

Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
---
 drivers/net/wimax/i2400m/i2400m-usb.h       |  190 +++++++++++++++++++++++++++
 drivers/net/wimax/i2400m/usb-debug-levels.h |   42 ++++++
 2 files changed, 232 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/i2400m-usb.h
 create mode 100644 drivers/net/wimax/i2400m/usb-debug-levels.h

diff --git a/drivers/net/wimax/i2400m/i2400m-usb.h b/drivers/net/wimax/i2400m/i2400m-usb.h
new file mode 100644
index 0000000..e22cde4
--- /dev/null
+++ b/drivers/net/wimax/i2400m/i2400m-usb.h
@@ -0,0 +1,190 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * USB-specific i2400m driver definitions
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *   * Neither the name of Intel Corporation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Intel Corporation <linux-wimax@intel.com>
+ * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
+ * Yanir Lubetkin <yanirx.lubetkin@intel.com>
+ *  - Initial implementation
+ *
+ *
+ * This driver implements the bus-specific part of the i2400m for
+ * USB. Check i2400m.h for a generic driver description.
+ *
+ * ARCHITECTURE
+ *
+ * This driver listens to notifications sent from the notification
+ * endpoint (in usb-notif.c); when data is ready to read, the code in
+ * there schedules a read from the device (usb-rx.c) and then passes
+ * the data to the generic RX code (rx.c).
+ *
+ * When the generic driver needs to send data (network or control), it
+ * queues up in the TX FIFO (tx.c) and that will notify the driver
+ * through the i2400m->bus_tx_kick() callback
+ * (usb-tx.c:i2400mu_bus_tx_kick) which will send the items in the
+ * FIFO queue.
+ *
+ * This driver, as well, implements the USB-specific ops for the generic
+ * driver to be able to setup/teardown communication with the device
+ * [i2400m_bus_dev_start() and i2400m_bus_dev_stop()], reseting the
+ * device [i2400m_bus_reset()] and performing firmware upload
+ * [i2400m_bus_bm_cmd() and i2400_bus_bm_wait_for_ack()].
+ */
+
+#ifndef __I2400M_USB_H__
+#define __I2400M_USB_H__
+
+#include "i2400m.h"
+#include "edc.h"
+#include <linux/kthread.h>
+
+/* Host-Device interface for USB */
+enum {
+	I2400MU_MAX_NOTIFICATION_LEN = 256,
+	I2400MU_BLK_SIZE = 16,
+	I2400MU_PL_SIZE_MAX = 0x3EFF,
+
+	/* Endpoints */
+	I2400MU_EP_BULK_OUT = 0,
+	I2400MU_EP_NOTIFICATION,
+	I2400MU_EP_RESET_COLD,
+	I2400MU_EP_BULK_IN,
+};
+
+
+/**
+ * struct i2400mu - descriptor for a USB connected i2400m
+ *
+ * @i2400m: bus-generic i2400m implementation; has to be first (see
+ *     it's documentation in i2400m.h).
+ *
+ * @usb_dev: pointer to our USB device
+ *
+ * @usb_iface: pointer to our USB interface
+ *
+ * @urb_edc: error density counter; used to keep a density-on-time tab
+ *     on how many soft (retryable or ignorable) errors we get. If we
+ *     go over the threshold, we consider the bus transport is failing
+ *     too much and reset.
+ *
+ * @notif_urb: URB for receiving notifications from the device.
+ *
+ * @tx_kthread: thread we use for data TX. We use a thread because in
+ *     order to do deep power saving and put the device to sleep, we
+ *     need to call usb_autopm_*() [blocking functions].
+ *
+ * @tx_wq: waitqueue for the TX kthread to sleep when there is no data
+ *     to be sent; when more data is available, it is woken up by
+ *     i2400mu_bus_tx_kick().
+ *
+ * @rx_kthread: thread we use for data RX. We use a thread because in
+ *     order to do deep power saving and put the device to sleep, we
+ *     need to call usb_autopm_*() [blocking functions].
+ *
+ * @rx_wq: waitqueue for the RX kthread to sleep when there is no data
+ *     to receive. When data is available, it is woken up by
+ *     usb-notif.c:i2400mu_notification_grok().
+ *
+ * @rx_pending_count: number of rx-data-ready notifications that were
+ *     still not handled by the RX kthread.
+ *
+ * @rx_size: current RX buffer size that is being used.
+ *
+ * @rx_size_acc: accumulator of the sizes of the previous read
+ *     transactions.
+ *
+ * @rx_size_cnt: number of read transactions accumulated in
+ *     @rx_size_acc.
+ *
+ * @do_autopm: disable(0)/enable(>0) calling the
+ *     usb_autopm_get/put_interface() barriers when executing
+ *     commands. See doc in i2400mu_suspend() for more information.
+ *
+ * @rx_size_auto_shrink: if true, the rx_size is shrinked
+ *     automatically based on the average size of the received
+ *     transactions. This allows the receive code to allocate smaller
+ *     chunks of memory and thus reduce pressure on the memory
+ *     allocator by not wasting so much space. By default it is
+ *     enabled.
+ */
+struct i2400mu {
+	struct i2400m i2400m;		/* FIRST! See doc */
+
+	struct usb_device *usb_dev;
+	struct usb_interface *usb_iface;
+	struct edc urb_edc;		/* Error density counter */
+
+	struct urb *notif_urb;
+	struct task_struct *tx_kthread;
+	wait_queue_head_t tx_wq;
+
+	struct task_struct *rx_kthread;
+	wait_queue_head_t rx_wq;
+	atomic_t rx_pending_count;
+	size_t rx_size, rx_size_acc, rx_size_cnt;
+	atomic_t do_autopm;
+	unsigned rx_size_auto_shrink:1;
+};
+
+
+static inline
+void i2400mu_init(struct i2400mu *i2400mu)
+{
+	i2400m_init(&i2400mu->i2400m);
+	edc_init(&i2400mu->urb_edc);
+	init_waitqueue_head(&i2400mu->tx_wq);
+	atomic_set(&i2400mu->rx_pending_count, 0);
+	init_waitqueue_head(&i2400mu->rx_wq);
+	i2400mu->rx_size = PAGE_SIZE - sizeof(struct skb_shared_info);
+	atomic_set(&i2400mu->do_autopm, 1);
+	i2400mu->rx_size_auto_shrink = 1;
+}
+
+extern int i2400mu_notification_setup(struct i2400mu *);
+extern void i2400mu_notification_release(struct i2400mu *);
+
+extern int i2400mu_rx_setup(struct i2400mu *);
+extern void i2400mu_rx_release(struct i2400mu *);
+extern void i2400mu_rx_kick(struct i2400mu *);
+
+extern int i2400mu_tx_setup(struct i2400mu *);
+extern void i2400mu_tx_release(struct i2400mu *);
+extern void i2400mu_bus_tx_kick(struct i2400m *);
+
+extern ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *,
+				       const struct i2400m_bootrom_header *,
+				       size_t, int);
+extern ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *,
+					   struct i2400m_bootrom_header *,
+					   size_t);
+#endif /* #ifndef __I2400M_USB_H__ */
diff --git a/drivers/net/wimax/i2400m/usb-debug-levels.h b/drivers/net/wimax/i2400m/usb-debug-levels.h
new file mode 100644
index 0000000..e4358bd
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb-debug-levels.h
@@ -0,0 +1,42 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * Debug levels control file for the i2400m-usb module
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
+ * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#ifndef __debug_levels__h__
+#define __debug_levels__h__
+
+/* Maximum compile and run time debug level for all submodules */
+#define D_MODULENAME i2400m_usb
+#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
+
+#include <linux/wimax/debug.h>
+
+/* List of all the enabled modules */
+enum d_module {
+	D_SUBMODULE_DECLARE(usb),
+	D_SUBMODULE_DECLARE(fw),
+	D_SUBMODULE_DECLARE(notif),
+	D_SUBMODULE_DECLARE(rx),
+	D_SUBMODULE_DECLARE(tx),
+};
+
+
+#endif /* #ifndef __debug_levels__h__ */
-- 
1.5.6.5

--
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/39] merge request for WiMAX kernel stack and i24 ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 01/39] wimax: documentation for the stack, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 02/39] wimax: declarations for the in-kernel WiMAX API, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 03/39] wimax: constants and definitions to interact ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 04/39] wimax: internal API for the kernel space WiM ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 05/39] wimax: debug macros and debug settings for t ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 06/39] genetlink: export genl_unregister_mc_group(), Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 07/39] wimax: generic WiMAX device management (regi ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 08/39] wimax: Mappping of generic netlink family ID ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 09/39] wimax: provides user space with information ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 10/39] wimax: Generic messaging interface between u ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 11/39] wimax: RF-kill framework integration, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 12/39] wimax: API call to reset a WiMAX device, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 13/39] wimax: Makefile, Kconfig and docbook linkage ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 14/39] i2400m: documentation and instructions for usage, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 15/39] i2400m: host-to-device protocol definitions, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 16/39] i2400m: core driver definitions and API, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 17/39] i2400m: Generic probe/disconnect, reset and ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 18/39] i2400m: linkage to the networking stack, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 19/39] i2400m: sysfs controls, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 20/39] i2400m: rfkill integration with the WiMAX stack, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 21/39] i2400m: firmware loading and bootrom initial ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 22/39] i2400m: handling of the data/control recepti ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 23/39] i2400m: handling of the data/control transmi ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 24/39] i2400m: various functions for device management, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 25/39] i2400m/USB: header for the USB bus driver, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 26/39] i2400m/USB: error density tracking, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 27/39] i2400m/USB: main probe/disconnect and backen ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 28/39] i2400m/USB: firmware upload backend, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 29/39] i2400m/USB: handling of notifications from t ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 30/39] i2400m/USB: read transactions from the USB d ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 31/39] i2400m/USB: write transactions to the USB device, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 32/39] i2400m/SDIO: header for the SDIO subdriver, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 33/39] i2400m/SDIO: main probe/disconnect and backe ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 34/39] i2400m/SDIO: firmware upload backend, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 35/39] i2400m/SDIO: read transactions from the SDIO ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 36/39] i2400m/SDIO: write transactions to the SDIO ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 37/39] i2400m: Makefile and Kconfig, Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 38/39] wimax: export linux/wimax.h and linux/wimax/ ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
[PATCH 39/39] wimax/i2400m: add CREDITS and MAINTAINERS en ..., Inaky Perez-Gonzalez, (Wed Nov 26, 3:40 pm)
Re: [PATCH 19/39] i2400m: sysfs controls, Johannes Berg, (Thu Nov 27, 2:23 am)
Re: [PATCH 00/39] merge request for WiMAX kernel stack and ..., Inaky Perez-Gonzalez, (Thu Nov 27, 2:24 am)
Re: [PATCH 01/39] wimax: documentation for the stack, Johannes Berg, (Thu Nov 27, 2:29 am)
Re: [PATCH 11/39] wimax: RF-kill framework integration, Johannes Berg, (Thu Nov 27, 2:56 am)
Re: [PATCH 12/39] wimax: API call to reset a WiMAX device, Johannes Berg, (Thu Nov 27, 2:58 am)
Re: [PATCH 00/39] merge request for WiMAX kernel stack and ..., Arkadiusz Miskiewicz, (Thu Nov 27, 3:18 am)
Re: [PATCH 00/39] merge request for WiMAX kernel stack and ..., Inaky Perez-Gonzalez, (Thu Nov 27, 9:51 am)
Re: [PATCH 10/39] wimax: Generic messaging interface betwe ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:02 pm)
Re: [PATCH 11/39] wimax: RF-kill framework integration, Inaky Perez-Gonzalez, (Tue Dec 2, 7:03 pm)
Re: [PATCH 12/39] wimax: API call to reset a WiMAX device, Inaky Perez-Gonzalez, (Tue Dec 2, 7:05 pm)
Re: [PATCH 03/39] wimax: constants and definitions to inte ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:06 pm)
Re: [PATCH 09/39] wimax: provides user space with informat ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:06 pm)
Re: [PATCH 07/39] wimax: generic WiMAX device management ( ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:06 pm)
Re: [PATCH 08/39] wimax: Mappping of generic netlink famil ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:06 pm)
Re: [PATCH 14/39] i2400m: documentation and instructions f ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:06 pm)
Re: [PATCH 15/39] i2400m: host-to-device protocol definitions, Inaky Perez-Gonzalez, (Tue Dec 2, 7:06 pm)
Re: [PATCH 00/39] merge request for WiMAX kernel stack and ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:07 pm)
Re: [PATCH 02/39] wimax: declarations for the in-kernel Wi ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:07 pm)
Re: [PATCH 04/39] wimax: internal API for the kernel space ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:07 pm)
Re: [PATCH 05/39] wimax: debug macros and debug settings f ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:07 pm)
Re: [PATCH 01/39] wimax: documentation for the stack, Inaky Perez-Gonzalez, (Tue Dec 2, 7:07 pm)
Re: [PATCH 00/39] merge request for WiMAX kernel stack and ..., Inaky Perez-Gonzalez, (Tue Dec 2, 7:10 pm)
Re: [PATCH 00/39] merge request for WiMAX kernel stack and ..., Inaky Perez-Gonzalez, (Thu Dec 4, 12:21 pm)
Re: [PATCH 04/39] wimax: internal API for the kernel space ..., Inaky Perez-Gonzalez, (Thu Dec 4, 12:22 pm)
Re: [PATCH 02/39] wimax: declarations for the in-kernel Wi ..., Inaky Perez-Gonzalez, (Thu Dec 4, 1:11 pm)