Skip to contentSkip to conversation

b43: Add support for new firmware

PATCH In review Michael Buesch 3 participants 5 messages Jan 10, 2008 – Jan 11, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 b43: Add support for new firmware

This patch adds support for new firmware.
Please test this on old and new firmware.

To get new firmware, go to ftp://ftp.linksys.com/opensourcecode/wrt150nv11/1.51.3/ and download the tarball. We don't have a smaller tarball, yet. That will be fixed later.
You can extract firmware out of the "wl_ap.o" file contained in this tarball using latest fwcutter. You must pass the option --unsupported to fwcutter.

drivers/net/wireless/b43/dma.c +11 -11
Index: wireless-2.6/drivers/net/wireless/b43/dma.c
===================================================================
@@ -804,44 +804,43 @@ struct b43_dmaring *b43_setup_dmaring(st
 	ring->meta = kcalloc(nr_slots, sizeof(struct b43_dmadesc_meta),
 			     GFP_KERNEL);
 	if (!ring->meta)
 		goto err_kfree_ring;
 	if (for_tx) {
 		ring->txhdr_cache = kcalloc(nr_slots,
-					    sizeof(struct b43_txhdr_fw4),
+					    b43_txhdr_size(dev),
 					    GFP_KERNEL);
 		if (!ring->txhdr_cache)
 			goto err_kfree_meta;
 
 		/* test for ability to dma to txhdr_cache */
 		dma_test = dma_map_single(dev->dev->dev,
 					  ring->txhdr_cache,
-					  sizeof(struct b43_txhdr_fw4),
+					  b43_txhdr_size(dev),
 					  DMA_TO_DEVICE);
 
 		if (dma_mapping_error(dma_test)) {
 			/* ugh realloc */
 			kfree(ring->txhdr_cache);
 			ring->txhdr_cache = kcalloc(nr_slots,
-						    sizeof(struct
-							   b43_txhdr_fw4),
+						    b43_txhdr_size(dev),
 						    GFP_KERNEL | GFP_DMA);
 			if (!ring->txhdr_cache)
 				goto err_kfree_meta;
 
 			dma_test = dma_map_single(dev->dev->dev,
 						  ring->txhdr_cache,
-						  sizeof(struct b43_txhdr_fw4),
+						  b43_txhdr_size(dev),
 						  DMA_TO_DEVICE);
 
 			if (dma_mapping_error(dma_test))
 				goto err_kfree_txhdr_cache;
 		}
 
 		dma_unmap_single(dev->dev->dev,
-				 dma_test, sizeof(struct b43_txhdr_fw4),
+				 dma_test, b43_txhdr_size(dev),
 				 DMA_TO_DEVICE);
 	}
 
 	ring->dev = dev;
 	ring->nr_slots = nr_slots;
 	ring->mmio_base = b43_dmacontroller_base(dma64, controller_index);
@@ -1119,32 +1118,33 @@ static int dma_tx_fragment(struct b43_dm
 	int err;
 	struct b43_dmadesc_generic *desc;
 	struct b43_dmadesc_meta *meta;
 	struct b43_dmadesc_meta *meta_hdr;
 	struct sk_buff *bounce_skb;
 	u16 cookie;
+	size_t hdrsize = b43_txhdr_size(ring->dev);
 
 #define SLOTS_PER_PACKET  2
 	B43_WARN_ON(skb_shinfo(skb)->nr_frags);
 
 	/* Get a slot for the header. */
 	slot = request_slot(ring);
 	desc = ops->idx2desc(ring, slot, &meta_hdr);
 	memset(meta_hdr, 0, sizeof(*meta_hdr));
 
-	header = &(ring->txhdr_cache[slot * sizeof(struct b43_txhdr_fw4)]);
+	header = &(ring->txhdr_cache[slot * hdrsize]);
 	cookie = generate_cookie(ring, slot);
 	b43_generate_txhdr(ring->dev, header,
 			   skb->data, skb->len, ctl, cookie);
 
 	meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header,
-					   sizeof(struct b43_txhdr_fw4), 1);
+					   hdrsize, 1);
 	if (dma_mapping_error(meta_hdr->dmaaddr))
 		return -EIO;
 	ops->fill_descriptor(ring, desc, meta_hdr->dmaaddr,
-			     sizeof(struct b43_txhdr_fw4), 1, 0, 0);
+			     hdrsize, 1, 0, 0);
 
 	/* Get a slot for the payload. */
 	slot = request_slot(ring);
 	desc = ops->idx2desc(ring, slot, &meta);
 	memset(meta, 0, sizeof(*meta));
 
@@ -1186,13 +1186,13 @@ static int dma_tx_fragment(struct b43_dm
 	return 0;
 
 out_free_bounce:
 	dev_kfree_skb_any(skb);
 out_unmap_hdr:
 	unmap_descbuffer(ring, meta_hdr->dmaaddr,
-			 sizeof(struct b43_txhdr_fw4), 1);
+			 hdrsize, 1);
 	return err;
 }
 
 static inline int should_inject_overflow(struct b43_dmaring *ring)
 {
 #ifdef CONFIG_B43_DEBUG
@@ -1295,13 +1295,13 @@ void b43_dma_handle_txstatus(struct b43_
 
 		if (meta->skb)
 			unmap_descbuffer(ring, meta->dmaaddr, meta->skb->len,
 					 1);
 		else
 			unmap_descbuffer(ring, meta->dmaaddr,
-					 sizeof(struct b43_txhdr_fw4), 1);
+					 b43_txhdr_size(dev), 1);
 
 		if (meta->is_last_fragment) {
 			B43_WARN_ON(!meta->skb);
 			/* Call back to inform the ieee80211 subsystem about the
 			 * status of the transmission.
 			 * Some fields of txstat are already filled in dma_tx().
drivers/net/wireless/b43/main.c +36 -14

167 lines not on this page · raw message

drivers/net/wireless/b43/xmit.c +94 -50

248 lines not on this page · raw message

drivers/net/wireless/b43/xmit.h +146 -54

220 lines not on this page · raw message

Documentation/feature-removal-schedule.txt +9 -0
Index: wireless-2.6/Documentation/feature-removal-schedule.txt
===================================================================
@@ -355,6 +355,15 @@ What:	rc80211-simple rate control algori
 When:	2.6.26
 Files:	net/mac80211/rc80211-simple.c
 Why:	This algorithm was provided for reference but always exhibited bad
 	responsiveness and performance and has some serious flaws. It has been
 	replaced by rc80211-pid.
 Who:	Stefano Brivio <[email protected]>
+
+---------------------------
+
+What:	b43 support for firmware revision < 410
+When:	July 2008
+Why:	The support code for the old firmware hurts code readability/maintainability
+	and slightly hurts runtime performance. Bugfixes for the old firmware
+	are not provided by Broadcom anymore.
+Who:	Michael Buesch <[email protected]>
drivers/net/wireless/b43/phy.h +2 -0
Index: wireless-2.6/drivers/net/wireless/b43/phy.h
===================================================================
@@ -177,12 +177,14 @@ void b43_gtab_write(struct b43_wldev *de
 
 enum {
 	B43_ANTENNA0,		/* Antenna 0 */
 	B43_ANTENNA1,		/* Antenna 0 */
 	B43_ANTENNA_AUTO1,	/* Automatic, starting with antenna 1 */
 	B43_ANTENNA_AUTO0,	/* Automatic, starting with antenna 0 */
+	B43_ANTENNA2,
+	B43_ANTENNA3 = 8,
 
 	B43_ANTENNA_AUTO = B43_ANTENNA_AUTO0,
 	B43_ANTENNA_DEFAULT = B43_ANTENNA_AUTO,
 };
 
 enum {
#1 lore raw
Quoted 2 lines · Michael Buesch

This patch adds support for new firmware.
Please test this on old and new firmware.

I have tested this patch with old firmware. It seems to work; however my testing is not complete as my computer has started hanging with the "Caps Lock" light flashing. The crash is not caused by this patch as it happened with 2.6.24-rc5, which has run for many days. I do have a suggestion for changing the patch (see below).

drivers/net/wireless/b43/xmit.h _b43_declare_plcp_hdr(4); · line 174

Quoted 7 lines
drivers/net/wireless/b43/xmit.h +7 -0
+static inline
+size_t b43_txhdr_size(struct b43_wldev *dev)
+{
+	if (b43_is_old_txhdr_format(dev))
+		return 100 + sizeof(struct b43_plcp_hdr6);
+	return 104 + sizeof(struct b43_plcp_hdr6);
+}

Why not eliminate most of the magic numbers in this part with

size_t b43_txhdr_size(struct b43_wldev *dev)

{
	if (b43_is_old_txhdr_format(dev))
		return sizeof(struct b43_txhdr) - 4;
	return sizeof(struct b43_txhdr);
}

Larry

#2 lore raw
Quoted 19 lines · On Friday 11 January 2008 17:40:04 Larry Finger wrote:
Quoted 2 lines · Michael Buesch

This patch adds support for new firmware.
Please test this on old and new firmware.

I have tested this patch with old firmware. It seems to work; however my testing is not complete as my computer has started hanging with the "Caps Lock" light flashing. The crash is not caused by this patch as it happened with 2.6.24-rc5, which has run for many days. I do have a suggestion for changing the patch (see below).

drivers/net/wireless/b43/xmit.h _b43_declare_plcp_hdr(4); · line 174

Quoted 7 lines
drivers/net/wireless/b43/xmit.h +7 -0
+static inline
+size_t b43_txhdr_size(struct b43_wldev *dev)
+{
+	if (b43_is_old_txhdr_format(dev))
+		return 100 + sizeof(struct b43_plcp_hdr6);
+	return 104 + sizeof(struct b43_plcp_hdr6);
+}

Why not eliminate most of the magic numbers in this part with

Quoted 6 lines

size_t b43_txhdr_size(struct b43_wldev *dev)

{
	if (b43_is_old_txhdr_format(dev))
		return sizeof(struct b43_txhdr) - 4;
	return sizeof(struct b43_txhdr);
}

Because this is IMO as magic as the above.
The struct b43_txhdr is _not_ meant to be used as an object anymore, as it now contains this union magic stuff. So we must only use it as a pointer type. The sizeof, however, uses it as an object. I'm perfectly fine with the hardcoded constants. And they really are constants, as they are defined by the hard(firm)ware. I think this all leads to the same issue as "Should we use #defines for the PCI IDs in PCI ID tables?".
However, this code will go away in summer anyway. So it doesn't really matter. It really is just a hack.

Signature · 1 line
Greetings Michael.
#3 lore raw
In reply to Larry Finger

Larry Finger escribi=F3:

Quoted 5 lines
Quoted 2 lines · Michael Buesch

This patch adds support for new firmware.
Please test this on old and new firmware.

=20
I have tested this patch with old firmware. It seems to work; however=

my testing is not complete as

Quoted 1 line

my computer has started hanging with the "Caps Lock" light flashing. =

The crash is not caused by this

Quoted 1 line

patch as it happened with 2.6.24-rc5, which has run for many days. I =

do have a suggestion for

Quoted 1 line

changing the patch (see below).

Sorry if it's a change of subject, but what does the flashing caps hang= =20
mean? It has happend to me a lot when trying to run 3D apps. -
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 3 lines · Martin Marques

Sorry if it's a change of subject, but what does the flashing caps hang mean? It has happend to me a lot when trying to run 3D apps.

AFAIK, it indicates an error so severe that the kernel has no chance to recover. Examples might be stack underflow or a page fault while accessing the stack.

Your crashes when running 3D apps is likely a bug in the driver for your graphics adapter. Are you using a binary-only driver? If so, complain to the manufacturer. If it is an open-source driver, then a note to the Linux Kernel Mailing List would be appropriate. You should describe your kernel, configuration, etc. and list the 3D app that causes the problem.

Larry