Skip to contentSkip to conversation

merge request for WiMAX kernel stack and i2400m driver v2

PATCH In review Inaky Perez-Gonzalez 9 participants 95 messages Nov 26, 2008 – Dec 4, 2008 Page 2 of 2

Subsystems (3)
lore
Share & tools
lore
#66 lore raw

PATCH 30/39 i2400m/USB: read transactions from the USB device

In reply to Inaky Perez-Gonzalez

This code implements reading from the USB device; it uses a simple adaptive algorithm so it doesn't preallocate huge buffers that then are underused. When a transaction is read, it is passed to the generic driver for processing and delivery.

All is done in a kthread sitting on a loop. We need a thread context to run USB autopm functions and to process the received data (can get to be heavy in processing time). It is dedicated to a single task, so it has less overhead than a workqueue.

---
 drivers/net/wimax/i2400m/usb-rx.c |  417 +++++++++++++++++++++++++++++++++++++
 1 files changed, 417 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/usb-rx.c
drivers/net/wimax/i2400m/usb-rx.c new file +417 -0
new file mode 100644
index 0000000..074cc1f
@@ -0,0 +1,417 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * USB RX handling
+ *
+ *
+ * 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 <[email protected]>
+ * Yanir Lubetkin <[email protected]>
+ *  - Initial implementation
+ * Inaky Perez-Gonzalez <[email protected]>
+ *  - Use skb_clone(), break up processing in chunks
+ *  - Split transport/device specific
+ *  - Make buffer size dynamic to exert less memory pressure
+ *
+ *
+ * This handles the RX path on USB.
+ *
+ * When a notification is received that says 'there is RX data ready',
+ * we call i2400mu_rx_kick(); that wakes up the RX kthread, which
+ * reads a buffer from USB and passes it to i2400m_rx() in the generic
+ * handling code. The RX buffer has an specific format that is
+ * described in rx.c.
+ *
+ * We use a kernel thread in a loop because:
+ *
+ *  - we want to be able to call the USB power management get/put
+ *    functions (blocking) before each transaction.
+ *
+ *  - We might get a lot of notifications and we don't want to submit
+ *    a zillion reads; by serializing, we are throttling.
+ *
+ *  - RX data processing can get heavy enough so that it is not
+ *    appropiate for doing it in the USB callback; thus we run it in a
+ *    process context.
+ *
+ * We provide a read buffer of an arbitrary size (short of a page); if
+ * the callback reports -EOVERFLOW, it means it was too small, so we
+ * just double the size and retry (being careful to append, as
+ * sometimes the device provided some data). Every now and then we
+ * check if the average packet size is smaller than the current packet
+ * size and if so, we halve it. At the end, the size of the
+ * preallocated buffer should be following the average received
+ * transaction size, adapting dynamically to it.
+ *
+ * ROADMAP
+ *
+ * i2400mu_rx_kick()		   Called from notif.c when we get a
+ *   			           'data ready' notification
+ * i2400mu_rxd()                   Kernel RX daemon
+ *   i2400mu_rx()                  Receive USB data
+ *   i2400m_rx()                   Send data to generic i2400m RX handling
+ *
+ * i2400mu_rx_setup()              called from i2400mu_bus_dev_start()
+ *
+ * i2400mu_rx_release()            called from i2400mu_bus_dev_stop()
+ */
+#include <linux/workqueue.h>
+#include <linux/usb.h>
+#include "i2400m-usb.h"
+
+
+#define D_SUBMODULE rx
+#include "usb-debug-levels.h"
+
+/*
+ * Dynamic RX size
+ *
+ * We can't let the rx_size be a multiple of 512 bytes (the RX
+ * endpoint's max packet size). On some USB host controllers (we
+ * haven't been able to fully characterize which), if the device is
+ * about to send (for example) X bytes and we only post a buffer to
+ * receive n*512, it will fail to mark that as babble (so that
+ * i2400mu_rx() [case -EOVERFLOW] can resize the buffer and get the
+ * rest).
+ *
+ * So on growing or shrinking, if it is a multiple of the
+ * maxpacketsize, we remove some (instead of incresing some, so in a
+ * buddy allocator we try to waste less space).
+ *
+ * Note we also need a hook for this on i2400mu_rx() -- when we do the
+ * first read, we are sure we won't hit this spot because
+ * i240mm->rx_size has been set properly. However, if we have to
+ * double because of -EOVERFLOW, when we launch the read to get the
+ * rest of the data, we *have* to make sure that also is not a
+ * multiple of the max_pkt_size.
+ */
+
+static
+size_t i2400mu_rx_size_grow(struct i2400mu *i2400mu)
+{
+	struct device *dev = &i2400mu->usb_iface->dev;
+	size_t rx_size;
+	const size_t max_pkt_size = 512;
+
+	rx_size = 2 * i2400mu->rx_size;
+	if (rx_size % max_pkt_size == 0) {
+		rx_size -= 8;
+		d_printf(1, dev,
+			 "RX: expected size grew to %zu [adjusted -8] "
+			 "from %zu\n",
+			 rx_size, i2400mu->rx_size);
+	} else
+		d_printf(1, dev,
+			 "RX: expected size grew to %zu from %zu\n",
+			 rx_size, i2400mu->rx_size);
+	return rx_size;
+}
+
+
+static
+void i2400mu_rx_size_maybe_shrink(struct i2400mu *i2400mu)
+{
+	const size_t max_pkt_size = 512;
+	struct device *dev = &i2400mu->usb_iface->dev;
+
+	if (unlikely(i2400mu->rx_size_cnt >= 100
+		     && i2400mu->rx_size_auto_shrink)) {
+		size_t avg_rx_size =
+			i2400mu->rx_size_acc / i2400mu->rx_size_cnt;
+		size_t new_rx_size = i2400mu->rx_size / 2;
+		if (avg_rx_size < new_rx_size) {
+			if (new_rx_size % max_pkt_size == 0) {
+				new_rx_size -= 8;
+				d_printf(1, dev,
+					 "RX: expected size shrank to %zu "
+					 "[adjusted -8] from %zu\n",
+					 new_rx_size, i2400mu->rx_size);
+			} else
+				d_printf(1, dev,
+					 "RX: expected size shrank to %zu "
+					 "from %zu\n",
+					 new_rx_size, i2400mu->rx_size);
+			i2400mu->rx_size = new_rx_size;
+			i2400mu->rx_size_cnt = 0;
+			i2400mu->rx_size_acc = i2400mu->rx_size;
+		}
+	}
+}
+
+/*
+ * Receive a message with payloads from the USB bus into an skb
+ *
+ * @i2400mu: USB device descriptor
+ * @rx_skb: skb where to place the received message
+ *
+ * Deals with all the USB-specifics of receiving, dynamically
+ * increasing the buffer size if so needed. Returns the payload in the
+ * skb, ready to process. On a zero-length packet, we retry.
+ *
+ * On soft USB errors, we retry (until they become too frequent and
+ * then are promoted to hard); on hard USB errors, we reset the
+ * device. On other errors (skb realloacation, we just drop it and
+ * hope for the next invocation to solve it).
+ *
+ * Returns: pointer to the skb if ok, ERR_PTR on error.
+ *   NOTE: this function might realloc the skb (if it is too small),
+ *   so always update with the one returned.
+ *   ERR_PTR() is < 0 on error.
+ */
+static
+struct sk_buff *i2400mu_rx(struct i2400mu *i2400mu, struct sk_buff *rx_skb)
+{
+	int result = 0;
+	struct device *dev = &i2400mu->usb_iface->dev;
+	int usb_pipe, read_size, rx_size, do_autopm;
+	struct usb_endpoint_descriptor *epd;
+	const size_t max_pkt_size = 512;
+
+	d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
+	do_autopm = atomic_read(&i2400mu->do_autopm);
+	result = do_autopm ?
+		usb_autopm_get_interface(i2400mu->usb_iface) : 0;
+	if (result < 0) {
+		dev_err(dev, "RX: can't get autopm: %d\n", result);
+		do_autopm = 0;
+	}
+	epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_BULK_IN);
+	usb_pipe = usb_rcvbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
+retry:
+	rx_size = skb_end_pointer(rx_skb) - rx_skb->data - rx_skb->len;
+	if (unlikely(rx_size % max_pkt_size == 0)) {
+		rx_size -= 8;
+		d_printf(1, dev, "RX: rx_size adapted to %d [-8]\n", rx_size);
+	}
+	result = usb_bulk_msg(
+		i2400mu->usb_dev, usb_pipe, rx_skb->data + rx_skb->len,
+		rx_size, &read_size, HZ);
+	usb_mark_last_busy(i2400mu->usb_dev);
+	switch (result) {
+	case 0:
+		if (read_size == 0)
+			goto retry;	/* ZLP, just resubmit */
+		skb_put(rx_skb, read_size);
+		break;
+	case -EINVAL:			/* while removing driver */
+	case -ENODEV:			/* dev disconnect ... */
+	case -ENOENT:			/* just ignore it */
+	case -ESHUTDOWN:
+	case -ECONNRESET:
+		break;
+	case -EOVERFLOW: {		/* too small, reallocate */
+		struct sk_buff *new_skb;
+		rx_size = i2400mu_rx_size_grow(i2400mu);
+		if (rx_size <= (1 << 16))	/* cap it */
+			i2400mu->rx_size = rx_size;
+		else if (printk_ratelimit()) {
+			dev_err(dev, "BUG? rx_size up to %d\n", rx_size);
+			result = -EINVAL;
+			goto out;
+		}
+		skb_put(rx_skb, read_size);
+		new_skb = skb_copy_expand(rx_skb, 0, rx_size - rx_skb->len,
+					  GFP_KERNEL);
+		if (new_skb == NULL) {
+			if (printk_ratelimit())
+				dev_err(dev, "RX: Can't reallocate skb to %d; "
+					"RX dropped\n", rx_size);
+			kfree(rx_skb);
+			result = 0;
+			goto out;	/* drop it...*/
+		}
+		kfree_skb(rx_skb);
+		rx_skb = new_skb;
+		i2400mu->rx_size_cnt = 0;
+		i2400mu->rx_size_acc = i2400mu->rx_size;
+		d_printf(1, dev, "RX: size changed to %d, received %d, "
+			 "copied %d, capacity %ld\n",
+			 rx_size, read_size, rx_skb->len,
+			 (long) (skb_end_pointer(new_skb) - new_skb->head));
+		goto retry;
+	}
+		/* In most cases, it happens due to the hardware scheduling a
+		 * read when there was no data - unfortunately, we have no way
+		 * to tell this timeout from a USB timeout. So we just ignore
+		 * it. */
+	case -ETIMEDOUT:
+		dev_err(dev, "RX: timeout: %d\n", result);
+		result = 0;
+		break;
+	default:			/* Any error */
+		if (edc_inc(&i2400mu->urb_edc,
+			    EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
+			goto error_reset;
+		dev_err(dev, "RX: error receiving URB: %d, retrying\n", result);
+		goto retry;
+	}
+out:
+	if (do_autopm)
+		usb_autopm_put_interface(i2400mu->usb_iface);
+	d_fnend(4, dev, "(i2400mu %p) = %p\n", i2400mu, rx_skb);
+	return rx_skb;
+
+error_reset:
+	dev_err(dev, "RX: maximum errors in URB exceeded; "
+		"resetting device\n");
+	usb_queue_reset_device(i2400mu->usb_iface);
+	rx_skb = ERR_PTR(result);
+	goto out;
+}
+
+
+/*
+ * Kernel thread for USB reception of data
+ *
+ * This thread waits for a kick; once kicked, it will allocate an skb
+ * and receive a single message to it from USB (using
+ * i2400mu_rx()). Once received, it is passed to the generic i2400m RX
+ * code for processing.
+ *
+ * When done processing, it runs some dirty statistics to verify if
+ * the last 100 messages received were smaller than half of the
+ * current RX buffer size. In that case, the RX buffer size is
+ * halved. This will helps lowering the pressure on the memory
+ * allocator.
+ *
+ * Hard errors force the thread to exit.
+ */
+static
+int i2400mu_rxd(void *_i2400mu)
+{
+	int result = 0;
+	struct i2400mu *i2400mu = _i2400mu;
+	struct i2400m *i2400m = &i2400mu->i2400m;
+	struct device *dev = &i2400mu->usb_iface->dev;
+	struct net_device *net_dev = i2400m->wimax_dev.net_dev;
+	size_t pending;
+	int rx_size;
+	struct sk_buff *rx_skb;
+
+	d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
+	while (1) {
+		d_printf(2, dev, "TX: waiting for messages\n");
+		pending = 0;
+		wait_event_interruptible(
+			i2400mu->rx_wq,
+			(kthread_should_stop()	/* check this first! */
+			 || (pending = atomic_read(&i2400mu->rx_pending_count)))
+			);
+		if (kthread_should_stop())
+			break;
+		if (pending == 0)
+			continue;
+		rx_size = i2400mu->rx_size;
+		d_printf(2, dev, "RX: reading up to %d bytes\n", rx_size);
+		rx_skb = __netdev_alloc_skb(net_dev, rx_size, GFP_KERNEL);
+		if (rx_skb == NULL) {
+			dev_err(dev, "RX: can't allocate skb [%d bytes]\n",
+				rx_size);
+			msleep(50);	/* give it some time? */
+			continue;
+		}
+
+		/* Receive the message with the payloads */
+		rx_skb = i2400mu_rx(i2400mu, rx_skb);
+		result = PTR_ERR(rx_skb);
+		if (IS_ERR(rx_skb))
+			goto out;
+		atomic_dec(&i2400mu->rx_pending_count);
+		if (rx_skb->len == 0) {	/* some ignorable condition */
+			kfree_skb(rx_skb);
+			continue;
+		}
+
+		/* Deliver the message to the generic i2400m code */
+		i2400mu->rx_size_cnt++;
+		i2400mu->rx_size_acc += rx_skb->len;
+		result = i2400m_rx(i2400m, rx_skb);
+		if (result == -EIO
+		    && edc_inc(&i2400mu->urb_edc,
+			       EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
+			goto error_reset;
+		}
+
+		/* Maybe adjust RX buffer size */
+		i2400mu_rx_size_maybe_shrink(i2400mu);
+	}
+	result = 0;
+out:
+	d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result);
+	return result;
+
+error_reset:
+	dev_err(dev, "RX: maximum errors in received buffer exceeded; "
+		"resetting device\n");
+	usb_queue_reset_device(i2400mu->usb_iface);
+	goto out;
+}
+
+
+/*
+ * Start reading from the device
+ *
+ * @i2400m: device instance
+ *
+ * Notify the RX thread that there is data pending.
+ */
+void i2400mu_rx_kick(struct i2400mu *i2400mu)
+{
+	struct i2400m *i2400m = &i2400mu->i2400m;
+	struct device *dev = &i2400mu->usb_iface->dev;
+
+	d_fnstart(3, dev, "(i2400mu %p)\n", i2400m);
+	atomic_inc(&i2400mu->rx_pending_count);
+	wake_up_all(&i2400mu->rx_wq);
+	d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
+}
+
+
+int i2400mu_rx_setup(struct i2400mu *i2400mu)
+{
+	int result = 0;
+	struct i2400m *i2400m = &i2400mu->i2400m;
+	struct device *dev = &i2400mu->usb_iface->dev;
+	struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
+
+	i2400mu->rx_kthread = kthread_run(i2400mu_rxd, i2400mu, "%s-rx",
+					  wimax_dev->name);
+	if (IS_ERR(i2400mu->rx_kthread)) {
+		result = PTR_ERR(i2400mu->rx_kthread);
+		dev_err(dev, "RX: cannot start thread: %d\n", result);
+	}
+	return result;
+}
+
+void i2400mu_rx_release(struct i2400mu *i2400mu)
+{
+	kthread_stop(i2400mu->rx_kthread);
+}
+
Signature · 1 line
1.5.6.5
#67 lore raw

PATCH 31/39 i2400m/USB: write transactions to the USB device

In reply to Inaky Perez-Gonzalez

Implements the backend so that the generic driver can send data to the USB device. Implemented with a kthread sitting in a never-ending loop that when kicked by the generic driver will pull data from the TX FIFO and send it to the device until it drains it. Then it goes back sleep, waiting for another kick.

This is a thread for similar reasons as the case of USB reading. We need to be able to use the USB autopm management functions, which are blocking. As well, it is dedicated to a single task, so it has less overhead than a workqueue.

---
 drivers/net/wimax/i2400m/usb-tx.c |  229 +++++++++++++++++++++++++++++++++++++
 1 files changed, 229 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/usb-tx.c
drivers/net/wimax/i2400m/usb-tx.c new file +229 -0
new file mode 100644
index 0000000..dfd8933
@@ -0,0 +1,229 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * USB specific TX handling
+ *
+ *
+ * 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 <[email protected]>
+ * Yanir Lubetkin <[email protected]>
+ *  - Initial implementation
+ * Inaky Perez-Gonzalez <[email protected]>
+ *  - Split transport/device specific
+ *
+ *
+ * Takes the TX messages in the i2400m's driver TX FIFO and sends them
+ * to the device until there are no more.
+ *
+ * If we fail sending the message, we just drop it. There isn't much
+ * we can do at this point. We could also retry, but the USB stack has
+ * already retried and still failed, so there is not much of a
+ * point. As well, most of the traffic is network, which has recovery
+ * methods for dropped packets.
+ *
+ * For sending we just obtain a FIFO buffer to send, send it to the
+ * USB bulk out, tell the TX FIFO code we have sent it; query for
+ * another one, etc... until done.
+ *
+ * We use a thread so we can call usb_autopm_enable() and
+ * usb_autopm_disable() for each transaction; this way when the device
+ * goes idle, it will suspend. It also has less overhead than a
+ * dedicated workqueue, as it is being used for a single task.
+ *
+ * ROADMAP
+ *
+ * i2400mu_tx_setup()
+ * i2400mu_tx_release()
+ *
+ * i2400mu_bus_tx_kick()	- Called by the tx.c code when there
+ *                                is new data in the FIFO.
+ * i2400mu_txd()
+ *   i2400m_tx_msg_get()
+ *   i2400m_tx_msg_sent()
+ */
+#include "i2400m-usb.h"
+
+
+#define D_SUBMODULE tx
+#include "usb-debug-levels.h"
+
+
+/*
+ * Get the next TX message in the TX FIFO and send it to the device
+ *
+ * Note that any iteration consumes a message to be sent, no matter if
+ * it succeeds or fails (we have no real way to retry or complain).
+ *
+ * Return: 0 if ok, < 0 errno code on hard error.
+ */
+static
+int i2400mu_tx(struct i2400mu *i2400mu, struct i2400m_msg_hdr *tx_msg,
+	       size_t tx_msg_size)
+{
+	int result = 0;
+	struct i2400m *i2400m = &i2400mu->i2400m;
+	struct device *dev = &i2400mu->usb_iface->dev;
+	int usb_pipe, sent_size, do_autopm;
+	struct usb_endpoint_descriptor *epd;
+
+	d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
+	do_autopm = atomic_read(&i2400mu->do_autopm);
+	result = do_autopm ?
+		usb_autopm_get_interface(i2400mu->usb_iface) : 0;
+	if (result < 0) {
+		dev_err(dev, "TX: can't get autopm: %d\n", result);
+		do_autopm = 0;
+	}
+	epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_BULK_OUT);
+	usb_pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
+retry:
+	result = usb_bulk_msg(i2400mu->usb_dev, usb_pipe,
+			      tx_msg, tx_msg_size, &sent_size, HZ);
+	usb_mark_last_busy(i2400mu->usb_dev);
+	switch (result) {
+	case 0:
+		if (sent_size != tx_msg_size) {	/* Too short? drop it */
+			dev_err(dev, "TX: short write (%d B vs %zu "
+				"expected)\n", sent_size, tx_msg_size);
+			result = -EIO;
+		}
+		break;
+	case -EINVAL:			/* while removing driver */
+	case -ENODEV:			/* dev disconnect ... */
+	case -ENOENT:			/* just ignore it */
+	case -ESHUTDOWN:		/* and exit */
+	case -ECONNRESET:
+		result = -ESHUTDOWN;
+		break;
+	default:			/* Some error? */
+		if (edc_inc(&i2400mu->urb_edc,
+			    EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
+			dev_err(dev, "TX: maximum errors in URB "
+				"exceeded; resetting device\n");
+			usb_queue_reset_device(i2400mu->usb_iface);
+		} else {
+			dev_err(dev, "TX: cannot send URB; retrying. "
+				"tx_msg @%zu %zu B [%d sent]: %d\n",
+				(void *) tx_msg - i2400m->tx_buf,
+				tx_msg_size, sent_size, result);
+			goto retry;
+		}
+	}
+	if (do_autopm)
+		usb_autopm_put_interface(i2400mu->usb_iface);
+	d_fnend(4, dev, "(i2400mu %p) = result\n", i2400mu);
+	return result;
+}
+
+
+/*
+ * Get the next TX message in the TX FIFO and send it to the device
+ *
+ * Note we exit the loop if i2400mu_tx() fails; that funtion only
+ * fails on hard error (failing to tx a buffer not being one of them,
+ * see its doc).
+ *
+ * Return: 0
+ */
+static
+int i2400mu_txd(void *_i2400mu)
+{
+	int result = 0;
+	struct i2400mu *i2400mu = _i2400mu;
+	struct i2400m *i2400m = &i2400mu->i2400m;
+	struct device *dev = &i2400mu->usb_iface->dev;
+	struct i2400m_msg_hdr *tx_msg;
+	size_t tx_msg_size;
+
+	d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
+
+	while (1) {
+		d_printf(2, dev, "TX: waiting for messages\n");
+		tx_msg = NULL;
+		wait_event_interruptible(
+			i2400mu->tx_wq,
+			(kthread_should_stop()	/* check this first! */
+			 || (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size)))
+			);
+		if (kthread_should_stop())
+			break;
+		WARN_ON(tx_msg == NULL);	/* should not happen...*/
+		d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size);
+		d_dump(5, dev, tx_msg, tx_msg_size);
+		/* Yeah, we ignore errors ... not much we can do */
+		i2400mu_tx(i2400mu, tx_msg, tx_msg_size);
+		i2400m_tx_msg_sent(i2400m);	/* ack it, advance the FIFO */
+		if (result < 0)
+			break;
+	}
+	d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result);
+	return result;
+}
+
+
+/*
+ * i2400m TX engine notifies us that there is data in the FIFO ready
+ * for TX
+ *
+ * If there is a URB in flight, don't do anything; when it finishes,
+ * it will see there is data in the FIFO and send it. Else, just
+ * submit a write.
+ */
+void i2400mu_bus_tx_kick(struct i2400m *i2400m)
+{
+	struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
+	struct device *dev = &i2400mu->usb_iface->dev;
+
+	d_fnstart(3, dev, "(i2400m %p) = void\n", i2400m);
+	wake_up_all(&i2400mu->tx_wq);
+	d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
+}
+
+
+int i2400mu_tx_setup(struct i2400mu *i2400mu)
+{
+	int result = 0;
+	struct i2400m *i2400m = &i2400mu->i2400m;
+	struct device *dev = &i2400mu->usb_iface->dev;
+	struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
+
+	i2400mu->tx_kthread = kthread_run(i2400mu_txd, i2400mu, "%s-tx",
+					  wimax_dev->name);
+	if (IS_ERR(i2400mu->tx_kthread)) {
+		result = PTR_ERR(i2400mu->tx_kthread);
+		dev_err(dev, "TX: cannot start thread: %d\n", result);
+	}
+	return result;
+}
+
+void i2400mu_tx_release(struct i2400mu *i2400mu)
+{
+	kthread_stop(i2400mu->tx_kthread);
+}
Signature · 1 line
1.5.6.5
#68 lore raw

PATCH 32/39 i2400m/SDIO: header for the SDIO subdriver

In reply to Inaky Perez-Gonzalez

This contains the common function declaration and constants for the SDIO driver for the 2400m Wireless WiMAX Connection and the debug level settings for the SDIO driver.

---
 drivers/net/wimax/i2400m/i2400m-sdio.h       |  130 ++++++++++++++++++++++++++
 drivers/net/wimax/i2400m/sdio-debug-levels.h |   22 +++++
 2 files changed, 152 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/i2400m-sdio.h
 create mode 100644 drivers/net/wimax/i2400m/sdio-debug-levels.h
drivers/net/wimax/i2400m/i2400m-sdio.h new file +130 -0
new file mode 100644
index 0000000..1c9cd54
@@ -0,0 +1,130 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * SDIO-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 <[email protected]>
+ * Brian Bian <[email protected]>
+ * Dirk Brandewie <[email protected]>
+ * Inaky Perez-Gonzalez <[email protected]>
+ * Yanir Lubetkin <[email protected]>
+ *  - Initial implementation
+ *
+ *
+ * This driver implements the bus-specific part of the i2400m for
+ * SDIO. Check i2400m.h for a generic driver description.
+ *
+ * ARCHITECTURE
+ *
+ * This driver sits under the bus-generic i2400m driver, providing the
+ * connection to the device.
+ *
+ * When probed, all the function pointers are setup and then the
+ * bus-generic code called. The generic driver will then use the
+ * provided pointers for uploading firmware (i2400ms_bus_bm*() in
+ * sdio-fw.c) and then setting up the device (i2400ms_dev_*() in
+ * sdio.c).
+ *
+ * Once firmware is uploaded, TX functions (sdio-tx.c) are called when
+ * data is ready for transmission in the TX fifo; then the SDIO IRQ is
+ * fired and data is available (sdio-rx.c), it is sent to the generic
+ * driver for processing with i2400m_rx.
+ */
+
+#ifndef __I2400M_SDIO_H__
+#define __I2400M_SDIO_H__
+
+#include "i2400m.h"
+
+/* Host-Device interface for SDIO */
+enum {
+	I2400MS_BLK_SIZE = 256,
+	I2400MS_PL_SIZE_MAX = 0x3E00,
+
+	I2400MS_DATA_ADDR = 0x0,
+	I2400MS_INTR_STATUS_ADDR = 0x13,
+	I2400MS_INTR_CLEAR_ADDR = 0x13,
+	I2400MS_INTR_ENABLE_ADDR = 0x14,
+	I2400MS_INTR_GET_SIZE_ADDR = 0x2C,
+	/* The number of ticks to wait for the device to signal that
+	 * it is ready */
+	I2400MS_INIT_SLEEP_INTERVAL = 10,
+};
+
+
+/**
+ * struct i2400ms - descriptor for a SDIO connected i2400m
+ *
+ * @i2400m: bus-generic i2400m implementation; has to be first (see
+ *     it's documentation in i2400m.h).
+ *
+ * @func: pointer to our SDIO function
+ *
+ * @tx_worker: workqueue struct used to TX data when the bus-generic
+ *     code signals packets are pending for transmission to the device.
+ *
+ * @tx_workqueue: workqeueue used for data TX; we don't use the
+ *     system's workqueue as that might cause deadlocks with code in
+ *     the bus-generic driver.
+ */
+struct i2400ms {
+	struct i2400m i2400m;		/* FIRST! See doc */
+	struct sdio_func *func;
+
+	struct work_struct tx_worker;
+	struct workqueue_struct *tx_workqueue;
+	char tx_wq_name[32];
+};
+
+
+static inline
+void i2400ms_init(struct i2400ms *i2400ms)
+{
+	i2400m_init(&i2400ms->i2400m);
+}
+
+
+extern int i2400ms_rx_setup(struct i2400ms *);
+extern void i2400ms_rx_release(struct i2400ms *);
+extern ssize_t __i2400ms_rx_get_size(struct i2400ms *);
+
+extern int i2400ms_tx_setup(struct i2400ms *);
+extern void i2400ms_tx_release(struct i2400ms *);
+extern void i2400ms_bus_tx_kick(struct i2400m *);
+
+extern ssize_t i2400ms_bus_bm_cmd_send(struct i2400m *,
+				       const struct i2400m_bootrom_header *,
+				       size_t, int);
+extern ssize_t i2400ms_bus_bm_wait_for_ack(struct i2400m *,
+					   struct i2400m_bootrom_header *,
+					   size_t);
+#endif /* #ifndef __I2400M_SDIO_H__ */
drivers/net/wimax/i2400m/sdio-debug-levels.h new file +22 -0
new file mode 100644
index 0000000..3e3eae9
@@ -0,0 +1,22 @@
+/*
+ * debug levels control file for the i2400m module's
+ */
+#ifndef __debug_levels__h__
+#define __debug_levels__h__
+
+/* Maximum compile and run time debug level for all submodules */
+#define D_MODULENAME i2400m_sdio
+#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(sdio_main),
+	D_SUBMODULE_DECLARE(sdio_tx),
+	D_SUBMODULE_DECLARE(sdio_rx),
+	D_SUBMODULE_DECLARE(sdio_fw)
+};
+
+
+#endif /* #ifndef __debug_levels__h__ */
Signature · 1 line
1.5.6.5
#69 lore raw

PATCH 33/39 i2400m/SDIO: main probe/disconnect and backend routines

In reply to Inaky Perez-Gonzalez

Implements probe/disconnect for the SDIO device, as well as main backends for the generic driver to control the SDIO device (bus_dev_start(), bus_dev_stop() and bus_reset()).

---
 drivers/net/wimax/i2400m/sdio.c |  491 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 491 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/sdio.c
drivers/net/wimax/i2400m/sdio.c new file +491 -0
new file mode 100644
index 0000000..b70ffd7
@@ -0,0 +1,491 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * Linux driver model glue for the SDIO device, reset & fw upload
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation <[email protected]>
+ * Dirk Brandewie <[email protected]>
+ * Inaky Perez-Gonzalez <[email protected]>
+ * Yanir Lubetkin <[email protected]>
+ *
+ * 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.
+ *
+ *
+ * See i2400m-sdio.h for a general description of this driver.
+ *
+ * This file implements driver model glue, and hook ups for the
+ * generic driver to implement the bus-specific functions (device
+ * communication setup/tear down, firmware upload and resetting).
+ *
+ * ROADMAP
+ *
+ * i2400m_probe()
+ *   alloc_netdev()
+ *     i2400ms_netdev_setup()
+ *       i2400ms_init()
+ *       i2400m_netdev_setup()
+ *   i2400ms_enable_function()
+ *   i2400m_setup()
+ *
+ * i2400m_remove()
+ *     i2400m_release()
+ *     free_netdev(net_dev)
+ *
+ * i2400ms_bus_reset()            Called by i2400m->bus_reset
+ *   __i2400ms_reset()
+ *     __i2400ms_send_barker()
+ *
+ * i2400ms_bus_dev_start()        Called by i2400m_dev_start() [who is
+ *   i2400ms_tx_setup()           called by i2400m_setup()]
+ *   i2400ms_rx_setup()
+ *
+ * i2400ms_bus_dev_stop()         Called by i2400m_dev_stop() [who is
+ *   i2400ms_rx_release()         is called by i2400m_release()]
+ *   i2400ms_tx_release()
+ *
+ */
+
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/sdio_func.h>
+#include "i2400m-sdio.h"
+#include <linux/wimax/i2400m.h>
+
+#define D_SUBMODULE sdio_main
+#include "sdio-debug-levels.h"
+
+/* IOE WiMAX function timeout in seconds */
+static int ioe_timeout = 2;
+module_param(ioe_timeout, int, 0);
+
+/* Our firmware file name */
+#define I2400MS_FW_FILE_NAME "i2400m-fw-sdio-" I2400M_FW_VERSION ".sbcf"
+
+/*
+ * Enable the SDIO function
+ *
+ * Tries to enable the SDIO function; might fail if it is still not
+ * ready (in some hardware, the SDIO WiMAX function is only enabled
+ * when we ask it to explicitly doing). Tries until a timeout is
+ * reached.
+ *
+ * The reverse of this is...sdio_disable_function()
+ *
+ * Returns: 0 if the SDIO function was enabled, < 0 errno code on
+ *     error (-ENODEV when it was unable to enable the function).
+ */
+static
+int i2400ms_enable_function(struct sdio_func *func)
+{
+	u64 timeout;
+	int err;
+	struct device *dev = &func->dev;
+
+	d_fnstart(3, dev, "(func %p)\n", func);
+	/* Setup timeout (FIXME: This needs to read the CIS table to
+	 * get a real timeout) and then wait for the device to signal
+	 * it is ready */
+	timeout = get_jiffies_64() + ioe_timeout * HZ;
+	err = -ENODEV;
+	while (err != 0 && time_before64(get_jiffies_64(), timeout)) {
+		sdio_claim_host(func);
+		err = sdio_enable_func(func);
+		if (0 == err) {
+			sdio_release_host(func);
+			d_printf(2, dev, "SDIO function enabled\n");
+			goto function_enabled;
+		}
+		d_printf(2, dev, "SDIO function failed to enable: %d\n", err);
+		sdio_disable_func(func);
+		sdio_release_host(func);
+		msleep(I2400MS_INIT_SLEEP_INTERVAL);
+	}
+	/* If timed out, device is not there yet -- get -ENODEV so
+	 * the device driver core will retry later on. */
+	if (err == -ETIME) {
+		dev_err(dev, "Can't enable WiMAX function; "
+			" has the function been enabled?\n");
+		err = -ENODEV;
+	}
+function_enabled:
+	d_fnend(3, dev, "(func %p) = %d\n", func, err);
+	return err;
+}
+
+
+/*
+ * Setup driver resources needed to communicate with the device
+ *
+ * The fw needs some time to settle, and it was just uploaded,
+ * so give it a break first. I'd prefer to just wait for the device to
+ * send something, but seems the poking we do to enable SDIO stuff
+ * interferes with it, so just give it a break before starting...
+ */
+static
+int i2400ms_bus_dev_start(struct i2400m *i2400m)
+{
+	int result;
+	struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+
+	d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
+	msleep(200);
+	result = i2400ms_rx_setup(i2400ms);
+	if (result < 0)
+		goto error_rx_setup;
+	result = i2400ms_tx_setup(i2400ms);
+	if (result < 0)
+		goto error_tx_setup;
+	d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
+	return result;
+
+	i2400ms_tx_release(i2400ms);
+error_tx_setup:
+	i2400ms_rx_release(i2400ms);
+error_rx_setup:
+	d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
+	return result;
+}
+
+
+static
+void i2400ms_bus_dev_stop(struct i2400m *i2400m)
+{
+	struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+
+	d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
+	i2400ms_rx_release(i2400ms);
+	i2400ms_tx_release(i2400ms);
+	d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
+}
+
+
+/*
+ * Sends a barker buffer to the device
+ *
+ * This helper will allocate a kmalloced buffer and use it to transmit
+ * (then free it). Reason for this is that the SDIO host controller
+ * expects alignment (unknown exactly which) which the stack won't
+ * really provide and certain arches/host-controller combinations
+ * cannot use stack/vmalloc/text areas for DMA transfers.
+ */
+static
+int __i2400ms_send_barker(struct i2400ms *i2400ms,
+			  const __le32 *barker, size_t barker_size)
+{
+	int  ret;
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+	void *buffer;
+
+	ret = -ENOMEM;
+	buffer = kmalloc(I2400MS_BLK_SIZE, GFP_KERNEL);
+	if (buffer == NULL)
+		goto error_kzalloc;
+
+	memcpy(buffer, barker, barker_size);
+	sdio_claim_host(func);
+	ret = sdio_memcpy_toio(func, 0, buffer, I2400MS_BLK_SIZE);
+	sdio_release_host(func);
+
+	if (ret < 0)
+		d_printf(0, dev, "E: barker error: %d\n", ret);
+
+	kfree(buffer);
+error_kzalloc:
+	return ret;
+}
+
+
+/*
+ * Reset a device at different levels (warm, cold or bus)
+ *
+ * @i2400ms: device descriptor
+ * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
+ *
+ * FIXME: not tested -- need to confirm expected effects
+ *
+ * Warm and cold resets get an SDIO reset if they fail (unimplemented)
+ *
+ * Warm reset:
+ *
+ * The device will be fully reset internally, but won't be
+ * disconnected from the USB bus (so no reenumeration will
+ * happen). Firmware upload will be neccessary.
+ *
+ * The device will send a reboot barker in the notification endpoint
+ * that will trigger the driver to reinitialize the state
+ * automatically from notif.c:i2400m_notification_grok() into
+ * i2400m_dev_bootstrap_delayed().
+ *
+ * Cold and bus (USB) reset:
+ *
+ * The device will be fully reset internally, disconnected from the
+ * USB bus an a reenumeration will happen. Firmware upload will be
+ * neccessary. Thus, we don't do any locking or struct
+ * reinitialization, as we are going to be fully disconnected and
+ * reenumerated.
+ *
+ * Note we need to return -ENODEV if a warm reset was requested and we
+ * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
+ * and wimax_dev->op_reset.
+ *
+ * WARNING: no driver state saved/fixed
+ */
+static
+int i2400ms_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
+{
+	int result;
+	struct i2400ms *i2400ms =
+		container_of(i2400m, struct i2400ms, i2400m);
+	struct device *dev = i2400m_dev(i2400m);
+	static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
+		__constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
+		__constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
+		__constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
+		__constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
+	};
+	static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
+		__constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
+		__constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
+		__constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
+		__constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
+	};
+
+	if (rt == I2400M_RT_WARM)
+		result = __i2400ms_send_barker(i2400ms, i2400m_WARM_BOOT_BARKER,
+					       sizeof(i2400m_WARM_BOOT_BARKER));
+	else if (rt == I2400M_RT_COLD)
+		result = __i2400ms_send_barker(i2400ms, i2400m_COLD_BOOT_BARKER,
+					       sizeof(i2400m_COLD_BOOT_BARKER));
+	else if (rt == I2400M_RT_BUS) {
+do_bus_reset:
+		dev_err(dev, "FIXME: SDIO bus reset not implemented\n");
+		result = rt == I2400M_RT_WARM ? -ENODEV : -ENOSYS;
+	} else
+		BUG();
+	if (result < 0 && rt != I2400M_RT_BUS) {
+		dev_err(dev, "%s reset failed (%d); trying SDIO reset\n",
+			rt == I2400M_RT_WARM ? "warm" : "cold", result);
+		rt = I2400M_RT_BUS;
+		goto do_bus_reset;
+	}
+	return result;
+}
+
+
+static
+void i2400ms_netdev_setup(struct net_device *net_dev)
+{
+	struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
+	struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	i2400ms_init(i2400ms);
+	i2400m_netdev_setup(net_dev);
+}
+
+
+/*
+ * Debug levels control; see debug.h
+ */
+struct d_level D_LEVEL[] = {
+	D_SUBMODULE_DEFINE(sdio_main),
+	D_SUBMODULE_DEFINE(sdio_tx),
+	D_SUBMODULE_DEFINE(sdio_rx),
+	D_SUBMODULE_DEFINE(sdio_fw),
+};
+size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
+
+static
+DEVICE_ATTR(i2400ms_debug_levels, S_IRUGO | S_IWUSR,
+	    d_level_show, d_level_store);
+
+static
+struct attribute *i2400ms_dev_attrs[] = {
+	&dev_attr_i2400ms_debug_levels.attr,
+	NULL,
+};
+
+static
+struct attribute_group i2400ms_dev_attr_group = {
+	.name = NULL,		/* we want them in the same directory */
+	.attrs = i2400ms_dev_attrs,
+};
+
+
+/*
+ * Probe a i2400m interface and register it
+ *
+ * @func:    SDIO function
+ * @id:      SDIO device ID
+ * @returns: 0 if ok, < 0 errno code on error.
+ *
+ * Alloc a net device, initialize the bus-specific details and then
+ * calls the bus-generic initialization routine. That will register
+ * the wimax and netdev devices, upload the firmware [using
+ * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
+ * communication with the device and then will start to talk to it to
+ * finnish setting it up.
+ *
+ * Initialization is tricky; some instances of the hw are packed with
+ * others in a way that requires a third driver that enables the WiMAX
+ * function. In those cases, we can't enable the SDIO function and
+ * we'll return with -ENODEV. When the driver that enables the WiMAX
+ * function does its thing, it has to do a bus_rescan_devices() on the
+ * SDIO bus so this driver is called again to enumerate the WiMAX
+ * function.
+ */
+static
+int i2400ms_probe(struct sdio_func *func,
+		  const struct sdio_device_id *id)
+{
+	int result;
+	struct net_device *net_dev;
+	struct device *dev = &func->dev;
+	struct i2400m *i2400m;
+	struct i2400ms *i2400ms;
+
+	/* Allocate instance [calls i2400m_netdev_setup() on it]. */
+	result = -ENOMEM;
+	net_dev = alloc_netdev(sizeof(*i2400ms), "wmx%d",
+			       i2400ms_netdev_setup);
+	if (net_dev == NULL) {
+		dev_err(dev, "no memory for network device instance\n");
+		goto error_alloc_netdev;
+	}
+	SET_NETDEV_DEV(net_dev, dev);
+	i2400m = net_dev_to_i2400m(net_dev);
+	i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	i2400m->wimax_dev.net_dev = net_dev;
+	i2400ms->func = func;
+	sdio_set_drvdata(func, i2400ms);
+
+	i2400m->bus_tx_block_size = I2400MS_BLK_SIZE;
+	i2400m->bus_pl_size_max = I2400MS_PL_SIZE_MAX;
+	i2400m->bus_dev_start = i2400ms_bus_dev_start;
+	i2400m->bus_dev_stop = i2400ms_bus_dev_stop;
+	i2400m->bus_tx_kick = i2400ms_bus_tx_kick;
+	i2400m->bus_reset = i2400ms_bus_reset;
+	i2400m->bus_bm_cmd_send = i2400ms_bus_bm_cmd_send;
+	i2400m->bus_bm_wait_for_ack = i2400ms_bus_bm_wait_for_ack;
+	i2400m->bus_fw_name = I2400MS_FW_FILE_NAME;
+	i2400m->bus_bm_mac_addr_impaired = 1;
+
+	result = i2400ms_enable_function(i2400ms->func);
+	if (result < 0) {
+		dev_err(dev, "Cannot enable SDIO function: %d\n", result);
+		goto error_func_enable;
+	}
+
+	sdio_claim_host(func);
+	result = sdio_set_block_size(func, I2400MS_BLK_SIZE);
+	if (result < 0) {
+		dev_err(dev, "Failed to set block size: %d\n", result);
+		goto error_set_blk_size;
+	}
+	sdio_release_host(func);
+
+	result = i2400m_setup(i2400m, I2400M_BRI_NO_REBOOT);
+	if (result < 0) {
+		dev_err(dev, "cannot setup device: %d\n", result);
+		goto error_setup;
+	}
+
+	result = sysfs_create_group(&dev->kobj, &i2400ms_dev_attr_group);
+	if (result < 0) {
+		dev_err(dev, "cannot create SDIO sysfs files: %d\n",
+			result);
+		goto error_create_group;
+	}
+	return 0;
+
+error_create_group:
+	i2400m_release(i2400m);
+error_setup:
+	sdio_set_drvdata(func, i2400ms);
+	sdio_claim_host(func);
+error_set_blk_size:
+	sdio_disable_func(func);
+	sdio_release_host(func);
+error_func_enable:
+	free_netdev(net_dev);
+error_alloc_netdev:
+	return result;
+}
+
+
+static
+void i2400ms_remove(struct sdio_func *func)
+{
+	struct device *dev = &func->dev;
+	struct i2400ms *i2400ms = sdio_get_drvdata(func);
+	struct i2400m *i2400m = &i2400ms->i2400m;
+	struct net_device *net_dev = i2400m->wimax_dev.net_dev;
+
+	d_fnstart(3, dev, "SDIO func %p\n", func);
+	sysfs_remove_group(&dev->kobj, &i2400ms_dev_attr_group);
+	i2400m_release(i2400m);
+	sdio_set_drvdata(func, NULL);
+	sdio_claim_host(func);
+	sdio_disable_func(func);
+	sdio_release_host(func);
+	free_netdev(net_dev);
+	d_fnend(3, dev, "SDIO func %p\n", func);
+}
+
+enum {
+	I2400MS_INTEL_VID = 0x89,
+};
+
+static
+const struct sdio_device_id i2400ms_sdio_ids[] = {
+	/* Intel: i2400m WiMAX over SDIO */
+	{ SDIO_DEVICE(I2400MS_INTEL_VID, 0x1402) },
+	{ }, 			/* end: all zeroes */
+};
+MODULE_DEVICE_TABLE(sdio, i2400ms_sdio_ids);
+
+
+static
+struct sdio_driver i2400m_sdio_driver = {
+	.name		= KBUILD_MODNAME,
+	.probe		= i2400ms_probe,
+	.remove		= i2400ms_remove,
+	.id_table	= i2400ms_sdio_ids,
+};
+
+
+static
+int __init i2400ms_driver_init(void)
+{
+	return sdio_register_driver(&i2400m_sdio_driver);
+}
+module_init(i2400ms_driver_init);
+
+
+static
+void __exit i2400ms_driver_exit(void)
+{
+	flush_scheduled_work();	/* for the stuff we schedule */
+	sdio_unregister_driver(&i2400m_sdio_driver);
+}
+module_exit(i2400ms_driver_exit);
+
+
+MODULE_AUTHOR("Intel Corporation <[email protected]>");
+MODULE_DESCRIPTION("Intel 2400M WiMAX networking for SDIO");
+MODULE_LICENSE("GPL");
+MODULE_FIRMWARE(I2400MS_FW_FILE_NAME);
Signature · 1 line
1.5.6.5
#70 lore raw

PATCH 34/39 i2400m/SDIO: firmware upload backend

In reply to Inaky Perez-Gonzalez

This implements the backends for the generic driver (i2400m) to be able to load firmware to the SDIO device.

---
 drivers/net/wimax/i2400m/sdio-fw.c |  224 ++++++++++++++++++++++++++++++++++++
 1 files changed, 224 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/sdio-fw.c
drivers/net/wimax/i2400m/sdio-fw.c new file +224 -0
new file mode 100644
index 0000000..8e3a286
@@ -0,0 +1,224 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * Firmware uploader's SDIO specifics
+ *
+ *
+ * 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 <[email protected]>
+ * Yanir Lubetkin <[email protected]>
+ * Inaky Perez-Gonzalez <[email protected]>
+ *  - Initial implementation
+ *
+ * Inaky Perez-Gonzalez <[email protected]>
+ *  - Bus generic/specific split for USB
+ *
+ * Dirk Brandewie <[email protected]>
+ *  - Initial implementation for SDIO
+ *
+ * Inaky Perez-Gonzalez <[email protected]>
+ *  - SDIO rehash for changes in the bus-driver model
+ *
+ * THE PROCEDURE
+ *
+ * See fw.c for the generic description of this procedure.
+ *
+ * This file implements only the SDIO specifics. It boils down to how
+ * to send a command and waiting for an acknowledgement from the
+ * device. We do polled reads.
+ *
+ * COMMAND EXECUTION
+ *
+ * THe generic firmware upload code will call i2400m_bus_bm_cmd_send()
+ * to send commands.
+ *
+ * The SDIO devices expects things in 256 byte blocks, so it will pad
+ * it, compute the checksum (if needed) and pass it to SDIO.
+ *
+ * ACK RECEPTION
+ *
+ * This works in polling mode -- the fw loader says when to wait for
+ * data and for that it calls i2400ms_bus_bm_wait_for_ack().
+ *
+ * This will poll the device for data until it is received. We need to
+ * receive at least as much bytes as where asked for (although it'll
+ * always be a multiple of 256 bytes).
+ */
+#include <linux/mmc/sdio_func.h>
+#include "i2400m-sdio.h"
+
+
+#define D_SUBMODULE sdio_fw
+#include "sdio-debug-levels.h"
+
+/*
+ * Send a boot-mode command to the SDIO function
+ *
+ * We use a bounce buffer (i2400m->bm_cmd_buf) because we need to
+ * touch the header if the RAW flag is not set.
+ *
+ * @flags: pass thru from i2400m_bm_cmd()
+ * @return: cmd_size if ok, < 0 errno code on error.
+ *
+ * Note the command is padded to the SDIO block size for the device.
+ */
+ssize_t i2400ms_bus_bm_cmd_send(struct i2400m *i2400m,
+				const struct i2400m_bootrom_header *_cmd,
+				size_t cmd_size, int flags)
+{
+	ssize_t result;
+	struct device *dev = i2400m_dev(i2400m);
+	struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	int opcode = _cmd == NULL ? -1 : i2400m_brh_get_opcode(_cmd);
+	struct i2400m_bootrom_header *cmd;
+	/* SDIO restriction */
+	size_t cmd_size_a = ALIGN(cmd_size, I2400MS_BLK_SIZE);
+
+	d_fnstart(5, dev, "(i2400m %p cmd %p size %zu)\n",
+		  i2400m, _cmd, cmd_size);
+	result = -E2BIG;
+	if (cmd_size > I2400M_BM_CMD_BUF_SIZE)
+		goto error_too_big;
+
+	memcpy(i2400m->bm_cmd_buf, _cmd, cmd_size);	/* Prep command */
+	cmd = i2400m->bm_cmd_buf;
+	if (cmd_size_a > cmd_size)			/* Zero pad space */
+		memset(i2400m->bm_cmd_buf + cmd_size, 0, cmd_size_a - cmd_size);
+	if ((flags & I2400M_BM_CMD_RAW) == 0) {
+		if (WARN_ON(i2400m_brh_get_response_required(cmd) == 0))
+			dev_warn(dev, "SW BUG: response_required == 0\n");
+		i2400m_bm_cmd_prepare(cmd);
+	}
+	d_printf(4, dev, "BM cmd %d: %zu bytes (%zu padded)\n",
+		 opcode, cmd_size, cmd_size_a);
+	d_dump(5, dev, cmd, cmd_size);
+
+	sdio_claim_host(i2400ms->func);			/* Send & check */
+	result = sdio_memcpy_toio(i2400ms->func, I2400MS_DATA_ADDR,
+				  i2400m->bm_cmd_buf, cmd_size_a);
+	sdio_release_host(i2400ms->func);
+	if (result < 0) {
+		dev_err(dev, "BM cmd %d: cannot send: %ld\n",
+			opcode, (long) result);
+		goto error_cmd_send;
+	}
+	result = cmd_size;
+error_cmd_send:
+error_too_big:
+	d_fnend(5, dev, "(i2400m %p cmd %p size %zu) = %d\n",
+		i2400m, _cmd, cmd_size, (int) result);
+	return result;
+}
+
+
+/*
+ * Read an ack from the device's boot-mode (polling)
+ *
+ * @i2400m:
+ * @_ack: pointer to where to store the read data
+ * @ack_size: how many bytes we should read
+ *
+ * Returns: < 0 errno code on error; otherwise, amount of received bytes.
+ *
+ * The ACK for a BM command is always at least sizeof(*ack) bytes, so
+ * check for that. We don't need to check for device reboots
+ *
+ * NOTE: We do an artificial timeout of 1 sec over the SDIO timeout;
+ *     this way we have control over it...there is no way that I know
+ *     of setting an SDIO transaction timeout.
+ */
+ssize_t i2400ms_bus_bm_wait_for_ack(struct i2400m *i2400m,
+				    struct i2400m_bootrom_header *ack,
+				    size_t ack_size)
+{
+	int result;
+	ssize_t rx_size;
+	u64 timeout;
+	struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+
+	BUG_ON(sizeof(*ack) > ack_size);
+
+	d_fnstart(5, dev, "(i2400m %p ack %p size %zu)\n",
+		  i2400m, ack, ack_size);
+
+	timeout = get_jiffies_64() + 2 * HZ;
+	sdio_claim_host(func);
+	while (1) {
+		if (time_after64(get_jiffies_64(), timeout)) {
+			rx_size = -ETIMEDOUT;
+			dev_err(dev, "timeout waiting for ack data\n");
+			goto error_timedout;
+		}
+
+		/* Find the RX size, check if it fits or not -- it if
+		 * doesn't fit, fail, as we have no way to dispose of
+		 * the extra data. */
+		rx_size = __i2400ms_rx_get_size(i2400ms);
+		if (rx_size < 0)
+			goto error_rx_get_size;
+		result = -ENOSPC;		/* Check it fits */
+		if (rx_size < sizeof(*ack)) {
+			rx_size = -EIO;
+			dev_err(dev, "HW BUG? received is too small (%zu vs "
+				"%zu needed)\n", sizeof(*ack), rx_size);
+			goto error_too_small;
+		}
+		if (rx_size > I2400M_BM_ACK_BUF_SIZE) {
+			dev_err(dev, "SW BUG? BM_ACK_BUF is too small (%u vs "
+				"%zu needed)\n", I2400M_BM_ACK_BUF_SIZE,
+				rx_size);
+			goto error_too_small;
+		}
+
+		/* Read it */
+		result = sdio_memcpy_fromio(func, i2400m->bm_ack_buf,
+					    I2400MS_DATA_ADDR, rx_size);
+		if (result == -ETIMEDOUT || result == -ETIME)
+			continue;
+		if (result < 0) {
+			dev_err(dev, "BM SDIO receive (%zu B) failed: %d\n",
+				rx_size, result);
+			goto error_read;
+		} else
+			break;
+	}
+	rx_size = min((ssize_t)ack_size, rx_size);
+	memcpy(ack, i2400m->bm_ack_buf, rx_size);
+error_read:
+error_too_small:
+error_rx_get_size:
+error_timedout:
+	sdio_release_host(func);
+	d_fnend(5, dev, "(i2400m %p ack %p size %zu) = %ld\n",
+		i2400m, ack, ack_size, (long) rx_size);
+	return rx_size;
+}
Signature · 1 line
1.5.6.5
#71 lore raw

PATCH 35/39 i2400m/SDIO: read transactions from the SDIO device

In reply to Inaky Perez-Gonzalez

This code implements reading from the SDIO device; when data is ready the SDIO IRQ is fired and that will allocate an skb, put all the data there and then pass it to the generic driver for processing and delivery.

---
 drivers/net/wimax/i2400m/sdio-rx.c |  255 ++++++++++++++++++++++++++++++++++++
 1 files changed, 255 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/sdio-rx.c
drivers/net/wimax/i2400m/sdio-rx.c new file +255 -0
new file mode 100644
index 0000000..237279d
@@ -0,0 +1,255 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * SDIO RX handling
+ *
+ *
+ * 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 <[email protected]>
+ * Dirk Brandewie <[email protected]>
+ *  - Initial implementation
+ *
+ *
+ * This handles the RX path on SDIO.
+ *
+ * The SDIO bus driver calls the "irq" routine when data is available.
+ * This is not a traditional interrupt routine since the SDIO bus
+ * driver calls us from its irq thread context.  Because of this
+ * sleeping in the SDIO RX IRQ routine is okay.
+ *
+ * From there on, we obtain the size of the data that is available,
+ * allocate an skb, copy it and then pass it to the generic driver's
+ * RX routine [i2400m_rx()].
+ *
+ * ROADMAP
+ *
+ * i2400ms_irq()
+ *   i2400ms_rx()
+ *     __i2400ms_rx_get_size()
+ *     i2400m_rx()
+ *
+ * i2400ms_rx_setup()
+ *
+ * i2400ms_rx_release()
+ */
+#include <linux/workqueue.h>
+#include <linux/wait.h>
+#include <linux/skbuff.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/sdio_func.h>
+#include "i2400m-sdio.h"
+
+#define D_SUBMODULE sdio_rx
+#include "sdio-debug-levels.h"
+
+
+/*
+ * Read and return the amount of bytes available for RX
+ *
+ * The RX size has to be read like this: byte reads of three
+ * sequential locations; then glue'em together.
+ *
+ * sdio_readl() doesn't work.
+ */
+ssize_t __i2400ms_rx_get_size(struct i2400ms *i2400ms)
+{
+	int ret, cnt, val;
+	ssize_t rx_size;
+	unsigned xfer_size_addr;
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &i2400ms->func->dev;
+
+	d_fnstart(7, dev, "(i2400ms %p)\n", i2400ms);
+	xfer_size_addr = I2400MS_INTR_GET_SIZE_ADDR;
+	rx_size = 0;
+	for (cnt = 0; cnt < 3; cnt++) {
+		val = sdio_readb(func, xfer_size_addr + cnt, &ret);
+		if (ret < 0) {
+			dev_err(dev, "RX: Can't read byte %d of RX size from "
+				"0x%08x: %d\n", cnt, xfer_size_addr + cnt, ret);
+			rx_size = ret;
+			goto error_read;
+		}
+		rx_size = rx_size << 8 | (val & 0xff);
+	}
+	d_printf(6, dev, "RX: rx_size is %ld\n", (long) rx_size);
+error_read:
+	d_fnend(7, dev, "(i2400ms %p) = %ld\n", i2400ms, (long) rx_size);
+	return rx_size;
+}
+
+
+/*
+ * Read data from the device (when in normal)
+ *
+ * Allocate an SKB of the right size, read the data in and then
+ * deliver it to the generic layer.
+ *
+ * We also check for a reboot barker. That means the device died and
+ * we have to reboot it.
+ */
+static
+void i2400ms_rx(struct i2400ms *i2400ms)
+{
+	int ret;
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+	struct i2400m *i2400m = &i2400ms->i2400m;
+	struct sk_buff *skb;
+	ssize_t rx_size;
+
+	d_fnstart(7, dev, "(i2400ms %p)\n", i2400ms);
+	rx_size = __i2400ms_rx_get_size(i2400ms);
+	if (rx_size < 0) {
+		ret = rx_size;
+		goto error_get_size;
+	}
+	ret = -ENOMEM;
+	skb = alloc_skb(rx_size, GFP_ATOMIC);
+	if (NULL == skb) {
+		dev_err(dev, "RX: unable to alloc skb\n");
+		goto error_alloc_skb;
+	}
+
+	ret = sdio_memcpy_fromio(func, skb->data,
+				 I2400MS_DATA_ADDR, rx_size);
+	if (ret < 0) {
+		dev_err(dev, "RX: SDIO data read failed: %d\n", ret);
+		goto error_memcpy_fromio;
+	}
+	/* Check if device has reset */
+	if (!memcmp(skb->data, i2400m_NBOOT_BARKER,
+		    sizeof(i2400m_NBOOT_BARKER))
+	    || !memcmp(skb->data, i2400m_SBOOT_BARKER,
+		       sizeof(i2400m_SBOOT_BARKER))) {
+		ret = i2400m_dev_reset_handle(i2400m);
+		kfree_skb(skb);
+	} else {
+		skb_put(skb, rx_size);
+		i2400m_rx(i2400m, skb);
+	}
+	d_fnend(7, dev, "(i2400ms %p) = void\n", i2400ms);
+	return;
+
+error_memcpy_fromio:
+	kfree_skb(skb);
+error_alloc_skb:
+error_get_size:
+	d_fnend(7, dev, "(i2400ms %p) = %d\n", i2400ms, ret);
+	return;
+}
+
+
+/*
+ * Process an interrupt from the SDIO card
+ *
+ * FIXME: need to process other events that are not just ready-to-read
+ *
+ * Checks there is data ready and then proceeds to read it.
+ */
+static
+void i2400ms_irq(struct sdio_func *func)
+{
+	int ret;
+	struct i2400ms *i2400ms = sdio_get_drvdata(func);
+	struct i2400m *i2400m = &i2400ms->i2400m;
+	struct device *dev = &func->dev;
+	int val;
+
+	d_fnstart(6, dev, "(i2400ms %p)\n", i2400ms);
+	val = sdio_readb(func, I2400MS_INTR_STATUS_ADDR, &ret);
+	if (ret < 0) {
+		dev_err(dev, "RX: Can't read interrupt status: %d\n", ret);
+		goto error_no_irq;
+	}
+	if (!val) {
+		dev_err(dev, "RX: BUG? got IRQ but no interrupt ready?\n");
+		goto error_no_irq;
+	}
+	sdio_writeb(func, 1, I2400MS_INTR_CLEAR_ADDR, &ret);
+	if (WARN_ON(i2400m->boot_mode != 0))
+		dev_err(dev, "RX: SW BUG? boot mode and IRQ is up?\n");
+	else
+		i2400ms_rx(i2400ms);
+error_no_irq:
+	d_fnend(6, dev, "(i2400ms %p) = void\n", i2400ms);
+	return;
+}
+
+
+/*
+ * Setup SDIO RX
+ *
+ * Hooks up the IRQ handler and then enables IRQs.
+ */
+int i2400ms_rx_setup(struct i2400ms *i2400ms)
+{
+	int result;
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+
+	d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms);
+	sdio_claim_host(func);
+	result = sdio_claim_irq(func, i2400ms_irq);
+	if (result < 0) {
+		dev_err(dev, "Cannot claim IRQ: %d\n", result);
+		goto error_irq_claim;
+	}
+	result = 0;
+	sdio_writeb(func, 1, I2400MS_INTR_ENABLE_ADDR, &result);
+	if (result < 0) {
+		sdio_release_irq(func);
+		dev_err(dev, "Failed to enable interrupts %d\n", result);
+	}
+error_irq_claim:
+	sdio_release_host(func);
+	d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result);
+	return result;
+}
+
+
+/*
+ * Tear down SDIO RX
+ *
+ * Disables IRQs in the device and removes the IRQ handler.
+ */
+void i2400ms_rx_release(struct i2400ms *i2400ms)
+{
+	int result;
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+
+	d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms);
+	sdio_claim_host(func);
+	sdio_writeb(func, 0, I2400MS_INTR_ENABLE_ADDR, &result);
+	sdio_release_irq(func);
+	sdio_release_host(func);
+	d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result);
+}
Signature · 1 line
1.5.6.5
#72 lore raw

PATCH 36/39 i2400m/SDIO: write transactions to the SDIO device

In reply to Inaky Perez-Gonzalez

Implements the backend so that the generic driver can send data to the SDIO device. When kicked by the generic driver, this will schedule work on a driver-specific workqueue that pulls data from the TX FIFO and sends it to the device until it drains it.

---
 drivers/net/wimax/i2400m/sdio-tx.c |  153 ++++++++++++++++++++++++++++++++++++
 1 files changed, 153 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/i2400m/sdio-tx.c
drivers/net/wimax/i2400m/sdio-tx.c new file +153 -0
new file mode 100644
index 0000000..8f29a3b
@@ -0,0 +1,153 @@
+/*
+ * Intel Wireless WiMAX Connection 2400m
+ * SDIO TX transaction backends
+ *
+ *
+ * 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 <[email protected]>
+ * Dirk Brandewie <[email protected]>
+ *  - Initial implementation
+ *
+ *
+ * Takes the TX messages in the i2400m's driver TX FIFO and sends them
+ * to the device until there are no more.
+ *
+ * If we fail sending the message, we just drop it. There isn't much
+ * we can do at this point. Most of the traffic is network, which has
+ * recovery methods for dropped packets.
+ *
+ * The SDIO functions are not atomic, so we can't run from the context
+ * where i2400m->bus_tx_kick() [i2400ms_bus_tx_kick()] is being called
+ * (some times atomic). Thus, the actual TX work is deferred to a
+ * workqueue.
+ *
+ * ROADMAP
+ *
+ * i2400ms_bus_tx_kick()
+ *   i2400ms_tx_submit()     [through workqueue]
+ *
+ * i2400m_tx_setup()
+ *
+ * i2400m_tx_release()
+ */
+#include <linux/mmc/sdio_func.h>
+#include "i2400m-sdio.h"
+
+#define D_SUBMODULE sdio_tx
+#include "sdio-debug-levels.h"
+
+
+/*
+ * Pull TX transations from the TX FIFO and send them to the device
+ * until there are no more.
+ */
+static
+void i2400ms_tx_submit(struct work_struct *ws)
+{
+	int result;
+	struct i2400ms *i2400ms = container_of(ws, struct i2400ms, tx_worker);
+	struct i2400m *i2400m = &i2400ms->i2400m;
+	struct sdio_func *func = i2400ms->func;
+	struct device *dev = &func->dev;
+	struct i2400m_msg_hdr *tx_msg;
+	size_t tx_msg_size;
+
+	d_fnstart(4, dev, "(i2400ms %p, i2400m %p)\n", i2400ms, i2400ms);
+
+	while (NULL != (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size))) {
+		d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size);
+		d_dump(5, dev, tx_msg, tx_msg_size);
+
+		sdio_claim_host(func);
+		result = sdio_memcpy_toio(func, 0, tx_msg, tx_msg_size);
+		sdio_release_host(func);
+
+		i2400m_tx_msg_sent(i2400m);
+
+		if (result < 0) {
+			dev_err(dev, "TX: cannot submit TX; tx_msg @%zu %zu B:"
+				" %d\n", (void *) tx_msg - i2400m->tx_buf,
+				tx_msg_size, result);
+		}
+
+		d_printf(2, dev, "TX: %zub submitted\n", tx_msg_size);
+	}
+
+	d_fnend(4, dev, "(i2400ms %p) = void\n", i2400ms);
+}
+
+
+/*
+ * The generic driver notifies us that there is data ready for TX
+ *
+ * Schedule a run of i2400ms_tx_submit() to handle it.
+ */
+void i2400ms_bus_tx_kick(struct i2400m *i2400m)
+{
+	struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
+	struct device *dev = &i2400ms->func->dev;
+
+	d_fnstart(3, dev, "(i2400m %p) = void\n", i2400m);
+
+	/* schedule tx work, this is because tx may block, therefore
+	 * it has to run in a thread context.
+	 */
+	queue_work(i2400ms->tx_workqueue, &i2400ms->tx_worker);
+
+	d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
+}
+
+int i2400ms_tx_setup(struct i2400ms *i2400ms)
+{
+	int result;
+	struct device *dev = &i2400ms->func->dev;
+	struct i2400m *i2400m = &i2400ms->i2400m;
+
+	d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms);
+
+	INIT_WORK(&i2400ms->tx_worker, i2400ms_tx_submit);
+	snprintf(i2400ms->tx_wq_name, sizeof(i2400ms->tx_wq_name),
+		 "%s-tx", i2400m->wimax_dev.name);
+	i2400ms->tx_workqueue =
+		create_singlethread_workqueue(i2400ms->tx_wq_name);
+	if (NULL == i2400ms->tx_workqueue) {
+		dev_err(dev, "TX: failed to create workqueue\n");
+		result = -ENOMEM;
+	} else
+		result = 0;
+	d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result);
+	return result;
+}
+
+void i2400ms_tx_release(struct i2400ms *i2400ms)
+{
+	destroy_workqueue(i2400ms->tx_workqueue);
+}
Signature · 1 line
1.5.6.5
#73 lore raw

PATCH 37/39 i2400m: Makefile and Kconfig

In reply to Inaky Perez-Gonzalez

This patch provides the Makefile and KConfig for the i2400m driver, integrating them into the WiMAX stack's Makefile and Kconfig.

---
 drivers/net/Kconfig               |    2 +
 drivers/net/Makefile              |    1 +
 drivers/net/wimax/Kconfig         |   17 +++++++++++++
 drivers/net/wimax/Makefile        |    2 +
 drivers/net/wimax/i2400m/Kconfig  |   49 +++++++++++++++++++++++++++++++++++++
 drivers/net/wimax/i2400m/Makefile |   28 +++++++++++++++++++++
 6 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/wimax/Kconfig
 create mode 100644 drivers/net/wimax/Makefile
 create mode 100644 drivers/net/wimax/i2400m/Kconfig
 create mode 100644 drivers/net/wimax/i2400m/Makefile
drivers/net/Kconfig +2 -0
index 11f143f..f413d58 100644
@@ -2584,6 +2584,8 @@ source "drivers/net/tokenring/Kconfig"
 
 source "drivers/net/wireless/Kconfig"
 
+source "drivers/net/wimax/Kconfig"
+
 source "drivers/net/usb/Kconfig"
 
 source "drivers/net/pcmcia/Kconfig"
drivers/net/Makefile +1 -0
index f19acf8..3ac378f 100644
@@ -262,3 +262,4 @@ obj-$(CONFIG_NIU) += niu.o
 obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
 obj-$(CONFIG_SFC) += sfc/
 
+obj-y += wimax/
drivers/net/wimax/Kconfig new file +17 -0
new file mode 100644
index 0000000..30347e4
@@ -0,0 +1,17 @@
+#
+# WiMAX LAN device drivers configuration
+#
+
+
+comment "Enable WiMAX (Networking options) to see the WiMAX drivers"
+        depends on WIMAX = n
+
+if WIMAX
+
+menu "WiMAX Wireless Broadband devices"
+
+source "drivers/net/wimax/i2400m/Kconfig"
+
+endmenu
+
+endif
drivers/net/wimax/Makefile new file +2 -0
new file mode 100644
index 0000000..bda9430
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_WIMAX_I2400M)	+= i2400m/
drivers/net/wimax/i2400m/Kconfig new file +49 -0

49 lines not on this page · raw message

drivers/net/wimax/i2400m/Makefile new file +28 -0
new file mode 100644
index 0000000..7113a5f
@@ -0,0 +1,28 @@
+
+obj-$(CONFIG_WIMAX_I2400M) += i2400m.o
+obj-$(CONFIG_WIMAX_I2400M_USB) += i2400m-usb.o
+obj-$(CONFIG_WIMAX_I2400M_SDIO) += i2400m-sdio.o
+
+i2400m-objs :=		\
+	control.o	\
+	driver.o	\
+	fw.o		\
+	op-rfkill.o	\
+	sysfs.o		\
+	netdev.o	\
+	tx.o		\
+	rx.o
+
+i2400m-usb-objs :=		\
+	usb-fw.o		\
+	usb-notif.o		\
+	usb-tx.o		\
+	usb-rx.o		\
+	usb.o
+
+
+i2400m-sdio-objs := 		\
+	sdio.o      		\
+	sdio-tx.o   		\
+	sdio-fw.o	 	\
+	sdio-rx.o
Signature · 1 line
1.5.6.5
#74 lore raw

PATCH 38/39 wimax: export linux/wimax.h and linux/wimax/i2400m.h with headers_install

In reply to Inaky Perez-Gonzalez

These two files are what user space can use to establish communication with the WiMAX kernel API and to speak the Intel 2400m Wireless WiMAX connection's control protocol.

---
 include/linux/Kbuild       |    2 ++
 include/linux/wimax/Kbuild |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/wimax/Kbuild
include/linux/Kbuild +2 -0
index e531783..89079ff 100644
@@ -375,3 +375,5 @@ unifdef-y += xattr.h
 unifdef-y += xfrm.h
 
 objhdr-y += version.h
+header-y += wimax.h
+header-y += wimax/
include/linux/wimax/Kbuild new file +1 -0
new file mode 100644
index 0000000..3cb4f26
@@ -0,0 +1 @@
+header-y += i2400m.h
Signature · 1 line
1.5.6.5
#75 lore raw

PATCH 39/39 wimax/i2400m: add CREDITS and MAINTAINERS entries

In reply to Inaky Perez-Gonzalez

This patch adds entries for the original developers of the i2400m drivers and up-to-date maintainer entries.

---
 CREDITS     |   17 +++++++++++++++++
 MAINTAINERS |   16 ++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
CREDITS +17 -0
index b50db17..ae5b804 100644
@@ -464,6 +464,11 @@ S: 1200 Goldenrod Dr.
 S: Nampa, Idaho 83686
 S: USA
 
+N: Dirk J. Brandewie
+E: [email protected]
+E: [email protected]
+D: Intel Wireless WiMAX Connection 2400 SDIO driver
+
 N: Derrick J. Brashear
 E: [email protected]
 W: http://www.dementia.org/~shadow
@@ -2119,6 +2124,11 @@ N: H.J. Lu
 E: [email protected]
 D: GCC + libraries hacker
 
+N: Yanir Lubetkin
+E: [email protected]
+E: [email protected]
+D: Intel Wireless WiMAX Connection 2400 driver
+
 N: Michal Ludvig
 E: [email protected]
 E: [email protected]
@@ -2693,6 +2703,13 @@ S: RR #5, 497 Pole Line Road
 S: Thunder Bay, Ontario
 S: CANADA P7C 5M9
 
+N: Inaky Perez-Gonzalez
+E: [email protected]
+E: [email protected]
+E: [email protected]
+D: WiMAX stack
+D: Intel Wireless WiMAX Connection 2400 driver
+
 N: Yuri Per
 E: [email protected]
 D: Some smbfs fixes
MAINTAINERS +16 -0
index 8e0777f..7950b97 100644
@@ -2299,6 +2299,14 @@ W:	http://lists.sourceforge.net/mailman/listinfo/ipw2100-devel
 W:	http://ipw2200.sourceforge.net
 S:	Supported
 
+INTEL WIRELESS WIMAX CONNECTION 2400
+P:	Inaky Perez-Gonzalez
+M:	[email protected]
+M:	[email protected]
+L:	[email protected]
+S:	Supported
+W:	http://linuxwimax.org
+
 INTEL WIRELESS WIFI LINK (iwlwifi)
 P:	Zhu Yi
 M:	[email protected]
@@ -4704,6 +4712,14 @@ M:	[email protected]
 L:	[email protected]
 S:	Maintained
 
+WIMAX STACK
+P:	Inaky Perez-Gonzalez
+M:	[email protected]
+M:	[email protected]
+L:	[email protected]
+S:	Supported
+W:	http://linuxwimax.org
+
 WIMEDIA LLC PROTOCOL (WLP) SUBSYSTEM
 P:	David Vrabel
 M:	[email protected]
Signature · 1 line
1.5.6.5
maintainer
#76 lore raw
In reply to Inaky Perez-Gonzalez

From: Inaky Perez-Gonzalez <[email protected]>
Date: Wed, 26 Nov 2008 14:40:19 -0800

Quoted 8 lines

Changes since v1:

- (Stephen Hemminger) don't use bitfields in struct wimax_dev

- (Stephen Hemminger) don't use the interface name for the generic netlink family, as it might change on if rename. Change to use the interface index.

Quoted 5 lines

- (David Miller) move the WiMAX stack to net/wimax

- misc checkpatch fixes, kconfig cleanups.

- use DEFINE_SPINLOCK

I'm fine with this, so feel free to merge this stuff in via the USB stack (due to the dependencies there).

Thanks!

#77 lore raw
Quoted 11 lines · David Miller

From: Inaky Perez-Gonzalez <[email protected]>
Date: Wed, 26 Nov 2008 14:40:19 -0800

Quoted 8 lines

Changes since v1:

- (Stephen Hemminger) don't use bitfields in struct wimax_dev

- (Stephen Hemminger) don't use the interface name for the generic netlink family, as it might change on if rename. Change to use the interface index.

Quoted 8 lines
Quoted 5 lines

- (David Miller) move the WiMAX stack to net/wimax

- misc checkpatch fixes, kconfig cleanups.

- use DEFINE_SPINLOCK

I'm fine with this, so feel free to merge this stuff in via the USB stack (due to the dependencies there).

Thanks David -- I'll wait for some feedback some guys told me they were going to send and submit (latest on Monday) the patchset to Greg KH.

Signature · 1 line
Inaky
#78 lore raw
In reply to Inaky Perez-Gonzalez

On Wednesday 26 of November 2008, Inaky Perez-Gonzalez wrote:

[...]

Quoted 3 lines

driver for the Intel 2400m Wireless WiMAX
connection to the tree. We'd like to get it in for the 2.6.29 merge window.

Is 802.11b/g also supported by this driver (or other existing linux driver) ?

AFAIK these intel cards do support 802.11b/g, too.

(I asked this before but vger bounced my email, so resending)

Signature · 2 lines
Arkadiusz Miśkiewicz        PLD/Linux Team
arekm / maven.pl            http://ftp.pld-linux.org/
#79 lore raw

Hi Arkadiusz,

Quoted 7 lines
Quoted 3 lines

driver for the Intel 2400m Wireless WiMAX
connection to the tree. We'd like to get it in for the 2.6.29 merge window.

Is 802.11b/g also supported by this driver (or other existing linux driver) ?

AFAIK these intel cards do support 802.11b/g, too.

some of them are multi-function devices and Linux binds drivers on a per function (or in the USB term, interface). So in case of multi-radio cards you need separate drivers for each function. The 2400m driver is only responsible for the WiMAX function.

Regards

Marcel

#80 lore raw
In reply to Inaky Perez-Gonzalez

Hi,

Thanks for this work. I don't personally have much of an interest in wimax, so I don't really care what you do, so take things I have said and will say with a grain of salt. It's not my intention to say "you've done it all wrong", but more to offer observations on how these things were done in wifi and how it went all wrong there, requiring a complete rewrite recently.

Conceptually, I think wimax is now at a point where wifi was many years ago with the first wireless drivers: everything was full-mac, wext ioctls were written to go directly to the driver. Then ipw2x00 came along, more functionality was moved to the host (yes, you say this won't happen with wimax, but I think it will, eventually, if wimax gets to be popular enough. never say never), and wext got more messy. Wext even was defining actual operations, as undefined as they often were, you're not even doing that.

Quoted 4 lines

* The WiMAX kernel stack

The (kernel) WiMAX stack is (as of now) very basic; it conforms a "control plane", in a similar fashion to cfg80211.

I don't think you can say it's like cfg80211, cfg80211 in fact does a lot more than the wimax "stack", it can validate parameters for example, and provides actual operations (key operations, peer operations, scanning [soon], ...) rather than just a transport to the driver. As I've said on the relevant patch, I'd love to see the wimax stack take more of that direction.

Quoted 3 lines

We still don't know what's going to be a good abstraction layer because so far, we have only see one WiMAX device for which we could implement support.

I don't see that as much of a problem. Many of the commands you have defined for the i2400m driver are very generic, for example:
* I2400M_MT_GET_SCAN_RESULT
* I2400M_MT_SET_SCAN_PARAM (why are those not part of the SCAN command btw?)
* I2400M_MT_CMD_SCAN
* I2400M_MT_CMD_CONNECT
* I2400M_MT_CMD_DISCONNECT
* I2400M_MT_GET_LINK_STATUS
* I2400M_MT_GET_STATISTICS
* I2400M_MT_GET_STATE
* I2400M_MT_SET_INIT_CONFIG
* I2400M_MT_CMD_INIT
* I2400M_MT_CMD_ENTER_POWERSAVE
* all the *EAP* seem applicable to devices that don't offload all of that to the host, and those devices that do will just need new, more lower level, primitives, compare for example the wext WPA stuff which handles both the PS3 wifi that does this in the "hardware" and normal wireless hw that leaves it to wpa supplicant
* (and more)

They will surely apply to any wimax device, or to a soft wimax stack if that should ever happen. And for those commands that don't, it's easy to see whether or not a device supports them and use different, possibly more generic, ones; say a device doesn't support scanning, it'll surely support connecting if you know the network already.

Conceptually, I'm not sure you should call the wimax stack a "stack" at all, so far it seems more like a "transport" that really should be part of the driver. It's not defining any *wimax* commands, but it's only defining the transport for those *driver-specific* commands.

This is the biggest issue I see here. I don't see how the stack helps anyone implement a driver for a new device. Sure, they won't have to come up with a new transport, write less lines of generic netlink code, but ultimately that's not the hard part, the hard part is getting the relevant operations right etc.

Quoted 5 lines

So the current abstraction layer provides a low-level WiMAX API with means for resetting, monitoring state changes, controlling rfkill and sending messages to the driver (in a driver specific format) back and forth (more on this below). The documentation in include/net/wimax.h provides more information.

This really means you're putting the actual "driver", the piece that does the hardware abstraction, into userspace. And in a binary daemon even, afaict. This was quickly shot down with ipw3945/4965, not sure why nobody has cared here so far. Maybe because you're actually planning to open source that part.

Quoted 4 lines

The driver for the 2400m sits below the stack, providing the back end operations to drive control (reset, rfkill, message passing) and feeding it state change information. On the other side, the 2400m driver connects to netdev, where it emulates an ethernet device (*1).

Couldn't the stack provide more functionality here? Somewhere else you speak of using ethernet vs. rawip, couldn't the stack do that translation, possibly even allowing both rawip and ethernet to coexist, or be switchable at runtime if you have a working dhcp client?

johannes

#81 lore raw

Hi Johannes,

Quoted 7 lines

Thanks for this work. I don't personally have much of an interest in wimax, so I don't really care what you do, so take things I have said and will say with a grain of salt. It's not my intention to say "you've done it all wrong", but more to offer observations on how these things were done in wifi and how it went all wrong there, requiring a complete rewrite recently.

Quoted 8 lines

Conceptually, I think wimax is now at a point where wifi was many years ago with the first wireless drivers: everything was full-mac, wext ioctls were written to go directly to the driver. Then ipw2x00 came along, more functionality was moved to the host (yes, you say this won't happen with wimax, but I think it will, eventually, if wimax gets to be popular enough. never say never), and wext got more messy. Wext even was defining actual operations, as undefined as they often were, you're not even doing that.

some parts of the WiMAX specification are still undergoing re-writes and we really don't know for sure what is coming. We just have to start somewhere.

Quoted 11 lines

They will surely apply to any wimax device, or to a soft wimax stack if that should ever happen. And for those commands that don't, it's easy to see whether or not a device supports them and use different, possibly more generic, ones; say a device doesn't support scanning, it'll surely support connecting if you know the network already.

Conceptually, I'm not sure you should call the wimax stack a "stack" at all, so far it seems more like a "transport" that really should be part of the driver. It's not defining any *wimax* commands, but it's only defining the transport for those *driver-specific* commands.

Quoted 5 lines

This is the biggest issue I see here. I don't see how the stack helps anyone implement a driver for a new device. Sure, they won't have to come up with a new transport, write less lines of generic netlink code, but ultimately that's not the hard part, the hard part is getting the relevant operations right etc.

The idea is to make the WiMAX subsystem more generic and create something similar to what we have with mac80211/cfg80211 and also inside Bluetooth. This is the common starting point and next step is to move functionality that has been identified as generic and common from the driver into the subsystem.

I prefer if we do this development inside the kernel tree instead of externally. One big thing we should have learned from mac80211 is that developing a full stack outside the kernel source tree is not really working out. We should apply the same model as we did for ext4 or what Greg is doing with his staging tree.

Quoted 11 lines
Quoted 5 lines

So the current abstraction layer provides a low-level WiMAX API with means for resetting, monitoring state changes, controlling rfkill and sending messages to the driver (in a driver specific format) back and forth (more on this below). The documentation in include/net/wimax.h provides more information.

This really means you're putting the actual "driver", the piece that does the hardware abstraction, into userspace. And in a binary daemon even, afaict. This was quickly shot down with ipw3945/4965, not sure why nobody has cared here so far. Maybe because you're actually planning to open source that part.

It has been open source since quite some time now at linuxwimax.org (exception are some tiny binary pieces).

Quoted 9 lines
Quoted 4 lines

The driver for the 2400m sits below the stack, providing the back end operations to drive control (reset, rfkill, message passing) and feeding it state change information. On the other side, the 2400m driver connects to netdev, where it emulates an ethernet device (*1).

Couldn't the stack provide more functionality here? Somewhere else you speak of using ethernet vs. rawip, couldn't the stack do that translation, possibly even allowing both rawip and ethernet to coexist, or be switchable at runtime if you have a working dhcp client?

Either we do Ethernet framing or a pure IP device. I am for the pure IP device with a separate ARP header (which we managed to get allocated). Wrapping everything into Ethernet only because dhclient is broken is not an answer. An alternate option would be a point-to-point device like the HSO driver or PPP is using. However then the usage of DHCP becomes a lot more trickier. Don't ask me why WiMAX decided to go for DHCP and not did the IP stuff in-band.

Regards

Marcel

#82 lore raw
Quoted 6 lines

The idea is to make the WiMAX subsystem more generic and create something similar to what we have with mac80211/cfg80211 and also inside Bluetooth. This is the common starting point and next step is to move functionality that has been identified as generic and common from the driver into the subsystem.

The problem is with the current stack design this isn't really possible, since the stack only provides like three real commands:
* talk to driver
* reset device
* do rfkill (though I'm not sure why this is needed)

Quoted 5 lines

I prefer if we do this development inside the kernel tree instead of externally. One big thing we should have learned from mac80211 is that developing a full stack outside the kernel source tree is not really working out. We should apply the same model as we did for ext4 or what Greg is doing with his staging tree.

The problem with that is that the stack is setting APIs in stone that are, if you ask me, suboptimal. Once we add those, I don't see how we can migrate away from a "command handled by driver" model towards a "command handled by stack and appropriate driver callback called" model, which would be more like cfg80211/nl80211 rather than iwpriv.

Quoted 2 lines

It has been open source since quite some time now at linuxwimax.org (exception are some tiny binary pieces).

Ok, sorry, I thought there was a bunch of binary code still.

johannes

#83 lore raw
Quoted 24 lines · Johannes Berg
Quoted 5 lines

The idea is to make the WiMAX subsystem more generic and create something similar to what we have with mac80211/cfg80211 and also inside Bluetooth. This is the common starting point and next step is to move functionality that has been identified as generic and common from the driver into the subsystem.

The problem is with the current stack design this isn't really possible, since the stack only provides like three real commands:
* talk to driver
* reset device
* do rfkill (though I'm not sure why this is needed)

Quoted 5 lines

I prefer if we do this development inside the kernel tree instead of externally. One big thing we should have learned from mac80211 is that developing a full stack outside the kernel source tree is not really working out. We should apply the same model as we did for ext4 or what Greg is doing with his staging tree.

The problem with that is that the stack is setting APIs in stone that are, if you ask me, suboptimal. Once we add those, I don't see how we can migrate away from a "command handled by driver" model towards a "command handled by stack and appropriate driver callback called" model, which would be more like cfg80211/nl80211 rather than iwpriv.

Quoted 4 lines
Quoted 2 lines

It has been open source since quite some time now at linuxwimax.org (exception are some tiny binary pieces).

Ok, sorry, I thought there was a bunch of binary code still.

The 802.1x supplicant still is.

Dan

#84 lore raw
In reply to Marcel Holtmann
Quoted 5 lines · Marcel Holtmann

Either we do Ethernet framing or a pure IP device. I am for the pure IP device with a separate ARP header (which we managed to get allocated). Wrapping everything into Ethernet only because dhclient is broken is not an answer. An alternate option would be a point-to-point

It's not only dhclient, but also lots of other raw packet users like tcpdump etc.

Quoted 2 lines

device like the HSO driver or PPP is using. However then the usage of DHCP becomes a lot more trickier.

I personally think user convenience is more important at least short term. It's also not that the pseudo header is that much overhead.

-Andi

Signature · 1 line
[email protected]
#85 lore raw
Quoted 9 lines · Andi Kleen
Quoted 5 lines · Marcel Holtmann

Either we do Ethernet framing or a pure IP device. I am for the pure IP device with a separate ARP header (which we managed to get allocated). Wrapping everything into Ethernet only because dhclient is broken is not an answer. An alternate option would be a point-to-point

It's not only dhclient, but also lots of other raw packet users like tcpdump etc.

tcpdump works fine on almost anything you throw at it, I have a hard time believing it wouldn't be able to decompose rawip easily.

johannes

#86 lore raw
In reply to Johannes Berg

Hi There

Quoted 8 lines · Johannes Berg

Hi,

Thanks for this work. I don't personally have much of an interest in wimax, so I don't really care what you do, so take things I have said and will say with a grain of salt. It's not my intention to say "you've done it all wrong", but more to offer observations on how these things were done in wifi and how it went all wrong there, requiring a complete rewrite recently.

Thanks, I really appreciate the level of review (from you, Patrik and Thomas).

Many of the comments you guys have are solved by documenting why things were done, others require work, others are remnants that I missed to clean up.

It's Thanksgiving weekend here in the US, so I most probably will wait for Monday to address all your guys concerns -- just sending this so you don't think I don't care :) I do.

Signature · 1 line
Inaky
#87 lore raw
In reply to Johannes Berg
Quoted 3 lines · Johannes Berg

along, more functionality was moved to the host (yes, you say this won't happen with wimax, but I think it will, eventually, if wimax gets to be popular enough. never say never), and wext got more

Agree, never say never; but these are the reasons why I highly doubt it'll ever happen:

- WiMAX spectrum is heavily regulated

- Operators won't allow it. They want tightly safe, certified and tested firmwares/devices that adhere to the standard so they can make sure devices don't mess up a single hertz as that means lost money, especially with a radio that can beam over miles.

- Certification (required) of stacks make it almost impossible to maintain a soft implementation.

Quoted 2 lines

messy. Wext even was defining actual operations, as undefined as they often were, you're not even doing that.

Why would I define them when I don't even know how they are going to look like? It is not as simple as it looks.

The basics that aren't covered in current's kernel API are scan, connect, disconnect. Disconnect is simple, but scan & connect? very much impossible to tell what common ground is going to be until more devices show up.

For scanning, some devices require to be told exactly where to scan in (as in which combination of band, fft width and coloring of the band). Some others don't. Then of course, the scan results might be operators? Network Service Providers? Network Access Providers? base station IDs? how do you stitch'em together? You need information to map from one to the other, and that is device specific depending on at which level they work. How to stich that information together depends on the network too (OMA-DM and provisining information help to compose this). If it is done at the device/firmware level or at the host level is device specific.

Connect has exactly the same levels of issues as scan: what do I connect to? A base station? a NAP or an NSP?

So back to the original question: I have no information to define such an interface at low level, so I am not defining it. Simple :/

Quoted 6 lines

I don't think you can say it's like cfg80211, cfg80211 in fact does a lot more than the wimax "stack", it can validate parameters for example, and provides actual operations (key operations, peer operations, scanning [soon], ...) rather than just a transport to the driver. As I've said on the relevant patch, I'd love to see the wimax stack take more of that direction.

If it has to happen, it will happen eventually. If it is a stack or not as of now and just a simple control interface, not that I really mind. It's just a name.

Quoted 2 lines

I don't see that as much of a problem. Many of the commands you have defined for the i2400m driver are very generic, for example:

As I said above, it is not so simple. They are not as generic as they look.

Quoted 5 lines

This is the biggest issue I see here. I don't see how the stack helps anyone implement a driver for a new device. Sure, they won't have to come up with a new transport, write less lines of generic netlink code, but ultimately that's not the hard part, the hard part is getting the relevant operations right etc.

I agree -- and that's the whole reason why the "stack" is there--because even if it doesn't look so hard, it's just a pain.

This way someone comes in with a need for a driver and then we can start deciding how to cut the scan & connect interfaces. Maybe it makes no sense to do it at the kernel level and it has to be done at user space, as the i2400m does it; then the kernel API stays the same...until another driver comes in...etc. Don't fix it if it ain't broke.

Quoted 5 lines

This really means you're putting the actual "driver", the piece that does the hardware abstraction, into userspace. And in a binary daemon even, afaict. This was quickly shot down with ipw3945/4965, not sure why nobody has cared here so far. Maybe because you're actually planning to open source that part.

Nope. I am putting the part that knows how to scan and connect in user space because it does not belong in kernel space. It is big and complex, needs permanent storage, requires complex crypto code and can really use a OMA-DM client to communicate with the network.

Not a binary, btw. Currently the supplicant is a binary, but that will change. The OMA-DM client daemon is also a binary as of now and we are still thinking how to fix that situation, as there are no open source equivalents. Luckily, it is kind of optional.

Quoted 5 lines

Couldn't the stack provide more functionality here? Somewhere else you speak of using ethernet vs. rawip, couldn't the stack do that translation, possibly even allowing both rawip and ethernet to coexist, or be switchable at runtime if you have a working dhcp client?

The stack is a control plane, not a data plane. Each driver implements data frame passing the way that is most optimal to the device it implements support for.

There is not good reason (as of now) that justifies the extra overhead that would be introduced by the "stack" doing it.

The only reason I would see that happening would be a mac80211 like case, where the stack is doing packet handling in a hypothetical soft-mac implementation. As I said above, I highly doubt that scenario.

Thanks,

Signature · 1 line
Inaky
#88 lore raw
Quoted 9 lines · Inaky Perez-Gonzalez
Quoted 3 lines · Johannes Berg

along, more functionality was moved to the host (yes, you say this won't happen with wimax, but I think it will, eventually, if wimax gets to be popular enough. never say never), and wext got more

Agree, never say never; but these are the reasons why I highly doubt it'll ever happen:

- WiMAX spectrum is heavily regulated

Well, to be fair 3.5GHz is "lightly regulated" here in the US, you just have to register your base station with the FCC and as long as nobody else has done so in your area, you win. The Intel parts don't support 3.5 GHz, but I'm sure somebody elses parts will in the future.

TowerStream has already deployed 3.5GHz fixed WiMAX gear here in Boston, though they are doing fixed access/T1-replacement for businesses, not a large consumer-focused mobile wimax network like XOHM/Clear.

Dan

Quoted 106 lines

- Operators won't allow it. They want tightly safe, certified and tested firmwares/devices that adhere to the standard so they can make sure devices don't mess up a single hertz as that means lost money, especially with a radio that can beam over miles.

- Certification (required) of stacks make it almost impossible to maintain a soft implementation.

Quoted 2 lines

messy. Wext even was defining actual operations, as undefined as they often were, you're not even doing that.

Why would I define them when I don't even know how they are going to look like? It is not as simple as it looks.

The basics that aren't covered in current's kernel API are scan, connect, disconnect. Disconnect is simple, but scan & connect? very much impossible to tell what common ground is going to be until more devices show up.

For scanning, some devices require to be told exactly where to scan in (as in which combination of band, fft width and coloring of the band). Some others don't. Then of course, the scan results might be operators? Network Service Providers? Network Access Providers? base station IDs? how do you stitch'em together? You need information to map from one to the other, and that is device specific depending on at which level they work. How to stich that information together depends on the network too (OMA-DM and provisining information help to compose this). If it is done at the device/firmware level or at the host level is device specific.

Connect has exactly the same levels of issues as scan: what do I connect to? A base station? a NAP or an NSP?

So back to the original question: I have no information to define such an interface at low level, so I am not defining it. Simple :/

Quoted 6 lines

I don't think you can say it's like cfg80211, cfg80211 in fact does a lot more than the wimax "stack", it can validate parameters for example, and provides actual operations (key operations, peer operations, scanning [soon], ...) rather than just a transport to the driver. As I've said on the relevant patch, I'd love to see the wimax stack take more of that direction.

If it has to happen, it will happen eventually. If it is a stack or not as of now and just a simple control interface, not that I really mind. It's just a name.

Quoted 2 lines

I don't see that as much of a problem. Many of the commands you have defined for the i2400m driver are very generic, for example:

As I said above, it is not so simple. They are not as generic as they look.

Quoted 5 lines

This is the biggest issue I see here. I don't see how the stack helps anyone implement a driver for a new device. Sure, they won't have to come up with a new transport, write less lines of generic netlink code, but ultimately that's not the hard part, the hard part is getting the relevant operations right etc.

I agree -- and that's the whole reason why the "stack" is there--because even if it doesn't look so hard, it's just a pain.

This way someone comes in with a need for a driver and then we can start deciding how to cut the scan & connect interfaces. Maybe it makes no sense to do it at the kernel level and it has to be done at user space, as the i2400m does it; then the kernel API stays the same...until another driver comes in...etc. Don't fix it if it ain't broke.

Quoted 5 lines

This really means you're putting the actual "driver", the piece that does the hardware abstraction, into userspace. And in a binary daemon even, afaict. This was quickly shot down with ipw3945/4965, not sure why nobody has cared here so far. Maybe because you're actually planning to open source that part.

Nope. I am putting the part that knows how to scan and connect in user space because it does not belong in kernel space. It is big and complex, needs permanent storage, requires complex crypto code and can really use a OMA-DM client to communicate with the network.

Not a binary, btw. Currently the supplicant is a binary, but that will change. The OMA-DM client daemon is also a binary as of now and we are still thinking how to fix that situation, as there are no open source equivalents. Luckily, it is kind of optional.

Quoted 5 lines

Couldn't the stack provide more functionality here? Somewhere else you speak of using ethernet vs. rawip, couldn't the stack do that translation, possibly even allowing both rawip and ethernet to coexist, or be switchable at runtime if you have a working dhcp client?

The stack is a control plane, not a data plane. Each driver implements data frame passing the way that is most optimal to the device it implements support for.

There is not good reason (as of now) that justifies the extra overhead that would be introduced by the "stack" doing it.

The only reason I would see that happening would be a mac80211 like case, where the stack is doing packet handling in a hypothetical soft-mac implementation. As I said above, I highly doubt that scenario.

Thanks,

#89 lore raw
In reply to Inaky Perez-Gonzalez
Quoted 3 lines · Inaky Perez-Gonzalez

For scanning, some devices require to be told exactly where to scan in (as in which combination of band, fft width and coloring of the band). Some others don't.

But things like these are fairly easy to cover, just allow netlink attributes to specify where to scan, and allow drivers to disregard them, no harm caused. Maybe include a capability bit, like I'm adding to nl80211 in my scanning patch (not included yet) that includes a capability for how many SSIDs it can scan actively at once.

Quoted 8 lines

Then of course, the scan results might be
operators? Network Service Providers? Network Access Providers? base station IDs? how do you stitch'em together? You need information to map from one to the other, and that is device specific depending on at which level they work. How to stich that information together depends on the network too (OMA-DM and provisining information help to compose this). If it is done at the device/firmware level or at the host level is device specific.

I have no idea about these things, obviously. But what's wrong with just defining the scan operation with netlink attributes as you need them now (say the scan returns NSPs) and then later when somebody needs to return NAPs add a new attribute? Userspace will easily be able to figure out which one it got by looking at which attributes are present.

Quoted 5 lines

Connect has exactly the same levels of issues as scan: what do I connect to? A base station? a NAP or an NSP?

So back to the original question: I have no information to define such an interface at low level, so I am not defining it. Simple :/

Here's where I disagree, obviously, I think you should at least define a subset of the imaginable interface, which is, in my opinion, _much_ better than defining no interface at all and hoping for the next guy to figure it out, which is unlikely to happen when you haven't started with something the next guy can understand.

Quoted 10 lines
Quoted 5 lines

This really means you're putting the actual "driver", the piece that does the hardware abstraction, into userspace. And in a binary daemon even, afaict. This was quickly shot down with ipw3945/4965, not sure why nobody has cared here so far. Maybe because you're actually planning to open source that part.

Nope. I am putting the part that knows how to scan and connect in user space because it does not belong in kernel space. It is big and complex, needs permanent storage, requires complex crypto code and can really use a OMA-DM client to communicate with the network.

Ok, I guess that makes sense then, I'm not aware of all the details.

Quoted 4 lines

Not a binary, btw. Currently the supplicant is a binary, but that will change. The OMA-DM client daemon is also a binary as of now and we are still thinking how to fix that situation, as there are no open source equivalents. Luckily, it is kind of optional.

Ok, thanks for the explanation.

johannes

#90 lore raw
Quoted 10 lines · Johannes Berg
Quoted 3 lines · Inaky Perez-Gonzalez

For scanning, some devices require to be told exactly where to scan in (as in which combination of band, fft width and coloring of the band). Some others don't.

But things like these are fairly easy to cover, just allow netlink attributes to specify where to scan, and allow drivers to disregard them, no harm caused. Maybe include a capability bit, like I'm adding to nl80211 in my scanning patch (not included yet) that includes a capability for how many SSIDs it can scan actively at once.

The implementation details are not the problem, there I totally agree with you. The problem is how to establish the cutline. What you are saying is exactly how I envision it to happen and the direction I'd like it to take, but I just don't want to do it until at least we have two vendors talking.

Quoted 9 lines
Quoted 8 lines

Then of course, the scan results might be
operators? Network Service Providers? Network Access Providers? base station IDs? how do you stitch'em together? You need information to map from one to the other, and that is device specific depending on at which level they work. How to stich that information together depends on the network too (OMA-DM and provisining information help to compose this). If it is done at the device/firmware level or at the host level is device specific.

Quoted 5 lines

I have no idea about these things, obviously. But what's wrong with just defining the scan operation with netlink attributes as you need them now (say the scan returns NSPs) and then later when somebody needs to return NAPs add a new attribute? Userspace will easily be able to figure out which one it got by looking at which attributes are present.

Call me chicken :) [more below]

Quoted 11 lines
Quoted 5 lines

Connect has exactly the same levels of issues as scan: what do I connect to? A base station? a NAP or an NSP?

So back to the original question: I have no information to define such an interface at low level, so I am not defining it. Simple :/

Here's where I disagree, obviously, I think you should at least define a subset of the imaginable interface, which is, in my opinion, _much_ better than defining no interface at all and hoping for the next guy to figure it out, which is unlikely to happen when you haven't started with something the next guy can understand.

No wait, I don't want guy #2 to define it--I want to work together to define it, to make sure it works for him and for me without having to throw to the garbage something I did on my own that won't work.

Quoted 21 lines
Quoted 10 lines
Quoted 5 lines

This really means you're putting the actual "driver", the piece that does the hardware abstraction, into userspace. And in a binary daemon even, afaict. This was quickly shot down with ipw3945/4965, not sure why nobody has cared here so far. Maybe because you're actually planning to open source that part.

Nope. I am putting the part that knows how to scan and connect in user space because it does not belong in kernel space. It is big and complex, needs permanent storage, requires complex crypto code and can really use a OMA-DM client to communicate with the network.

Ok, I guess that makes sense then, I'm not aware of all the details.

Quoted 4 lines

Not a binary, btw. Currently the supplicant is a binary, but that will change. The OMA-DM client daemon is also a binary as of now and we are still thinking how to fix that situation, as there are no open source equivalents. Luckily, it is kind of optional.

Ok, thanks for the explanation.

johannes

Signature · 1 line
Inaky
#91 lore raw
Quoted 12 lines · Inaky Perez-Gonzalez

The implementation details are not the problem, there I totally agree with you. The problem is how to establish the cutline. What you are saying is exactly how I envision it to happen and the direction I'd like it to take, but I just don't want to do it until at least we have two vendors talking.

Quoted 5 lines

Here's where I disagree, obviously, I think you should at least define a subset of the imaginable interface, which is, in my opinion, _much_ better than defining no interface at all and hoping for the next guy to figure it out, which is unlikely to happen when you haven't started with something the next guy can understand.

Quoted 3 lines

No wait, I don't want guy #2 to define it--I want to work together to define it, to make sure it works for him and for me without having to throw to the garbage something I did on my own that won't work.

But, but, you have to throw away all your 'behind-the-private-call' things anyway, at that point.

I think my point here really is that you're defining an API that's intentionally private because you don't want to define a public one even though that should be extensible enough. And then we get to the stuck with the private API because all the userland uses it, and the next guy will invariably implement it that way too, simply because you did and it works that way and is much easier than getting it right (he'll just say that because his is somewhat similar to yours he wants to wait for the third implementation... ;) )

johannes

#92 lore raw
In reply to Inaky Perez-Gonzalez
Quoted 7 lines · Inaky Perez-Gonzalez

Hi All

This patchset (or the linux-wimax GIT tree at git.kernel.org) merges the WiMAX subsystem and driver for the Intel 2400m Wireless WiMAX connection to the tree. We'd like to get it in for the 2.6.29 merge window.

That was a lot of feedback, thanks guys.

I think I covered most of your concerns, please let me know. I still have left to work on:

- replacing the ifinfo stuff with looking at the controller

- moving some of the sysfs files to debugfs

- moving to use dynamic_printk()

First two ones I plan to tackle ASAP. The dynamic_printk() stuff might take longer and I was wondering if you would be ok with changing that post-29 in case I were about to miss the merge window (got a few very busy weeks ahead of me).

Once I am done tackling those two ones I'll update the trees in kernel.org and repost a new set of patches.

Thanks,

Signature · 1 line
Inaky
#93 lore raw
Quoted 4 lines · Inaky Perez-Gonzalez

First two ones I plan to tackle ASAP. The dynamic_printk() stuff might take longer and I was wondering if you would be ok with changing that post-29 in case I were about to miss the merge window (got a few very busy weeks ahead of me).

Fine with me, I guess, I don't even know if the dynprintk is applicable (though I'd rather see you make it work if it isn't than add yet another huge debug macro file :) )

johannes

#94 lore raw

Hi Johannes,

Quoted 8 lines
Quoted 4 lines

First two ones I plan to tackle ASAP. The dynamic_printk() stuff might take longer and I was wondering if you would be ok with changing that post-29 in case I were about to miss the merge window (got a few very busy weeks ahead of me).

Fine with me, I guess, I don't even know if the dynprintk is applicable (though I'd rather see you make it work if it isn't than add yet another huge debug macro file :) )

I switched over the Bluetooth stack to use dynamic_printk(). It is as easy as just using pr_debug() or dev_dbg(). The rest already works perfectly fine.

However it is either full debug or nothing. Not a fine grained stuff we have in the iwlwifi drivers. However not sure if that is actually needed. It confuses me more and having to unload the driver and reload it makes me not using it a lot. The dynamic_printk() is really nice since you can turn it on and off. And since it is on a per module basis it was enough for Bluetooth. Not sure if that is applicable to everything, but then it could be extended with debug levels, I guess.

Regards

Marcel