aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2009-06-08 15:04:57 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-10 13:28:37 -0400
commit403a3a136122457165321e90b7569a321cc9ac12 (patch)
tree55eafd8ccb989d19937d884993326c7d8e135be7 /drivers/net/wireless/b43
parent908209c160da8ecb68052111972b7a21310eac3f (diff)
b43: Add fw capabilities
Add automagic feature flags, so the firmware can tell the driver about supported features and the driver can switch features on/off as needed. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r--drivers/net/wireless/b43/b43.h14
-rw-r--r--drivers/net/wireless/b43/dma.c2
-rw-r--r--drivers/net/wireless/b43/main.c56
-rw-r--r--drivers/net/wireless/b43/main.h1
-rw-r--r--drivers/net/wireless/b43/pio.c2
5 files changed, 61 insertions, 14 deletions
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 75aede02f932..f580c2812d91 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -163,6 +163,7 @@ enum {
163#define B43_SHM_SH_WLCOREREV 0x0016 /* 802.11 core revision */ 163#define B43_SHM_SH_WLCOREREV 0x0016 /* 802.11 core revision */
164#define B43_SHM_SH_PCTLWDPOS 0x0008 164#define B43_SHM_SH_PCTLWDPOS 0x0008
165#define B43_SHM_SH_RXPADOFF 0x0034 /* RX Padding data offset (PIO only) */ 165#define B43_SHM_SH_RXPADOFF 0x0034 /* RX Padding data offset (PIO only) */
166#define B43_SHM_SH_FWCAPA 0x0042 /* Firmware capabilities (Opensource firmware only) */
166#define B43_SHM_SH_PHYVER 0x0050 /* PHY version */ 167#define B43_SHM_SH_PHYVER 0x0050 /* PHY version */
167#define B43_SHM_SH_PHYTYPE 0x0052 /* PHY type */ 168#define B43_SHM_SH_PHYTYPE 0x0052 /* PHY type */
168#define B43_SHM_SH_ANTSWAP 0x005C /* Antenna swap threshold */ 169#define B43_SHM_SH_ANTSWAP 0x005C /* Antenna swap threshold */
@@ -297,6 +298,10 @@ enum {
297#define B43_HF_MLADVW 0x001000000000ULL /* N PHY ML ADV workaround (rev >= 13 only) */ 298#define B43_HF_MLADVW 0x001000000000ULL /* N PHY ML ADV workaround (rev >= 13 only) */
298#define B43_HF_PR45960W 0x080000000000ULL /* PR 45960 workaround (rev >= 13 only) */ 299#define B43_HF_PR45960W 0x080000000000ULL /* PR 45960 workaround (rev >= 13 only) */
299 300
301/* Firmware capabilities field in SHM (Opensource firmware only) */
302#define B43_FWCAPA_HWCRYPTO 0x0001
303#define B43_FWCAPA_QOS 0x0002
304
300/* MacFilter offsets. */ 305/* MacFilter offsets. */
301#define B43_MACFILTER_SELF 0x0000 306#define B43_MACFILTER_SELF 0x0000
302#define B43_MACFILTER_BSSID 0x0003 307#define B43_MACFILTER_BSSID 0x0003
@@ -596,6 +601,13 @@ struct b43_wl {
596 /* Pointer to the ieee80211 hardware data structure */ 601 /* Pointer to the ieee80211 hardware data structure */
597 struct ieee80211_hw *hw; 602 struct ieee80211_hw *hw;
598 603
604 /* The number of queues that were registered with the mac80211 subsystem
605 * initially. This is a backup copy of hw->queues in case hw->queues has
606 * to be dynamically lowered at runtime (Firmware does not support QoS).
607 * hw->queues has to be restored to the original value before unregistering
608 * from the mac80211 subsystem. */
609 u16 mac80211_initially_registered_queues;
610
599 struct mutex mutex; 611 struct mutex mutex;
600 spinlock_t irq_lock; 612 spinlock_t irq_lock;
601 /* R/W lock for data transmission. 613 /* R/W lock for data transmission.
@@ -749,6 +761,8 @@ struct b43_wldev {
749 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */ 761 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */
750 bool radio_hw_enable; /* saved state of radio hardware enabled state */ 762 bool radio_hw_enable; /* saved state of radio hardware enabled state */
751 bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */ 763 bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */
764 bool qos_enabled; /* TRUE, if QoS is used. */
765 bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
752 766
753 /* PHY/Radio device. */ 767 /* PHY/Radio device. */
754 struct b43_phy phy; 768 struct b43_phy phy;
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index eae680b53052..7964cc32b258 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -1285,7 +1285,7 @@ static struct b43_dmaring *select_ring_by_priority(struct b43_wldev *dev,
1285{ 1285{
1286 struct b43_dmaring *ring; 1286 struct b43_dmaring *ring;
1287 1287
1288 if (b43_modparam_qos) { 1288 if (dev->qos_enabled) {
1289 /* 0 = highest priority */ 1289 /* 0 = highest priority */
1290 switch (queue_prio) { 1290 switch (queue_prio) {
1291 default: 1291 default:
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 5d9f1981f2ce..6456afebdba1 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -80,8 +80,8 @@ static int modparam_nohwcrypt;
80module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444); 80module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
81MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); 81MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
82 82
83int b43_modparam_qos = 1; 83static int modparam_qos = 1;
84module_param_named(qos, b43_modparam_qos, int, 0444); 84module_param_named(qos, modparam_qos, int, 0444);
85MODULE_PARM_DESC(qos, "Enable QOS support (default on)"); 85MODULE_PARM_DESC(qos, "Enable QOS support (default on)");
86 86
87static int modparam_btcoex = 1; 87static int modparam_btcoex = 1;
@@ -538,6 +538,13 @@ void b43_hf_write(struct b43_wldev *dev, u64 value)
538 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_HOSTFHI, hi); 538 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_HOSTFHI, hi);
539} 539}
540 540
541/* Read the firmware capabilities bitmask (Opensource firmware only) */
542static u16 b43_fwcapa_read(struct b43_wldev *dev)
543{
544 B43_WARN_ON(!dev->fw.opensource);
545 return b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_FWCAPA);
546}
547
541void b43_tsf_read(struct b43_wldev *dev, u64 *tsf) 548void b43_tsf_read(struct b43_wldev *dev, u64 *tsf)
542{ 549{
543 u32 low, high; 550 u32 low, high;
@@ -2307,12 +2314,34 @@ static int b43_upload_microcode(struct b43_wldev *dev)
2307 dev->fw.patch = fwpatch; 2314 dev->fw.patch = fwpatch;
2308 dev->fw.opensource = (fwdate == 0xFFFF); 2315 dev->fw.opensource = (fwdate == 0xFFFF);
2309 2316
2317 /* Default to use-all-queues. */
2318 dev->wl->hw->queues = dev->wl->mac80211_initially_registered_queues;
2319 dev->qos_enabled = !!modparam_qos;
2320 /* Default to firmware/hardware crypto acceleration. */
2321 dev->hwcrypto_enabled = 1;
2322
2310 if (dev->fw.opensource) { 2323 if (dev->fw.opensource) {
2324 u16 fwcapa;
2325
2311 /* Patchlevel info is encoded in the "time" field. */ 2326 /* Patchlevel info is encoded in the "time" field. */
2312 dev->fw.patch = fwtime; 2327 dev->fw.patch = fwtime;
2313 b43info(dev->wl, "Loading OpenSource firmware version %u.%u%s\n", 2328 b43info(dev->wl, "Loading OpenSource firmware version %u.%u\n",
2314 dev->fw.rev, dev->fw.patch, 2329 dev->fw.rev, dev->fw.patch);
2315 dev->fw.pcm_request_failed ? " (Hardware crypto not supported)" : ""); 2330
2331 fwcapa = b43_fwcapa_read(dev);
2332 if (!(fwcapa & B43_FWCAPA_HWCRYPTO) || dev->fw.pcm_request_failed) {
2333 b43info(dev->wl, "Hardware crypto acceleration not supported by firmware\n");
2334 /* Disable hardware crypto and fall back to software crypto. */
2335 dev->hwcrypto_enabled = 0;
2336 }
2337 if (!(fwcapa & B43_FWCAPA_QOS)) {
2338 b43info(dev->wl, "QoS not supported by firmware\n");
2339 /* Disable QoS. Tweak hw->queues to 1. It will be restored before
2340 * ieee80211_unregister to make sure the networking core can
2341 * properly free possible resources. */
2342 dev->wl->hw->queues = 1;
2343 dev->qos_enabled = 0;
2344 }
2316 } else { 2345 } else {
2317 b43info(dev->wl, "Loading firmware version %u.%u " 2346 b43info(dev->wl, "Loading firmware version %u.%u "
2318 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n", 2347 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
@@ -3627,7 +3656,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3627 if (!dev || b43_status(dev) < B43_STAT_INITIALIZED) 3656 if (!dev || b43_status(dev) < B43_STAT_INITIALIZED)
3628 goto out_unlock; 3657 goto out_unlock;
3629 3658
3630 if (dev->fw.pcm_request_failed) { 3659 if (dev->fw.pcm_request_failed || !dev->hwcrypto_enabled) {
3631 /* We don't have firmware for the crypto engine. 3660 /* We don't have firmware for the crypto engine.
3632 * Must use software-crypto. */ 3661 * Must use software-crypto. */
3633 err = -EOPNOTSUPP; 3662 err = -EOPNOTSUPP;
@@ -4727,6 +4756,7 @@ static int b43_wireless_init(struct ssb_device *dev)
4727 b43err(NULL, "Could not allocate ieee80211 device\n"); 4756 b43err(NULL, "Could not allocate ieee80211 device\n");
4728 goto out; 4757 goto out;
4729 } 4758 }
4759 wl = hw_to_b43_wl(hw);
4730 4760
4731 /* fill hw info */ 4761 /* fill hw info */
4732 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 4762 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
@@ -4740,7 +4770,8 @@ static int b43_wireless_init(struct ssb_device *dev)
4740 BIT(NL80211_IFTYPE_WDS) | 4770 BIT(NL80211_IFTYPE_WDS) |
4741 BIT(NL80211_IFTYPE_ADHOC); 4771 BIT(NL80211_IFTYPE_ADHOC);
4742 4772
4743 hw->queues = b43_modparam_qos ? 4 : 1; 4773 hw->queues = modparam_qos ? 4 : 1;
4774 wl->mac80211_initially_registered_queues = hw->queues;
4744 hw->max_rates = 2; 4775 hw->max_rates = 2;
4745 SET_IEEE80211_DEV(hw, dev->dev); 4776 SET_IEEE80211_DEV(hw, dev->dev);
4746 if (is_valid_ether_addr(sprom->et1mac)) 4777 if (is_valid_ether_addr(sprom->et1mac))
@@ -4748,9 +4779,7 @@ static int b43_wireless_init(struct ssb_device *dev)
4748 else 4779 else
4749 SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac); 4780 SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac);
4750 4781
4751 /* Get and initialize struct b43_wl */ 4782 /* Initialize struct b43_wl */
4752 wl = hw_to_b43_wl(hw);
4753 memset(wl, 0, sizeof(*wl));
4754 wl->hw = hw; 4783 wl->hw = hw;
4755 spin_lock_init(&wl->irq_lock); 4784 spin_lock_init(&wl->irq_lock);
4756 rwlock_init(&wl->tx_lock); 4785 rwlock_init(&wl->tx_lock);
@@ -4816,8 +4845,13 @@ static void b43_remove(struct ssb_device *dev)
4816 cancel_work_sync(&wldev->restart_work); 4845 cancel_work_sync(&wldev->restart_work);
4817 4846
4818 B43_WARN_ON(!wl); 4847 B43_WARN_ON(!wl);
4819 if (wl->current_dev == wldev) 4848 if (wl->current_dev == wldev) {
4849 /* Restore the queues count before unregistering, because firmware detect
4850 * might have modified it. Restoring is important, so the networking
4851 * stack can properly free resources. */
4852 wl->hw->queues = wl->mac80211_initially_registered_queues;
4820 ieee80211_unregister_hw(wl->hw); 4853 ieee80211_unregister_hw(wl->hw);
4854 }
4821 4855
4822 b43_one_core_detach(dev); 4856 b43_one_core_detach(dev);
4823 4857
diff --git a/drivers/net/wireless/b43/main.h b/drivers/net/wireless/b43/main.h
index 40abcf5d1b43..950fb1b0546d 100644
--- a/drivers/net/wireless/b43/main.h
+++ b/drivers/net/wireless/b43/main.h
@@ -39,7 +39,6 @@
39#define PAD_BYTES(nr_bytes) P4D_BYTES( __LINE__ , (nr_bytes)) 39#define PAD_BYTES(nr_bytes) P4D_BYTES( __LINE__ , (nr_bytes))
40 40
41 41
42extern int b43_modparam_qos;
43extern int b43_modparam_verbose; 42extern int b43_modparam_verbose;
44 43
45/* Logmessage verbosity levels. Update the b43_modparam_verbose helptext, if 44/* Logmessage verbosity levels. Update the b43_modparam_verbose helptext, if
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c
index 8cd9776752e6..69138e8c1db6 100644
--- a/drivers/net/wireless/b43/pio.c
+++ b/drivers/net/wireless/b43/pio.c
@@ -313,7 +313,7 @@ static struct b43_pio_txqueue *select_queue_by_priority(struct b43_wldev *dev,
313{ 313{
314 struct b43_pio_txqueue *q; 314 struct b43_pio_txqueue *q;
315 315
316 if (b43_modparam_qos) { 316 if (dev->qos_enabled) {
317 /* 0 = highest priority */ 317 /* 0 = highest priority */
318 switch (queue_prio) { 318 switch (queue_prio) {
319 default: 319 default: