wireless: remove print_mac uses
[pandora-kernel.git] / drivers / net / wireless / b43 / main.c
index cb4a871..3f4360a 100644 (file)
@@ -80,8 +80,8 @@ static int modparam_nohwcrypt;
 module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
 
-int b43_modparam_qos = 1;
-module_param_named(qos, b43_modparam_qos, int, 0444);
+static int modparam_qos = 1;
+module_param_named(qos, modparam_qos, int, 0444);
 MODULE_PARM_DESC(qos, "Enable QOS support (default on)");
 
 static int modparam_btcoex = 1;
@@ -538,6 +538,13 @@ void b43_hf_write(struct b43_wldev *dev, u64 value)
        b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_HOSTFHI, hi);
 }
 
+/* Read the firmware capabilities bitmask (Opensource firmware only) */
+static u16 b43_fwcapa_read(struct b43_wldev *dev)
+{
+       B43_WARN_ON(!dev->fw.opensource);
+       return b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_FWCAPA);
+}
+
 void b43_tsf_read(struct b43_wldev *dev, u64 *tsf)
 {
        u32 low, high;
@@ -931,7 +938,6 @@ static void b43_clear_keys(struct b43_wldev *dev)
 static void b43_dump_keymemory(struct b43_wldev *dev)
 {
        unsigned int i, index, offset;
-       DECLARE_MAC_BUF(macbuf);
        u8 mac[ETH_ALEN];
        u16 algo;
        u32 rcmta0;
@@ -966,8 +972,7 @@ static void b43_dump_keymemory(struct b43_wldev *dev)
                                                ((index - 4) * 2) + 1);
                        *((__le32 *)(&mac[0])) = cpu_to_le32(rcmta0);
                        *((__le16 *)(&mac[4])) = cpu_to_le16(rcmta1);
-                       printk("   MAC: %s",
-                              print_mac(macbuf, mac));
+                       printk("   MAC: %pM", mac);
                } else
                        printk("   DEFAULT KEY");
                printk("\n");
@@ -2307,12 +2312,34 @@ static int b43_upload_microcode(struct b43_wldev *dev)
        dev->fw.patch = fwpatch;
        dev->fw.opensource = (fwdate == 0xFFFF);
 
+       /* Default to use-all-queues. */
+       dev->wl->hw->queues = dev->wl->mac80211_initially_registered_queues;
+       dev->qos_enabled = !!modparam_qos;
+       /* Default to firmware/hardware crypto acceleration. */
+       dev->hwcrypto_enabled = 1;
+
        if (dev->fw.opensource) {
+               u16 fwcapa;
+
                /* Patchlevel info is encoded in the "time" field. */
                dev->fw.patch = fwtime;
-               b43info(dev->wl, "Loading OpenSource firmware version %u.%u%s\n",
-                       dev->fw.rev, dev->fw.patch,
-                       dev->fw.pcm_request_failed ? " (Hardware crypto not supported)" : "");
+               b43info(dev->wl, "Loading OpenSource firmware version %u.%u\n",
+                       dev->fw.rev, dev->fw.patch);
+
+               fwcapa = b43_fwcapa_read(dev);
+               if (!(fwcapa & B43_FWCAPA_HWCRYPTO) || dev->fw.pcm_request_failed) {
+                       b43info(dev->wl, "Hardware crypto acceleration not supported by firmware\n");
+                       /* Disable hardware crypto and fall back to software crypto. */
+                       dev->hwcrypto_enabled = 0;
+               }
+               if (!(fwcapa & B43_FWCAPA_QOS)) {
+                       b43info(dev->wl, "QoS not supported by firmware\n");
+                       /* Disable QoS. Tweak hw->queues to 1. It will be restored before
+                        * ieee80211_unregister to make sure the networking core can
+                        * properly free possible resources. */
+                       dev->wl->hw->queues = 1;
+                       dev->qos_enabled = 0;
+               }
        } else {
                b43info(dev->wl, "Loading firmware version %u.%u "
                        "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
@@ -3468,9 +3495,9 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
        if (phy->ops->set_rx_antenna)
                phy->ops->set_rx_antenna(dev, antenna);
 
-       if (!!conf->radio_enabled != phy->radio_on) {
-               if (conf->radio_enabled) {
-                       b43_software_rfkill(dev, RFKILL_STATE_UNBLOCKED);
+       if (wl->radio_enabled != phy->radio_on) {
+               if (wl->radio_enabled) {
+                       b43_software_rfkill(dev, false);
                        b43info(dev->wl, "Radio turned on by software\n");
                        if (!dev->radio_hw_enable) {
                                b43info(dev->wl, "The hardware RF-kill button "
@@ -3478,7 +3505,7 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
                                        "Press the button to turn it on.\n");
                        }
                } else {
-                       b43_software_rfkill(dev, RFKILL_STATE_SOFT_BLOCKED);
+                       b43_software_rfkill(dev, true);
                        b43info(dev->wl, "Radio turned off by software\n");
                }
        }
@@ -3627,7 +3654,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        if (!dev || b43_status(dev) < B43_STAT_INITIALIZED)
                goto out_unlock;
 
-       if (dev->fw.pcm_request_failed) {
+       if (dev->fw.pcm_request_failed || !dev->hwcrypto_enabled) {
                /* We don't have firmware for the crypto engine.
                 * Must use software-crypto. */
                err = -EOPNOTSUPP;
@@ -4298,7 +4325,6 @@ static int b43_op_start(struct ieee80211_hw *hw)
        struct b43_wldev *dev = wl->current_dev;
        int did_init = 0;
        int err = 0;
-       bool do_rfkill_exit = 0;
 
        /* Kill all old instance specific information to make sure
         * the card won't use it in the short timeframe between start
@@ -4311,19 +4337,14 @@ static int b43_op_start(struct ieee80211_hw *hw)
        wl->beacon0_uploaded = 0;
        wl->beacon1_uploaded = 0;
        wl->beacon_templates_virgin = 1;
-
-       /* First register RFkill.
-        * LEDs that are registered later depend on it. */
-       b43_rfkill_init(dev);
+       wl->radio_enabled = 1;
 
        mutex_lock(&wl->mutex);
 
        if (b43_status(dev) < B43_STAT_INITIALIZED) {
                err = b43_wireless_core_init(dev);
-               if (err) {
-                       do_rfkill_exit = 1;
+               if (err)
                        goto out_mutex_unlock;
-               }
                did_init = 1;
        }
 
@@ -4332,17 +4353,16 @@ static int b43_op_start(struct ieee80211_hw *hw)
                if (err) {
                        if (did_init)
                                b43_wireless_core_exit(dev);
-                       do_rfkill_exit = 1;
                        goto out_mutex_unlock;
                }
        }
 
+       /* XXX: only do if device doesn't support rfkill irq */
+       wiphy_rfkill_start_polling(hw->wiphy);
+
  out_mutex_unlock:
        mutex_unlock(&wl->mutex);
 
-       if (do_rfkill_exit)
-               b43_rfkill_exit(dev);
-
        return err;
 }
 
@@ -4351,13 +4371,13 @@ static void b43_op_stop(struct ieee80211_hw *hw)
        struct b43_wl *wl = hw_to_b43_wl(hw);
        struct b43_wldev *dev = wl->current_dev;
 
-       b43_rfkill_exit(dev);
        cancel_work_sync(&(wl->beacon_update_trigger));
 
        mutex_lock(&wl->mutex);
        if (b43_status(dev) >= B43_STAT_STARTED)
                b43_wireless_core_stop(dev);
        b43_wireless_core_exit(dev);
+       wl->radio_enabled = 0;
        mutex_unlock(&wl->mutex);
 
        cancel_work_sync(&(wl->txpower_adjust_work));
@@ -4433,6 +4453,7 @@ static const struct ieee80211_ops b43_hw_ops = {
        .sta_notify             = b43_op_sta_notify,
        .sw_scan_start          = b43_op_sw_scan_start_notifier,
        .sw_scan_complete       = b43_op_sw_scan_complete_notifier,
+       .rfkill_poll            = b43_rfkill_poll,
 };
 
 /* Hard-reset the chip. Do not call this directly.
@@ -4539,6 +4560,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
                B43_WARN_ON(1);
 
        dev->phy.gmode = have_2ghz_phy;
+       dev->phy.radio_on = 1;
        tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0;
        b43_wireless_core_reset(dev, tmp);
 
@@ -4735,6 +4757,7 @@ static int b43_wireless_init(struct ssb_device *dev)
                b43err(NULL, "Could not allocate ieee80211 device\n");
                goto out;
        }
+       wl = hw_to_b43_wl(hw);
 
        /* fill hw info */
        hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
@@ -4748,7 +4771,8 @@ static int b43_wireless_init(struct ssb_device *dev)
                BIT(NL80211_IFTYPE_WDS) |
                BIT(NL80211_IFTYPE_ADHOC);
 
-       hw->queues = b43_modparam_qos ? 4 : 1;
+       hw->queues = modparam_qos ? 4 : 1;
+       wl->mac80211_initially_registered_queues = hw->queues;
        hw->max_rates = 2;
        SET_IEEE80211_DEV(hw, dev->dev);
        if (is_valid_ether_addr(sprom->et1mac))
@@ -4756,9 +4780,7 @@ static int b43_wireless_init(struct ssb_device *dev)
        else
                SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac);
 
-       /* Get and initialize struct b43_wl */
-       wl = hw_to_b43_wl(hw);
-       memset(wl, 0, sizeof(*wl));
+       /* Initialize struct b43_wl */
        wl->hw = hw;
        spin_lock_init(&wl->irq_lock);
        rwlock_init(&wl->tx_lock);
@@ -4824,8 +4846,13 @@ static void b43_remove(struct ssb_device *dev)
        cancel_work_sync(&wldev->restart_work);
 
        B43_WARN_ON(!wl);
-       if (wl->current_dev == wldev)
+       if (wl->current_dev == wldev) {
+               /* Restore the queues count before unregistering, because firmware detect
+                * might have modified it. Restoring is important, so the networking
+                * stack can properly free resources. */
+               wl->hw->queues = wl->mac80211_initially_registered_queues;
                ieee80211_unregister_hw(wl->hw);
+       }
 
        b43_one_core_detach(dev);
 
@@ -4920,7 +4947,7 @@ static struct ssb_driver b43_ssb_driver = {
 static void b43_print_driverinfo(void)
 {
        const char *feat_pci = "", *feat_pcmcia = "", *feat_nphy = "",
-                  *feat_leds = "", *feat_rfkill = "";
+                  *feat_leds = "";
 
 #ifdef CONFIG_B43_PCI_AUTOSELECT
        feat_pci = "P";
@@ -4933,15 +4960,12 @@ static void b43_print_driverinfo(void)
 #endif
 #ifdef CONFIG_B43_LEDS
        feat_leds = "L";
-#endif
-#ifdef CONFIG_B43_RFKILL
-       feat_rfkill = "R";
 #endif
        printk(KERN_INFO "Broadcom 43xx driver loaded "
-              "[ Features: %s%s%s%s%s, Firmware-ID: "
+              "[ Features: %s%s%s%s, Firmware-ID: "
               B43_SUPPORTED_FIRMWARE_ID " ]\n",
               feat_pci, feat_pcmcia, feat_nphy,
-              feat_leds, feat_rfkill);
+              feat_leds);
 }
 
 static int __init b43_init(void)