Skip to contentSkip to conversation

New patch series for merge

PATCH In review Michael Buesch 2 participants 11 messages Aug 23, 2007 – Aug 24, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover New patch series for merge

Hi John,

This patch series catches wireless-dev up to my
current wireless-development patchset.

Please merge this into wireless-dev.

#1 lore raw

PATCH 1/7 b43: Change Kconfig help text

Hopefully people can understand this better.

drivers/net/wireless/b43/Kconfig +20 -10
Index: wireless-dev-new/drivers/net/wireless/b43/Kconfig
===================================================================
@@ -1,21 +1,31 @@
 config B43
 	tristate "Broadcom 43xx wireless support (mac80211 stack)"
-	depends on SSB_POSSIBLE && MAC80211 && WLAN_80211 && EXPERIMENTAL
+	depends on SSB_POSSIBLE && MAC80211 && WLAN_80211
 	select SSB
 	select FW_LOADER
 	select HW_RANDOM
 	---help---
-	  This is an experimental driver for the Broadcom 43xx wireless chip,
-	  found in the Apple Airport Extreme and various other devices. This
-	  driver supports 802.11a and 802.11g, but not 802.11b. As a result,
-	  BCM4301 and BCM4303 are not supported - use b43legacy instead.
-	  It is safe to include both b43 and b43legacy as the ssb driver will
-	  load the correct version for your device.
+	  b43 is a driver for the Broadcom 43xx series wireless devices.
+
+	  Check "lspci" for something like
+	  "Broadcom Corporation BCM43XX 802.11 Wireless LAN Controller"
+	  to determine whether you own such a device.
+
+	  This driver supports the new BCM43xx IEEE 802.11G devices, but not
+	  the old IEEE 802.11B devices. Old devices are supported by
+	  the b43legacy driver.
+	  Note that this has nothing to do with the standard that your AccessPoint
+	  supports (A, B, G or a combination).
+	  IEEE 802.11G devices can talk to IEEE 802.11B AccessPoints.
+
+	  It is safe to include both b43 and b43legacy as the underlying glue
+	  layer will automatically load the correct version for your device.
 
 	  This driver uses V4 firmware, which must be installed separately using
 	  b43-fwcutter.
 
 	  This driver can be built as a module (recommended) that will be called "b43".
+	  If unsure, say M.
 
 # Auto-select SSB PCI-HOST support, if possible
 config B43_PCI_AUTOSELECT
@@ -32,8 +42,8 @@ config B43_PCICORE_AUTOSELECT
 	default y
 
 config B43_PCMCIA
-	bool "Broadcom 43xx PCMCIA device support"
-	depends on B43 && SSB_PCMCIAHOST_POSSIBLE
+	bool "Broadcom 43xx PCMCIA device support (EXPERIMENTAL)"
+	depends on B43 && SSB_PCMCIAHOST_POSSIBLE && EXPERIMENTAL
 	select SSB_PCMCIAHOST
 	---help---
 	  Broadcom 43xx PCMCIA device support.
@@ -41,7 +51,7 @@ config B43_PCMCIA
 	  Support for 16bit PCMCIA devices.
 	  Please note that most PC-CARD devices are _NOT_ 16bit PCMCIA
 	  devices, but 32bit CardBUS devices. CardBUS devices are supported
-	  by "B43 PCI device support".
+	  out of the box by b43.
 
 	  With this config option you can drive b43 cards in
 	  CompactFlash formfactor in a PCMCIA adaptor.
#2 lore raw

PATCH 2/7 b43: Fix oops when firmware not found

In reply to Michael Buesch

Add a return statement.

drivers/net/wireless/b43/main.c +1 -0
Index: wireless-dev-new/drivers/net/wireless/b43/main.c
===================================================================
@@ -1601,6 +1601,7 @@ static int do_request_fw(struct b43_wlde
 	if (err) {
 		b43err(dev->wl, "Firmware file \"%s\" not found "
 		       "or load failed.\n", path);
+		return err;
 	}
 	if ((*fw)->size < sizeof(struct b43_fw_header))
 		goto err_format;
#3 lore raw

PATCH 3/7 b43: allow disabling hardware encryption

In reply to Michael Buesch

From: Johannes Berg <[email protected]>

For debugging it seems useful to be able to turn off hardware encryption. With the changes I made to mac80211 that is now simple.

drivers/net/wireless/b43/main.c +7 -0
Index: wireless-dev-new/drivers/net/wireless/b43/main.c
===================================================================
@@ -104,6 +104,10 @@ static int modparam_hwpctl;
 module_param_named(hwpctl, modparam_hwpctl, int, 0444);
 MODULE_PARM_DESC(hwpctl, "Enable hardware-side power control (default off)");
 
+static int modparam_nohwcrypt;
+module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
+MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
+
 static const struct ssb_device_id b43_ssb_tbl[] = {
 	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 5),
 	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 6),
@@ -2872,6 +2876,9 @@ static int b43_dev_set_key(struct ieee80
 	u8 index;
 	int err = -EINVAL;
 
+	if (modparam_nohwcrypt)
+		return -ENOSPC; /* User disabled HW-crypto */
+
 	if (!dev)
 		return -ENODEV;
 	switch (key->alg) {
#4 lore raw

PATCH 4/7 b43: Add debugfs file to extract LO calibration data

In reply to Michael Buesch

Add a file to debugfs to extract the Local Oscillator calibration data.

drivers/net/wireless/b43/debugfs.c +93 -0
Index: wireless-dev-new/drivers/net/wireless/b43/debugfs.c
===================================================================
@@ -374,6 +374,88 @@ static ssize_t txpower_g_write_file(stru
 	return res;
 }
 
+static size_t append_lo_table(size_t pos, char *buf, const size_t len,
+			      struct b43_loctl table[B43_NR_BB][B43_NR_RF])
+{
+	unsigned int i, j;
+	struct b43_loctl *ctl;
+
+	for (i = 0; i < B43_NR_BB; i++) {
+		for (j = 0; j < B43_NR_RF; j++) {
+			ctl = &(table[i][j]);
+			fappend("(bbatt %2u, rfatt %2u)  ->  "
+				"(I %+3d, Q %+3d, Used: %d, Calibrated: %d)\n",
+				i, j, ctl->i, ctl->q,
+				ctl->used,
+				b43_loctl_is_calibrated(ctl));
+		}
+	}
+
+	return pos;
+}
+
+static ssize_t loctls_read_file(struct file *file, char __user *userbuf,
+				size_t count, loff_t *ppos)
+{
+	struct b43_wldev *dev = file->private_data;
+	const size_t len = ARRAY_SIZE(big_buffer);
+	char *buf = big_buffer;
+	size_t pos = 0;
+	ssize_t res;
+	unsigned long flags;
+	struct b43_txpower_lo_control *lo;
+	unsigned int i;
+
+	mutex_lock(&big_buffer_mutex);
+	mutex_lock(&dev->wl->mutex);
+	spin_lock_irqsave(&dev->wl->irq_lock, flags);
+	if (b43_status(dev) < B43_STAT_INITIALIZED) {
+		fappend("Not initialized\n");
+		goto out;
+	}
+	if (dev->phy.type != B43_PHYTYPE_G) {
+		fappend("Device is not a G-PHY\n");
+		goto out;
+	}
+
+	lo = dev->phy.lo_control;
+	fappend("-- Local Oscillator calibration data --\n\n");
+	fappend("Measured: %d,  Rebuild: %d,  HW-power-control: %d\n",
+		lo->lo_measured,
+		lo->rebuild,
+		dev->phy.hardware_power_control);
+	fappend("TX Bias: 0x%02X,  TX Magn: 0x%02X\n",
+		lo->tx_bias, lo->tx_magn);
+	fappend("Power Vector: 0x%08X%08X\n",
+		(unsigned int)((lo->power_vector & 0xFFFFFFFF00000000ULL) >> 32),
+		(unsigned int)(lo->power_vector & 0x00000000FFFFFFFFULL));
+	fappend("\nControl table WITH PADMIX:\n");
+	pos = append_lo_table(pos, buf, len, lo->with_padmix);
+	fappend("\nControl table WITHOUT PADMIX:\n");
+	pos = append_lo_table(pos, buf, len, lo->no_padmix);
+	fappend("\nUsed RF attenuation values:  Value(WithPadmix flag)\n");
+	for (i = 0; i < lo->rfatt_list.len; i++) {
+		fappend("%u(%d), ",
+			lo->rfatt_list.list[i].att,
+			lo->rfatt_list.list[i].with_padmix);
+	}
+	fappend("\n");
+	fappend("\nUsed Baseband attenuation values:\n");
+	for (i = 0; i < lo->bbatt_list.len; i++) {
+		fappend("%u, ",
+			lo->bbatt_list.list[i].att);
+	}
+	fappend("\n");
+
+out:
+	spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
+	mutex_unlock(&dev->wl->mutex);
+	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	mutex_unlock(&big_buffer_mutex);
+
+	return res;
+}
+
 #undef fappend
 
 static struct file_operations drvinfo_fops = {
@@ -405,6 +487,12 @@ static struct file_operations restart_fo
 	.open = open_file_generic,
 };
 
+static struct file_operations loctls_fops = {
+	.read = loctls_read_file,
+	.open = open_file_generic,
+};
+
+
 int b43_debug(struct b43_wldev *dev, enum b43_dyndbg feature)
 {
 	return !!(dev->dfsentry && dev->dfsentry->dyn_debug[feature]);
@@ -499,6 +587,10 @@ void b43_debugfs_add_device(struct b43_w
 						dev, &restart_fops);
 	if (IS_ERR(e->dentry_restart))
 		e->dentry_restart = NULL;
+	e->dentry_loctls = debugfs_create_file("loctls", 0400, e->subdir,
+					       dev, &loctls_fops);
+	if (IS_ERR(e->dentry_loctls))
+		e->dentry_loctls = NULL;
 
 	b43_add_dynamic_debug(dev);
 }
@@ -513,6 +605,7 @@ void b43_debugfs_remove_device(struct b4
 	if (!e)
 		return;
 	b43_remove_dynamic_debug(dev);
+	debugfs_remove(e->dentry_loctls);
 	debugfs_remove(e->dentry_tsf);
 	debugfs_remove(e->dentry_txstat);
 	debugfs_remove(e->dentry_restart);
drivers/net/wireless/b43/debugfs.h +1 -0
Index: wireless-dev-new/drivers/net/wireless/b43/debugfs.h
===================================================================
@@ -34,6 +34,7 @@ struct b43_dfsentry {
 	struct dentry *dentry_txstat;
 	struct dentry *dentry_txpower_g;
 	struct dentry *dentry_restart;
+	struct dentry *dentry_loctls;
 
 	struct b43_wldev *dev;
 
#5 lore raw

PATCH 5/7 b43: Fix hwcrypto keyidx for new firmware.

In reply to Michael Buesch

This fixes crypto-RX on new firmware.

drivers/net/wireless/b43/main.c +15 -6
Index: wireless-dev-new/drivers/net/wireless/b43/main.c
===================================================================
@@ -730,13 +730,18 @@ static void key_write(struct b43_wldev *
 static void keymac_write(struct b43_wldev *dev, u8 index, const u8 * addr)
 {
 	u32 addrtmp[2];
+	u8 per_sta_keys_start = 8;
 
-	B43_WARN_ON(index < 4 + 4);
-	/* We have two default TX keys and two default RX keys.
-	 * Physical mac 0 is mapped to physical key 8.
+	if (b43_new_kidx_api(dev))
+		per_sta_keys_start = 4;
+
+	B43_WARN_ON(index < per_sta_keys_start);
+	/* We have two default TX keys and possibly two default RX keys.
+	 * Physical mac 0 is mapped to physical key 4 or 8, depending
+	 * on the firmware version.
 	 * So we must adjust the index here.
 	 */
-	index -= 8;
+	index -= per_sta_keys_start;
 
 	addrtmp[0] = addr[0];
 	addrtmp[0] |= ((u32) (addr[1]) << 8);
@@ -774,16 +779,20 @@ static void do_key_write(struct b43_wlde
 			 const u8 * key, size_t key_len, const u8 * mac_addr)
 {
 	u8 buf[B43_SEC_KEYSIZE];
+	u8 per_sta_keys_start = 8;
+
+	if (b43_new_kidx_api(dev))
+		per_sta_keys_start = 4;
 
 	B43_WARN_ON(index >= dev->max_nr_keys);
 	B43_WARN_ON(key_len > B43_SEC_KEYSIZE);
 
 	memset(buf, 0, sizeof(buf));
-	if (index >= 8)
+	if (index >= per_sta_keys_start)
 		keymac_write(dev, index, buf);	/* First zero out mac. */
 	memcpy(buf, key, key_len);
 	key_write(dev, index, algorithm, buf);
-	if (index >= 8)
+	if (index >= per_sta_keys_start)
 		keymac_write(dev, index, mac_addr);
 
 	dev->key[index].algorithm = algorithm;
#6 lore raw

PATCH 6/7 b43: Add missing stuff to pwork

In reply to Michael Buesch

This adds missing stuff for new cards to pwork.

drivers/net/wireless/b43/main.c +16 -1
Index: wireless-dev-new/drivers/net/wireless/b43/main.c
===================================================================
@@ -2308,14 +2308,29 @@ static void b43_periodic_every120sec(str
 	b43_mac_suspend(dev);
 	b43_lo_g_measure(dev);
 	b43_mac_enable(dev);
+	if (b43_has_hardware_pctl(phy))
+		b43_lo_g_ctl_mark_all_unused(dev);
 }
 
 static void b43_periodic_every60sec(struct b43_wldev *dev)
 {
-	b43_lo_g_ctl_mark_all_unused(dev);
+	struct b43_phy *phy = &dev->phy;
+
+	if (!b43_has_hardware_pctl(phy))
+		b43_lo_g_ctl_mark_all_unused(dev);
 	if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_RSSI) {
 		b43_mac_suspend(dev);
 		b43_calc_nrssi_slope(dev);
+		if ((phy->radio_ver == 0x2050) && (phy->radio_rev == 8)) {
+			u8 old_chan = phy->channel;
+
+			/* VCO Calibration */
+			if (old_chan >= 8)
+				b43_radio_selectchannel(dev, 1, 0);
+			else
+				b43_radio_selectchannel(dev, 13, 0);
+			b43_radio_selectchannel(dev, old_chan, 0);
+		}
 		b43_mac_enable(dev);
 	}
 }
#7 lore raw

PATCH 7/7 b43: Fix and cleanup hwcrypto

In reply to Michael Buesch

This fixes bugs and does a cleanup of the hwcrypto stuff.

drivers/net/wireless/b43/b43.h +4 -2
Index: wireless-dev-new/drivers/net/wireless/b43/b43.h
===================================================================
@@ -571,8 +571,10 @@ struct b43_stats {
 };
 
 struct b43_key {
-	void *keyconf;
-	bool enabled;
+	/* If keyconf is NULL, this key is disabled.
+	 * keyconf is a cookie. Don't derefenrence it outside of the set_key
+	 * path, because b43 doesn't own it. */
+	struct ieee80211_key_conf *keyconf;
 	u8 algorithm;
 };
 
drivers/net/wireless/b43/main.c +14 -21
Index: wireless-dev-new/drivers/net/wireless/b43/main.c
===================================================================
@@ -806,31 +806,29 @@ static int b43_key_write(struct b43_wlde
 {
 	int i;
 	int sta_keys_start;
+	bool removal = 0;
 
 	if (key_len > B43_SEC_KEYSIZE)
 		return -EINVAL;
 	if (index < 0) {
-		/* Per station key with associated MAC address.
-		 * Look if it already exists, if yes update, otherwise
-		 * allocate a new key.
-		 */
+		/* Either pairwise key or address is 00:00:00:00:00:00
+		 * for transmit-only keys. Search the index. */
 		if (b43_new_kidx_api(dev))
 			sta_keys_start = 4;
 		else
 			sta_keys_start = 8;
 		for (i = sta_keys_start; i < dev->max_nr_keys; i++) {
 			if (dev->key[i].keyconf == keyconf) {
-				/*
-				 * we already have this key so we must be
-				 * in removal (there is no update)
-				 */
+				/* we already have this key so we must be
+				 * in removal (there is no update) */
+				removal = 1;
 				index = i;
 				break;
 			}
 		}
 		if (index < 0) {
 			for (i = sta_keys_start; i < dev->max_nr_keys; i++) {
-				if (!dev->key[i].enabled) {
+				if (!dev->key[i].keyconf) {
 					/* found empty */
 					index = i;
 					break;
@@ -851,6 +849,7 @@ static int b43_key_write(struct b43_wlde
 		do_key_write(dev, index + 4, algorithm, key, key_len, NULL);
 	}
 	keyconf->hw_key_idx = index;
+	dev->key[index].keyconf = removal ? NULL : keyconf;
 
 	return 0;
 }
@@ -864,7 +863,7 @@ static void b43_clear_keys(struct b43_wl
 	for (i = 0; i < dev->max_nr_keys; i++) {
 		do_key_write(dev, i, B43_SEC_ALGO_NONE,
 			     zero, B43_SEC_KEYSIZE, zero);
-		dev->key[i].enabled = 0;
+		dev->key[i].keyconf = NULL;
 	}
 }
 
@@ -2960,7 +2959,6 @@ static int b43_dev_set_key(struct ieee80
 		}
 		if (err)
 			goto out_unlock;
-		dev->key[key->hw_key_idx].enabled = 1;
 
 		if (algorithm == B43_SEC_ALGO_WEP40 ||
 		    algorithm == B43_SEC_ALGO_WEP104) {
@@ -2974,16 +2972,11 @@ static int b43_dev_set_key(struct ieee80
 		static const u8 zero[B43_SEC_KEYSIZE] = { 0 };
 
 		algorithm = B43_SEC_ALGO_NONE;
-		if (is_broadcast_ether_addr(addr)) {
-			err = b43_key_write(dev, index, algorithm,
-					    zero, B43_SEC_KEYSIZE,
-					    NULL, key);
-		} else {
-			err = b43_key_write(dev, -1, algorithm,
-					    zero, B43_SEC_KEYSIZE,
-					    addr, key);
-		}
-		dev->key[key->hw_key_idx].enabled = 0;
+		err = b43_key_write(dev, index, algorithm,
+				    zero, B43_SEC_KEYSIZE,
+				    NULL, key);
+		if (err)
+			goto out_unlock;
 		break;
 	}
 	default:
drivers/net/wireless/b43/xmit.c +13 -16
Index: wireless-dev-new/drivers/net/wireless/b43/xmit.c
===================================================================
@@ -234,23 +234,20 @@ static void generate_txhdr_fw4(struct b4
 
 		B43_WARN_ON(key_idx >= dev->max_nr_keys);
 		key = &(dev->key[key_idx]);
+		B43_WARN_ON(!key->keyconf);
 
-		if (key->enabled) {
-			/* Hardware appends ICV. */
-			plcp_fragment_len += txctl->icv_len;
-
-			key_idx = b43_kidx_to_fw(dev, key_idx);
-			mac_ctl |= (key_idx << B43_TX4_MAC_KEYIDX_SHIFT) &
-			    B43_TX4_MAC_KEYIDX;
-			mac_ctl |=
-			    (key->
-			     algorithm << B43_TX4_MAC_KEYALG_SHIFT) &
-			    B43_TX4_MAC_KEYALG;
-			wlhdr_len = ieee80211_get_hdrlen(fctl);
-			iv_len = min((size_t) txctl->iv_len,
-				     ARRAY_SIZE(txhdr->iv));
-			memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len);
-		}
+		/* Hardware appends ICV. */
+		plcp_fragment_len += txctl->icv_len;
+
+		key_idx = b43_kidx_to_fw(dev, key_idx);
+		mac_ctl |= (key_idx << B43_TX4_MAC_KEYIDX_SHIFT) &
+			   B43_TX4_MAC_KEYIDX;
+		mac_ctl |= (key->algorithm << B43_TX4_MAC_KEYALG_SHIFT) &
+			   B43_TX4_MAC_KEYALG;
+		wlhdr_len = ieee80211_get_hdrlen(fctl);
+		iv_len = min((size_t) txctl->iv_len,
+			     ARRAY_SIZE(txhdr->iv));
+		memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len);
 	}
 	b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->plcp),
 			      plcp_fragment_len, rate);
maintainer
#8 lore raw

Re: [patch 7/7] b43: Fix and cleanup hwcrypto

drivers/net/wireless/b43/b43.h struct b43_stats { · line 577

Quoted 7 lines · Michael Buesch

struct b43_key {

drivers/net/wireless/b43/b43.h +4 -2
-	void *keyconf;
-	bool enabled;
+	/* If keyconf is NULL, this key is disabled.
+	 * keyconf is a cookie. Don't derefenrence it outside of the set_key
+	 * path, because b43 doesn't own it. */
+	struct ieee80211_key_conf *keyconf;

Just for clarification, you're allowed to dereference it as well if you wish but most things you can do with it (e.g. change hw key index) are racy.

johannes

#9 lore raw

Re: [patch 7/7] b43: Fix and cleanup hwcrypto

Quoted 13 lines · On Friday 24 August 2007 12:08:32 Johannes Berg wrote:

drivers/net/wireless/b43/b43.h struct b43_stats { · line 577

Quoted 7 lines · Michael Buesch

struct b43_key {

drivers/net/wireless/b43/b43.h +4 -2
-	void *keyconf;
-	bool enabled;
+	/* If keyconf is NULL, this key is disabled.
+	 * keyconf is a cookie. Don't derefenrence it outside of the set_key
+	 * path, because b43 doesn't own it. */
+	struct ieee80211_key_conf *keyconf;

Just for clarification, you're allowed to dereference it as well if you wish but most things you can do with it (e.g. change hw key index) are racy.

That's what "because b43 doesn't own it" means. :)

Signature · 1 line
Greetings Michael.
maintainer
#10 lore raw

Re: [patch 7/7] b43: Fix and cleanup hwcrypto

Quoted 15 lines · Michael Buesch
Quoted 13 lines · On Friday 24 August 2007 12:08:32 Johannes Berg wrote:

drivers/net/wireless/b43/b43.h struct b43_stats { · line 577

Quoted 7 lines · Michael Buesch

struct b43_key {

drivers/net/wireless/b43/b43.h +4 -2
-	void *keyconf;
-	bool enabled;
+	/* If keyconf is NULL, this key is disabled.
+	 * keyconf is a cookie. Don't derefenrence it outside of the set_key
+	 * path, because b43 doesn't own it. */
+	struct ieee80211_key_conf *keyconf;

Just for clarification, you're allowed to dereference it as well if you wish but most things you can do with it (e.g. change hw key index) are racy.

Quoted 1 line

That's what "because b43 doesn't own it" means. :)

I missed the "outside of the set_key" part, sorry.

johannes