Skip to contentSkip to conversation

mwl8k: split driver by chipset

PATCH In review Dan Williams 4 participants 7 messages Nov 22, 2009 – Nov 26, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mwl8k: split driver by chipset

No functional changes, but split the code up to make it easier to add support for other Libertas softmac chipsets like the 88w8361, which has slightly different RX and TX descriptors and some slightly different commands.

---
Note: patch is large (code reshuffle) so in case it gets rejected:

http://bigw.org/~dan/mwl8k-split.patch

Note #2: I've tested firmware loading and up to GET_HW_SPEC with an 8361 card and I assume since there are no functional changes it will continue to work with 8687 and 8366. But Lennert, please test; the machine I have with PCI-E slots is only running 2.6.30 so I can't test the 8687 myself.

drivers/net/wireless/Kconfig +1 -9
index 56dd665..cb4c2c1 100644
@@ -334,15 +334,6 @@ config MAC80211_HWSIM
 	  To compile this driver as a module, choose M here: the module will be
 	  called mac80211_hwsim.  If unsure, say N.
 
-config MWL8K
-	tristate "Marvell 88W8xxx PCI/PCIe Wireless support"
-	depends on MAC80211 && PCI && EXPERIMENTAL
-	---help---
-	  This driver supports Marvell TOPDOG 802.11 wireless cards.
-
-	  To compile this driver as a module, choose M here: the module
-	  will be called mwl8k.  If unsure, say N.
-
 source "drivers/net/wireless/ath/Kconfig"
 source "drivers/net/wireless/b43/Kconfig"
 source "drivers/net/wireless/b43legacy/Kconfig"
@@ -351,6 +342,7 @@ source "drivers/net/wireless/ipw2x00/Kconfig"
 source "drivers/net/wireless/iwlwifi/Kconfig"
 source "drivers/net/wireless/iwmc3200wifi/Kconfig"
 source "drivers/net/wireless/libertas/Kconfig"
+source "drivers/net/wireless/mwl8k/Kconfig"
 source "drivers/net/wireless/orinoco/Kconfig"
 source "drivers/net/wireless/p54/Kconfig"
 source "drivers/net/wireless/rt2x00/Kconfig"
drivers/net/wireless/Makefile +1 -1
index 5d4ce4d..478f327 100644
@@ -38,7 +38,7 @@ obj-$(CONFIG_LIBERTAS_THINFIRM)	+= libertas_tf/
 
 obj-$(CONFIG_ADM8211)	+= adm8211.o
 
-obj-$(CONFIG_MWL8K)	+= mwl8k.o
+obj-$(CONFIG_MWL8K)	+= mwl8k/
 
 obj-$(CONFIG_IWLWIFI)	+= iwlwifi/
 obj-$(CONFIG_RT2X00)	+= rt2x00/
drivers/net/wireless/mwl8k.c deleted +0 -3673

2,970 lines not on this page · raw message

drivers/net/wireless/mwl8k/Kconfig new file +29 -0
new file mode 100644
index 0000000..48b4071

Lines of this file are not shown. View the raw message.

drivers/net/wireless/mwl8k/Makefile new file +4 -0
new file mode 100644
index 0000000..4fb93ec

Lines of this file are not shown. View the raw message.

drivers/net/wireless/mwl8k/mwl8366.c new file +153 -0

153 lines not on this page · raw message

drivers/net/wireless/mwl8k/mwl8687.c new file +152 -0

152 lines not on this page · raw message

drivers/net/wireless/mwl8k/mwl8k.c new file +3336 -0

3,336 lines not on this page · raw message

drivers/net/wireless/mwl8k/mwl8k.h new file +146 -0

146 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 6 lines · Dan Williams

No functional changes, but split the code up to make it easier to add support for other Libertas softmac chipsets like the 88w8361, which has slightly different RX and TX descriptors and some slightly different commands.

Yay, potential 88w8335 support!

Quoted 4 lines

---
Note: patch is large (code reshuffle) so in case it gets rejected:

http://bigw.org/~dan/mwl8k-split.patch

Diffstat?

Quoted 25 lines
drivers/net/wireless/mwl8k/Kconfig new file +19 -0
new file mode 100644
index 0000000..48b4071
@@ -0,0 +1,29 @@
+config MWL8K_COMMON
+       tristate "Marvell 88W8xxx PCI/PCIe Wireless support"
+       depends on MAC80211 && PCI && WLAN_80211 && EXPERIMENTAL
+       ---help---
+         This is common code for Marvell TOPDOG 802.11 wireless cards.  This
+         module does nothing by itself - the device-specific front-ends
+         also need to be enabled in order to support any devices.
+
+         To compile this driver as a module, choose M here: the module
+         will be called mwl8k.  If unsure, say N.
+
+config MWL8687
+       tristate "Marvell 88W8687 PCI/PCIe Wireless support"
+       depends on MWL8K_COMMON
+       ---help---
+         This driver is for Marvell TOPDOG 88w8687-based wireless cards.
+
+         To compile this driver as a module, choose M here: the module
+         will be called mwl8687.  If unsure, say N.

drivers/net/wireless/mwl8k/Kconfig line 29

Quoted 10 lines
drivers/net/wireless/mwl8k/Kconfig new file +10 -0
+
+config MWL8366
+       tristate "Marvell 88W8366 PCI/PCIe Wireless support"
+       depends on MWL8K_COMMON
+       ---help---
+         This driver is for Marvell TOPDOG 88w8366-based wireless cards.
+
+         To compile this driver as a module, choose M here: the module
+         will be called mwl8366.  If unsure, say N.
+

Isn't there a menuconfig option that'd make the depends on MWL8K_COMMON redundant?

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/
#2 lore raw
In reply to Dan Williams

Hi Dan,

Quoted 4 lines · Dan Williams

No functional changes, but split the code up to make it easier to add support for other Libertas softmac chipsets like the 88w8361, which has slightly different RX and TX descriptors and some slightly different commands.

As to RX/TX desc layout, see below.

Quoted 6 lines

---
Note: patch is large (code reshuffle) so in case it gets rejected:

http://bigw.org/~dan/mwl8k-split.patch

I've been thinking about splitting up mwl8k.c for a while as well now, but I've resisted it so far, as I wasn't sure what the split would have to look like after support for more device types would be added.

The interface with the wireless chip is almost entirely defined by the firmware running on it, and not by the actual wireless chip itself. So e.g. putting the RX desc handling in files named after the chip is somewhat confusing (but I guess it's my fault for naming the rxd ops like that in the first place).

This isn't just a theoretical issue: there are generally two different firmware branches for the chips that mwl8k supports (AP firmware and STA firmware), and the rxd format depends on which firmware you use. So e.g. if you put a STA firmware image on, say, the 8366, you'll end up having to use the rxd ops that are currently marked as being for the 8687, and not the "8366" ones. (I only found this out after submitting that round of patches.)

I was wondering if we should really make the support for each chip a different kernel module as you did in your patch, but then I figured that this might be a good way to let the user choose whether to load AP or STA firmware if we have both available, which was still one of the unsolved problems. I.e., make mwl8366_ap and mwl8366_sta, and then let the user choose which one to load. Or is there a better way of doing this?

Quoted 3 lines

Note #2: I've tested firmware loading and up to GET_HW_SPEC with an 8361 card and I assume since there are no functional changes it will continue to work with 8687 and 8366.

You mentioned that there are slightly different commands on the 8361 firmware you have -- can you give some examples?

thanks,
Lennert

maintainer
#3 lore raw
Quoted 7 lines · Lennert Buytenhek

I was wondering if we should really make the support for each chip a different kernel module as you did in your patch, but then I figured that this might be a good way to let the user choose whether to load AP or STA firmware if we have both available, which was still one of the unsolved problems. I.e., make mwl8366_ap and mwl8366_sta, and then let the user choose which one to load. Or is there a better way of doing this?

Try to load both at probe() time (via the async firmware loading interface that I fixed up recently [1], that patch will be in .33), and hang on to the firmware images [2]. Register the wiphy with appropriate bits depending on which firmware files you found (and fail + unbind if you didn't find any, cf. my ar9170 patch [3]). Then you can upload the right firmware depending on the type of interface the user is adding.

(Maybe, if needed for EMBEDDED, allow the user to configure which firmware you load.)

johannes

[1] http://johannes.sipsolutions.net/patches/kernel/all/LATEST/NNN-firmware-class-nowait.patch
[2] that is what my patch allows doing
[3] http://johannes.sipsolutions.net/patches/kernel/all/LATEST/NNN-ar9170-firmware-request-async.patch

#4 lore raw
Quoted 8 lines · Johannes Berg
Quoted 7 lines

I was wondering if we should really make the support for each chip a different kernel module as you did in your patch, but then I figured that this might be a good way to let the user choose whether to load AP or STA firmware if we have both available, which was still one of the unsolved problems. I.e., make mwl8366_ap and mwl8366_sta, and then let the user choose which one to load. Or is there a better way of doing this?

Quoted 6 lines

Try to load both at probe() time (via the async firmware loading interface that I fixed up recently [1], that patch will be in .33), and hang on to the firmware images [2]. Register the wiphy with appropriate bits depending on which firmware files you found (and fail + unbind if you didn't find any, cf. my ar9170 patch [3]). Then you can upload the right firmware depending on the type of interface the user is adding.

This has the problem that e.g. if someone creates a STA interface first, and we load the STA firmware image in response to that, and then creates an additional AP interface, we'd have reload the chip while there's still an active interface (the original STA one), which seems somewhat involved. Just rejecting the second add_interface() seems undesirable, as then the outcome of two add_interface() calls will depend on their order.

(AP firmware supports both AP and STA interfaces, but e.g. it doesn't do STA power save and such.)

It'll also have some consequences if there are monitor interfaces, as e.g. STA firmware allows fine-grained control over the receive filter, while the AP firmware does not.

maintainer
#5 lore raw
Quoted 8 lines · Lennert Buytenhek

This has the problem that e.g. if someone creates a STA interface first, and we load the STA firmware image in response to that, and then creates an additional AP interface, we'd have reload the chip while there's still an active interface (the original STA one), which seems somewhat involved. Just rejecting the second add_interface() seems undesirable, as then the outcome of two add_interface() calls will depend on their order.

Quoted 6 lines

(AP firmware supports both AP and STA interfaces, but e.g. it doesn't do STA power save and such.)

It'll also have some consequences if there are monitor interfaces, as e.g. STA firmware allows fine-grained control over the receive filter, while the AP firmware does not.

Hah well in that case it won't really work because you really shouldn't change capabilities on the fly. I have no useful idea then, sorry.

johannes

#6 lore raw
In reply to Lennert Buytenhek
Quoted 25 lines · Lennert Buytenhek

Hi Dan,

Quoted 4 lines · Dan Williams

No functional changes, but split the code up to make it easier to add support for other Libertas softmac chipsets like the 88w8361, which has slightly different RX and TX descriptors and some slightly different commands.

As to RX/TX desc layout, see below.

Quoted 6 lines

---
Note: patch is large (code reshuffle) so in case it gets rejected:

http://bigw.org/~dan/mwl8k-split.patch

I've been thinking about splitting up mwl8k.c for a while as well now, but I've resisted it so far, as I wasn't sure what the split would have to look like after support for more device types would be added.

Quoted 5 lines

The interface with the wireless chip is almost entirely defined by the firmware running on it, and not by the actual wireless chip itself. So e.g. putting the RX desc handling in files named after the chip is somewhat confusing (but I guess it's my fault for naming the rxd ops like that in the first place).

True.

Quoted 8 lines

This isn't just a theoretical issue: there are generally two different firmware branches for the chips that mwl8k supports (AP firmware and STA firmware), and the rxd format depends on which firmware you use. So e.g. if you put a STA firmware image on, say, the 8366, you'll end up having to use the rxd ops that are currently marked as being for the 8687, and not the "8366" ones. (I only found this out after submitting that round of patches.)

Quoted 7 lines

I was wondering if we should really make the support for each chip a different kernel module as you did in your patch, but then I figured that this might be a good way to let the user choose whether to load AP or STA firmware if we have both available, which was still one of the unsolved problems. I.e., make mwl8366_ap and mwl8366_sta, and then let the user choose which one to load. Or is there a better way of doing this?

Ugh. I'd rather not have different kernel modules like this because that's not how every other driver works. It's a pain from userspace because to switch to AP mode for whatever reason (like for connection sharing or whatever in NM) we'd need to know to reload the driver and messing with rmmod/modprobe just sucks. Like we'd need to have a list of cards with this issue, and what the module names were, hardcoded into NM.

I'd much rather have some bit in cfg80211 that says that the card cannot switch modes without killing all connections and reinitializing the chip. Some drivers reload firmware for stuff like this (orinoco, old prism54, band switches) already. From userspace it's much more useful to be able to make a choice based on a flag than to reload hardcoded modules.

Quoted 6 lines
Quoted 3 lines

Note #2: I've tested firmware loading and up to GET_HW_SPEC with an 8361 card and I assume since there are no functional changes it will continue to work with 8687 and 8366.

You mentioned that there are slightly different commands on the 8361 firmware you have -- can you give some examples?

I'm using the 8361 marvell driver dump from linville's kernel.org 'marvell' tree, and also looking at the usb82 linux driver from Extranet.

Some changes for 8361:

1) 8361 has a 'u32 signature' at the start of the rx & tx descriptors which is set to a magic value (MRVL_PCI_DMA_SIGNATURE = 0xCAFEEFAC). This appears to be only for the driver's use in ensuring that the descriptor pool doesn't get corrupted, but it's part of the rx/tx descriptors and thus I assume the firmware accounts for it.

2) the STA GET_HW_SPEC command is different; it ends with "caps2" and does not include "num_tx_desc_per_queue" or "total_rxd"

3) GET_STAT has a different layout; mwl8k looks for ACK_FAILURE at index 9, but on 8361 it's index 5; mwl8k looks for RTS_FAILURE at 12 but on 8361 it's 4, etc.

4) 8361 doesn't appear to implement the "sniffer" stuff, so I had to ignore the error when setting up the chip

5) struct peer_capability_info is shorter on 8361; it doesn't have anything after 'ht_rates'

6) The firmware image starts with 0x10, not 0x01. It does however load and boot correctly.

That's all I can find for now.

8335 is a whole different beast which might actually deserve it's own driver based on mwl8k. It makes more extensive use of MMIO instead of DMA (ex the helper firmware is written to device memory byte-at-a-time instead of using DMA) and the command structures are correspondingly different too. Obviously it doesn't do 11n. Might make sense to do a mwl8k_lib module later on, but at the moment I'll be happy to get 8361pci working.

8338 and 8382 are both USB and of course their command submission will be different. We've got the usb82 sources in both Linville's 'marvell' tree (though I think they are incomplete there) and also the usb82 driver the Extranet. One step at a time though :)

So maybe we don't need to split up mwl8k yet. Supporting 8361 may not pollute the code too much. 8335 or USB support would probably require a much more extensive split. I'll go ahead and try to graft on 8361 and see where I get.

Dan