Skip to contentSkip to conversation

libertas_tf: Add libertas_tf_sdio to libertas_tf

PATCH In review Steve deRosier 4 participants 30 messages Sep 8, 2010 – Sep 28, 2010 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover libertas_tf: Add libertas_tf_sdio to libertas_tf

The following series of patches adds an sdio driver to libertas_tf for the support of the sd8686 thin firmware for OLPC. This driver and firmware are used by OLPC's XO-1.5 and some Gumstix platforms.

The firmware can be pulled from OLPC's site:
http://dev.laptop.org/pub/firmware/libertas/thinfirm/lbtf_sdio-9.0.7.p3.bin

Full project documentation is on OLPC's wiki:
http://wiki.laptop.org/go/Thinfirm_1.5

Further patches will follow this series with various fixes given to me by the community, fixes to the libertas_tf_usb driver, and fixes for mesh.

These have been tested on OLPC's XO-1.5 with the thin firmware.

- Steve

[PATCH 1/9] libertas_tf: Add a sdio driver to libertas_tf
[PATCH 2/9] libertas_tf: deb_defs.h: Fix include guard
[PATCH 3/9] libertas_tf: Added fullmac mode support so firmware supports libertas driver [PATCH 4/9] libertas_tf: Add firmware reset to sdio driver and attempt firmware reload [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address [PATCH 6/9] libertas_tf: Fix to enable interrupts even when firmware has already started [PATCH 7/9] libertas_tf: Add tx feedback to libertas_tf_sdio
[PATCH 8/9] libertas_tf: updated with beacon code
[PATCH 9/9] libertas_tf: Allow tx up to full chip buffers

#1 lore raw

PATCH 1/9 libertas_tf: Add a sdio driver to libertas_tf

This patch adds support for sdio-connected libertas chips with the thin-firmware to libertas_tf. This includes the sd8686 in the OLPC XO-1.5s, as well as some Gumstix platforms. Restructuring was necessary in libertas_tf that will break libertas_tf_usb, which is fixed in a subsequent patch.

---
 drivers/net/wireless/Kconfig                   |    6 +
 drivers/net/wireless/libertas_tf/Makefile      |    2 +
 drivers/net/wireless/libertas_tf/cmd.c         |   10 +-
 drivers/net/wireless/libertas_tf/deb_defs.h    |    5 +-
 drivers/net/wireless/libertas_tf/if_sdio.c     | 1201 ++++++++++++++++++++++++
 drivers/net/wireless/libertas_tf/if_sdio.h     |   56 ++
 drivers/net/wireless/libertas_tf/libertas_tf.h |   19 +-
 drivers/net/wireless/libertas_tf/main.c        |  100 ++-
 8 files changed, 1379 insertions(+), 20 deletions(-)
 create mode 100644 drivers/net/wireless/libertas_tf/if_sdio.c
 create mode 100644 drivers/net/wireless/libertas_tf/if_sdio.h
drivers/net/wireless/Kconfig +6 -0
index 174e344..fc6c713 100644
@@ -45,6 +45,12 @@ config LIBERTAS_THINFIRM_DEBUG
 	---help---
 	  Debugging support.
 
+config LIBERTAS_THINFIRM_SDIO
+	tristate "Marvell Libertas 8686 SDIO 802.11b/g cards"
+	depends on LIBERTAS_THINFIRM && MMC
+	---help---
+	  A driver for Marvell Libertas 8686 SDIO devices.
+
 config LIBERTAS_THINFIRM_USB
 	tristate "Marvell Libertas 8388 USB 802.11b/g cards with thin firmware"
 	depends on LIBERTAS_THINFIRM && USB
drivers/net/wireless/libertas_tf/Makefile +2 -0
index ff5544d..1a44340 100644
@@ -1,6 +1,8 @@
 libertas_tf-objs := main.o cmd.o
 
 libertas_tf_usb-objs += if_usb.o
+libertas_tf_sdio-objs += if_sdio.o
 
 obj-$(CONFIG_LIBERTAS_THINFIRM) += libertas_tf.o
 obj-$(CONFIG_LIBERTAS_THINFIRM_USB) += libertas_tf_usb.o
+obj-$(CONFIG_LIBERTAS_THINFIRM_SDIO) += libertas_tf_sdio.o
drivers/net/wireless/libertas_tf/cmd.c +8 -2
index 8945afd..738a2ff 100644
@@ -101,7 +101,7 @@ int lbtf_update_hw_spec(struct lbtf_private *priv)
 	priv->fwrelease = (priv->fwrelease << 8) |
 		(priv->fwrelease >> 24 & 0xff);
 
-	printk(KERN_INFO "libertastf: %pM, fw %u.%u.%up%u, cap 0x%08x\n",
+	printk(KERN_INFO "libertas_tf: %pM, fw %u.%u.%up%u, cap 0x%08x\n",
 		cmd.permanentaddr,
 		priv->fwrelease >> 24 & 0xff,
 		priv->fwrelease >> 16 & 0xff,
@@ -252,7 +252,7 @@ static void lbtf_submit_command(struct lbtf_private *priv,
 
 	lbtf_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n",
 		     command, le16_to_cpu(cmd->seqnum), cmdsize);
-	lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize);
+	lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD ", (void *) cmdnode->cmdbuf, cmdsize);
 
 	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
 	spin_unlock_irqrestore(&priv->driver_lock, flags);
@@ -672,6 +672,12 @@ int __lbtf_cmd(struct lbtf_private *priv, uint16_t command,
 
 	lbtf_deb_enter(LBTF_DEB_HOST);
 
+	if (priv->surpriseremoved) {
+		lbtf_deb_host("CMD: card removed\n");
+		cmdnode = ERR_PTR(-ENOENT);
+		goto done;
+	}
+
 	cmdnode = __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size,
 				  callback, callback_arg);
 	if (IS_ERR(cmdnode)) {
drivers/net/wireless/libertas_tf/deb_defs.h +4 -1
index ae75396..e2f009c 100644
@@ -11,6 +11,9 @@
 
 #include <linux/spinlock.h>
 
+#undef pr_fmt
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #ifdef CONFIG_LIBERTAS_THINFIRM_DEBUG
 #define DEBUG
 #define PROC_DEBUG
@@ -82,7 +85,7 @@ do { if ((lbtf_debug & (grp)) == (grp)) \
 #define lbtf_deb_usbd(dev, fmt, args...) LBTF_DEB_LL(LBTF_DEB_USB, " usbd", "%s:" fmt, dev_name(dev), ##args)
 #define lbtf_deb_cs(fmt, args...)        LBTF_DEB_LL(LBTF_DEB_CS, " cs", fmt, ##args)
 #define lbtf_deb_thread(fmt, args...)    LBTF_DEB_LL(LBTF_DEB_THREAD, " thread", fmt, ##args)
-#define lbtf_deb_sdio(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_SDIO, " thread", fmt, ##args)
+#define lbtf_deb_sdio(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_SDIO, " sdio", fmt, ##args)
 #define lbtf_deb_macops(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_MACOPS, " thread", fmt, ##args)
 
 #ifdef DEBUG
drivers/net/wireless/libertas_tf/if_sdio.c new file +1201 -0

1,201 lines not on this page · raw message

drivers/net/wireless/libertas_tf/if_sdio.h new file +56 -0

56 lines not on this page · raw message

drivers/net/wireless/libertas_tf/libertas_tf.h +15 -4
index ad77b92..078c52e 100644
@@ -190,9 +190,13 @@ struct lbtf_private {
 	struct work_struct tx_work;
 	/** Hardware access */
 	int (*hw_host_to_card) (struct lbtf_private *priv, u8 type, u8 *payload, u16 nb);
-	int (*hw_prog_firmware) (struct if_usb_card *cardp);
-	int (*hw_reset_device) (struct if_usb_card *cardp);
-
+	int (*hw_prog_firmware) (void *cardp);
+	int (*hw_reset_device) (void *cardp);
+	int (*enter_deep_sleep) (struct lbtf_private *priv);
+	int (*exit_deep_sleep) (struct lbtf_private *priv);
+	int (*reset_deep_sleep_wakeup) (struct lbtf_private *priv);
+	int (*enable_interrupts) (struct lbtf_private *priv);
+	int (*disable_interrupts) (struct lbtf_private *priv);
 
 	/** Wlan adapter data structure*/
 	/** STATUS variables */
@@ -256,6 +260,13 @@ struct lbtf_private {
 
 	/* Most recently reported noise in dBm */
 	s8 noise;
+	
+	/* Command responses sent from the hardware to the driver */
+	int cur_cmd_retcode;
+	u8 resp_idx;
+	u8 resp_buf[2][LBS_UPLD_SIZE];
+	u32 resp_len[2];
+
 };
 
 /* 802.11-related definitions */
@@ -488,9 +499,9 @@ struct chan_freq_power *lbtf_get_region_cfp_table(u8 region,
 	int *cfp_no);
 struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev);
 int lbtf_remove_card(struct lbtf_private *priv);
-int lbtf_start_card(struct lbtf_private *priv);
 int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb);
 void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail);
+void lbtf_host_to_card_done(struct lbtf_private *priv );
 void lbtf_bcn_sent(struct lbtf_private *priv);
 
 /* support functions for cmd.c */
drivers/net/wireless/libertas_tf/main.c +87 -13

210 lines not on this page · raw message

Signature · 1 line
1.7.0
#2 lore raw

PATCH 2/9 libertas_tf: deb_defs.h: Fix include guard

In reply to Steve deRosier

From: Thomas Klute <[email protected]>

Compiling with CONFIG_LIBERTAS_THINFIRM_DEBUG=y failed before, this was the reason.

---
 drivers/net/wireless/libertas_tf/deb_defs.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/libertas_tf/deb_defs.h +1 -1
index e2f009c..99a7478 100644
@@ -3,7 +3,7 @@
   * global variable declaration.
   */
 #ifndef _LBS_DEB_DEFS_H_
-#define _LBS_DEB_EFS_H_
+#define _LBS_DEB_DEFS_H_
 
 #ifndef DRV_NAME
 #define DRV_NAME "libertas_tf"
Signature · 1 line
1.7.0
#3 lore raw

PATCH 3/9 libertas_tf: Added fullmac mode support so firmware supports libertas driver

In reply to Steve deRosier
---
 drivers/net/wireless/libertas_tf/libertas_tf.h |    1 +
 drivers/net/wireless/libertas_tf/main.c        |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas_tf/libertas_tf.h +1 -0
index 078c52e..bedb6b1 100644
@@ -80,6 +80,7 @@ enum lbtf_mode {
 	LBTF_PASSIVE_MODE,
 	LBTF_STA_MODE,
 	LBTF_AP_MODE,
+	LBTF_FULLMAC_MODE,
 };
 
 /** Card Event definition */
drivers/net/wireless/libertas_tf/main.c +1 -0
index 90ef6c7..5d34ad9 100644
@@ -158,6 +158,7 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
 
 	lbtf_set_mac_control(priv);
 	lbtf_set_radio_control(priv);
+	lbtf_set_mode(priv, LBTF_PASSIVE_MODE);
 
 	ret = 0;
 done:
Signature · 1 line
1.7.0
#4 lore raw

PATCH 4/9 libertas_tf: Add firmware reset to sdio driver and attempt firmware reload

In reply to Steve deRosier

This patch adds a method to do a firmware/chip reset to the sdio driver and attempts to reload the firmware.

---
 drivers/net/wireless/libertas_tf/if_sdio.c |   40 +++++++++++++++++++++++----
 drivers/net/wireless/libertas_tf/main.c    |    7 ++++-
 2 files changed, 40 insertions(+), 7 deletions(-)
drivers/net/wireless/libertas_tf/if_sdio.c +34 -6
index fed5aff..1e72b4c 100644
@@ -53,6 +53,8 @@ struct if_sdio_model {
 	const char *firmware;
 };
 
+extern unsigned int lbtf_reset_fw;
+
 static struct if_sdio_model if_sdio_models[] = {
 	{
 		/* 8686 */
@@ -673,6 +675,8 @@ out:
 	return ret;
 }
 
+static void if_sdio_reset_device(struct if_sdio_card *card);
+
 static int if_sdio_prog_firmware(struct if_sdio_card *card)
 {
 	int ret;
@@ -691,17 +695,29 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
 	scratch = if_sdio_read_scratch(card, &ret);
 	sdio_release_host(card->func);
 
+	lbtf_deb_sdio("firmware status = %#x\n", scratch);
+	lbtf_deb_sdio("scratch ret = %d\n", ret);
+
 	if (ret)
 		goto out;
 
-	lbtf_deb_sdio("firmware status = %#x\n", scratch);
-
 	if (scratch == IF_SDIO_FIRMWARE_OK) {
 		lbtf_deb_sdio("firmware already loaded\n");
 		goto success;
 	} else if ((card->model == IF_SDIO_MODEL_8686) && (scratch > 0)) {
 		lbtf_deb_sdio("firmware may be running\n");
-		goto success;
+		if( lbtf_reset_fw == 0 ) {
+			goto success;
+		} else {
+			int i = 0;
+			lbtf_deb_sdio("attempting to reset and reload firmware\n");
+
+			if_sdio_reset_device(card);
+			lbtf_reset_fw=0;
+
+			ret = if_sdio_prog_firmware(card);
+			goto out;
+		}
 	}
 
 	ret = if_sdio_prog_helper(card);
@@ -864,7 +880,7 @@ static void if_sdio_reset_device(struct if_sdio_card *card)
 
 	if_sdio_host_to_card(card->priv, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
 
-	msleep(100);
+	msleep(1000);
 
 	lbtf_deb_leave(LBTF_DEB_SDIO);
 
@@ -887,10 +903,12 @@ static void if_sdio_interrupt(struct sdio_func *func)
 	card = sdio_get_drvdata(func);
 
 	cause = sdio_readb(card->func, IF_SDIO_H_INT_STATUS, &ret);
+	lbtf_deb_sdio("interrupt: 0x%X\n", (unsigned)cause);
+	lbtf_deb_sdio("interrupt ret: 0x%X\n", ret);
 	if (ret)
 		goto out;
 
-	lbtf_deb_sdio("interrupt: 0x%X\n", (unsigned)cause);
+//	lbtf_deb_sdio("interrupt: 0x%X\n", (unsigned)cause);
 
 	sdio_writeb(card->func, ~cause, IF_SDIO_H_INT_STATUS, &ret);
 	if (ret)
@@ -1061,13 +1079,23 @@ static int if_sdio_probe(struct sdio_func *func,
 	priv->enter_deep_sleep = if_sdio_enter_deep_sleep;
 	priv->exit_deep_sleep = if_sdio_exit_deep_sleep;
 	priv->reset_deep_sleep_wakeup = if_sdio_reset_deep_sleep_wakeup;
-	priv->hw_reset_device = if_sdio_reset_device;
 	priv->enable_interrupts = if_sdio_enable_interrupts;
 	priv->disable_interrupts = if_sdio_disable_interrupts;
 
 	/* SD8385 & SD8686 do not have rx_unit.	*/
 	card->rx_unit = 0;
 
+	/*
+	 * Enable interrupts now that everything is set up
+	 */
+	ret = _if_sdio_enable_interrupts(card);
+	if (ret) {
+		pr_err("Error enabling interrupts: %d", ret);
+		goto err_activate_card;
+	}
+
+	priv->fw_ready = 1;
+
 out:
 	lbtf_deb_leave_args(LBTF_DEB_SDIO, "ret %d", ret);
 
drivers/net/wireless/libertas_tf/main.c +6 -1
index 5d34ad9..119d625 100644
@@ -24,6 +24,10 @@ unsigned int lbtf_debug;
 EXPORT_SYMBOL_GPL(lbtf_debug);
 module_param_named(libertas_tf_debug, lbtf_debug, int, 0644);
 
+unsigned int lbtf_reset_fw;
+EXPORT_SYMBOL_GPL(lbtf_reset_fw);
+module_param_named(libertas_tf_reset_fw, lbtf_reset_fw, int, 0644);
+
 static const char lbtf_driver_version[] = "THINFIRM-USB8388-" DRIVER_RELEASE_VERSION
 #ifdef DEBUG
 	"-dbg"
@@ -360,7 +364,8 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
 	return 0;
 
 err_prog_firmware:
-//	priv->hw_reset_device(card);
+	if (priv->hw_reset_device)
+		priv->hw_reset_device(card);
 	lbtf_deb_leave_args(LBTF_DEB_MACOPS, "error programing fw; ret=%d", ret);
 	return ret;
 }
Signature · 1 line
1.7.0
#5 lore raw

Re: [PATCH 4/9] libertas_tf: Add firmware reset to sdio driver and attempt firmware reload

Minor nit:

Quoted 16 lines · Steve deRosier

This patch adds a method to do a firmware/chip reset to the sdio driver and attempts to reload the firmware.

---
 drivers/net/wireless/libertas_tf/if_sdio.c |   40 +++++++++++++++++++++++---- drivers/net/wireless/libertas_tf/main.c    |    7 ++++-

 2 files changed, 40 insertions(+), 7 deletions(-)
drivers/net/wireless/libertas_tf/main.c +0 -0
index fed5aff..1e72b4c 100644
@@ -360,7 +364,8 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
        return 0;
 
Quoted 4 lines

 err_prog_firmware:
-//     priv->hw_reset_device(card);
+       if (priv->hw_reset_device)
+               priv->hw_reset_device(card);

Should this not be done in the first patch? - rather than just commenting out the call: Would commenting out this line in the first patch make the original version of libertas_tf unable to handle firmware errors properly?

Quoted 3 lines

       lbtf_deb_leave_args(LBTF_DEB_MACOPS, "error programing fw; ret=%d", ret); return ret;
 }

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#6 lore raw

Re: [PATCH 4/9] libertas_tf: Add firmware reset to sdio driver and attempt firmware reload

Quoted 19 lines · Julian Calaby

Minor nit:

Quoted 16 lines · Steve deRosier

This patch adds a method to do a firmware/chip reset to the sdio driver and attempts to reload the firmware.

---
 drivers/net/wireless/libertas_tf/if_sdio.c |   40 +++++++++++++++++++++++---- drivers/net/wireless/libertas_tf/main.c    |    7 ++++-

 2 files changed, 40 insertions(+), 7 deletions(-)
drivers/net/wireless/libertas_tf/main.c +0 -0
index fed5aff..1e72b4c 100644
@@ -360,7 +364,8 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
        return 0;
 
Quoted 10 lines
Quoted 4 lines

 err_prog_firmware:
-//     priv->hw_reset_device(card);
+       if (priv->hw_reset_device)
+               priv->hw_reset_device(card);

Should this not be done in the first patch? - rather than just commenting out the call: Would commenting out this line in the first patch make the original version of libertas_tf unable to handle firmware errors properly?

Yes, it could have been done in the first patch. I could have rolled all my patches into one single patch, but I felt it was better to keep some parts split out. As it was, I squashed and reordered about 50 commits into the 17 I posted. I basically spent most of the day rebasing 3 months worth of commits to come out with what I thought was a logical set. In particular, since I had contributions from others in the mix, I wanted to respect their patches as _theirs_ instead of squashing them into my own. As you'll notice patch 2 was from someone else.

If John would prefer, I can squish all my patches into one, with the exception of those submitted to me by other parties and the lone mac80211 patch.

As for the specific question about this item... The libertas_tf_sdio driver started from the libertas_sdio driver. I hacked and molded until I had something that worked and I learned more about the chip and the interface. I started by commenting out code I didn't need at the time. This specific line was commented out because it wasn't germane to the problems I was solving at the moment AND it caused problems. Did commenting the line out "make the original version of libertas_tf unable to handle firmware errors properly?" No: simple fact is resetting the device didn't work properly at the time anyway and just really mucked up the situation making debugging the firmware a bear.

If it really matters, I'll be happy to rebase more and send up fewer patches.

Thanks,
- Steve

#7 lore raw

PATCH 5/9 libertas_tf: Moved firmware loading to probe in order to fetch MAC address

In reply to Steve deRosier

mac80211 requires that the MAC address be known and set before calling ieee80211_register_hw(). If this isn't done, we see bad MAC addresses in our packet headers. In order to make this happen, I had to restructure to have if_sdio_probe load the firmware and get the hardware specs.

I had to add a if_sdio_update_hw_spec function as if_sdio can't use the standard command as several required variables aren't setup yet. if_sdio_update_hw_spec essentially uses polled io to get the hw spec command response from the card.

---
 drivers/net/wireless/libertas_tf/if_sdio.c     |  263 ++++++++++++++++++++----
 drivers/net/wireless/libertas_tf/libertas_tf.h |    2 +-
 drivers/net/wireless/libertas_tf/main.c        |   38 +++--
 3 files changed, 248 insertions(+), 55 deletions(-)
drivers/net/wireless/libertas_tf/if_sdio.c +223 -40
index 1e72b4c..189b820 100644
@@ -91,12 +91,15 @@ struct if_sdio_card {
 	struct workqueue_struct	*workqueue;
 	struct work_struct	packet_worker;
 
+	u8 hw_addr[ETH_ALEN];
+	u32 fwrelease;
+	u32 fwcapinfo;
+
 	u8			rx_unit;
 };
 
-static int if_sdio_enable_interrupts(struct lbtf_private *priv)
+static int _if_sdio_enable_interrupts(struct if_sdio_card *card)
 {
-	struct if_sdio_card *card = priv->card;
 	int ret;
 
 	lbtf_deb_enter(LBTF_DEB_SDIO);
@@ -109,9 +112,14 @@ static int if_sdio_enable_interrupts(struct lbtf_private *priv)
 	return (ret);
 }
 
-static int if_sdio_disable_interrupts(struct lbtf_private *priv)
+static int if_sdio_enable_interrupts(struct lbtf_private *priv)
 {
 	struct if_sdio_card *card = priv->card;
+	return _if_sdio_enable_interrupts(card);
+}
+
+static int _if_sdio_disable_interrupts(struct if_sdio_card *card)
+{
 	int ret;
 
 	lbtf_deb_enter(LBTF_DEB_SDIO);
@@ -124,6 +132,12 @@ static int if_sdio_disable_interrupts(struct lbtf_private *priv)
 	return (ret);
 }
 
+static int if_sdio_disable_interrupts(struct lbtf_private *priv)
+{
+	struct if_sdio_card *card = priv->card;
+	return _if_sdio_disable_interrupts(card);
+}
+
 /*
  *  For SD8385/SD8686, this function reads firmware status after
  *  the image is downloaded, or reads RX packet length when
@@ -187,7 +201,6 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
 	struct lbtf_private *priv = card->priv;
 	int ret;
 	unsigned long flags;
-	u8 i;
 
 	lbtf_deb_enter(LBTF_DEB_SDIO);
 
@@ -414,10 +427,14 @@ static void if_sdio_host_to_card_worker(struct work_struct *work)
 			break;
 
 		// Check for removed device
-		if (card->priv->surpriseremoved) {
-			lbtf_deb_sdio("Device removed\n");
-			kfree(packet);
-			break;
+		if (card->priv) {
+			if (card->priv->surpriseremoved) {
+				lbtf_deb_sdio("Device removed\n");
+				kfree(packet);
+				break;
+			}
+		} else {
+			lbtf_deb_sdio("host->card called during init, assuming device exists");
 		}
 
 		sdio_claim_host(card->func);
@@ -687,7 +704,7 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
 	/*
 	 * Disable interrupts
 	 */
-	ret = if_sdio_disable_interrupts(card->priv);
+	ret = _if_sdio_disable_interrupts(card);
 	if (ret)
 		pr_warning("unable to disable interrupts: %d", ret);
 
@@ -709,7 +726,6 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
 		if( lbtf_reset_fw == 0 ) {
 			goto success;
 		} else {
-			int i = 0;
 			lbtf_deb_sdio("attempting to reset and reload firmware\n");
 
 			if_sdio_reset_device(card);
@@ -733,15 +749,6 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
 	lbtf_deb_sdio("Firmware loaded\n");
 
 success:
-	/*
-	 * Enable interrupts now that everything is set up
-	 */
-	ret = if_sdio_enable_interrupts(card->priv);
-	if (ret) {
-		pr_err("Error enabling interrupts: %d", ret);
-		goto out;
-	}
-
 	sdio_claim_host(card->func);
 	sdio_set_block_size(card->func, IF_SDIO_BLOCK_SIZE);
 	sdio_release_host(card->func);
@@ -756,19 +763,16 @@ out:
 /* Libertas callbacks                                              */
 /*******************************************************************/
 
-static int if_sdio_host_to_card(struct lbtf_private *priv,
+static int _if_sdio_host_to_card(struct if_sdio_card *card,
 		u8 type, u8 *buf, u16 nb)
 {
 	int ret;
-	struct if_sdio_card *card;
 	struct if_sdio_packet *packet, *cur;
 	u16 size;
 	unsigned long flags;
 
 	lbtf_deb_enter_args(LBTF_DEB_SDIO, "type %d, bytes %d", type, nb);
 
-	card = priv->card;
-
 	if (nb > (65536 - sizeof(struct if_sdio_packet) - 4)) {
 		ret = -EINVAL;
 		goto out;
@@ -812,6 +816,27 @@ static int if_sdio_host_to_card(struct lbtf_private *priv,
 		cur->next = packet;
 	}
 
+	spin_unlock_irqrestore(&card->lock, flags);
+
+	queue_work(card->workqueue, &card->packet_worker);
+
+	ret = 0;
+
+out:
+	lbtf_deb_leave_args(LBTF_DEB_SDIO, "ret %d", ret);
+
+	return ret;
+}
+
+static int if_sdio_host_to_card(struct lbtf_private *priv,
+		u8 type, u8 *buf, u16 nb)
+{
+	struct if_sdio_card *card;
+	unsigned long flags;
+
+	card = priv->card;
+
+	spin_lock_irqsave(&card->lock, flags);
 	/* TODO: the dndl_sent has to do with sleep stuff.
 	 * Commented out till we add that.
 	 */
@@ -825,17 +850,9 @@ static int if_sdio_host_to_card(struct lbtf_private *priv,
 	default:
 		lbtf_deb_sdio("unknown packet type %d\n", (int)type);
 	}
-
 	spin_unlock_irqrestore(&card->lock, flags);
 
-	queue_work(card->workqueue, &card->packet_worker);
-
-	ret = 0;
-
-out:
-	lbtf_deb_leave_args(LBTF_DEB_SDIO, "ret %d", ret);
-
-	return ret;
+	return _if_sdio_host_to_card(card, type, buf, nb);
 }
 
 static int if_sdio_enter_deep_sleep(struct lbtf_private *priv)
@@ -846,7 +863,6 @@ static int if_sdio_enter_deep_sleep(struct lbtf_private *priv)
 
 static int if_sdio_exit_deep_sleep(struct lbtf_private *priv)
 {
-	struct if_sdio_card *card = priv->card;
 	int ret = -1;
 
 	lbtf_deb_enter(LBTF_DEB_SDIO);
@@ -857,14 +873,12 @@ static int if_sdio_exit_deep_sleep(struct lbtf_private *priv)
 
 static int if_sdio_reset_deep_sleep_wakeup(struct lbtf_private *priv)
 {
-	struct if_sdio_card *card = priv->card;
 	int ret = -1;
 
 	lbtf_deb_enter(LBTF_DEB_SDIO);
 
 	lbtf_deb_leave_args(LBTF_DEB_SDIO, "ret %d", ret);
 	return ret;
-
 }
 
 static void if_sdio_reset_device(struct if_sdio_card *card)
@@ -878,7 +892,7 @@ static void if_sdio_reset_device(struct if_sdio_card *card)
 	cmd.hdr.size = cpu_to_le16(sizeof(cmd));
 	cmd.action = cpu_to_le16(CMD_ACT_HALT);
 
-	if_sdio_host_to_card(card->priv, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
+	_if_sdio_host_to_card(card, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
 
 	msleep(1000);
 
@@ -888,6 +902,157 @@ static void if_sdio_reset_device(struct if_sdio_card *card)
 }
 EXPORT_SYMBOL_GPL(if_sdio_reset_device);
 
+/**
+ *  lbtf_update_hw_spec: Updates the hardware details.
+ *
+ *  @priv    	A pointer to struct lbtf_private structure
+ *
+ *  Returns: 0 on success, error on failure
+ */
+int if_sdio_update_hw_spec(struct if_sdio_card *card)
+{
+	struct cmd_ds_get_hw_spec cmd;
+	int ret = -1;
+	unsigned long timeout;
+	u16 size, type, chunk;
+	int wait_cmd_done = 0;
+
+	lbtf_deb_enter(LBTF_DEB_SDIO);
+
+	/* Send hw spec command */
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.hdr.size = cpu_to_le16(sizeof(cmd));
+	cmd.hdr.command = cpu_to_le16(CMD_GET_HW_SPEC);
+	memcpy(cmd.permanentaddr, card->hw_addr, ETH_ALEN);
+	ret = _if_sdio_host_to_card(card, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
+	if (ret) {
+		goto out;
+	}
+
+	/* Wait for and retrieve response */
+	timeout = jiffies + HZ;
+	while (wait_cmd_done < 1) {
+		/* Wait for response to cmd */
+		sdio_claim_host(card->func);
+		ret = if_sdio_wait_status(card, IF_SDIO_UL_RDY);
+		sdio_release_host(card->func);
+		if (ret) {
+			/* time-out */
+			lbtf_deb_sdio("error waiting on IO ready");
+			goto out;
+		}
+
+		/* get the rx size */
+		sdio_claim_host(card->func);
+		size = if_sdio_read_rx_len(card, &ret);
+		sdio_release_host(card->func);
+		if (ret)
+			goto out;
+
+		if (size == 0) {
+		} else if (size < 4) {
+			lbtf_deb_sdio("invalid packet size (%d bytes) from firmware\n",
+				(int)size);
+			ret = -EINVAL;
+			goto out;
+		} else /* size > 4 */ {
+			/*
+			 * Get command response.
+			 *
+			 * The transfer must be in one transaction or the firmware
+			 * goes suicidal. There's no way to guarantee that for all
+			 * controllers, but we can at least try.
+			 */
+			sdio_claim_host(card->func);
+			chunk = sdio_align_size(card->func, size);
+
+			ret = sdio_readsb(card->func, card->buffer, card->ioport, chunk);
+			sdio_release_host(card->func);
+			if (ret)
+				goto out;
+
+			chunk = card->buffer[0] | (card->buffer[1] << 8);
+			type = card->buffer[2] | (card->buffer[3] << 8);
+
+			lbtf_deb_sdio("packet of type %d and size %d bytes\n",
+				(int)type, (int)chunk);
+
+			lbtf_deb_hex(LBTF_DEB_SDIO, "SDIO Rx: ", card->buffer,
+						 min_t(unsigned int, size, 100));
+
+			if (chunk > size) {
+				lbtf_deb_sdio("packet fragment (%d > %d)\n",
+					(int)chunk, (int)size);
+				ret = -EINVAL;
+				goto out;
+			}
+
+			if (chunk < size) {
+				lbtf_deb_sdio("packet fragment (%d < %d)\n",
+					(int)chunk, (int)size);
+			}
+
+			switch (type) {
+			case MVMS_DAT:
+				lbtf_deb_sdio("Got MVMS_DAT");
+				continue;
+			case MVMS_CMD:
+				lbtf_deb_sdio("Got MVMS_CMD");
+				memcpy(&cmd, card->buffer +4, sizeof(cmd));
+				wait_cmd_done = 1;
+				break;
+			case MVMS_EVENT:
+				lbtf_deb_sdio("Got MVMS_EVENT");
+				continue;
+			default:
+				lbtf_deb_sdio("invalid type (%d) from firmware\n",
+						(int)type);
+				ret = -EINVAL;
+				goto out;
+			}
+		} /* size > 4 */
+
+		if (!wait_cmd_done) {
+			if (time_after(jiffies, timeout)) {
+				ret = -ETIMEDOUT;
+				pr_warning("Update hw spec cmd timed out\n");
+				ret = -1;
+				goto out;
+			}
+
+			msleep(10);
+		}
+	}
+
+	lbtf_deb_sdio("Got hw spec command response");
+
+	/* Process cmd return */
+	card->fwcapinfo = le32_to_cpu(cmd.fwcapinfo);
+
+	/* The firmware release is in an interesting format: the patch
+	 * level is in the most significant nibble ... so fix that: */
+	card->fwrelease = le32_to_cpu(cmd.fwrelease);
+	card->fwrelease = (card->fwrelease << 8) |
+		(card->fwrelease >> 24 & 0xff);
+
+	printk(KERN_INFO "libertas_tf_sdio: %pM, fw %u.%u.%up%u, cap 0x%08x\n",
+		cmd.permanentaddr,
+		card->fwrelease >> 24 & 0xff,
+		card->fwrelease >> 16 & 0xff,
+		card->fwrelease >>  8 & 0xff,
+		card->fwrelease       & 0xff,
+		card->fwcapinfo);
+	lbtf_deb_sdio("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
+		    cmd.hwifversion, cmd.version);
+
+	memmove(card->hw_addr, cmd.permanentaddr, ETH_ALEN);
+
+out:
+	lbtf_deb_leave(LBTF_DEB_SDIO);
+	return ret;
+}
+
+
 /*******************************************************************/
 /* SDIO callbacks                                                  */
 /*******************************************************************/
@@ -919,8 +1084,8 @@ static void if_sdio_interrupt(struct sdio_func *func)
 	 * successfully received the command.
 	 */
 	if (cause & IF_SDIO_H_INT_DNLD)
-		lbtf_host_to_card_done(card->priv);
-
+		if (card->priv)
+			lbtf_host_to_card_done(card->priv);
 
 	if (cause & IF_SDIO_H_INT_UPLD) {
 		ret = if_sdio_card_to_host(card);
@@ -1065,7 +1230,26 @@ static int if_sdio_probe(struct sdio_func *func,
 			func->class, func->vendor, func->device,
 			model, (unsigned)card->ioport);
 
-	priv = lbtf_add_card(card, &func->dev);
+	/* Upload firmware */
+	lbtf_deb_sdio("Going to upload fw...");
+	if (if_sdio_prog_firmware(card))
+		goto reclaim;
+
+	/*
+	 * We need to get the hw spec here because we must have the
+	 * MAC address before we call lbtf_add_card
+	 *
+	 * Read priv address from HW
+	 */
+	memset(card->hw_addr, 0xff, ETH_ALEN);
+	ret = if_sdio_update_hw_spec(card);
+	if (ret) {
+		ret = -1;
+		pr_err("Error fetching MAC address from hardware.");
+		goto reclaim;
+	}
+
+	priv = lbtf_add_card(card, &func->dev, card->hw_addr);
 	if (!priv) {
 		ret = -ENOMEM;
 		goto reclaim;
@@ -1075,7 +1259,6 @@ static int if_sdio_probe(struct sdio_func *func,
 	priv->card = card;
 
 	priv->hw_host_to_card = if_sdio_host_to_card;
-	priv->hw_prog_firmware = if_sdio_prog_firmware;
 	priv->enter_deep_sleep = if_sdio_enter_deep_sleep;
 	priv->exit_deep_sleep = if_sdio_exit_deep_sleep;
 	priv->reset_deep_sleep_wakeup = if_sdio_reset_deep_sleep_wakeup;
drivers/net/wireless/libertas_tf/libertas_tf.h +1 -1
index bedb6b1..c7588fd 100644
@@ -498,7 +498,7 @@ void lbtf_cmd_response_rx(struct lbtf_private *priv);
 /* main.c */
 struct chan_freq_power *lbtf_get_region_cfp_table(u8 region,
 	int *cfp_no);
-struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev);
+struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev, u8 mac_addr[ETH_ALEN]);
 int lbtf_remove_card(struct lbtf_private *priv);
 int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb);
 void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail);
drivers/net/wireless/libertas_tf/main.c +24 -14
index 119d625..14ce1bc 100644
@@ -150,14 +150,15 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
 	int ret = -1;
 
 	lbtf_deb_enter(LBTF_DEB_FW);
+
 	/*
 	 * Read priv address from HW
 	 */
 	memset(priv->current_addr, 0xff, ETH_ALEN);
 	ret = lbtf_update_hw_spec(priv);
 	if (ret) {
-		ret = -1;
-		goto done;
+		   ret = -1;
+		   goto done;
 	}
 
 	lbtf_set_mac_control(priv);
@@ -165,6 +166,7 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
 	lbtf_set_mode(priv, LBTF_PASSIVE_MODE);
 
 	ret = 0;
+
 done:
 	lbtf_deb_leave_args(LBTF_DEB_FW, "ret: %d", ret);
 	return ret;
@@ -325,18 +327,20 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
 
 	lbtf_deb_enter(LBTF_DEB_MACOPS);
 
-	if (!priv->fw_ready) {
-		lbtf_deb_main("Going to upload fw...");
-		/* Upload firmware */
-		if (priv->hw_prog_firmware(card))
-			goto err_prog_firmware;
-		else
-			priv->fw_ready = 1;
-	} else {
-		if (priv->enable_interrupts) {
-			priv->enable_interrupts(priv);
+	if (priv->hw_prog_firmware) {
+		if (!priv->fw_ready) {
+			lbtf_deb_main("Going to upload fw...");
+			/* Upload firmware */
+			if (priv->hw_prog_firmware(card))
+				goto err_prog_firmware;
+			else
+				priv->fw_ready = 1;
+		} else {
+			if (priv->enable_interrupts) {
+				priv->enable_interrupts(priv);
+			}
+			lbtf_deb_main("FW was already ready...");
 		}
-		lbtf_deb_main("FW was already ready...");
 	}
 
 	/* poke the firmware */
@@ -433,6 +437,7 @@ static int lbtf_op_add_interface(struct ieee80211_hw *hw,
 		lbtf_set_mac_address(priv, (u8 *) vif->addr);
 	}
 
+
 	lbtf_deb_leave(LBTF_DEB_MACOPS);
 	return 0;
 }
@@ -663,7 +668,7 @@ EXPORT_SYMBOL_GPL(lbtf_rx);
  *
  *  Returns: pointer to struct lbtf_priv.
  */
-struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev)
+struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev, u8 mac_addr[ETH_ALEN])
 {
 	struct ieee80211_hw *hw;
 	struct lbtf_private *priv = NULL;
@@ -701,6 +706,11 @@ struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev)
 
 	INIT_WORK(&priv->cmd_work, lbtf_cmd_work);
 	INIT_WORK(&priv->tx_work, lbtf_tx_work);
+
+	printk(KERN_INFO "libertas_tf: Marvell WLAN 802.11 thinfirm adapter\n");
+
+	SET_IEEE80211_PERM_ADDR(hw, mac_addr);
+
 	if (ieee80211_register_hw(hw))
 		goto err_init_adapter;
 
Signature · 1 line
1.7.0
#8 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

More nits:

Quoted 51 lines · Steve deRosier

mac80211 requires that the MAC address be known and set before calling ieee80211_register_hw().  If this isn't done, we see bad MAC addresses in our packet headers.  In order to make this happen, I had to restructure to have if_sdio_probe load the firmware and get the hardware specs.

I had to add a if_sdio_update_hw_spec function as if_sdio can't use the standard command as several required variables aren't setup yet. if_sdio_update_hw_spec essentially uses polled io to get the hw spec command response from the card.

---
 drivers/net/wireless/libertas_tf/if_sdio.c     |  263 ++++++++++++++++++++---- drivers/net/wireless/libertas_tf/libertas_tf.h |    2 +- drivers/net/wireless/libertas_tf/main.c        |   38 +++--

 3 files changed, 248 insertions(+), 55 deletions(-)
drivers/net/wireless/libertas_tf/if_sdio.c +7 -3
index 1e72b4c..189b820 100644
@@ -91,12 +91,15 @@ struct if_sdio_card {
        u8                      rx_unit;
  };
 
-static int if_sdio_enable_interrupts(struct lbtf_private *priv)
+static int _if_sdio_enable_interrupts(struct if_sdio_card *card)
  {
-       struct if_sdio_card *card = priv->card;
        int ret;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);
@@ -109,9 +112,14 @@ static int if_sdio_enable_interrupts(struct lbtf_private *priv)
        return (ret);
  }
 
-static int if_sdio_disable_interrupts(struct lbtf_private *priv)
+static int if_sdio_enable_interrupts(struct lbtf_private *priv)
  {
        struct if_sdio_card *card = priv->card;
+       return _if_sdio_enable_interrupts(card);
+}
+
+static int _if_sdio_disable_interrupts(struct if_sdio_card *card)
+{
        int ret;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);
@@ -124,6 +132,12 @@ static int if_sdio_disable_interrupts(struct lbtf_private *priv)
        return (ret);
  }

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_disable_interrupts(struct lbtf_private *priv) · line 143

Quoted 10 lines
drivers/net/wireless/libertas_tf/if_sdio.c +6 -0
 
+static int if_sdio_disable_interrupts(struct lbtf_private *priv)
+{
+       struct if_sdio_card *card = priv->card;
+       return _if_sdio_disable_interrupts(card);
+}
+
  /*
  *  For SD8385/SD8686, this function reads firmware status after
  *  the image is downloaded, or reads RX packet length when

Are these changes really necessary here? - It'd probably be cleaner to change the initial functions to just take the card struct instead? (as it's always available as priv->card)

I'm guessing you're going to do something with the _* versions of these functions later, so should this change be there instead?

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_handle_cmd(struct if_sdio_card *card, · line 206

Quoted 8 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -187,7 +201,6 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
        struct lbtf_private *priv = card->priv;
        int ret;
        unsigned long flags;
-       u8 i;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);
 

Shouldn't this be elsewhere (maybe rolled into patch #1?)

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_prog_firmware(struct if_sdio_card *card) · line 731

Quoted 8 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -709,7 +726,6 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
                if( lbtf_reset_fw == 0 ) {
                        goto success;
                } else {
-                       int i = 0;
                        lbtf_deb_sdio("attempting to reset and reload firmware\n");
 
                        if_sdio_reset_device(card);

Ditto.

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_enter_deep_sleep(struct lbtf_private *priv) · line 868

Quoted 8 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -846,7 +863,6 @@ static int if_sdio_enter_deep_sleep(struct lbtf_private *priv)
 
  static int if_sdio_exit_deep_sleep(struct lbtf_private *priv)
  {
-       struct if_sdio_card *card = priv->card;
        int ret = -1;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);

Ditto.

Quoted 5 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -857,14 +873,12 @@ static int if_sdio_exit_deep_sleep(struct lbtf_private *priv)
 
  static int if_sdio_reset_deep_sleep_wakeup(struct lbtf_private *priv)
  {
-       struct if_sdio_card *card = priv->card;

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_exit_deep_sleep(struct lbtf_private *priv) · line 884

Quoted 10 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
        int ret = -1;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);
 
        lbtf_deb_leave_args(LBTF_DEB_SDIO, "ret %d", ret);
        return ret;
-
  }
 
  static void if_sdio_reset_device(struct if_sdio_card *card)

Ditto.

Quoted 12 lines
drivers/net/wireless/libertas_tf/main.c +1 -0
index 119d625..14ce1bc 100644
@@ -150,14 +150,15 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
        int ret = -1;
 
        lbtf_deb_enter(LBTF_DEB_FW);
+
        /*
         * Read priv address from HW
         */

drivers/net/wireless/libertas_tf/main.c static int lbtf_setup_firmware(struct lbtf_private *priv) · line 164

Quoted 10 lines
drivers/net/wireless/libertas_tf/main.c +2 -2
        memset(priv->current_addr, 0xff, ETH_ALEN);
        ret = lbtf_update_hw_spec(priv);
        if (ret) {
-               ret = -1;
-               goto done;
+                  ret = -1;
+                  goto done;
        }
 
        lbtf_set_mac_control(priv);

Whitespace change noise.

Quoted 8 lines
drivers/net/wireless/libertas_tf/main.c +1 -0
@@ -165,6 +166,7 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
        lbtf_set_mode(priv, LBTF_PASSIVE_MODE);
 
        ret = 0;
+

 done:
       lbtf_deb_leave_args(LBTF_DEB_FW, "ret: %d", ret); return ret;

And again.

drivers/net/wireless/libertas_tf/main.c static int lbtf_op_add_interface(struct ieee80211_hw *hw, · line 443

Quoted 8 lines
drivers/net/wireless/libertas_tf/main.c +1 -0
@@ -433,6 +437,7 @@ static int lbtf_op_add_interface(struct ieee80211_hw *hw,
                lbtf_set_mac_address(priv, (u8 *) vif->addr);
        }
 
+
        lbtf_deb_leave(LBTF_DEB_MACOPS);
        return 0;
  }

And again.

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#9 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 10 lines · Julian Calaby

More nits:

Are these changes really necessary here? - It'd probably be cleaner to change the initial functions to just take the card struct instead? (as it's always available as priv->card)

I'm guessing you're going to do something with the _* versions of these functions later, so should this change be there instead?

Yes, these changes are necessary. The enable and disable interrupt calls are called both from main.c as well as sdio.c. main.c has access to and needs to call with a priv, while at least one of the calls from sdio.c happens before priv exists. I could have changed the stuff in main.c to call with priv->card, but alas at the time I was still trying to minimize structural changes main.c and avoiding changes to the USB driver.

Quoted 11 lines

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_handle_cmd(struct if_sdio_card *card, · line 206

Quoted 8 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -187,7 +201,6 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
        struct lbtf_private *priv = card->priv;
        int ret;
        unsigned long flags;
-       u8 i;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);
 

Shouldn't this be elsewhere (maybe rolled into patch #1?)

It could be, but I didn't do this cleanup till now, some 20 commits later. Not that easy to pick and choose which lines from an atomic commit go to which patch some weeks later.

Quoted 10 lines

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_prog_firmware(struct if_sdio_card *card) · line 731

Quoted 8 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -709,7 +726,6 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
                if( lbtf_reset_fw == 0 ) {
                        goto success;
                } else {
-                       int i = 0;
                        lbtf_deb_sdio("attempting to reset and reload firmware\n");
 
                        if_sdio_reset_device(card);

Ditto.

Ditto. And so on...

Quoted 21 lines
Quoted 21 lines
drivers/net/wireless/libertas_tf/main.c +3 -2
index 119d625..14ce1bc 100644
@@ -150,14 +150,15 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
        int ret = -1;
 
        lbtf_deb_enter(LBTF_DEB_FW);
+
        /*
         * Read priv address from HW
         */
        memset(priv->current_addr, 0xff, ETH_ALEN);
        ret = lbtf_update_hw_spec(priv);
        if (ret) {
-               ret = -1;
-               goto done;
+                  ret = -1;
+                  goto done;
        }
 
Quoted 3 lines

drivers/net/wireless/libertas_tf/main.c static int lbtf_setup_firmware(struct lbtf_private *priv) · line 164

Quoted 1 line
drivers/net/wireless/libertas_tf/main.c +0 -0
        lbtf_set_mac_control(priv);

Whitespace change noise.

Well, perhaps. On the other hand, it made it more readable to me (the first one, the newline. The indentation change is actually incorrect, no doubt about it). Have you ever worked with a codebase for 3 some months and not incidentally or accidentally changed some whitespace? If this patch was just to change whitespace, then I'd agree with you and wouldn't have wasted time bothering to submit it, but the patch as a whole adds necessary functionality.

If you want me to fix the whitespace, I can.

Thanks,
- Steve

#10 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 12 lines · Steve deRosier
Quoted 10 lines · Julian Calaby

More nits:

Are these changes really necessary here? - It'd probably be cleaner to change the initial functions to just take the card struct instead? (as it's always available as priv->card)

I'm guessing you're going to do something with the _* versions of these functions later, so should this change be there instead?

Quoted 7 lines

Yes, these changes are necessary.  The enable and disable interrupt calls are called both from main.c as well as sdio.c.  main.c has access to and needs to call with a priv, while at least one of the calls from sdio.c happens before priv exists.  I could have changed the stuff in main.c to call with priv->card, but alas at the time I was still trying to minimize structural changes main.c and avoiding changes to the USB driver.

I'm no maintainer, but my opinion is that it's better to make (sensible) sweeping changes to a code base, then add the changes you want to make, rather than adding extra functions to access a particular piece of functionality in different ways.

Quoted 12 lines
Quoted 11 lines

drivers/net/wireless/libertas_tf/if_sdio.c static int if_sdio_handle_cmd(struct if_sdio_card *card, · line 206

Quoted 8 lines
drivers/net/wireless/libertas_tf/if_sdio.c +0 -1
@@ -187,7 +201,6 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
        struct lbtf_private *priv = card->priv;
        int ret;
        unsigned long flags;
-       u8 i;
 
        lbtf_deb_enter(LBTF_DEB_SDIO);
 

Shouldn't this be elsewhere (maybe rolled into patch #1?)

Quoted 3 lines

It could be, but I didn't do this cleanup till now, some 20 commits later.  Not that easy to pick and choose which lines from an atomic commit go to which patch some weeks later.

I know it isn't - I'm doing exactly that for a project I'm working on, and my MO is to split out such changes, then roll them into more appropriate patches later. (e.g. if I'm making the foo() function do bar work, and, in the process of doing this, fix a whole stack of stupid code in it, I'll commit the latter first, then the former, then roll the changes into more appropriate patches - even if that means more work for me. - But then I am pedantic about that.) These changes are, in a way, why I've run my particular fine tooth comb over your patches - I'm bored =)

Quoted 25 lines
Quoted 21 lines
Quoted 21 lines
drivers/net/wireless/libertas_tf/main.c +3 -2
index 119d625..14ce1bc 100644
@@ -150,14 +150,15 @@ static int lbtf_setup_firmware(struct lbtf_private *priv)
        int ret = -1;
 
        lbtf_deb_enter(LBTF_DEB_FW);
+
        /*
         * Read priv address from HW
         */
        memset(priv->current_addr, 0xff, ETH_ALEN);
        ret = lbtf_update_hw_spec(priv);
        if (ret) {
-               ret = -1;
-               goto done;
+                  ret = -1;
+                  goto done;
        }
 
Quoted 3 lines

drivers/net/wireless/libertas_tf/main.c static int lbtf_setup_firmware(struct lbtf_private *priv) · line 164

Quoted 1 line
drivers/net/wireless/libertas_tf/main.c +0 -0
        lbtf_set_mac_control(priv);

Whitespace change noise.

Quoted 7 lines

Well, perhaps.  On the other hand, it made it more readable to me (the first one, the newline.  The indentation change is actually incorrect, no doubt about it).  Have you ever worked with a codebase for 3 some months and not incidentally or accidentally changed some whitespace? If this patch was just to change whitespace, then I'd agree with you and wouldn't have wasted time bothering to submit it, but the patch as a whole adds necessary functionality.

Yes, I have. (and it was over 3 years in my case)

Quoted 1 line

From what I understand, it's expected that white space changes and

other trivial cleanups get their own patches, mainly so that it's easier to review separate patches. E.g. If I change the parameters passed to bar(), and in the process lean up the whitespace in one of the functions that calls it, those extra changes, whilst not that significant, can make the patch harder to read. Some of the SCSI maintainers get particularly pedantic about this, (with occasional discussions on whether a piece of whitespace should or should not be changed) but I expect the wireless folks are a little more relaxed. =)

I'm not meaning to lean on you over all of this, just running my eyes over these patches.

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
maintainer
#11 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

In reply to Steve deRosier
Quoted 3 lines · Steve deRosier

mac80211 requires that the MAC address be known and set before calling ieee80211_register_hw(). If this isn't done, we see bad MAC addresses in our packet headers. In order to make this happen, I had to

restructure

Quoted 7 lines

to have if_sdio_probe load the firmware and get the hardware specs.

I had to add a if_sdio_update_hw_spec function as if_sdio can't use the standard
command as several required variables aren't setup yet. if_sdio_update_hw_spec essentially uses polled io to get the hw spec command response from the card.

You should probably keep this for development purposes, but it will break if your code is built into the kernel. The working model we've adopted to solve this is to use request_firmware_nowait() in probe, and then only continue doing work when the firmware loading returns (and then register with mac80211 etc)

johannes

#12 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 15 lines · Johannes Berg
Quoted 3 lines · Steve deRosier

mac80211 requires that the MAC address be known and set before calling ieee80211_register_hw().  If this isn't done, we see bad MAC addresses in our packet headers.  In order to make this happen, I had to

restructure

Quoted 7 lines

to have if_sdio_probe load the firmware and get the hardware specs.

I had to add a if_sdio_update_hw_spec function as if_sdio can't use the standard
command as several required variables aren't setup yet. if_sdio_update_hw_spec essentially uses polled io to get the hw spec command response from the card.

Quoted 6 lines

You should probably keep this for development purposes, but it will break if your code is built into the kernel. The working model we've adopted to solve this is to use request_firmware_nowait() in probe, and then only continue doing work when the firmware loading returns (and then register with mac80211 etc)

Johannes,

Before doing any of this stuff (back in patch 1), my driver goes through and loads the firmware using the request_firmware() calls anyway. In other words, I haven't changed that part. Is the problem specifically with my "get the MAC from the hardware before setting up mac80211" change, or with waiting on firmware loading?

For fun, I just tried compiling the driver into the kernel. Mixed
results: with two cards on the system, the first card found failed on the call to request_firmware() with a -ENOENT, while the second card came up just fine. When done as modules, both work fine. So there's clearly something to what you're saying. Is it that the filesystem is not up and available yet when we try to load the firmware for the first card?

Quoted 1 line

From looking through the drivers, iwl and ar9170_usb are the only ones

to use the request_firmware_nowait(). I don't know if those are the only mac80211 cards with firmware or not everyone's following the model.

Do you have specific pointers of which code I should look at as a model, or a better way to solve the problem?

In the short term, can we limit libertas_tf to build as module only via Kconfig, and I can add the request_firmware_nowait() as a new feature later with a new patch? Looking at the examples, it looks like the changes for this would be fairly involved and I would prefer to break such a change out separately. I'd like to get libertas_tf_sdio accepted as a base so I can then do smaller change sets going forward. Is that a reasonable plan or just plain silly?

BTW, thanks for pointing out this problem. I hadn't tried this built into the kernel and it never occurred to me that this would be an issue.

Thanks,
- Steve

maintainer
#13 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 3 lines · Steve deRosier

Before doing any of this stuff (back in patch 1), my driver goes through and loads the firmware using the request_firmware() calls anyway.

Right.

Quoted 3 lines

In other words, I haven't changed that part. Is the problem specifically with my "get the MAC from the hardware before setting up mac80211" change, or with waiting on firmware loading?

Well, so previously mac80211 had some support for *not* knowing the MAC address before setting up all of the mac80211 stuff, but that broke and I'd like to remove it as well because it advertises wrong things to userspace. So you need to know the MAC address before registering with mac80211.

Now, on libertas_tf (correct me if I'm wrong), the firmware has to be loaded to read the MAC address. So you need to load the firmware in probe or so, like you do now. Then, however, building it into the kernel may fail to load the firmware.

Quoted 7 lines

For fun, I just tried compiling the driver into the kernel. Mixed
results: with two cards on the system, the first card found failed on the call to request_firmware() with a -ENOENT, while the second card came up just fine. When done as modules, both work fine. So there's clearly something to what you're saying. Is it that the filesystem is not up and available yet when we try to load the firmware for the first card?

Yeah, userspace needs to be up and running to load firmware.

Quoted 4 lines

From looking through the drivers, iwl and ar9170_usb are the only ones to use the request_firmware_nowait(). I don't know if those are the only mac80211 cards with firmware or not everyone's following the model.

Well, not everyone's following the model _yet_ (look at mwl8k for example), but nobody but libertas_tf needs firmware loaded to know the MAC address. So they don't have the MAC address issue there.

Quoted 2 lines

Do you have specific pointers of which code I should look at as a model, or a better way to solve the problem?

You should probably look at ar9170 or iwlwifi.

Quoted 3 lines

In the short term, can we limit libertas_tf to build as module only via Kconfig, and I can add the request_firmware_nowait() as a new feature later with a new patch?

Certainly. I just wanted to point it out. This wasn't meant as a comment that should stop merging of these patches.

Quoted 3 lines

Looking at the examples, it looks
like the changes for this would be fairly involved and I would prefer to break such a change out separately.

Yeah, I tried to do it in libertas_tf at some point last year and failed miserably :-)

Quoted 3 lines

I'd like to get
libertas_tf_sdio accepted as a base so I can then do smaller change sets going forward. Is that a reasonable plan or just plain silly?

Makes sense to me.

johannes

#14 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 13 lines · Johannes Berg

On Thu, 9 Sep 2010 12:13:52 -0700, Steve deRosier <[email protected]>

Quoted 3 lines

In the short term, can we limit libertas_tf to build as module only via Kconfig, and I can add the request_firmware_nowait() as a new feature later with a new patch?

Certainly. I just wanted to point it out. This wasn't meant as a comment that should stop merging of these patches.

Quoted 3 lines

Looking at the examples, it looks
like the changes for this would be fairly involved and I would prefer to break such a change out separately.

Quoted 9 lines

Yeah, I tried to do it in libertas_tf at some point last year and failed miserably :-)

Quoted 3 lines

I'd like to get
libertas_tf_sdio accepted as a base so I can then do smaller change sets going forward. Is that a reasonable plan or just plain silly?

Makes sense to me.

In light of the above, and Julian's comments, I'm going to rework the libertas_tf patch set a little. I'll make the following two changes:
1. Restrict building to module-only for now. This avoids building it into the kernel which we know will break. Latter when I have time I'll happily do what's necessary to make the fix Johannes wants, but as it's not trivial I want to get a base down.
2. I'll change a few things around as Julian's advised so the patch set makes a bit more sense. I'll be also killing some inadvertent white-space changes that were mistakes.

I think my mac80211 patch "mac80211: Fix dangling pointer in ieee80211_xmit" stands 100% alone and fixes a clear bug. I don't see any need to delay that one.

It might be a few days before I get these in.

Thanks,
- Steve

maintainer
#15 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 3 lines · Steve deRosier

I think my mac80211 patch "mac80211: Fix dangling pointer in ieee80211_xmit" stands 100% alone and fixes a clear bug. I don't see any need to delay that one.

Agree, best resend it outside this series, or if John wants to just pick it up outside the series.

(Generally, I would ask to send mac80211 patches outside driver series anyway, because it makes it harder to miss such things)

johannes

#16 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

In reply to Steve deRosier
Quoted 9 lines · Steve deRosier

In light of the above, and Julian's comments, I'm going to rework the libertas_tf patch set a little. I'll make the following two changes:
1. Restrict building to module-only for now. This avoids building it into the kernel which we know will break. Latter when I have time I'll happily do what's necessary to make the fix Johannes wants, but as it's not trivial I want to get a base down.
2. I'll change a few things around as Julian's advised so the patch set makes a bit more sense. I'll be also killing some inadvertent white-space changes that were mistakes.

I interpret this as "drop this series -- new series will replace it".

Quoted 3 lines

I think my mac80211 patch "mac80211: Fix dangling pointer in ieee80211_xmit" stands 100% alone and fixes a clear bug. I don't see any need to delay that one.

I missed this before -- I'll take that patch on its own.

Quoted 1 line

It might be a few days before I get these in.

Is this still coming?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#17 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

Quoted 5 lines · John W. Linville
Quoted 3 lines

I think my mac80211 patch "mac80211: Fix dangling pointer in ieee80211_xmit" stands 100% alone and fixes a clear bug. I don't see any need to delay that one.

I missed this before -- I'll take that patch on its own.

Actually, looks like I already did... :-)

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#18 lore raw

Re: [PATCH 5/9] libertas_tf: Moved firmware loading to probe in order to fetch MAC address

In reply to John W. Linville
Quoted 1 line · John W. Linville

I interpret this as "drop this series -- new series will replace it".

Yes, "drop this series -- new series will replace it". I'll be more clear next time. :)

Quoted 4 lines
Quoted 1 line

It might be a few days before I get these in.

Is this still coming?

Yes. Due to vacation and other work commitments, I've been delayed on the patches. I'll try to finish it up and resubmit sometime next week.

- Steve

#19 lore raw

PATCH 6/9 libertas_tf: Fix to enable interrupts even when firmware has already started

In reply to Steve deRosier
---
 drivers/net/wireless/libertas_tf/main.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/wireless/libertas_tf/main.c +9 -9
index 14ce1bc..b797787 100644
@@ -327,20 +327,20 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
 
 	lbtf_deb_enter(LBTF_DEB_MACOPS);
 
-	if (priv->hw_prog_firmware) {
-		if (!priv->fw_ready) {
-			lbtf_deb_main("Going to upload fw...");
-			/* Upload firmware */
+	if (!priv->fw_ready) {
+		lbtf_deb_main("Going to upload fw...");
+		/* Upload firmware */
+		if (priv->hw_prog_firmware) {
 			if (priv->hw_prog_firmware(card))
 				goto err_prog_firmware;
 			else
 				priv->fw_ready = 1;
-		} else {
-			if (priv->enable_interrupts) {
-				priv->enable_interrupts(priv);
-			}
-			lbtf_deb_main("FW was already ready...");
 		}
+	} else {
+		if (priv->enable_interrupts) {
+			priv->enable_interrupts(priv);
+		}
+		lbtf_deb_main("FW was already ready...");
 	}
 
 	/* poke the firmware */
Signature · 1 line
1.7.0
#20 lore raw

Re: [PATCH 6/9] libertas_tf: Fix to enable interrupts even when firmware has already started

Quoted 5 lines · Steve deRosier

---
 drivers/net/wireless/libertas_tf/main.c |   18 +++++++++---------

 1 files changed, 9 insertions(+), 9 deletions(-)

Shouldn't this be rolled into the previous patch?

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#21 lore raw

PATCH 7/9 libertas_tf: Add tx feedback to libertas_tf_sdio

In reply to Steve deRosier

This patch adds tx-feedback to libertas_tf_sdio so that mac80211 rate adaptation and other bookkeeping tasks function properly.

---
 drivers/net/wireless/libertas_tf/deb_defs.h |    5 ++
 drivers/net/wireless/libertas_tf/if_sdio.c  |   42 +++++++++++------
 drivers/net/wireless/libertas_tf/main.c     |   65 ++++++++++++++++----------
 3 files changed, 72 insertions(+), 40 deletions(-)
drivers/net/wireless/libertas_tf/deb_defs.h +5 -0
index 99a7478..8e86e11 100644
@@ -43,6 +43,9 @@
 #define LBTF_DEB_HEX	0x00200000
 #define LBTF_DEB_SDIO	0x00400000
 #define LBTF_DEB_MACOPS	0x00800000
+#define LBTF_DEB_STATS	0x01000000
+#define LBTF_DEB_INT    0x02000000
+#define LBTF_DEB_SCRATCH 0x04000000
 
 extern unsigned int lbtf_debug;
 
@@ -87,6 +90,8 @@ do { if ((lbtf_debug & (grp)) == (grp)) \
 #define lbtf_deb_thread(fmt, args...)    LBTF_DEB_LL(LBTF_DEB_THREAD, " thread", fmt, ##args)
 #define lbtf_deb_sdio(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_SDIO, " sdio", fmt, ##args)
 #define lbtf_deb_macops(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_MACOPS, " thread", fmt, ##args)
+#define lbtf_deb_stats(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_STATS, " statistics", fmt, ##args)
+#define lbtf_deb_int(fmt, args...)      LBTF_DEB_LL(LBTF_DEB_INT, " int", fmt, ##args)
 
 #ifdef DEBUG
 static inline void lbtf_deb_hex(unsigned int grp, const char *prompt, u8 *buf, int len)
drivers/net/wireless/libertas_tf/if_sdio.c +27 -15

115 lines not on this page · raw message

drivers/net/wireless/libertas_tf/main.c +40 -25

105 lines not on this page · raw message

Signature · 1 line
1.7.0
#22 lore raw

Re: [PATCH 7/9] libertas_tf: Add tx feedback to libertas_tf_sdio

More nits:

Quoted 15 lines · Steve deRosier

This patch adds tx-feedback to libertas_tf_sdio so that mac80211 rate adaptation and other bookkeeping tasks function properly.

---
 drivers/net/wireless/libertas_tf/deb_defs.h |    5 ++ drivers/net/wireless/libertas_tf/if_sdio.c  |   42 +++++++++++------ drivers/net/wireless/libertas_tf/main.c     |   65 ++++++++++++++++----------

 3 files changed, 72 insertions(+), 40 deletions(-)
drivers/net/wireless/libertas_tf/deb_defs.h +0 -0
index 99a7478..8e86e11 100644

drivers/net/wireless/libertas_tf/deb_defs.h static void if_sdio_interrupt(struct sdio_func *func) · line 1082

Quoted 8 lines
drivers/net/wireless/libertas_tf/deb_defs.h +0 -2
@@ -1063,25 +1077,23 @@ static void if_sdio_interrupt(struct sdio_func *func)
        if (ret)
                goto out;
 
-//     lbtf_deb_sdio("interrupt: 0x%X\n", (unsigned)cause);
-
        sdio_writeb(card->func, ~cause, IF_SDIO_H_INT_STATUS, &ret);
        if (ret)
                goto out;

Shouldn't this have been removed instead of being commented in the patch that commented it?

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#23 lore raw

Re: [PATCH 7/9] libertas_tf: Add tx feedback to libertas_tf_sdio

Quoted 21 lines · Julian Calaby

More nits:

Quoted 18 lines · Steve deRosier

This patch adds tx-feedback to libertas_tf_sdio so that mac80211 rate adaptation and other bookkeeping tasks function properly.

---
 drivers/net/wireless/libertas_tf/deb_defs.h |    5 ++ drivers/net/wireless/libertas_tf/if_sdio.c  |   42 +++++++++++------ drivers/net/wireless/libertas_tf/main.c     |   65 ++++++++++++++++----------

 3 files changed, 72 insertions(+), 40 deletions(-)
drivers/net/wireless/libertas_tf/deb_defs.h +0 -0
index 99a7478..8e86e11 100644
@@ -1063,25 +1077,23 @@ static void if_sdio_interrupt(struct sdio_func *func)
        if (ret)
                goto out;
 
Quoted 9 lines

drivers/net/wireless/libertas_tf/deb_defs.h static void if_sdio_interrupt(struct sdio_func *func) · line 1082

Quoted 5 lines
drivers/net/wireless/libertas_tf/deb_defs.h +0 -2
-//     lbtf_deb_sdio("interrupt: 0x%X\n", (unsigned)cause);
-
        sdio_writeb(card->func, ~cause, IF_SDIO_H_INT_STATUS, &ret);
        if (ret)
                goto out;

Shouldn't this have been removed instead of being commented in the patch that commented it?

Until this time I was using this line intermittently. I frequently uncommented it in order to see some debugging info. But as it is in an interrupt, it creates a lot of noise that I usually didn't want to see. Once I was past a certain point (here) and didn't need it anymore, it got deleted.

I could have rolled all the patches into one single patch that was nice and neat with a blue bow, but then you wouldn't have seen all the fun I had and you would have missed out. :)

Thanks,
- Steve

#24 lore raw

Re: [PATCH 7/9] libertas_tf: Add tx feedback to libertas_tf_sdio

Quoted 38 lines · Steve deRosier
Quoted 21 lines · Julian Calaby

More nits:

Quoted 18 lines · Steve deRosier

This patch adds tx-feedback to libertas_tf_sdio so that mac80211 rate adaptation and other bookkeeping tasks function properly.

---
 drivers/net/wireless/libertas_tf/deb_defs.h |    5 ++ drivers/net/wireless/libertas_tf/if_sdio.c  |   42 +++++++++++------ drivers/net/wireless/libertas_tf/main.c     |   65 ++++++++++++++++----------

 3 files changed, 72 insertions(+), 40 deletions(-)
drivers/net/wireless/libertas_tf/deb_defs.h +0 -0
index 99a7478..8e86e11 100644
@@ -1063,25 +1077,23 @@ static void if_sdio_interrupt(struct sdio_func *func)
        if (ret)
                goto out;
 
Quoted 9 lines

drivers/net/wireless/libertas_tf/deb_defs.h static void if_sdio_interrupt(struct sdio_func *func) · line 1082

Quoted 5 lines
drivers/net/wireless/libertas_tf/deb_defs.h +0 -2
-//     lbtf_deb_sdio("interrupt: 0x%X\n", (unsigned)cause);
-
        sdio_writeb(card->func, ~cause, IF_SDIO_H_INT_STATUS, &ret);
        if (ret)
                goto out;

Shouldn't this have been removed instead of being commented in the patch that commented it?

Until this time I was using this line intermittently.  I frequently uncommented it in order to see some debugging info.  But as it is in an interrupt, it creates a lot of noise that I usually didn't want to see.  Once I was past a certain point (here) and didn't need it anymore, it got deleted.

Quoted 3 lines

I could have rolled all the patches into one single patch that was nice and neat with a blue bow, but then you wouldn't have seen all the fun I had and you would have missed out.  :)

Hehehe. Quite. I guess I'm just more pedantic about such things than most people. Ah well =)

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#25 lore raw

PATCH 8/9 libertas_tf: updated with beacon code

In reply to Steve deRosier
---
 drivers/net/wireless/libertas_tf/cmd.c         |    2 +-
 drivers/net/wireless/libertas_tf/if_sdio.c     |    5 +-
 drivers/net/wireless/libertas_tf/libertas_tf.h |    6 ++
 drivers/net/wireless/libertas_tf/main.c        |   88 ++++++++++++++++++------
 4 files changed, 78 insertions(+), 23 deletions(-)
drivers/net/wireless/libertas_tf/cmd.c +1 -1
index 738a2ff..8c15e35 100644
@@ -354,7 +354,7 @@ void lbtf_set_bssid(struct lbtf_private *priv, bool activate, const u8 *bssid)
 {
 	struct cmd_ds_set_bssid cmd;
 	lbtf_deb_enter(LBTF_DEB_CMD);
-
+	lbtf_deb_cmd("Set BSSID: %pM a: %d", bssid, activate);
 	cmd.hdr.size = cpu_to_le16(sizeof(cmd));
 	cmd.activate = activate ? 1 : 0;
 	if (activate)
drivers/net/wireless/libertas_tf/if_sdio.c +4 -1
index 5074f8b..09c028f 100644
@@ -303,8 +303,11 @@ static int if_sdio_handle_event(struct if_sdio_card *card,
 			failure = (tmp & 0xff00) >> 8;
 			lbtf_deb_stats("Got feedback event. retry: %d, failure: %d", retrycnt, failure);
 			lbtf_send_tx_feedback(card->priv, retrycnt, failure);
-		} else if (event == LBTF_EVENT_BCN_SENT)
+		} else if (event == LBTF_EVENT_BCN_SENT) {
 			lbtf_bcn_sent(card->priv);
+		} else {
+			lbtf_deb_stats("UNKNOWN HOST EVENT: 0x%x", event);
+		}
 
 	ret = 0;
 
drivers/net/wireless/libertas_tf/libertas_tf.h +6 -0
index c7588fd..db6dd7b 100644
@@ -241,6 +241,8 @@ struct lbtf_private {
 
 	struct sk_buff *skb_to_tx;
 	struct sk_buff *tx_skb;
+	struct sk_buff *tx_skb_old;
+	struct sk_buff_head tx_skb_buf;
 
 	/** NIC Operation characteristics */
 	u16 mac_control;
@@ -267,6 +269,10 @@ struct lbtf_private {
 	u8 resp_idx;
 	u8 resp_buf[2][LBS_UPLD_SIZE];
 	u32 resp_len[2];
+	
+	/* beacon status info */
+	bool beacon_enable;
+	u16 beacon_int;
 
 };
 
drivers/net/wireless/libertas_tf/main.c +67 -21

188 lines not on this page · raw message

Signature · 1 line
1.7.0
#26 lore raw

Re: [PATCH 8/9] libertas_tf: updated with beacon code

Quoted 2 lines · Steve deRosier

It'd be nice if the subject line of this patch was a bit more descriptive.

Something like "libertas_tf: Update beacon code" would be descriptive.

Also, it appears that this patch does two things, update the beacon code and add some debugging. You may want to separate this into two patches.

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#27 lore raw

Re: [PATCH 8/9] libertas_tf: updated with beacon code

Quoted 3 lines · Julian Calaby

Also, it appears that this patch does two things, update the beacon code and add some debugging. You may want to separate this into two patches.

Well, the debugging was added _for_ the beacon code and to debug the beacon code either here in the driver or the interaction with new beacon code in the firmware.

Thanks,
- Steve

#28 lore raw

Re: [PATCH 8/9] libertas_tf: updated with beacon code

Quoted 8 lines · Steve deRosier
Quoted 3 lines · Julian Calaby

Also, it appears that this patch does two things, update the beacon code and add some debugging. You may want to separate this into two patches.

Well, the debugging was added _for_ the beacon code and to debug the beacon code either here in the driver or the interaction with new beacon code in the firmware.

You should probably mention that in the commit message then.

libertas_tf: Update beacon code

Update beacon code and add beacon debugging info.

Thanks,

Signature · 5 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
#29 lore raw

PATCH 9/9 libertas_tf: Allow tx up to full chip buffers

In reply to Steve deRosier
---
 drivers/net/wireless/libertas_tf/libertas_tf.h |    1 +
 drivers/net/wireless/libertas_tf/main.c        |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)
drivers/net/wireless/libertas_tf/libertas_tf.h +1 -0
index db6dd7b..5ccec4d 100644
@@ -104,6 +104,7 @@ enum lbtf_mode {
 #define LBS_CMD_BUFFER_SIZE             (2 * 1024)
 #define MRVDRV_MAX_CHANNEL_SIZE		14
 #define MRVDRV_SNAP_HEADER_LEN          8
+#define LBS_NUM_BUFFERS				7
 
 #define	LBS_UPLD_SIZE			2312
 #define DEV_NAME_LEN			32
drivers/net/wireless/libertas_tf/main.c +4 -1
index 6c4a1b6..0b03fd5 100644
@@ -315,8 +315,11 @@ static void lbtf_tx_work(struct work_struct *work)
 		dev_kfree_skb_any(skb);
 		skb_dequeue_tail(&priv->tx_skb_buf);
 		pr_err("TX error: %d", err);
+	} else {
+		if (LBS_NUM_BUFFERS > skb_queue_len(&priv->tx_skb_buf))
+			ieee80211_wake_queues(priv->hw);
+		lbtf_deb_tx("TX success");
 	}
-	lbtf_deb_tx("TX success");
 	lbtf_deb_leave(LBTF_DEB_MACOPS | LBTF_DEB_TX);
 }
 
Signature · 1 line
1.7.0