]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Merge branch 'wl12xx-next' into for-linville
authorLuciano Coelho <coelho@ti.com>
Thu, 8 Mar 2012 12:40:40 +0000 (14:40 +0200)
committerLuciano Coelho <coelho@ti.com>
Thu, 8 Mar 2012 12:40:40 +0000 (14:40 +0200)
169 files changed:
arch/mips/bcm47xx/Makefile
arch/mips/bcm47xx/nvram.c
arch/mips/bcm47xx/setup.c
arch/mips/bcm47xx/sprom.c [new file with mode: 0644]
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
arch/mips/include/asm/mach-bcm47xx/nvram.h
drivers/bcma/driver_chipcommon_pmu.c
drivers/bcma/main.c
drivers/bcma/sprom.c
drivers/net/wireless/airo.c
drivers/net/wireless/ath/ath5k/ath5k.h
drivers/net/wireless/ath/ath5k/base.c
drivers/net/wireless/ath/ath5k/mac80211-ops.c
drivers/net/wireless/ath/ath5k/phy.c
drivers/net/wireless/ath/ath6kl/wmi.c
drivers/net/wireless/ath/ath9k/Kconfig
drivers/net/wireless/ath/ath9k/ar5008_phy.c
drivers/net/wireless/ath/ath9k/ar9002_hw.c
drivers/net/wireless/ath/ath9k/ar9003_mac.c
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/beacon.c
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/debug.h
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/mac.c
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/rc.c
drivers/net/wireless/ath/ath9k/rc.h
drivers/net/wireless/ath/ath9k/recv.c
drivers/net/wireless/ath/ath9k/xmit.c
drivers/net/wireless/ath/carl9170/tx.c
drivers/net/wireless/b43/main.c
drivers/net/wireless/b43legacy/phy.c
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
drivers/net/wireless/brcm80211/brcmfmac/usb.c
drivers/net/wireless/brcm80211/brcmfmac/usb.h
drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
drivers/net/wireless/ipw2x00/ipw2100.c
drivers/net/wireless/iwlegacy/4965-calib.c
drivers/net/wireless/iwlegacy/4965-mac.c
drivers/net/wireless/iwlegacy/4965.h
drivers/net/wireless/iwlegacy/Kconfig
drivers/net/wireless/iwlegacy/common.h
drivers/net/wireless/iwlwifi/Makefile
drivers/net/wireless/iwlwifi/iwl-1000.c
drivers/net/wireless/iwlwifi/iwl-2000.c
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-6000.c
drivers/net/wireless/iwlwifi/iwl-agn-calib.c
drivers/net/wireless/iwlwifi/iwl-agn-lib.c
drivers/net/wireless/iwlwifi/iwl-agn-rs.c
drivers/net/wireless/iwlwifi/iwl-agn-rx.c
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
drivers/net/wireless/iwlwifi/iwl-agn-sta.c
drivers/net/wireless/iwlwifi/iwl-agn-tt.c
drivers/net/wireless/iwlwifi/iwl-agn-tx.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-agn.h
drivers/net/wireless/iwlwifi/iwl-bus.h [deleted file]
drivers/net/wireless/iwlwifi/iwl-cfg.h
drivers/net/wireless/iwlwifi/iwl-commands.h
drivers/net/wireless/iwlwifi/iwl-core.c
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl-debug.c
drivers/net/wireless/iwlwifi/iwl-debug.h
drivers/net/wireless/iwlwifi/iwl-debugfs.c
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/iwlwifi/iwl-devtrace.h
drivers/net/wireless/iwlwifi/iwl-drv.c [new file with mode: 0644]
drivers/net/wireless/iwlwifi/iwl-drv.h [new file with mode: 0644]
drivers/net/wireless/iwlwifi/iwl-eeprom.c
drivers/net/wireless/iwlwifi/iwl-eeprom.h
drivers/net/wireless/iwlwifi/iwl-fw-file.h [moved from drivers/net/wireless/iwlwifi/iwl-ucode.h with 75% similarity]
drivers/net/wireless/iwlwifi/iwl-fw.h [moved from drivers/net/wireless/iwlwifi/iwl-wifi.h with 59% similarity]
drivers/net/wireless/iwlwifi/iwl-io.h
drivers/net/wireless/iwlwifi/iwl-led.c
drivers/net/wireless/iwlwifi/iwl-mac80211.c
drivers/net/wireless/iwlwifi/iwl-notif-wait.c [new file with mode: 0644]
drivers/net/wireless/iwlwifi/iwl-notif-wait.h [moved from drivers/net/wireless/iwlwifi/iwl-trans.c with 59% similarity]
drivers/net/wireless/iwlwifi/iwl-op-mode.h [new file with mode: 0644]
drivers/net/wireless/iwlwifi/iwl-pci.c
drivers/net/wireless/iwlwifi/iwl-power.c
drivers/net/wireless/iwlwifi/iwl-scan.c
drivers/net/wireless/iwlwifi/iwl-shared.h
drivers/net/wireless/iwlwifi/iwl-testmode.c
drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
drivers/net/wireless/iwlwifi/iwl-trans.h
drivers/net/wireless/iwlwifi/iwl-ucode.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/cmdevt.c
drivers/net/wireless/mwifiex/decl.h
drivers/net/wireless/mwifiex/fw.h
drivers/net/wireless/mwifiex/init.c
drivers/net/wireless/mwifiex/ioctl.h
drivers/net/wireless/mwifiex/join.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/scan.c
drivers/net/wireless/mwifiex/sta_event.c
drivers/net/wireless/mwifiex/sta_ioctl.c
drivers/net/wireless/p54/main.c
drivers/net/wireless/p54/p54pci.c
drivers/net/wireless/p54/p54spi.c
drivers/net/wireless/p54/txrx.c
drivers/net/wireless/rndis_wlan.c
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rtl818x/rtl8187/dev.c
drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
drivers/net/wireless/rtlwifi/usb.c
drivers/net/wireless/zd1211rw/zd_mac.c
drivers/nfc/pn533.c
drivers/ssb/pci.c
drivers/ssb/pcmcia.c
drivers/ssb/sdio.c
include/linux/bcma/bcma.h
include/linux/bcma/bcma_driver_chipcommon.h
include/linux/nfc.h
include/linux/nl80211.h
include/linux/ssb/ssb.h
include/net/cfg80211.h
include/net/mac80211.h
include/net/nfc/nci_core.h
include/net/nfc/nfc.h
net/mac80211/cfg.c
net/mac80211/debugfs_netdev.c
net/mac80211/ibss.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/mesh.c
net/mac80211/mesh.h
net/mac80211/mesh_hwmp.c
net/mac80211/mesh_pathtbl.c
net/mac80211/mesh_plink.c
net/mac80211/mlme.c
net/mac80211/rate.c
net/mac80211/rx.c
net/mac80211/scan.c
net/mac80211/sta_info.c
net/mac80211/sta_info.h
net/mac80211/status.c
net/mac80211/tx.c
net/mac80211/util.c
net/nfc/af_nfc.c
net/nfc/core.c
net/nfc/llcp/commands.c
net/nfc/llcp/llcp.c
net/nfc/llcp/llcp.h
net/nfc/llcp/sock.c
net/nfc/nci/core.c
net/nfc/nci/data.c
net/nfc/nci/ntf.c
net/nfc/nci/rsp.c
net/nfc/netlink.c
net/nfc/nfc.h
net/nfc/rawsock.c
net/wireless/mesh.c
net/wireless/mlme.c
net/wireless/nl80211.c
net/wireless/nl80211.h
net/wireless/util.c

index 4add17349ff9549a264da1814249ae533144e042..4389de182eb476a5cf3ff50565e7f13b86585611 100644 (file)
@@ -3,5 +3,5 @@
 # under Linux.
 #
 
-obj-y                          += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o
+obj-y                          += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
 obj-$(CONFIG_BCM47XX_SSB)      += wgt634u.o
index a84e3bb7387f685bc7025e689e01e57cfa97bd21..d43ceff5be4782b7024ae0f04ad73f278d4d7486 100644 (file)
@@ -107,8 +107,7 @@ int nvram_getenv(char *name, char *val, size_t val_len)
                value = eq + 1;
                if ((eq - var) == strlen(name) &&
                        strncmp(var, name, (eq - var)) == 0) {
-                       snprintf(val, val_len, "%s", value);
-                       return 0;
+                       return snprintf(val, val_len, "%s", value);
                }
        }
        return NVRAM_ERR_ENVNOTFOUND;
index aab6b0c40a7569b54767c5e473e75da5ba5b8563..19780aa917081e0ce547c63e1ffc8fff9d8723be 100644 (file)
@@ -3,7 +3,7 @@
  *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
  *  Copyright (C) 2006 Michael Buesch <m@bues.ch>
  *  Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
- *  Copyright (C) 2010-2011 Hauke Mehrtens <hauke@hauke-m.de>
+ *  Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
@@ -85,156 +85,7 @@ static void bcm47xx_machine_halt(void)
 }
 
 #ifdef CONFIG_BCM47XX_SSB
-#define READ_FROM_NVRAM(_outvar, name, buf) \
-       if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\
-               sprom->_outvar = simple_strtoul(buf, NULL, 0);
-
-#define READ_FROM_NVRAM2(_outvar, name1, name2, buf) \
-       if (nvram_getprefix(prefix, name1, buf, sizeof(buf)) >= 0 || \
-           nvram_getprefix(prefix, name2, buf, sizeof(buf)) >= 0)\
-               sprom->_outvar = simple_strtoul(buf, NULL, 0);
-
-static inline int nvram_getprefix(const char *prefix, char *name,
-                                 char *buf, int len)
-{
-       if (prefix) {
-               char key[100];
-
-               snprintf(key, sizeof(key), "%s%s", prefix, name);
-               return nvram_getenv(key, buf, len);
-       }
-
-       return nvram_getenv(name, buf, len);
-}
-
-static u32 nvram_getu32(const char *name, char *buf, int len)
-{
-       int rv;
-       char key[100];
-       u16 var0, var1;
-
-       snprintf(key, sizeof(key), "%s0", name);
-       rv = nvram_getenv(key, buf, len);
-       /* return 0 here so this looks like unset */
-       if (rv < 0)
-               return 0;
-       var0 = simple_strtoul(buf, NULL, 0);
-
-       snprintf(key, sizeof(key), "%s1", name);
-       rv = nvram_getenv(key, buf, len);
-       if (rv < 0)
-               return 0;
-       var1 = simple_strtoul(buf, NULL, 0);
-       return var1 << 16 | var0;
-}
-
-static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
-{
-       char buf[100];
-       u32 boardflags;
-
-       memset(sprom, 0, sizeof(struct ssb_sprom));
-
-       sprom->revision = 1; /* Fallback: Old hardware does not define this. */
-       READ_FROM_NVRAM(revision, "sromrev", buf);
-       if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0 ||
-           nvram_getprefix(prefix, "macaddr", buf, sizeof(buf)) >= 0)
-               nvram_parse_macaddr(buf, sprom->il0mac);
-       if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0)
-               nvram_parse_macaddr(buf, sprom->et0mac);
-       if (nvram_getprefix(prefix, "et1macaddr", buf, sizeof(buf)) >= 0)
-               nvram_parse_macaddr(buf, sprom->et1mac);
-       READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
-       READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
-       READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
-       READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
-       READ_FROM_NVRAM(board_rev, "boardrev", buf);
-       READ_FROM_NVRAM(country_code, "ccode", buf);
-       READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
-       READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
-       READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
-       READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
-       READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
-       READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
-       READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
-       READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
-       READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
-       READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
-       READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
-       READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
-       READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
-       READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
-       READ_FROM_NVRAM2(gpio0, "ledbh0", "wl0gpio0", buf);
-       READ_FROM_NVRAM2(gpio1, "ledbh1", "wl0gpio1", buf);
-       READ_FROM_NVRAM2(gpio2, "ledbh2", "wl0gpio2", buf);
-       READ_FROM_NVRAM2(gpio3, "ledbh3", "wl0gpio3", buf);
-       READ_FROM_NVRAM2(maxpwr_bg, "maxp2ga0", "pa0maxpwr", buf);
-       READ_FROM_NVRAM2(maxpwr_al, "maxp5gla0", "pa1lomaxpwr", buf);
-       READ_FROM_NVRAM2(maxpwr_a, "maxp5ga0", "pa1maxpwr", buf);
-       READ_FROM_NVRAM2(maxpwr_ah, "maxp5gha0", "pa1himaxpwr", buf);
-       READ_FROM_NVRAM2(itssi_bg, "itt5ga0", "pa0itssit", buf);
-       READ_FROM_NVRAM2(itssi_a, "itt2ga0", "pa1itssit", buf);
-       READ_FROM_NVRAM(tri2g, "tri2g", buf);
-       READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
-       READ_FROM_NVRAM(tri5g, "tri5g", buf);
-       READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
-       READ_FROM_NVRAM(txpid2g[0], "txpid2ga0", buf);
-       READ_FROM_NVRAM(txpid2g[1], "txpid2ga1", buf);
-       READ_FROM_NVRAM(txpid2g[2], "txpid2ga2", buf);
-       READ_FROM_NVRAM(txpid2g[3], "txpid2ga3", buf);
-       READ_FROM_NVRAM(txpid5g[0], "txpid5ga0", buf);
-       READ_FROM_NVRAM(txpid5g[1], "txpid5ga1", buf);
-       READ_FROM_NVRAM(txpid5g[2], "txpid5ga2", buf);
-       READ_FROM_NVRAM(txpid5g[3], "txpid5ga3", buf);
-       READ_FROM_NVRAM(txpid5gl[0], "txpid5gla0", buf);
-       READ_FROM_NVRAM(txpid5gl[1], "txpid5gla1", buf);
-       READ_FROM_NVRAM(txpid5gl[2], "txpid5gla2", buf);
-       READ_FROM_NVRAM(txpid5gl[3], "txpid5gla3", buf);
-       READ_FROM_NVRAM(txpid5gh[0], "txpid5gha0", buf);
-       READ_FROM_NVRAM(txpid5gh[1], "txpid5gha1", buf);
-       READ_FROM_NVRAM(txpid5gh[2], "txpid5gha2", buf);
-       READ_FROM_NVRAM(txpid5gh[3], "txpid5gha3", buf);
-       READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
-       READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
-       READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
-       READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
-       READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
-       READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
-       READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
-       READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
-       READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
-       READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
-       READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
-
-       sprom->ofdm2gpo = nvram_getu32("ofdm2gpo", buf, sizeof(buf));
-       sprom->ofdm5glpo = nvram_getu32("ofdm5glpo", buf, sizeof(buf));
-       sprom->ofdm5gpo = nvram_getu32("ofdm5gpo", buf, sizeof(buf));
-       sprom->ofdm5ghpo = nvram_getu32("ofdm5ghpo", buf, sizeof(buf));
-
-       READ_FROM_NVRAM(antenna_gain.ghz24.a0, "ag0", buf);
-       READ_FROM_NVRAM(antenna_gain.ghz24.a1, "ag1", buf);
-       READ_FROM_NVRAM(antenna_gain.ghz24.a2, "ag2", buf);
-       READ_FROM_NVRAM(antenna_gain.ghz24.a3, "ag3", buf);
-       memcpy(&sprom->antenna_gain.ghz5, &sprom->antenna_gain.ghz24,
-              sizeof(sprom->antenna_gain.ghz5));
-
-       if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) {
-               boardflags = simple_strtoul(buf, NULL, 0);
-               if (boardflags) {
-                       sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
-                       sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
-               }
-       }
-       if (nvram_getprefix(prefix, "boardflags2", buf, sizeof(buf)) >= 0) {
-               boardflags = simple_strtoul(buf, NULL, 0);
-               if (boardflags) {
-                       sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
-                       sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
-               }
-       }
-}
-
-int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
+static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
 {
        char prefix[10];
 
@@ -251,7 +102,7 @@ int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
 }
 
 static int bcm47xx_get_invariants(struct ssb_bus *bus,
-                                  struct ssb_init_invariants *iv)
+                                 struct ssb_init_invariants *iv)
 {
        char buf[20];
 
@@ -281,7 +132,7 @@ static void __init bcm47xx_register_ssb(void)
        char buf[100];
        struct ssb_mipscore *mcore;
 
-       err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom);
+       err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
        if (err)
                printk(KERN_WARNING "bcm47xx: someone else already registered"
                        " a ssb SPROM callback handler (err %d)\n", err);
@@ -308,10 +159,41 @@ static void __init bcm47xx_register_ssb(void)
 #endif
 
 #ifdef CONFIG_BCM47XX_BCMA
+static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
+{
+       char prefix[10];
+       struct bcma_device *core;
+
+       switch (bus->hosttype) {
+       case BCMA_HOSTTYPE_PCI:
+               snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
+                        bus->host_pci->bus->number + 1,
+                        PCI_SLOT(bus->host_pci->devfn));
+               bcm47xx_fill_sprom(out, prefix);
+               return 0;
+       case BCMA_HOSTTYPE_SOC:
+               bcm47xx_fill_sprom_ethernet(out, NULL);
+               core = bcma_find_core(bus, BCMA_CORE_80211);
+               if (core) {
+                       snprintf(prefix, sizeof(prefix), "sb/%u/",
+                                core->core_index);
+                       bcm47xx_fill_sprom(out, prefix);
+               }
+               return 0;
+       default:
+               pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
+               return -EINVAL;
+       }
+}
+
 static void __init bcm47xx_register_bcma(void)
 {
        int err;
 
+       err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
+       if (err)
+               pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
+
        err = bcma_host_soc_register(&bcm47xx_bus.bcma);
        if (err)
                panic("Failed to initialize BCMA bus (err %d)", err);
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
new file mode 100644 (file)
index 0000000..5c8dcd2
--- /dev/null
@@ -0,0 +1,620 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2006 Michael Buesch <m@bues.ch>
+ *  Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
+ *  Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <bcm47xx.h>
+#include <nvram.h>
+
+static void create_key(const char *prefix, const char *postfix,
+                      const char *name, char *buf, int len)
+{
+       if (prefix && postfix)
+               snprintf(buf, len, "%s%s%s", prefix, name, postfix);
+       else if (prefix)
+               snprintf(buf, len, "%s%s", prefix, name);
+       else if (postfix)
+               snprintf(buf, len, "%s%s", name, postfix);
+       else
+               snprintf(buf, len, "%s", name);
+}
+
+#define NVRAM_READ_VAL(type)                                           \
+static void nvram_read_ ## type (const char *prefix,                   \
+                                const char *postfix, const char *name, \
+                                type *val, type allset)                \
+{                                                                      \
+       char buf[100];                                                  \
+       char key[40];                                                   \
+       int err;                                                        \
+       type var;                                                       \
+                                                                       \
+       create_key(prefix, postfix, name, key, sizeof(key));            \
+                                                                       \
+       err = nvram_getenv(key, buf, sizeof(buf));                      \
+       if (err < 0)                                                    \
+               return;                                                 \
+       err = kstrto ## type (buf, 0, &var);                            \
+       if (err) {                                                      \
+               pr_warn("can not parse nvram name %s with value %s"     \
+                       " got %i", key, buf, err);                      \
+               return;                                                 \
+       }                                                               \
+       if (allset && var == allset)                                    \
+               return;                                                 \
+       *val = var;                                                     \
+}
+
+NVRAM_READ_VAL(u8)
+NVRAM_READ_VAL(s8)
+NVRAM_READ_VAL(u16)
+NVRAM_READ_VAL(u32)
+
+#undef NVRAM_READ_VAL
+
+static void nvram_read_u32_2(const char *prefix, const char *name,
+                            u16 *val_lo, u16 *val_hi)
+{
+       char buf[100];
+       char key[40];
+       int err;
+       u32 val;
+
+       create_key(prefix, NULL, name, key, sizeof(key));
+
+       err = nvram_getenv(key, buf, sizeof(buf));
+       if (err < 0)
+               return;
+       err = kstrtou32(buf, 0, &val);
+       if (err) {
+               pr_warn("can not parse nvram name %s with value %s got %i",
+                       key, buf, err);
+               return;
+       }
+       *val_lo = (val & 0x0000FFFFU);
+       *val_hi = (val & 0xFFFF0000U) >> 16;
+}
+
+static void nvram_read_leddc(const char *prefix, const char *name,
+                            u8 *leddc_on_time, u8 *leddc_off_time)
+{
+       char buf[100];
+       char key[40];
+       int err;
+       u32 val;
+
+       create_key(prefix, NULL, name, key, sizeof(key));
+
+       err = nvram_getenv(key, buf, sizeof(buf));
+       if (err < 0)
+               return;
+       err = kstrtou32(buf, 0, &val);
+       if (err) {
+               pr_warn("can not parse nvram name %s with value %s got %i",
+                       key, buf, err);
+               return;
+       }
+
+       if (val == 0xffff || val == 0xffffffff)
+               return;
+
+       *leddc_on_time = val & 0xff;
+       *leddc_off_time = (val >> 16) & 0xff;
+}
+
+static void nvram_read_macaddr(const char *prefix, const char *name,
+                              u8 (*val)[6])
+{
+       char buf[100];
+       char key[40];
+       int err;
+
+       create_key(prefix, NULL, name, key, sizeof(key));
+
+       err = nvram_getenv(key, buf, sizeof(buf));
+       if (err < 0)
+               return;
+       nvram_parse_macaddr(buf, *val);
+}
+
+static void nvram_read_alpha2(const char *prefix, const char *name,
+                            char (*val)[2])
+{
+       char buf[10];
+       char key[40];
+       int err;
+
+       create_key(prefix, NULL, name, key, sizeof(key));
+
+       err = nvram_getenv(key, buf, sizeof(buf));
+       if (err < 0)
+               return;
+       if (buf[0] == '0')
+               return;
+       if (strlen(buf) > 2) {
+               pr_warn("alpha2 is too long %s", buf);
+               return;
+       }
+       memcpy(val, buf, sizeof(val));
+}
+
+static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom,
+                                       const char *prefix)
+{
+       nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0);
+       nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0);
+       nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff);
+       nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff);
+       nvram_read_u8(prefix, NULL, "ledbh2", &sprom->gpio2, 0xff);
+       nvram_read_u8(prefix, NULL, "ledbh3", &sprom->gpio3, 0xff);
+       nvram_read_u8(prefix, NULL, "aa2g", &sprom->ant_available_bg, 0);
+       nvram_read_u8(prefix, NULL, "aa5g", &sprom->ant_available_a, 0);
+       nvram_read_s8(prefix, NULL, "ag0", &sprom->antenna_gain.a0, 0);
+       nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0);
+       nvram_read_alpha2(prefix, "ccode", &sprom->alpha2);
+}
+
+static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom,
+                                     const char *prefix)
+{
+       nvram_read_u16(prefix, NULL, "pa0b0", &sprom->pa0b0, 0);
+       nvram_read_u16(prefix, NULL, "pa0b1", &sprom->pa0b1, 0);
+       nvram_read_u16(prefix, NULL, "pa0b2", &sprom->pa0b2, 0);
+       nvram_read_u8(prefix, NULL, "pa0itssit", &sprom->itssi_bg, 0);
+       nvram_read_u8(prefix, NULL, "pa0maxpwr", &sprom->maxpwr_bg, 0);
+       nvram_read_u16(prefix, NULL, "pa1b0", &sprom->pa1b0, 0);
+       nvram_read_u16(prefix, NULL, "pa1b1", &sprom->pa1b1, 0);
+       nvram_read_u16(prefix, NULL, "pa1b2", &sprom->pa1b2, 0);
+       nvram_read_u8(prefix, NULL, "pa1itssit", &sprom->itssi_a, 0);
+       nvram_read_u8(prefix, NULL, "pa1maxpwr", &sprom->maxpwr_a, 0);
+}
+
+static void bcm47xx_fill_sprom_r1(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u16(prefix, NULL, "boardflags", &sprom->boardflags_lo, 0);
+       nvram_read_u8(prefix, NULL, "cc", &sprom->country_code, 0);
+}
+
+static void bcm47xx_fill_sprom_r2389(struct ssb_sprom *sprom,
+                                    const char *prefix)
+{
+       nvram_read_u8(prefix, NULL, "opo", &sprom->opo, 0);
+       nvram_read_u16(prefix, NULL, "pa1lob0", &sprom->pa1lob0, 0);
+       nvram_read_u16(prefix, NULL, "pa1lob1", &sprom->pa1lob1, 0);
+       nvram_read_u16(prefix, NULL, "pa1lob2", &sprom->pa1lob2, 0);
+       nvram_read_u16(prefix, NULL, "pa1hib0", &sprom->pa1hib0, 0);
+       nvram_read_u16(prefix, NULL, "pa1hib1", &sprom->pa1hib1, 0);
+       nvram_read_u16(prefix, NULL, "pa1hib2", &sprom->pa1hib2, 0);
+       nvram_read_u8(prefix, NULL, "pa1lomaxpwr", &sprom->maxpwr_al, 0);
+       nvram_read_u8(prefix, NULL, "pa1himaxpwr", &sprom->maxpwr_ah, 0);
+}
+
+static void bcm47xx_fill_sprom_r2(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
+                        &sprom->boardflags_hi);
+       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
+}
+
+static void bcm47xx_fill_sprom_r389(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u8(prefix, NULL, "bxa2g", &sprom->bxa2g, 0);
+       nvram_read_u8(prefix, NULL, "rssisav2g", &sprom->rssisav2g, 0);
+       nvram_read_u8(prefix, NULL, "rssismc2g", &sprom->rssismc2g, 0);
+       nvram_read_u8(prefix, NULL, "rssismf2g", &sprom->rssismf2g, 0);
+       nvram_read_u8(prefix, NULL, "bxa5g", &sprom->bxa5g, 0);
+       nvram_read_u8(prefix, NULL, "rssisav5g", &sprom->rssisav5g, 0);
+       nvram_read_u8(prefix, NULL, "rssismc5g", &sprom->rssismc5g, 0);
+       nvram_read_u8(prefix, NULL, "rssismf5g", &sprom->rssismf5g, 0);
+       nvram_read_u8(prefix, NULL, "tri2g", &sprom->tri2g, 0);
+       nvram_read_u8(prefix, NULL, "tri5g", &sprom->tri5g, 0);
+       nvram_read_u8(prefix, NULL, "tri5gl", &sprom->tri5gl, 0);
+       nvram_read_u8(prefix, NULL, "tri5gh", &sprom->tri5gh, 0);
+       nvram_read_s8(prefix, NULL, "rxpo2g", &sprom->rxpo2g, 0);
+       nvram_read_s8(prefix, NULL, "rxpo5g", &sprom->rxpo5g, 0);
+}
+
+static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
+                        &sprom->boardflags_hi);
+       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
+       nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0);
+       nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
+                        &sprom->leddc_off_time);
+}
+
+static void bcm47xx_fill_sprom_r4589(struct ssb_sprom *sprom,
+                                    const char *prefix)
+{
+       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
+                        &sprom->boardflags_hi);
+       nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo,
+                        &sprom->boardflags2_hi);
+       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
+       nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0);
+       nvram_read_s8(prefix, NULL, "ag2", &sprom->antenna_gain.a2, 0);
+       nvram_read_s8(prefix, NULL, "ag3", &sprom->antenna_gain.a3, 0);
+       nvram_read_u8(prefix, NULL, "txchain", &sprom->txchain, 0xf);
+       nvram_read_u8(prefix, NULL, "rxchain", &sprom->rxchain, 0xf);
+       nvram_read_u8(prefix, NULL, "antswitch", &sprom->antswitch, 0xff);
+       nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
+                        &sprom->leddc_off_time);
+}
+
+static void bcm47xx_fill_sprom_r458(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u16(prefix, NULL, "cck2gpo", &sprom->cck2gpo, 0);
+       nvram_read_u32(prefix, NULL, "ofdm2gpo", &sprom->ofdm2gpo, 0);
+       nvram_read_u32(prefix, NULL, "ofdm5gpo", &sprom->ofdm5gpo, 0);
+       nvram_read_u32(prefix, NULL, "ofdm5glpo", &sprom->ofdm5glpo, 0);
+       nvram_read_u32(prefix, NULL, "ofdm5ghpo", &sprom->ofdm5ghpo, 0);
+       nvram_read_u16(prefix, NULL, "cddpo", &sprom->cddpo, 0);
+       nvram_read_u16(prefix, NULL, "stbcpo", &sprom->stbcpo, 0);
+       nvram_read_u16(prefix, NULL, "bw40po", &sprom->bw40po, 0);
+       nvram_read_u16(prefix, NULL, "bwduppo", &sprom->bwduppo, 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo0", &sprom->mcs2gpo[0], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo1", &sprom->mcs2gpo[1], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo2", &sprom->mcs2gpo[2], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo3", &sprom->mcs2gpo[3], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo4", &sprom->mcs2gpo[4], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo5", &sprom->mcs2gpo[5], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo6", &sprom->mcs2gpo[6], 0);
+       nvram_read_u16(prefix, NULL, "mcs2gpo7", &sprom->mcs2gpo[7], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo0", &sprom->mcs5gpo[0], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo1", &sprom->mcs5gpo[1], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo2", &sprom->mcs5gpo[2], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo3", &sprom->mcs5gpo[3], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo4", &sprom->mcs5gpo[4], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo5", &sprom->mcs5gpo[5], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo6", &sprom->mcs5gpo[6], 0);
+       nvram_read_u16(prefix, NULL, "mcs5gpo7", &sprom->mcs5gpo[7], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo0", &sprom->mcs5glpo[0], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo1", &sprom->mcs5glpo[1], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo2", &sprom->mcs5glpo[2], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo3", &sprom->mcs5glpo[3], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo4", &sprom->mcs5glpo[4], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo5", &sprom->mcs5glpo[5], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo6", &sprom->mcs5glpo[6], 0);
+       nvram_read_u16(prefix, NULL, "mcs5glpo7", &sprom->mcs5glpo[7], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo0", &sprom->mcs5ghpo[0], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo1", &sprom->mcs5ghpo[1], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo2", &sprom->mcs5ghpo[2], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo3", &sprom->mcs5ghpo[3], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo4", &sprom->mcs5ghpo[4], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo5", &sprom->mcs5ghpo[5], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo6", &sprom->mcs5ghpo[6], 0);
+       nvram_read_u16(prefix, NULL, "mcs5ghpo7", &sprom->mcs5ghpo[7], 0);
+}
+
+static void bcm47xx_fill_sprom_r45(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u8(prefix, NULL, "txpid2ga0", &sprom->txpid2g[0], 0);
+       nvram_read_u8(prefix, NULL, "txpid2ga1", &sprom->txpid2g[1], 0);
+       nvram_read_u8(prefix, NULL, "txpid2ga2", &sprom->txpid2g[2], 0);
+       nvram_read_u8(prefix, NULL, "txpid2ga3", &sprom->txpid2g[3], 0);
+       nvram_read_u8(prefix, NULL, "txpid5ga0", &sprom->txpid5g[0], 0);
+       nvram_read_u8(prefix, NULL, "txpid5ga1", &sprom->txpid5g[1], 0);
+       nvram_read_u8(prefix, NULL, "txpid5ga2", &sprom->txpid5g[2], 0);
+       nvram_read_u8(prefix, NULL, "txpid5ga3", &sprom->txpid5g[3], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gla0", &sprom->txpid5gl[0], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gla1", &sprom->txpid5gl[1], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gla2", &sprom->txpid5gl[2], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gla3", &sprom->txpid5gl[3], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gha0", &sprom->txpid5gh[0], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gha1", &sprom->txpid5gh[1], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gha2", &sprom->txpid5gh[2], 0);
+       nvram_read_u8(prefix, NULL, "txpid5gha3", &sprom->txpid5gh[3], 0);
+}
+
+static void bcm47xx_fill_sprom_r89(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u8(prefix, NULL, "tssipos2g", &sprom->fem.ghz2.tssipos, 0);
+       nvram_read_u8(prefix, NULL, "extpagain2g",
+                     &sprom->fem.ghz2.extpa_gain, 0);
+       nvram_read_u8(prefix, NULL, "pdetrange2g",
+                     &sprom->fem.ghz2.pdet_range, 0);
+       nvram_read_u8(prefix, NULL, "triso2g", &sprom->fem.ghz2.tr_iso, 0);
+       nvram_read_u8(prefix, NULL, "antswctl2g", &sprom->fem.ghz2.antswlut, 0);
+       nvram_read_u8(prefix, NULL, "tssipos5g", &sprom->fem.ghz5.tssipos, 0);
+       nvram_read_u8(prefix, NULL, "extpagain5g",
+                     &sprom->fem.ghz5.extpa_gain, 0);
+       nvram_read_u8(prefix, NULL, "pdetrange5g",
+                     &sprom->fem.ghz5.pdet_range, 0);
+       nvram_read_u8(prefix, NULL, "triso5g", &sprom->fem.ghz5.tr_iso, 0);
+       nvram_read_u8(prefix, NULL, "antswctl5g", &sprom->fem.ghz5.antswlut, 0);
+       nvram_read_u8(prefix, NULL, "tempthresh", &sprom->tempthresh, 0);
+       nvram_read_u8(prefix, NULL, "tempoffset", &sprom->tempoffset, 0);
+       nvram_read_u16(prefix, NULL, "rawtempsense", &sprom->rawtempsense, 0);
+       nvram_read_u8(prefix, NULL, "measpower", &sprom->measpower, 0);
+       nvram_read_u8(prefix, NULL, "tempsense_slope",
+                     &sprom->tempsense_slope, 0);
+       nvram_read_u8(prefix, NULL, "tempcorrx", &sprom->tempcorrx, 0);
+       nvram_read_u8(prefix, NULL, "tempsense_option",
+                     &sprom->tempsense_option, 0);
+       nvram_read_u8(prefix, NULL, "freqoffset_corr",
+                     &sprom->freqoffset_corr, 0);
+       nvram_read_u8(prefix, NULL, "iqcal_swp_dis", &sprom->iqcal_swp_dis, 0);
+       nvram_read_u8(prefix, NULL, "hw_iqcal_en", &sprom->hw_iqcal_en, 0);
+       nvram_read_u8(prefix, NULL, "elna2g", &sprom->elna2g, 0);
+       nvram_read_u8(prefix, NULL, "elna5g", &sprom->elna5g, 0);
+       nvram_read_u8(prefix, NULL, "phycal_tempdelta",
+                     &sprom->phycal_tempdelta, 0);
+       nvram_read_u8(prefix, NULL, "temps_period", &sprom->temps_period, 0);
+       nvram_read_u8(prefix, NULL, "temps_hysteresis",
+                     &sprom->temps_hysteresis, 0);
+       nvram_read_u8(prefix, NULL, "measpower1", &sprom->measpower1, 0);
+       nvram_read_u8(prefix, NULL, "measpower2", &sprom->measpower2, 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr2ga0",
+                     &sprom->rxgainerr2ga[0], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr2ga1",
+                     &sprom->rxgainerr2ga[1], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr2ga2",
+                     &sprom->rxgainerr2ga[2], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gla0",
+                     &sprom->rxgainerr5gla[0], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gla1",
+                     &sprom->rxgainerr5gla[1], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gla2",
+                     &sprom->rxgainerr5gla[2], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gma0",
+                     &sprom->rxgainerr5gma[0], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gma1",
+                     &sprom->rxgainerr5gma[1], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gma2",
+                     &sprom->rxgainerr5gma[2], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gha0",
+                     &sprom->rxgainerr5gha[0], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gha1",
+                     &sprom->rxgainerr5gha[1], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gha2",
+                     &sprom->rxgainerr5gha[2], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gua0",
+                     &sprom->rxgainerr5gua[0], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gua1",
+                     &sprom->rxgainerr5gua[1], 0);
+       nvram_read_u8(prefix, NULL, "rxgainerr5gua2",
+                     &sprom->rxgainerr5gua[2], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl2ga0", &sprom->noiselvl2ga[0], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl2ga1", &sprom->noiselvl2ga[1], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl2ga2", &sprom->noiselvl2ga[2], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gla0",
+                     &sprom->noiselvl5gla[0], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gla1",
+                     &sprom->noiselvl5gla[1], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gla2",
+                     &sprom->noiselvl5gla[2], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gma0",
+                     &sprom->noiselvl5gma[0], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gma1",
+                     &sprom->noiselvl5gma[1], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gma2",
+                     &sprom->noiselvl5gma[2], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gha0",
+                     &sprom->noiselvl5gha[0], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gha1",
+                     &sprom->noiselvl5gha[1], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gha2",
+                     &sprom->noiselvl5gha[2], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gua0",
+                     &sprom->noiselvl5gua[0], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gua1",
+                     &sprom->noiselvl5gua[1], 0);
+       nvram_read_u8(prefix, NULL, "noiselvl5gua2",
+                     &sprom->noiselvl5gua[2], 0);
+       nvram_read_u8(prefix, NULL, "pcieingress_war",
+                     &sprom->pcieingress_war, 0);
+}
+
+static void bcm47xx_fill_sprom_r9(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_u16(prefix, NULL, "cckbw202gpo", &sprom->cckbw202gpo, 0);
+       nvram_read_u16(prefix, NULL, "cckbw20ul2gpo", &sprom->cckbw20ul2gpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw202gpo",
+                      &sprom->legofdmbw202gpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw20ul2gpo",
+                      &sprom->legofdmbw20ul2gpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw205glpo",
+                      &sprom->legofdmbw205glpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw20ul5glpo",
+                      &sprom->legofdmbw20ul5glpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw205gmpo",
+                      &sprom->legofdmbw205gmpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw20ul5gmpo",
+                      &sprom->legofdmbw20ul5gmpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw205ghpo",
+                      &sprom->legofdmbw205ghpo, 0);
+       nvram_read_u32(prefix, NULL, "legofdmbw20ul5ghpo",
+                      &sprom->legofdmbw20ul5ghpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw202gpo", &sprom->mcsbw202gpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw20ul2gpo", &sprom->mcsbw20ul2gpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw402gpo", &sprom->mcsbw402gpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw205glpo", &sprom->mcsbw205glpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw20ul5glpo",
+                      &sprom->mcsbw20ul5glpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw405glpo", &sprom->mcsbw405glpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw205gmpo", &sprom->mcsbw205gmpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw20ul5gmpo",
+                      &sprom->mcsbw20ul5gmpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw405gmpo", &sprom->mcsbw405gmpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw205ghpo", &sprom->mcsbw205ghpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw20ul5ghpo",
+                      &sprom->mcsbw20ul5ghpo, 0);
+       nvram_read_u32(prefix, NULL, "mcsbw405ghpo", &sprom->mcsbw405ghpo, 0);
+       nvram_read_u16(prefix, NULL, "mcs32po", &sprom->mcs32po, 0);
+       nvram_read_u16(prefix, NULL, "legofdm40duppo",
+                      &sprom->legofdm40duppo, 0);
+       nvram_read_u8(prefix, NULL, "sar2g", &sprom->sar2g, 0);
+       nvram_read_u8(prefix, NULL, "sar5g", &sprom->sar5g, 0);
+}
+
+static void bcm47xx_fill_sprom_path_r4589(struct ssb_sprom *sprom,
+                                         const char *prefix)
+{
+       char postfix[2];
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) {
+               struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i];
+               snprintf(postfix, sizeof(postfix), "%i", i);
+               nvram_read_u8(prefix, postfix, "maxp2ga",
+                             &pwr_info->maxpwr_2g, 0);
+               nvram_read_u8(prefix, postfix, "itt2ga",
+                             &pwr_info->itssi_2g, 0);
+               nvram_read_u8(prefix, postfix, "itt5ga",
+                             &pwr_info->itssi_5g, 0);
+               nvram_read_u16(prefix, postfix, "pa2gw0a",
+                              &pwr_info->pa_2g[0], 0);
+               nvram_read_u16(prefix, postfix, "pa2gw1a",
+                              &pwr_info->pa_2g[1], 0);
+               nvram_read_u16(prefix, postfix, "pa2gw2a",
+                              &pwr_info->pa_2g[2], 0);
+               nvram_read_u8(prefix, postfix, "maxp5ga",
+                             &pwr_info->maxpwr_5g, 0);
+               nvram_read_u8(prefix, postfix, "maxp5gha",
+                             &pwr_info->maxpwr_5gh, 0);
+               nvram_read_u8(prefix, postfix, "maxp5gla",
+                             &pwr_info->maxpwr_5gl, 0);
+               nvram_read_u16(prefix, postfix, "pa5gw0a",
+                              &pwr_info->pa_5g[0], 0);
+               nvram_read_u16(prefix, postfix, "pa5gw1a",
+                              &pwr_info->pa_5g[1], 0);
+               nvram_read_u16(prefix, postfix, "pa5gw2a",
+                              &pwr_info->pa_5g[2], 0);
+               nvram_read_u16(prefix, postfix, "pa5glw0a",
+                              &pwr_info->pa_5gl[0], 0);
+               nvram_read_u16(prefix, postfix, "pa5glw1a",
+                              &pwr_info->pa_5gl[1], 0);
+               nvram_read_u16(prefix, postfix, "pa5glw2a",
+                              &pwr_info->pa_5gl[2], 0);
+               nvram_read_u16(prefix, postfix, "pa5ghw0a",
+                              &pwr_info->pa_5gh[0], 0);
+               nvram_read_u16(prefix, postfix, "pa5ghw1a",
+                              &pwr_info->pa_5gh[1], 0);
+               nvram_read_u16(prefix, postfix, "pa5ghw2a",
+                              &pwr_info->pa_5gh[2], 0);
+       }
+}
+
+static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom,
+                                       const char *prefix)
+{
+       char postfix[2];
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) {
+               struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i];
+               snprintf(postfix, sizeof(postfix), "%i", i);
+               nvram_read_u16(prefix, postfix, "pa2gw3a",
+                              &pwr_info->pa_2g[3], 0);
+               nvram_read_u16(prefix, postfix, "pa5gw3a",
+                              &pwr_info->pa_5g[3], 0);
+               nvram_read_u16(prefix, postfix, "pa5glw3a",
+                              &pwr_info->pa_5gl[3], 0);
+               nvram_read_u16(prefix, postfix, "pa5ghw3a",
+                              &pwr_info->pa_5gh[3], 0);
+       }
+}
+
+void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix)
+{
+       nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac);
+       nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0);
+       nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0);
+
+       nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac);
+       nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0);
+       nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0);
+
+       nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac);
+       nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac);
+}
+
+void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
+{
+       memset(sprom, 0, sizeof(struct ssb_sprom));
+
+       bcm47xx_fill_sprom_ethernet(sprom, prefix);
+
+       nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0);
+
+       switch (sprom->revision) {
+       case 1:
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r12389(sprom, prefix);
+               bcm47xx_fill_sprom_r1(sprom, prefix);
+               break;
+       case 2:
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r12389(sprom, prefix);
+               bcm47xx_fill_sprom_r2389(sprom, prefix);
+               bcm47xx_fill_sprom_r2(sprom, prefix);
+               break;
+       case 3:
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r12389(sprom, prefix);
+               bcm47xx_fill_sprom_r2389(sprom, prefix);
+               bcm47xx_fill_sprom_r389(sprom, prefix);
+               bcm47xx_fill_sprom_r3(sprom, prefix);
+               break;
+       case 4:
+       case 5:
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r4589(sprom, prefix);
+               bcm47xx_fill_sprom_r458(sprom, prefix);
+               bcm47xx_fill_sprom_r45(sprom, prefix);
+               bcm47xx_fill_sprom_path_r4589(sprom, prefix);
+               bcm47xx_fill_sprom_path_r45(sprom, prefix);
+               break;
+       case 8:
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r12389(sprom, prefix);
+               bcm47xx_fill_sprom_r2389(sprom, prefix);
+               bcm47xx_fill_sprom_r389(sprom, prefix);
+               bcm47xx_fill_sprom_r4589(sprom, prefix);
+               bcm47xx_fill_sprom_r458(sprom, prefix);
+               bcm47xx_fill_sprom_r89(sprom, prefix);
+               bcm47xx_fill_sprom_path_r4589(sprom, prefix);
+               break;
+       case 9:
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r12389(sprom, prefix);
+               bcm47xx_fill_sprom_r2389(sprom, prefix);
+               bcm47xx_fill_sprom_r389(sprom, prefix);
+               bcm47xx_fill_sprom_r4589(sprom, prefix);
+               bcm47xx_fill_sprom_r89(sprom, prefix);
+               bcm47xx_fill_sprom_r9(sprom, prefix);
+               bcm47xx_fill_sprom_path_r4589(sprom, prefix);
+               break;
+       default:
+               pr_warn("Unsupported SPROM revision %d detected. Will extract"
+                       " v1\n", sprom->revision);
+               sprom->revision = 1;
+               bcm47xx_fill_sprom_r1234589(sprom, prefix);
+               bcm47xx_fill_sprom_r12389(sprom, prefix);
+               bcm47xx_fill_sprom_r1(sprom, prefix);
+       }
+}
index de95e0723e2bb058d3164a54c6cc9a1153b9b6e0..5ecaf47b34d2c965dac18d212497dcaf1c71a562 100644 (file)
@@ -44,4 +44,7 @@ union bcm47xx_bus {
 extern union bcm47xx_bus bcm47xx_bus;
 extern enum bcm47xx_bus_type bcm47xx_bus_type;
 
+void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix);
+void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix);
+
 #endif /* __ASM_BCM47XX_H */
index 184d5ecb5f51bbec1f7b0584adfe0e273a383a42..69ef3efe06e7ab40f5a168a5ec766031177df2d6 100644 (file)
@@ -37,7 +37,7 @@ struct nvram_header {
 
 extern int nvram_getenv(char *name, char *val, size_t val_len);
 
-static inline void nvram_parse_macaddr(char *buf, u8 *macaddr)
+static inline void nvram_parse_macaddr(char *buf, u8 macaddr[6])
 {
        if (strchr(buf, ':'))
                sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0],
index 800163c8c2e7a046a4aa1219e6d7c876be0be19b..a058842f14fdf54b92b495f01c34a02ed2b74bcc 100644 (file)
@@ -80,6 +80,7 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
                min_msk = 0x200D;
                max_msk = 0xFFFF;
                break;
+       case 0x4331:
        case 43224:
        case 43225:
                break;
index b8379b90d045c85b1581e3b97b9f4bcb42aff2e1..7e138ec21357bb460e69f5aaed01d09307605709 100644 (file)
@@ -61,7 +61,7 @@ static struct bus_type bcma_bus_type = {
        .dev_attrs      = bcma_device_attrs,
 };
 
-static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
+struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
 {
        struct bcma_device *core;
 
@@ -71,6 +71,7 @@ static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
        }
        return NULL;
 }
+EXPORT_SYMBOL_GPL(bcma_find_core);
 
 static void bcma_release_core_dev(struct device *dev)
 {
index ca7752510d5b3a943bb2b5feb28a98ae54708318..cdcf75c0954febe06c4ac04f030568470284c160 100644 (file)
@@ -2,6 +2,8 @@
  * Broadcom specific AMBA
  * SPROM reading
  *
+ * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
+ *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 
+static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out);
+
+/**
+ * bcma_arch_register_fallback_sprom - Registers a method providing a
+ * fallback SPROM if no SPROM is found.
+ *
+ * @sprom_callback: The callback function.
+ *
+ * With this function the architecture implementation may register a
+ * callback handler which fills the SPROM data structure. The fallback is
+ * used for PCI based BCMA devices, where no valid SPROM can be found
+ * in the shadow registers and to provide the SPROM for SoCs where BCMA is
+ * to controll the system bus.
+ *
+ * This function is useful for weird architectures that have a half-assed
+ * BCMA device hardwired to their PCI bus.
+ *
+ * This function is available for architecture code, only. So it is not
+ * exported.
+ */
+int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus,
+                                    struct ssb_sprom *out))
+{
+       if (get_fallback_sprom)
+               return -EEXIST;
+       get_fallback_sprom = sprom_callback;
+
+       return 0;
+}
+
+static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus,
+                                        struct ssb_sprom *out)
+{
+       int err;
+
+       if (!get_fallback_sprom) {
+               err = -ENOENT;
+               goto fail;
+       }
+
+       err = get_fallback_sprom(bus, out);
+       if (err)
+               goto fail;
+
+       pr_debug("Using SPROM revision %d provided by"
+                " platform.\n", bus->sprom.revision);
+       return 0;
+fail:
+       pr_warn("Using fallback SPROM failed (err %d)\n", err);
+       return err;
+}
+
 /**************************************************
  * R/W ops.
  **************************************************/
@@ -246,23 +300,128 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
             SSB_SROM8_FEM_ANTSWLUT_SHIFT);
 }
 
+/*
+ * Indicates the presence of external SPROM.
+ */
+static bool bcma_sprom_ext_available(struct bcma_bus *bus)
+{
+       u32 chip_status;
+       u32 srom_control;
+       u32 present_mask;
+
+       if (bus->drv_cc.core->id.rev >= 31) {
+               if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
+                       return false;
+
+               srom_control = bcma_read32(bus->drv_cc.core,
+                                          BCMA_CC_SROM_CONTROL);
+               return srom_control & BCMA_CC_SROM_CONTROL_PRESENT;
+       }
+
+       /* older chipcommon revisions use chip status register */
+       chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
+       switch (bus->chipinfo.id) {
+       case 0x4313:
+               present_mask = BCMA_CC_CHIPST_4313_SPROM_PRESENT;
+               break;
+
+       case 0x4331:
+               present_mask = BCMA_CC_CHIPST_4331_SPROM_PRESENT;
+               break;
+
+       default:
+               return true;
+       }
+
+       return chip_status & present_mask;
+}
+
+/*
+ * Indicates that on-chip OTP memory is present and enabled.
+ */
+static bool bcma_sprom_onchip_available(struct bcma_bus *bus)
+{
+       u32 chip_status;
+       u32 otpsize = 0;
+       bool present;
+
+       chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
+       switch (bus->chipinfo.id) {
+       case 0x4313:
+               present = chip_status & BCMA_CC_CHIPST_4313_OTP_PRESENT;
+               break;
+
+       case 0x4331:
+               present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
+               break;
+
+       case 43224:
+       case 43225:
+               /* for these chips OTP is always available */
+               present = true;
+               break;
+
+       default:
+               present = false;
+               break;
+       }
+
+       if (present) {
+               otpsize = bus->drv_cc.capabilities & BCMA_CC_CAP_OTPS;
+               otpsize >>= BCMA_CC_CAP_OTPS_SHIFT;
+       }
+
+       return otpsize != 0;
+}
+
+/*
+ * Verify OTP is filled and determine the byte
+ * offset where SPROM data is located.
+ *
+ * On error, returns 0; byte offset otherwise.
+ */
+static int bcma_sprom_onchip_offset(struct bcma_bus *bus)
+{
+       struct bcma_device *cc = bus->drv_cc.core;
+       u32 offset;
+
+       /* verify OTP status */
+       if ((bcma_read32(cc, BCMA_CC_OTPS) & BCMA_CC_OTPS_GU_PROG_HW) == 0)
+               return 0;
+
+       /* obtain bit offset from otplayout register */
+       offset = (bcma_read32(cc, BCMA_CC_OTPL) & BCMA_CC_OTPL_GURGN_OFFSET);
+       return BCMA_CC_SPROM + (offset >> 3);
+}
+
 int bcma_sprom_get(struct bcma_bus *bus)
 {
-       u16 offset;
+       u16 offset = BCMA_CC_SPROM;
        u16 *sprom;
-       u32 sromctrl;
        int err = 0;
 
        if (!bus->drv_cc.core)
                return -EOPNOTSUPP;
 
-       if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
-               return -ENOENT;
-
-       if (bus->drv_cc.core->id.rev >= 32) {
-               sromctrl = bcma_read32(bus->drv_cc.core, BCMA_CC_SROM_CONTROL);
-               if (!(sromctrl & BCMA_CC_SROM_CONTROL_PRESENT))
-                       return -ENOENT;
+       if (!bcma_sprom_ext_available(bus)) {
+               /*
+                * External SPROM takes precedence so check
+                * on-chip OTP only when no external SPROM
+                * is present.
+                */
+               if (bcma_sprom_onchip_available(bus)) {
+                       /* determine offset */
+                       offset = bcma_sprom_onchip_offset(bus);
+               }
+               if (!offset) {
+                       /*
+                        * Maybe there is no SPROM on the device?
+                        * Now we ask the arch code if there is some sprom
+                        * available for this device in some other storage.
+                        */
+                       err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
+                       return err;
+               }
        }
 
        sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
@@ -273,11 +432,6 @@ int bcma_sprom_get(struct bcma_bus *bus)
        if (bus->chipinfo.id == 0x4331)
                bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
 
-       /* Most cards have SPROM moved by additional offset 0x30 (48 dwords).
-        * According to brcm80211 this applies to cards with PCIe rev >= 6
-        * TODO: understand this condition and use it */
-       offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM :
-               BCMA_CC_SPROM_PCIE6;
        pr_debug("SPROM offset 0x%x\n", offset);
        bcma_sprom_read(bus, offset, sprom);
 
index 1c008c61b95ce8113d8ad230ee4e48aad27992b7..ddc061dd150ce47438020f28424a7449e9ab66a5 100644 (file)
@@ -1869,7 +1869,7 @@ static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock)
 
 static void try_auto_wep(struct airo_info *ai)
 {
-       if (auto_wep && !(ai->flags & FLAG_RADIO_DOWN)) {
+       if (auto_wep && !test_bit(FLAG_RADIO_DOWN, &ai->flags)) {
                ai->expires = RUN_AT(3*HZ);
                wake_up_interruptible(&ai->thr_wait);
        }
index 6640326f70056d1af8074eb90699316d20d156e8..8d434b8f58557ff8b105371fe012661b829367e4 100644 (file)
@@ -1320,6 +1320,7 @@ struct ath5k_hw {
        struct ieee80211_vif    *bslot[ATH_BCBUF];
        u16                     num_ap_vifs;
        u16                     num_adhoc_vifs;
+       u16                     num_mesh_vifs;
        unsigned int            bhalq,          /* SW q for outgoing beacons */
                                bmisscount,     /* missed beacon transmits */
                                bintval,        /* beacon interval in TU */
index a339693fbe265cfc475f097d70fb0c11dc29e0b0..0e643b016b3286a12d80e040a7d399914468f8fb 100644 (file)
@@ -1867,7 +1867,8 @@ ath5k_beacon_send(struct ath5k_hw *ah)
                ah->bmisscount = 0;
        }
 
-       if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs > 1) ||
+       if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs +
+                       ah->num_mesh_vifs > 1) ||
                        ah->opmode == NL80211_IFTYPE_MESH_POINT) {
                u64 tsf = ath5k_hw_get_tsf64(ah);
                u32 tsftu = TSF_TO_TU(tsf);
@@ -1952,7 +1953,8 @@ ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf)
        u64 hw_tsf;
 
        intval = ah->bintval & AR5K_BEACON_PERIOD;
-       if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs > 1) {
+       if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs
+               + ah->num_mesh_vifs > 1) {
                intval /= ATH_BCBUF;    /* staggered multi-bss beacons */
                if (intval < 15)
                        ATH5K_WARN(ah, "intval %u is too low, min 15\n",
@@ -2330,15 +2332,6 @@ ath5k_calibrate_work(struct work_struct *work)
                                        "got new rfgain, resetting\n");
                        ieee80211_queue_work(ah->hw, &ah->reset_work);
                }
-
-               /* TODO: On full calibration we should stop TX here,
-                * so that it doesn't interfere (mostly due to gain_f
-                * calibration that messes with tx packets -see phy.c).
-                *
-                * NOTE: Stopping the queues from above is not enough
-                * to stop TX but saves us from disconecting (at least
-                * we don't lose packets). */
-               ieee80211_stop_queues(ah->hw);
        } else
                ah->ah_cal_mask |= AR5K_CALIBRATION_SHORT;
 
@@ -2353,10 +2346,9 @@ ath5k_calibrate_work(struct work_struct *work)
                                ah->curchan->center_freq));
 
        /* Clear calibration flags */
-       if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) {
-               ieee80211_wake_queues(ah->hw);
+       if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL)
                ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL;
-       else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)
+       else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)
                ah->ah_cal_mask &= ~AR5K_CALIBRATION_SHORT;
 }
 
index af4c7ecb4b303a6595413339de28473677ac135a..5c5329955414966247d5f44dcb8d7760e2d474f1 100644 (file)
@@ -134,6 +134,8 @@ ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
                        ah->num_ap_vifs++;
                else if (avf->opmode == NL80211_IFTYPE_ADHOC)
                        ah->num_adhoc_vifs++;
+               else if (avf->opmode == NL80211_IFTYPE_MESH_POINT)
+                       ah->num_mesh_vifs++;
        }
 
        /* Any MAC address is fine, all others are included through the
@@ -175,6 +177,8 @@ ath5k_remove_interface(struct ieee80211_hw *hw,
                ah->num_ap_vifs--;
        else if (avf->opmode == NL80211_IFTYPE_ADHOC)
                ah->num_adhoc_vifs--;
+       else if (avf->opmode == NL80211_IFTYPE_MESH_POINT)
+               ah->num_mesh_vifs--;
 
        ath5k_update_bssid_mask_and_opmode(ah, NULL);
        mutex_unlock(&ah->lock);
index e1f8613426a921f05fe294ba1409baaec7e2b954..3a2845489a1b67cb7df9c4750785a690639d9bdd 100644 (file)
@@ -1871,31 +1871,15 @@ ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
                ret = 0;
        }
 
-       /* On full calibration do an AGC calibration and
-        * request a PAPD probe for gainf calibration if
-        * needed */
-       if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) {
-
-               AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_AGCCTL,
-                                       AR5K_PHY_AGCCTL_CAL);
-
-               ret = ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL,
-                       AR5K_PHY_AGCCTL_CAL | AR5K_PHY_AGCCTL_NF,
-                       0, false);
-               if (ret) {
-                       ATH5K_ERR(ah,
-                               "gain calibration timeout (%uMHz)\n",
-                               channel->center_freq);
-               }
-
-               if ((ah->ah_radio == AR5K_RF5111 ||
-                       ah->ah_radio == AR5K_RF5112)
-                       && (channel->hw_value != AR5K_MODE_11B))
-                       ath5k_hw_request_rfgain_probe(ah);
-       }
-
-       /* Update noise floor
-        * XXX: Only do this after AGC calibration */
+       /* On full calibration request a PAPD probe for
+        * gainf calibration if needed */
+       if ((ah->ah_cal_mask & AR5K_CALIBRATION_FULL) &&
+           (ah->ah_radio == AR5K_RF5111 ||
+            ah->ah_radio == AR5K_RF5112) &&
+           channel->hw_value != AR5K_MODE_11B)
+               ath5k_hw_request_rfgain_probe(ah);
+
+       /* Update noise floor */
        if (!(ah->ah_cal_mask & AR5K_CALIBRATION_NF))
                ath5k_hw_update_noise_floor(ah);
 
index 18fa9aa8af92464a4888f37b68d9904293ed2573..97abf4699b41270883b80357185652253237c59c 100644 (file)
@@ -556,7 +556,8 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len,
                   dlen, freq, vif->probe_req_report);
 
        if (vif->probe_req_report || vif->nw_type == AP_NETWORK)
-               cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC);
+               cfg80211_rx_mgmt(vif->ndev, freq, 0,
+                                ev->data, dlen, GFP_ATOMIC);
 
        return 0;
 }
@@ -595,7 +596,8 @@ static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len,
                return -EINVAL;
        }
        ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
-       cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC);
+       cfg80211_rx_mgmt(vif->ndev, freq, 0,
+                        ev->data, dlen, GFP_ATOMIC);
 
        return 0;
 }
index 595a272aa96e47b7fa55119df870a6958df8170e..e507e78398f3dc76b3678fb8d16a8b7282735c14 100644 (file)
@@ -81,6 +81,14 @@ config ATH9K_DFS_CERTIFIED
          developed. At this point enabling this option won't do anything
          except increase code size.
 
+config ATH9K_MAC_DEBUG
+       bool "Atheros MAC statistics"
+       depends on ATH9K_DEBUGFS
+       default y
+       ---help---
+         This option enables collection of statistics for Rx/Tx status
+         data and some other MAC related statistics
+
 config ATH9K_RATE_CONTROL
        bool "Atheros ath9k rate control"
        depends on ATH9K
index f901a17f76baf6da3a2ad3e55880a8aa25df35e8..86a891f93fc9dc70939088e70080af874343f4b4 100644 (file)
@@ -489,8 +489,6 @@ static int ar5008_hw_rf_alloc_ext_banks(struct ath_hw *ah)
        ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
        ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
        ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
-       ATH_ALLOC_BANK(ah->addac5416_21,
-                      ah->iniAddac.ia_rows * ah->iniAddac.ia_columns);
        ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
 
        return 0;
@@ -519,7 +517,6 @@ static void ar5008_hw_rf_free_ext_banks(struct ath_hw *ah)
        ATH_FREE_BANK(ah->analogBank6Data);
        ATH_FREE_BANK(ah->analogBank6TPCData);
        ATH_FREE_BANK(ah->analogBank7Data);
-       ATH_FREE_BANK(ah->addac5416_21);
        ATH_FREE_BANK(ah->bank6Temp);
 
 #undef ATH_FREE_BANK
@@ -805,27 +802,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
        if (ah->eep_ops->set_addac)
                ah->eep_ops->set_addac(ah, chan);
 
-       if (AR_SREV_5416_22_OR_LATER(ah)) {
-               REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
-       } else {
-               struct ar5416IniArray temp;
-               u32 addacSize =
-                       sizeof(u32) * ah->iniAddac.ia_rows *
-                       ah->iniAddac.ia_columns;
-
-               /* For AR5416 2.0/2.1 */
-               memcpy(ah->addac5416_21,
-                      ah->iniAddac.ia_array, addacSize);
-
-               /* override CLKDRV value at [row, column] = [31, 1] */
-               (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0;
-
-               temp.ia_array = ah->addac5416_21;
-               temp.ia_columns = ah->iniAddac.ia_columns;
-               temp.ia_rows = ah->iniAddac.ia_rows;
-               REG_WRITE_ARRAY(&temp, 1, regWrites);
-       }
-
+       REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
        REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC);
 
        ENABLE_REGWRITE_BUFFER(ah);
index d48f5fe8af7faac760b332a713728fc9c1a3eec6..e3f268900763a02374440717ba4490c2ebdca7c1 100644 (file)
@@ -141,6 +141,25 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
                        INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100,
                                       ARRAY_SIZE(ar5416Bank6TPC_9100), 3);
        }
+
+       /* iniAddac needs to be modified for these chips */
+       if (AR_SREV_9160(ah) || !AR_SREV_5416_22_OR_LATER(ah)) {
+               struct ar5416IniArray *addac = &ah->iniAddac;
+               u32 size = sizeof(u32) * addac->ia_rows * addac->ia_columns;
+               u32 *data;
+
+               data = kmalloc(size, GFP_KERNEL);
+               if (!data)
+                       return;
+
+               memcpy(data, addac->ia_array, size);
+               addac->ia_array = data;
+
+               if (!AR_SREV_5416_22_OR_LATER(ah)) {
+                       /* override CLKDRV value */
+                       INI_RA(addac, 31,1) = 0;
+               }
+       }
 }
 
 /* Support for Japan ch.14 (2484) spread */
index 51687e3f63d81c8971a85235369ac9aa5e225a1c..a66a13b768487746b96c1ebdca96c87df89681f4 100644 (file)
@@ -326,7 +326,6 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
 static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
                                 struct ath_tx_status *ts)
 {
-       struct ar9003_txc *txc = (struct ar9003_txc *) ds;
        struct ar9003_txs *ads;
        u32 status;
 
@@ -336,11 +335,7 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
        if ((status & AR_TxDone) == 0)
                return -EINPROGRESS;
 
-       ts->qid = MS(ads->ds_info, AR_TxQcuNum);
-       if (!txc || (MS(txc->info, AR_TxQcuNum) == ts->qid))
-               ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
-       else
-               return -ENOENT;
+       ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size;
 
        if ((MS(ads->ds_info, AR_DescId) != ATHEROS_VENDOR_ID) ||
            (MS(ads->ds_info, AR_TxRxDesc) != 1)) {
@@ -354,6 +349,7 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
        ts->ts_seqnum = MS(status, AR_SeqNum);
        ts->tid = MS(status, AR_TxTid);
 
+       ts->qid = MS(ads->ds_info, AR_TxQcuNum);
        ts->desc_id = MS(ads->status1, AR_TxDescId);
        ts->ts_tstamp = ads->status4;
        ts->ts_status = 0;
@@ -440,20 +436,14 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
        struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr;
        unsigned int phyerr;
 
-       /* TODO: byte swap on big endian for ar9300_10 */
-
-       if (!rxs) {
-               if ((rxsp->status11 & AR_RxDone) == 0)
-                       return -EINPROGRESS;
-
-               if (MS(rxsp->ds_info, AR_DescId) != 0x168c)
-                       return -EINVAL;
+       if ((rxsp->status11 & AR_RxDone) == 0)
+               return -EINPROGRESS;
 
-               if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0)
-                       return -EINPROGRESS;
+       if (MS(rxsp->ds_info, AR_DescId) != 0x168c)
+               return -EINVAL;
 
-               return 0;
-       }
+       if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0)
+               return -EINPROGRESS;
 
        rxs->rs_status = 0;
        rxs->rs_flags =  0;
@@ -510,7 +500,11 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
                 */
                if (rxsp->status11 & AR_CRCErr)
                        rxs->rs_status |= ATH9K_RXERR_CRC;
-               else if (rxsp->status11 & AR_PHYErr) {
+               else if (rxsp->status11 & AR_DecryptCRCErr)
+                       rxs->rs_status |= ATH9K_RXERR_DECRYPT;
+               else if (rxsp->status11 & AR_MichaelErr)
+                       rxs->rs_status |= ATH9K_RXERR_MIC;
+               if (rxsp->status11 & AR_PHYErr) {
                        phyerr = MS(rxsp->status11, AR_PHYErrCode);
                        /*
                         * If we reach a point here where AR_PostDelimCRCErr is
@@ -532,11 +526,7 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
                                rxs->rs_status |= ATH9K_RXERR_PHY;
                                rxs->rs_phyerr = phyerr;
                        }
-
-               } else if (rxsp->status11 & AR_DecryptCRCErr)
-                       rxs->rs_status |= ATH9K_RXERR_DECRYPT;
-               else if (rxsp->status11 & AR_MichaelErr)
-                       rxs->rs_status |= ATH9K_RXERR_MIC;
+               };
        }
 
        if (rxsp->status11 & AR_KeyMiss)
index c2ccba676ecabc4b3f7976f2551a925d25a4837e..3d8e51cd5d8f1bbd9227fbf394433d3742193753 100644 (file)
@@ -299,7 +299,6 @@ struct ath_tx {
 
 struct ath_rx_edma {
        struct sk_buff_head rx_fifo;
-       struct sk_buff_head rx_buffers;
        u32 rx_fifo_hwsize;
 };
 
index b8967e482e6ef952ea97317bac7d4f34322d4e7e..43882f9e25c46d02b9b70180e1258d15f35e5255 100644 (file)
@@ -91,7 +91,7 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
        info.txpower = MAX_RATE_POWER;
        info.keyix = ATH9K_TXKEYIX_INVALID;
        info.keytype = ATH9K_KEY_TYPE_CLEAR;
-       info.flags = ATH9K_TXDESC_NOACK;
+       info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_INTREQ;
 
        info.buf_addr[0] = bf->bf_buf_addr;
        info.buf_len[0] = roundup(skb->len, 4);
@@ -355,7 +355,6 @@ void ath_beacon_tasklet(unsigned long data)
        struct ath_common *common = ath9k_hw_common(ah);
        struct ath_buf *bf = NULL;
        struct ieee80211_vif *vif;
-       struct ath_tx_status ts;
        bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
        int slot;
        u32 bfaddr, bc = 0;
@@ -462,11 +461,6 @@ void ath_beacon_tasklet(unsigned long data)
                        ath9k_hw_txstart(ah, sc->beacon.beaconq);
 
                sc->beacon.ast_be_xmit += bc;     /* XXX per-vif? */
-               if (edma) {
-                       spin_lock_bh(&sc->sc_pcu_lock);
-                       ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts);
-                       spin_unlock_bh(&sc->sc_pcu_lock);
-               }
        }
 }
 
index 228c18189a3a38979e8eb01716643b6aa64126c0..c2edf688da49497159a8962bcbb46a723e4e80c9 100644 (file)
@@ -818,6 +818,7 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
        if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
                TX_STAT_INC(qnum, delim_underrun);
 
+#ifdef CONFIG_ATH9K_MAC_DEBUG
        spin_lock(&sc->debug.samp_lock);
        TX_SAMP_DBG(jiffies) = jiffies;
        TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
@@ -844,6 +845,7 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
 
        sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
        spin_unlock(&sc->debug.samp_lock);
+#endif
 
 #undef TX_SAMP_DBG
 }
@@ -941,27 +943,6 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
        PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
        PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
 
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "RSSI-CTL0",
-                       sc->debug.stats.rxstats.rs_rssi_ctl0);
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "RSSI-CTL1",
-                       sc->debug.stats.rxstats.rs_rssi_ctl1);
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "RSSI-CTL2",
-                       sc->debug.stats.rxstats.rs_rssi_ctl2);
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "RSSI-EXT0",
-                       sc->debug.stats.rxstats.rs_rssi_ext0);
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "RSSI-EXT1",
-                       sc->debug.stats.rxstats.rs_rssi_ext1);
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "RSSI-EXT2",
-                       sc->debug.stats.rxstats.rs_rssi_ext2);
-       len += snprintf(buf + len, size - len,
-                       "%22s : %10d\n", "Rx Antenna",
-                       sc->debug.stats.rxstats.rs_antenna);
        len += snprintf(buf + len, size - len,
                        "%22s : %10u\n", "RX-Pkts-All",
                        sc->debug.stats.rxstats.rx_pkts_all);
@@ -1009,16 +990,7 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
                        RX_PHY_ERR_INC(rs->rs_phyerr);
        }
 
-       sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
-       sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
-       sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
-
-       sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
-       sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
-       sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
-
-       sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
-
+#ifdef CONFIG_ATH9K_MAC_DEBUG
        spin_lock(&sc->debug.samp_lock);
        RX_SAMP_DBG(jiffies) = jiffies;
        RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
@@ -1035,6 +1007,8 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
        sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
        spin_unlock(&sc->debug.samp_lock);
 
+#endif
+
 #undef RX_STAT_INC
 #undef RX_PHY_ERR_INC
 #undef RX_SAMP_DBG
@@ -1278,6 +1252,8 @@ static const struct file_operations fops_modal_eeprom = {
        .llseek = default_llseek,
 };
 
+#ifdef CONFIG_ATH9K_MAC_DEBUG
+
 void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
 {
 #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
@@ -1551,6 +1527,7 @@ static const struct file_operations fops_samps = {
        .llseek = default_llseek,
 };
 
+#endif
 
 int ath9k_init_debug(struct ath_hw *ah)
 {
@@ -1604,8 +1581,10 @@ int ath9k_init_debug(struct ath_hw *ah)
                            &fops_base_eeprom);
        debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
                            &fops_modal_eeprom);
+#ifdef CONFIG_ATH9K_MAC_DEBUG
        debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
                            &fops_samps);
+#endif
 
        debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
                           sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
index 776a24ada600fc377940851a4abbe7e3fa8a2001..64fcfad467bf44a38e325d2aed6a4bbee4adfc37 100644 (file)
@@ -165,13 +165,6 @@ struct ath_rx_stats {
        u32 post_delim_crc_err;
        u32 decrypt_busy_err;
        u32 phy_err_stats[ATH9K_PHYERR_MAX];
-       int8_t rs_rssi_ctl0;
-       int8_t rs_rssi_ctl1;
-       int8_t rs_rssi_ctl2;
-       int8_t rs_rssi_ext0;
-       int8_t rs_rssi_ext1;
-       int8_t rs_rssi_ext2;
-       u8 rs_antenna;
 };
 
 enum ath_reset_type {
@@ -235,16 +228,17 @@ struct ath9k_debug {
        struct dentry *debugfs_phy;
        u32 regidx;
        struct ath_stats stats;
+#ifdef CONFIG_ATH9K_MAC_DEBUG
        spinlock_t samp_lock;
        struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
        u8 sampidx;
        u8 tsidx;
        u8 rsidx;
+#endif
 };
 
 int ath9k_init_debug(struct ath_hw *ah);
 
-void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
                       struct ath_tx_status *ts, struct ath_txq *txq,
@@ -258,10 +252,6 @@ static inline int ath9k_init_debug(struct ath_hw *ah)
        return 0;
 }
 
-static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
-{
-}
-
 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
                                            enum ath9k_int status)
 {
@@ -282,4 +272,17 @@ static inline void ath_debug_stat_rx(struct ath_softc *sc,
 
 #endif /* CONFIG_ATH9K_DEBUGFS */
 
+#ifdef CONFIG_ATH9K_MAC_DEBUG
+
+void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
+
+#else
+
+static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
+{
+}
+
+#endif
+
+
 #endif /* DEBUG_H */
index 8c840cad3ac29d540717db15eb6b154c20da98cb..d582cf73098fec9b06595babeaa2036c3ad6992b 100644 (file)
@@ -1386,10 +1386,16 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
 static bool ath9k_hw_chip_reset(struct ath_hw *ah,
                                struct ath9k_channel *chan)
 {
-       if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) {
-               if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON))
-                       return false;
-       } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
+       int reset_type = ATH9K_RESET_WARM;
+
+       if (AR_SREV_9280(ah)) {
+               if (ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
+                       reset_type = ATH9K_RESET_POWER_ON;
+               else
+                       reset_type = ATH9K_RESET_COLD;
+       }
+
+       if (!ath9k_hw_set_reset_reg(ah, reset_type))
                return false;
 
        if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
index c785303eb3ad7de438f0be9603bcb2251a9d99c5..1707137e0a30a20fd117ad2826daf3636c39c62b 100644 (file)
@@ -781,7 +781,6 @@ struct ath_hw {
        u32 *analogBank6Data;
        u32 *analogBank6TPCData;
        u32 *analogBank7Data;
-       u32 *addac5416_21;
        u32 *bank6Temp;
 
        u8 txpower_limit;
index d8b05961f7e35e22dfea73e480f0e195e48e40c1..944e9b518f1935ba61111d1ca1d6c6aa8eb89b24 100644 (file)
@@ -555,8 +555,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
        mutex_init(&sc->mutex);
 #ifdef CONFIG_ATH9K_DEBUGFS
        spin_lock_init(&sc->nodes_lock);
-       spin_lock_init(&sc->debug.samp_lock);
        INIT_LIST_HEAD(&sc->nodes);
+#endif
+#ifdef CONFIG_ATH9K_MAC_DEBUG
+       spin_lock_init(&sc->debug.samp_lock);
 #endif
        tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
        tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
index e196aba77acf568387d7a4b2b5852e316d801e4f..5f4ae6c9a93c69f4605bf7af447bc29e1c8cb583 100644 (file)
@@ -745,7 +745,11 @@ int ath9k_hw_beaconq_setup(struct ath_hw *ah)
        qi.tqi_aifs = 1;
        qi.tqi_cwmin = 0;
        qi.tqi_cwmax = 0;
-       /* NB: don't enable any interrupts */
+
+       if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
+               qi.tqi_qflags = TXQ_FLAG_TXOKINT_ENABLE |
+                               TXQ_FLAG_TXERRINT_ENABLE;
+
        return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
 }
 EXPORT_SYMBOL(ath9k_hw_beaconq_setup);
index 02e95c8e7465539e0617a9bb0fb5e072cf377014..cc2535c38beddd6a9adb2db9be3a2fe8683ec51c 100644 (file)
@@ -2300,6 +2300,7 @@ static int ath9k_tx_last_beacon(struct ieee80211_hw *hw)
        struct ath_vif *avp;
        struct ath_buf *bf;
        struct ath_tx_status ts;
+       bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
        int status;
 
        vif = sc->beacon.bslot[0];
@@ -2310,7 +2311,7 @@ static int ath9k_tx_last_beacon(struct ieee80211_hw *hw)
        if (!avp->is_bslot_active)
                return 0;
 
-       if (!sc->beacon.tx_processed) {
+       if (!sc->beacon.tx_processed && !edma) {
                tasklet_disable(&sc->bcon_tasklet);
 
                bf = avp->av_bcbuf;
index b8c6c38cbb98ca1c570b989590e2ad4ee366fb22..6407af22f7b90b216752198703574670f48726c9 100644 (file)
@@ -1226,7 +1226,7 @@ static void ath_rc_init(struct ath_softc *sc,
        ath_rc_init_valid_rate_idx(ath_rc_priv);
 
        for (i = 0; i < WLAN_RC_PHY_MAX; i++) {
-               for (j = 0; j < MAX_TX_RATE_PHY; j++)
+               for (j = 0; j < RATE_TABLE_SIZE; j++)
                        ath_rc_priv->valid_phy_rateidx[i][j] = 0;
                ath_rc_priv->valid_phy_ratecnt[i] = 0;
        }
index b7a4bcd3eec70f02c62f11e0a23ea7ff843813f2..75f8e9b06b2859d2866f16653c3a22913ee6baf5 100644 (file)
@@ -25,8 +25,6 @@ struct ath_softc;
 
 #define ATH_RATE_MAX     30
 #define RATE_TABLE_SIZE  72
-#define MAX_TX_RATE_PHY  48
-
 
 #define RC_INVALID     0x0000
 #define RC_LEGACY      0x0001
index 7e1a91af149751b13a53ee9d6dab5c16fcd2f01f..1b1b279c304aa5e3794c8e13f8ac2fec4b3b2e37 100644 (file)
@@ -169,22 +169,17 @@ static void ath_rx_addbuffer_edma(struct ath_softc *sc,
                                  enum ath9k_rx_qtype qtype, int size)
 {
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-       u32 nbuf = 0;
+       struct ath_buf *bf, *tbf;
 
        if (list_empty(&sc->rx.rxbuf)) {
                ath_dbg(common, QUEUE, "No free rx buf available\n");
                return;
        }
 
-       while (!list_empty(&sc->rx.rxbuf)) {
-               nbuf++;
-
+       list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list)
                if (!ath_rx_edma_buf_link(sc, qtype))
                        break;
 
-               if (nbuf >= size)
-                       break;
-       }
 }
 
 static void ath_rx_remove_buffer(struct ath_softc *sc,
@@ -232,7 +227,6 @@ static void ath_rx_edma_cleanup(struct ath_softc *sc)
 static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size)
 {
        skb_queue_head_init(&rx_edma->rx_fifo);
-       skb_queue_head_init(&rx_edma->rx_buffers);
        rx_edma->rx_fifo_hwsize = size;
 }
 
@@ -658,7 +652,9 @@ static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb, bool mybeacon)
 }
 
 static bool ath_edma_get_buffers(struct ath_softc *sc,
-                                enum ath9k_rx_qtype qtype)
+                                enum ath9k_rx_qtype qtype,
+                                struct ath_rx_status *rs,
+                                struct ath_buf **dest)
 {
        struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
        struct ath_hw *ah = sc->sc_ah;
@@ -677,7 +673,7 @@ static bool ath_edma_get_buffers(struct ath_softc *sc,
        dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
                                common->rx_bufsize, DMA_FROM_DEVICE);
 
-       ret = ath9k_hw_process_rxdesc_edma(ah, NULL, skb->data);
+       ret = ath9k_hw_process_rxdesc_edma(ah, rs, skb->data);
        if (ret == -EINPROGRESS) {
                /*let device gain the buffer again*/
                dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
@@ -690,20 +686,21 @@ static bool ath_edma_get_buffers(struct ath_softc *sc,
                /* corrupt descriptor, skip this one and the following one */
                list_add_tail(&bf->list, &sc->rx.rxbuf);
                ath_rx_edma_buf_link(sc, qtype);
-               skb = skb_peek(&rx_edma->rx_fifo);
-               if (!skb)
-                       return true;
 
-               bf = SKB_CB_ATHBUF(skb);
-               BUG_ON(!bf);
+               skb = skb_peek(&rx_edma->rx_fifo);
+               if (skb) {
+                       bf = SKB_CB_ATHBUF(skb);
+                       BUG_ON(!bf);
 
-               __skb_unlink(skb, &rx_edma->rx_fifo);
-               list_add_tail(&bf->list, &sc->rx.rxbuf);
-               ath_rx_edma_buf_link(sc, qtype);
-               return true;
+                       __skb_unlink(skb, &rx_edma->rx_fifo);
+                       list_add_tail(&bf->list, &sc->rx.rxbuf);
+                       ath_rx_edma_buf_link(sc, qtype);
+               } else {
+                       bf = NULL;
+               }
        }
-       skb_queue_tail(&rx_edma->rx_buffers, skb);
 
+       *dest = bf;
        return true;
 }
 
@@ -711,18 +708,15 @@ static struct ath_buf *ath_edma_get_next_rx_buf(struct ath_softc *sc,
                                                struct ath_rx_status *rs,
                                                enum ath9k_rx_qtype qtype)
 {
-       struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
-       struct sk_buff *skb;
-       struct ath_buf *bf;
+       struct ath_buf *bf = NULL;
 
-       while (ath_edma_get_buffers(sc, qtype));
-       skb = __skb_dequeue(&rx_edma->rx_buffers);
-       if (!skb)
-               return NULL;
+       while (ath_edma_get_buffers(sc, qtype, rs, &bf)) {
+               if (!bf)
+                       continue;
 
-       bf = SKB_CB_ATHBUF(skb);
-       ath9k_hw_process_rxdesc_edma(sc->sc_ah, rs, skb->data);
-       return bf;
+               return bf;
+       }
+       return NULL;
 }
 
 static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
@@ -954,6 +948,7 @@ static void ath9k_process_rssi(struct ath_common *common,
        struct ath_softc *sc = hw->priv;
        struct ath_hw *ah = common->ah;
        int last_rssi;
+       int rssi = rx_stats->rs_rssi;
 
        if (!rx_stats->is_mybeacon ||
            ((ah->opmode != NL80211_IFTYPE_STATION) &&
@@ -965,13 +960,12 @@ static void ath9k_process_rssi(struct ath_common *common,
 
        last_rssi = sc->last_rssi;
        if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
-               rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
-                                             ATH_RSSI_EP_MULTIPLIER);
-       if (rx_stats->rs_rssi < 0)
-               rx_stats->rs_rssi = 0;
+               rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
+       if (rssi < 0)
+               rssi = 0;
 
        /* Update Beacon RSSI, this is used by ANI. */
-       ah->stats.avgbrssi = rx_stats->rs_rssi;
+       ah->stats.avgbrssi = rssi;
 }
 
 /*
@@ -1011,6 +1005,8 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common,
        rx_status->signal = ah->noise + rx_stats->rs_rssi;
        rx_status->antenna = rx_stats->rs_antenna;
        rx_status->flag |= RX_FLAG_MACTIME_MPDU;
+       if (rx_stats->rs_moreaggr)
+               rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
 
        return 0;
 }
index 5dd27d2712fcceaf192e09f7e6a0417872e5cf08..9f785015a7dcef6acbe75eb74e044a7dcfb463ad 100644 (file)
@@ -2296,9 +2296,12 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
                        break;
                }
 
-               /* Skip beacon completions */
-               if (ts.qid == sc->beacon.beaconq)
+               /* Process beacon completions separately */
+               if (ts.qid == sc->beacon.beaconq) {
+                       sc->beacon.tx_processed = true;
+                       sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
                        continue;
+               }
 
                txq = &sc->tx.txq[ts.qid];
 
index 771e1a9294c54e1d70e1183e2cdbe00fa2595dc7..aed305177af6a92ba784a8014c66bee117f5bea4 100644 (file)
@@ -1236,6 +1236,7 @@ static bool carl9170_tx_ps_drop(struct ar9170 *ar, struct sk_buff *skb)
 {
        struct ieee80211_sta *sta;
        struct carl9170_sta_info *sta_info;
+       struct ieee80211_tx_info *tx_info;
 
        rcu_read_lock();
        sta = __carl9170_get_tx_sta(ar, skb);
@@ -1243,16 +1244,18 @@ static bool carl9170_tx_ps_drop(struct ar9170 *ar, struct sk_buff *skb)
                goto out_rcu;
 
        sta_info = (void *) sta->drv_priv;
-       if (unlikely(sta_info->sleeping)) {
-               struct ieee80211_tx_info *tx_info;
+       tx_info = IEEE80211_SKB_CB(skb);
 
+       if (unlikely(sta_info->sleeping) &&
+           !(tx_info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
+                               IEEE80211_TX_CTL_CLEAR_PS_FILT))) {
                rcu_read_unlock();
 
-               tx_info = IEEE80211_SKB_CB(skb);
                if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
                        atomic_dec(&ar->tx_ampdu_upload);
 
                tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
+               carl9170_release_dev_space(ar, skb);
                carl9170_tx_status(ar, skb, false);
                return true;
        }
index 5189cf38123a8a30af8ec50d9157e5f51869f44d..1d633f3b3274f15583f033ba2faea7ae3d203d5f 100644 (file)
@@ -2706,6 +2706,8 @@ static int b43_gpio_init(struct b43_wldev *dev)
                mask |= 0x0060;
                set |= 0x0060;
        }
+       if (dev->dev->chip_id == 0x5354)
+               set &= 0xff02;
        if (0 /* FIXME: conditional unknown */ ) {
                b43_write16(dev, B43_MMIO_GPIO_MASK,
                            b43_read16(dev, B43_MMIO_GPIO_MASK)
index 96faaef3661b075fc2a3b52f8c08a7d91b708d20..950334197f403e12daaaf274b31bb78c9a792cee 100644 (file)
@@ -1860,7 +1860,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
         * which accounts for the factor of 4 */
 #define REG_MAX_PWR 20
        max_pwr = min(REG_MAX_PWR * 4
-                     - dev->dev->bus->sprom.antenna_gain.ghz24.a0
+                     - dev->dev->bus->sprom.antenna_gain.a0
                      - 0x6, max_pwr);
 
        /* find the desired power in Q5.2 - power_level is in dBm
index 83ca3cc2cccb72f2017da288261e34c23600d76e..4688904908ec464b3b9895504e8566eb61d6c5e7 100644 (file)
@@ -604,7 +604,7 @@ void brcmf_sdio_exit(void)
        sdio_unregister_driver(&brcmf_sdmmc_driver);
 }
 
-int brcmf_sdio_init(void)
+void brcmf_sdio_init(void)
 {
        int ret;
 
@@ -614,6 +614,4 @@ int brcmf_sdio_init(void)
 
        if (ret)
                brcmf_dbg(ERROR, "sdio_register_driver failed: %d\n", ret);
-
-       return ret;
 }
index b7671b30692ff0e367c5708db8de8d5463aa4f60..366916494be402a90ffdc5654cc286f075bdc795 100644 (file)
@@ -108,11 +108,11 @@ extern int brcmf_add_if(struct device *dev, int ifidx,
 
 #ifdef CONFIG_BRCMFMAC_SDIO
 extern void brcmf_sdio_exit(void);
-extern int brcmf_sdio_init(void);
+extern void brcmf_sdio_init(void);
 #endif
 #ifdef CONFIG_BRCMFMAC_USB
 extern void brcmf_usb_exit(void);
-extern int brcmf_usb_init(void);
+extern void brcmf_usb_init(void);
 #endif
 
 #endif                         /* _BRCMF_BUS_H_ */
index c4da05817443b6532c6885ac699569262a75433c..2a1e5ae0c4024ff560b40dade098c4599894feb5 100644 (file)
@@ -1181,27 +1181,29 @@ exit:
 }
 #endif                         /* DEBUG */
 
-static int __init brcmfmac_init(void)
+static void brcmf_driver_init(struct work_struct *work)
 {
-       int ret = 0;
-
 #ifdef CONFIG_BRCMFMAC_SDIO
-       ret = brcmf_sdio_init();
-       if (ret)
-               goto fail;
+       brcmf_sdio_init();
 #endif
 #ifdef CONFIG_BRCMFMAC_USB
-       ret = brcmf_usb_init();
-       if (ret)
-               goto fail;
+       brcmf_usb_init();
 #endif
+}
+static DECLARE_WORK(brcmf_driver_work, brcmf_driver_init);
 
-fail:
-       return ret;
+static int __init brcmfmac_module_init(void)
+{
+       if (!schedule_work(&brcmf_driver_work))
+               return -EBUSY;
+
+       return 0;
 }
 
-static void __exit brcmfmac_exit(void)
+static void __exit brcmfmac_module_exit(void)
 {
+       cancel_work_sync(&brcmf_driver_work);
+
 #ifdef CONFIG_BRCMFMAC_SDIO
        brcmf_sdio_exit();
 #endif
@@ -1210,5 +1212,5 @@ static void __exit brcmfmac_exit(void)
 #endif
 }
 
-module_init(brcmfmac_init);
-module_exit(brcmfmac_exit);
+module_init(brcmfmac_module_init);
+module_exit(brcmfmac_module_exit);
index d4a9e8e7deb3c31659b64213c4469c4f6a2906d8..82364223e81785e0023b0d56136dd2b170cac4eb 100644 (file)
@@ -514,9 +514,9 @@ static void brcmf_usb_tx_complete(struct urb *urb)
 
        brcmf_usb_del_fromq(devinfo, req);
        if (urb->status == 0)
-               devinfo->bus_pub.stats.tx_packets++;
+               devinfo->bus_pub.bus->dstats.tx_packets++;
        else
-               devinfo->bus_pub.stats.tx_errors++;
+               devinfo->bus_pub.bus->dstats.tx_errors++;
 
        dev_kfree_skb(req->skb);
        req->skb = NULL;
@@ -536,9 +536,9 @@ static void brcmf_usb_rx_complete(struct urb *urb)
        req->skb = NULL;
 
        if (urb->status == 0) {
-               devinfo->bus_pub.stats.rx_packets++;
+               devinfo->bus_pub.bus->dstats.rx_packets++;
        } else {
-               devinfo->bus_pub.stats.rx_errors++;
+               devinfo->bus_pub.bus->dstats.rx_errors++;
                dev_kfree_skb(skb);
                brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req);
                return;
@@ -712,9 +712,6 @@ static int brcmf_usb_up(struct device *dev)
        struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
        u16 ifnum;
 
-       if (devinfo == NULL)
-               return -EINVAL;
-
        if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP)
                return 0;
 
@@ -900,8 +897,8 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo)
                        sizeof(struct bootrom_id_le));
                return false;
        } else {
-               devinfo->bus_pub.attrib.devid = chipid;
-               devinfo->bus_pub.attrib.chiprev = chiprev;
+               devinfo->bus_pub.devid = chipid;
+               devinfo->bus_pub.chiprev = chiprev;
        }
        return true;
 }
@@ -1067,7 +1064,7 @@ static int brcmf_usb_dlstart(struct brcmf_usbdev_info *devinfo, u8 *fw, int len)
        if (devinfo == NULL)
                return -EINVAL;
 
-       if (devinfo->bus_pub.attrib.devid == 0xDEAD)
+       if (devinfo->bus_pub.devid == 0xDEAD)
                return -EINVAL;
 
        err = brcmf_usb_dl_writeimage(devinfo, fw, len);
@@ -1088,7 +1085,7 @@ static int brcmf_usb_dlrun(struct brcmf_usbdev_info *devinfo)
        if (!devinfo)
                return -EINVAL;
 
-       if (devinfo->bus_pub.attrib.devid == 0xDEAD)
+       if (devinfo->bus_pub.devid == 0xDEAD)
                return -EINVAL;
 
        /* Check we are runnable */
@@ -1127,18 +1124,19 @@ static bool brcmf_usb_chip_support(int chipid, int chiprev)
 static int
 brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo)
 {
-       struct brcmf_usb_attrib *attr;
+       int devid, chiprev;
        int err;
 
        brcmf_dbg(TRACE, "enter\n");
        if (devinfo == NULL)
                return -ENODEV;
 
-       attr = &devinfo->bus_pub.attrib;
+       devid = devinfo->bus_pub.devid;
+       chiprev = devinfo->bus_pub.chiprev;
 
-       if (!brcmf_usb_chip_support(attr->devid, attr->chiprev)) {
+       if (!brcmf_usb_chip_support(devid, chiprev)) {
                brcmf_dbg(ERROR, "unsupported chip %d rev %d\n",
-                         attr->devid, attr->chiprev);
+                         devid, chiprev);
                return -EINVAL;
        }
 
@@ -1617,7 +1615,7 @@ void brcmf_usb_exit(void)
        g_image.len = 0;
 }
 
-int brcmf_usb_init(void)
+void brcmf_usb_init(void)
 {
-       return usb_register(&brcmf_usbdrvr);
+       usb_register(&brcmf_usbdrvr);
 }
index b31da7b83ff7a2a65c1772c058b80f50ca0dc58c..acfa5e89872fb8c8103ebb626beef5c0ba0064a2 100644 (file)
@@ -33,36 +33,12 @@ enum brcmf_usb_pnp_state {
 };
 
 struct brcmf_stats {
-       u32 tx_errors;
-       u32 tx_packets;
-       u32 tx_multicast;
        u32 tx_ctlpkts;
        u32 tx_ctlerrs;
-       u32 tx_dropped;
-       u32 tx_flushed;
-       u32 rx_errors;
-       u32 rx_packets;
-       u32 rx_multicast;
        u32 rx_ctlpkts;
        u32 rx_ctlerrs;
-       u32 rx_dropped;
-       u32 rx_flushed;
-
-};
-
-struct brcmf_usb_attrib {
-       int bustype;
-       int vid;
-       int pid;
-       int devid;
-       int chiprev; /* chip revsion number */
-       int mtu;
-       int nchan; /* Data Channels */
-       int has_2nd_bulk_in_ep;
 };
 
-struct brcmf_usbdev_info;
-
 struct brcmf_usbdev {
        struct brcmf_bus *bus;
        struct brcmf_usbdev_info *devinfo;
@@ -70,7 +46,8 @@ struct brcmf_usbdev {
        struct brcmf_stats stats;
        int ntxq, nrxq, rxsize;
        u32 bus_mtu;
-       struct brcmf_usb_attrib attrib;
+       int devid;
+       int chiprev; /* chip revsion number */
 };
 
 /* IO Request Block (IRB) */
index c1ce831b9bf47f73c9ce9fac2fa394ede5c4c017..95b5902bc4b3a3241f68cde20434b8592ba71ebc 100644 (file)
@@ -959,14 +959,13 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                if (supr_status) {
                        update_rate = false;
                        if (supr_status == TX_STATUS_SUPR_BADCH) {
-                               wiphy_err(wiphy, "%s: Pkt tx suppressed, "
-                                         "illegal channel possibly %d\n",
+                               wiphy_err(wiphy,
+                                         "%s: Pkt tx suppressed, illegal channel possibly %d\n",
                                          __func__, CHSPEC_CHANNEL(
                                          wlc->default_bss->chanspec));
                        } else {
                                if (supr_status != TX_STATUS_SUPR_FRAG)
-                                       wiphy_err(wiphy, "%s:"
-                                                 "supr_status 0x%x\n",
+                                       wiphy_err(wiphy, "%s: supr_status 0x%x\n",
                                                  __func__, supr_status);
                        }
                        /* no need to retry for badch; will fail again */
@@ -988,9 +987,8 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                        }
                } else if (txs->phyerr) {
                        update_rate = false;
-                       wiphy_err(wiphy, "wl%d: ampdu tx phy "
-                                 "error (0x%x)\n", wlc->pub->unit,
-                                 txs->phyerr);
+                       wiphy_err(wiphy, "%s: ampdu tx phy error (0x%x)\n",
+                                 __func__, txs->phyerr);
 
                        if (brcm_msg_level & LOG_ERROR_VAL) {
                                brcmu_prpkt("txpkt (AMPDU)", p);
@@ -1018,10 +1016,10 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                ack_recd = false;
                if (ba_recd) {
                        bindex = MODSUB_POW2(seq, start_seq, SEQNUM_MAX);
-                       BCMMSG(wlc->wiphy, "tid %d seq %d,"
-                               " start_seq %d, bindex %d set %d, index %d\n",
-                               tid, seq, start_seq, bindex,
-                               isset(bitmap, bindex), index);
+                       BCMMSG(wiphy,
+                              "tid %d seq %d, start_seq %d, bindex %d set %d, index %d\n",
+                              tid, seq, start_seq, bindex,
+                              isset(bitmap, bindex), index);
                        /* if acked then clear bit and free packet */
                        if ((bindex < AMPDU_TX_BA_MAX_WSIZE)
                            && isset(bitmap, bindex)) {
@@ -1070,9 +1068,9 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                                    IEEE80211_TX_STAT_AMPDU_NO_BACK;
                                skb_pull(p, D11_PHY_HDR_LEN);
                                skb_pull(p, D11_TXH_LEN);
-                               wiphy_err(wiphy, "%s: BA Timeout, seq %d, in_"
-                                       "transit %d\n", "AMPDU status", seq,
-                                       ini->tx_in_transit);
+                               BCMMSG(wiphy,
+                                      "BA Timeout, seq %d, in_transit %d\n",
+                                      seq, ini->tx_in_transit);
                                ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw,
                                                            p);
                        }
index fec0f10773e5023c2882396db91cf03d290ec2af..569ab8abd2a1c2d132eb1fbe273d09f077d68c3e 100644 (file)
@@ -1169,25 +1169,31 @@ static struct bcma_driver brcms_bcma_driver = {
 /**
  * This is the main entry point for the brcmsmac driver.
  *
- * This function determines if a device pointed to by pdev is a WL device,
- * and if so, performs a brcms_attach() on it.
- *
+ * This function is scheduled upon module initialization and
+ * does the driver registration, which result in brcms_bcma_probe()
+ * call resulting in the driver bringup.
  */
-static int __init brcms_module_init(void)
+static void brcms_driver_init(struct work_struct *work)
 {
-       int error = -ENODEV;
+       int error;
 
+       error = bcma_driver_register(&brcms_bcma_driver);
+       if (error)
+               pr_err("%s: register returned %d\n", __func__, error);
+}
+
+static DECLARE_WORK(brcms_driver_work, brcms_driver_init);
+
+static int __init brcms_module_init(void)
+{
 #ifdef DEBUG
        if (msglevel != 0xdeadbeef)
                brcm_msg_level = msglevel;
-#endif                         /* DEBUG */
-
-       error = bcma_driver_register(&brcms_bcma_driver);
-       pr_err("%s: register returned %d\n", __func__, error);
-       if (!error)
-               return 0;
+#endif
+       if (!schedule_work(&brcms_driver_work))
+               return -EBUSY;
 
-       return error;
+       return 0;
 }
 
 /**
@@ -1199,6 +1205,7 @@ static int __init brcms_module_init(void)
  */
 static void __exit brcms_module_exit(void)
 {
+       cancel_work_sync(&brcms_driver_work);
        bcma_driver_unregister(&brcms_bcma_driver);
 }
 
index da41b8cf87002440a13ac8e61f97e8a1f20aa511..5d7e97e63def5a02540ded9ad0fe92efdfefdc87 100644 (file)
@@ -309,13 +309,6 @@ static const long ipw2100_frequencies[] = {
 
 #define FREQ_COUNT     ARRAY_SIZE(ipw2100_frequencies)
 
-static const long ipw2100_rates_11b[] = {
-       1000000,
-       2000000,
-       5500000,
-       11000000
-};
-
 static struct ieee80211_rate ipw2100_bg_rates[] = {
        { .bitrate = 10 },
        { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
@@ -323,7 +316,7 @@ static struct ieee80211_rate ipw2100_bg_rates[] = {
        { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
 };
 
-#define RATE_COUNT ARRAY_SIZE(ipw2100_rates_11b)
+#define RATE_COUNT ARRAY_SIZE(ipw2100_bg_rates)
 
 /* Pre-decl until we get the code solid and then we can clean it up */
 static void ipw2100_tx_send_commands(struct ipw2100_priv *priv);
@@ -6896,7 +6889,7 @@ static int ipw2100_wx_get_range(struct net_device *dev,
        range->num_bitrates = RATE_COUNT;
 
        for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
-               range->bitrate[i] = ipw2100_rates_11b[i];
+               range->bitrate[i] = ipw2100_bg_rates[i].bitrate * 100 * 1000;
        }
 
        range->min_rts = MIN_RTS_THRESHOLD;
index 47c20e3d560506214a3aef2135dd4a6dbbe00ec2..e78bdefb8952ca605ae8eb1d3243274b80bdd63f 100644 (file)
@@ -79,18 +79,6 @@ struct stats_general_data {
        u32 beacon_energy_c;
 };
 
-void
-il4965_calib_free_results(struct il_priv *il)
-{
-       int i;
-
-       for (i = 0; i < IL_CALIB_MAX; i++) {
-               kfree(il->calib_results[i].buf);
-               il->calib_results[i].buf = NULL;
-               il->calib_results[i].buf_len = 0;
-       }
-}
-
 /*****************************************************************************
  * RUNTIME calibrations framework
  *****************************************************************************/
index 2d01db0f08e0ea7854a09532c7382a656e63395b..7b54dbb338be6127bec123f8414cd3231eaabb00 100644 (file)
@@ -1693,7 +1693,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
                sta_priv = (void *)sta->drv_priv;
 
        if (sta_priv && sta_priv->asleep &&
-           (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
+           (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
                /*
                 * This sends an asynchronous command to the device,
                 * but we can rely on it being processed before the
@@ -6347,7 +6347,6 @@ err:
 static void
 il4965_uninit_drv(struct il_priv *il)
 {
-       il4965_calib_free_results(il);
        il_free_geos(il);
        il_free_channel_map(il);
        kfree(il->scan_cmd);
index 208a4564d063a6cb9f6c6a90fc65d261b60dc44a..1db677689cfe36b18940c406e302519c51591bef 100644 (file)
@@ -927,7 +927,6 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp);
 void il4965_sensitivity_calibration(struct il_priv *il, void *resp);
 void il4965_init_sensitivity(struct il_priv *il);
 void il4965_reset_run_time_calib(struct il_priv *il);
-void il4965_calib_free_results(struct il_priv *il);
 
 /* Debug */
 #ifdef CONFIG_IWLEGACY_DEBUGFS
index 05bd375cb845b73fbf94401ba57bfc50c59d448d..fb919727b8bb520bc32f2c151997e1d33c721eab 100644 (file)
@@ -6,45 +6,6 @@ config IWLEGACY
        select LEDS_TRIGGERS
        select MAC80211_LEDS
 
-menu "Debugging Options"
-       depends on IWLEGACY
-
-config IWLEGACY_DEBUG
-       bool "Enable full debugging output in iwlegacy (iwl 3945/4965) drivers"
-       depends on IWLEGACY
-       ---help---
-         This option will enable debug tracing output for the iwlegacy
-         drivers.
-
-         This will result in the kernel module being ~100k larger.  You can
-         control which debug output is sent to the kernel log by setting the
-         value in
-
-               /sys/class/net/wlan0/device/debug_level
-
-         This entry will only exist if this option is enabled.
-
-         To set a value, simply echo an 8-byte hex value to the same file:
-
-                 % echo 0x43fff > /sys/class/net/wlan0/device/debug_level
-
-         You can find the list of debug mask values in:
-                 drivers/net/wireless/iwlegacy/common.h
-
-         If this is your first time using this driver, you should say Y here
-         as the debug information can assist others in helping you resolve
-         any problems you may encounter.
-
-config IWLEGACY_DEBUGFS
-        bool "iwlegacy (iwl 3945/4965) debugfs support"
-        depends on IWLEGACY && MAC80211_DEBUGFS
-        ---help---
-         Enable creation of debugfs files for the iwlegacy drivers. This
-         is a low-impact option that allows getting insight into the
-         driver's state at runtime.
-
-endmenu
-
 config IWL4965
        tristate "Intel Wireless WiFi 4965AGN (iwl4965)"
        depends on PCI && MAC80211
@@ -98,3 +59,42 @@ config IWL3945
          inserted in and removed from the running kernel whenever you want),
          say M here and read <file:Documentation/kbuild/modules.txt>.  The
          module will be called iwl3945.
+
+menu "iwl3945 / iwl4965 Debugging Options"
+       depends on IWLEGACY
+
+config IWLEGACY_DEBUG
+       bool "Enable full debugging output in iwlegacy (iwl 3945/4965) drivers"
+       depends on IWLEGACY
+       ---help---
+         This option will enable debug tracing output for the iwlegacy
+         drivers.
+
+         This will result in the kernel module being ~100k larger.  You can
+         control which debug output is sent to the kernel log by setting the
+         value in
+
+               /sys/class/net/wlan0/device/debug_level
+
+         This entry will only exist if this option is enabled.
+
+         To set a value, simply echo an 8-byte hex value to the same file:
+
+                 % echo 0x43fff > /sys/class/net/wlan0/device/debug_level
+
+         You can find the list of debug mask values in:
+                 drivers/net/wireless/iwlegacy/common.h
+
+         If this is your first time using this driver, you should say Y here
+         as the debug information can assist others in helping you resolve
+         any problems you may encounter.
+
+config IWLEGACY_DEBUGFS
+        bool "iwlegacy (iwl 3945/4965) debugfs support"
+        depends on IWLEGACY && MAC80211_DEBUGFS
+        ---help---
+         Enable creation of debugfs files for the iwlegacy drivers. This
+         is a low-impact option that allows getting insight into the
+         driver's state at runtime.
+
+endmenu
index 6ed9871f1c4b77aa6606eb44d6134756069fc2ca..5f5017767b9990b54096b705c23310e866ff2d92 100644 (file)
@@ -956,26 +956,6 @@ enum il4965_chain_noise_state {
        IL_CHAIN_NOISE_DONE,
 };
 
-enum il4965_calib_enabled_state {
-       IL_CALIB_DISABLED = 0,  /* must be 0 */
-       IL_CALIB_ENABLED = 1,
-};
-
-/*
- * enum il_calib
- * defines the order in which results of initial calibrations
- * should be sent to the runtime uCode
- */
-enum il_calib {
-       IL_CALIB_MAX,
-};
-
-/* Opaque calibration results */
-struct il_calib_result {
-       void *buf;
-       size_t buf_len;
-};
-
 enum ucode_type {
        UCODE_NONE = 0,
        UCODE_INIT,
@@ -1195,9 +1175,6 @@ struct il_priv {
        s32 temperature;        /* degrees Kelvin */
        s32 last_temperature;
 
-       /* init calibration results */
-       struct il_calib_result calib_results[IL_CALIB_MAX];
-
        /* Scan related variables */
        unsigned long scan_start;
        unsigned long scan_start_tsf;
index 46622a0f017b0c357dc11d8a12b61222fac44370..85d163ed3db18dd224477231fc0d1728b157f261 100644 (file)
@@ -13,7 +13,8 @@ iwlwifi-objs          += iwl-6000.o
 iwlwifi-objs           += iwl-1000.o
 iwlwifi-objs           += iwl-2000.o
 iwlwifi-objs           += iwl-pci.o
-iwlwifi-objs           += iwl-trans.o
+iwlwifi-objs           += iwl-drv.o
+iwlwifi-objs           += iwl-notif-wait.o
 iwlwifi-objs           += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o
 
 iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o
index 605ee3df1d82dffd1db92ffd9bfbb90a7bd80104..f6e6f57aade5d8be879be427a5506230c4ae40b8 100644 (file)
@@ -43,6 +43,7 @@
 #include "iwl-agn-hw.h"
 #include "iwl-shared.h"
 #include "iwl-cfg.h"
+#include "iwl-prph.h"
 
 /* Highest firmware API version supported */
 #define IWL1000_UCODE_API_MAX 6
@@ -122,23 +123,17 @@ static struct iwl_sensitivity_ranges iwl1000_sensitivity = {
 
 static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
 {
-       if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
-           iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
-               cfg(priv)->base_params->num_of_queues =
-                       iwlagn_mod_params.num_of_queues;
-
        hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
        if (cfg(priv)->rx_with_siso_diversity)
                hw_params(priv).rx_chains_num = 1;
        else
                hw_params(priv).rx_chains_num =
-                       num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+                       num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl1000_set_ct_threshold(priv);
 
@@ -163,7 +158,7 @@ static struct iwl_lib_ops iwl1000_lib = {
        .temperature = iwlagn_temperature,
 };
 
-static struct iwl_base_params iwl1000_base_params = {
+static const struct iwl_base_params iwl1000_base_params = {
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
        .eeprom_size = OTP_LOW_IMAGE_SIZE,
@@ -178,7 +173,8 @@ static struct iwl_base_params iwl1000_base_params = {
        .max_event_log_size = 128,
        .wd_disable = true,
 };
-static struct iwl_ht_params iwl1000_ht_params = {
+
+static const struct iwl_ht_params iwl1000_ht_params = {
        .ht_greenfield_support = true,
        .use_rts_for_aggregation = true, /* use rts/cts protection */
        .smps_mode = IEEE80211_SMPS_DYNAMIC,
@@ -197,13 +193,13 @@ static struct iwl_ht_params iwl1000_ht_params = {
        .base_params = &iwl1000_base_params,                    \
        .led_mode = IWL_LED_BLINK
 
-struct iwl_cfg iwl1000_bgn_cfg = {
+const struct iwl_cfg iwl1000_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
        IWL_DEVICE_1000,
        .ht_params = &iwl1000_ht_params,
 };
 
-struct iwl_cfg iwl1000_bg_cfg = {
+const struct iwl_cfg iwl1000_bg_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
        IWL_DEVICE_1000,
 };
@@ -222,13 +218,13 @@ struct iwl_cfg iwl1000_bg_cfg = {
        .led_mode = IWL_LED_RF_STATE,                           \
        .rx_with_siso_diversity = true
 
-struct iwl_cfg iwl100_bgn_cfg = {
+const struct iwl_cfg iwl100_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 100 BGN",
        IWL_DEVICE_100,
        .ht_params = &iwl1000_ht_params,
 };
 
-struct iwl_cfg iwl100_bg_cfg = {
+const struct iwl_cfg iwl100_bg_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 100 BG",
        IWL_DEVICE_100,
 };
index e6e8c79a80d8e731f7bc624b695dafeb8e1f3967..446d010dfe84a32cac425e7f86aa02e47ad63d6c 100644 (file)
@@ -118,23 +118,17 @@ static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
 
 static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
 {
-       if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
-           iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
-               cfg(priv)->base_params->num_of_queues =
-                       iwlagn_mod_params.num_of_queues;
-
        hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
        if (cfg(priv)->rx_with_siso_diversity)
                hw_params(priv).rx_chains_num = 1;
        else
                hw_params(priv).rx_chains_num =
-                       num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+                       num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl2000_set_ct_threshold(priv);
 
@@ -181,7 +175,7 @@ static struct iwl_lib_ops iwl2030_lib = {
        .temperature = iwlagn_temperature,
 };
 
-static struct iwl_base_params iwl2000_base_params = {
+static const struct iwl_base_params iwl2000_base_params = {
        .eeprom_size = OTP_LOW_IMAGE_SIZE,
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -200,7 +194,7 @@ static struct iwl_base_params iwl2000_base_params = {
 };
 
 
-static struct iwl_base_params iwl2030_base_params = {
+static const struct iwl_base_params iwl2030_base_params = {
        .eeprom_size = OTP_LOW_IMAGE_SIZE,
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -218,12 +212,12 @@ static struct iwl_base_params iwl2030_base_params = {
        .hd_v2 = true,
 };
 
-static struct iwl_ht_params iwl2000_ht_params = {
+static const struct iwl_ht_params iwl2000_ht_params = {
        .ht_greenfield_support = true,
        .use_rts_for_aggregation = true, /* use rts/cts protection */
 };
 
-static struct iwl_bt_params iwl2030_bt_params = {
+static const struct iwl_bt_params iwl2030_bt_params = {
        /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
        .advanced_bt_coexist = true,
        .agg_time_limit = BT_AGG_THRESHOLD_DEF,
@@ -249,13 +243,13 @@ static struct iwl_bt_params iwl2030_bt_params = {
        .led_mode = IWL_LED_RF_STATE,                           \
        .iq_invert = true                                       \
 
-struct iwl_cfg iwl2000_2bgn_cfg = {
+const struct iwl_cfg iwl2000_2bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 2200 BGN",
        IWL_DEVICE_2000,
        .ht_params = &iwl2000_ht_params,
 };
 
-struct iwl_cfg iwl2000_2bgn_d_cfg = {
+const struct iwl_cfg iwl2000_2bgn_d_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 2200D BGN",
        IWL_DEVICE_2000,
        .ht_params = &iwl2000_ht_params,
@@ -279,7 +273,7 @@ struct iwl_cfg iwl2000_2bgn_d_cfg = {
        .adv_pm = true,                                         \
        .iq_invert = true                                       \
 
-struct iwl_cfg iwl2030_2bgn_cfg = {
+const struct iwl_cfg iwl2030_2bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 2230 BGN",
        IWL_DEVICE_2030,
        .ht_params = &iwl2000_ht_params,
@@ -303,13 +297,13 @@ struct iwl_cfg iwl2030_2bgn_cfg = {
        .rx_with_siso_diversity = true,                         \
        .iq_invert = true                                       \
 
-struct iwl_cfg iwl105_bgn_cfg = {
+const struct iwl_cfg iwl105_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 105 BGN",
        IWL_DEVICE_105,
        .ht_params = &iwl2000_ht_params,
 };
 
-struct iwl_cfg iwl105_bgn_d_cfg = {
+const struct iwl_cfg iwl105_bgn_d_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 105D BGN",
        IWL_DEVICE_105,
        .ht_params = &iwl2000_ht_params,
@@ -334,7 +328,7 @@ struct iwl_cfg iwl105_bgn_d_cfg = {
        .rx_with_siso_diversity = true,                         \
        .iq_invert = true                                       \
 
-struct iwl_cfg iwl135_bgn_cfg = {
+const struct iwl_cfg iwl135_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 135 BGN",
        IWL_DEVICE_135,
        .ht_params = &iwl2000_ht_params,
index 1527dec7a26706d714f46619b44449c796ee0e59..907a0b22f7b24d5a263d1c090e8becca8791b4c3 100644 (file)
@@ -45,6 +45,7 @@
 #include "iwl-trans.h"
 #include "iwl-shared.h"
 #include "iwl-cfg.h"
+#include "iwl-prph.h"
 
 /* Highest firmware API version supported */
 #define IWL5000_UCODE_API_MAX 5
 /* NIC configuration for 5000 series */
 static void iwl5000_nic_config(struct iwl_priv *priv)
 {
-       unsigned long flags;
-
        iwl_rf_config(priv);
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
-
        /* W/A : NIC is stuck in a reset state after Early PCIe power off
         * (PCIe power is lost before PERST# is asserted),
         * causing ME FW to lose ownership and not being able to obtain it back.
@@ -76,9 +73,6 @@ static void iwl5000_nic_config(struct iwl_priv *priv)
        iwl_set_bits_mask_prph(trans(priv), APMG_PS_CTRL_REG,
                                APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
                                ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
-
-
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
 }
 
 static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
@@ -164,20 +158,15 @@ static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
 
 static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
 {
-       if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
-           iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
-               cfg(priv)->base_params->num_of_queues =
-                       iwlagn_mod_params.num_of_queues;
-
        hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
-       hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
+       hw_params(priv).rx_chains_num =
+               num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl5000_set_ct_threshold(priv);
 
@@ -187,20 +176,15 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
 
 static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
 {
-       if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
-           iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
-               cfg(priv)->base_params->num_of_queues =
-                       iwlagn_mod_params.num_of_queues;
-
        hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
-       hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
+       hw_params(priv).rx_chains_num =
+               num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl5150_set_ct_threshold(priv);
 
@@ -288,7 +272,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
                return -EFAULT;
        }
 
-       return iwl_trans_send_cmd(trans(priv), &hcmd);
+       return iwl_dvm_send_cmd(priv, &hcmd);
 }
 
 static struct iwl_lib_ops iwl5000_lib = {
@@ -327,7 +311,7 @@ static struct iwl_lib_ops iwl5150_lib = {
        .temperature = iwl5150_temperature,
 };
 
-static struct iwl_base_params iwl5000_base_params = {
+static const struct iwl_base_params iwl5000_base_params = {
        .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -340,7 +324,8 @@ static struct iwl_base_params iwl5000_base_params = {
        .no_idle_support = true,
        .wd_disable = true,
 };
-static struct iwl_ht_params iwl5000_ht_params = {
+
+static const struct iwl_ht_params iwl5000_ht_params = {
        .ht_greenfield_support = true,
 };
 
@@ -356,7 +341,7 @@ static struct iwl_ht_params iwl5000_ht_params = {
        .base_params = &iwl5000_base_params,                    \
        .led_mode = IWL_LED_BLINK
 
-struct iwl_cfg iwl5300_agn_cfg = {
+const struct iwl_cfg iwl5300_agn_cfg = {
        .name = "Intel(R) Ultimate N WiFi Link 5300 AGN",
        IWL_DEVICE_5000,
        /* at least EEPROM 0x11A has wrong info */
@@ -365,7 +350,7 @@ struct iwl_cfg iwl5300_agn_cfg = {
        .ht_params = &iwl5000_ht_params,
 };
 
-struct iwl_cfg iwl5100_bgn_cfg = {
+const struct iwl_cfg iwl5100_bgn_cfg = {
        .name = "Intel(R) WiFi Link 5100 BGN",
        IWL_DEVICE_5000,
        .valid_tx_ant = ANT_B,          /* .cfg overwrite */
@@ -373,14 +358,14 @@ struct iwl_cfg iwl5100_bgn_cfg = {
        .ht_params = &iwl5000_ht_params,
 };
 
-struct iwl_cfg iwl5100_abg_cfg = {
+const struct iwl_cfg iwl5100_abg_cfg = {
        .name = "Intel(R) WiFi Link 5100 ABG",
        IWL_DEVICE_5000,
        .valid_tx_ant = ANT_B,          /* .cfg overwrite */
        .valid_rx_ant = ANT_AB,         /* .cfg overwrite */
 };
 
-struct iwl_cfg iwl5100_agn_cfg = {
+const struct iwl_cfg iwl5100_agn_cfg = {
        .name = "Intel(R) WiFi Link 5100 AGN",
        IWL_DEVICE_5000,
        .valid_tx_ant = ANT_B,          /* .cfg overwrite */
@@ -388,7 +373,7 @@ struct iwl_cfg iwl5100_agn_cfg = {
        .ht_params = &iwl5000_ht_params,
 };
 
-struct iwl_cfg iwl5350_agn_cfg = {
+const struct iwl_cfg iwl5350_agn_cfg = {
        .name = "Intel(R) WiMAX/WiFi Link 5350 AGN",
        .fw_name_pre = IWL5000_FW_PRE,
        .ucode_api_max = IWL5000_UCODE_API_MAX,
@@ -418,14 +403,14 @@ struct iwl_cfg iwl5350_agn_cfg = {
        .led_mode = IWL_LED_BLINK,                              \
        .internal_wimax_coex = true
 
-struct iwl_cfg iwl5150_agn_cfg = {
+const struct iwl_cfg iwl5150_agn_cfg = {
        .name = "Intel(R) WiMAX/WiFi Link 5150 AGN",
        IWL_DEVICE_5150,
        .ht_params = &iwl5000_ht_params,
 
 };
 
-struct iwl_cfg iwl5150_abg_cfg = {
+const struct iwl_cfg iwl5150_abg_cfg = {
        .name = "Intel(R) WiMAX/WiFi Link 5150 ABG",
        IWL_DEVICE_5150,
 };
index 1e6fbf4fcb46cbdc865d486a7fb62a5a113efe6e..d299f05dfc9bfe1bbcb85c2081bbb0b739666cb7 100644 (file)
@@ -96,20 +96,21 @@ static void iwl6150_additional_nic_config(struct iwl_priv *priv)
                    CSR_GP_DRIVER_REG_BIT_6050_1x2);
 }
 
+static void iwl6000i_additional_nic_config(struct iwl_priv *priv)
+{
+       /* 2x2 IPA phy type */
+       iwl_write32(trans(priv), CSR_GP_DRIVER_REG,
+                    CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
+}
+
 /* NIC configuration for 6000 series */
 static void iwl6000_nic_config(struct iwl_priv *priv)
 {
        iwl_rf_config(priv);
 
-       /* no locking required for register write */
-       if (cfg(priv)->pa_type == IWL_PA_INTERNAL) {
-               /* 2x2 IPA phy type */
-               iwl_write32(trans(priv), CSR_GP_DRIVER_REG,
-                            CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
-       }
        /* do additional nic configuration if needed */
        if (cfg(priv)->additional_nic_config)
-                       cfg(priv)->additional_nic_config(priv);
+               cfg(priv)->additional_nic_config(priv);
 }
 
 static struct iwl_sensitivity_ranges iwl6000_sensitivity = {
@@ -139,24 +140,18 @@ static struct iwl_sensitivity_ranges iwl6000_sensitivity = {
 
 static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
 {
-       if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
-           iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
-               cfg(priv)->base_params->num_of_queues =
-                       iwlagn_mod_params.num_of_queues;
-
        hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
        if (cfg(priv)->rx_with_siso_diversity)
                hw_params(priv).rx_chains_num = 1;
        else
                hw_params(priv).rx_chains_num =
-                       num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+                       num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl6000_set_ct_threshold(priv);
 
@@ -233,7 +228,7 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
                return -EFAULT;
        }
 
-       return iwl_trans_send_cmd(trans(priv), &hcmd);
+       return iwl_dvm_send_cmd(priv, &hcmd);
 }
 
 static struct iwl_lib_ops iwl6000_lib = {
@@ -277,7 +272,7 @@ static struct iwl_lib_ops iwl6030_lib = {
        .temperature = iwlagn_temperature,
 };
 
-static struct iwl_base_params iwl6000_base_params = {
+static const struct iwl_base_params iwl6000_base_params = {
        .eeprom_size = OTP_LOW_IMAGE_SIZE,
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -294,7 +289,7 @@ static struct iwl_base_params iwl6000_base_params = {
        .shadow_reg_enable = true,
 };
 
-static struct iwl_base_params iwl6050_base_params = {
+static const struct iwl_base_params iwl6050_base_params = {
        .eeprom_size = OTP_LOW_IMAGE_SIZE,
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -310,7 +305,8 @@ static struct iwl_base_params iwl6050_base_params = {
        .max_event_log_size = 1024,
        .shadow_reg_enable = true,
 };
-static struct iwl_base_params iwl6000_g2_base_params = {
+
+static const struct iwl_base_params iwl6000_g2_base_params = {
        .eeprom_size = OTP_LOW_IMAGE_SIZE,
        .num_of_queues = IWLAGN_NUM_QUEUES,
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -327,12 +323,12 @@ static struct iwl_base_params iwl6000_g2_base_params = {
        .shadow_reg_enable = true,
 };
 
-static struct iwl_ht_params iwl6000_ht_params = {
+static const struct iwl_ht_params iwl6000_ht_params = {
        .ht_greenfield_support = true,
        .use_rts_for_aggregation = true, /* use rts/cts protection */
 };
 
-static struct iwl_bt_params iwl6000_bt_params = {
+static const struct iwl_bt_params iwl6000_bt_params = {
        /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
        .advanced_bt_coexist = true,
        .agg_time_limit = BT_AGG_THRESHOLD_DEF,
@@ -355,34 +351,46 @@ static struct iwl_bt_params iwl6000_bt_params = {
        .need_temp_offset_calib = true,                         \
        .led_mode = IWL_LED_RF_STATE
 
-struct iwl_cfg iwl6005_2agn_cfg = {
+const struct iwl_cfg iwl6005_2agn_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6205 AGN",
        IWL_DEVICE_6005,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6005_2abg_cfg = {
+const struct iwl_cfg iwl6005_2abg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6205 ABG",
        IWL_DEVICE_6005,
 };
 
-struct iwl_cfg iwl6005_2bg_cfg = {
+const struct iwl_cfg iwl6005_2bg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6205 BG",
        IWL_DEVICE_6005,
 };
 
-struct iwl_cfg iwl6005_2agn_sff_cfg = {
+const struct iwl_cfg iwl6005_2agn_sff_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6205S AGN",
        IWL_DEVICE_6005,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6005_2agn_d_cfg = {
+const struct iwl_cfg iwl6005_2agn_d_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6205D AGN",
        IWL_DEVICE_6005,
        .ht_params = &iwl6000_ht_params,
 };
 
+const struct iwl_cfg iwl6005_2agn_mow1_cfg = {
+       .name = "Intel(R) Centrino(R) Advanced-N 6206 AGN",
+       IWL_DEVICE_6005,
+       .ht_params = &iwl6000_ht_params,
+};
+
+const struct iwl_cfg iwl6005_2agn_mow2_cfg = {
+       .name = "Intel(R) Centrino(R) Advanced-N 6207 AGN",
+       IWL_DEVICE_6005,
+       .ht_params = &iwl6000_ht_params,
+};
+
 #define IWL_DEVICE_6030                                                \
        .fw_name_pre = IWL6030_FW_PRE,                          \
        .ucode_api_max = IWL6000G2_UCODE_API_MAX,               \
@@ -399,53 +407,53 @@ struct iwl_cfg iwl6005_2agn_d_cfg = {
        .led_mode = IWL_LED_RF_STATE,                           \
        .adv_pm = true                                          \
 
-struct iwl_cfg iwl6030_2agn_cfg = {
+const struct iwl_cfg iwl6030_2agn_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6230 AGN",
        IWL_DEVICE_6030,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6030_2abg_cfg = {
+const struct iwl_cfg iwl6030_2abg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6230 ABG",
        IWL_DEVICE_6030,
 };
 
-struct iwl_cfg iwl6030_2bgn_cfg = {
+const struct iwl_cfg iwl6030_2bgn_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6230 BGN",
        IWL_DEVICE_6030,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6030_2bg_cfg = {
+const struct iwl_cfg iwl6030_2bg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6230 BG",
        IWL_DEVICE_6030,
 };
 
-struct iwl_cfg iwl6035_2agn_cfg = {
+const struct iwl_cfg iwl6035_2agn_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN",
        IWL_DEVICE_6030,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl1030_bgn_cfg = {
+const struct iwl_cfg iwl1030_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN",
        IWL_DEVICE_6030,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl1030_bg_cfg = {
+const struct iwl_cfg iwl1030_bg_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 1030 BG",
        IWL_DEVICE_6030,
 };
 
-struct iwl_cfg iwl130_bgn_cfg = {
+const struct iwl_cfg iwl130_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 130 BGN",
        IWL_DEVICE_6030,
        .ht_params = &iwl6000_ht_params,
        .rx_with_siso_diversity = true,
 };
 
-struct iwl_cfg iwl130_bg_cfg = {
+const struct iwl_cfg iwl130_bg_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N 130 BG",
        IWL_DEVICE_6030,
        .rx_with_siso_diversity = true,
@@ -466,22 +474,22 @@ struct iwl_cfg iwl130_bg_cfg = {
        .eeprom_ver = EEPROM_6000_EEPROM_VERSION,               \
        .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION,       \
        .lib = &iwl6000_lib,                                    \
+       .additional_nic_config = iwl6000i_additional_nic_config,\
        .base_params = &iwl6000_base_params,                    \
-       .pa_type = IWL_PA_INTERNAL,                             \
        .led_mode = IWL_LED_BLINK
 
-struct iwl_cfg iwl6000i_2agn_cfg = {
+const struct iwl_cfg iwl6000i_2agn_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN",
        IWL_DEVICE_6000i,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6000i_2abg_cfg = {
+const struct iwl_cfg iwl6000i_2abg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6200 ABG",
        IWL_DEVICE_6000i,
 };
 
-struct iwl_cfg iwl6000i_2bg_cfg = {
+const struct iwl_cfg iwl6000i_2bg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N 6200 BG",
        IWL_DEVICE_6000i,
 };
@@ -502,13 +510,13 @@ struct iwl_cfg iwl6000i_2bg_cfg = {
        .led_mode = IWL_LED_BLINK,                              \
        .internal_wimax_coex = true
 
-struct iwl_cfg iwl6050_2agn_cfg = {
+const struct iwl_cfg iwl6050_2agn_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN",
        IWL_DEVICE_6050,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6050_2abg_cfg = {
+const struct iwl_cfg iwl6050_2abg_cfg = {
        .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 ABG",
        IWL_DEVICE_6050,
 };
@@ -527,18 +535,18 @@ struct iwl_cfg iwl6050_2abg_cfg = {
        .led_mode = IWL_LED_BLINK,                              \
        .internal_wimax_coex = true
 
-struct iwl_cfg iwl6150_bgn_cfg = {
+const struct iwl_cfg iwl6150_bgn_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN",
        IWL_DEVICE_6150,
        .ht_params = &iwl6000_ht_params,
 };
 
-struct iwl_cfg iwl6150_bg_cfg = {
+const struct iwl_cfg iwl6150_bg_cfg = {
        .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG",
        IWL_DEVICE_6150,
 };
 
-struct iwl_cfg iwl6000_3agn_cfg = {
+const struct iwl_cfg iwl6000_3agn_cfg = {
        .name = "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
        .fw_name_pre = IWL6000_FW_PRE,
        .ucode_api_max = IWL6000_UCODE_API_MAX,
index 988ee454a9446773a94feea6fb6642c3e187feb6..579679edd5f13543f1d8591821a47366b9009a1f 100644 (file)
 #include "iwl-agn-calib.h"
 #include "iwl-trans.h"
 #include "iwl-agn.h"
-#include "iwl-wifi.h"
-#include "iwl-ucode.h"
 
 /*****************************************************************************
  * INIT calibrations framework
  *****************************************************************************/
 
+/* Opaque calibration results */
+struct iwl_calib_result {
+       struct list_head list;
+       size_t cmd_len;
+       struct iwl_calib_hdr hdr;
+       /* data follows */
+};
+
 struct statistics_general_data {
        u32 beacon_silence_rssi_a;
        u32 beacon_silence_rssi_b;
@@ -84,7 +90,7 @@ struct statistics_general_data {
        u32 beacon_energy_c;
 };
 
-int iwl_send_calib_results(struct iwl_trans *trans)
+int iwl_send_calib_results(struct iwl_priv *priv)
 {
        struct iwl_host_cmd hcmd = {
                .id = REPLY_PHY_CALIBRATION_CMD,
@@ -92,15 +98,15 @@ int iwl_send_calib_results(struct iwl_trans *trans)
        };
        struct iwl_calib_result *res;
 
-       list_for_each_entry(res, &trans->calib_results, list) {
+       list_for_each_entry(res, &priv->calib_results, list) {
                int ret;
 
                hcmd.len[0] = res->cmd_len;
                hcmd.data[0] = &res->hdr;
                hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
-               ret = iwl_trans_send_cmd(trans, &hcmd);
+               ret = iwl_dvm_send_cmd(priv, &hcmd);
                if (ret) {
-                       IWL_ERR(trans, "Error %d on calib cmd %d\n",
+                       IWL_ERR(priv, "Error %d on calib cmd %d\n",
                                ret, res->hdr.op_code);
                        return ret;
                }
@@ -109,7 +115,7 @@ int iwl_send_calib_results(struct iwl_trans *trans)
        return 0;
 }
 
-int iwl_calib_set(struct iwl_trans *trans,
+int iwl_calib_set(struct iwl_priv *priv,
                  const struct iwl_calib_hdr *cmd, int len)
 {
        struct iwl_calib_result *res, *tmp;
@@ -121,7 +127,7 @@ int iwl_calib_set(struct iwl_trans *trans,
        memcpy(&res->hdr, cmd, len);
        res->cmd_len = len;
 
-       list_for_each_entry(tmp, &trans->calib_results, list) {
+       list_for_each_entry(tmp, &priv->calib_results, list) {
                if (tmp->hdr.op_code == res->hdr.op_code) {
                        list_replace(&tmp->list, &res->list);
                        kfree(tmp);
@@ -130,16 +136,16 @@ int iwl_calib_set(struct iwl_trans *trans,
        }
 
        /* wasn't in list already */
-       list_add_tail(&res->list, &trans->calib_results);
+       list_add_tail(&res->list, &priv->calib_results);
 
        return 0;
 }
 
-void iwl_calib_free_results(struct iwl_trans *trans)
+void iwl_calib_free_results(struct iwl_priv *priv)
 {
        struct iwl_calib_result *res, *tmp;
 
-       list_for_each_entry_safe(res, tmp, &trans->calib_results, list) {
+       list_for_each_entry_safe(res, tmp, &priv->calib_results, list) {
                list_del(&res->list);
                kfree(res);
        }
@@ -494,7 +500,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
        memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]),
               sizeof(u16)*HD_TABLE_SIZE);
 
-       return iwl_trans_send_cmd(trans(priv), &cmd_out);
+       return iwl_dvm_send_cmd(priv, &cmd_out);
 }
 
 /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
@@ -583,7 +589,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv)
               &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]),
               sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES);
 
-       return iwl_trans_send_cmd(trans(priv), &cmd_out);
+       return iwl_dvm_send_cmd(priv, &cmd_out);
 }
 
 void iwl_init_sensitivity(struct iwl_priv *priv)
@@ -636,7 +642,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv)
        data->last_bad_plcp_cnt_cck = 0;
        data->last_fa_cnt_cck = 0;
 
-       if (nic(priv)->fw.enhance_sensitivity_table)
+       if (priv->fw->enhance_sensitivity_table)
                ret |= iwl_enhance_sensitivity_write(priv);
        else
                ret |= iwl_sensitivity_write(priv);
@@ -655,7 +661,6 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
        struct iwl_sensitivity_data *data = NULL;
        struct statistics_rx_non_phy *rx_info;
        struct statistics_rx_phy *ofdm, *cck;
-       unsigned long flags;
        struct statistics_general_data statis;
 
        if (priv->disable_sens_cal)
@@ -668,13 +673,13 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
                return;
        }
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
+       spin_lock_bh(&priv->statistics.lock);
        rx_info = &priv->statistics.rx_non_phy;
        ofdm = &priv->statistics.rx_ofdm;
        cck = &priv->statistics.rx_cck;
        if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
                IWL_DEBUG_CALIB(priv, "<< invalid data.\n");
-               spin_unlock_irqrestore(&priv->shrd->lock, flags);
+               spin_unlock_bh(&priv->statistics.lock);
                return;
        }
 
@@ -698,7 +703,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
        statis.beacon_energy_c =
                        le32_to_cpu(rx_info->beacon_energy_c);
 
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
+       spin_unlock_bh(&priv->statistics.lock);
 
        IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time);
 
@@ -747,7 +752,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv)
 
        iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time);
        iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis);
-       if (nic(priv)->fw.enhance_sensitivity_table)
+       if (priv->fw->enhance_sensitivity_table)
                iwl_enhance_sensitivity_write(priv);
        else
                iwl_sensitivity_write(priv);
@@ -849,7 +854,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
                         * connect the first valid tx chain
                         */
                        first_chain =
-                               find_first_chain(cfg(priv)->valid_tx_ant);
+                               find_first_chain(hw_params(priv).valid_tx_ant);
                        data->disconn_array[first_chain] = 0;
                        active_chains |= BIT(first_chain);
                        IWL_DEBUG_CALIB(priv,
@@ -925,7 +930,7 @@ static void iwlagn_gain_computation(struct iwl_priv *priv,
                        priv->phy_calib_chain_noise_gain_cmd);
                cmd.delta_gain_1 = data->delta_gain_code[1];
                cmd.delta_gain_2 = data->delta_gain_code[2];
-               iwl_trans_send_cmd_pdu(trans(priv), REPLY_PHY_CALIBRATION_CMD,
+               iwl_dvm_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
                        CMD_ASYNC, sizeof(cmd), &cmd);
 
                data->radio_write = 1;
@@ -958,7 +963,6 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
        u16 stat_chnum = INITIALIZATION_VALUE;
        u8 rxon_band24;
        u8 stat_band24;
-       unsigned long flags;
        struct statistics_rx_non_phy *rx_info;
 
        /*
@@ -983,13 +987,13 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
                return;
        }
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
+       spin_lock_bh(&priv->statistics.lock);
 
        rx_info = &priv->statistics.rx_non_phy;
 
        if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
                IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n");
-               spin_unlock_irqrestore(&priv->shrd->lock, flags);
+               spin_unlock_bh(&priv->statistics.lock);
                return;
        }
 
@@ -1004,7 +1008,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
        if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) {
                IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n",
                                rxon_chnum, rxon_band24);
-               spin_unlock_irqrestore(&priv->shrd->lock, flags);
+               spin_unlock_bh(&priv->statistics.lock);
                return;
        }
 
@@ -1023,7 +1027,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
        chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER;
        chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER;
 
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
+       spin_unlock_bh(&priv->statistics.lock);
 
        data->beacon_count++;
 
@@ -1084,7 +1088,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
 
        iwlagn_gain_computation(priv, average_noise,
                                min_average_noise_antenna_i, min_average_noise,
-                               find_first_chain(cfg(priv)->valid_rx_ant));
+                               find_first_chain(hw_params(priv).valid_rx_ant));
 
        /* Some power changes may have been made during the calibration.
         * Update and commit the RXON
index c368433f8bc8dc1203d1cd43f05cbf5e269e7cee..b2ee1f9373c0c055255da20a808527db63341066 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 
-#include "iwl-wifi.h"
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-io.h"
@@ -77,17 +76,19 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
        tx_power_cmd.flags = IWLAGN_TX_POWER_NO_CLOSED;
        tx_power_cmd.srv_chan_lmt = IWLAGN_TX_POWER_AUTO;
 
-       if (IWL_UCODE_API(nic(priv)->fw.ucode_ver) == 1)
+       if (IWL_UCODE_API(priv->fw->ucode_ver) == 1)
                tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD_V1;
        else
                tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
 
-       return iwl_trans_send_cmd_pdu(trans(priv), tx_ant_cfg_cmd, CMD_SYNC,
+       return iwl_dvm_send_cmd_pdu(priv, tx_ant_cfg_cmd, CMD_SYNC,
                        sizeof(tx_power_cmd), &tx_power_cmd);
 }
 
 void iwlagn_temperature(struct iwl_priv *priv)
 {
+       lockdep_assert_held(&priv->statistics.lock);
+
        /* store temperature from correct statistics (in Celsius) */
        priv->temperature = le32_to_cpu(priv->statistics.common.temperature);
        iwl_tt_handler(priv);
@@ -233,19 +234,19 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
                                IWL_PAN_SCD_BK_MSK | IWL_PAN_SCD_MGMT_MSK |
                                IWL_PAN_SCD_MULTICAST_MSK;
 
-       if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE)
+       if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE)
                flush_cmd.fifo_control |= IWL_AGG_TX_QUEUE_MSK;
 
        IWL_DEBUG_INFO(priv, "fifo queue control: 0X%x\n",
                       flush_cmd.fifo_control);
        flush_cmd.flush_control = cpu_to_le16(flush_control);
 
-       return iwl_trans_send_cmd(trans(priv), &cmd);
+       return iwl_dvm_send_cmd(priv, &cmd);
 }
 
 void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
 {
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        ieee80211_stop_queues(priv->hw);
        if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) {
                IWL_ERR(priv, "flush request fail\n");
@@ -255,7 +256,7 @@ void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
        iwl_trans_wait_tx_queue_empty(trans(priv));
 done:
        ieee80211_wake_queues(priv->hw);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 /*
@@ -434,12 +435,12 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
        if (cfg(priv)->bt_params->bt_session_2) {
                memcpy(&bt_cmd_2000.basic, &basic,
                        sizeof(basic));
-               ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
+               ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG,
                        CMD_SYNC, sizeof(bt_cmd_2000), &bt_cmd_2000);
        } else {
                memcpy(&bt_cmd_6000.basic, &basic,
                        sizeof(basic));
-               ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
+               ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG,
                        CMD_SYNC, sizeof(bt_cmd_6000), &bt_cmd_6000);
        }
        if (ret)
@@ -452,7 +453,7 @@ void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena)
        struct iwl_rxon_context *ctx, *found_ctx = NULL;
        bool found_ap = false;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        /* Check whether AP or GO mode is active. */
        if (rssi_ena) {
@@ -565,7 +566,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
                break;
        }
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        /*
         * We can not send command to firmware while scanning. When the scan
@@ -593,7 +594,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work)
         */
        iwlagn_bt_coex_rssi_monitor(priv);
 out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 /*
@@ -705,12 +706,11 @@ static void iwlagn_set_kill_msk(struct iwl_priv *priv,
 }
 
 int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
-                                 struct iwl_rx_mem_buffer *rxb,
+                                 struct iwl_rx_cmd_buffer *rxb,
                                  struct iwl_device_cmd *cmd)
 {
-       unsigned long flags;
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_bt_coex_profile_notif *coex = &pkt->u.bt_coex_profile_notif;
+       struct iwl_bt_coex_profile_notif *coex = (void *)pkt->data;
        struct iwl_bt_uart_msg *uart_msg = &coex->last_bt_uart_msg;
 
        if (priv->bt_enable_flag == IWLAGN_BT_FLAG_COEX_MODE_DISABLED) {
@@ -754,9 +754,7 @@ int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
 
        /* FIXME: based on notification, adjust the prio_boost */
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
        priv->bt_ci_compliance = coex->bt_ci_compliance;
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
        return 0;
 }
 
@@ -959,7 +957,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
                               struct ieee80211_key_conf *key,
                               void *_data)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct wowlan_key_data *data = _data;
        struct iwl_rxon_context *ctx = data->ctx;
        struct aes_sc *aes_sc, *aes_tx_sc = NULL;
@@ -971,7 +969,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
        u16 p1k[IWLAGN_P1K_SIZE];
        int ret, i;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
             key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
@@ -1077,7 +1075,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
                break;
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 int iwlagn_send_patterns(struct iwl_priv *priv,
@@ -1117,7 +1115,7 @@ int iwlagn_send_patterns(struct iwl_priv *priv,
        }
 
        cmd.data[0] = pattern_cmd;
-       err = iwl_trans_send_cmd(trans(priv), &cmd);
+       err = iwl_dvm_send_cmd(priv, &cmd);
        kfree(pattern_cmd);
        return err;
 }
@@ -1194,9 +1192,9 @@ int iwlagn_suspend(struct iwl_priv *priv,
 
        iwl_trans_stop_device(trans(priv));
 
-       priv->shrd->wowlan = true;
+       priv->wowlan = true;
 
-       ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_WOWLAN);
+       ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN);
        if (ret)
                goto out;
 
@@ -1224,11 +1222,11 @@ int iwlagn_suspend(struct iwl_priv *priv,
                 * constraints. Since we're in the suspend path
                 * that isn't really a problem though.
                 */
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
                ieee80211_iter_keys(priv->hw, ctx->vif,
                                    iwlagn_wowlan_program_keys,
                                    &key_data);
-               mutex_lock(&priv->shrd->mutex);
+               mutex_lock(&priv->mutex);
                if (key_data.error) {
                        ret = -EIO;
                        goto out;
@@ -1243,13 +1241,13 @@ int iwlagn_suspend(struct iwl_priv *priv,
                                .len[0] = sizeof(key_data.rsc_tsc),
                        };
 
-                       ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd);
+                       ret = iwl_dvm_send_cmd(priv, &rsc_tsc_cmd);
                        if (ret)
                                goto out;
                }
 
                if (key_data.use_tkip) {
-                       ret = iwl_trans_send_cmd_pdu(trans(priv),
+                       ret = iwl_dvm_send_cmd_pdu(priv,
                                                 REPLY_WOWLAN_TKIP_PARAMS,
                                                 CMD_SYNC, sizeof(tkip_cmd),
                                                 &tkip_cmd);
@@ -1265,7 +1263,7 @@ int iwlagn_suspend(struct iwl_priv *priv,
                        kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
                        kek_kck_cmd.replay_ctr = priv->replay_ctr;
 
-                       ret = iwl_trans_send_cmd_pdu(trans(priv),
+                       ret = iwl_dvm_send_cmd_pdu(priv,
                                                 REPLY_WOWLAN_KEK_KCK_MATERIAL,
                                                 CMD_SYNC, sizeof(kek_kck_cmd),
                                                 &kek_kck_cmd);
@@ -1274,12 +1272,12 @@ int iwlagn_suspend(struct iwl_priv *priv,
                }
        }
 
-       ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC,
+       ret = iwl_dvm_send_cmd_pdu(priv, REPLY_D3_CONFIG, CMD_SYNC,
                                     sizeof(d3_cfg_cmd), &d3_cfg_cmd);
        if (ret)
                goto out;
 
-       ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER,
+       ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WOWLAN_WAKEUP_FILTER,
                                 CMD_SYNC, sizeof(wakeup_filter_cmd),
                                 &wakeup_filter_cmd);
        if (ret)
@@ -1291,3 +1289,41 @@ int iwlagn_suspend(struct iwl_priv *priv,
        return ret;
 }
 #endif
+
+int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
+{
+       if (iwl_is_rfkill(priv->shrd) || iwl_is_ctkill(priv->shrd)) {
+               IWL_WARN(priv, "Not sending command - %s KILL\n",
+                        iwl_is_rfkill(priv->shrd) ? "RF" : "CT");
+               return -EIO;
+       }
+
+       /*
+        * Synchronous commands from this op-mode must hold
+        * the mutex, this ensures we don't try to send two
+        * (or more) synchronous commands at a time.
+        */
+       if (cmd->flags & CMD_SYNC)
+               lockdep_assert_held(&priv->mutex);
+
+       if (priv->ucode_owner == IWL_OWNERSHIP_TM &&
+           !(cmd->flags & CMD_ON_DEMAND)) {
+               IWL_DEBUG_HC(priv, "tm own the uCode, no regular hcmd send\n");
+               return -EIO;
+       }
+
+       return iwl_trans_send_cmd(trans(priv), cmd);
+}
+
+int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id,
+                        u32 flags, u16 len, const void *data)
+{
+       struct iwl_host_cmd cmd = {
+               .id = id,
+               .len = { len, },
+               .data = { data, },
+               .flags = flags,
+       };
+
+       return iwl_dvm_send_cmd(priv, &cmd);
+}
index f88e2e33e2e874a5c6617914d4d793d5791ae207..9895b807246bb1343483ee5b3d0816004c4f8709 100644 (file)
@@ -38,6 +38,7 @@
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-agn.h"
+#include "iwl-op-mode.h"
 
 #define RS_NAME "iwl-agn-rs"
 
@@ -869,19 +870,16 @@ static void rs_bt_update_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
 {
        struct iwl_scale_tbl_info *tbl;
        bool full_concurrent = priv->bt_full_concurrent;
-       unsigned long flags;
 
        if (priv->bt_ant_couple_ok) {
                /*
                 * Is there a need to switch between
                 * full concurrency and 3-wire?
                 */
-               spin_lock_irqsave(&priv->shrd->lock, flags);
                if (priv->bt_ci_compliance && priv->bt_ant_couple_ok)
                        full_concurrent = true;
                else
                        full_concurrent = false;
-               spin_unlock_irqrestore(&priv->shrd->lock, flags);
        }
        if ((priv->bt_traffic_load != priv->last_bt_traffic_load) ||
            (priv->bt_full_concurrent != full_concurrent)) {
@@ -909,7 +907,8 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
        struct iwl_lq_sta *lq_sta = priv_sta;
        struct iwl_link_quality_cmd *table;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-       struct iwl_priv *priv = (struct iwl_priv *)priv_r;
+       struct iwl_op_mode *op_mode = (struct iwl_op_mode *)priv_r;
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        enum mac80211_rate_control_flags mac_flags;
        u32 tx_rate;
@@ -2737,7 +2736,9 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
 
        struct sk_buff *skb = txrc->skb;
        struct ieee80211_supported_band *sband = txrc->sband;
-       struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r;
+       struct iwl_op_mode *op_mode __maybe_unused =
+                       (struct iwl_op_mode *)priv_r;
+       struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode);
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct iwl_lq_sta *lq_sta = priv_sta;
        int rate_idx;
@@ -2805,9 +2806,10 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
                          gfp_t gfp)
 {
        struct iwl_station_priv *sta_priv = (struct iwl_station_priv *) sta->drv_priv;
-       struct iwl_priv *priv;
+       struct iwl_op_mode *op_mode __maybe_unused =
+                       (struct iwl_op_mode *)priv_rate;
+       struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode);
 
-       priv = (struct iwl_priv *)priv_rate;
        IWL_DEBUG_RATE(priv, "create station rate scale window\n");
 
        return &sta_priv->lq_sta;
@@ -3074,7 +3076,8 @@ static void rs_free(void *priv_rate)
 static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
                        void *priv_sta)
 {
-       struct iwl_priv *priv __maybe_unused = priv_r;
+       struct iwl_op_mode *op_mode __maybe_unused = priv_r;
+       struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode);
 
        IWL_DEBUG_RATE(priv, "enter\n");
        IWL_DEBUG_RATE(priv, "leave\n");
index aee7d060d317ab8ea557ffbc1a0ba271cd277240..521c820ea10ac717f0633462ae9246f5fb3729f8 100644 (file)
@@ -131,26 +131,27 @@ const char *get_cmd_string(u8 cmd)
  ******************************************************************************/
 
 static int iwlagn_rx_reply_error(struct iwl_priv *priv,
-                              struct iwl_rx_mem_buffer *rxb,
+                              struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
+       struct iwl_error_resp *err_resp = (void *)pkt->data;
 
        IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) "
                "seq 0x%04X ser 0x%08X\n",
-               le32_to_cpu(pkt->u.err_resp.error_type),
-               get_cmd_string(pkt->u.err_resp.cmd_id),
-               pkt->u.err_resp.cmd_id,
-               le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num),
-               le32_to_cpu(pkt->u.err_resp.error_info));
+               le32_to_cpu(err_resp->error_type),
+               get_cmd_string(err_resp->cmd_id),
+               err_resp->cmd_id,
+               le16_to_cpu(err_resp->bad_cmd_seq_num),
+               le32_to_cpu(err_resp->error_info));
        return 0;
 }
 
-static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
+static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
+       struct iwl_csa_notification *csa = (void *)pkt->data;
        /*
         * MULTI-FIXME
         * See iwlagn_mac_channel_switch.
@@ -177,11 +178,11 @@ static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
 
 
 static int iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv,
-                                         struct iwl_rx_mem_buffer *rxb,
+                                         struct iwl_rx_cmd_buffer *rxb,
                                          struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif);
+       struct iwl_spectrum_notification *report = (void *)pkt->data;
 
        if (!report->state) {
                IWL_DEBUG_11H(priv,
@@ -195,12 +196,12 @@ static int iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv,
 }
 
 static int iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv,
-                                 struct iwl_rx_mem_buffer *rxb,
+                                 struct iwl_rx_cmd_buffer *rxb,
                                  struct iwl_device_cmd *cmd)
 {
 #ifdef CONFIG_IWLWIFI_DEBUG
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
+       struct iwl_sleep_notification *sleep = (void *)pkt->data;
        IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
                     sleep->pm_sleep_mode, sleep->pm_wakeup_src);
 #endif
@@ -208,7 +209,7 @@ static int iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv,
 }
 
 static int iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
-                                            struct iwl_rx_mem_buffer *rxb,
+                                            struct iwl_rx_cmd_buffer *rxb,
                                             struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
@@ -217,16 +218,16 @@ static int iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
        IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
                        "notification for %s:\n", len,
                        get_cmd_string(pkt->hdr.cmd));
-       iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len);
+       iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->data, len);
        return 0;
 }
 
 static int iwlagn_rx_beacon_notif(struct iwl_priv *priv,
-                               struct iwl_rx_mem_buffer *rxb,
+                               struct iwl_rx_cmd_buffer *rxb,
                                struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwlagn_beacon_notif *beacon = (void *)pkt->u.raw;
+       struct iwlagn_beacon_notif *beacon = (void *)pkt->data;
 #ifdef CONFIG_IWLWIFI_DEBUG
        u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status);
        u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
@@ -266,6 +267,8 @@ static bool iwlagn_good_ack_health(struct iwl_priv *priv,
        if (priv->agg_tids_count)
                return true;
 
+       lockdep_assert_held(&priv->statistics.lock);
+
        old = &priv->statistics.tx;
 
        actual_delta = le32_to_cpu(cur->actual_ack_cnt) -
@@ -318,7 +321,7 @@ static bool iwlagn_good_plcp_health(struct iwl_priv *priv,
                                 unsigned int msecs)
 {
        int delta;
-       int threshold = cfg(priv)->base_params->plcp_delta_threshold;
+       int threshold = priv->plcp_delta_threshold;
 
        if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {
                IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");
@@ -487,7 +490,7 @@ iwlagn_accumulative_statistics(struct iwl_priv *priv,
 #endif
 
 static int iwlagn_rx_statistics(struct iwl_priv *priv,
-                             struct iwl_rx_mem_buffer *rxb,
+                             struct iwl_rx_cmd_buffer *rxb,
                              struct iwl_device_cmd *cmd)
 {
        unsigned long stamp = jiffies;
@@ -509,9 +512,11 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv,
        IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n",
                     len);
 
+       spin_lock(&priv->statistics.lock);
+
        if (len == sizeof(struct iwl_bt_notif_statistics)) {
                struct iwl_bt_notif_statistics *stats;
-               stats = &pkt->u.stats_bt;
+               stats = (void *)&pkt->data;
                flag = &stats->flag;
                common = &stats->general.common;
                rx_non_phy = &stats->rx.general.common;
@@ -529,7 +534,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv,
 #endif
        } else if (len == sizeof(struct iwl_notif_statistics)) {
                struct iwl_notif_statistics *stats;
-               stats = &pkt->u.stats;
+               stats = (void *)&pkt->data;
                flag = &stats->flag;
                common = &stats->general.common;
                rx_non_phy = &stats->rx.general;
@@ -542,6 +547,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv,
                WARN_ONCE(1, "len %d doesn't match BT (%zu) or normal (%zu)\n",
                          len, sizeof(struct iwl_bt_notif_statistics),
                          sizeof(struct iwl_notif_statistics));
+               spin_unlock(&priv->statistics.lock);
                return 0;
        }
 
@@ -585,16 +591,20 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv,
        }
        if (cfg(priv)->lib->temperature && change)
                cfg(priv)->lib->temperature(priv);
+
+       spin_unlock(&priv->statistics.lock);
+
        return 0;
 }
 
 static int iwlagn_rx_reply_statistics(struct iwl_priv *priv,
-                                   struct iwl_rx_mem_buffer *rxb,
+                                   struct iwl_rx_cmd_buffer *rxb,
                                    struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
+       struct iwl_notif_statistics *stats = (void *)pkt->data;
 
-       if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) {
+       if (le32_to_cpu(stats->flag) & UCODE_STATISTICS_CLEAR_MSK) {
 #ifdef CONFIG_IWLWIFI_DEBUGFS
                memset(&priv->accum_stats, 0,
                        sizeof(priv->accum_stats));
@@ -612,11 +622,12 @@ static int iwlagn_rx_reply_statistics(struct iwl_priv *priv,
 /* Handle notification from uCode that card's power state is changing
  * due to software, hardware, or critical temperature RFKILL */
 static int iwlagn_rx_card_state_notif(struct iwl_priv *priv,
-                                   struct iwl_rx_mem_buffer *rxb,
+                                   struct iwl_rx_cmd_buffer *rxb,
                                    struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
+       struct iwl_card_state_notif *card_state_notif = (void *)pkt->data;
+       u32 flags = le32_to_cpu(card_state_notif->flags);
        unsigned long status = priv->shrd->status;
 
        IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",
@@ -665,14 +676,13 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv,
 }
 
 static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv,
-                                      struct iwl_rx_mem_buffer *rxb,
+                                      struct iwl_rx_cmd_buffer *rxb,
                                       struct iwl_device_cmd *cmd)
 
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_missed_beacon_notif *missed_beacon;
+       struct iwl_missed_beacon_notif *missed_beacon = (void *)pkt->data;
 
-       missed_beacon = &pkt->u.missed_beacon;
        if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) >
            priv->missed_beacon_threshold) {
                IWL_DEBUG_CALIB(priv,
@@ -690,13 +700,13 @@ static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv,
 /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
  * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
 static int iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,
-                               struct iwl_rx_mem_buffer *rxb,
+                               struct iwl_rx_cmd_buffer *rxb,
                                struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
 
        priv->last_phy_res_valid = true;
-       memcpy(&priv->last_phy_res, pkt->u.raw,
+       memcpy(&priv->last_phy_res, pkt->data,
               sizeof(struct iwl_rx_phy_res));
        return 0;
 }
@@ -757,12 +767,14 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
                                        struct ieee80211_hdr *hdr,
                                        u16 len,
                                        u32 ampdu_status,
-                                       struct iwl_rx_mem_buffer *rxb,
+                                       struct iwl_rx_cmd_buffer *rxb,
                                        struct ieee80211_rx_status *stats)
 {
        struct sk_buff *skb;
        __le16 fc = hdr->frame_control;
        struct iwl_rxon_context *ctx;
+       struct page *p;
+       int offset;
 
        /* We only process data packets if the interface is open */
        if (unlikely(!priv->is_open)) {
@@ -782,7 +794,9 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
                return;
        }
 
-       skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len);
+       offset = (void *)hdr - rxb_addr(rxb);
+       p = rxb_steal_page(rxb);
+       skb_add_rx_frag(skb, 0, p, offset, len);
 
        iwl_update_stats(priv, false, fc, len);
 
@@ -809,7 +823,6 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
        memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
 
        ieee80211_rx(priv->hw, skb);
-       rxb->page = NULL;
 }
 
 static u32 iwlagn_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
@@ -915,7 +928,7 @@ static int iwlagn_calc_rssi(struct iwl_priv *priv,
 /* Called for REPLY_RX (legacy ABG frames), or
  * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
 static int iwlagn_rx_reply_rx(struct iwl_priv *priv,
-                           struct iwl_rx_mem_buffer *rxb,
+                           struct iwl_rx_cmd_buffer *rxb,
                            struct iwl_device_cmd *cmd)
 {
        struct ieee80211_hdr *header;
@@ -938,12 +951,12 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv,
         * received.
         */
        if (pkt->hdr.cmd == REPLY_RX) {
-               phy_res = (struct iwl_rx_phy_res *)pkt->u.raw;
-               header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res)
+               phy_res = (struct iwl_rx_phy_res *)pkt->data;
+               header = (struct ieee80211_hdr *)(pkt->data + sizeof(*phy_res)
                                + phy_res->cfg_phy_cnt);
 
                len = le16_to_cpu(phy_res->byte_count);
-               rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) +
+               rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*phy_res) +
                                phy_res->cfg_phy_cnt + len);
                ampdu_status = le32_to_cpu(rx_pkt_status);
        } else {
@@ -952,10 +965,10 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv,
                        return 0;
                }
                phy_res = &priv->last_phy_res;
-               amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw;
-               header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu));
+               amsdu = (struct iwl_rx_mpdu_res_start *)pkt->data;
+               header = (struct ieee80211_hdr *)(pkt->data + sizeof(*amsdu));
                len = le16_to_cpu(amsdu->byte_count);
-               rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len);
+               rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*amsdu) + len);
                ampdu_status = iwlagn_translate_rx_status(priv,
                                                le32_to_cpu(rx_pkt_status));
        }
@@ -1035,12 +1048,12 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv,
 }
 
 static int iwlagn_rx_noa_notification(struct iwl_priv *priv,
-                                     struct iwl_rx_mem_buffer *rxb,
+                                     struct iwl_rx_cmd_buffer *rxb,
                                      struct iwl_device_cmd *cmd)
 {
        struct iwl_wipan_noa_data *new_data, *old_data;
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->u.raw;
+       struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->data;
 
        /* no condition -- we're in softirq */
        old_data = rcu_dereference_protected(priv->noa_data, true);
@@ -1086,7 +1099,7 @@ static int iwlagn_rx_noa_notification(struct iwl_priv *priv,
  */
 void iwl_setup_rx_handlers(struct iwl_priv *priv)
 {
-       int (**handlers)(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
+       int (**handlers)(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd);
 
        handlers = priv->rx_handlers;
@@ -1131,9 +1144,7 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv)
        priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx;
 
        /* set up notification wait support */
-       spin_lock_init(&priv->shrd->notif_wait_lock);
-       INIT_LIST_HEAD(&priv->shrd->notif_waits);
-       init_waitqueue_head(&priv->shrd->notif_waitq);
+       iwl_notification_wait_init(&priv->notif_wait);
 
        /* Set up BT Rx handlers */
        if (cfg(priv)->lib->bt_rx_handler_setup)
@@ -1141,10 +1152,11 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv)
 
 }
 
-int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
-                    struct iwl_device_cmd *cmd)
+int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
+                   struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
        int err = 0;
 
        /*
@@ -1152,28 +1164,10 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
         * even if the RX handler consumes the RXB we have
         * access to it in the notification wait entry.
         */
-       if (!list_empty(&priv->shrd->notif_waits)) {
-               struct iwl_notification_wait *w;
-
-               spin_lock(&priv->shrd->notif_wait_lock);
-               list_for_each_entry(w, &priv->shrd->notif_waits, list) {
-                       if (w->cmd != pkt->hdr.cmd)
-                               continue;
-                       IWL_DEBUG_RX(priv,
-                               "Notif: %s, 0x%02x - wake the callers up\n",
-                               get_cmd_string(pkt->hdr.cmd),
-                               pkt->hdr.cmd);
-                       w->triggered = true;
-                       if (w->fn)
-                               w->fn(trans(priv), pkt, w->fn_data);
-               }
-               spin_unlock(&priv->shrd->notif_wait_lock);
-
-               wake_up_all(&priv->shrd->notif_waitq);
-       }
+       iwl_notification_wait_notify(&priv->notif_wait, pkt);
 
        if (priv->pre_rx_handler &&
-           priv->shrd->ucode_owner == IWL_OWNERSHIP_TM)
+           priv->ucode_owner == IWL_OWNERSHIP_TM)
                priv->pre_rx_handler(priv, rxb);
        else {
                /* Based on type of command response or notification,
index 35dd7e364b4652831d1d2b1fc7b7c5bb20415504..9d955fa387e51958f04e0e345c56b4505cd3c96f 100644 (file)
@@ -39,7 +39,7 @@ static int iwlagn_disable_bss(struct iwl_priv *priv,
        int ret;
 
        send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
-       ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd,
+       ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd,
                                CMD_SYNC, sizeof(*send), send);
 
        send->filter_flags = old_filter;
@@ -60,13 +60,13 @@ static int iwlagn_disable_pan(struct iwl_priv *priv,
        u8 old_dev_type = send->dev_type;
        int ret;
 
-       iwl_init_notification_wait(priv->shrd, &disable_wait,
-                                     REPLY_WIPAN_DEACTIVATION_COMPLETE,
-                                     NULL, NULL);
+       iwl_init_notification_wait(&priv->notif_wait, &disable_wait,
+                                  REPLY_WIPAN_DEACTIVATION_COMPLETE,
+                                  NULL, NULL);
 
        send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
        send->dev_type = RXON_DEV_TYPE_P2P;
-       ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd,
+       ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd,
                                CMD_SYNC, sizeof(*send), send);
 
        send->filter_flags = old_filter;
@@ -74,9 +74,10 @@ static int iwlagn_disable_pan(struct iwl_priv *priv,
 
        if (ret) {
                IWL_ERR(priv, "Error disabling PAN (%d)\n", ret);
-               iwl_remove_notification(priv->shrd, &disable_wait);
+               iwl_remove_notification(&priv->notif_wait, &disable_wait);
        } else {
-               ret = iwl_wait_notification(priv->shrd, &disable_wait, HZ);
+               ret = iwl_wait_notification(&priv->notif_wait,
+                                           &disable_wait, HZ);
                if (ret)
                        IWL_ERR(priv, "Timed out waiting for PAN disable\n");
        }
@@ -92,7 +93,7 @@ static int iwlagn_disconn_pan(struct iwl_priv *priv,
        int ret;
 
        send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
-       ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd, CMD_SYNC,
+       ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC,
                                sizeof(*send), send);
 
        send->filter_flags = old_filter;
@@ -121,7 +122,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv,
                      ctx->qos_data.qos_active,
                      ctx->qos_data.def_qos_parm.qos_flags);
 
-       ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->qos_cmd, CMD_SYNC,
+       ret = iwl_dvm_send_cmd_pdu(priv, ctx->qos_cmd, CMD_SYNC,
                               sizeof(struct iwl_qosparam_cmd),
                               &ctx->qos_data.def_qos_parm);
        if (ret)
@@ -131,7 +132,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv,
 static int iwlagn_update_beacon(struct iwl_priv *priv,
                                struct ieee80211_vif *vif)
 {
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        dev_kfree_skb(priv->beacon_skb);
        priv->beacon_skb = ieee80211_beacon_get(priv->hw, vif);
@@ -180,7 +181,7 @@ static int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
                 ctx->staging.ofdm_ht_triple_stream_basic_rates;
        rxon_assoc.acquisition_data = ctx->staging.acquisition_data;
 
-       ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_assoc_cmd,
+       ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_assoc_cmd,
                                CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc);
        return ret;
 }
@@ -266,7 +267,7 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
         * Associated RXON doesn't clear the station table in uCode,
         * so we don't need to restore stations etc. after this.
         */
-       ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd, CMD_SYNC,
+       ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC,
                      sizeof(struct iwl_rxon_cmd), &ctx->staging);
        if (ret) {
                IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
@@ -274,8 +275,6 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
        }
        memcpy(active, &ctx->staging, sizeof(*active));
 
-       iwl_reprogram_ap_sta(priv, ctx);
-
        /* IBSS beacon needs to be sent after setting assoc */
        if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC))
                if (iwlagn_update_beacon(priv, ctx->vif))
@@ -315,7 +314,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv)
 
        BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
        ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
@@ -387,7 +386,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv)
        cmd.slots[0].width = cpu_to_le16(slot0);
        cmd.slots[1].width = cpu_to_le16(slot1);
 
-       ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WIPAN_PARAMS, CMD_SYNC,
+       ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC,
                        sizeof(cmd), &cmd);
        if (ret)
                IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
@@ -420,10 +419,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
        bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
-
-       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
-               return -EINVAL;
+       lockdep_assert_held(&priv->mutex);
 
        if (!iwl_is_alive(priv->shrd))
                return -EBUSY;
@@ -434,10 +430,6 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
        if (!ctx->is_active)
                return 0;
 
-       /* override BSSID if necessary due to preauth */
-       if (ctx->preauth_bssid)
-               memcpy(ctx->staging.bssid_addr, ctx->bssid, ETH_ALEN);
-
        /* always get timestamp with Rx frame */
        ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
 
@@ -445,8 +437,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
         * force CTS-to-self frames protection if RTS-CTS is not preferred
         * one aggregation protection method
         */
-       if (!(cfg(priv)->ht_params &&
-             cfg(priv)->ht_params->use_rts_for_aggregation))
+       if (!hw_params(priv).use_rts_for_aggregation)
                ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
 
        if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) ||
@@ -549,7 +540,7 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf,
 
 int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx;
        struct ieee80211_conf *conf = &hw->conf;
        struct ieee80211_channel *channel = conf->channel;
@@ -558,10 +549,7 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
 
        IWL_DEBUG_MAC80211(priv, "enter: changed %#x", changed);
 
-       mutex_lock(&priv->shrd->mutex);
-
-       if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
-               goto out;
+       mutex_lock(&priv->mutex);
 
        if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) {
                IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
@@ -590,8 +578,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
        }
 
        if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
-               unsigned long flags;
-
                ch_info = iwl_get_channel_info(priv, channel->band,
                                               channel->hw_value);
                if (!is_channel_valid(ch_info)) {
@@ -600,8 +586,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
                        goto out;
                }
 
-               spin_lock_irqsave(&priv->shrd->lock, flags);
-
                for_each_context(priv, ctx) {
                        /* Configure HT40 channels */
                        if (ctx->ht.enabled != conf_is_ht(conf))
@@ -636,8 +620,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
                                               ctx->vif);
                }
 
-               spin_unlock_irqrestore(&priv->shrd->lock, flags);
-
                iwl_update_bcast_stations(priv);
 
                /*
@@ -668,7 +650,7 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
                iwlagn_commit_rxon(priv, ctx);
        }
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return ret;
@@ -685,7 +667,7 @@ static void iwlagn_check_needed_chains(struct iwl_priv *priv,
        struct ieee80211_sta_ht_cap *ht_cap;
        bool need_multiple;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        switch (vif->type) {
        case NL80211_IFTYPE_STATION:
@@ -789,7 +771,7 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
                memset(&cmd, 0, sizeof(cmd));
                iwl_set_calib_hdr(&cmd.hdr,
                        priv->phy_calib_chain_noise_reset_cmd);
-               ret = iwl_trans_send_cmd_pdu(trans(priv),
+               ret = iwl_dvm_send_cmd_pdu(priv,
                                        REPLY_PHY_CALIBRATION_CMD,
                                        CMD_SYNC, sizeof(cmd), &cmd);
                if (ret)
@@ -805,22 +787,22 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
                             struct ieee80211_bss_conf *bss_conf,
                             u32 changes)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
        int ret;
        bool force = false;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (unlikely(!iwl_is_ready(priv->shrd))) {
                IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
                return;
         }
 
        if (unlikely(!ctx->vif)) {
                IWL_DEBUG_MAC80211(priv, "leave - vif is NULL\n");
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
                return;
        }
 
@@ -932,7 +914,6 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
                if (!priv->disable_chain_noise_cal)
                        iwlagn_chain_noise_reset(priv);
                priv->start_calib = 1;
-               WARN_ON(ctx->preauth_bssid);
        }
 
        if (changes & BSS_CHANGED_IBSS) {
@@ -950,7 +931,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
                        IWL_ERR(priv, "Error sending IBSS beacon\n");
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 void iwlagn_post_scan(struct iwl_priv *priv)
index d6aab00272b9a1a5a2817084bbd0bf61321feed4..cf5cc1060cf41f585814831221837fc0c127281f 100644 (file)
@@ -26,7 +26,7 @@
  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  *
  *****************************************************************************/
-
+#include <linux/etherdevice.h>
 #include <net/mac80211.h>
 
 #include "iwl-dev.h"
 #include "iwl-agn.h"
 #include "iwl-trans.h"
 
-/* priv->shrd->sta_lock must be held */
 static int iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
 {
+       lockdep_assert_held(&priv->sta_lock);
+
        if (sta_id >= IWLAGN_STATION_COUNT) {
                IWL_ERR(priv, "invalid sta_id %u", sta_id);
                return -EINVAL;
@@ -63,8 +64,8 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
                                    struct iwl_addsta_cmd *addsta,
                                    struct iwl_rx_packet *pkt)
 {
+       struct iwl_add_sta_resp *add_sta_resp = (void *)pkt->data;
        u8 sta_id = addsta->sta.sta_id;
-       unsigned long flags;
        int ret = -EIO;
 
        if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
@@ -76,9 +77,9 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
        IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n",
                       sta_id);
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock(&priv->sta_lock);
 
-       switch (pkt->u.add_sta.status) {
+       switch (add_sta_resp->status) {
        case ADD_STA_SUCCESS_MSK:
                IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
                ret = iwl_sta_ucode_activate(priv, sta_id);
@@ -97,7 +98,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
                break;
        default:
                IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n",
-                               pkt->u.add_sta.status);
+                               add_sta_resp->status);
                break;
        }
 
@@ -118,12 +119,12 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
                       priv->stations[sta_id].sta.mode ==
                       STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
                       addsta->sta.addr);
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock(&priv->sta_lock);
 
        return ret;
 }
 
-int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
+int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
@@ -153,14 +154,14 @@ int iwl_send_add_sta(struct iwl_priv *priv,
                might_sleep();
        }
 
-       ret = iwl_trans_send_cmd(trans(priv), &cmd);
+       ret = iwl_dvm_send_cmd(priv, &cmd);
 
        if (ret || (flags & CMD_ASYNC))
                return ret;
        /*else the command was successfully sent in SYNC mode, need to free
         * the reply page */
 
-       iwl_free_pages(priv->shrd, cmd.reply_page);
+       iwl_free_resp(&cmd);
 
        if (cmd.handler_status)
                IWL_ERR(priv, "%s - error in the CMD response %d", __func__,
@@ -169,34 +170,38 @@ int iwl_send_add_sta(struct iwl_priv *priv,
        return cmd.handler_status;
 }
 
-static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
-                                  struct ieee80211_sta *sta,
-                                  struct iwl_rxon_context *ctx)
+static void iwl_sta_calc_ht_flags(struct iwl_priv *priv,
+                                 struct ieee80211_sta *sta,
+                                 struct iwl_rxon_context *ctx,
+                                 __le32 *flags, __le32 *mask)
 {
        struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap;
-       __le32 sta_flags;
        u8 mimo_ps_mode;
 
+       *mask = STA_FLG_RTS_MIMO_PROT_MSK |
+               STA_FLG_MIMO_DIS_MSK |
+               STA_FLG_HT40_EN_MSK |
+               STA_FLG_MAX_AGG_SIZE_MSK |
+               STA_FLG_AGG_MPDU_DENSITY_MSK;
+       *flags = 0;
+
        if (!sta || !sta_ht_inf->ht_supported)
-               goto done;
+               return;
 
        mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
-       IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n",
+
+       IWL_DEBUG_INFO(priv, "STA %pM SM PS mode: %s\n",
                        (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ?
                        "static" :
                        (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ?
                        "dynamic" : "disabled");
 
-       sta_flags = priv->stations[index].sta.station_flags;
-
-       sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK);
-
        switch (mimo_ps_mode) {
        case WLAN_HT_CAP_SM_PS_STATIC:
-               sta_flags |= STA_FLG_MIMO_DIS_MSK;
+               *flags |= STA_FLG_MIMO_DIS_MSK;
                break;
        case WLAN_HT_CAP_SM_PS_DYNAMIC:
-               sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK;
+               *flags |= STA_FLG_RTS_MIMO_PROT_MSK;
                break;
        case WLAN_HT_CAP_SM_PS_DISABLED:
                break;
@@ -205,20 +210,53 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
                break;
        }
 
-       sta_flags |= cpu_to_le32(
-             (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS);
+       *flags |= cpu_to_le32(
+               (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS);
 
-       sta_flags |= cpu_to_le32(
-             (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
+       *flags |= cpu_to_le32(
+               (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
 
        if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap))
-               sta_flags |= STA_FLG_HT40_EN_MSK;
-       else
-               sta_flags &= ~STA_FLG_HT40_EN_MSK;
+               *flags |= STA_FLG_HT40_EN_MSK;
+}
+
+int iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
+                     struct ieee80211_sta *sta)
+{
+       u8 sta_id = iwl_sta_id(sta);
+       __le32 flags, mask;
+       struct iwl_addsta_cmd cmd;
+
+       if (WARN_ON_ONCE(sta_id == IWL_INVALID_STATION))
+               return -EINVAL;
+
+       iwl_sta_calc_ht_flags(priv, sta, ctx, &flags, &mask);
+
+       spin_lock_bh(&priv->sta_lock);
+       priv->stations[sta_id].sta.station_flags &= ~mask;
+       priv->stations[sta_id].sta.station_flags |= flags;
+       spin_unlock_bh(&priv->sta_lock);
 
-       priv->stations[index].sta.station_flags = sta_flags;
- done:
-       return;
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.mode = STA_CONTROL_MODIFY_MSK;
+       cmd.station_flags_msk = mask;
+       cmd.station_flags = flags;
+       cmd.sta.sta_id = sta_id;
+
+       return iwl_send_add_sta(priv, &cmd, CMD_SYNC);
+}
+
+static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
+                                  struct ieee80211_sta *sta,
+                                  struct iwl_rxon_context *ctx)
+{
+       __le32 flags, mask;
+
+       iwl_sta_calc_ht_flags(priv, sta, ctx, &flags, &mask);
+
+       lockdep_assert_held(&priv->sta_lock);
+       priv->stations[index].sta.station_flags &= ~mask;
+       priv->stations[index].sta.station_flags |= flags;
 }
 
 /**
@@ -317,18 +355,17 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                           const u8 *addr, bool is_ap,
                           struct ieee80211_sta *sta, u8 *sta_id_r)
 {
-       unsigned long flags_spin;
        int ret = 0;
        u8 sta_id;
        struct iwl_addsta_cmd sta_cmd;
 
        *sta_id_r = 0;
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+       spin_lock_bh(&priv->sta_lock);
        sta_id = iwl_prep_station(priv, ctx, addr, is_ap, sta);
        if (sta_id == IWL_INVALID_STATION) {
                IWL_ERR(priv, "Unable to prepare station %pM for addition\n",
                        addr);
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+               spin_unlock_bh(&priv->sta_lock);
                return -EINVAL;
        }
 
@@ -340,7 +377,7 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
        if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
                IWL_DEBUG_INFO(priv, "STA %d already in process of being "
                               "added.\n", sta_id);
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+               spin_unlock_bh(&priv->sta_lock);
                return -EEXIST;
        }
 
@@ -348,24 +385,24 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
            (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
                IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not "
                                "adding again.\n", sta_id, addr);
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+               spin_unlock_bh(&priv->sta_lock);
                return -EEXIST;
        }
 
        priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS;
        memcpy(&sta_cmd, &priv->stations[sta_id].sta,
               sizeof(struct iwl_addsta_cmd));
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+       spin_unlock_bh(&priv->sta_lock);
 
        /* Add station to device's station table */
        ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
        if (ret) {
-               spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+               spin_lock_bh(&priv->sta_lock);
                IWL_ERR(priv, "Adding station %pM failed.\n",
                        priv->stations[sta_id].sta.sta.addr);
                priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
                priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+               spin_unlock_bh(&priv->sta_lock);
        }
        *sta_id_r = sta_id;
        return ret;
@@ -373,11 +410,11 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
 
 /**
  * iwl_sta_ucode_deactivate - deactivate ucode status for a station
- *
- * priv->shrd->sta_lock must be held
  */
 static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id)
 {
+       lockdep_assert_held(&priv->sta_lock);
+
        /* Ucode must be active and driver must be non active */
        if ((priv->stations[sta_id].used &
             (IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) !=
@@ -396,8 +433,6 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
 {
        struct iwl_rx_packet *pkt;
        int ret;
-
-       unsigned long flags_spin;
        struct iwl_rem_sta_cmd rm_sta_cmd;
 
        struct iwl_host_cmd cmd = {
@@ -413,12 +448,12 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
 
        cmd.flags |= CMD_WANT_SKB;
 
-       ret = iwl_trans_send_cmd(trans(priv), &cmd);
+       ret = iwl_dvm_send_cmd(priv, &cmd);
 
        if (ret)
                return ret;
 
-       pkt = (struct iwl_rx_packet *)cmd.reply_page;
+       pkt = cmd.resp_pkt;
        if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
                IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n",
                          pkt->hdr.flags);
@@ -426,14 +461,13 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
        }
 
        if (!ret) {
-               switch (pkt->u.rem_sta.status) {
+               struct iwl_rem_sta_resp *rem_sta_resp = (void *)pkt->data;
+               switch (rem_sta_resp->status) {
                case REM_STA_SUCCESS_MSK:
                        if (!temporary) {
-                               spin_lock_irqsave(&priv->shrd->sta_lock,
-                                       flags_spin);
+                               spin_lock_bh(&priv->sta_lock);
                                iwl_sta_ucode_deactivate(priv, sta_id);
-                               spin_unlock_irqrestore(&priv->shrd->sta_lock,
-                                       flags_spin);
+                               spin_unlock_bh(&priv->sta_lock);
                        }
                        IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n");
                        break;
@@ -443,7 +477,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
                        break;
                }
        }
-       iwl_free_pages(priv->shrd, cmd.reply_page);
+       iwl_free_resp(&cmd);
 
        return ret;
 }
@@ -454,7 +488,6 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
 int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
                       const u8 *addr)
 {
-       unsigned long flags;
        u8 tid;
 
        if (!iwl_is_ready(priv->shrd)) {
@@ -475,7 +508,7 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
        if (WARN_ON(sta_id == IWL_INVALID_STATION))
                return -EINVAL;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
 
        if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
                IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n",
@@ -505,11 +538,11 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
        if (WARN_ON(priv->num_stations < 0))
                priv->num_stations = 0;
 
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return iwl_send_remove_station(priv, addr, sta_id, false);
 out_err:
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
        return -EINVAL;
 }
 
@@ -525,12 +558,11 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv,
                              struct iwl_rxon_context *ctx)
 {
        int i;
-       unsigned long flags_spin;
        bool cleared = false;
 
        IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n");
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+       spin_lock_bh(&priv->sta_lock);
        for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
                if (ctx && ctx->ctxid != priv->stations[i].ctxid)
                        continue;
@@ -542,7 +574,7 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv,
                        cleared = true;
                }
        }
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+       spin_unlock_bh(&priv->sta_lock);
 
        if (!cleared)
                IWL_DEBUG_INFO(priv,
@@ -561,7 +593,6 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 {
        struct iwl_addsta_cmd sta_cmd;
        struct iwl_link_quality_cmd lq;
-       unsigned long flags_spin;
        int i;
        bool found = false;
        int ret;
@@ -574,7 +605,7 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
        }
 
        IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+       spin_lock_bh(&priv->sta_lock);
        for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
                if (ctx->ctxid != priv->stations[i].ctxid)
                        continue;
@@ -594,27 +625,24 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                               sizeof(struct iwl_addsta_cmd));
                        send_lq = false;
                        if (priv->stations[i].lq) {
-                               if (priv->shrd->wowlan)
+                               if (priv->wowlan)
                                        iwl_sta_fill_lq(priv, ctx, i, &lq);
                                else
                                        memcpy(&lq, priv->stations[i].lq,
                                               sizeof(struct iwl_link_quality_cmd));
                                send_lq = true;
                        }
-                       spin_unlock_irqrestore(&priv->shrd->sta_lock,
-                                              flags_spin);
+                       spin_unlock_bh(&priv->sta_lock);
                        ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
                        if (ret) {
-                               spin_lock_irqsave(&priv->shrd->sta_lock,
-                                                 flags_spin);
+                               spin_lock_bh(&priv->sta_lock);
                                IWL_ERR(priv, "Adding station %pM failed.\n",
                                        priv->stations[i].sta.sta.addr);
                                priv->stations[i].used &=
                                                ~IWL_STA_DRIVER_ACTIVE;
                                priv->stations[i].used &=
                                                ~IWL_STA_UCODE_INPROGRESS;
-                               spin_unlock_irqrestore(&priv->shrd->sta_lock,
-                                                      flags_spin);
+                               spin_unlock_bh(&priv->sta_lock);
                        }
                        /*
                         * Rate scaling has already been initialized, send
@@ -623,12 +651,12 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                        if (send_lq)
                                iwl_send_lq_cmd(priv, ctx, &lq,
                                                CMD_SYNC, true);
-                       spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+                       spin_lock_bh(&priv->sta_lock);
                        priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
                }
        }
 
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+       spin_unlock_bh(&priv->sta_lock);
        if (!found)
                IWL_DEBUG_INFO(priv, "Restoring all known stations .... "
                        "no stations to be restored.\n");
@@ -637,52 +665,6 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                        "complete.\n");
 }
 
-void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
-{
-       unsigned long flags;
-       int sta_id = ctx->ap_sta_id;
-       int ret;
-       struct iwl_addsta_cmd sta_cmd;
-       struct iwl_link_quality_cmd lq;
-       bool active, have_lq = false;
-
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
-       if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
-               return;
-       }
-
-       memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd));
-       sta_cmd.mode = 0;
-       if (priv->stations[sta_id].lq) {
-               memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq));
-               have_lq = true;
-       }
-
-       active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE;
-       priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
-
-       if (active) {
-               ret = iwl_send_remove_station(
-                       priv, priv->stations[sta_id].sta.sta.addr,
-                       sta_id, true);
-               if (ret)
-                       IWL_ERR(priv, "failed to remove STA %pM (%d)\n",
-                               priv->stations[sta_id].sta.sta.addr, ret);
-       }
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
-       priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
-
-       ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
-       if (ret)
-               IWL_ERR(priv, "failed to re-add STA %pM (%d)\n",
-                       priv->stations[sta_id].sta.sta.addr, ret);
-       if (have_lq)
-               iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true);
-}
-
 int iwl_get_free_ucode_key_offset(struct iwl_priv *priv)
 {
        int i;
@@ -696,10 +678,9 @@ int iwl_get_free_ucode_key_offset(struct iwl_priv *priv)
 
 void iwl_dealloc_bcast_stations(struct iwl_priv *priv)
 {
-       unsigned long flags;
        int i;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
                if (!(priv->stations[i].used & IWL_STA_BCAST))
                        continue;
@@ -711,7 +692,7 @@ void iwl_dealloc_bcast_stations(struct iwl_priv *priv)
                kfree(priv->stations[i].lq);
                priv->stations[i].lq = NULL;
        }
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
@@ -783,8 +764,6 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                    struct iwl_link_quality_cmd *lq, u8 flags, bool init)
 {
        int ret = 0;
-       unsigned long flags_spin;
-
        struct iwl_host_cmd cmd = {
                .id = REPLY_TX_LINK_QUALITY_CMD,
                .len = { sizeof(struct iwl_link_quality_cmd), },
@@ -796,19 +775,19 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                return -EINVAL;
 
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+       spin_lock_bh(&priv->sta_lock);
        if (!(priv->stations[lq->sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+               spin_unlock_bh(&priv->sta_lock);
                return -EINVAL;
        }
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+       spin_unlock_bh(&priv->sta_lock);
 
        iwl_dump_lq_cmd(priv, lq);
        if (WARN_ON(init && (cmd.flags & CMD_ASYNC)))
                return -EINVAL;
 
        if (is_lq_table_valid(priv, ctx, lq))
-               ret = iwl_trans_send_cmd(trans(priv), &cmd);
+               ret = iwl_dvm_send_cmd(priv, &cmd);
        else
                ret = -EINVAL;
 
@@ -819,9 +798,9 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                IWL_DEBUG_INFO(priv, "init LQ command complete, "
                               "clearing sta addition status for sta %d\n",
                               lq->sta_id);
-               spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin);
+               spin_lock_bh(&priv->sta_lock);
                priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin);
+               spin_unlock_bh(&priv->sta_lock);
        }
        return ret;
 }
@@ -834,7 +813,7 @@ void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
        u32 rate_flags = 0;
        __le32 rate_n_flags;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        memset(link_cmd, 0, sizeof(*link_cmd));
 
@@ -906,7 +885,6 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv,
        int ret;
        u8 sta_id;
        struct iwl_link_quality_cmd *link_cmd;
-       unsigned long flags;
 
        if (sta_id_r)
                *sta_id_r = IWL_INVALID_STATION;
@@ -920,9 +898,9 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv,
        if (sta_id_r)
                *sta_id_r = sta_id;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        priv->stations[sta_id].used |= IWL_STA_LOCAL;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        /* Set up default rate scaling table in device's station table */
        link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id);
@@ -937,9 +915,9 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv,
        if (ret)
                IWL_ERR(priv, "Link quality command failed (%d)\n", ret);
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        priv->stations[sta_id].lq = link_cmd;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return 0;
 }
@@ -994,7 +972,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv,
        cmd.len[0] = cmd_size;
 
        if (not_empty || send_if_empty)
-               return iwl_trans_send_cmd(trans(priv), &cmd);
+               return iwl_dvm_send_cmd(priv, &cmd);
        else
                return 0;
 }
@@ -1002,7 +980,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv,
 int iwl_restore_default_wep_keys(struct iwl_priv *priv,
                                 struct iwl_rxon_context *ctx)
 {
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        return iwl_send_static_wepkey_cmd(priv, ctx, false);
 }
@@ -1013,7 +991,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
 {
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
                      keyconf->keyidx);
@@ -1038,7 +1016,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
 {
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (keyconf->keylen != WEP_KEY_LEN_128 &&
            keyconf->keylen != WEP_KEY_LEN_64) {
@@ -1080,32 +1058,19 @@ static u8 iwlagn_key_sta_id(struct iwl_priv *priv,
                            struct ieee80211_sta *sta)
 {
        struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
-       u8 sta_id = IWL_INVALID_STATION;
 
        if (sta)
-               sta_id = iwl_sta_id(sta);
+               return iwl_sta_id(sta);
 
        /*
         * The device expects GTKs for station interfaces to be
         * installed as GTKs for the AP station. If we have no
         * station ID, then use the ap_sta_id in that case.
         */
-       if (!sta && vif && vif_priv->ctx) {
-               switch (vif->type) {
-               case NL80211_IFTYPE_STATION:
-                       sta_id = vif_priv->ctx->ap_sta_id;
-                       break;
-               default:
-                       /*
-                        * In all other cases, the key will be
-                        * used either for TX only or is bound
-                        * to a station already.
-                        */
-                       break;
-               }
-       }
+       if (vif->type == NL80211_IFTYPE_STATION && vif_priv->ctx)
+               return vif_priv->ctx->ap_sta_id;
 
-       return sta_id;
+       return IWL_INVALID_STATION;
 }
 
 static int iwlagn_send_sta_key(struct iwl_priv *priv,
@@ -1113,14 +1078,13 @@ static int iwlagn_send_sta_key(struct iwl_priv *priv,
                               u8 sta_id, u32 tkip_iv32, u16 *tkip_p1k,
                               u32 cmd_flags)
 {
-       unsigned long flags;
        __le16 key_flags;
        struct iwl_addsta_cmd sta_cmd;
        int i;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd));
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        key_flags = cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
        key_flags |= STA_KEY_FLG_MAP_KEY_MSK;
@@ -1187,24 +1151,24 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
                           struct ieee80211_key_conf *keyconf,
                           struct ieee80211_sta *sta)
 {
-       unsigned long flags;
        struct iwl_addsta_cmd sta_cmd;
        u8 sta_id = iwlagn_key_sta_id(priv, ctx->vif, sta);
+       __le16 key_flags;
 
        /* if station isn't there, neither is the key */
        if (sta_id == IWL_INVALID_STATION)
                return -ENOENT;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd));
        if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE))
                sta_id = IWL_INVALID_STATION;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        if (sta_id == IWL_INVALID_STATION)
                return 0;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        ctx->key_mapping_keys--;
 
@@ -1215,7 +1179,14 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
                IWL_ERR(priv, "offset %d not used in uCode key table.\n",
                        keyconf->hw_key_idx);
 
-       sta_cmd.key.key_flags = STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID;
+       key_flags = cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
+       key_flags |= STA_KEY_FLG_MAP_KEY_MSK | STA_KEY_FLG_NO_ENC |
+                    STA_KEY_FLG_INVALID;
+
+       if (!(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE))
+               key_flags |= STA_KEY_MULTICAST_MSK;
+
+       sta_cmd.key.key_flags = key_flags;
        sta_cmd.key.key_offset = WEP_INVALID_OFFSET;
        sta_cmd.sta.modify_mask = STA_MODIFY_KEY_MASK;
        sta_cmd.mode = STA_CONTROL_MODIFY_MSK;
@@ -1237,7 +1208,7 @@ int iwl_set_dynamic_key(struct iwl_priv *priv,
        if (sta_id == IWL_INVALID_STATION)
                return -EINVAL;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        keyconf->hw_key_idx = iwl_get_free_ucode_key_offset(priv);
        if (keyconf->hw_key_idx == WEP_INVALID_OFFSET)
@@ -1292,21 +1263,20 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv,
                               struct iwl_rxon_context *ctx)
 {
        struct iwl_link_quality_cmd *link_cmd;
-       unsigned long flags;
        u8 sta_id;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        sta_id = iwl_prep_station(priv, ctx, iwl_bcast_addr, false, NULL);
        if (sta_id == IWL_INVALID_STATION) {
                IWL_ERR(priv, "Unable to prepare broadcast station\n");
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+               spin_unlock_bh(&priv->sta_lock);
 
                return -EINVAL;
        }
 
        priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE;
        priv->stations[sta_id].used |= IWL_STA_BCAST;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id);
        if (!link_cmd) {
@@ -1315,9 +1285,9 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv,
                return -ENOMEM;
        }
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        priv->stations[sta_id].lq = link_cmd;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return 0;
 }
@@ -1331,7 +1301,6 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv,
 int iwl_update_bcast_station(struct iwl_priv *priv,
                             struct iwl_rxon_context *ctx)
 {
-       unsigned long flags;
        struct iwl_link_quality_cmd *link_cmd;
        u8 sta_id = ctx->bcast_sta_id;
 
@@ -1341,13 +1310,13 @@ int iwl_update_bcast_station(struct iwl_priv *priv,
                return -ENOMEM;
        }
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        if (priv->stations[sta_id].lq)
                kfree(priv->stations[sta_id].lq);
        else
                IWL_DEBUG_INFO(priv, "Bcast station rate scaling has not been initialized yet.\n");
        priv->stations[sta_id].lq = link_cmd;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return 0;
 }
@@ -1371,18 +1340,17 @@ int iwl_update_bcast_stations(struct iwl_priv *priv)
  */
 int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
 {
-       unsigned long flags;
        struct iwl_addsta_cmd sta_cmd;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        /* Remove "disable" flag, to enable Tx for this TID */
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX;
        priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid));
        priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
        memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd));
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
 }
@@ -1390,24 +1358,23 @@ int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
 int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
                         int tid, u16 ssn)
 {
-       unsigned long flags;
        int sta_id;
        struct iwl_addsta_cmd sta_cmd;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        sta_id = iwl_sta_id(sta);
        if (sta_id == IWL_INVALID_STATION)
                return -ENXIO;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        priv->stations[sta_id].sta.station_flags_msk = 0;
        priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK;
        priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid;
        priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn);
        priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
        memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd));
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
 }
@@ -1415,11 +1382,10 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
 int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
                        int tid)
 {
-       unsigned long flags;
        int sta_id;
        struct iwl_addsta_cmd sta_cmd;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        sta_id = iwl_sta_id(sta);
        if (sta_id == IWL_INVALID_STATION) {
@@ -1427,13 +1393,13 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
                return -ENXIO;
        }
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        priv->stations[sta_id].sta.station_flags_msk = 0;
        priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK;
        priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid;
        priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
        memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd));
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
 }
@@ -1442,16 +1408,14 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
 
 void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
-       priv->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK;
-       priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
-       priv->stations[sta_id].sta.sta.modify_mask =
-                                       STA_MODIFY_SLEEP_TX_COUNT_MSK;
-       priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt);
-       priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
-       iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       struct iwl_addsta_cmd cmd = {
+               .mode = STA_CONTROL_MODIFY_MSK,
+               .station_flags = STA_FLG_PWR_SAVE_MSK,
+               .station_flags_msk = STA_FLG_PWR_SAVE_MSK,
+               .sta.sta_id = sta_id,
+               .sta.modify_mask = STA_MODIFY_SLEEP_TX_COUNT_MSK,
+               .sleep_tx_count = cpu_to_le16(cnt),
+       };
 
+       iwl_send_add_sta(priv, &cmd, CMD_ASYNC);
 }
index 56d7c0e38163eeb4240f60f43ebe28dd54bf4768..7712c5537370f6f31e6c63a6e6652065f32c8b02 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <net/mac80211.h>
 
+#include "iwl-agn.h"
 #include "iwl-eeprom.h"
 #include "iwl-dev.h"
 #include "iwl-core.h"
@@ -310,7 +311,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
                        tt->tt_power_mode = IWL_POWER_INDEX_5;
                        break;
                }
-               mutex_lock(&priv->shrd->mutex);
+               mutex_lock(&priv->mutex);
                if (old_state == IWL_TI_CT_KILL)
                        clear_bit(STATUS_CT_KILL, &priv->shrd->status);
                if (tt->state != IWL_TI_CT_KILL &&
@@ -341,7 +342,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
                        IWL_DEBUG_TEMP(priv, "Power Index change to %u\n",
                                        tt->tt_power_mode);
                }
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
        }
 }
 
@@ -451,7 +452,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
                         * in case get disabled before */
                        iwl_set_rxon_ht(priv, &priv->current_ht_config);
                }
-               mutex_lock(&priv->shrd->mutex);
+               mutex_lock(&priv->mutex);
                if (old_state == IWL_TI_CT_KILL)
                        clear_bit(STATUS_CT_KILL, &priv->shrd->status);
                if (tt->state != IWL_TI_CT_KILL &&
@@ -486,7 +487,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
                                iwl_perform_ct_kill_task(priv, false);
                        }
                }
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
        }
 }
 
index da18a8fc9af71516abd2a839062a5620489892d0..0ef59d9a99eeef136c4aa357e3b9c09e7f11f1c1 100644 (file)
@@ -126,7 +126,7 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
        u8 data_retry_limit;
        u8 rate_plcp;
 
-       if (priv->shrd->wowlan) {
+       if (priv->wowlan) {
                rts_retry_limit = IWLAGN_LOW_RETRY_LIMIT;
                data_retry_limit = IWLAGN_LOW_RETRY_LIMIT;
        } else {
@@ -208,10 +208,9 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
 }
 
 static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
-                                     struct ieee80211_tx_info *info,
-                                     struct iwl_tx_cmd *tx_cmd,
-                                     struct sk_buff *skb_frag,
-                                     int sta_id)
+                                        struct ieee80211_tx_info *info,
+                                        struct iwl_tx_cmd *tx_cmd,
+                                        struct sk_buff *skb_frag)
 {
        struct ieee80211_key_conf *keyconf = info->control.hw_key;
 
@@ -260,18 +259,15 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
        struct iwl_device_cmd *dev_cmd = NULL;
        struct iwl_tx_cmd *tx_cmd;
-
        __le16 fc;
        u8 hdr_len;
        u16 len, seq_number = 0;
        u8 sta_id, tid = IWL_MAX_TID_COUNT;
-       unsigned long flags;
        bool is_agg = false;
 
        if (info->control.vif)
                ctx = iwl_rxon_ctx_from_vif(info->control.vif);
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
        if (iwl_is_rfkill(priv->shrd)) {
                IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n");
                goto drop_unlock_priv;
@@ -322,7 +318,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
                sta_priv = (void *)info->control.sta->drv_priv;
 
        if (sta_priv && sta_priv->asleep &&
-           (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
+           (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) {
                /*
                 * This sends an asynchronous command to the device,
                 * but we can rely on it being processed before the
@@ -331,6 +327,10 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
                 * counter.
                 * For now set the counter to just 1 since we do not
                 * support uAPSD yet.
+                *
+                * FIXME: If we get two non-bufferable frames one
+                * after the other, we might only send out one of
+                * them because this is racy.
                 */
                iwl_sta_modify_sleep_tx_count(priv, sta_id, 1);
        }
@@ -338,13 +338,10 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
        if (info->flags & IEEE80211_TX_CTL_AMPDU)
                is_agg = true;
 
-       /* irqs already disabled/saved above when locking priv->shrd->lock */
-       spin_lock(&priv->shrd->sta_lock);
-
        dev_cmd = kmem_cache_alloc(priv->tx_cmd_pool, GFP_ATOMIC);
 
        if (unlikely(!dev_cmd))
-               goto drop_unlock_sta;
+               goto drop_unlock_priv;
 
        memset(dev_cmd, 0, sizeof(*dev_cmd));
        tx_cmd = (struct iwl_tx_cmd *) dev_cmd->payload;
@@ -354,7 +351,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
        tx_cmd->len = cpu_to_le16(len);
 
        if (info->control.hw_key)
-               iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id);
+               iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb);
 
        /* TODO need this for burst mode later on */
        iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id);
@@ -369,6 +366,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
        info->driver_data[0] = ctx;
        info->driver_data[1] = dev_cmd;
 
+       spin_lock(&priv->sta_lock);
+
        if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc)) {
                u8 *qc = NULL;
                struct iwl_tid_data *tid_data;
@@ -414,8 +413,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
            !ieee80211_has_morefrags(fc))
                priv->tid_data[sta_id][tid].seq_number = seq_number;
 
-       spin_unlock(&priv->shrd->sta_lock);
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
+       spin_unlock(&priv->sta_lock);
 
        /*
         * Avoid atomic ops if it isn't an associated client.
@@ -432,9 +430,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
 drop_unlock_sta:
        if (dev_cmd)
                kmem_cache_free(priv->tx_cmd_pool, dev_cmd);
-       spin_unlock(&priv->shrd->sta_lock);
+       spin_unlock(&priv->sta_lock);
 drop_unlock_priv:
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
        return -1;
 }
 
@@ -442,7 +439,6 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
                        struct ieee80211_sta *sta, u16 tid)
 {
        struct iwl_tid_data *tid_data;
-       unsigned long flags;
        int sta_id;
 
        sta_id = iwl_sta_id(sta);
@@ -452,7 +448,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
                return -ENXIO;
        }
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
 
        tid_data = &priv->tid_data[sta_id][tid];
 
@@ -472,7 +468,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
                IWL_WARN(priv, "Stopping AGG while state not ON "
                         "or starting for %d on %d (%d)\n", sta_id, tid,
                         priv->tid_data[sta_id][tid].agg.state);
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+               spin_unlock_bh(&priv->sta_lock);
                return 0;
        }
 
@@ -486,7 +482,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
                                    tid_data->next_reclaimed);
                priv->tid_data[sta_id][tid].agg.state =
                        IWL_EMPTYING_HW_QUEUE_DELBA;
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+               spin_unlock_bh(&priv->sta_lock);
                return 0;
        }
 
@@ -495,14 +491,10 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
 turn_off:
        priv->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF;
 
-       /* do not restore/save irqs */
-       spin_unlock(&priv->shrd->sta_lock);
-       spin_lock(&priv->shrd->lock);
+       spin_unlock_bh(&priv->sta_lock);
 
        iwl_trans_tx_agg_disable(trans(priv), sta_id, tid);
 
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
-
        ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
 
        return 0;
@@ -512,7 +504,6 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
                        struct ieee80211_sta *sta, u16 tid, u16 *ssn)
 {
        struct iwl_tid_data *tid_data;
-       unsigned long flags;
        int sta_id;
        int ret;
 
@@ -536,7 +527,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
        if (ret)
                return ret;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
 
        tid_data = &priv->tid_data[sta_id][tid];
        tid_data->agg.ssn = SEQ_TO_SN(tid_data->seq_number);
@@ -545,7 +536,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
 
        ret = iwl_trans_tx_agg_alloc(trans(priv), sta_id, tid);
        if (ret) {
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+               spin_unlock_bh(&priv->sta_lock);
                return ret;
        }
 
@@ -562,7 +553,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
                tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA;
        }
 
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        return ret;
 }
@@ -572,14 +563,13 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
 {
        struct iwl_station_priv *sta_priv = (void *) sta->drv_priv;
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
-       unsigned long flags;
        u16 ssn;
 
        buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF);
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock_bh(&priv->sta_lock);
        ssn = priv->tid_data[sta_priv->sta_id][tid].agg.ssn;
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock_bh(&priv->sta_lock);
 
        iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, sta_priv->sta_id, tid,
                               buf_size, ssn);
@@ -604,8 +594,7 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
        sta_priv->max_agg_bufsize =
                min(sta_priv->max_agg_bufsize, buf_size);
 
-       if (cfg(priv)->ht_params &&
-           cfg(priv)->ht_params->use_rts_for_aggregation) {
+       if (hw_params(priv).use_rts_for_aggregation) {
                /*
                 * switch to RTS/CTS if it is the prefer protection
                 * method for HT traffic
@@ -635,7 +624,7 @@ static void iwlagn_check_ratid_empty(struct iwl_priv *priv, int sta_id, u8 tid)
        struct ieee80211_vif *vif;
        u8 *addr;
 
-       lockdep_assert_held(&priv->shrd->sta_lock);
+       lockdep_assert_held(&priv->sta_lock);
 
        addr = priv->stations[sta_id].sta.sta.addr;
        ctx = priv->stations[sta_id].ctxid;
@@ -987,14 +976,14 @@ static void iwl_check_abort_status(struct iwl_priv *priv,
        }
 }
 
-int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
+int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
        u16 sequence = le16_to_cpu(pkt->hdr.sequence);
        int txq_id = SEQ_TO_QUEUE(sequence);
        int cmd_index __maybe_unused = SEQ_TO_INDEX(sequence);
-       struct iwlagn_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
+       struct iwlagn_tx_resp *tx_resp = (void *)pkt->data;
        struct ieee80211_hdr *hdr;
        u32 status = le16_to_cpu(tx_resp->status.status);
        u16 ssn = iwlagn_get_scd_ssn(tx_resp);
@@ -1002,7 +991,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
        int sta_id;
        int freed;
        struct ieee80211_tx_info *info;
-       unsigned long flags;
        struct sk_buff_head skbs;
        struct sk_buff *skb;
        struct iwl_rxon_context *ctx;
@@ -1013,11 +1001,13 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
        sta_id = (tx_resp->ra_tid & IWLAGN_TX_RES_RA_MSK) >>
                IWLAGN_TX_RES_RA_POS;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock(&priv->sta_lock);
 
        if (is_agg)
                iwl_rx_reply_tx_agg(priv, tx_resp);
 
+       __skb_queue_head_init(&skbs);
+
        if (tx_resp->frame_count == 1) {
                u16 next_reclaimed = le16_to_cpu(tx_resp->seq_ctl);
                next_reclaimed = SEQ_TO_SN(next_reclaimed + 0x10);
@@ -1037,8 +1027,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
                        next_reclaimed = ssn;
                }
 
-               __skb_queue_head_init(&skbs);
-
                if (tid != IWL_TID_NON_QOS) {
                        priv->tid_data[sta_id][tid].next_reclaimed =
                                next_reclaimed;
@@ -1051,8 +1039,9 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
                                  ssn, status, &skbs));
                iwlagn_check_ratid_empty(priv, sta_id, tid);
                freed = 0;
-               while (!skb_queue_empty(&skbs)) {
-                       skb = __skb_dequeue(&skbs);
+
+               /* process frames */
+               skb_queue_walk(&skbs, skb) {
                        hdr = (struct ieee80211_hdr *)skb->data;
 
                        if (!ieee80211_is_data_qos(hdr->frame_control))
@@ -1094,8 +1083,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
                        if (!is_agg)
                                iwlagn_non_agg_tx_status(priv, ctx, hdr->addr1);
 
-                       ieee80211_tx_status_irqsafe(priv->hw, skb);
-
                        freed++;
                }
 
@@ -1103,7 +1090,13 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
        }
 
        iwl_check_abort_status(priv, tx_resp->frame_count, status);
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       spin_unlock(&priv->sta_lock);
+
+       while (!skb_queue_empty(&skbs)) {
+               skb = __skb_dequeue(&skbs);
+               ieee80211_tx_status(priv->hw, skb);
+       }
+
        return 0;
 }
 
@@ -1114,17 +1107,16 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
  * of frames sent via aggregation.
  */
 int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
-                                  struct iwl_rx_mem_buffer *rxb,
+                                  struct iwl_rx_cmd_buffer *rxb,
                                   struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba;
+       struct iwl_compressed_ba_resp *ba_resp = (void *)pkt->data;
        struct iwl_ht_agg *agg;
        struct sk_buff_head reclaimed_skbs;
        struct ieee80211_tx_info *info;
        struct ieee80211_hdr *hdr;
        struct sk_buff *skb;
-       unsigned long flags;
        int sta_id;
        int tid;
        int freed;
@@ -1146,12 +1138,12 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
        tid = ba_resp->tid;
        agg = &priv->tid_data[sta_id][tid].agg;
 
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
+       spin_lock(&priv->sta_lock);
 
        if (unlikely(!agg->wait_for_ba)) {
                if (unlikely(ba_resp->bitmap))
                        IWL_ERR(priv, "Received BA when not expected\n");
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+               spin_unlock(&priv->sta_lock);
                return 0;
        }
 
@@ -1162,7 +1154,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
         * transmitted ... if not, it's too late anyway). */
        if (iwl_trans_reclaim(trans(priv), sta_id, tid, scd_flow,
                              ba_resp_scd_ssn, 0, &reclaimed_skbs)) {
-               spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+               spin_unlock(&priv->sta_lock);
                return 0;
        }
 
@@ -1198,9 +1190,8 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
 
        iwlagn_check_ratid_empty(priv, sta_id, tid);
        freed = 0;
-       while (!skb_queue_empty(&reclaimed_skbs)) {
 
-               skb = __skb_dequeue(&reclaimed_skbs);
+       skb_queue_walk(&reclaimed_skbs, skb) {
                hdr = (struct ieee80211_hdr *)skb->data;
 
                if (ieee80211_is_data_qos(hdr->frame_control))
@@ -1223,10 +1214,14 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
                        iwlagn_hwrate_to_tx_control(priv, agg->rate_n_flags,
                                                    info);
                }
+       }
+
+       spin_unlock(&priv->sta_lock);
 
-               ieee80211_tx_status_irqsafe(priv->hw, skb);
+       while (!skb_queue_empty(&reclaimed_skbs)) {
+               skb = __skb_dequeue(&reclaimed_skbs);
+               ieee80211_tx_status(priv->hw, skb);
        }
 
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
        return 0;
 }
index e8fed167f97ee0b168020e4a85a5621473555d35..4cd375c811e2273ac010a19ed984c72f505c76df 100644 (file)
 
 #include <asm/div64.h>
 
-#include "iwl-ucode.h"
 #include "iwl-eeprom.h"
-#include "iwl-wifi.h"
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-io.h"
 #include "iwl-agn-calib.h"
 #include "iwl-agn.h"
 #include "iwl-shared.h"
-#include "iwl-bus.h"
 #include "iwl-trans.h"
+#include "iwl-op-mode.h"
 
 /******************************************************************************
  *
@@ -134,7 +132,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
         * beacon contents.
         */
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (!priv->beacon_ctx) {
                IWL_ERR(priv, "trying to build beacon w/o beacon context!\n");
@@ -199,7 +197,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
        cmd.data[1] = priv->beacon_skb->data;
        cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY;
 
-       return iwl_trans_send_cmd(trans(priv), &cmd);
+       return iwl_dvm_send_cmd(priv, &cmd);
 }
 
 static void iwl_bg_beacon_update(struct work_struct *work)
@@ -208,7 +206,7 @@ static void iwl_bg_beacon_update(struct work_struct *work)
                container_of(work, struct iwl_priv, beacon_update);
        struct sk_buff *beacon;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        if (!priv->beacon_ctx) {
                IWL_ERR(priv, "updating beacon w/o beacon context!\n");
                goto out;
@@ -238,7 +236,7 @@ static void iwl_bg_beacon_update(struct work_struct *work)
 
        iwlagn_send_beacon_cmd(priv);
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 static void iwl_bg_bt_runtime_config(struct work_struct *work)
@@ -261,7 +259,7 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work)
                container_of(work, struct iwl_priv, bt_full_concurrency);
        struct iwl_rxon_context *ctx;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
                goto out;
@@ -285,7 +283,7 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work)
 
        iwlagn_send_advance_bt_config(priv);
 out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 /**
@@ -355,11 +353,12 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
                ev = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
                time = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
                if (mode == 0) {
-                       trace_iwlwifi_dev_ucode_cont_event(priv, 0, time, ev);
+                       trace_iwlwifi_dev_ucode_cont_event(
+                                       trans(priv)->dev, 0, time, ev);
                } else {
                        data = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
-                       trace_iwlwifi_dev_ucode_cont_event(priv, time,
-                                                          data, ev);
+                       trace_iwlwifi_dev_ucode_cont_event(
+                                       trans(priv)->dev, time, data, ev);
                }
        }
        /* Allow device to power down */
@@ -424,7 +423,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv)
                else
                        priv->event_log.wraps_once_count++;
 
-               trace_iwlwifi_dev_ucode_wrap_event(priv,
+               trace_iwlwifi_dev_ucode_wrap_event(trans(priv)->dev,
                                num_wraps - priv->event_log.num_wraps,
                                next_entry, priv->event_log.next_entry);
 
@@ -552,13 +551,11 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
 {
        struct iwl_ct_kill_config cmd;
        struct iwl_ct_kill_throttling_config adv_cmd;
-       unsigned long flags;
        int ret = 0;
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
        iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR,
                    CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
+
        priv->thermal_throttle.ct_kill_toggle = false;
 
        if (cfg(priv)->base_params->support_ct_kill_exit) {
@@ -567,7 +564,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
                adv_cmd.critical_temperature_exit =
                        cpu_to_le32(hw_params(priv).ct_kill_exit_threshold);
 
-               ret = iwl_trans_send_cmd_pdu(trans(priv),
+               ret = iwl_dvm_send_cmd_pdu(priv,
                                       REPLY_CT_KILL_CONFIG_CMD,
                                       CMD_SYNC, sizeof(adv_cmd), &adv_cmd);
                if (ret)
@@ -582,7 +579,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
                cmd.critical_temperature_R =
                        cpu_to_le32(hw_params(priv).ct_kill_threshold);
 
-               ret = iwl_trans_send_cmd_pdu(trans(priv),
+               ret = iwl_dvm_send_cmd_pdu(priv,
                                       REPLY_CT_KILL_CONFIG_CMD,
                                       CMD_SYNC, sizeof(cmd), &cmd);
                if (ret)
@@ -608,7 +605,7 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg)
        calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_RT_CFG_ALL;
        calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg);
 
-       return iwl_trans_send_cmd(trans(priv), &cmd);
+       return iwl_dvm_send_cmd(priv, &cmd);
 }
 
 
@@ -618,9 +615,9 @@ static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
          .valid = cpu_to_le32(valid_tx_ant),
        };
 
-       if (IWL_UCODE_API(nic(priv)->fw.ucode_ver) > 1) {
+       if (IWL_UCODE_API(priv->fw->ucode_ver) > 1) {
                IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
-               return iwl_trans_send_cmd_pdu(trans(priv),
+               return iwl_dvm_send_cmd_pdu(priv,
                                        TX_ANT_CONFIGURATION_CMD,
                                        CMD_SYNC,
                                        sizeof(struct iwl_tx_ant_config_cmd),
@@ -673,14 +670,14 @@ int iwl_alive_start(struct iwl_priv *priv)
                priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS;
                priv->cur_rssi_ctx = NULL;
 
-               iwl_send_prio_tbl(trans(priv));
+               iwl_send_prio_tbl(priv);
 
                /* FIXME: w/a to force change uCode BT state machine */
-               ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN,
+               ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
                                         BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
                if (ret)
                        return ret;
-               ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_CLOSE,
+               ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE,
                                         BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
                if (ret)
                        return ret;
@@ -701,9 +698,9 @@ int iwl_alive_start(struct iwl_priv *priv)
        priv->active_rate = IWL_RATES_MASK;
 
        /* Configure Tx antenna selection based on H/W config */
-       iwlagn_send_tx_ant_config(priv, cfg(priv)->valid_tx_ant);
+       iwlagn_send_tx_ant_config(priv, hw_params(priv).valid_tx_ant);
 
-       if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) {
+       if (iwl_is_associated_ctx(ctx) && !priv->wowlan) {
                struct iwl_rxon_cmd *active_rxon =
                                (struct iwl_rxon_cmd *)&ctx->active;
                /* apply any changes in staging */
@@ -718,7 +715,7 @@ int iwl_alive_start(struct iwl_priv *priv)
                iwlagn_set_rxon_chain(priv, ctx);
        }
 
-       if (!priv->shrd->wowlan) {
+       if (!priv->wowlan) {
                /* WoWLAN ucode will not reply in the same way, skip it */
                iwl_reset_run_time_calib(priv);
        }
@@ -738,13 +735,47 @@ int iwl_alive_start(struct iwl_priv *priv)
        return iwl_power_update_mode(priv, true);
 }
 
+/**
+ * iwl_clear_driver_stations - clear knowledge of all stations from driver
+ * @priv: iwl priv struct
+ *
+ * This is called during iwl_down() to make sure that in the case
+ * we're coming there from a hardware restart mac80211 will be
+ * able to reconfigure stations -- if we're getting there in the
+ * normal down flow then the stations will already be cleared.
+ */
+static void iwl_clear_driver_stations(struct iwl_priv *priv)
+{
+       struct iwl_rxon_context *ctx;
+
+       spin_lock_bh(&priv->sta_lock);
+       memset(priv->stations, 0, sizeof(priv->stations));
+       priv->num_stations = 0;
+
+       priv->ucode_key_table = 0;
+
+       for_each_context(priv, ctx) {
+               /*
+                * Remove all key information that is not stored as part
+                * of station information since mac80211 may not have had
+                * a chance to remove all the keys. When device is
+                * reconfigured by mac80211 after an error all keys will
+                * be reconfigured.
+                */
+               memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys));
+               ctx->key_mapping_keys = 0;
+       }
+
+       spin_unlock_bh(&priv->sta_lock);
+}
+
 void iwl_down(struct iwl_priv *priv)
 {
        int exit_pending;
 
        IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        iwl_scan_cancel_timeout(priv, 200);
 
@@ -814,11 +845,11 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
        struct iwl_priv *priv = container_of(work, struct iwl_priv,
                        run_time_calib_work);
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) ||
            test_bit(STATUS_SCANNING, &priv->shrd->status)) {
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
                return;
        }
 
@@ -827,7 +858,7 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
                iwl_sensitivity_calibration(priv);
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 void iwlagn_prepare_restart(struct iwl_priv *priv)
@@ -839,7 +870,7 @@ void iwlagn_prepare_restart(struct iwl_priv *priv)
        u8 bt_status;
        bool bt_is_sco;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        for_each_context(priv, ctx)
                ctx->vif = NULL;
@@ -877,9 +908,9 @@ static void iwl_bg_restart(struct work_struct *data)
                return;
 
        if (test_and_clear_bit(STATUS_FW_ERROR, &priv->shrd->status)) {
-               mutex_lock(&priv->shrd->mutex);
+               mutex_lock(&priv->mutex);
                iwlagn_prepare_restart(priv);
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
                iwl_cancel_deferred_work(priv);
                ieee80211_restart_hw(priv->hw);
        } else {
@@ -894,7 +925,7 @@ void iwlagn_disable_roc(struct iwl_priv *priv)
 {
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN];
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (!priv->hw_roc_setup)
                return;
@@ -917,9 +948,9 @@ static void iwlagn_disable_roc_work(struct work_struct *work)
        struct iwl_priv *priv = container_of(work, struct iwl_priv,
                                             hw_roc_disable_work.work);
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwlagn_disable_roc(priv);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 /*****************************************************************************
@@ -1004,21 +1035,26 @@ static int iwl_init_drv(struct iwl_priv *priv)
 {
        int ret;
 
-       spin_lock_init(&priv->shrd->sta_lock);
+       spin_lock_init(&priv->sta_lock);
 
-       mutex_init(&priv->shrd->mutex);
+       mutex_init(&priv->mutex);
 
-       INIT_LIST_HEAD(&trans(priv)->calib_results);
+       INIT_LIST_HEAD(&priv->calib_results);
 
        priv->ieee_channels = NULL;
        priv->ieee_rates = NULL;
        priv->band = IEEE80211_BAND_2GHZ;
 
+       priv->plcp_delta_threshold =
+               cfg(priv)->base_params->plcp_delta_threshold;
+
        priv->iw_mode = NL80211_IFTYPE_STATION;
        priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
        priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
        priv->agg_tids_count = 0;
 
+       priv->ucode_owner = IWL_OWNERSHIP_DRIVER;
+
        /* initialize force reset */
        priv->force_reset[IWL_RF_RESET].reset_duration =
                IWL_DELAY_NEXT_FORCE_RF_RESET;
@@ -1073,6 +1109,7 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
        kfree(priv->scan_cmd);
        kfree(priv->beacon_cmd);
        kfree(rcu_dereference_raw(priv->noa_data));
+       iwl_calib_free_results(priv);
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        kfree(priv->wowlan_sram);
 #endif
@@ -1084,6 +1121,10 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
 
 static void iwl_set_hw_params(struct iwl_priv *priv)
 {
+       if (cfg(priv)->ht_params)
+               hw_params(priv).use_rts_for_aggregation =
+                       cfg(priv)->ht_params->use_rts_for_aggregation;
+
        if (iwlagn_mod_params.amsdu_size_8K)
                hw_params(priv).rx_page_order =
                        get_order(IWL_RX_BUF_SIZE_8K);
@@ -1092,13 +1133,10 @@ static void iwl_set_hw_params(struct iwl_priv *priv)
                        get_order(IWL_RX_BUF_SIZE_4K);
 
        if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_ALL)
-               cfg(priv)->sku &= ~EEPROM_SKU_CAP_11N_ENABLE;
+               hw_params(priv).sku &= ~EEPROM_SKU_CAP_11N_ENABLE;
 
        hw_params(priv).num_ampdu_queues =
                cfg(priv)->base_params->num_of_ampdu_queues;
-       hw_params(priv).shadow_reg_enable =
-               cfg(priv)->base_params->shadow_reg_enable;
-       hw_params(priv).sku = cfg(priv)->sku;
        hw_params(priv).wd_timeout = cfg(priv)->base_params->wd_timeout;
 
        /* Device-specific setup */
@@ -1142,37 +1180,45 @@ static void iwl_debug_config(struct iwl_priv *priv)
 #endif
 }
 
-int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
-               struct iwl_cfg *cfg)
+static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
+                                                const struct iwl_fw *fw)
 {
        int err = 0;
        struct iwl_priv *priv;
        struct ieee80211_hw *hw;
+       struct iwl_op_mode *op_mode;
        u16 num_mac;
+       u32 ucode_flags;
 
        /************************
         * 1. Allocating HW data
         ************************/
        hw = iwl_alloc_all();
        if (!hw) {
-               pr_err("%s: Cannot allocate network device\n", cfg->name);
+               pr_err("%s: Cannot allocate network device\n",
+                               cfg(trans)->name);
                err = -ENOMEM;
                goto out;
        }
 
-       priv = hw->priv;
-       priv->shrd = bus->shrd;
-       priv->shrd->priv = priv;
+       op_mode = hw->priv;
+       op_mode->ops = &iwl_dvm_ops;
+       priv = IWL_OP_MODE_GET_DVM(op_mode);
+       priv->shrd = trans->shrd;
+       priv->fw = fw;
+       /* TODO: remove fw from shared data later */
+       priv->shrd->fw = fw;
+
+       iwl_trans_configure(trans(priv), op_mode);
 
        /* At this point both hw and priv are allocated. */
 
-       SET_IEEE80211_DEV(hw, trans(priv)->dev);
+       SET_IEEE80211_DEV(priv->hw, trans(priv)->dev);
 
        /* show what debugging capabilities we have */
        iwl_debug_config(priv);
 
        IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
-       cfg(priv) = cfg;
 
        /* is antenna coupling more than 35dB ? */
        priv->bt_ant_couple_ok =
@@ -1192,7 +1238,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
         * we should init now
         */
        spin_lock_init(&trans(priv)->reg_lock);
-       spin_lock_init(&priv->shrd->lock);
+       spin_lock_init(&priv->statistics.lock);
 
        /***********************
         * 3. Read REV register
@@ -1208,7 +1254,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
         * 4. Read EEPROM
         *****************/
        /* Read the EEPROM */
-       err = iwl_eeprom_init(priv, trans(priv)->hw_rev);
+       err = iwl_eeprom_init(trans(priv), trans(priv)->hw_rev);
        /* Reset chip to save power until we load uCode during "up". */
        iwl_trans_stop_hw(trans(priv));
        if (err) {
@@ -1219,7 +1265,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
        if (err)
                goto out_free_eeprom;
 
-       err = iwl_eeprom_check_sku(priv);
+       err = iwl_eeprom_init_hw_params(priv);
        if (err)
                goto out_free_eeprom;
 
@@ -1241,6 +1287,22 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
         ************************/
        iwl_set_hw_params(priv);
 
+       ucode_flags = fw->ucode_capa.flags;
+
+#ifndef CONFIG_IWLWIFI_P2P
+       ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN;
+#endif
+       if (!(hw_params(priv).sku & EEPROM_SKU_CAP_IPAN_ENABLE))
+               ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN;
+
+       /*
+        * if not PAN, then don't support P2P -- might be a uCode
+        * packaging bug or due to the eeprom check above
+        */
+       if (!(ucode_flags & IWL_UCODE_TLV_FLAGS_PAN))
+               ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P;
+
+
        /*******************
         * 6. Setup priv
         *******************/
@@ -1260,13 +1322,45 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
        iwl_power_initialize(priv);
        iwl_tt_initialize(priv);
 
-       init_completion(&nic(priv)->request_firmware_complete);
+       snprintf(priv->hw->wiphy->fw_version,
+                sizeof(priv->hw->wiphy->fw_version),
+                "%s", fw->fw_version);
+
+       priv->new_scan_threshold_behaviour =
+               !!(ucode_flags & IWL_UCODE_TLV_FLAGS_NEWSCAN);
+
+       if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) {
+               priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN;
+               priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM;
+       } else {
+               priv->sta_key_max_num = STA_KEY_MAX_NUM;
+               priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;
+       }
+
+       priv->phy_calib_chain_noise_reset_cmd =
+               fw->ucode_capa.standard_phy_calibration_size;
+       priv->phy_calib_chain_noise_gain_cmd =
+               fw->ucode_capa.standard_phy_calibration_size + 1;
+
+       /* initialize all valid contexts */
+       iwl_init_context(priv, ucode_flags);
 
-       err = iwl_request_firmware(nic(priv), true);
+       /**************************************************
+        * This is still part of probe() in a sense...
+        *
+        * 9. Setup and register with mac80211 and debugfs
+        **************************************************/
+       err = iwlagn_mac_setup_register(priv, &fw->ucode_capa);
        if (err)
                goto out_destroy_workqueue;
 
-       return 0;
+       err = iwl_dbgfs_register(priv, DRV_NAME);
+       if (err)
+               IWL_ERR(priv,
+                       "failed to create debugfs files. Ignoring error: %d\n",
+                       err);
+
+       return op_mode;
 
 out_destroy_workqueue:
        destroy_workqueue(priv->workqueue);
@@ -1278,23 +1372,18 @@ out_free_traffic_mem:
        iwl_free_traffic_mem(priv);
        ieee80211_free_hw(priv->hw);
 out:
-       return err;
+       op_mode = NULL;
+       return op_mode;
 }
 
-void __devexit iwl_remove(struct iwl_priv * priv)
+static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
 {
-       wait_for_completion(&nic(priv)->request_firmware_complete);
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
 
        IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
 
        iwl_dbgfs_unregister(priv);
 
-       /* ieee80211_unregister_hw call wil cause iwlagn_mac_stop to
-        * to be called and iwl_down since we are removing the device
-        * we need to set STATUS_EXIT_PENDING bit.
-        */
-       set_bit(STATUS_EXIT_PENDING, &priv->shrd->status);
-
        iwl_testmode_cleanup(priv);
        iwlagn_mac_unregister(priv);
 
@@ -1303,8 +1392,6 @@ void __devexit iwl_remove(struct iwl_priv * priv)
        /*This will stop the queues, move the device to low power state */
        iwl_trans_stop_device(trans(priv));
 
-       iwl_dealloc_ucode(nic(priv));
-
        iwl_eeprom_free(priv->shrd);
 
        /*netif_stop_queue(dev); */
@@ -1324,6 +1411,35 @@ void __devexit iwl_remove(struct iwl_priv * priv)
        ieee80211_free_hw(priv->hw);
 }
 
+static void iwl_cmd_queue_full(struct iwl_op_mode *op_mode)
+{
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
+
+       if (!iwl_check_for_ct_kill(priv)) {
+               IWL_ERR(priv, "Restarting adapter queue is full\n");
+               iwl_nic_error(op_mode);
+       }
+}
+
+static void iwl_nic_config(struct iwl_op_mode *op_mode)
+{
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
+
+       cfg(priv)->lib->nic_config(priv);
+}
+
+const struct iwl_op_mode_ops iwl_dvm_ops = {
+       .start = iwl_op_mode_dvm_start,
+       .stop = iwl_op_mode_dvm_stop,
+       .rx = iwl_rx_dispatch,
+       .queue_full = iwl_stop_sw_queue,
+       .queue_not_full = iwl_wake_sw_queue,
+       .hw_rf_kill = iwl_set_hw_rfkill_state,
+       .free_skb = iwl_free_skb,
+       .nic_error = iwl_nic_error,
+       .cmd_queue_full = iwl_cmd_queue_full,
+       .nic_config = iwl_nic_config,
+};
 
 /*****************************************************************************
  *
@@ -1371,8 +1487,6 @@ MODULE_PARM_DESC(debug, "debug output mask");
 
 module_param_named(swcrypto, iwlagn_mod_params.sw_crypto, int, S_IRUGO);
 MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
-module_param_named(queues_num, iwlagn_mod_params.num_of_queues, int, S_IRUGO);
-MODULE_PARM_DESC(queues_num, "number of hw queues.");
 module_param_named(11n_disable, iwlagn_mod_params.disable_11n, uint, S_IRUGO);
 MODULE_PARM_DESC(11n_disable,
        "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX");
index 79894aca9644c9aad26bc1f8f96d8684ed798553..ec3a90c42efb0a0c2116967f9243dad06b896f9c 100644 (file)
@@ -80,13 +80,29 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd)
 void iwl_down(struct iwl_priv *priv);
 void iwl_cancel_deferred_work(struct iwl_priv *priv);
 void iwlagn_prepare_restart(struct iwl_priv *priv);
+void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb);
+int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode,
+                                struct iwl_rx_cmd_buffer *rxb,
+                                struct iwl_device_cmd *cmd);
+void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac);
+void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac);
+void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state);
+void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac);
+void iwl_nic_error(struct iwl_op_mode *op_mode);
+
+bool iwl_check_for_ct_kill(struct iwl_priv *priv);
 
 /* MAC80211 */
 struct ieee80211_hw *iwl_alloc_all(void);
 int iwlagn_mac_setup_register(struct iwl_priv *priv,
-                             struct iwl_ucode_capabilities *capa);
+                             const struct iwl_ucode_capabilities *capa);
 void iwlagn_mac_unregister(struct iwl_priv *priv);
 
+/* commands */
+int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
+int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id,
+                        u32 flags, u16 len, const void *data);
+
 /* RXON */
 int iwlagn_set_pan_params(struct iwl_priv *priv);
 int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
@@ -101,9 +117,19 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf,
 
 /* uCode */
 int iwlagn_rx_calib_result(struct iwl_priv *priv,
-                           struct iwl_rx_mem_buffer *rxb,
+                           struct iwl_rx_cmd_buffer *rxb,
                            struct iwl_device_cmd *cmd);
 void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags);
+int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
+void iwl_send_prio_tbl(struct iwl_priv *priv);
+int iwl_init_alive_start(struct iwl_priv *priv);
+int iwl_run_init_ucode(struct iwl_priv *priv);
+int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
+                             enum iwl_ucode_type ucode_type);
+int iwl_send_calib_results(struct iwl_priv *priv);
+int iwl_calib_set(struct iwl_priv *priv,
+                 const struct iwl_calib_hdr *cmd, int len);
+void iwl_calib_free_results(struct iwl_priv *priv);
 
 /* lib */
 int iwlagn_send_tx_power(struct iwl_priv *priv);
@@ -133,9 +159,9 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif,
 int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
                       struct ieee80211_sta *sta, u16 tid);
 int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
-                                  struct iwl_rx_mem_buffer *rxb,
+                                  struct iwl_rx_cmd_buffer *rxb,
                                   struct iwl_device_cmd *cmd);
-int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
+int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd);
 
 static inline u32 iwl_tx_status_to_mac80211(u32 status)
@@ -170,7 +196,7 @@ void iwlagn_disable_roc(struct iwl_priv *priv);
 /* bt coex */
 void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
 int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
-                                 struct iwl_rx_mem_buffer *rxb,
+                                 struct iwl_rx_cmd_buffer *rxb,
                                  struct iwl_device_cmd *cmd);
 void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv);
 void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv);
@@ -218,46 +244,12 @@ void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                     u8 sta_id, struct iwl_link_quality_cmd *link_cmd);
 int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                    struct iwl_link_quality_cmd *lq, u8 flags, bool init);
-void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
-int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
+int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
                               struct iwl_device_cmd *cmd);
+int iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
+                     struct ieee80211_sta *sta);
 
 
-/**
- * iwl_clear_driver_stations - clear knowledge of all stations from driver
- * @priv: iwl priv struct
- *
- * This is called during iwl_down() to make sure that in the case
- * we're coming there from a hardware restart mac80211 will be
- * able to reconfigure stations -- if we're getting there in the
- * normal down flow then the stations will already be cleared.
- */
-static inline void iwl_clear_driver_stations(struct iwl_priv *priv)
-{
-       unsigned long flags;
-       struct iwl_rxon_context *ctx;
-
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
-       memset(priv->stations, 0, sizeof(priv->stations));
-       priv->num_stations = 0;
-
-       priv->ucode_key_table = 0;
-
-       for_each_context(priv, ctx) {
-               /*
-                * Remove all key information that is not stored as part
-                * of station information since mac80211 may not have had
-                * a chance to remove all the keys. When device is
-                * reconfigured by mac80211 after an error all keys will
-                * be reconfigured.
-                */
-               memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys));
-               ctx->key_mapping_keys = 0;
-       }
-
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
-}
-
 static inline int iwl_sta_id(struct ieee80211_sta *sta)
 {
        if (WARN_ON(!sta))
@@ -383,4 +375,78 @@ void iwl_testmode_cleanup(struct iwl_priv *priv)
 }
 #endif
 
+#ifdef CONFIG_IWLWIFI_DEBUG
+void iwl_print_rx_config_cmd(struct iwl_priv *priv,
+                            enum iwl_rxon_context_id ctxid);
+#else
+static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
+                                          enum iwl_rxon_context_id ctxid)
+{
+}
+#endif
+
+/* status checks */
+
+static inline int iwl_is_ready(struct iwl_shared *shrd)
+{
+       /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
+        * set but EXIT_PENDING is not */
+       return test_bit(STATUS_READY, &shrd->status) &&
+              test_bit(STATUS_GEO_CONFIGURED, &shrd->status) &&
+              !test_bit(STATUS_EXIT_PENDING, &shrd->status);
+}
+
+static inline int iwl_is_alive(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_ALIVE, &shrd->status);
+}
+
+static inline int iwl_is_init(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_INIT, &shrd->status);
+}
+
+static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_RF_KILL_HW, &shrd->status);
+}
+
+static inline int iwl_is_rfkill(struct iwl_shared *shrd)
+{
+       return iwl_is_rfkill_hw(shrd);
+}
+
+static inline int iwl_is_ctkill(struct iwl_shared *shrd)
+{
+       return test_bit(STATUS_CT_KILL, &shrd->status);
+}
+
+static inline int iwl_is_ready_rf(struct iwl_shared *shrd)
+{
+       if (iwl_is_rfkill(shrd))
+               return 0;
+
+       return iwl_is_ready(shrd);
+}
+
+#ifdef CONFIG_IWLWIFI_DEBUG
+#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)        \
+do {                                                                   \
+       if (!iwl_is_rfkill((m)->shrd))                                  \
+               IWL_ERR(m, fmt, ##args);                                \
+       else                                                            \
+               __iwl_err(trans(m)->dev, true,                          \
+                         !iwl_have_debug_level(IWL_DL_RADIO),          \
+                         fmt, ##args);                                 \
+} while (0)
+#else
+#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)        \
+do {                                                                   \
+       if (!iwl_is_rfkill((m)->shrd))                                  \
+               IWL_ERR(m, fmt, ##args);                                \
+       else                                                            \
+               __iwl_err(trans(m)->dev, true, true, fmt, ##args);      \
+} while (0)
+#endif                         /* CONFIG_IWLWIFI_DEBUG */
+
 #endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h
deleted file mode 100644 (file)
index 30965e0..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/******************************************************************************
- *
- * This file is provided under a dual BSD/GPLv2 license.  When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
- * USA
- *
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * Contact Information:
- *  Intel Linux Wireless <ilw@linux.intel.com>
- * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
- *
- * BSD LICENSE
- *
- * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *  * Neither the name Intel Corporation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-#ifndef __iwl_bus_h__
-#define __iwl_bus_h__
-
-#include <linux/types.h>
-#include <linux/spinlock.h>
-
-/**
- * DOC: Bus layer - role and goal
- *
- * iwl-bus.h defines the API to the bus layer of the iwlwifi driver.
- * The bus layer is responsible for doing very basic bus operations that are
- * listed in the iwl_bus_ops structure.
- * The bus layer registers to the bus driver, advertises the supported HW and
- * gets notifications about enumeration, suspend, resume.
- * For the moment, the bus layer is not a linux kernel module as itself, and
- * the module_init function of the driver must call the bus specific
- * registration functions. These functions are listed at the end of this file.
- * For the moment, there is only one implementation of this interface: PCI-e.
- * This implementation is iwl-pci.c
- */
-
-/**
- * DOC: encapsulation and type safety
- *
- * The iwl_bus describes the data that is shared amongst all the bus layer
- * implementations. This data is visible to other layers. Data in the bus
- * specific area is not visible outside the bus specific implementation.
- * iwl_bus holds a pointer to iwl_shared which holds pointer to all the other
- * layers of the driver (iwl_priv, iwl_trans). In fact, this is the way to go
- * when the transport layer needs to call a function of another layer.
- *
- * In order to achieve encapsulation, iwl_priv cannot be dereferenced from the
- * bus layer. Type safety is still kept since functions that gets iwl_priv gets
- * a typed pointer (as opposed to void *).
- */
-
-/**
- * DOC: probe flow
- *
- * The module_init calls the bus specific registration function. The
- * registration to the bus layer will trigger an enumeration of the bus which
- * will call the bus specific probe function.
- * The first thing this function must do is to allocate the memory needed by
- * iwl_bus + the bus_specific data.
- * Once the bus specific probe function has configured the hardware, it
- * chooses the appropriate transport layer and calls iwl_probe that will run
- * the bus independent probe flow.
- *
- * Note: The bus specific code must set the following data in iwl_bus before it
- *       calls iwl_probe:
- *     * bus->dev
- *     * bus->irq
- *     * bus->ops
- */
-
-struct iwl_shared;
-struct iwl_bus;
-
-/**
- * struct iwl_bus - bus common data
- *
- * This data is common to all bus layer implementations.
- *
- * @ops - pointer to iwl_bus_ops
- * @shrd - pointer to iwl_shared which holds shared data from the upper layer
- *     NB: for the time being this needs to be set by the upper layer since
- *     it allocates the shared data
- */
-struct iwl_bus {
-       struct iwl_shared *shrd;
-
-       /* pointer to bus specific struct */
-       /*Ensure that this pointer will always be aligned to sizeof pointer */
-       char bus_specific[0] __attribute__((__aligned__(sizeof(void *))));
-};
-
-/*****************************************************
-* Bus layer registration functions
-******************************************************/
-int __must_check iwl_pci_register_driver(void);
-void iwl_pci_unregister_driver(void);
-
-#endif /* __iwl_bus_h__ */
index 957bc00cdaf0f469e07338983e10a74e7c368e10..82152311d73b3ebe5a89d3cdfac1732892327696 100644 (file)
  * This file declares the config structures for all devices.
  */
 
-extern struct iwl_cfg iwl5300_agn_cfg;
-extern struct iwl_cfg iwl5100_agn_cfg;
-extern struct iwl_cfg iwl5350_agn_cfg;
-extern struct iwl_cfg iwl5100_bgn_cfg;
-extern struct iwl_cfg iwl5100_abg_cfg;
-extern struct iwl_cfg iwl5150_agn_cfg;
-extern struct iwl_cfg iwl5150_abg_cfg;
-extern struct iwl_cfg iwl6005_2agn_cfg;
-extern struct iwl_cfg iwl6005_2abg_cfg;
-extern struct iwl_cfg iwl6005_2bg_cfg;
-extern struct iwl_cfg iwl6005_2agn_sff_cfg;
-extern struct iwl_cfg iwl6005_2agn_d_cfg;
-extern struct iwl_cfg iwl1030_bgn_cfg;
-extern struct iwl_cfg iwl1030_bg_cfg;
-extern struct iwl_cfg iwl6030_2agn_cfg;
-extern struct iwl_cfg iwl6030_2abg_cfg;
-extern struct iwl_cfg iwl6030_2bgn_cfg;
-extern struct iwl_cfg iwl6030_2bg_cfg;
-extern struct iwl_cfg iwl6000i_2agn_cfg;
-extern struct iwl_cfg iwl6000i_2abg_cfg;
-extern struct iwl_cfg iwl6000i_2bg_cfg;
-extern struct iwl_cfg iwl6000_3agn_cfg;
-extern struct iwl_cfg iwl6050_2agn_cfg;
-extern struct iwl_cfg iwl6050_2abg_cfg;
-extern struct iwl_cfg iwl6150_bgn_cfg;
-extern struct iwl_cfg iwl6150_bg_cfg;
-extern struct iwl_cfg iwl1000_bgn_cfg;
-extern struct iwl_cfg iwl1000_bg_cfg;
-extern struct iwl_cfg iwl100_bgn_cfg;
-extern struct iwl_cfg iwl100_bg_cfg;
-extern struct iwl_cfg iwl130_bgn_cfg;
-extern struct iwl_cfg iwl130_bg_cfg;
-extern struct iwl_cfg iwl2000_2bgn_cfg;
-extern struct iwl_cfg iwl2000_2bgn_d_cfg;
-extern struct iwl_cfg iwl2030_2bgn_cfg;
-extern struct iwl_cfg iwl6035_2agn_cfg;
-extern struct iwl_cfg iwl105_bgn_cfg;
-extern struct iwl_cfg iwl105_bgn_d_cfg;
-extern struct iwl_cfg iwl135_bgn_cfg;
+extern const struct iwl_cfg iwl5300_agn_cfg;
+extern const struct iwl_cfg iwl5100_agn_cfg;
+extern const struct iwl_cfg iwl5350_agn_cfg;
+extern const struct iwl_cfg iwl5100_bgn_cfg;
+extern const struct iwl_cfg iwl5100_abg_cfg;
+extern const struct iwl_cfg iwl5150_agn_cfg;
+extern const struct iwl_cfg iwl5150_abg_cfg;
+extern const struct iwl_cfg iwl6005_2agn_cfg;
+extern const struct iwl_cfg iwl6005_2abg_cfg;
+extern const struct iwl_cfg iwl6005_2bg_cfg;
+extern const struct iwl_cfg iwl6005_2agn_sff_cfg;
+extern const struct iwl_cfg iwl6005_2agn_d_cfg;
+extern const struct iwl_cfg iwl6005_2agn_mow1_cfg;
+extern const struct iwl_cfg iwl6005_2agn_mow2_cfg;
+extern const struct iwl_cfg iwl1030_bgn_cfg;
+extern const struct iwl_cfg iwl1030_bg_cfg;
+extern const struct iwl_cfg iwl6030_2agn_cfg;
+extern const struct iwl_cfg iwl6030_2abg_cfg;
+extern const struct iwl_cfg iwl6030_2bgn_cfg;
+extern const struct iwl_cfg iwl6030_2bg_cfg;
+extern const struct iwl_cfg iwl6000i_2agn_cfg;
+extern const struct iwl_cfg iwl6000i_2abg_cfg;
+extern const struct iwl_cfg iwl6000i_2bg_cfg;
+extern const struct iwl_cfg iwl6000_3agn_cfg;
+extern const struct iwl_cfg iwl6050_2agn_cfg;
+extern const struct iwl_cfg iwl6050_2abg_cfg;
+extern const struct iwl_cfg iwl6150_bgn_cfg;
+extern const struct iwl_cfg iwl6150_bg_cfg;
+extern const struct iwl_cfg iwl1000_bgn_cfg;
+extern const struct iwl_cfg iwl1000_bg_cfg;
+extern const struct iwl_cfg iwl100_bgn_cfg;
+extern const struct iwl_cfg iwl100_bg_cfg;
+extern const struct iwl_cfg iwl130_bgn_cfg;
+extern const struct iwl_cfg iwl130_bg_cfg;
+extern const struct iwl_cfg iwl2000_2bgn_cfg;
+extern const struct iwl_cfg iwl2000_2bgn_d_cfg;
+extern const struct iwl_cfg iwl2030_2bgn_cfg;
+extern const struct iwl_cfg iwl6035_2agn_cfg;
+extern const struct iwl_cfg iwl105_bgn_cfg;
+extern const struct iwl_cfg iwl105_bgn_d_cfg;
+extern const struct iwl_cfg iwl135_bgn_cfg;
 
 #endif /* __iwl_pci_h__ */
index c20618d9226813d2e1b75654c2000522e181eebc..9ed73e5154be908a18662fb9493292233594e0d8 100644 (file)
 #ifndef __iwl_commands_h__
 #define __iwl_commands_h__
 
-#include <linux/etherdevice.h>
 #include <linux/ieee80211.h>
+#include <linux/types.h>
 
-struct iwl_priv;
-
-/* uCode version contains 4 values: Major/Minor/API/Serial */
-#define IWL_UCODE_MAJOR(ver)   (((ver) & 0xFF000000) >> 24)
-#define IWL_UCODE_MINOR(ver)   (((ver) & 0x00FF0000) >> 16)
-#define IWL_UCODE_API(ver)     (((ver) & 0x0000FF00) >> 8)
-#define IWL_UCODE_SERIAL(ver)  ((ver) & 0x000000FF)
-
-
-/* Tx rates */
-#define IWL_CCK_RATES  4
-#define IWL_OFDM_RATES 8
-#define IWL_MAX_RATES  (IWL_CCK_RATES + IWL_OFDM_RATES)
 
 enum {
        REPLY_ALIVE = 0x1,
@@ -213,48 +200,6 @@ enum {
 /* iwl_cmd_header flags value */
 #define IWL_CMD_FAILED_MSK 0x40
 
-#define SEQ_TO_QUEUE(s)        (((s) >> 8) & 0x1f)
-#define QUEUE_TO_SEQ(q)        (((q) & 0x1f) << 8)
-#define SEQ_TO_INDEX(s)        ((s) & 0xff)
-#define INDEX_TO_SEQ(i)        ((i) & 0xff)
-#define SEQ_RX_FRAME   cpu_to_le16(0x8000)
-
-/**
- * struct iwl_cmd_header
- *
- * This header format appears in the beginning of each command sent from the
- * driver, and each response/notification received from uCode.
- */
-struct iwl_cmd_header {
-       u8 cmd;         /* Command ID:  REPLY_RXON, etc. */
-       u8 flags;       /* 0:5 reserved, 6 abort, 7 internal */
-       /*
-        * The driver sets up the sequence number to values of its choosing.
-        * uCode does not use this value, but passes it back to the driver
-        * when sending the response to each driver-originated command, so
-        * the driver can match the response to the command.  Since the values
-        * don't get used by uCode, the driver may set up an arbitrary format.
-        *
-        * There is one exception:  uCode sets bit 15 when it originates
-        * the response/notification, i.e. when the response/notification
-        * is not a direct response to a command sent by the driver.  For
-        * example, uCode issues REPLY_RX when it sends a received frame
-        * to the driver; it is not a direct response to any driver command.
-        *
-        * The Linux driver uses the following format:
-        *
-        *  0:7         tfd index - position within TX queue
-        *  8:12        TX queue id
-        *  13:14       reserved
-        *  15          unsolicited RX or uCode-originated notification
-        */
-       __le16 sequence;
-
-       /* command or response/notification data follows immediately */
-       u8 data[0];
-} __packed;
-
-
 /**
  * iwlagn rate_n_flags bit fields
  *
@@ -3151,8 +3096,6 @@ struct iwl_enhance_sensitivity_cmd {
  */
 
 /* Phy calibration command for series */
-/* The default calibrate table size if not specified by firmware */
-#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE    18
 enum {
        IWL_PHY_CALIBRATE_DC_CMD                = 8,
        IWL_PHY_CALIBRATE_LO_CMD                = 9,
@@ -3161,11 +3104,8 @@ enum {
        IWL_PHY_CALIBRATE_BASE_BAND_CMD         = 16,
        IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD        = 17,
        IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD       = 18,
-       IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19,
 };
 
-#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE         (253)
-
 /* This enum defines the bitmap of various calibrations to enable in both
  * init ucode and runtime ucode through CALIBRATION_CFG_CMD.
  */
@@ -3905,50 +3845,6 @@ struct iwlagn_wowlan_kek_kck_material_cmd {
        __le64  replay_ctr;
 } __packed;
 
-/******************************************************************************
- * (13)
- * Union of all expected notifications/responses:
- *
- *****************************************************************************/
-#define FH_RSCSR_FRAME_SIZE_MSK        (0x00003FFF)    /* bits 0-13 */
-
-struct iwl_rx_packet {
-       /*
-        * The first 4 bytes of the RX frame header contain both the RX frame
-        * size and some flags.
-        * Bit fields:
-        * 31:    flag flush RB request
-        * 30:    flag ignore TC (terminal counter) request
-        * 29:    flag fast IRQ request
-        * 28-14: Reserved
-        * 13-00: RX frame size
-        */
-       __le32 len_n_flags;
-       struct iwl_cmd_header hdr;
-       union {
-               struct iwl_alive_resp alive_frame;
-               struct iwl_spectrum_notification spectrum_notif;
-               struct iwl_csa_notification csa_notif;
-               struct iwl_error_resp err_resp;
-               struct iwl_card_state_notif card_state_notif;
-               struct iwl_add_sta_resp add_sta;
-               struct iwl_rem_sta_resp rem_sta;
-               struct iwl_sleep_notification sleep_notif;
-               struct iwl_spectrum_resp spectrum;
-               struct iwl_notif_statistics stats;
-               struct iwl_bt_notif_statistics stats_bt;
-               struct iwl_compressed_ba_resp compressed_ba;
-               struct iwl_missed_beacon_notif missed_beacon;
-               struct iwl_coex_medium_notification coex_medium_notif;
-               struct iwl_coex_event_resp coex_event;
-               struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
-               __le32 status;
-               u8 raw[0];
-       } u;
-} __packed;
-
-int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
-
 /*
  * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification)
  */
index f52d5458a3af7a2786af4d72f226de9c9cd93f63..f43f51d1570e7a717aba37076e5996bc86065f9d 100644 (file)
@@ -136,7 +136,7 @@ int iwl_init_geos(struct iwl_priv *priv)
        sband->bitrates = &rates[IWL_FIRST_OFDM_RATE];
        sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE;
 
-       if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE)
+       if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE)
                iwl_init_ht_hw_capab(priv, &sband->ht_cap,
                                         IEEE80211_BAND_5GHZ);
 
@@ -146,7 +146,7 @@ int iwl_init_geos(struct iwl_priv *priv)
        sband->bitrates = rates;
        sband->n_bitrates = IWL_RATE_COUNT_LEGACY;
 
-       if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE)
+       if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE)
                iwl_init_ht_hw_capab(priv, &sband->ht_cap,
                                         IEEE80211_BAND_2GHZ);
 
@@ -201,11 +201,11 @@ int iwl_init_geos(struct iwl_priv *priv)
        priv->tx_power_next = max_tx_power;
 
        if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
-            cfg(priv)->sku & EEPROM_SKU_CAP_BAND_52GHZ) {
+            hw_params(priv).sku & EEPROM_SKU_CAP_BAND_52GHZ) {
                IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
                        "Please send your %s to maintainer.\n",
                        trans(priv)->hw_id_str);
-               cfg(priv)->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ;
+               hw_params(priv).sku &= ~EEPROM_SKU_CAP_BAND_52GHZ;
        }
 
        IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n",
@@ -316,7 +316,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 
        conf = &priv->hw->conf;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd));
 
@@ -369,7 +369,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
                        le32_to_cpu(ctx->timing.beacon_init_val),
                        le16_to_cpu(ctx->timing.atim_window));
 
-       return iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_timing_cmd,
+       return iwl_dvm_send_cmd_pdu(priv, ctx->rxon_timing_cmd,
                                CMD_SYNC, sizeof(ctx->timing), &ctx->timing);
 }
 
@@ -829,18 +829,23 @@ void iwl_print_rx_config_cmd(struct iwl_priv *priv,
 }
 #endif
 
-void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
+static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
 {
        unsigned int reload_msec;
        unsigned long reload_jiffies;
 
+#ifdef CONFIG_IWLWIFI_DEBUG
+       if (iwl_have_debug_level(IWL_DL_FW_ERRORS))
+               iwl_print_rx_config_cmd(priv, IWL_RXON_CTX_BSS);
+#endif
+
        /* Set the FW error flag -- cleared on iwl_down */
        set_bit(STATUS_FW_ERROR, &priv->shrd->status);
 
        /* Cancel currently queued command. */
        clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status);
 
-       iwl_abort_notification_waits(priv->shrd);
+       iwl_abort_notification_waits(&priv->notif_wait);
 
        /* Keep the restart process from trying to send host
         * commands by clearing the ready bit */
@@ -887,7 +892,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
        bool defer;
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (priv->tx_power_user_lmt == tx_power && !force)
                return 0;
@@ -953,7 +958,7 @@ void iwl_send_bt_config(struct iwl_priv *priv)
        IWL_DEBUG_INFO(priv, "BT coex %s\n",
                (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
 
-       if (iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG,
+       if (iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG,
                             CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd))
                IWL_ERR(priv, "failed to send BT Coex Config\n");
 }
@@ -966,12 +971,12 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
        };
 
        if (flags & CMD_ASYNC)
-               return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD,
+               return iwl_dvm_send_cmd_pdu(priv, REPLY_STATISTICS_CMD,
                                              CMD_ASYNC,
                                               sizeof(struct iwl_statistics_cmd),
                                               &statistics_cmd);
        else
-               return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD,
+               return iwl_dvm_send_cmd_pdu(priv, REPLY_STATISTICS_CMD,
                                        CMD_SYNC,
                                        sizeof(struct iwl_statistics_cmd),
                                        &statistics_cmd);
@@ -998,7 +1003,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv)
 {
        u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE;
 
-       if (iwl_get_debug_level(priv->shrd) & IWL_DL_TX) {
+       if (iwl_have_debug_level(IWL_DL_TX)) {
                if (!priv->tx_traffic) {
                        priv->tx_traffic =
                                kzalloc(traffic_size, GFP_KERNEL);
@@ -1006,7 +1011,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv)
                                return -ENOMEM;
                }
        }
-       if (iwl_get_debug_level(priv->shrd) & IWL_DL_RX) {
+       if (iwl_have_debug_level(IWL_DL_RX)) {
                if (!priv->rx_traffic) {
                        priv->rx_traffic =
                                kzalloc(traffic_size, GFP_KERNEL);
@@ -1033,7 +1038,7 @@ void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv,
        __le16 fc;
        u16 len;
 
-       if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_TX)))
+       if (likely(!iwl_have_debug_level(IWL_DL_TX)))
                return;
 
        if (!priv->tx_traffic)
@@ -1057,7 +1062,7 @@ void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
        __le16 fc;
        u16 len;
 
-       if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_RX)))
+       if (likely(!iwl_have_debug_level(IWL_DL_RX)))
                return;
 
        if (!priv->rx_traffic)
@@ -1295,7 +1300,7 @@ int iwl_cmd_echo_test(struct iwl_priv *priv)
                .flags = CMD_SYNC,
        };
 
-       ret = iwl_trans_send_cmd(trans(priv), &cmd);
+       ret = iwl_dvm_send_cmd(priv, &cmd);
        if (ret)
                IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
        else
@@ -1335,24 +1340,14 @@ void iwl_bg_watchdog(unsigned long data)
        if (iwl_is_rfkill(priv->shrd))
                return;
 
-       timeout = cfg(priv)->base_params->wd_timeout;
+       timeout = hw_params(priv).wd_timeout;
        if (timeout == 0)
                return;
 
-       /* monitor and check for stuck cmd queue */
-       if (iwl_check_stuck_queue(priv, priv->shrd->cmd_queue))
-               return;
-
-       /* monitor and check for other stuck queues */
-       if (iwl_is_any_associated(priv)) {
-               for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) {
-                       /* skip as we already checked the command queue */
-                       if (cnt == priv->shrd->cmd_queue)
-                               continue;
-                       if (iwl_check_stuck_queue(priv, cnt))
-                               return;
-               }
-       }
+       /* monitor and check for stuck queues */
+       for (cnt = 0; cnt < cfg(priv)->base_params->num_of_queues; cnt++)
+               if (iwl_check_stuck_queue(priv, cnt))
+                       return;
 
        mod_timer(&priv->watchdog, jiffies +
                  msecs_to_jiffies(IWL_WD_TICK(timeout)));
@@ -1360,7 +1355,7 @@ void iwl_bg_watchdog(unsigned long data)
 
 void iwl_setup_watchdog(struct iwl_priv *priv)
 {
-       unsigned int timeout = cfg(priv)->base_params->wd_timeout;
+       unsigned int timeout = hw_params(priv).wd_timeout;
 
        if (!iwlagn_mod_params.wd_disable) {
                /* use system default */
@@ -1454,18 +1449,28 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
        return cpu_to_le32(res);
 }
 
-void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state)
+void iwl_nic_error(struct iwl_op_mode *op_mode)
 {
-       wiphy_rfkill_set_hw_state(priv->hw->wiphy, state);
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
+
+       iwlagn_fw_error(priv, false);
 }
 
-void iwl_nic_config(struct iwl_priv *priv)
+void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
 {
-       cfg(priv)->lib->nic_config(priv);
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
+
+       if (state)
+               set_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
+       else
+               clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status);
+
+       wiphy_rfkill_set_hw_state(priv->hw->wiphy, state);
 }
 
-void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb)
+void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb)
 {
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
        struct ieee80211_tx_info *info;
 
        info = IEEE80211_SKB_CB(skb);
@@ -1473,12 +1478,16 @@ void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb)
        dev_kfree_skb_any(skb);
 }
 
-void iwl_stop_sw_queue(struct iwl_priv *priv, u8 ac)
+void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac)
 {
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
+
        ieee80211_stop_queue(priv->hw, ac);
 }
 
-void iwl_wake_sw_queue(struct iwl_priv *priv, u8 ac)
+void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac)
 {
+       struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
+
        ieee80211_wake_queue(priv->hw, ac);
 }
index 930e247bbae6337e3d17a2cde92f6186edb1e45c..e0423c4c01c7fe79067d617f2bf227f0db2a21f5 100644 (file)
@@ -95,48 +95,6 @@ struct iwl_lib_ops {
        void (*temperature)(struct iwl_priv *priv);
 };
 
-/*
- * @max_ll_items: max number of OTP blocks
- * @shadow_ram_support: shadow support for OTP memory
- * @led_compensation: compensate on the led on/off time per HW according
- *     to the deviation to achieve the desired led frequency.
- *     The detail algorithm is described in iwl-led.c
- * @chain_noise_num_beacons: number of beacons used to compute chain noise
- * @adv_thermal_throttle: support advance thermal throttle
- * @support_ct_kill_exit: support ct kill exit condition
- * @support_wimax_coexist: support wimax/wifi co-exist
- * @plcp_delta_threshold: plcp error rate threshold used to trigger
- *     radio tuning when there is a high receiving plcp error rate
- * @chain_noise_scale: default chain noise scale used for gain computation
- * @wd_timeout: TX queues watchdog timeout
- * @max_event_log_size: size of event log buffer size for ucode event logging
- * @shadow_reg_enable: HW shadhow register bit
- * @no_idle_support: do not support idle mode
- * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
- * wd_disable: disable watchdog timer
- */
-struct iwl_base_params {
-       int eeprom_size;
-       int num_of_queues;      /* def: HW dependent */
-       int num_of_ampdu_queues;/* def: HW dependent */
-       /* for iwl_apm_init() */
-       u32 pll_cfg_val;
-
-       const u16 max_ll_items;
-       const bool shadow_ram_support;
-       u16 led_compensation;
-       bool adv_thermal_throttle;
-       bool support_ct_kill_exit;
-       const bool support_wimax_coexist;
-       u8 plcp_delta_threshold;
-       s32 chain_noise_scale;
-       unsigned int wd_timeout;
-       u32 max_event_log_size;
-       const bool shadow_reg_enable;
-       const bool no_idle_support;
-       const bool hd_v2;
-       const bool wd_disable;
-};
 /*
  * @advanced_bt_coexist: support advanced bt coexist
  * @bt_init_traffic_load: specify initial bt traffic load
@@ -197,6 +155,8 @@ const char *get_ctrl_string(int cmd);
 void iwl_clear_traffic_stats(struct iwl_priv *priv);
 void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc,
                      u16 len);
+void iwl_reset_traffic_log(struct iwl_priv *priv);
+
 #else
 static inline int iwl_alloc_traffic_mem(struct iwl_priv *priv)
 {
@@ -242,8 +202,6 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
 void iwl_force_scan_end(struct iwl_priv *priv);
 void iwl_internal_short_hw_scan(struct iwl_priv *priv);
 int iwl_force_reset(struct iwl_priv *priv, int mode, bool external);
-u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
-                      const u8 *ta, const u8 *ie, int ie_len, int left);
 void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
 void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
 void iwl_cancel_scan_deferred_work(struct iwl_priv *priv);
@@ -263,6 +221,10 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
 
 #define IWL_SCAN_CHECK_WATCHDOG                (HZ * 7)
 
+/* traffic log definitions */
+#define IWL_TRAFFIC_ENTRIES    (256)
+#define IWL_TRAFFIC_ENTRY_SIZE  (64)
+
 /*****************************************************
  *   S e n d i n g     H o s t     C o m m a n d s   *
  *****************************************************/
index 4bc2e70051d6f5701b539148880b61a6b99a5998..059efabda18424b3af7299f1fd676f43cb2e4865 100644 (file)
@@ -104,7 +104,7 @@ void __iwl_err(struct device *dev, bool rfkill_prefix, bool trace_only,
 }
 
 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
-void __iwl_dbg(struct iwl_shared *shared, struct device *dev,
+void __iwl_dbg(struct device *dev,
               u32 level, bool limit, const char *function,
               const char *fmt, ...)
 {
@@ -116,7 +116,7 @@ void __iwl_dbg(struct iwl_shared *shared, struct device *dev,
        va_start(args, fmt);
        vaf.va = &args;
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_get_debug_level(shared) & level &&
+       if (iwl_have_debug_level(level) &&
            (!limit || net_ratelimit()))
                dev_err(dev, "%c %s %pV", in_interrupt() ? 'I' : 'U',
                        function, &vaf);
index bfc08494ed22682e5fd71a9c11b99abcc1c8715f..a6b32a11e103092fd11ce2d074034fca9e23d854 100644 (file)
@@ -29,7 +29,6 @@
 #ifndef __iwl_debug_h__
 #define __iwl_debug_h__
 
-#include "iwl-bus.h"
 #include "iwl-shared.h"
 #include "iwl-devtrace.h"
 
@@ -48,12 +47,12 @@ void __iwl_crit(struct device *dev, const char *fmt, ...);
 #define IWL_CRIT(m, f, a...) __iwl_crit(trans(m)->dev, f, ## a)
 
 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
-void __iwl_dbg(struct iwl_shared *shared, struct device *dev,
+void __iwl_dbg(struct device *dev,
               u32 level, bool limit, const char *function,
               const char *fmt, ...);
 #else
 static inline void
-__iwl_dbg(struct iwl_shared *shared, struct device *dev,
+__iwl_dbg(struct device *dev,
          u32 level, bool limit, const char *function,
          const char *fmt, ...)
 {}
@@ -66,35 +65,19 @@ do {                                                                        \
 } while (0)
 
 #define IWL_DEBUG(m, level, fmt, args...)                              \
-       __iwl_dbg((m)->shrd, trans(m)->dev, level, false, __func__, fmt, ##args)
+       __iwl_dbg(trans(m)->dev, level, false, __func__, fmt, ##args)
 #define IWL_DEBUG_LIMIT(m, level, fmt, args...)                                \
-       __iwl_dbg((m)->shrd, trans(m)->dev, level, true, __func__, fmt, ##args)
+       __iwl_dbg(trans(m)->dev, level, true, __func__, fmt, ##args)
 
 #ifdef CONFIG_IWLWIFI_DEBUG
 #define iwl_print_hex_dump(m, level, p, len)                           \
 do {                                                                   \
-       if (iwl_get_debug_level((m)->shrd) & level)                     \
+       if (iwl_have_debug_level(level))                                \
                print_hex_dump(KERN_DEBUG, "iwl data: ",                \
                               DUMP_PREFIX_OFFSET, 16, 1, p, len, 1);   \
 } while (0)
-#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)        \
-do {                                                                   \
-       if (!iwl_is_rfkill((m)->shrd))                                  \
-               IWL_ERR(m, fmt, ##args);                                \
-       else                                                            \
-               __iwl_err(trans(m)->dev, true,                          \
-                         !(iwl_get_debug_level((m)->shrd) & IWL_DL_RADIO),\
-                         fmt, ##args);                                 \
-} while (0)
 #else
 #define iwl_print_hex_dump(m, level, p, len)
-#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)        \
-do {                                                                   \
-       if (!iwl_is_rfkill((m)->shrd))                                  \
-               IWL_ERR(m, fmt, ##args);                                \
-       else                                                            \
-               __iwl_err(trans(m)->dev, true, true, fmt, ##args);      \
-} while (0)
 #endif                         /* CONFIG_IWLWIFI_DEBUG */
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
index ad74138e1c7011a233bcdcc204242fa24917077f..0a898c54c733de4454ef125a3eb653ee2f9fe4ff 100644 (file)
@@ -40,7 +40,6 @@
 #include "iwl-core.h"
 #include "iwl-io.h"
 #include "iwl-agn.h"
-#include "iwl-wifi.h"
 
 /* create and remove of files */
 #define DEBUGFS_ADD_FILE(name, parent, mode) do {                      \
@@ -235,12 +234,11 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
 
        /* default is to dump the entire data segment */
        if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
-               struct iwl_nic *nic = nic(priv);
                priv->dbgfs_sram_offset = 0x800000;
-               if (nic->shrd->ucode_type == IWL_UCODE_INIT)
-                       priv->dbgfs_sram_len = nic->fw.ucode_init.data.len;
+               if (priv->shrd->ucode_type == IWL_UCODE_INIT)
+                       priv->dbgfs_sram_len = priv->fw->ucode_init.data.len;
                else
-                       priv->dbgfs_sram_len = nic->fw.ucode_rt.data.len;
+                       priv->dbgfs_sram_len = priv->fw->ucode_rt.data.len;
        }
        len = priv->dbgfs_sram_len;
 
@@ -343,7 +341,7 @@ static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
 
        return simple_read_from_buffer(user_buf, count, ppos,
                                       priv->wowlan_sram,
-                                      nic(priv)->fw.ucode_wowlan.data.len);
+                                      priv->fw->ucode_wowlan.data.len);
 }
 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
                                        size_t count, loff_t *ppos)
@@ -763,9 +761,9 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
 
        priv->power_data.debug_sleep_level_override = value;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_power_update_mode(priv, true);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        return count;
 }
@@ -845,8 +843,7 @@ static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
                IWL_ERR(priv, "Can not allocate buffer\n");
                return -ENOMEM;
        }
-       if (priv->tx_traffic &&
-               (iwl_get_debug_level(priv->shrd) & IWL_DL_TX)) {
+       if (priv->tx_traffic && iwl_have_debug_level(IWL_DL_TX)) {
                ptr = priv->tx_traffic;
                pos += scnprintf(buf + pos, bufsz - pos,
                                "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
@@ -864,8 +861,7 @@ static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
                }
        }
 
-       if (priv->rx_traffic &&
-               (iwl_get_debug_level(priv->shrd) & IWL_DL_RX)) {
+       if (priv->rx_traffic && iwl_have_debug_level(IWL_DL_RX)) {
                ptr = priv->rx_traffic;
                pos += scnprintf(buf + pos, bufsz - pos,
                                "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
@@ -920,6 +916,8 @@ static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
        int p = 0;
        u32 flag;
 
+       lockdep_assert_held(&priv->statistics.lock);
+
        flag = le32_to_cpu(priv->statistics.flag);
 
        p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
@@ -967,6 +965,7 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
         * the last statistics notification from uCode
         * might not reflect the current uCode activity
         */
+       spin_lock_bh(&priv->statistics.lock);
        ofdm = &priv->statistics.rx_ofdm;
        cck = &priv->statistics.rx_cck;
        general = &priv->statistics.rx_non_phy;
@@ -1363,6 +1362,8 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
                         accum_ht->unsupport_mcs,
                         delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
 
+       spin_unlock_bh(&priv->statistics.lock);
+
        ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
        kfree(buf);
        return ret;
@@ -1392,6 +1393,8 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
         * the last statistics notification from uCode
         * might not reflect the current uCode activity
         */
+       spin_lock_bh(&priv->statistics.lock);
+
        tx = &priv->statistics.tx;
        accum_tx = &priv->accum_stats.tx;
        delta_tx = &priv->delta_stats.tx;
@@ -1541,19 +1544,25 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
        if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
                pos += scnprintf(buf + pos, bufsz - pos,
                        "tx power: (1/2 dB step)\n");
-               if ((cfg(priv)->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
+               if ((hw_params(priv).valid_tx_ant & ANT_A) &&
+                   tx->tx_power.ant_a)
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        fmt_hex, "antenna A:",
                                        tx->tx_power.ant_a);
-               if ((cfg(priv)->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
+               if ((hw_params(priv).valid_tx_ant & ANT_B) &&
+                   tx->tx_power.ant_b)
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        fmt_hex, "antenna B:",
                                        tx->tx_power.ant_b);
-               if ((cfg(priv)->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
+               if ((hw_params(priv).valid_tx_ant & ANT_C) &&
+                   tx->tx_power.ant_c)
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        fmt_hex, "antenna C:",
                                        tx->tx_power.ant_c);
        }
+
+       spin_unlock_bh(&priv->statistics.lock);
+
        ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
        kfree(buf);
        return ret;
@@ -1586,6 +1595,9 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
         * the last statistics notification from uCode
         * might not reflect the current uCode activity
         */
+
+       spin_lock_bh(&priv->statistics.lock);
+
        general = &priv->statistics.common;
        dbg = &priv->statistics.common.dbg;
        div = &priv->statistics.common.div;
@@ -1670,6 +1682,9 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
                         accum_general->num_of_sos_states,
                         delta_general->num_of_sos_states,
                         max_general->num_of_sos_states);
+
+       spin_unlock_bh(&priv->statistics.lock);
+
        ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
        kfree(buf);
        return ret;
@@ -1693,9 +1708,9 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
                return -EINVAL;
 
        /* make request to uCode to retrieve statistics information */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        if (ret) {
                IWL_ERR(priv,
@@ -1713,6 +1728,9 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
         * the last statistics notification from uCode
         * might not reflect the current uCode activity
         */
+
+       spin_lock_bh(&priv->statistics.lock);
+
        bt = &priv->statistics.bt_activity;
        accum_bt = &priv->accum_stats.bt_activity;
 
@@ -1758,6 +1776,8 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
                         le32_to_cpu(priv->statistics.num_bt_kills),
                         priv->statistics.accum_num_bt_kills);
 
+       spin_unlock_bh(&priv->statistics.lock);
+
        ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
        kfree(buf);
        return ret;
@@ -2086,9 +2106,9 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
                return -EFAULT;
 
        /* make request to uCode to retrieve statistics information */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_send_statistics_request(priv, CMD_SYNC, true);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        return count;
 }
@@ -2221,7 +2241,7 @@ static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
        const size_t bufsz = sizeof(buf);
 
        pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
-                       cfg(priv)->base_params->plcp_delta_threshold);
+                       priv->plcp_delta_threshold);
 
        return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
 }
@@ -2243,10 +2263,10 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
                return -EINVAL;
        if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
                (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
-               cfg(priv)->base_params->plcp_delta_threshold =
+               priv->plcp_delta_threshold =
                        IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
        else
-               cfg(priv)->base_params->plcp_delta_threshold = plcp;
+               priv->plcp_delta_threshold = plcp;
        return count;
 }
 
@@ -2348,7 +2368,7 @@ static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file,
        if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT)
                timeout = IWL_DEF_WD_TIMEOUT;
 
-       cfg(priv)->base_params->wd_timeout = timeout;
+       hw_params(priv).wd_timeout = timeout;
        iwl_setup_watchdog(priv);
        return count;
 }
@@ -2411,7 +2431,7 @@ static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
        if (cfg(priv)->ht_params)
                pos += scnprintf(buf + pos, bufsz - pos,
                         "use %s for aggregation\n",
-                        (cfg(priv)->ht_params->use_rts_for_aggregation) ?
+                        (hw_params(priv).use_rts_for_aggregation) ?
                                "rts/cts" : "cts-to-self");
        else
                pos += scnprintf(buf + pos, bufsz - pos, "N/A");
@@ -2438,9 +2458,9 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
        if (sscanf(buf, "%d", &rts) != 1)
                return -EINVAL;
        if (rts)
-               cfg(priv)->ht_params->use_rts_for_aggregation = true;
+               hw_params(priv).use_rts_for_aggregation = true;
        else
-               cfg(priv)->ht_params->use_rts_for_aggregation = false;
+               hw_params(priv).use_rts_for_aggregation = false;
        return count;
 }
 
@@ -2486,52 +2506,6 @@ DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
 DEBUGFS_READ_FILE_OPS(reply_tx_error);
 DEBUGFS_WRITE_FILE_OPS(echo_test);
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-static ssize_t iwl_dbgfs_debug_level_read(struct file *file,
-                                         char __user *user_buf,
-                                         size_t count, loff_t *ppos)
-{
-       struct iwl_priv *priv = file->private_data;
-       struct iwl_shared *shrd = priv->shrd;
-       char buf[11];
-       int len;
-
-       len = scnprintf(buf, sizeof(buf), "0x%.8x",
-                       iwl_get_debug_level(shrd));
-
-       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
-}
-
-static ssize_t iwl_dbgfs_debug_level_write(struct file *file,
-                                          const char __user *user_buf,
-                                          size_t count, loff_t *ppos)
-{
-       struct iwl_priv *priv = file->private_data;
-       struct iwl_shared *shrd = priv->shrd;
-       char buf[11];
-       unsigned long val;
-       int ret;
-
-       if (count > sizeof(buf))
-               return -EINVAL;
-
-       memset(buf, 0, sizeof(buf));
-       if (copy_from_user(buf, user_buf, count))
-               return -EFAULT;
-
-       ret = strict_strtoul(buf, 0, &val);
-       if (ret)
-               return ret;
-
-       shrd->dbg_level_dev = val;
-       if (iwl_alloc_traffic_mem(priv))
-               IWL_ERR(priv, "Not enough memory to generate traffic log\n");
-
-       return count;
-}
-DEBUGFS_READ_WRITE_FILE_OPS(debug_level);
-#endif /* CONFIG_IWLWIFI_DEBUG */
-
 /*
  * Create the debugfs files and directories
  *
@@ -2596,9 +2570,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR);
        if (iwl_advanced_bt_coexist(priv))
                DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
-#ifdef CONFIG_IWLWIFI_DEBUG
-       DEBUGFS_ADD_FILE(debug_level, dir_debug, S_IRUSR | S_IWUSR);
-#endif
 
        DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
                         &priv->disable_sens_cal);
index 494c696dc1779468504acd3f4a7675c60c008751..d1e722bd9f5b45c76ec4a1280b0e1988c68264ef 100644 (file)
 #include <linux/wait.h>
 #include <linux/leds.h>
 #include <linux/slab.h>
-#include <net/ieee80211_radiotap.h>
+#include <linux/mutex.h>
 
 #include "iwl-eeprom.h"
 #include "iwl-csr.h"
-#include "iwl-prph.h"
 #include "iwl-debug.h"
 #include "iwl-agn-hw.h"
 #include "iwl-led.h"
 #include "iwl-power.h"
 #include "iwl-agn-rs.h"
 #include "iwl-agn-tt.h"
-#include "iwl-bus.h"
 #include "iwl-trans.h"
 #include "iwl-shared.h"
+#include "iwl-op-mode.h"
+#include "iwl-notif-wait.h"
 
 struct iwl_tx_queue;
 
@@ -442,9 +442,6 @@ struct iwl_chain_noise_data {
        u8 state;
 };
 
-#define        EEPROM_SEM_TIMEOUT 10           /* milliseconds */
-#define EEPROM_SEM_RETRY_LIMIT 1000    /* number of attempts (not time) */
-
 enum {
        MEASUREMENT_READY = (1 << 0),
        MEASUREMENT_ACTIVE = (1 << 1),
@@ -674,9 +671,6 @@ struct iwl_rxon_context {
                u8 extension_chan_offset;
        } ht;
 
-       u8 bssid[ETH_ALEN];
-       bool preauth_bssid;
-
        bool last_tx_rejected;
 };
 
@@ -710,10 +704,21 @@ struct iwl_wipan_noa_data {
        u8 data[];
 };
 
+#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
+       ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
+
+#define IWL_MAC80211_GET_DVM(_hw) \
+       ((struct iwl_priv *) ((struct iwl_op_mode *) \
+       (_hw)->priv)->op_mode_specific)
+
 struct iwl_priv {
 
        /*data shared among all the driver's layers */
        struct iwl_shared *shrd;
+       const struct iwl_fw *fw;
+
+       spinlock_t sta_lock;
+       struct mutex mutex;
 
        /* ieee device used by generic ieee processing code */
        struct ieee80211_hw *hw;
@@ -721,22 +726,30 @@ struct iwl_priv {
        struct ieee80211_rate *ieee_rates;
        struct kmem_cache *tx_cmd_pool;
 
+       struct list_head calib_results;
+
        struct workqueue_struct *workqueue;
 
        enum ieee80211_band band;
 
        void (*pre_rx_handler)(struct iwl_priv *priv,
-                              struct iwl_rx_mem_buffer *rxb);
+                              struct iwl_rx_cmd_buffer *rxb);
        int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
-                                      struct iwl_rx_mem_buffer *rxb,
+                                      struct iwl_rx_cmd_buffer *rxb,
                                       struct iwl_device_cmd *cmd);
 
+       struct iwl_notif_wait_data notif_wait;
+
        struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
 
        /* spectrum measurement report caching */
        struct iwl_spectrum_notification measure_report;
        u8 measurement_status;
 
+#define IWL_OWNERSHIP_DRIVER   0
+#define IWL_OWNERSHIP_TM       1
+       u8 ucode_owner;
+
        /* ucode beacon time */
        u32 ucode_beacon_time;
        int missed_beacon_threshold;
@@ -762,6 +775,8 @@ struct iwl_priv {
        struct iwl_channel_info *channel_info;  /* channel info array */
        u8 channel_count;       /* # of channels */
 
+       u8 plcp_delta_threshold;
+
        /* thermal calibration */
        s32 temperature;        /* Celsius */
        s32 last_temperature;
@@ -784,6 +799,8 @@ struct iwl_priv {
 
        bool new_scan_threshold_behaviour;
 
+       bool wowlan;
+
        /* EEPROM MAC addresses */
        struct mac_address addresses[2];
 
@@ -841,6 +858,7 @@ struct iwl_priv {
                struct statistics_bt_activity bt_activity;
                __le32 num_bt_kills, accum_num_bt_kills;
 #endif
+               spinlock_t lock;
        } statistics;
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        struct {
index 96e62338cec0a9ce489d35a85ef0b20abff76c57..06203d6a1d86fe50c38c590ded15954aa0ab0c04 100644 (file)
@@ -41,130 +41,134 @@ static inline void trace_ ## name(proto) {}
 static inline void trace_ ## name(proto) {}
 #endif
 
-#define PRIV_ENTRY     __field(void *, priv)
-#define PRIV_ASSIGN    __entry->priv = priv
+#define DEV_ENTRY      __string(dev, dev_name(dev))
+#define DEV_ASSIGN     __assign_str(dev, dev_name(dev))
 
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM iwlwifi_io
 
 TRACE_EVENT(iwlwifi_dev_ioread32,
-       TP_PROTO(void *priv, u32 offs, u32 val),
-       TP_ARGS(priv, offs, val),
+       TP_PROTO(const struct device *dev, u32 offs, u32 val),
+       TP_ARGS(dev, offs, val),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __field(u32, offs)
                __field(u32, val)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->offs = offs;
                __entry->val = val;
        ),
-       TP_printk("[%p] read io[%#x] = %#x", __entry->priv, __entry->offs, __entry->val)
+       TP_printk("[%s] read io[%#x] = %#x",
+                 __get_str(dev), __entry->offs, __entry->val)
 );
 
 TRACE_EVENT(iwlwifi_dev_iowrite8,
-       TP_PROTO(void *priv, u32 offs, u8 val),
-       TP_ARGS(priv, offs, val),
+       TP_PROTO(const struct device *dev, u32 offs, u8 val),
+       TP_ARGS(dev, offs, val),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __field(u32, offs)
                __field(u8, val)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->offs = offs;
                __entry->val = val;
        ),
-       TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, __entry->offs, __entry->val)
+       TP_printk("[%s] write io[%#x] = %#x)",
+                 __get_str(dev), __entry->offs, __entry->val)
 );
 
 TRACE_EVENT(iwlwifi_dev_iowrite32,
-       TP_PROTO(void *priv, u32 offs, u32 val),
-       TP_ARGS(priv, offs, val),
+       TP_PROTO(const struct device *dev, u32 offs, u32 val),
+       TP_ARGS(dev, offs, val),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __field(u32, offs)
                __field(u32, val)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->offs = offs;
                __entry->val = val;
        ),
-       TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, __entry->offs, __entry->val)
+       TP_printk("[%s] write io[%#x] = %#x)",
+                 __get_str(dev), __entry->offs, __entry->val)
 );
 
 TRACE_EVENT(iwlwifi_dev_irq,
-       TP_PROTO(void *priv),
-       TP_ARGS(priv),
+       TP_PROTO(const struct device *dev),
+       TP_ARGS(dev),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
        ),
        /* TP_printk("") doesn't compile */
        TP_printk("%d", 0)
 );
 
 TRACE_EVENT(iwlwifi_dev_ict_read,
-       TP_PROTO(void *priv, u32 index, u32 value),
-       TP_ARGS(priv, index, value),
+       TP_PROTO(const struct device *dev, u32 index, u32 value),
+       TP_ARGS(dev, index, value),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __field(u32, index)
                __field(u32, value)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->index = index;
                __entry->value = value;
        ),
-       TP_printk("read ict[%d] = %#.8x", __entry->index, __entry->value)
+       TP_printk("[%s] read ict[%d] = %#.8x",
+                 __get_str(dev), __entry->index, __entry->value)
 );
 
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM iwlwifi_ucode
 
 TRACE_EVENT(iwlwifi_dev_ucode_cont_event,
-       TP_PROTO(void *priv, u32 time, u32 data, u32 ev),
-       TP_ARGS(priv, time, data, ev),
+       TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
+       TP_ARGS(dev, time, data, ev),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
 
                __field(u32, time)
                __field(u32, data)
                __field(u32, ev)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->time = time;
                __entry->data = data;
                __entry->ev = ev;
        ),
-       TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u",
-                 __entry->priv, __entry->time, __entry->data, __entry->ev)
+       TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
+                 __get_str(dev), __entry->time, __entry->data, __entry->ev)
 );
 
 TRACE_EVENT(iwlwifi_dev_ucode_wrap_event,
-       TP_PROTO(void *priv, u32 wraps, u32 n_entry, u32 p_entry),
-       TP_ARGS(priv, wraps, n_entry, p_entry),
+       TP_PROTO(const struct device *dev, u32 wraps, u32 n_entry, u32 p_entry),
+       TP_ARGS(dev, wraps, n_entry, p_entry),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
 
                __field(u32, wraps)
                __field(u32, n_entry)
                __field(u32, p_entry)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->wraps = wraps;
                __entry->n_entry = n_entry;
                __entry->p_entry = p_entry;
        ),
-       TP_printk("[%p] wraps=#%02d n=0x%X p=0x%X",
-                 __entry->priv, __entry->wraps, __entry->n_entry,
+       TP_printk("[%s] wraps=#%02d n=0x%X p=0x%X",
+                 __get_str(dev), __entry->wraps, __entry->n_entry,
                  __entry->p_entry)
 );
 
@@ -232,52 +236,52 @@ TRACE_EVENT(iwlwifi_dbg,
 #define TRACE_SYSTEM iwlwifi
 
 TRACE_EVENT(iwlwifi_dev_hcmd,
-       TP_PROTO(void *priv, u32 flags,
+       TP_PROTO(const struct device *dev, u32 flags,
                 const void *hcmd0, size_t len0,
                 const void *hcmd1, size_t len1,
                 const void *hcmd2, size_t len2),
-       TP_ARGS(priv, flags, hcmd0, len0, hcmd1, len1, hcmd2, len2),
+       TP_ARGS(dev, flags, hcmd0, len0, hcmd1, len1, hcmd2, len2),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __dynamic_array(u8, hcmd0, len0)
                __dynamic_array(u8, hcmd1, len1)
                __dynamic_array(u8, hcmd2, len2)
                __field(u32, flags)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                memcpy(__get_dynamic_array(hcmd0), hcmd0, len0);
                memcpy(__get_dynamic_array(hcmd1), hcmd1, len1);
                memcpy(__get_dynamic_array(hcmd2), hcmd2, len2);
                __entry->flags = flags;
        ),
-       TP_printk("[%p] hcmd %#.2x (%ssync)",
-                 __entry->priv, ((u8 *)__get_dynamic_array(hcmd0))[0],
+       TP_printk("[%s] hcmd %#.2x (%ssync)",
+                 __get_str(dev), ((u8 *)__get_dynamic_array(hcmd0))[0],
                  __entry->flags & CMD_ASYNC ? "a" : "")
 );
 
 TRACE_EVENT(iwlwifi_dev_rx,
-       TP_PROTO(void *priv, void *rxbuf, size_t len),
-       TP_ARGS(priv, rxbuf, len),
+       TP_PROTO(const struct device *dev, void *rxbuf, size_t len),
+       TP_ARGS(dev, rxbuf, len),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __dynamic_array(u8, rxbuf, len)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                memcpy(__get_dynamic_array(rxbuf), rxbuf, len);
        ),
-       TP_printk("[%p] RX cmd %#.2x",
-                 __entry->priv, ((u8 *)__get_dynamic_array(rxbuf))[4])
+       TP_printk("[%s] RX cmd %#.2x",
+                 __get_str(dev), ((u8 *)__get_dynamic_array(rxbuf))[4])
 );
 
 TRACE_EVENT(iwlwifi_dev_tx,
-       TP_PROTO(void *priv, void *tfd, size_t tfdlen,
+       TP_PROTO(const struct device *dev, void *tfd, size_t tfdlen,
                 void *buf0, size_t buf0_len,
                 void *buf1, size_t buf1_len),
-       TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len),
+       TP_ARGS(dev, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
 
                __field(size_t, framelen)
                __dynamic_array(u8, tfd, tfdlen)
@@ -291,29 +295,28 @@ TRACE_EVENT(iwlwifi_dev_tx,
                __dynamic_array(u8, buf1, buf1_len)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->framelen = buf0_len + buf1_len;
                memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
                memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
                memcpy(__get_dynamic_array(buf1), buf1, buf1_len);
        ),
-       TP_printk("[%p] TX %.2x (%zu bytes)",
-                 __entry->priv,
-                 ((u8 *)__get_dynamic_array(buf0))[0],
+       TP_printk("[%s] TX %.2x (%zu bytes)",
+                 __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
                  __entry->framelen)
 );
 
 TRACE_EVENT(iwlwifi_dev_ucode_error,
-       TP_PROTO(void *priv, u32 desc, u32 tsf_low,
+       TP_PROTO(const struct device *dev, u32 desc, u32 tsf_low,
                 u32 data1, u32 data2, u32 line, u32 blink1,
                 u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time,
                 u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver,
                 u32 brd_ver),
-       TP_ARGS(priv, desc, tsf_low, data1, data2, line,
+       TP_ARGS(dev, desc, tsf_low, data1, data2, line,
                blink1, blink2, ilink1, ilink2, bcon_time, gp1, gp2,
                gp3, ucode_ver, hw_ver, brd_ver),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
                __field(u32, desc)
                __field(u32, tsf_low)
                __field(u32, data1)
@@ -332,7 +335,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_error,
                __field(u32, brd_ver)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->desc = desc;
                __entry->tsf_low = tsf_low;
                __entry->data1 = data1;
@@ -350,11 +353,11 @@ TRACE_EVENT(iwlwifi_dev_ucode_error,
                __entry->hw_ver = hw_ver;
                __entry->brd_ver = brd_ver;
        ),
-       TP_printk("[%p] #%02d %010u data 0x%08X 0x%08X line %u, "
+       TP_printk("[%s] #%02d %010u data 0x%08X 0x%08X line %u, "
                  "blink 0x%05X 0x%05X ilink 0x%05X 0x%05X "
                  "bcon_tm %010u gp 0x%08X 0x%08X 0x%08X uCode 0x%08X "
                  "hw 0x%08X brd 0x%08X",
-                 __entry->priv, __entry->desc, __entry->tsf_low,
+                 __get_str(dev), __entry->desc, __entry->tsf_low,
                  __entry->data1,
                  __entry->data2, __entry->line, __entry->blink1,
                  __entry->blink2, __entry->ilink1, __entry->ilink2,
@@ -364,23 +367,23 @@ TRACE_EVENT(iwlwifi_dev_ucode_error,
 );
 
 TRACE_EVENT(iwlwifi_dev_ucode_event,
-       TP_PROTO(void *priv, u32 time, u32 data, u32 ev),
-       TP_ARGS(priv, time, data, ev),
+       TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
+       TP_ARGS(dev, time, data, ev),
        TP_STRUCT__entry(
-               PRIV_ENTRY
+               DEV_ENTRY
 
                __field(u32, time)
                __field(u32, data)
                __field(u32, ev)
        ),
        TP_fast_assign(
-               PRIV_ASSIGN;
+               DEV_ASSIGN;
                __entry->time = time;
                __entry->data = data;
                __entry->ev = ev;
        ),
-       TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u",
-                 __entry->priv, __entry->time, __entry->data, __entry->ev)
+       TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
+                 __get_str(dev), __entry->time, __entry->data, __entry->ev)
 );
 #endif /* __IWLWIFI_DEVICE_TRACE */
 
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
new file mode 100644 (file)
index 0000000..29a3ae4
--- /dev/null
@@ -0,0 +1,763 @@
+/******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#include <linux/completion.h>
+#include <linux/dma-mapping.h>
+#include <linux/firmware.h>
+#include <linux/module.h>
+
+#include "iwl-drv.h"
+#include "iwl-trans.h"
+#include "iwl-shared.h"
+#include "iwl-op-mode.h"
+
+/* private includes */
+#include "iwl-fw-file.h"
+
+/**
+ * struct iwl_drv - drv common data
+ * @fw: the iwl_fw structure
+ * @shrd: pointer to common shared structure
+ * @op_mode: the running op_mode
+ * @fw_index: firmware revision to try loading
+ * @firmware_name: composite filename of ucode file to load
+ * @request_firmware_complete: the firmware has been obtained from user space
+ */
+struct iwl_drv {
+       struct iwl_fw fw;
+
+       struct iwl_shared *shrd;
+       struct iwl_op_mode *op_mode;
+
+       int fw_index;                   /* firmware we're trying to load */
+       char firmware_name[25];         /* name of firmware file to load */
+
+       struct completion request_firmware_complete;
+};
+
+
+
+static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
+{
+       if (desc->v_addr)
+               dma_free_coherent(trans(drv)->dev, desc->len,
+                                 desc->v_addr, desc->p_addr);
+       desc->v_addr = NULL;
+       desc->len = 0;
+}
+
+static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img)
+{
+       iwl_free_fw_desc(drv, &img->code);
+       iwl_free_fw_desc(drv, &img->data);
+}
+
+static void iwl_dealloc_ucode(struct iwl_drv *drv)
+{
+       iwl_free_fw_img(drv, &drv->fw.ucode_rt);
+       iwl_free_fw_img(drv, &drv->fw.ucode_init);
+       iwl_free_fw_img(drv, &drv->fw.ucode_wowlan);
+}
+
+static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
+                     const void *data, size_t len)
+{
+       if (!len) {
+               desc->v_addr = NULL;
+               return -EINVAL;
+       }
+
+       desc->v_addr = dma_alloc_coherent(trans(drv)->dev, len,
+                                         &desc->p_addr, GFP_KERNEL);
+       if (!desc->v_addr)
+               return -ENOMEM;
+
+       desc->len = len;
+       memcpy(desc->v_addr, data, len);
+       return 0;
+}
+
+static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
+
+#define UCODE_EXPERIMENTAL_INDEX       100
+#define UCODE_EXPERIMENTAL_TAG         "exp"
+
+static int iwl_request_firmware(struct iwl_drv *drv, bool first)
+{
+       const struct iwl_cfg *cfg = cfg(drv);
+       const char *name_pre = cfg->fw_name_pre;
+       char tag[8];
+
+       if (first) {
+#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
+               drv->fw_index = UCODE_EXPERIMENTAL_INDEX;
+               strcpy(tag, UCODE_EXPERIMENTAL_TAG);
+       } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) {
+#endif
+               drv->fw_index = cfg->ucode_api_max;
+               sprintf(tag, "%d", drv->fw_index);
+       } else {
+               drv->fw_index--;
+               sprintf(tag, "%d", drv->fw_index);
+       }
+
+       if (drv->fw_index < cfg->ucode_api_min) {
+               IWL_ERR(drv, "no suitable firmware found!\n");
+               return -ENOENT;
+       }
+
+       sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
+
+       IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n",
+                      (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
+                               ? "EXPERIMENTAL " : "",
+                      drv->firmware_name);
+
+       return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
+                                      trans(drv)->dev,
+                                      GFP_KERNEL, drv, iwl_ucode_callback);
+}
+
+struct iwlagn_firmware_pieces {
+       const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data;
+       size_t inst_size, data_size, init_size, init_data_size,
+              wowlan_inst_size, wowlan_data_size;
+
+       u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
+       u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
+};
+
+static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
+                                      const struct firmware *ucode_raw,
+                                      struct iwlagn_firmware_pieces *pieces)
+{
+       struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
+       u32 api_ver, hdr_size, build;
+       char buildstr[25];
+       const u8 *src;
+
+       drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
+       api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
+
+       switch (api_ver) {
+       default:
+               hdr_size = 28;
+               if (ucode_raw->size < hdr_size) {
+                       IWL_ERR(drv, "File size too small!\n");
+                       return -EINVAL;
+               }
+               build = le32_to_cpu(ucode->u.v2.build);
+               pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size);
+               pieces->data_size = le32_to_cpu(ucode->u.v2.data_size);
+               pieces->init_size = le32_to_cpu(ucode->u.v2.init_size);
+               pieces->init_data_size =
+                       le32_to_cpu(ucode->u.v2.init_data_size);
+               src = ucode->u.v2.data;
+               break;
+       case 0:
+       case 1:
+       case 2:
+               hdr_size = 24;
+               if (ucode_raw->size < hdr_size) {
+                       IWL_ERR(drv, "File size too small!\n");
+                       return -EINVAL;
+               }
+               build = 0;
+               pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size);
+               pieces->data_size = le32_to_cpu(ucode->u.v1.data_size);
+               pieces->init_size = le32_to_cpu(ucode->u.v1.init_size);
+               pieces->init_data_size =
+                       le32_to_cpu(ucode->u.v1.init_data_size);
+               src = ucode->u.v1.data;
+               break;
+       }
+
+       if (build)
+               sprintf(buildstr, " build %u%s", build,
+                      (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
+                               ? " (EXP)" : "");
+       else
+               buildstr[0] = '\0';
+
+       snprintf(drv->fw.fw_version,
+                sizeof(drv->fw.fw_version),
+                "%u.%u.%u.%u%s",
+                IWL_UCODE_MAJOR(drv->fw.ucode_ver),
+                IWL_UCODE_MINOR(drv->fw.ucode_ver),
+                IWL_UCODE_API(drv->fw.ucode_ver),
+                IWL_UCODE_SERIAL(drv->fw.ucode_ver),
+                buildstr);
+
+       /* Verify size of file vs. image size info in file's header */
+       if (ucode_raw->size != hdr_size + pieces->inst_size +
+                               pieces->data_size + pieces->init_size +
+                               pieces->init_data_size) {
+
+               IWL_ERR(drv,
+                       "uCode file size %d does not match expected size\n",
+                       (int)ucode_raw->size);
+               return -EINVAL;
+       }
+
+       pieces->inst = src;
+       src += pieces->inst_size;
+       pieces->data = src;
+       src += pieces->data_size;
+       pieces->init = src;
+       src += pieces->init_size;
+       pieces->init_data = src;
+       src += pieces->init_data_size;
+
+       return 0;
+}
+
+static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
+                               const struct firmware *ucode_raw,
+                               struct iwlagn_firmware_pieces *pieces,
+                               struct iwl_ucode_capabilities *capa)
+{
+       struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
+       struct iwl_ucode_tlv *tlv;
+       size_t len = ucode_raw->size;
+       const u8 *data;
+       int wanted_alternative = iwlagn_mod_params.wanted_ucode_alternative;
+       int tmp;
+       u64 alternatives;
+       u32 tlv_len;
+       enum iwl_ucode_tlv_type tlv_type;
+       const u8 *tlv_data;
+       char buildstr[25];
+       u32 build;
+
+       if (len < sizeof(*ucode)) {
+               IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
+               return -EINVAL;
+       }
+
+       if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
+               IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
+                       le32_to_cpu(ucode->magic));
+               return -EINVAL;
+       }
+
+       /*
+        * Check which alternatives are present, and "downgrade"
+        * when the chosen alternative is not present, warning
+        * the user when that happens. Some files may not have
+        * any alternatives, so don't warn in that case.
+        */
+       alternatives = le64_to_cpu(ucode->alternatives);
+       tmp = wanted_alternative;
+       if (wanted_alternative > 63)
+               wanted_alternative = 63;
+       while (wanted_alternative && !(alternatives & BIT(wanted_alternative)))
+               wanted_alternative--;
+       if (wanted_alternative && wanted_alternative != tmp)
+               IWL_WARN(drv,
+                        "uCode alternative %d not available, choosing %d\n",
+                        tmp, wanted_alternative);
+
+       drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
+       build = le32_to_cpu(ucode->build);
+
+       if (build)
+               sprintf(buildstr, " build %u%s", build,
+                      (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
+                               ? " (EXP)" : "");
+       else
+               buildstr[0] = '\0';
+
+       snprintf(drv->fw.fw_version,
+                sizeof(drv->fw.fw_version),
+                "%u.%u.%u.%u%s",
+                IWL_UCODE_MAJOR(drv->fw.ucode_ver),
+                IWL_UCODE_MINOR(drv->fw.ucode_ver),
+                IWL_UCODE_API(drv->fw.ucode_ver),
+                IWL_UCODE_SERIAL(drv->fw.ucode_ver),
+                buildstr);
+
+       data = ucode->data;
+
+       len -= sizeof(*ucode);
+
+       while (len >= sizeof(*tlv)) {
+               u16 tlv_alt;
+
+               len -= sizeof(*tlv);
+               tlv = (void *)data;
+
+               tlv_len = le32_to_cpu(tlv->length);
+               tlv_type = le16_to_cpu(tlv->type);
+               tlv_alt = le16_to_cpu(tlv->alternative);
+               tlv_data = tlv->data;
+
+               if (len < tlv_len) {
+                       IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
+                               len, tlv_len);
+                       return -EINVAL;
+               }
+               len -= ALIGN(tlv_len, 4);
+               data += sizeof(*tlv) + ALIGN(tlv_len, 4);
+
+               /*
+                * Alternative 0 is always valid.
+                *
+                * Skip alternative TLVs that are not selected.
+                */
+               if (tlv_alt != 0 && tlv_alt != wanted_alternative)
+                       continue;
+
+               switch (tlv_type) {
+               case IWL_UCODE_TLV_INST:
+                       pieces->inst = tlv_data;
+                       pieces->inst_size = tlv_len;
+                       break;
+               case IWL_UCODE_TLV_DATA:
+                       pieces->data = tlv_data;
+                       pieces->data_size = tlv_len;
+                       break;
+               case IWL_UCODE_TLV_INIT:
+                       pieces->init = tlv_data;
+                       pieces->init_size = tlv_len;
+                       break;
+               case IWL_UCODE_TLV_INIT_DATA:
+                       pieces->init_data = tlv_data;
+                       pieces->init_data_size = tlv_len;
+                       break;
+               case IWL_UCODE_TLV_BOOT:
+                       IWL_ERR(drv, "Found unexpected BOOT ucode\n");
+                       break;
+               case IWL_UCODE_TLV_PROBE_MAX_LEN:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       capa->max_probe_length =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_PAN:
+                       if (tlv_len)
+                               goto invalid_tlv_len;
+                       capa->flags |= IWL_UCODE_TLV_FLAGS_PAN;
+                       break;
+               case IWL_UCODE_TLV_FLAGS:
+                       /* must be at least one u32 */
+                       if (tlv_len < sizeof(u32))
+                               goto invalid_tlv_len;
+                       /* and a proper number of u32s */
+                       if (tlv_len % sizeof(u32))
+                               goto invalid_tlv_len;
+                       /*
+                        * This driver only reads the first u32 as
+                        * right now no more features are defined,
+                        * if that changes then either the driver
+                        * will not work with the new firmware, or
+                        * it'll not take advantage of new features.
+                        */
+                       capa->flags = le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       pieces->init_evtlog_ptr =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_INIT_EVTLOG_SIZE:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       pieces->init_evtlog_size =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_INIT_ERRLOG_PTR:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       pieces->init_errlog_ptr =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_RUNT_EVTLOG_PTR:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       pieces->inst_evtlog_ptr =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       pieces->inst_evtlog_size =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_RUNT_ERRLOG_PTR:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       pieces->inst_errlog_ptr =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
+                       if (tlv_len)
+                               goto invalid_tlv_len;
+                       drv->fw.enhance_sensitivity_table = true;
+                       break;
+               case IWL_UCODE_TLV_WOWLAN_INST:
+                       pieces->wowlan_inst = tlv_data;
+                       pieces->wowlan_inst_size = tlv_len;
+                       break;
+               case IWL_UCODE_TLV_WOWLAN_DATA:
+                       pieces->wowlan_data = tlv_data;
+                       pieces->wowlan_data_size = tlv_len;
+                       break;
+               case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
+                       if (tlv_len != sizeof(u32))
+                               goto invalid_tlv_len;
+                       capa->standard_phy_calibration_size =
+                                       le32_to_cpup((__le32 *)tlv_data);
+                       break;
+               default:
+                       IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
+                       break;
+               }
+       }
+
+       if (len) {
+               IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
+               iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
+               return -EINVAL;
+       }
+
+       return 0;
+
+ invalid_tlv_len:
+       IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
+       iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
+
+       return -EINVAL;
+}
+
+/**
+ * iwl_ucode_callback - callback when firmware was loaded
+ *
+ * If loaded successfully, copies the firmware into buffers
+ * for the card to fetch (via DMA).
+ */
+static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
+{
+       struct iwl_drv *drv = context;
+       const struct iwl_cfg *cfg = cfg(drv);
+       struct iwl_fw *fw = &drv->fw;
+       struct iwl_ucode_header *ucode;
+       int err;
+       struct iwlagn_firmware_pieces pieces;
+       const unsigned int api_max = cfg->ucode_api_max;
+       unsigned int api_ok = cfg->ucode_api_ok;
+       const unsigned int api_min = cfg->ucode_api_min;
+       u32 api_ver;
+
+       fw->ucode_capa.max_probe_length = 200;
+       fw->ucode_capa.standard_phy_calibration_size =
+                       IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
+
+       if (!api_ok)
+               api_ok = api_max;
+
+       memset(&pieces, 0, sizeof(pieces));
+
+       if (!ucode_raw) {
+               if (drv->fw_index <= api_ok)
+                       IWL_ERR(drv,
+                               "request for firmware file '%s' failed.\n",
+                               drv->firmware_name);
+               goto try_again;
+       }
+
+       IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
+                      drv->firmware_name, ucode_raw->size);
+
+       /* Make sure that we got at least the API version number */
+       if (ucode_raw->size < 4) {
+               IWL_ERR(drv, "File size way too small!\n");
+               goto try_again;
+       }
+
+       /* Data from ucode file:  header followed by uCode images */
+       ucode = (struct iwl_ucode_header *)ucode_raw->data;
+
+       if (ucode->ver)
+               err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces);
+       else
+               err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces,
+                                          &fw->ucode_capa);
+
+       if (err)
+               goto try_again;
+
+       api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
+
+       /*
+        * api_ver should match the api version forming part of the
+        * firmware filename ... but we don't check for that and only rely
+        * on the API version read from firmware header from here on forward
+        */
+       /* no api version check required for experimental uCode */
+       if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) {
+               if (api_ver < api_min || api_ver > api_max) {
+                       IWL_ERR(drv,
+                               "Driver unable to support your firmware API. "
+                               "Driver supports v%u, firmware is v%u.\n",
+                               api_max, api_ver);
+                       goto try_again;
+               }
+
+               if (api_ver < api_ok) {
+                       if (api_ok != api_max)
+                               IWL_ERR(drv, "Firmware has old API version, "
+                                       "expected v%u through v%u, got v%u.\n",
+                                       api_ok, api_max, api_ver);
+                       else
+                               IWL_ERR(drv, "Firmware has old API version, "
+                                       "expected v%u, got v%u.\n",
+                                       api_max, api_ver);
+                       IWL_ERR(drv, "New firmware can be obtained from "
+                                     "http://www.intellinuxwireless.org/.\n");
+               }
+       }
+
+       IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version);
+
+       /*
+        * For any of the failures below (before allocating pci memory)
+        * we will try to load a version with a smaller API -- maybe the
+        * user just got a corrupted version of the latest API.
+        */
+
+       IWL_DEBUG_INFO(drv, "f/w package hdr ucode version raw = 0x%x\n",
+                      drv->fw.ucode_ver);
+       IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
+                      pieces.inst_size);
+       IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
+                      pieces.data_size);
+       IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
+                      pieces.init_size);
+       IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
+                      pieces.init_data_size);
+
+       /* Verify that uCode images will fit in card's SRAM */
+       if (pieces.inst_size > cfg->max_inst_size) {
+               IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
+                       pieces.inst_size);
+               goto try_again;
+       }
+
+       if (pieces.data_size > cfg->max_data_size) {
+               IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
+                       pieces.data_size);
+               goto try_again;
+       }
+
+       if (pieces.init_size > cfg->max_inst_size) {
+               IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
+                       pieces.init_size);
+               goto try_again;
+       }
+
+       if (pieces.init_data_size > cfg->max_data_size) {
+               IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
+                       pieces.init_data_size);
+               goto try_again;
+       }
+
+       /* Allocate ucode buffers for card's bus-master loading ... */
+
+       /* Runtime instructions and 2 copies of data:
+        * 1) unmodified from disk
+        * 2) backup cache for save/restore during power-downs */
+       if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code,
+                             pieces.inst, pieces.inst_size))
+               goto err_pci_alloc;
+       if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data,
+                             pieces.data, pieces.data_size))
+               goto err_pci_alloc;
+
+       /* Initialization instructions and data */
+       if (pieces.init_size && pieces.init_data_size) {
+               if (iwl_alloc_fw_desc(drv,
+                                     &drv->fw.ucode_init.code,
+                                     pieces.init, pieces.init_size))
+                       goto err_pci_alloc;
+               if (iwl_alloc_fw_desc(drv,
+                                     &drv->fw.ucode_init.data,
+                                     pieces.init_data, pieces.init_data_size))
+                       goto err_pci_alloc;
+       }
+
+       /* WoWLAN instructions and data */
+       if (pieces.wowlan_inst_size && pieces.wowlan_data_size) {
+               if (iwl_alloc_fw_desc(drv,
+                                     &drv->fw.ucode_wowlan.code,
+                                     pieces.wowlan_inst,
+                                     pieces.wowlan_inst_size))
+                       goto err_pci_alloc;
+               if (iwl_alloc_fw_desc(drv,
+                                     &drv->fw.ucode_wowlan.data,
+                                     pieces.wowlan_data,
+                                     pieces.wowlan_data_size))
+                       goto err_pci_alloc;
+       }
+
+       /* Now that we can no longer fail, copy information */
+
+       /*
+        * The (size - 16) / 12 formula is based on the information recorded
+        * for each event, which is of mode 1 (including timestamp) for all
+        * new microcodes that include this information.
+        */
+       fw->init_evtlog_ptr = pieces.init_evtlog_ptr;
+       if (pieces.init_evtlog_size)
+               fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12;
+       else
+               fw->init_evtlog_size =
+                       cfg->base_params->max_event_log_size;
+       fw->init_errlog_ptr = pieces.init_errlog_ptr;
+       fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr;
+       if (pieces.inst_evtlog_size)
+               fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12;
+       else
+               fw->inst_evtlog_size =
+                       cfg->base_params->max_event_log_size;
+       fw->inst_errlog_ptr = pieces.inst_errlog_ptr;
+
+       /*
+        * figure out the offset of chain noise reset and gain commands
+        * base on the size of standard phy calibration commands table size
+        */
+       if (fw->ucode_capa.standard_phy_calibration_size >
+           IWL_MAX_PHY_CALIBRATE_TBL_SIZE)
+               fw->ucode_capa.standard_phy_calibration_size =
+                       IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
+
+       /* We have our copies now, allow OS release its copies */
+       release_firmware(ucode_raw);
+       complete(&drv->request_firmware_complete);
+
+       drv->op_mode = iwl_dvm_ops.start(drv->shrd->trans, &drv->fw);
+
+       if (!drv->op_mode)
+               goto out_unbind;
+
+       return;
+
+ try_again:
+       /* try next, if any */
+       release_firmware(ucode_raw);
+       if (iwl_request_firmware(drv, false))
+               goto out_unbind;
+       return;
+
+ err_pci_alloc:
+       IWL_ERR(drv, "failed to allocate pci memory\n");
+       iwl_dealloc_ucode(drv);
+       release_firmware(ucode_raw);
+ out_unbind:
+       complete(&drv->request_firmware_complete);
+       device_release_driver(trans(drv)->dev);
+}
+
+int iwl_drv_start(struct iwl_shared *shrd,
+                 struct iwl_trans *trans, const struct iwl_cfg *cfg)
+{
+       struct iwl_drv *drv;
+       int ret;
+
+       shrd->cfg = cfg;
+
+       drv = kzalloc(sizeof(*drv), GFP_KERNEL);
+       if (!drv) {
+               dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_drv");
+               return -ENOMEM;
+       }
+       drv->shrd = shrd;
+       shrd->drv = drv;
+
+       init_completion(&drv->request_firmware_complete);
+
+       ret = iwl_request_firmware(drv, true);
+
+       if (ret) {
+               dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw");
+               kfree(drv);
+               shrd->drv = NULL;
+       }
+
+       return ret;
+}
+
+void iwl_drv_stop(struct iwl_shared *shrd)
+{
+       struct iwl_drv *drv = shrd->drv;
+
+       wait_for_completion(&drv->request_firmware_complete);
+
+       /* op_mode can be NULL if its start failed */
+       if (drv->op_mode)
+               iwl_op_mode_stop(drv->op_mode);
+
+       iwl_dealloc_ucode(drv);
+
+       kfree(drv);
+       shrd->drv = NULL;
+}
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.h b/drivers/net/wireless/iwlwifi/iwl-drv.h
new file mode 100644 (file)
index 0000000..3b771c1
--- /dev/null
@@ -0,0 +1,123 @@
+/******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#ifndef __iwl_drv_h__
+#define __iwl_drv_h__
+
+#include "iwl-shared.h"
+
+/**
+ * DOC: Driver system flows - drv component
+ *
+ * This component implements the system flows such as bus enumeration, bus
+ * removal. Bus dependent parts of system flows (such as iwl_pci_probe) are in
+ * bus specific files (transport files). This is the code that is common among
+ * different buses.
+ *
+ * This component is also in charge of managing the several implementations of
+ * the wifi flows: it will allow to have several fw API implementation. These
+ * different implementations will differ in the way they implement mac80211's
+ * handlers too.
+
+ * The init flow wrt to the drv component looks like this:
+ * 1) The bus specific component is called from module_init
+ * 2) The bus specific component registers the bus driver
+ * 3) The bus driver calls the probe function
+ * 4) The bus specific component configures the bus
+ * 5) The bus specific component calls to the drv bus agnostic part
+ *    (iwl_drv_start)
+ * 6) iwl_drv_start fetches the fw ASYNC, iwl_ucode_callback
+ * 7) iwl_ucode_callback parses the fw file
+ * 8) iwl_ucode_callback starts the wifi implementation to matches the fw
+ */
+
+/**
+ * iwl_drv_start - start the drv
+ *
+ * @shrd: the shrd area
+ * @trans_ops: the ops of the transport
+ * @cfg: device specific constants / virtual functions
+ *
+ * TODO: review the parameters given to this function
+ *
+ * starts the driver: fetches the firmware. This should be called by bus
+ * specific system flows implementations. For example, the bus specific probe
+ * function should do bus related operations only, and then call to this
+ * function.
+ */
+int iwl_drv_start(struct iwl_shared *shrd,
+                 struct iwl_trans *trans, const struct iwl_cfg *cfg);
+
+/**
+ * iwl_drv_stop - stop the drv
+ *
+ * @shrd: the shrd area
+ *
+ * TODO: review the parameters given to this function
+ *
+ * Stop the driver. This should be called by bus specific system flows
+ * implementations. For example, the bus specific remove function should first
+ * call this function and then do the bus related operations only.
+ */
+void iwl_drv_stop(struct iwl_shared *shrd);
+
+#endif /* __iwl_drv_h__ */
index d1fd1cdb29c23923e4818bc6e6afb9426303ac0e..e2d80849001f5c9f4ac673ffa1bd30a387018a08 100644 (file)
@@ -75,6 +75,7 @@
 #include "iwl-agn.h"
 #include "iwl-eeprom.h"
 #include "iwl-io.h"
+#include "iwl-prph.h"
 
 /************************** EEPROM BANDS ****************************
  *
@@ -149,23 +150,27 @@ static const u8 iwl_eeprom_band_7[] = {       /* 5.2 ht40 channel */
  * EEPROM chip, not a single event, so even reads could conflict if they
  * weren't arbitrated by the semaphore.
  */
-static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus)
+
+#define        EEPROM_SEM_TIMEOUT 10           /* milliseconds */
+#define EEPROM_SEM_RETRY_LIMIT 1000    /* number of attempts (not time) */
+
+static int iwl_eeprom_acquire_semaphore(struct iwl_trans *trans)
 {
        u16 count;
        int ret;
 
        for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
                /* Request semaphore */
-               iwl_set_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
+               iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
                            CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
 
                /* See if we got it */
-               ret = iwl_poll_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
+               ret = iwl_poll_bit(trans, CSR_HW_IF_CONFIG_REG,
                                CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
                                CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
                                EEPROM_SEM_TIMEOUT);
                if (ret >= 0) {
-                       IWL_DEBUG_EEPROM(trans(bus),
+                       IWL_DEBUG_EEPROM(trans,
                                "Acquired semaphore after %d tries.\n",
                                count+1);
                        return ret;
@@ -175,9 +180,9 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus)
        return ret;
 }
 
-static void iwl_eeprom_release_semaphore(struct iwl_bus *bus)
+static void iwl_eeprom_release_semaphore(struct iwl_trans *trans)
 {
-       iwl_clear_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
+       iwl_clear_bit(trans, CSR_HW_IF_CONFIG_REG,
                CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
 
 }
@@ -248,46 +253,46 @@ err:
 
 }
 
-int iwl_eeprom_check_sku(struct iwl_priv *priv)
+int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
 {
        struct iwl_shared *shrd = priv->shrd;
        u16 radio_cfg;
 
-       if (!cfg(priv)->sku) {
-               /* not using sku overwrite */
-               cfg(priv)->sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP);
-               if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE &&
-                   !cfg(priv)->ht_params) {
-                       IWL_ERR(priv, "Invalid 11n configuration\n");
-                       return -EINVAL;
-               }
+       hw_params(priv).sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP);
+       if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE &&
+           !cfg(priv)->ht_params) {
+               IWL_ERR(priv, "Invalid 11n configuration\n");
+               return -EINVAL;
        }
-       if (!cfg(priv)->sku) {
+
+       if (!hw_params(priv).sku) {
                IWL_ERR(priv, "Invalid device sku\n");
                return -EINVAL;
        }
 
-       IWL_INFO(priv, "Device SKU: 0x%X\n", cfg(priv)->sku);
-
-       if (!cfg(priv)->valid_tx_ant && !cfg(priv)->valid_rx_ant) {
-               /* not using .cfg overwrite */
-               radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
-               cfg(priv)->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
-               cfg(priv)->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
-               if (!cfg(priv)->valid_tx_ant || !cfg(priv)->valid_rx_ant) {
-                       IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
-                               cfg(priv)->valid_tx_ant,
-                               cfg(priv)->valid_rx_ant);
-                       return -EINVAL;
-               }
-               IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
-                        cfg(priv)->valid_tx_ant, cfg(priv)->valid_rx_ant);
+       IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku);
+
+       radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
+
+       hw_params(priv).valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
+       hw_params(priv).valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
+
+       /* check overrides (some devices have wrong EEPROM) */
+       if (cfg(priv)->valid_tx_ant)
+               hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
+       if (cfg(priv)->valid_rx_ant)
+               hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+
+       if (!hw_params(priv).valid_tx_ant || !hw_params(priv).valid_rx_ant) {
+               IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
+                       hw_params(priv).valid_tx_ant,
+                       hw_params(priv).valid_rx_ant);
+               return -EINVAL;
        }
-       /*
-        * for some special cases,
-        * EEPROM did not reflect the correct antenna setting
-        * so overwrite the valid tx/rx antenna from .cfg
-        */
+
+       IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
+                hw_params(priv).valid_tx_ant, hw_params(priv).valid_rx_ant);
+
        return 0;
 }
 
@@ -304,19 +309,20 @@ void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac)
  *
 ******************************************************************************/
 
-static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode)
+static void iwl_set_otp_access(struct iwl_trans *trans,
+                              enum iwl_access_mode mode)
 {
-       iwl_read32(trans(bus), CSR_OTP_GP_REG);
+       iwl_read32(trans, CSR_OTP_GP_REG);
 
        if (mode == IWL_OTP_ACCESS_ABSOLUTE)
-               iwl_clear_bit(trans(bus), CSR_OTP_GP_REG,
+               iwl_clear_bit(trans, CSR_OTP_GP_REG,
                              CSR_OTP_GP_REG_OTP_ACCESS_MODE);
        else
-               iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
+               iwl_set_bit(trans, CSR_OTP_GP_REG,
                            CSR_OTP_GP_REG_OTP_ACCESS_MODE);
 }
 
-static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev)
+static int iwl_get_nvm_type(struct iwl_trans *trans, u32 hw_rev)
 {
        u32 otpgp;
        int nvm_type;
@@ -324,7 +330,7 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev)
        /* OTP only valid for CP/PP and after */
        switch (hw_rev & CSR_HW_REV_TYPE_MSK) {
        case CSR_HW_REV_TYPE_NONE:
-               IWL_ERR(bus, "Unknown hardware type\n");
+               IWL_ERR(trans, "Unknown hardware type\n");
                return -ENOENT;
        case CSR_HW_REV_TYPE_5300:
        case CSR_HW_REV_TYPE_5350:
@@ -333,7 +339,7 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev)
                nvm_type = NVM_DEVICE_TYPE_EEPROM;
                break;
        default:
-               otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG);
+               otpgp = iwl_read32(trans, CSR_OTP_GP_REG);
                if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT)
                        nvm_type = NVM_DEVICE_TYPE_OTP;
                else
@@ -343,73 +349,74 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev)
        return  nvm_type;
 }
 
-static int iwl_init_otp_access(struct iwl_bus *bus)
+static int iwl_init_otp_access(struct iwl_trans *trans)
 {
        int ret;
 
        /* Enable 40MHz radio clock */
-       iwl_write32(trans(bus), CSR_GP_CNTRL,
-                   iwl_read32(trans(bus), CSR_GP_CNTRL) |
+       iwl_write32(trans, CSR_GP_CNTRL,
+                   iwl_read32(trans, CSR_GP_CNTRL) |
                    CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
        /* wait for clock to be ready */
-       ret = iwl_poll_bit(trans(bus), CSR_GP_CNTRL,
+       ret = iwl_poll_bit(trans, CSR_GP_CNTRL,
                                 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
                                 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
                                 25000);
        if (ret < 0)
-               IWL_ERR(bus, "Time out access OTP\n");
+               IWL_ERR(trans, "Time out access OTP\n");
        else {
-               iwl_set_bits_prph(trans(bus), APMG_PS_CTRL_REG,
+               iwl_set_bits_prph(trans, APMG_PS_CTRL_REG,
                                  APMG_PS_CTRL_VAL_RESET_REQ);
                udelay(5);
-               iwl_clear_bits_prph(trans(bus), APMG_PS_CTRL_REG,
+               iwl_clear_bits_prph(trans, APMG_PS_CTRL_REG,
                                    APMG_PS_CTRL_VAL_RESET_REQ);
 
                /*
                 * CSR auto clock gate disable bit -
                 * this is only applicable for HW with OTP shadow RAM
                 */
-               if (cfg(bus)->base_params->shadow_ram_support)
-                       iwl_set_bit(trans(bus), CSR_DBG_LINK_PWR_MGMT_REG,
+               if (cfg(trans)->base_params->shadow_ram_support)
+                       iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
                                CSR_RESET_LINK_PWR_MGMT_DISABLED);
        }
        return ret;
 }
 
-static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data)
+static int iwl_read_otp_word(struct iwl_trans *trans, u16 addr,
+                            __le16 *eeprom_data)
 {
        int ret = 0;
        u32 r;
        u32 otpgp;
 
-       iwl_write32(trans(bus), CSR_EEPROM_REG,
+       iwl_write32(trans, CSR_EEPROM_REG,
                    CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
-       ret = iwl_poll_bit(trans(bus), CSR_EEPROM_REG,
+       ret = iwl_poll_bit(trans, CSR_EEPROM_REG,
                                 CSR_EEPROM_REG_READ_VALID_MSK,
                                 CSR_EEPROM_REG_READ_VALID_MSK,
                                 IWL_EEPROM_ACCESS_TIMEOUT);
        if (ret < 0) {
-               IWL_ERR(bus, "Time out reading OTP[%d]\n", addr);
+               IWL_ERR(trans, "Time out reading OTP[%d]\n", addr);
                return ret;
        }
-       r = iwl_read32(trans(bus), CSR_EEPROM_REG);
+       r = iwl_read32(trans, CSR_EEPROM_REG);
        /* check for ECC errors: */
-       otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG);
+       otpgp = iwl_read32(trans, CSR_OTP_GP_REG);
        if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) {
                /* stop in this case */
                /* set the uncorrectable OTP ECC bit for acknowledgement */
-               iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
+               iwl_set_bit(trans, CSR_OTP_GP_REG,
                        CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
-               IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n");
+               IWL_ERR(trans, "Uncorrectable OTP ECC error, abort OTP read\n");
                return -EINVAL;
        }
        if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) {
                /* continue in this case */
                /* set the correctable OTP ECC bit for acknowledgement */
-               iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
+               iwl_set_bit(trans, CSR_OTP_GP_REG,
                                CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
-               IWL_ERR(bus, "Correctable OTP ECC error, continue read\n");
+               IWL_ERR(trans, "Correctable OTP ECC error, continue read\n");
        }
        *eeprom_data = cpu_to_le16(r >> 16);
        return 0;
@@ -418,20 +425,20 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data)
 /*
  * iwl_is_otp_empty: check for empty OTP
  */
-static bool iwl_is_otp_empty(struct iwl_bus *bus)
+static bool iwl_is_otp_empty(struct iwl_trans *trans)
 {
        u16 next_link_addr = 0;
        __le16 link_value;
        bool is_empty = false;
 
        /* locate the beginning of OTP link list */
-       if (!iwl_read_otp_word(bus, next_link_addr, &link_value)) {
+       if (!iwl_read_otp_word(trans, next_link_addr, &link_value)) {
                if (!link_value) {
-                       IWL_ERR(bus, "OTP is empty\n");
+                       IWL_ERR(trans, "OTP is empty\n");
                        is_empty = true;
                }
        } else {
-               IWL_ERR(bus, "Unable to read first block of OTP list.\n");
+               IWL_ERR(trans, "Unable to read first block of OTP list.\n");
                is_empty = true;
        }
 
@@ -448,7 +455,7 @@ static bool iwl_is_otp_empty(struct iwl_bus *bus)
  *   we should read and used to configure the device.
  *   only perform this operation if shadow RAM is disabled
  */
-static int iwl_find_otp_image(struct iwl_bus *bus,
+static int iwl_find_otp_image(struct iwl_trans *trans,
                                        u16 *validblockaddr)
 {
        u16 next_link_addr = 0, valid_addr;
@@ -456,10 +463,10 @@ static int iwl_find_otp_image(struct iwl_bus *bus,
        int usedblocks = 0;
 
        /* set addressing mode to absolute to traverse the link list */
-       iwl_set_otp_access(bus, IWL_OTP_ACCESS_ABSOLUTE);
+       iwl_set_otp_access(trans, IWL_OTP_ACCESS_ABSOLUTE);
 
        /* checking for empty OTP or error */
-       if (iwl_is_otp_empty(bus))
+       if (iwl_is_otp_empty(trans))
                return -EINVAL;
 
        /*
@@ -473,9 +480,9 @@ static int iwl_find_otp_image(struct iwl_bus *bus,
                 */
                valid_addr = next_link_addr;
                next_link_addr = le16_to_cpu(link_value) * sizeof(u16);
-               IWL_DEBUG_EEPROM(bus, "OTP blocks %d addr 0x%x\n",
+               IWL_DEBUG_EEPROM(trans, "OTP blocks %d addr 0x%x\n",
                               usedblocks, next_link_addr);
-               if (iwl_read_otp_word(bus, next_link_addr, &link_value))
+               if (iwl_read_otp_word(trans, next_link_addr, &link_value))
                        return -EINVAL;
                if (!link_value) {
                        /*
@@ -490,10 +497,10 @@ static int iwl_find_otp_image(struct iwl_bus *bus,
                }
                /* more in the link list, continue */
                usedblocks++;
-       } while (usedblocks <= cfg(bus)->base_params->max_ll_items);
+       } while (usedblocks <= cfg(trans)->base_params->max_ll_items);
 
        /* OTP has no valid blocks */
-       IWL_DEBUG_EEPROM(bus, "OTP has no valid blocks\n");
+       IWL_DEBUG_EEPROM(trans, "OTP has no valid blocks\n");
        return -EINVAL;
 }
 
@@ -506,7 +513,7 @@ static int iwl_find_otp_image(struct iwl_bus *bus,
  * iwl_get_max_txpower_avg - get the highest tx power from all chains.
  *     find the highest tx power from all chains for the channel
  */
-static s8 iwl_get_max_txpower_avg(struct iwl_cfg *cfg,
+static s8 iwl_get_max_txpower_avg(const struct iwl_cfg *cfg,
                struct iwl_eeprom_enhanced_txpwr *enhanced_txpower,
                int element, s8 *max_txpower_in_half_dbm)
 {
@@ -653,63 +660,62 @@ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv)
  *
  * NOTE:  This routine uses the non-debug IO access functions.
  */
-int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
+int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev)
 {
-       struct iwl_shared *shrd = priv->shrd;
        __le16 *e;
-       u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP);
+       u32 gp = iwl_read32(trans, CSR_EEPROM_GP);
        int sz;
        int ret;
        u16 addr;
        u16 validblockaddr = 0;
        u16 cache_addr = 0;
 
-       trans(priv)->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev);
-       if (trans(priv)->nvm_device_type == -ENOENT)
+       trans->nvm_device_type = iwl_get_nvm_type(trans, hw_rev);
+       if (trans->nvm_device_type == -ENOENT)
                return -ENOENT;
        /* allocate eeprom */
-       sz = cfg(priv)->base_params->eeprom_size;
-       IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz);
-       shrd->eeprom = kzalloc(sz, GFP_KERNEL);
-       if (!shrd->eeprom) {
+       sz = cfg(trans)->base_params->eeprom_size;
+       IWL_DEBUG_EEPROM(trans, "NVM size = %d\n", sz);
+       trans->shrd->eeprom = kzalloc(sz, GFP_KERNEL);
+       if (!trans->shrd->eeprom) {
                ret = -ENOMEM;
                goto alloc_err;
        }
-       e = (__le16 *)shrd->eeprom;
+       e = (__le16 *)trans->shrd->eeprom;
 
-       ret = iwl_eeprom_verify_signature(trans(priv));
+       ret = iwl_eeprom_verify_signature(trans);
        if (ret < 0) {
-               IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
+               IWL_ERR(trans, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
                ret = -ENOENT;
                goto err;
        }
 
        /* Make sure driver (instead of uCode) is allowed to read EEPROM */
-       ret = iwl_eeprom_acquire_semaphore(bus(priv));
+       ret = iwl_eeprom_acquire_semaphore(trans);
        if (ret < 0) {
-               IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n");
+               IWL_ERR(trans, "Failed to acquire EEPROM semaphore.\n");
                ret = -ENOENT;
                goto err;
        }
 
-       if (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
+       if (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
 
-               ret = iwl_init_otp_access(bus(priv));
+               ret = iwl_init_otp_access(trans);
                if (ret) {
-                       IWL_ERR(priv, "Failed to initialize OTP access.\n");
+                       IWL_ERR(trans, "Failed to initialize OTP access.\n");
                        ret = -ENOENT;
                        goto done;
                }
-               iwl_write32(trans(priv), CSR_EEPROM_GP,
-                           iwl_read32(trans(priv), CSR_EEPROM_GP) &
+               iwl_write32(trans, CSR_EEPROM_GP,
+                           iwl_read32(trans, CSR_EEPROM_GP) &
                            ~CSR_EEPROM_GP_IF_OWNER_MSK);
 
-               iwl_set_bit(trans(priv), CSR_OTP_GP_REG,
+               iwl_set_bit(trans, CSR_OTP_GP_REG,
                             CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK |
                             CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
                /* traversing the linked list if no shadow ram supported */
-               if (!cfg(priv)->base_params->shadow_ram_support) {
-                       if (iwl_find_otp_image(bus(priv), &validblockaddr)) {
+               if (!cfg(trans)->base_params->shadow_ram_support) {
+                       if (iwl_find_otp_image(trans, &validblockaddr)) {
                                ret = -ENOENT;
                                goto done;
                        }
@@ -718,7 +724,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
                     addr += sizeof(u16)) {
                        __le16 eeprom_data;
 
-                       ret = iwl_read_otp_word(bus(priv), addr, &eeprom_data);
+                       ret = iwl_read_otp_word(trans, addr, &eeprom_data);
                        if (ret)
                                goto done;
                        e[cache_addr / 2] = eeprom_data;
@@ -729,34 +735,35 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
                for (addr = 0; addr < sz; addr += sizeof(u16)) {
                        u32 r;
 
-                       iwl_write32(trans(priv), CSR_EEPROM_REG,
+                       iwl_write32(trans, CSR_EEPROM_REG,
                                    CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
 
-                       ret = iwl_poll_bit(trans(priv), CSR_EEPROM_REG,
+                       ret = iwl_poll_bit(trans, CSR_EEPROM_REG,
                                                  CSR_EEPROM_REG_READ_VALID_MSK,
                                                  CSR_EEPROM_REG_READ_VALID_MSK,
                                                  IWL_EEPROM_ACCESS_TIMEOUT);
                        if (ret < 0) {
-                               IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr);
+                               IWL_ERR(trans,
+                                       "Time out reading EEPROM[%d]\n", addr);
                                goto done;
                        }
-                       r = iwl_read32(trans(priv), CSR_EEPROM_REG);
+                       r = iwl_read32(trans, CSR_EEPROM_REG);
                        e[addr / 2] = cpu_to_le16(r >> 16);
                }
        }
 
-       IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n",
-                      (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP)
+       IWL_DEBUG_EEPROM(trans, "NVM Type: %s, version: 0x%x\n",
+                      (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP)
                       ? "OTP" : "EEPROM",
-                      iwl_eeprom_query16(shrd, EEPROM_VERSION));
+                      iwl_eeprom_query16(trans->shrd, EEPROM_VERSION));
 
        ret = 0;
 done:
-       iwl_eeprom_release_semaphore(bus(priv));
+       iwl_eeprom_release_semaphore(trans);
 
 err:
        if (ret)
-               iwl_eeprom_free(priv->shrd);
+               iwl_eeprom_free(trans->shrd);
 alloc_err:
        return ret;
 }
index 13f2d3928ef8e57cb34869b0e7a282108aa7da69..3b17056d567552f9a97a424d2e26dc9011ce74bf 100644 (file)
@@ -67,6 +67,7 @@
 
 struct iwl_priv;
 struct iwl_shared;
+struct iwl_trans;
 
 /*
  * EEPROM access time values:
@@ -305,10 +306,10 @@ struct iwl_eeprom_ops {
 };
 
 
-int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev);
+int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev);
 void iwl_eeprom_free(struct iwl_shared *shrd);
 int  iwl_eeprom_check_version(struct iwl_priv *priv);
-int  iwl_eeprom_check_sku(struct iwl_priv *priv);
+int iwl_eeprom_init_hw_params(struct iwl_priv *priv);
 const u8 *iwl_eeprom_query_addr(const struct iwl_shared *shrd, size_t offset);
 u16 iwl_eeprom_query16(const struct iwl_shared *shrd, size_t offset);
 int iwl_init_channel_map(struct iwl_priv *priv);
similarity index 75%
rename from drivers/net/wireless/iwlwifi/iwl-ucode.h
rename to drivers/net/wireless/iwlwifi/iwl-fw-file.h
index d13e6241f126599a2b874aedf1266954fa0d917d..7ca6c952635769c846d6d00ff97c508a7cd214e4 100644 (file)
@@ -60,8 +60,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
-#ifndef __iwl_ucode_h__
-#define __iwl_ucode_h__
+#ifndef __iwl_fw_file_h__
+#define __iwl_fw_file_h__
 
 #include <linux/netdevice.h>
 
@@ -126,22 +126,6 @@ enum iwl_ucode_tlv_type {
        IWL_UCODE_TLV_FLAGS             = 18,
 };
 
-/**
- * enum iwl_ucode_tlv_flag - ucode API flags
- * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
- *     was a separate TLV but moved here to save space.
- * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
- *     treats good CRC threshold as a boolean
- * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
- * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
- */
-enum iwl_ucode_tlv_flag {
-       IWL_UCODE_TLV_FLAGS_PAN         = BIT(0),
-       IWL_UCODE_TLV_FLAGS_NEWSCAN     = BIT(1),
-       IWL_UCODE_TLV_FLAGS_MFP         = BIT(2),
-       IWL_UCODE_TLV_FLAGS_P2P         = BIT(3),
-};
-
 struct iwl_ucode_tlv {
        __le16 type;            /* see above */
        __le16 alternative;     /* see comment */
@@ -173,49 +157,4 @@ struct iwl_tlv_ucode_header {
        u8 data[0];
 };
 
-struct iwl_ucode_capabilities {
-       u32 max_probe_length;
-       u32 standard_phy_calibration_size;
-       u32 flags;
-};
-
-/* one for each uCode image (inst/data, boot/init/runtime) */
-struct fw_desc {
-       dma_addr_t p_addr;      /* hardware address */
-       void *v_addr;           /* software address */
-       u32 len;                /* size in bytes */
-};
-
-struct fw_img {
-       struct fw_desc code;    /* firmware code image */
-       struct fw_desc data;    /* firmware data image */
-};
-
-/**
- * struct iwl_fw - variables associated with the firmware
- *
- * @ucode_ver: ucode version from the ucode file
- * @fw_version: firmware version string
- * @ucode_rt: run time ucode image
- * @ucode_init: init ucode image
- * @ucode_wowlan: wake on wireless ucode image (optional)
- * @ucode_capa: capabilities parsed from the ucode file.
- * @enhance_sensitivity_table: device can do enhanced sensitivity.
- */
-struct iwl_fw {
-
-       /* ucode image and variables */
-       u32 ucode_ver;                  /* version of ucode, copy of
-                                          iwl_ucode.ver */
-       char fw_version[ETHTOOL_BUSINFO_LEN];
-
-       /* ucode images */
-       struct fw_img ucode_rt;
-       struct fw_img ucode_init;
-       struct fw_img ucode_wowlan;
-
-       struct iwl_ucode_capabilities ucode_capa;
-       bool enhance_sensitivity_table;
-};
-
-#endif  /* __iwl_ucode_h__ */
+#endif  /* __iwl_fw_file_h__ */
similarity index 59%
rename from drivers/net/wireless/iwlwifi/iwl-wifi.h
rename to drivers/net/wireless/iwlwifi/iwl-fw.h
index 84172f6de4bba1890e4d7e26839f7398a52f02a3..453812a21176a34eba7bc415532fb9a71285f4d2 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
-#ifndef __iwl_wifi_h__
-#define __iwl_wifi_h__
+#ifndef __iwl_fw_h__
+#define __iwl_fw_h__
+#include <linux/types.h>
 
-#include "iwl-shared.h"
-#include "iwl-ucode.h"
+/**
+ * enum iwl_ucode_tlv_flag - ucode API flags
+ * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
+ *     was a separate TLV but moved here to save space.
+ * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
+ *     treats good CRC threshold as a boolean
+ * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
+ * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
+ */
+enum iwl_ucode_tlv_flag {
+       IWL_UCODE_TLV_FLAGS_PAN         = BIT(0),
+       IWL_UCODE_TLV_FLAGS_NEWSCAN     = BIT(1),
+       IWL_UCODE_TLV_FLAGS_MFP         = BIT(2),
+       IWL_UCODE_TLV_FLAGS_P2P         = BIT(3),
+};
+
+/* The default calibrate table size if not specified by firmware file */
+#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE    18
+#define IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE                19
+#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE                 253
+
+struct iwl_ucode_capabilities {
+       u32 max_probe_length;
+       u32 standard_phy_calibration_size;
+       u32 flags;
+};
+
+/* one for each uCode image (inst/data, boot/init/runtime) */
+struct fw_desc {
+       dma_addr_t p_addr;      /* hardware address */
+       void *v_addr;           /* software address */
+       u32 len;                /* size in bytes */
+};
+
+struct fw_img {
+       struct fw_desc code;    /* firmware code image */
+       struct fw_desc data;    /* firmware data image */
+};
+
+/* uCode version contains 4 values: Major/Minor/API/Serial */
+#define IWL_UCODE_MAJOR(ver)   (((ver) & 0xFF000000) >> 24)
+#define IWL_UCODE_MINOR(ver)   (((ver) & 0x00FF0000) >> 16)
+#define IWL_UCODE_API(ver)     (((ver) & 0x0000FF00) >> 8)
+#define IWL_UCODE_SERIAL(ver)  ((ver) & 0x000000FF)
 
 /**
- * struct iwl_nic - nic common data
- * @fw: the iwl_fw structure
- * @shrd: pointer to common shared structure
- * @fw_index: firmware revision to try loading
- * @firmware_name: composite filename of ucode file to load
+ * struct iwl_fw - variables associated with the firmware
+ *
+ * @ucode_ver: ucode version from the ucode file
+ * @fw_version: firmware version string
+ * @ucode_rt: run time ucode image
+ * @ucode_init: init ucode image
+ * @ucode_wowlan: wake on wireless ucode image (optional)
+ * @ucode_capa: capabilities parsed from the ucode file.
+ * @enhance_sensitivity_table: device can do enhanced sensitivity.
  * @init_evtlog_ptr: event log offset for init ucode.
  * @init_evtlog_size: event log size for init ucode.
  * @init_errlog_ptr: error log offfset for init ucode.
  * @inst_evtlog_ptr: event log offset for runtime ucode.
  * @inst_evtlog_size: event log size for runtime ucode.
  * @inst_errlog_ptr: error log offfset for runtime ucode.
- * @request_firmware_complete: the firmware has been obtained from user space
  */
-struct iwl_nic {
-       struct iwl_fw fw;
+struct iwl_fw {
+       u32 ucode_ver;
 
-       struct iwl_shared *shrd;
+       char fw_version[ETHTOOL_BUSINFO_LEN];
 
-       int fw_index;                   /* firmware we're trying to load */
-       char firmware_name[25];         /* name of firmware file to load */
+       /* ucode images */
+       struct fw_img ucode_rt;
+       struct fw_img ucode_init;
+       struct fw_img ucode_wowlan;
+
+       struct iwl_ucode_capabilities ucode_capa;
+       bool enhance_sensitivity_table;
 
        u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
        u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
-
-       struct completion request_firmware_complete;
 };
 
-
-int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first);
-void iwl_dealloc_ucode(struct iwl_nic *nic);
-
-int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type);
-void iwl_send_prio_tbl(struct iwl_trans *trans);
-int iwl_init_alive_start(struct iwl_trans *trans);
-int iwl_run_init_ucode(struct iwl_trans *trans);
-int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
-                                enum iwl_ucode_type ucode_type);
-#endif  /* __iwl_wifi_h__ */
+#endif  /* __iwl_fw_h__ */
index 782486fc2f8f8a042acc84231d13e0370258664a..1136dc19936a06928c7550f2cc1cb21b2b27fec9 100644 (file)
 
 static inline void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val)
 {
-       trace_iwlwifi_dev_iowrite8(priv(trans), ofs, val);
+       trace_iwlwifi_dev_iowrite8(trans->dev, ofs, val);
        iwl_trans_write8(trans, ofs, val);
 }
 
 static inline void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val)
 {
-       trace_iwlwifi_dev_iowrite32(priv(trans), ofs, val);
+       trace_iwlwifi_dev_iowrite32(trans->dev, ofs, val);
        iwl_trans_write32(trans, ofs, val);
 }
 
 static inline u32 iwl_read32(struct iwl_trans *trans, u32 ofs)
 {
        u32 val = iwl_trans_read32(trans, ofs);
-       trace_iwlwifi_dev_ioread32(priv(trans), ofs, val);
+       trace_iwlwifi_dev_ioread32(trans->dev, ofs, val);
        return val;
 }
 
index 5c7741f07aa0c491ba388fc78749380d17dc9656..f2f706f084a57c744c2f68af15552bfa470e7924 100644 (file)
@@ -112,7 +112,7 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
                iwl_write32(trans(priv), CSR_LED_REG,
                            reg & CSR_LED_BSM_CTRL_MSK);
 
-       return iwl_trans_send_cmd(trans(priv), &cmd);
+       return iwl_dvm_send_cmd(priv, &cmd);
 }
 
 /* Set led pattern command */
index 9c29234221fd2fbb23ec25048a27b8bfb11511f1..d2c1d714c89c402b518420a44cca7ef9492a217f 100644 (file)
 
 #include <asm/div64.h>
 
-#include "iwl-ucode.h"
 #include "iwl-eeprom.h"
-#include "iwl-wifi.h"
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-io.h"
 #include "iwl-agn-calib.h"
 #include "iwl-agn.h"
 #include "iwl-shared.h"
-#include "iwl-bus.h"
 #include "iwl-trans.h"
+#include "iwl-op-mode.h"
 
 /*****************************************************************************
  *
@@ -136,7 +134,7 @@ iwlagn_iface_combinations_p2p[] = {
  * other mac80211 functions grouped here.
  */
 int iwlagn_mac_setup_register(struct iwl_priv *priv,
-                                 struct iwl_ucode_capabilities *capa)
+                             const struct iwl_ucode_capabilities *capa)
 {
        int ret;
        struct ieee80211_hw *hw = priv->hw;
@@ -161,7 +159,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
        hw->flags |= IEEE80211_HW_SUPPORTS_PS |
                     IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
 
-       if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE)
+       if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE)
                hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
                             IEEE80211_HW_SUPPORTS_STATIC_SMPS;
 
@@ -195,7 +193,8 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
                            WIPHY_FLAG_DISABLE_BEACON_HINTS |
                            WIPHY_FLAG_IBSS_RSN;
 
-       if (nic(priv)->fw.ucode_wowlan.code.len &&
+       if (priv->fw->ucode_wowlan.code.len &&
+           trans(priv)->ops->wowlan_suspend &&
            device_can_wakeup(trans(priv)->dev)) {
                hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT |
                                          WIPHY_WOWLAN_DISCONNECT |
@@ -262,7 +261,7 @@ static int __iwl_up(struct iwl_priv *priv)
        struct iwl_rxon_context *ctx;
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) {
                IWL_WARN(priv, "Exit pending; will not bring the NIC up\n");
@@ -277,13 +276,13 @@ static int __iwl_up(struct iwl_priv *priv)
                }
        }
 
-       ret = iwl_run_init_ucode(trans(priv));
+       ret = iwl_run_init_ucode(priv);
        if (ret) {
                IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret);
                goto error;
        }
 
-       ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_REGULAR);
+       ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
        if (ret) {
                IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret);
                goto error;
@@ -305,15 +304,15 @@ static int __iwl_up(struct iwl_priv *priv)
 
 static int iwlagn_mac_start(struct ieee80211_hw *hw)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int ret;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
        /* we should be verifying the device is ready to be opened */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        ret = __iwl_up(priv);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        if (ret)
                return ret;
 
@@ -332,7 +331,7 @@ static int iwlagn_mac_start(struct ieee80211_hw *hw)
 
 static void iwlagn_mac_stop(struct ieee80211_hw *hw)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
@@ -341,9 +340,9 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw)
 
        priv->is_open = 0;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_down(priv);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        iwl_cancel_deferred_work(priv);
 
@@ -362,13 +361,13 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
                                      struct ieee80211_vif *vif,
                                      struct cfg80211_gtk_rekey_data *data)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        if (iwlagn_mod_params.sw_crypto)
                return;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif)
                goto out;
@@ -380,7 +379,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
        priv->have_rekey_data = true;
 
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
@@ -389,7 +388,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
 static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
                              struct cfg80211_wowlan *wowlan)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
        int ret;
 
@@ -397,7 +396,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
                return -EINVAL;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        /* Don't attempt WoWLAN when not associated, tear down instead. */
        if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION ||
@@ -412,18 +411,16 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
 
        device_set_wakeup_enable(trans(priv)->dev, true);
 
-       /* Now let the ucode operate on its own */
-       iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET,
-                         CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
+       iwl_trans_wowlan_suspend(trans(priv));
 
        goto out;
 
  error:
-       priv->shrd->wowlan = false;
+       priv->wowlan = false;
        iwlagn_prepare_restart(priv);
        ieee80211_restart_hw(priv->hw);
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return ret;
@@ -431,7 +428,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
 
 static int iwlagn_mac_resume(struct ieee80211_hw *hw)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
        struct ieee80211_vif *vif;
        unsigned long flags;
@@ -439,7 +436,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        int ret = -EIO;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR,
                          CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
@@ -457,17 +454,16 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
                if (ret == 0) {
-                       struct iwl_nic *nic = nic(priv);
                        if (!priv->wowlan_sram)
                                priv->wowlan_sram =
-                                       kzalloc(nic->fw.ucode_wowlan.data.len,
+                                       kzalloc(priv->fw->ucode_wowlan.data.len,
                                                GFP_KERNEL);
 
                        if (priv->wowlan_sram)
                                _iwl_read_targ_mem_words(
                                        trans(priv), 0x800000,
                                        priv->wowlan_sram,
-                                       nic->fw.ucode_wowlan.data.len / 4);
+                                       priv->fw->ucode_wowlan.data.len / 4);
                }
 #endif
        }
@@ -475,7 +471,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        /* we'll clear ctx->vif during iwlagn_prepare_restart() */
        vif = ctx->vif;
 
-       priv->shrd->wowlan = false;
+       priv->wowlan = false;
 
        device_set_wakeup_enable(trans(priv)->dev, false);
 
@@ -485,7 +481,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
        iwl_connection_init_rx_config(priv, ctx);
        iwlagn_set_rxon_chain(priv, ctx);
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        ieee80211_resume_disconnect(vif);
@@ -497,7 +493,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
 
 static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
                     ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
@@ -512,7 +508,7 @@ static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw,
                                       struct ieee80211_sta *sta,
                                       u32 iv32, u16 *phase1key)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key);
 }
@@ -522,7 +518,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                              struct ieee80211_sta *sta,
                              struct ieee80211_key_conf *key)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
        struct iwl_rxon_context *ctx = vif_priv->ctx;
        int ret;
@@ -563,7 +559,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET)
                return 0;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_scan_cancel_timeout(priv, 100);
 
        BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT);
@@ -614,7 +610,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                ret = -EINVAL;
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return ret;
@@ -626,18 +622,18 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
                                   struct ieee80211_sta *sta, u16 tid, u16 *ssn,
                                   u8 buf_size)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int ret = -EINVAL;
        struct iwl_station_priv *sta_priv = (void *) sta->drv_priv;
 
        IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n",
                     sta->addr, tid);
 
-       if (!(cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE))
+       if (!(hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE))
                return -EACCES;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        switch (action) {
        case IEEE80211_AMPDU_RX_START:
@@ -649,8 +645,6 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
        case IEEE80211_AMPDU_RX_STOP:
                IWL_DEBUG_HT(priv, "stop Rx\n");
                ret = iwl_sta_rx_agg_stop(priv, sta, tid);
-               if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
-                       ret = 0;
                break;
        case IEEE80211_AMPDU_TX_START:
                if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
@@ -666,10 +660,8 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
                        IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
                                     priv->agg_tids_count);
                }
-               if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
-                       ret = 0;
-               if (!priv->agg_tids_count && cfg(priv)->ht_params &&
-                   cfg(priv)->ht_params->use_rts_for_aggregation) {
+               if (!priv->agg_tids_count &&
+                   hw_params(priv).use_rts_for_aggregation) {
                        /*
                         * switch off RTS/CTS if it was previously enabled
                         */
@@ -683,7 +675,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
                ret = iwlagn_tx_agg_oper(priv, vif, sta, tid, buf_size);
                break;
        }
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return ret;
 }
@@ -692,16 +684,13 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
                              struct ieee80211_vif *vif,
                              struct ieee80211_sta *sta)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
        struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
        bool is_ap = vif->type == NL80211_IFTYPE_STATION;
-       int ret = 0;
+       int ret;
        u8 sta_id;
 
-       IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n",
-                       sta->addr);
-       mutex_lock(&priv->shrd->mutex);
        IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n",
                        sta->addr);
        sta_priv->sta_id = IWL_INVALID_STATION;
@@ -716,17 +705,109 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
                IWL_ERR(priv, "Unable to add station %pM (%d)\n",
                        sta->addr, ret);
                /* Should we return success if return code is EEXIST ? */
-               goto out;
+               return ret;
        }
 
        sta_priv->sta_id = sta_id;
 
-       /* Initialize rate scaling */
-       IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
-                      sta->addr);
-       iwl_rs_rate_init(priv, sta, sta_id);
- out:
-       mutex_unlock(&priv->shrd->mutex);
+       return 0;
+}
+
+static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw,
+                                struct ieee80211_vif *vif,
+                                struct ieee80211_sta *sta)
+{
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
+       struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
+       int ret;
+
+       IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n",
+                       sta->addr);
+       ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr);
+       if (ret)
+               IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n",
+                       sta->addr);
+       return ret;
+}
+
+static int iwlagn_mac_sta_state(struct ieee80211_hw *hw,
+                               struct ieee80211_vif *vif,
+                               struct ieee80211_sta *sta,
+                               enum ieee80211_sta_state old_state,
+                               enum ieee80211_sta_state new_state)
+{
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
+       struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
+       enum {
+               NONE, ADD, REMOVE, HT_RATE_INIT, ADD_RATE_INIT,
+       } op = NONE;
+       int ret;
+
+       IWL_DEBUG_MAC80211(priv, "station %pM state change %d->%d\n",
+                          sta->addr, old_state, new_state);
+
+       mutex_lock(&priv->mutex);
+       if (vif->type == NL80211_IFTYPE_STATION) {
+               if (old_state == IEEE80211_STA_NOTEXIST &&
+                   new_state == IEEE80211_STA_NONE)
+                       op = ADD;
+               else if (old_state == IEEE80211_STA_NONE &&
+                        new_state == IEEE80211_STA_NOTEXIST)
+                       op = REMOVE;
+               else if (old_state == IEEE80211_STA_AUTH &&
+                        new_state == IEEE80211_STA_ASSOC)
+                       op = HT_RATE_INIT;
+       } else {
+               if (old_state == IEEE80211_STA_AUTH &&
+                   new_state == IEEE80211_STA_ASSOC)
+                       op = ADD_RATE_INIT;
+               else if (old_state == IEEE80211_STA_ASSOC &&
+                        new_state == IEEE80211_STA_AUTH)
+                       op = REMOVE;
+       }
+
+       switch (op) {
+       case ADD:
+               ret = iwlagn_mac_sta_add(hw, vif, sta);
+               break;
+       case REMOVE:
+               ret = iwlagn_mac_sta_remove(hw, vif, sta);
+               break;
+       case ADD_RATE_INIT:
+               ret = iwlagn_mac_sta_add(hw, vif, sta);
+               if (ret)
+                       break;
+               /* Initialize rate scaling */
+               IWL_DEBUG_INFO(priv,
+                              "Initializing rate scaling for station %pM\n",
+                              sta->addr);
+               iwl_rs_rate_init(priv, sta, iwl_sta_id(sta));
+               ret = 0;
+               break;
+       case HT_RATE_INIT:
+               /* Initialize rate scaling */
+               ret = iwl_sta_update_ht(priv, vif_priv->ctx, sta);
+               if (ret)
+                       break;
+               IWL_DEBUG_INFO(priv,
+                              "Initializing rate scaling for station %pM\n",
+                              sta->addr);
+               iwl_rs_rate_init(priv, sta, iwl_sta_id(sta));
+               ret = 0;
+               break;
+       default:
+               ret = 0;
+               break;
+       }
+
+       /*
+        * mac80211 might WARN if we fail, but due the way we
+        * (badly) handle hard rfkill, we might fail here
+        */
+       if (iwl_is_rfkill(priv->shrd))
+               ret = 0;
+
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return ret;
@@ -735,7 +816,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
 static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
                                struct ieee80211_channel_switch *ch_switch)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        const struct iwl_channel_info *ch_info;
        struct ieee80211_conf *conf = &hw->conf;
        struct ieee80211_channel *channel = ch_switch->channel;
@@ -753,7 +834,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (iwl_is_rfkill(priv->shrd))
                goto out;
@@ -779,8 +860,6 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
                goto out;
        }
 
-       spin_lock_irq(&priv->shrd->lock);
-
        priv->current_ht_config.smps = conf->smps_mode;
 
        /* Configure HT40 channels */
@@ -797,8 +876,6 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
        iwl_set_rxon_ht(priv, ht_conf);
        iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif);
 
-       spin_unlock_irq(&priv->shrd->lock);
-
        iwl_set_rate(priv);
        /*
         * at this point, staging_rxon has the
@@ -813,7 +890,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
        }
 
 out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
@@ -822,7 +899,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
                                    unsigned int *total_flags,
                                    u64 multicast)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        __le32 filter_or = 0, filter_nand = 0;
        struct iwl_rxon_context *ctx;
 
@@ -843,7 +920,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
 
 #undef CHK
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        for_each_context(priv, ctx) {
                ctx->staging.filter_flags &= ~filter_nand;
@@ -855,7 +932,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
                 */
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        /*
         * Receiving all multicast frames is always enabled by the
@@ -869,9 +946,9 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
 
 static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
        if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) {
@@ -897,7 +974,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop)
        IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n");
        iwl_trans_wait_tx_queue_empty(trans(priv));
 done:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
@@ -906,7 +983,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw,
                                     enum nl80211_channel_type channel_type,
                                     int duration)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN];
        int err = 0;
 
@@ -917,7 +994,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw,
                return -EOPNOTSUPP;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) {
                err = -EBUSY;
@@ -988,7 +1065,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw,
                iwlagn_disable_roc(priv);
 
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return err;
@@ -996,108 +1073,28 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw,
 
 static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
                return -EOPNOTSUPP;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_scan_cancel_timeout(priv, priv->hw_roc_duration);
        iwlagn_disable_roc(priv);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return 0;
 }
 
-static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw,
-                             struct ieee80211_vif *vif,
-                             const u8 *bssid,
-                             enum ieee80211_tx_sync_type type)
-{
-       struct iwl_priv *priv = hw->priv;
-       struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
-       struct iwl_rxon_context *ctx = vif_priv->ctx;
-       int ret;
-       u8 sta_id;
-
-       if (ctx->ctxid != IWL_RXON_CTX_PAN)
-               return 0;
-
-       IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
-
-       if (iwl_is_associated_ctx(ctx)) {
-               ret = 0;
-               goto out;
-       }
-
-       if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW,
-           &priv->shrd->status)) {
-               ret = -EBUSY;
-               goto out;
-       }
-
-       ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id);
-       if (ret)
-               goto out;
-
-       if (WARN_ON(sta_id != ctx->ap_sta_id)) {
-               ret = -EIO;
-               goto out_remove_sta;
-       }
-
-       memcpy(ctx->bssid, bssid, ETH_ALEN);
-       ctx->preauth_bssid = true;
-
-       ret = iwlagn_commit_rxon(priv, ctx);
-
-       if (ret == 0)
-               goto out;
-
- out_remove_sta:
-       iwl_remove_station(priv, sta_id, bssid);
- out:
-       mutex_unlock(&priv->shrd->mutex);
-       IWL_DEBUG_MAC80211(priv, "leave\n");
-
-       return ret;
-}
-
-static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw,
-                                  struct ieee80211_vif *vif,
-                                  const u8 *bssid,
-                                  enum ieee80211_tx_sync_type type)
-{
-       struct iwl_priv *priv = hw->priv;
-       struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
-       struct iwl_rxon_context *ctx = vif_priv->ctx;
-
-       if (ctx->ctxid != IWL_RXON_CTX_PAN)
-               return;
-
-       IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
-
-       if (iwl_is_associated_ctx(ctx))
-               goto out;
-
-       iwl_remove_station(priv, ctx->ap_sta_id, bssid);
-       ctx->preauth_bssid = false;
-       /* no need to commit */
- out:
-       mutex_unlock(&priv->shrd->mutex);
-       IWL_DEBUG_MAC80211(priv, "leave\n");
-}
-
 static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw,
                           enum ieee80211_rssi_event rssi_event)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (cfg(priv)->bt_params &&
                        cfg(priv)->bt_params->advanced_bt_coexist) {
@@ -1112,14 +1109,14 @@ static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw,
                                "ignoring RSSI callback\n");
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 }
 
 static int iwlagn_mac_set_tim(struct ieee80211_hw *hw,
                           struct ieee80211_sta *sta, bool set)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        queue_work(priv->workqueue, &priv->beacon_update);
 
@@ -1130,10 +1127,9 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw,
                    struct ieee80211_vif *vif, u16 queue,
                    const struct ieee80211_tx_queue_params *params)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
        struct iwl_rxon_context *ctx = vif_priv->ctx;
-       unsigned long flags;
        int q;
 
        if (WARN_ON(!ctx))
@@ -1153,7 +1149,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw,
 
        q = AC_NUM - 1 - queue;
 
-       spin_lock_irqsave(&priv->shrd->lock, flags);
+       mutex_lock(&priv->mutex);
 
        ctx->qos_data.def_qos_parm.ac[q].cw_min =
                cpu_to_le16(params->cw_min);
@@ -1165,7 +1161,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw,
 
        ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0;
 
-       spin_unlock_irqrestore(&priv->shrd->lock, flags);
+       mutex_unlock(&priv->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return 0;
@@ -1173,7 +1169,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw,
 
 static int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
 
        return priv->ibss_manager == IWL_IBSS_MANAGER;
 }
@@ -1193,7 +1189,7 @@ static int iwl_setup_interface(struct iwl_priv *priv,
        struct ieee80211_vif *vif = ctx->vif;
        int err;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        /*
         * This variable will be correct only when there's just
@@ -1227,7 +1223,7 @@ static int iwl_setup_interface(struct iwl_priv *priv,
 static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
                             struct ieee80211_vif *vif)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
        struct iwl_rxon_context *tmp, *ctx = NULL;
        int err;
@@ -1238,7 +1234,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
 
        cancel_delayed_work_sync(&priv->hw_roc_disable_work);
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        iwlagn_disable_roc(priv);
 
@@ -1285,7 +1281,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
        ctx->vif = NULL;
        priv->iw_mode = NL80211_IFTYPE_STATION;
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
        return err;
@@ -1297,7 +1293,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv,
 {
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (priv->scan_vif == vif) {
                iwl_scan_cancel_timeout(priv, 200);
@@ -1324,12 +1320,12 @@ static void iwl_teardown_interface(struct iwl_priv *priv,
 static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw,
                              struct ieee80211_vif *vif)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (WARN_ON(ctx->vif != vif)) {
                struct iwl_rxon_context *tmp;
@@ -1342,7 +1338,7 @@ static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw,
 
        iwl_teardown_interface(priv, vif, false);
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
@@ -1352,7 +1348,7 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw,
                                struct ieee80211_vif *vif,
                                enum nl80211_iftype newtype, bool newp2p)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
        struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS];
        struct iwl_rxon_context *tmp;
@@ -1364,7 +1360,7 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw,
 
        newtype = ieee80211_iftype_p2p(newtype, newp2p);
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) {
                /*
@@ -1428,7 +1424,7 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw,
        err = 0;
 
  out:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
        return err;
@@ -1438,7 +1434,7 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw,
                    struct ieee80211_vif *vif,
                    struct cfg80211_scan_request *req)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int ret;
 
        IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -1446,7 +1442,7 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw,
        if (req->n_channels == 0)
                return -EINVAL;
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        /*
         * If an internal scan is in progress, just set
@@ -1475,47 +1471,20 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw,
 
        IWL_DEBUG_MAC80211(priv, "leave\n");
 
-       mutex_unlock(&priv->shrd->mutex);
-
-       return ret;
-}
-
-static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw,
-                      struct ieee80211_vif *vif,
-                      struct ieee80211_sta *sta)
-{
-       struct iwl_priv *priv = hw->priv;
-       struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
-       int ret;
-
-       IWL_DEBUG_MAC80211(priv, "enter: received request to remove "
-                          "station %pM\n", sta->addr);
-       mutex_lock(&priv->shrd->mutex);
-       IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n",
-                       sta->addr);
-       ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr);
-       if (ret)
-               IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n",
-                       sta->addr);
-       mutex_unlock(&priv->shrd->mutex);
-       IWL_DEBUG_MAC80211(priv, "leave\n");
+       mutex_unlock(&priv->mutex);
 
        return ret;
 }
 
 static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&priv->shrd->sta_lock, flags);
-       priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK;
-       priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
-       priv->stations[sta_id].sta.sta.modify_mask = 0;
-       priv->stations[sta_id].sta.sleep_tx_count = 0;
-       priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
-       iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
-       spin_unlock_irqrestore(&priv->shrd->sta_lock, flags);
+       struct iwl_addsta_cmd cmd = {
+               .mode = STA_CONTROL_MODIFY_MSK,
+               .station_flags_msk = STA_FLG_PWR_SAVE_MSK,
+               .sta.sta_id = sta_id,
+       };
 
+       iwl_send_add_sta(priv, &cmd, CMD_ASYNC);
 }
 
 static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw,
@@ -1523,7 +1492,7 @@ static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw,
                           enum sta_notify_cmd cmd,
                           struct ieee80211_sta *sta)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
        int sta_id;
 
@@ -1572,8 +1541,7 @@ struct ieee80211_ops iwlagn_hw_ops = {
        .ampdu_action = iwlagn_mac_ampdu_action,
        .hw_scan = iwlagn_mac_hw_scan,
        .sta_notify = iwlagn_mac_sta_notify,
-       .sta_add = iwlagn_mac_sta_add,
-       .sta_remove = iwlagn_mac_sta_remove,
+       .sta_state = iwlagn_mac_sta_state,
        .channel_switch = iwlagn_mac_channel_switch,
        .flush = iwlagn_mac_flush,
        .tx_last_beacon = iwlagn_mac_tx_last_beacon,
@@ -1582,8 +1550,6 @@ struct ieee80211_ops iwlagn_hw_ops = {
        .rssi_callback = iwlagn_mac_rssi_callback,
        CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd)
        CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump)
-       .tx_sync = iwlagn_mac_tx_sync,
-       .finish_tx_sync = iwlagn_mac_finish_tx_sync,
        .set_tim = iwlagn_mac_set_tim,
 };
 
@@ -1591,15 +1557,18 @@ struct ieee80211_ops iwlagn_hw_ops = {
 struct ieee80211_hw *iwl_alloc_all(void)
 {
        struct iwl_priv *priv;
+       struct iwl_op_mode *op_mode;
        /* mac80211 allocates memory for this device instance, including
         *   space for this driver's private structure */
        struct ieee80211_hw *hw;
 
-       hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops);
+       hw = ieee80211_alloc_hw(sizeof(struct iwl_priv) +
+                               sizeof(struct iwl_op_mode), &iwlagn_hw_ops);
        if (!hw)
                goto out;
 
-       priv = hw->priv;
+       op_mode = hw->priv;
+       priv = IWL_OP_MODE_GET_DVM(op_mode);
        priv->hw = hw;
 
 out:
diff --git a/drivers/net/wireless/iwlwifi/iwl-notif-wait.c b/drivers/net/wireless/iwlwifi/iwl-notif-wait.c
new file mode 100644 (file)
index 0000000..88dc4a0
--- /dev/null
@@ -0,0 +1,157 @@
+/******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#include <linux/sched.h>
+
+#include "iwl-notif-wait.h"
+
+
+void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_wait)
+{
+       spin_lock_init(&notif_wait->notif_wait_lock);
+       INIT_LIST_HEAD(&notif_wait->notif_waits);
+       init_waitqueue_head(&notif_wait->notif_waitq);
+}
+
+void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_wait,
+                                 struct iwl_rx_packet *pkt)
+{
+       if (!list_empty(&notif_wait->notif_waits)) {
+               struct iwl_notification_wait *w;
+
+               spin_lock(&notif_wait->notif_wait_lock);
+               list_for_each_entry(w, &notif_wait->notif_waits, list) {
+                       if (w->cmd != pkt->hdr.cmd)
+                               continue;
+                       w->triggered = true;
+                       if (w->fn)
+                               w->fn(notif_wait, pkt, w->fn_data);
+               }
+               spin_unlock(&notif_wait->notif_wait_lock);
+
+               wake_up_all(&notif_wait->notif_waitq);
+       }
+}
+
+void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_wait)
+{
+       unsigned long flags;
+       struct iwl_notification_wait *wait_entry;
+
+       spin_lock_irqsave(&notif_wait->notif_wait_lock, flags);
+       list_for_each_entry(wait_entry, &notif_wait->notif_waits, list)
+               wait_entry->aborted = true;
+       spin_unlock_irqrestore(&notif_wait->notif_wait_lock, flags);
+
+       wake_up_all(&notif_wait->notif_waitq);
+}
+
+
+void
+iwl_init_notification_wait(struct iwl_notif_wait_data *notif_wait,
+                          struct iwl_notification_wait *wait_entry,
+                          u8 cmd,
+                          void (*fn)(struct iwl_notif_wait_data *notif_wait,
+                                     struct iwl_rx_packet *pkt, void *data),
+                          void *fn_data)
+{
+       wait_entry->fn = fn;
+       wait_entry->fn_data = fn_data;
+       wait_entry->cmd = cmd;
+       wait_entry->triggered = false;
+       wait_entry->aborted = false;
+
+       spin_lock_bh(&notif_wait->notif_wait_lock);
+       list_add(&wait_entry->list, &notif_wait->notif_waits);
+       spin_unlock_bh(&notif_wait->notif_wait_lock);
+}
+
+int iwl_wait_notification(struct iwl_notif_wait_data *notif_wait,
+                         struct iwl_notification_wait *wait_entry,
+                         unsigned long timeout)
+{
+       int ret;
+
+       ret = wait_event_timeout(notif_wait->notif_waitq,
+                                wait_entry->triggered || wait_entry->aborted,
+                                timeout);
+
+       spin_lock_bh(&notif_wait->notif_wait_lock);
+       list_del(&wait_entry->list);
+       spin_unlock_bh(&notif_wait->notif_wait_lock);
+
+       if (wait_entry->aborted)
+               return -EIO;
+
+       /* return value is always >= 0 */
+       if (ret <= 0)
+               return -ETIMEDOUT;
+       return 0;
+}
+
+void iwl_remove_notification(struct iwl_notif_wait_data *notif_wait,
+                            struct iwl_notification_wait *wait_entry)
+{
+       spin_lock_bh(&notif_wait->notif_wait_lock);
+       list_del(&wait_entry->list);
+       spin_unlock_bh(&notif_wait->notif_wait_lock);
+}
similarity index 59%
rename from drivers/net/wireless/iwlwifi/iwl-trans.c
rename to drivers/net/wireless/iwlwifi/iwl-notif-wait.h
index 506c062343b2afce4393fb3fb462d8ad96c7c241..5e8af957aa7bf730586dcc235b779df904df7913 100644 (file)
@@ -41,7 +41,6 @@
  *    notice, this list of conditions and the following disclaimer.
  *  * Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
  *    distribution.
  *  * Neither the name Intel Corporation nor the names of its
  *    contributors may be used to endorse or promote products derived
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  *****************************************************************************/
+#ifndef __iwl_notif_wait_h__
+#define __iwl_notif_wait_h__
+
+#include <linux/wait.h>
 
 #include "iwl-trans.h"
 
-int iwl_trans_send_cmd_pdu(struct iwl_trans *trans, u8 id,
-                          u32 flags, u16 len, const void *data)
-{
-       struct iwl_host_cmd cmd = {
-               .id = id,
-               .len = { len, },
-               .data = { data, },
-               .flags = flags,
-       };
+struct iwl_notif_wait_data {
+       struct list_head notif_waits;
+       spinlock_t notif_wait_lock;
+       wait_queue_head_t notif_waitq;
+};
+
+/**
+ * struct iwl_notification_wait - notification wait entry
+ * @list: list head for global list
+ * @fn: function called with the notification
+ * @cmd: command ID
+ *
+ * This structure is not used directly, to wait for a
+ * notification declare it on the stack, and call
+ * iwlagn_init_notification_wait() with appropriate
+ * parameters. Then do whatever will cause the ucode
+ * to notify the driver, and to wait for that then
+ * call iwlagn_wait_notification().
+ *
+ * Each notification is one-shot. If at some point we
+ * need to support multi-shot notifications (which
+ * can't be allocated on the stack) we need to modify
+ * the code for them.
+ */
+struct iwl_notification_wait {
+       struct list_head list;
+
+       void (*fn)(struct iwl_notif_wait_data *notif_data,
+                  struct iwl_rx_packet *pkt, void *data);
+       void *fn_data;
+
+       u8 cmd;
+       bool triggered, aborted;
+};
+
+
+/* caller functions */
+void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_data);
+void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_data,
+                                 struct iwl_rx_packet *pkt);
+void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_data);
+
+/* user functions */
+void __acquires(wait_entry)
+iwl_init_notification_wait(struct iwl_notif_wait_data *notif_data,
+                          struct iwl_notification_wait *wait_entry,
+                          u8 cmd,
+                          void (*fn)(struct iwl_notif_wait_data *notif_data,
+                                     struct iwl_rx_packet *pkt, void *data),
+                          void *fn_data);
+
+int __must_check __releases(wait_entry)
+iwl_wait_notification(struct iwl_notif_wait_data *notif_data,
+                     struct iwl_notification_wait *wait_entry,
+                     unsigned long timeout);
+
+void __releases(wait_entry)
+iwl_remove_notification(struct iwl_notif_wait_data *notif_data,
+                       struct iwl_notification_wait *wait_entry);
 
-       return iwl_trans_send_cmd(trans, &cmd);
-}
+#endif /* __iwl_notif_wait_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h
new file mode 100644 (file)
index 0000000..6ea4163
--- /dev/null
@@ -0,0 +1,216 @@
+/******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#ifndef __iwl_op_mode_h__
+#define __iwl_op_mode_h__
+
+struct iwl_op_mode;
+struct iwl_trans;
+struct sk_buff;
+struct iwl_device_cmd;
+struct iwl_rx_cmd_buffer;
+struct iwl_fw;
+
+/**
+ * DOC: Operational mode - what is it ?
+ *
+ * The operational mode (a.k.a. op_mode) is the layer that implements
+ * mac80211's handlers. It knows two APIs: mac80211's and the fw's. It uses
+ * the transport API to access the HW. The op_mode doesn't need to know how the
+ * underlying HW works, since the transport layer takes care of that.
+ *
+ * There can be several op_mode: i.e. different fw APIs will require two
+ * different op_modes. This is why the op_mode is virtualized.
+ */
+
+/**
+ * DOC: Life cycle of the Operational mode
+ *
+ * The operational mode has a very simple life cycle.
+ *
+ *     1) The driver layer (iwl-drv.c) chooses the op_mode based on the
+ *        capabilities advertized by the fw file (in TLV format).
+ *     2) The driver layer starts the op_mode (ops->start)
+ *     3) The op_mode registers registers mac80211
+ *     4) The op_mode is governed by mac80211
+ *     5) The driver layer stops the op_mode
+ */
+
+/**
+ * struct iwl_op_mode_ops - op_mode specific operations
+ *
+ * The op_mode exports its ops so that external components can start it and
+ * interact with it. The driver layer typically calls the start and stop
+ * handlers, the transport layer calls the others.
+ *
+ * All the handlers MUST be implemented
+ *
+ * @start: start the op_mode. The transport layer is already allocated.
+ *     May sleep
+ * @stop: stop the op_mode. Must free all the memory allocated.
+ *     May sleep
+ * @rx: Rx notification to the op_mode. rxb is the Rx buffer itself. Cmd is the
+ *     HCMD the this Rx responds to.
+ *     Must be atomic.
+ * @queue_full: notifies that a HW queue is full. Ac is the ac of the queue
+ *     Must be atomic
+ * @queue_not_full: notifies that a HW queue is not full any more.
+ *     Ac is the ac of the queue. Must be atomic
+ * @hw_rf_kill:notifies of a change in the HW rf kill switch. True means that
+ *     the radio is killed. Must be atomic.
+ * @free_skb: allows the transport layer to free skbs that haven't been
+ *     reclaimed by the op_mode. This can happen when the driver is freed and
+ *     there are Tx packets pending in the transport layer.
+ *     Must be atomic
+ * @nic_error: error notification. Must be atomic
+ * @cmd_queue_full: Called when the command queue gets full. Must be atomic.
+ * @nic_config: configure NIC, called before firmware is started.
+ *     May sleep
+ */
+struct iwl_op_mode_ops {
+       struct iwl_op_mode *(*start)(struct iwl_trans *trans,
+                                    const struct iwl_fw *fw);
+       void (*stop)(struct iwl_op_mode *op_mode);
+       int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
+                 struct iwl_device_cmd *cmd);
+       void (*queue_full)(struct iwl_op_mode *op_mode, u8 ac);
+       void (*queue_not_full)(struct iwl_op_mode *op_mode, u8 ac);
+       void (*hw_rf_kill)(struct iwl_op_mode *op_mode, bool state);
+       void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb);
+       void (*nic_error)(struct iwl_op_mode *op_mode);
+       void (*cmd_queue_full)(struct iwl_op_mode *op_mode);
+       void (*nic_config)(struct iwl_op_mode *op_mode);
+};
+
+/**
+ * struct iwl_op_mode - operational mode
+ *
+ * This holds an implementation of the mac80211 / fw API.
+ *
+ * @ops - pointer to its own ops
+ */
+struct iwl_op_mode {
+       const struct iwl_op_mode_ops *ops;
+       const struct iwl_trans *trans;
+
+       char op_mode_specific[0] __aligned(sizeof(void *));
+};
+
+static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode)
+{
+       might_sleep();
+
+       op_mode->ops->stop(op_mode);
+}
+
+static inline int iwl_op_mode_rx(struct iwl_op_mode *op_mode,
+                                 struct iwl_rx_cmd_buffer *rxb,
+                                 struct iwl_device_cmd *cmd)
+{
+       return op_mode->ops->rx(op_mode, rxb, cmd);
+}
+
+static inline void iwl_op_mode_queue_full(struct iwl_op_mode *op_mode, u8 ac)
+{
+       op_mode->ops->queue_full(op_mode, ac);
+}
+
+static inline void iwl_op_mode_queue_not_full(struct iwl_op_mode *op_mode,
+                                             u8 ac)
+{
+       op_mode->ops->queue_not_full(op_mode, ac);
+}
+
+static inline void iwl_op_mode_hw_rf_kill(struct iwl_op_mode *op_mode,
+                                         bool state)
+{
+       op_mode->ops->hw_rf_kill(op_mode, state);
+}
+
+static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode,
+                                       struct sk_buff *skb)
+{
+       op_mode->ops->free_skb(op_mode, skb);
+}
+
+static inline void iwl_op_mode_nic_error(struct iwl_op_mode *op_mode)
+{
+       op_mode->ops->nic_error(op_mode);
+}
+
+static inline void iwl_op_mode_cmd_queue_full(struct iwl_op_mode *op_mode)
+{
+       op_mode->ops->cmd_queue_full(op_mode);
+}
+
+static inline void iwl_op_mode_nic_config(struct iwl_op_mode *op_mode)
+{
+       might_sleep();
+       op_mode->ops->nic_config(op_mode);
+}
+
+/*****************************************************
+* Op mode layers implementations
+******************************************************/
+extern const struct iwl_op_mode_ops iwl_dvm_ops;
+
+#endif /* __iwl_op_mode_h__ */
index 5190670205344e1d0216acb76fb8159ed09902b7..c5e339ee918b03bb49c689eca7f33b0fc7ad592a 100644 (file)
 #include <linux/pci.h>
 #include <linux/pci-aspm.h>
 
-#include "iwl-bus.h"
 #include "iwl-io.h"
 #include "iwl-shared.h"
 #include "iwl-trans.h"
 #include "iwl-csr.h"
 #include "iwl-cfg.h"
-#include "iwl-wifi.h"
+#include "iwl-drv.h"
+#include "iwl-trans.h"
 
 #define IWL_PCI_DEVICE(dev, subdev, cfg) \
        .vendor = PCI_VENDOR_ID_INTEL,  .device = (dev), \
@@ -158,9 +158,9 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
        {IWL_PCI_DEVICE(0x0085, 0x1316, iwl6005_2abg_cfg)},
        {IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)},
        {IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)},
-       {IWL_PCI_DEVICE(0x0082, 0x1341, iwl6005_2agn_d_cfg)},
-       {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_cfg)},/* low 5GHz active */
-       {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_cfg)},/* high 5GHz active */
+       {IWL_PCI_DEVICE(0x0082, 0x4820, iwl6005_2agn_d_cfg)},
+       {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_mow1_cfg)},/* low 5GHz active */
+       {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_mow2_cfg)},/* high 5GHz active */
 
 /* 6x30 Series */
        {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)},
@@ -241,6 +241,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
        {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)},
        {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)},
        {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)},
+       {IWL_PCI_DEVICE(0x088E, 0x4860, iwl6035_2agn_cfg)},
 
 /* 105 Series */
        {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)},
@@ -262,85 +263,57 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
 
 static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-       struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
-       struct iwl_bus *bus;
+       const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
+       struct iwl_shared *shrd;
+       struct iwl_trans *iwl_trans;
        int err;
 
-       bus = kzalloc(sizeof(*bus), GFP_KERNEL);
-       if (!bus) {
-               dev_printk(KERN_ERR, &pdev->dev,
-                          "Couldn't allocate iwl_pci_bus");
-               return -ENOMEM;
-       }
-
-       bus->shrd = kzalloc(sizeof(*bus->shrd), GFP_KERNEL);
-       if (!bus->shrd) {
+       shrd = kzalloc(sizeof(*iwl_trans->shrd), GFP_KERNEL);
+       if (!shrd) {
                dev_printk(KERN_ERR, &pdev->dev,
                           "Couldn't allocate iwl_shared");
                err = -ENOMEM;
                goto out_free_bus;
        }
 
-       bus->shrd->bus = bus;
-
-       /* temporarily create this here */
-       bus->shrd->nic = kzalloc(sizeof(*bus->shrd->nic), GFP_KERNEL);
-       if (!bus->shrd->nic) {
-               dev_printk(KERN_ERR, &pdev->dev,
-                          "Couldn't allocate iwl_nic");
-               err = -ENOMEM;
-               goto out_free_bus;
-       }
-       /* and initialize it as well, temporarily */
-       bus->shrd->nic->shrd = bus->shrd;
-       pci_set_drvdata(pdev, bus);
-
 #ifdef CONFIG_IWLWIFI_IDI
-       trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent);
-       if (trans(bus) == NULL) {
-               err = -ENOMEM;
-               goto out_free_nic;
-       }
-
-       err = iwl_probe(bus, &trans_ops_idi, cfg);
+       iwl_trans = iwl_trans_idi_alloc(shrd, pdev, ent);
 #else
-       trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent);
-       if (trans(bus) == NULL) {
+       iwl_trans = iwl_trans_pcie_alloc(shrd, pdev, ent);
+#endif
+       if (iwl_trans == NULL) {
                err = -ENOMEM;
-               goto out_free_nic;
+               goto out_free_bus;
        }
 
-       err = iwl_probe(bus, &trans_ops_pcie, cfg);
-#endif
+       shrd->trans = iwl_trans;
+       pci_set_drvdata(pdev, iwl_trans);
+
+       err = iwl_drv_start(shrd, iwl_trans, cfg);
        if (err)
                goto out_free_trans;
 
        return 0;
 
 out_free_trans:
-       iwl_trans_free(trans(bus));
+       iwl_trans_free(iwl_trans);
        pci_set_drvdata(pdev, NULL);
-out_free_nic:
-       kfree(bus->shrd->nic);
 out_free_bus:
-       kfree(bus->shrd);
-       kfree(bus);
+       kfree(shrd);
        return err;
 }
 
 static void __devexit iwl_pci_remove(struct pci_dev *pdev)
 {
-       struct iwl_bus *bus = pci_get_drvdata(pdev);
-       struct iwl_shared *shrd = bus->shrd;
+       struct iwl_trans *iwl_trans = pci_get_drvdata(pdev);
+       struct iwl_shared *shrd = iwl_trans->shrd;
 
-       iwl_remove(shrd->priv);
+       iwl_drv_stop(shrd);
        iwl_trans_free(shrd->trans);
 
        pci_set_drvdata(pdev, NULL);
 
-       kfree(bus->shrd->nic);
-       kfree(bus->shrd);
-       kfree(bus);
+       kfree(shrd);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -348,22 +321,20 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
 static int iwl_pci_suspend(struct device *device)
 {
        struct pci_dev *pdev = to_pci_dev(device);
-       struct iwl_bus *bus = pci_get_drvdata(pdev);
-       struct iwl_shared *shrd = bus->shrd;
+       struct iwl_trans *iwl_trans = pci_get_drvdata(pdev);
 
        /* Before you put code here, think about WoWLAN. You cannot check here
         * whether WoWLAN is enabled or not, and your code will run even if
         * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx.
         */
 
-       return iwl_trans_suspend(shrd->trans);
+       return iwl_trans_suspend(iwl_trans);
 }
 
 static int iwl_pci_resume(struct device *device)
 {
        struct pci_dev *pdev = to_pci_dev(device);
-       struct iwl_bus *bus = pci_get_drvdata(pdev);
-       struct iwl_shared *shrd = bus->shrd;
+       struct iwl_trans *iwl_trans = pci_get_drvdata(pdev);
 
        /* Before you put code here, think about WoWLAN. You cannot check here
         * whether WoWLAN is enabled or not, and your code will run even if
@@ -376,7 +347,7 @@ static int iwl_pci_resume(struct device *device)
         */
        pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
 
-       return iwl_trans_resume(shrd->trans);
+       return iwl_trans_resume(iwl_trans);
 }
 
 static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
index fd008c4e41fd749eec780f98ce9ab988827373f9..f79ff16e29f4393cfa01aaca273e6177a074da2c 100644 (file)
@@ -215,7 +215,7 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv,
        else
                cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
 
-       if (hw_params(priv).shadow_reg_enable)
+       if (cfg(priv)->base_params->shadow_reg_enable)
                cmd->flags |= IWL_POWER_SHADOW_REG_ENA;
        else
                cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA;
@@ -301,7 +301,7 @@ static void iwl_power_fill_sleep_cmd(struct iwl_priv *priv,
        if (priv->power_data.bus_pm)
                cmd->flags |= IWL_POWER_PCI_PM_MSK;
 
-       if (hw_params(priv).shadow_reg_enable)
+       if (cfg(priv)->base_params->shadow_reg_enable)
                cmd->flags |= IWL_POWER_SHADOW_REG_ENA;
        else
                cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA;
@@ -336,7 +336,7 @@ static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
                        le32_to_cpu(cmd->sleep_interval[3]),
                        le32_to_cpu(cmd->sleep_interval[4]));
 
-       return iwl_trans_send_cmd_pdu(trans(priv), POWER_TABLE_CMD, CMD_SYNC,
+       return iwl_dvm_send_cmd_pdu(priv, POWER_TABLE_CMD, CMD_SYNC,
                                sizeof(struct iwl_powertable_cmd), cmd);
 }
 
@@ -348,7 +348,7 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
 
        dtimper = priv->hw->conf.ps_dtim_period ?: 1;
 
-       if (priv->shrd->wowlan)
+       if (priv->wowlan)
                iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
        else if (!cfg(priv)->base_params->no_idle_support &&
                 priv->hw->conf.flags & IEEE80211_CONF_IDLE)
@@ -383,7 +383,7 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
        int ret;
        bool update_chains;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        /* Don't update the RX chain when chain noise calibration is running */
        update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
index 42ee1c410efd7cbfc621749c89b72b333ded4a29..8c3fb3233d9f764eeec32b3c09024d9453f8bcd1 100644 (file)
 static int iwl_send_scan_abort(struct iwl_priv *priv)
 {
        int ret;
-       struct iwl_rx_packet *pkt;
        struct iwl_host_cmd cmd = {
                .id = REPLY_SCAN_ABORT_CMD,
                .flags = CMD_SYNC | CMD_WANT_SKB,
        };
+       __le32 *status;
 
        /* Exit instantly with error when device is not ready
         * to receive scan abort command or it does not perform
@@ -69,27 +69,27 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
        if (!test_bit(STATUS_READY, &priv->shrd->status) ||
            !test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status) ||
            !test_bit(STATUS_SCAN_HW, &priv->shrd->status) ||
-           test_bit(STATUS_FW_ERROR, &priv->shrd->status) ||
-           test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
+           test_bit(STATUS_FW_ERROR, &priv->shrd->status))
                return -EIO;
 
-       ret = iwl_trans_send_cmd(trans(priv), &cmd);
+       ret = iwl_dvm_send_cmd(priv, &cmd);
        if (ret)
                return ret;
 
-       pkt = (struct iwl_rx_packet *)cmd.reply_page;
-       if (pkt->u.status != CAN_ABORT_STATUS) {
+       status = (void *)cmd.resp_pkt->data;
+       if (*status != CAN_ABORT_STATUS) {
                /* The scan abort will return 1 for success or
                 * 2 for "failure".  A failure condition can be
                 * due to simply not being in an active scan which
                 * can occur if we send the scan abort before we
                 * the microcode has notified us that a scan is
                 * completed. */
-               IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status);
+               IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n",
+                              le32_to_cpu(*status));
                ret = -EIO;
        }
 
-       iwl_free_pages(priv->shrd, cmd.reply_page);
+       iwl_free_resp(&cmd);
        return ret;
 }
 
@@ -116,7 +116,7 @@ static void iwl_process_scan_complete(struct iwl_priv *priv)
 {
        bool aborted;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (!test_and_clear_bit(STATUS_SCAN_COMPLETE, &priv->shrd->status))
                return;
@@ -173,7 +173,7 @@ out_settings:
 
 void iwl_force_scan_end(struct iwl_priv *priv)
 {
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (!test_bit(STATUS_SCANNING, &priv->shrd->status)) {
                IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n");
@@ -192,7 +192,7 @@ static void iwl_do_scan_abort(struct iwl_priv *priv)
 {
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (!test_bit(STATUS_SCANNING, &priv->shrd->status)) {
                IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n");
@@ -231,7 +231,7 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
 {
        unsigned long timeout = jiffies + msecs_to_jiffies(ms);
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        IWL_DEBUG_SCAN(priv, "Scan cancel timeout\n");
 
@@ -261,13 +261,12 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
 
 /* Service response to REPLY_SCAN_CMD (0x80) */
 static int iwl_rx_reply_scan(struct iwl_priv *priv,
-                             struct iwl_rx_mem_buffer *rxb,
+                             struct iwl_rx_cmd_buffer *rxb,
                              struct iwl_device_cmd *cmd)
 {
 #ifdef CONFIG_IWLWIFI_DEBUG
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_scanreq_notification *notif =
-           (struct iwl_scanreq_notification *)pkt->u.raw;
+       struct iwl_scanreq_notification *notif = (void *)pkt->data;
 
        IWL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status);
 #endif
@@ -276,12 +275,12 @@ static int iwl_rx_reply_scan(struct iwl_priv *priv,
 
 /* Service SCAN_START_NOTIFICATION (0x82) */
 static int iwl_rx_scan_start_notif(struct iwl_priv *priv,
-                                   struct iwl_rx_mem_buffer *rxb,
+                                   struct iwl_rx_cmd_buffer *rxb,
                                    struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_scanstart_notification *notif =
-           (struct iwl_scanstart_notification *)pkt->u.raw;
+       struct iwl_scanstart_notification *notif = (void *)pkt->data;
+
        priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
        IWL_DEBUG_SCAN(priv, "Scan start: "
                       "%d [802.11%s] "
@@ -303,13 +302,12 @@ static int iwl_rx_scan_start_notif(struct iwl_priv *priv,
 
 /* Service SCAN_RESULTS_NOTIFICATION (0x83) */
 static int iwl_rx_scan_results_notif(struct iwl_priv *priv,
-                                     struct iwl_rx_mem_buffer *rxb,
+                                     struct iwl_rx_cmd_buffer *rxb,
                                      struct iwl_device_cmd *cmd)
 {
 #ifdef CONFIG_IWLWIFI_DEBUG
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_scanresults_notification *notif =
-           (struct iwl_scanresults_notification *)pkt->u.raw;
+       struct iwl_scanresults_notification *notif = (void *)pkt->data;
 
        IWL_DEBUG_SCAN(priv, "Scan ch.res: "
                       "%d [802.11%s] "
@@ -329,11 +327,11 @@ static int iwl_rx_scan_results_notif(struct iwl_priv *priv,
 
 /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
 static int iwl_rx_scan_complete_notif(struct iwl_priv *priv,
-                                      struct iwl_rx_mem_buffer *rxb,
+                                      struct iwl_rx_cmd_buffer *rxb,
                                       struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
+       struct iwl_scancomplete_notification *scan_notif = (void *)pkt->data;
 
        IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
                       scan_notif->scanned_channels,
@@ -574,6 +572,53 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
        return added;
 }
 
+/**
+ * iwl_fill_probe_req - fill in all required fields and IE for probe request
+ */
+
+static u16 iwl_fill_probe_req(struct ieee80211_mgmt *frame, const u8 *ta,
+                             const u8 *ies, int ie_len, int left)
+{
+       int len = 0;
+       u8 *pos = NULL;
+
+       /* Make sure there is enough space for the probe request,
+        * two mandatory IEs and the data */
+       left -= 24;
+       if (left < 0)
+               return 0;
+
+       frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
+       memcpy(frame->da, iwl_bcast_addr, ETH_ALEN);
+       memcpy(frame->sa, ta, ETH_ALEN);
+       memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN);
+       frame->seq_ctrl = 0;
+
+       len += 24;
+
+       /* ...next IE... */
+       pos = &frame->u.probe_req.variable[0];
+
+       /* fill in our indirect SSID IE */
+       left -= 2;
+       if (left < 0)
+               return 0;
+       *pos++ = WLAN_EID_SSID;
+       *pos++ = 0;
+
+       len += 2;
+
+       if (WARN_ON(left < ie_len))
+               return len;
+
+       if (ies && ie_len) {
+               memcpy(pos, ies, ie_len);
+               len += ie_len;
+       }
+
+       return (u16)len;
+}
+
 static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
 {
        struct iwl_host_cmd cmd = {
@@ -596,7 +641,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        u8 scan_tx_antennas = hw_params(priv).valid_tx_ant;
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        if (vif)
                ctx = iwl_rxon_ctx_from_vif(vif);
@@ -793,7 +838,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        scan->rx_chain = cpu_to_le16(rx_chain);
        switch (priv->scan_type) {
        case IWL_SCAN_NORMAL:
-               cmd_len = iwl_fill_probe_req(priv,
+               cmd_len = iwl_fill_probe_req(
                                        (struct ieee80211_mgmt *)scan->data,
                                        vif->addr,
                                        priv->scan_request->ie,
@@ -803,7 +848,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        case IWL_SCAN_RADIO_RESET:
        case IWL_SCAN_ROC:
                /* use bcast addr, will not be transmitted but must be valid */
-               cmd_len = iwl_fill_probe_req(priv,
+               cmd_len = iwl_fill_probe_req(
                                        (struct ieee80211_mgmt *)scan->data,
                                        iwl_bcast_addr, NULL, 0,
                                        IWL_MAX_SCAN_SIZE - sizeof(*scan));
@@ -888,7 +933,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
        if (ret)
                return ret;
 
-       ret = iwl_trans_send_cmd(trans(priv), &cmd);
+       ret = iwl_dvm_send_cmd(priv, &cmd);
        if (ret) {
                clear_bit(STATUS_SCAN_HW, &priv->shrd->status);
                iwlagn_set_pan_params(priv);
@@ -913,7 +958,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
 {
        int ret;
 
-       lockdep_assert_held(&priv->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        cancel_delayed_work(&priv->scan_check);
 
@@ -973,7 +1018,7 @@ static void iwl_bg_start_internal_scan(struct work_struct *work)
 
        IWL_DEBUG_SCAN(priv, "Start internal scan\n");
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        if (priv->scan_type == IWL_SCAN_RADIO_RESET) {
                IWL_DEBUG_SCAN(priv, "Internal scan already in progress\n");
@@ -988,7 +1033,7 @@ static void iwl_bg_start_internal_scan(struct work_struct *work)
        if (iwl_scan_initiate(priv, NULL, IWL_SCAN_RADIO_RESET, priv->band))
                IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n");
  unlock:
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 static void iwl_bg_scan_check(struct work_struct *data)
@@ -1001,56 +1046,9 @@ static void iwl_bg_scan_check(struct work_struct *data)
        /* Since we are here firmware does not finish scan and
         * most likely is in bad shape, so we don't bother to
         * send abort command, just force scan complete to mac80211 */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_force_scan_end(priv);
-       mutex_unlock(&priv->shrd->mutex);
-}
-
-/**
- * iwl_fill_probe_req - fill in all required fields and IE for probe request
- */
-
-u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
-                      const u8 *ta, const u8 *ies, int ie_len, int left)
-{
-       int len = 0;
-       u8 *pos = NULL;
-
-       /* Make sure there is enough space for the probe request,
-        * two mandatory IEs and the data */
-       left -= 24;
-       if (left < 0)
-               return 0;
-
-       frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
-       memcpy(frame->da, iwl_bcast_addr, ETH_ALEN);
-       memcpy(frame->sa, ta, ETH_ALEN);
-       memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN);
-       frame->seq_ctrl = 0;
-
-       len += 24;
-
-       /* ...next IE... */
-       pos = &frame->u.probe_req.variable[0];
-
-       /* fill in our indirect SSID IE */
-       left -= 2;
-       if (left < 0)
-               return 0;
-       *pos++ = WLAN_EID_SSID;
-       *pos++ = 0;
-
-       len += 2;
-
-       if (WARN_ON(left < ie_len))
-               return len;
-
-       if (ies && ie_len) {
-               memcpy(pos, ies, ie_len);
-               len += ie_len;
-       }
-
-       return (u16)len;
+       mutex_unlock(&priv->mutex);
 }
 
 static void iwl_bg_abort_scan(struct work_struct *work)
@@ -1061,9 +1059,9 @@ static void iwl_bg_abort_scan(struct work_struct *work)
 
        /* We keep scan_check work queued in case when firmware will not
         * report back scan completed notification */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_scan_cancel_timeout(priv, 200);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 static void iwl_bg_scan_completed(struct work_struct *work)
@@ -1071,9 +1069,9 @@ static void iwl_bg_scan_completed(struct work_struct *work)
        struct iwl_priv *priv =
                container_of(work, struct iwl_priv, scan_completed);
 
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        iwl_process_scan_complete(priv);
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
 }
 
 void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
@@ -1091,8 +1089,8 @@ void iwl_cancel_scan_deferred_work(struct iwl_priv *priv)
        cancel_work_sync(&priv->scan_completed);
 
        if (cancel_delayed_work_sync(&priv->scan_check)) {
-               mutex_lock(&priv->shrd->mutex);
+               mutex_lock(&priv->mutex);
                iwl_force_scan_end(priv);
-               mutex_unlock(&priv->shrd->mutex);
+               mutex_unlock(&priv->mutex);
        }
 }
index f810b41db9dfba0a27cdca623589ec83f165fc37..ff3394c47635bb6f91394e86dd4b2ff036688549 100644 (file)
 
 #include <linux/types.h>
 #include <linux/spinlock.h>
-#include <linux/mutex.h>
 #include <linux/gfp.h>
-#include <linux/mm.h> /* for page_address */
 #include <net/mac80211.h>
 
 #include "iwl-commands.h"
+#include "iwl-fw.h"
 
 /**
  * DOC: shared area - role and goal
@@ -94,7 +93,6 @@
  * This implementation is iwl-pci.c
  */
 
-struct iwl_bus;
 struct iwl_priv;
 struct iwl_trans;
 struct iwl_sensitivity_ranges;
@@ -117,7 +115,6 @@ extern struct iwl_mod_params iwlagn_mod_params;
  * Holds the module parameters
  *
  * @sw_crypto: using hardware encryption, default = 0
- * @num_of_queues: number of tx queue, HW dependent
  * @disable_11n: disable 11n capabilities, default = 0,
  *     use IWL_DISABLE_HT_* constants
  * @amsdu_size_8K: enable 8K amsdu size, default = 1
@@ -139,7 +136,6 @@ extern struct iwl_mod_params iwlagn_mod_params;
  */
 struct iwl_mod_params {
        int sw_crypto;
-       int num_of_queues;
        unsigned int disable_11n;
        int amsdu_size_8K;
        int antenna;
@@ -178,6 +174,7 @@ struct iwl_mod_params {
  *     relevant for 1000, 6000 and up
  * @wd_timeout: TX queues watchdog timeout
  * @struct iwl_sensitivity_ranges: range of sensitivity values
+ * @use_rts_for_aggregation: use rts/cts protection for HT traffic
  */
 struct iwl_hw_params {
        u8  max_txq_num;
@@ -187,7 +184,7 @@ struct iwl_hw_params {
        u8  valid_tx_ant;
        u8  valid_rx_ant;
        u8  ht40_channel;
-       bool shadow_reg_enable;
+       bool use_rts_for_aggregation;
        u16 sku;
        u32 rx_page_order;
        u32 ct_kill_threshold;
@@ -214,45 +211,6 @@ enum iwl_ucode_type {
        IWL_UCODE_WOWLAN,
 };
 
-/**
- * struct iwl_notification_wait - notification wait entry
- * @list: list head for global list
- * @fn: function called with the notification
- * @cmd: command ID
- *
- * This structure is not used directly, to wait for a
- * notification declare it on the stack, and call
- * iwlagn_init_notification_wait() with appropriate
- * parameters. Then do whatever will cause the ucode
- * to notify the driver, and to wait for that then
- * call iwlagn_wait_notification().
- *
- * Each notification is one-shot. If at some point we
- * need to support multi-shot notifications (which
- * can't be allocated on the stack) we need to modify
- * the code for them.
- */
-struct iwl_notification_wait {
-       struct list_head list;
-
-       void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt,
-                  void *data);
-       void *fn_data;
-
-       u8 cmd;
-       bool triggered, aborted;
-};
-
-/**
- * enum iwl_pa_type - Power Amplifier type
- * @IWL_PA_SYSTEM:  based on uCode configuration
- * @IWL_PA_INTERNAL: use Internal only
- */
-enum iwl_pa_type {
-       IWL_PA_SYSTEM = 0,
-       IWL_PA_INTERNAL = 1,
-};
-
 /*
  * LED mode
  *    IWL_LED_DEFAULT:  use device default
@@ -269,6 +227,49 @@ enum iwl_led_mode {
        IWL_LED_DISABLE,
 };
 
+/*
+ * @max_ll_items: max number of OTP blocks
+ * @shadow_ram_support: shadow support for OTP memory
+ * @led_compensation: compensate on the led on/off time per HW according
+ *     to the deviation to achieve the desired led frequency.
+ *     The detail algorithm is described in iwl-led.c
+ * @chain_noise_num_beacons: number of beacons used to compute chain noise
+ * @adv_thermal_throttle: support advance thermal throttle
+ * @support_ct_kill_exit: support ct kill exit condition
+ * @support_wimax_coexist: support wimax/wifi co-exist
+ * @plcp_delta_threshold: plcp error rate threshold used to trigger
+ *     radio tuning when there is a high receiving plcp error rate
+ * @chain_noise_scale: default chain noise scale used for gain computation
+ * @wd_timeout: TX queues watchdog timeout
+ * @max_event_log_size: size of event log buffer size for ucode event logging
+ * @shadow_reg_enable: HW shadhow register bit
+ * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
+ * @no_idle_support: do not support idle mode
+ * wd_disable: disable watchdog timer
+ */
+struct iwl_base_params {
+       int eeprom_size;
+       int num_of_queues;      /* def: HW dependent */
+       int num_of_ampdu_queues;/* def: HW dependent */
+       /* for iwl_apm_init() */
+       u32 pll_cfg_val;
+
+       const u16 max_ll_items;
+       const bool shadow_ram_support;
+       u16 led_compensation;
+       bool adv_thermal_throttle;
+       bool support_ct_kill_exit;
+       const bool support_wimax_coexist;
+       u8 plcp_delta_threshold;
+       s32 chain_noise_scale;
+       unsigned int wd_timeout;
+       u32 max_event_log_size;
+       const bool shadow_reg_enable;
+       const bool hd_v2;
+       const bool no_idle_support;
+       const bool wd_disable;
+};
+
 /**
  * struct iwl_cfg
  * @name: Offical name of the device
@@ -283,7 +284,6 @@ enum iwl_led_mode {
  * @max_data_size: The maximal length of the fw data section
  * @valid_tx_ant: valid transmit antenna
  * @valid_rx_ant: valid receive antenna
- * @sku: sku information from EEPROM
  * @eeprom_ver: EEPROM version
  * @eeprom_calib_ver: EEPROM calibration version
  * @lib: pointer to the lib ops
@@ -291,7 +291,6 @@ enum iwl_led_mode {
  * @base_params: pointer to basic parameters
  * @ht_params: point to ht patameters
  * @bt_params: pointer to bt parameters
- * @pa_type: used by 6000 series only to identify the type of Power Amplifier
  * @need_temp_offset_calib: need to perform temperature offset calibration
  * @no_xtal_calib: some devices do not need crystal calibration data,
  *     don't send it to those
@@ -322,17 +321,15 @@ struct iwl_cfg {
        const u32 max_inst_size;
        u8   valid_tx_ant;
        u8   valid_rx_ant;
-       u16  sku;
        u16  eeprom_ver;
        u16  eeprom_calib_ver;
        const struct iwl_lib_ops *lib;
        void (*additional_nic_config)(struct iwl_priv *priv);
        /* params not likely to change within a device family */
-       struct iwl_base_params *base_params;
+       const struct iwl_base_params *base_params;
        /* params likely to change within a device family */
-       struct iwl_ht_params *ht_params;
-       struct iwl_bt_params *bt_params;
-       enum iwl_pa_type pa_type;         /* if used set to IWL_PA_SYSTEM */
+       const struct iwl_ht_params *ht_params;
+       const struct iwl_bt_params *bt_params;
        const bool need_temp_offset_calib; /* if used set to true */
        const bool no_xtal_calib;
        u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
@@ -347,9 +344,6 @@ struct iwl_cfg {
 /**
  * struct iwl_shared - shared fields for all the layers of the driver
  *
- * @dbg_level_dev: dbg level set per device. Prevails on
- *     iwlagn_mod_params.debug_level if set (!= 0)
- * @ucode_owner: IWL_OWNERSHIP_*
  * @cmd_queue: command queue number
  * @status: STATUS_*
  * @wowlan: are we running wowlan uCode
@@ -361,40 +355,21 @@ struct iwl_cfg {
  * @nic: pointer to the nic data
  * @hw_params: see struct iwl_hw_params
  * @lock: protect general shared data
- * @sta_lock: protects the station table.
- *     If lock and sta_lock are needed, lock must be acquired first.
- * @mutex:
- * @wait_command_queue: the wait_queue for SYNC host command nad uCode load
+ * @wait_command_queue: the wait_queue for SYNC host commands
  * @eeprom: pointer to the eeprom/OTP image
  * @ucode_type: indicator of loaded ucode image
- * @notif_waits: things waiting for notification
- * @notif_wait_lock: lock protecting notification
- * @notif_waitq: head of notification wait queue
  * @device_pointers: pointers to ucode event tables
  */
 struct iwl_shared {
-#ifdef CONFIG_IWLWIFI_DEBUG
-       u32 dbg_level_dev;
-#endif /* CONFIG_IWLWIFI_DEBUG */
-
-#define IWL_OWNERSHIP_DRIVER   0
-#define IWL_OWNERSHIP_TM       1
-       u8 ucode_owner;
        u8 cmd_queue;
        unsigned long status;
-       bool wowlan;
        u8 valid_contexts;
 
-       struct iwl_bus *bus;
-       struct iwl_cfg *cfg;
-       struct iwl_priv *priv;
+       const struct iwl_cfg *cfg;
        struct iwl_trans *trans;
-       struct iwl_nic *nic;
+       void *drv;
        struct iwl_hw_params hw_params;
-
-       spinlock_t lock;
-       spinlock_t sta_lock;
-       struct mutex mutex;
+       const struct iwl_fw *fw;
 
        wait_queue_head_t wait_command_queue;
 
@@ -404,11 +379,6 @@ struct iwl_shared {
        /* ucode related variables */
        enum iwl_ucode_type ucode_type;
 
-       /* notification wait support */
-       struct list_head notif_waits;
-       spinlock_t notif_wait_lock;
-       wait_queue_head_t notif_waitq;
-
        struct {
                u32 error_event_table;
                u32 log_event_table;
@@ -416,113 +386,14 @@ struct iwl_shared {
 
 };
 
-/*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */
-#define priv(_m)       ((_m)->shrd->priv)
+/*Whatever _m is (iwl_trans, iwl_priv, these macros will work */
 #define cfg(_m)                ((_m)->shrd->cfg)
-#define bus(_m)                ((_m)->shrd->bus)
-#define nic(_m)                ((_m)->shrd->nic)
 #define trans(_m)      ((_m)->shrd->trans)
 #define hw_params(_m)  ((_m)->shrd->hw_params)
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-/*
- * iwl_get_debug_level: Return active debug level for device
- *
- * Using sysfs it is possible to set per device debug level. This debug
- * level will be used if set, otherwise the global debug level which can be
- * set via module parameter is used.
- */
-static inline u32 iwl_get_debug_level(struct iwl_shared *shrd)
-{
-       if (shrd->dbg_level_dev)
-               return shrd->dbg_level_dev;
-       else
-               return iwlagn_mod_params.debug_level;
-}
-#else
-static inline u32 iwl_get_debug_level(struct iwl_shared *shrd)
-{
-       return iwlagn_mod_params.debug_level;
-}
-#endif
-
-static inline void iwl_free_pages(struct iwl_shared *shrd, unsigned long page)
-{
-       free_pages(page, shrd->hw_params.rx_page_order);
-}
-
-/**
- * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
- * @index -- current index
- * @n_bd -- total number of entries in queue (must be power of 2)
- */
-static inline int iwl_queue_inc_wrap(int index, int n_bd)
-{
-       return ++index & (n_bd - 1);
-}
-
-/**
- * iwl_queue_dec_wrap - decrement queue index, wrap back to end
- * @index -- current index
- * @n_bd -- total number of entries in queue (must be power of 2)
- */
-static inline int iwl_queue_dec_wrap(int index, int n_bd)
+static inline bool iwl_have_debug_level(u32 level)
 {
-       return --index & (n_bd - 1);
-}
-
-struct iwl_rx_mem_buffer {
-       dma_addr_t page_dma;
-       struct page *page;
-       struct list_head list;
-};
-
-#define rxb_addr(r) page_address(r->page)
-
-/*
- * mac80211 queues, ACs, hardware queues, FIFOs.
- *
- * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues
- *
- * Mac80211 uses the following numbers, which we get as from it
- * by way of skb_get_queue_mapping(skb):
- *
- *     VO      0
- *     VI      1
- *     BE      2
- *     BK      3
- *
- *
- * Regular (not A-MPDU) frames are put into hardware queues corresponding
- * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their
- * own queue per aggregation session (RA/TID combination), such queues are
- * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In
- * order to map frames to the right queue, we also need an AC->hw queue
- * mapping. This is implemented here.
- *
- * Due to the way hw queues are set up (by the hw specific modules like
- * iwl-4965.c, iwl-5000.c etc.), the AC->hw queue mapping is the identity
- * mapping.
- */
-
-static const u8 tid_to_ac[] = {
-       IEEE80211_AC_BE,
-       IEEE80211_AC_BK,
-       IEEE80211_AC_BK,
-       IEEE80211_AC_BE,
-       IEEE80211_AC_VI,
-       IEEE80211_AC_VI,
-       IEEE80211_AC_VO,
-       IEEE80211_AC_VO
-};
-
-static inline int get_ac_from_tid(u16 tid)
-{
-       if (likely(tid < ARRAY_SIZE(tid_to_ac)))
-               return tid_to_ac[tid];
-
-       /* no support for TIDs 8-15 yet */
-       return -EINVAL;
+       return iwlagn_mod_params.debug_level & level;
 }
 
 enum iwl_rxon_context_id {
@@ -532,62 +403,10 @@ enum iwl_rxon_context_id {
        NUM_IWL_RXON_CTX
 };
 
-int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops,
-               struct iwl_cfg *cfg);
-void __devexit iwl_remove(struct iwl_priv * priv);
-struct iwl_device_cmd;
-int __must_check iwl_rx_dispatch(struct iwl_priv *priv,
-                                struct iwl_rx_mem_buffer *rxb,
-                                struct iwl_device_cmd *cmd);
-
 int iwlagn_hw_valid_rtc_data_addr(u32 addr);
-void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state);
-void iwl_nic_config(struct iwl_priv *priv);
-void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb);
-void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand);
 const char *get_cmd_string(u8 cmd);
-bool iwl_check_for_ct_kill(struct iwl_priv *priv);
-
-void iwl_stop_sw_queue(struct iwl_priv *priv, u8 ac);
-void iwl_wake_sw_queue(struct iwl_priv *priv, u8 ac);
-
-/* notification wait support */
-void iwl_abort_notification_waits(struct iwl_shared *shrd);
-void __acquires(wait_entry)
-iwl_init_notification_wait(struct iwl_shared *shrd,
-                             struct iwl_notification_wait *wait_entry,
-                             u8 cmd,
-                             void (*fn)(struct iwl_trans *trans,
-                                        struct iwl_rx_packet *pkt,
-                                        void *data),
-                             void *fn_data);
-int __must_check __releases(wait_entry)
-iwl_wait_notification(struct iwl_shared *shrd,
-                        struct iwl_notification_wait *wait_entry,
-                        unsigned long timeout);
-void __releases(wait_entry)
-iwl_remove_notification(struct iwl_shared *shrd,
-                          struct iwl_notification_wait *wait_entry);
-
-#ifdef CONFIG_IWLWIFI_DEBUGFS
-void iwl_reset_traffic_log(struct iwl_priv *priv);
-#endif /* CONFIG_IWLWIFI_DEBUGFS */
-
-#ifdef CONFIG_IWLWIFI_DEBUG
-void iwl_print_rx_config_cmd(struct iwl_priv *priv,
-                            enum iwl_rxon_context_id ctxid);
-#else
-static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
-                                          enum iwl_rxon_context_id ctxid)
-{
-}
-#endif
 
 #define IWL_CMD(x) case x: return #x
-#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
-
-#define IWL_TRAFFIC_ENTRIES    (256)
-#define IWL_TRAFFIC_ENTRY_SIZE  (64)
 
 /*****************************************************
 * DRIVER STATUS FUNCTIONS
@@ -613,46 +432,4 @@ static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
 #define STATUS_CHANNEL_SWITCH_PENDING 19
 #define STATUS_SCAN_COMPLETE   20
 
-static inline int iwl_is_ready(struct iwl_shared *shrd)
-{
-       /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
-        * set but EXIT_PENDING is not */
-       return test_bit(STATUS_READY, &shrd->status) &&
-              test_bit(STATUS_GEO_CONFIGURED, &shrd->status) &&
-              !test_bit(STATUS_EXIT_PENDING, &shrd->status);
-}
-
-static inline int iwl_is_alive(struct iwl_shared *shrd)
-{
-       return test_bit(STATUS_ALIVE, &shrd->status);
-}
-
-static inline int iwl_is_init(struct iwl_shared *shrd)
-{
-       return test_bit(STATUS_INIT, &shrd->status);
-}
-
-static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd)
-{
-       return test_bit(STATUS_RF_KILL_HW, &shrd->status);
-}
-
-static inline int iwl_is_rfkill(struct iwl_shared *shrd)
-{
-       return iwl_is_rfkill_hw(shrd);
-}
-
-static inline int iwl_is_ctkill(struct iwl_shared *shrd)
-{
-       return test_bit(STATUS_CT_KILL, &shrd->status);
-}
-
-static inline int iwl_is_ready_rf(struct iwl_shared *shrd)
-{
-       if (iwl_is_rfkill(shrd))
-               return 0;
-
-       return iwl_is_ready(shrd);
-}
-
 #endif /* #__iwl_shared_h__ */
index 80955ed06e821c04fbde46c083de35fa07116ac6..5b06916be6107789d287ebe643592e75e11d910a 100644 (file)
@@ -70,7 +70,6 @@
 #include <net/mac80211.h>
 #include <net/netlink.h>
 
-#include "iwl-wifi.h"
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-debug.h"
@@ -78,8 +77,8 @@
 #include "iwl-agn.h"
 #include "iwl-testmode.h"
 #include "iwl-trans.h"
-#include "iwl-bus.h"
 #include "iwl-fh.h"
+#include "iwl-prph.h"
 
 
 /* Periphery registers absolute lower bound. This is used in order to
@@ -132,7 +131,7 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = {
  * See the struct iwl_rx_packet in iwl-commands.h for the format of the
  * received events from the device
  */
-static inline int get_event_length(struct iwl_rx_mem_buffer *rxb)
+static inline int get_event_length(struct iwl_rx_cmd_buffer *rxb)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
        if (pkt)
@@ -163,7 +162,7 @@ static inline int get_event_length(struct iwl_rx_mem_buffer *rxb)
  */
 
 static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv,
-                               struct iwl_rx_mem_buffer *rxb)
+                                     struct iwl_rx_cmd_buffer *rxb)
 {
        struct ieee80211_hw *hw = priv->hw;
        struct sk_buff *skb;
@@ -255,7 +254,7 @@ void iwl_testmode_cleanup(struct iwl_priv *priv)
  */
 static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_host_cmd cmd;
        struct iwl_rx_packet *pkt;
        struct sk_buff *skb;
@@ -284,7 +283,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
        IWL_DEBUG_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x,"
                                " len %d\n", cmd.id, cmd.flags, cmd.len[0]);
 
-       ret = iwl_trans_send_cmd(trans(priv), &cmd);
+       ret = iwl_dvm_send_cmd(priv, &cmd);
        if (ret) {
                IWL_ERR(priv, "Failed to send hcmd\n");
                return ret;
@@ -293,7 +292,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
                return ret;
 
        /* Handling return of SKB to the user */
-       pkt = (struct iwl_rx_packet *)cmd.reply_page;
+       pkt = cmd.resp_pkt;
        if (!pkt) {
                IWL_ERR(priv, "HCMD received a null response packet\n");
                return ret;
@@ -310,7 +309,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
 
        /* The reply is in a page, that we cannot send to user space. */
        memcpy(reply_buf, &(pkt->hdr), reply_len);
-       iwl_free_pages(priv->shrd, cmd.reply_page);
+       iwl_free_resp(&cmd);
 
        NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT);
        NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf);
@@ -341,7 +340,7 @@ nla_put_failure:
  */
 static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        u32 ofs, val32, cmd;
        u8 val8;
        struct sk_buff *skb;
@@ -420,23 +419,23 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv)
        struct iwl_notification_wait calib_wait;
        int ret;
 
-       iwl_init_notification_wait(priv->shrd, &calib_wait,
-                                     CALIBRATION_COMPLETE_NOTIFICATION,
-                                     NULL, NULL);
-       ret = iwl_init_alive_start(trans(priv));
+       iwl_init_notification_wait(&priv->notif_wait, &calib_wait,
+                                  CALIBRATION_COMPLETE_NOTIFICATION,
+                                  NULL, NULL);
+       ret = iwl_init_alive_start(priv);
        if (ret) {
                IWL_ERR(priv, "Fail init calibration: %d\n", ret);
                goto cfg_init_calib_error;
        }
 
-       ret = iwl_wait_notification(priv->shrd, &calib_wait, 2 * HZ);
+       ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, 2 * HZ);
        if (ret)
                IWL_ERR(priv, "Error detecting"
                        " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret);
        return ret;
 
 cfg_init_calib_error:
-       iwl_remove_notification(priv->shrd, &calib_wait);
+       iwl_remove_notification(&priv->notif_wait, &calib_wait);
        return ret;
 }
 
@@ -458,7 +457,7 @@ cfg_init_calib_error:
  */
 static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct iwl_trans *trans = trans(priv);
        struct sk_buff *skb;
        unsigned char *rsp_data_ptr = NULL;
@@ -485,7 +484,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
                break;
 
        case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
-               status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT);
+               status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);
                if (status)
                        IWL_ERR(priv, "Error loading init ucode: %d\n", status);
                break;
@@ -496,7 +495,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
                break;
 
        case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
-               status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_REGULAR);
+               status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
                if (status) {
                        IWL_ERR(priv,
                                "Error loading runtime ucode: %d\n", status);
@@ -511,7 +510,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
        case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
                iwl_scan_cancel_timeout(priv, 200);
                iwl_trans_stop_device(trans);
-               status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_WOWLAN);
+               status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN);
                if (status) {
                        IWL_ERR(priv,
                                "Error loading WOWLAN ucode: %d\n", status);
@@ -554,7 +553,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
 
        case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
                IWL_INFO(priv, "uCode version raw: 0x%x\n",
-                        nic(priv)->fw.ucode_ver);
+                        priv->fw->ucode_ver);
 
                skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
                if (!skb) {
@@ -562,7 +561,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
                        return -ENOMEM;
                }
                NLA_PUT_U32(skb, IWL_TM_ATTR_FW_VERSION,
-                           nic(priv)->fw.ucode_ver);
+                           priv->fw->ucode_ver);
                status = cfg80211_testmode_reply(skb);
                if (status < 0)
                        IWL_ERR(priv, "Error sending msg : %d\n", status);
@@ -591,16 +590,16 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
                }
                switch (priv->shrd->ucode_type) {
                case IWL_UCODE_REGULAR:
-                       inst_size = nic(priv)->fw.ucode_rt.code.len;
-                       data_size = nic(priv)->fw.ucode_rt.data.len;
+                       inst_size = priv->fw->ucode_rt.code.len;
+                       data_size = priv->fw->ucode_rt.data.len;
                        break;
                case IWL_UCODE_INIT:
-                       inst_size = nic(priv)->fw.ucode_init.code.len;
-                       data_size = nic(priv)->fw.ucode_init.data.len;
+                       inst_size = priv->fw->ucode_init.code.len;
+                       data_size = priv->fw->ucode_init.data.len;
                        break;
                case IWL_UCODE_WOWLAN:
-                       inst_size = nic(priv)->fw.ucode_wowlan.code.len;
-                       data_size = nic(priv)->fw.ucode_wowlan.data.len;
+                       inst_size = priv->fw->ucode_wowlan.code.len;
+                       data_size = priv->fw->ucode_wowlan.data.len;
                        break;
                case IWL_UCODE_NONE:
                        IWL_ERR(priv, "No uCode has not been loaded\n");
@@ -643,7 +642,7 @@ nla_put_failure:
  */
 static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        struct sk_buff *skb;
        int status = 0;
        struct device *dev = trans(priv)->dev;
@@ -718,7 +717,7 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb,
                                   struct sk_buff *skb,
                                   struct netlink_callback *cb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int idx, length;
 
        if (priv->testmode_trace.trace_enabled &&
@@ -762,7 +761,7 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb,
  */
 static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        u8 owner;
 
        if (!tb[IWL_TM_ATTR_UCODE_OWNER]) {
@@ -772,7 +771,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
 
        owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
        if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM))
-               priv->shrd->ucode_owner = owner;
+               priv->ucode_owner = owner;
        else {
                IWL_ERR(priv, "Invalid owner\n");
                return -EINVAL;
@@ -876,7 +875,7 @@ static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr,
 static int iwl_testmode_indirect_mem(struct ieee80211_hw *hw,
        struct nlattr **tb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        u32 addr, size, cmd;
        unsigned char *buf;
 
@@ -910,7 +909,7 @@ static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, struct nlattr **tb,
                                   struct sk_buff *skb,
                                   struct netlink_callback *cb)
 {
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int idx, length;
 
        if (priv->testmode_mem.read_in_progress) {
@@ -961,7 +960,7 @@ static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, struct nlattr **tb,
 int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
 {
        struct nlattr *tb[IWL_TM_ATTR_MAX];
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int result;
 
        result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len,
@@ -977,7 +976,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
                return -ENOMSG;
        }
        /* in case multiple accesses to the device happens */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
 
        switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
        case IWL_TM_CMD_APP2DEV_UCODE:
@@ -1029,7 +1028,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
                break;
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        return result;
 }
 
@@ -1038,7 +1037,7 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
                      void *data, int len)
 {
        struct nlattr *tb[IWL_TM_ATTR_MAX];
-       struct iwl_priv *priv = hw->priv;
+       struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
        int result;
        u32 cmd;
 
@@ -1064,7 +1063,7 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
        }
 
        /* in case multiple accesses to the device happens */
-       mutex_lock(&priv->shrd->mutex);
+       mutex_lock(&priv->mutex);
        switch (cmd) {
        case IWL_TM_CMD_APP2DEV_READ_TRACE:
                IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n");
@@ -1079,6 +1078,6 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
                break;
        }
 
-       mutex_unlock(&priv->shrd->mutex);
+       mutex_unlock(&priv->mutex);
        return result;
 }
index 8c30fea8c2b3e6fec241195b000172062c836543..d13b8d1f08fab99103a3138838a3fdfc8870ead7 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/skbuff.h>
+#include <linux/wait.h>
 #include <linux/pci.h>
 
 #include "iwl-fh.h"
@@ -40,6 +41,7 @@
 #include "iwl-trans.h"
 #include "iwl-debug.h"
 #include "iwl-io.h"
+#include "iwl-op-mode.h"
 
 struct iwl_tx_queue;
 struct iwl_queue;
@@ -48,6 +50,12 @@ struct iwl_host_cmd;
 /*This file includes the declaration that are internal to the
  * trans_pcie layer */
 
+struct iwl_rx_mem_buffer {
+       dma_addr_t page_dma;
+       struct page *page;
+       struct list_head list;
+};
+
 /**
  * struct isr_statistics - interrupt statistics
  *
@@ -108,6 +116,26 @@ struct iwl_dma_ptr {
        size_t size;
 };
 
+/**
+ * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
+ * @index -- current index
+ * @n_bd -- total number of entries in queue (must be power of 2)
+ */
+static inline int iwl_queue_inc_wrap(int index, int n_bd)
+{
+       return ++index & (n_bd - 1);
+}
+
+/**
+ * iwl_queue_dec_wrap - decrement queue index, wrap back to end
+ * @index -- current index
+ * @n_bd -- total number of entries in queue (must be power of 2)
+ */
+static inline int iwl_queue_dec_wrap(int index, int n_bd)
+{
+       return --index & (n_bd - 1);
+}
+
 /*
  * This queue number is required for proper operation
  * because the ucode will stop/start the scheduler as
@@ -168,6 +196,7 @@ struct iwl_queue {
  * @meta: array of meta data for each command/tx buffer
  * @dma_addr_cmd: physical address of cmd/tx buffer array
  * @txb: array of per-TFD driver data
+ * lock: queue lock
  * @time_stamp: time (in jiffies) of last read_ptr change
  * @need_update: indicates need to update read/write index
  * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
@@ -186,6 +215,7 @@ struct iwl_tx_queue {
        struct iwl_device_cmd **cmd;
        struct iwl_cmd_meta *meta;
        struct sk_buff **skbs;
+       spinlock_t lock;
        unsigned long time_stamp;
        u8 need_update;
        u8 sched_retry;
@@ -201,6 +231,7 @@ struct iwl_tx_queue {
  * @rxq: all the RX queue data
  * @rx_replenish: work that will be called when buffers need to be allocated
  * @trans: pointer to the generic transport area
+ * @irq - the irq number for the device
  * @irq_requested: true when the irq has been requested
  * @scd_base_addr: scheduler sram base address in SRAM
  * @scd_bc_tbls: pointer to the byte count table of the scheduler
@@ -214,6 +245,8 @@ struct iwl_tx_queue {
  * queue_stop_count: tracks what SW queue is stopped
  * @pci_dev: basic pci-network driver stuff
  * @hw_base: pci hardware address support
+ * @ucode_write_complete: indicates that the ucode has been copied.
+ * @ucode_write_waitq: wait queue for uCode load
  */
 struct iwl_trans_pcie {
        struct iwl_rx_queue rxq;
@@ -230,6 +263,7 @@ struct iwl_trans_pcie {
        struct tasklet_struct irq_tasklet;
        struct isr_statistics isr_stats;
 
+       unsigned int irq;
        spinlock_t irq_lock;
        u32 inta_mask;
        u32 scd_base_addr;
@@ -250,6 +284,9 @@ struct iwl_trans_pcie {
        /* PCI bus related data */
        struct pci_dev *pci_dev;
        void __iomem *hw_base;
+
+       bool ucode_write_complete;
+       wait_queue_head_t ucode_write_waitq;
 };
 
 #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \
@@ -284,7 +321,7 @@ int iwlagn_txq_attach_buf_to_tfd(struct iwl_trans *trans,
 int iwl_queue_init(struct iwl_queue *q, int count, int slots_num, u32 id);
 int iwl_trans_pcie_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd);
 void iwl_tx_cmd_complete(struct iwl_trans *trans,
-                        struct iwl_rx_mem_buffer *rxb, int handler_status);
+                        struct iwl_rx_cmd_buffer *rxb, int handler_status);
 void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_trans *trans,
                                           struct iwl_tx_queue *txq,
                                           u16 byte_cnt);
@@ -374,7 +411,7 @@ static inline void iwl_wake_queue(struct iwl_trans *trans,
 
        if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) {
                if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) {
-                       iwl_wake_sw_queue(priv(trans), ac);
+                       iwl_op_mode_queue_not_full(trans->op_mode, ac);
                        IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d. %s",
                                            hwq, ac, msg);
                } else {
@@ -397,7 +434,7 @@ static inline void iwl_stop_queue(struct iwl_trans *trans,
 
        if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) {
                if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) {
-                       iwl_stop_sw_queue(priv(trans), ac);
+                       iwl_op_mode_queue_full(trans->op_mode, ac);
                        IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d ac %d"
                                            " stop count %d. %s",
                                            hwq, ac, atomic_read(&trans_pcie->
index 6715d04b72f4409d5927bcfcf0fb104bb7476b45..83cc60e8f6077ec1f172a7744de8e2198cc4e2c3 100644 (file)
 #include <linux/wait.h>
 #include <linux/gfp.h>
 
-/*TODO: Remove include to iwl-core.h*/
-#include "iwl-core.h"
+#include "iwl-prph.h"
 #include "iwl-io.h"
 #include "iwl-trans-pcie-int.h"
-#include "iwl-wifi.h"
+#include "iwl-op-mode.h"
 
 #ifdef CONFIG_IWLWIFI_IDI
 #include "iwl-amfh.h"
@@ -141,7 +140,7 @@ void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans,
        if (q->need_update == 0)
                goto exit_unlock;
 
-       if (hw_params(trans).shadow_reg_enable) {
+       if (cfg(trans)->base_params->shadow_reg_enable) {
                /* shadow register enabled */
                /* Device expects a multiple of 8 */
                q->write_actual = (q->write & ~0x7);
@@ -357,6 +356,113 @@ void iwl_bg_rx_replenish(struct work_struct *data)
        iwlagn_rx_replenish(trans_pcie->trans);
 }
 
+static void iwl_rx_handle_rxbuf(struct iwl_trans *trans,
+                               struct iwl_rx_mem_buffer *rxb)
+{
+       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+       struct iwl_rx_queue *rxq = &trans_pcie->rxq;
+       struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue];
+       struct iwl_device_cmd *cmd;
+       unsigned long flags;
+       int len, err;
+       u16 sequence;
+       struct iwl_rx_cmd_buffer rxcb;
+       struct iwl_rx_packet *pkt;
+       bool reclaim;
+       int index, cmd_index;
+
+       if (WARN_ON(!rxb))
+               return;
+
+       dma_unmap_page(trans->dev, rxb->page_dma,
+                      PAGE_SIZE << hw_params(trans).rx_page_order,
+                      DMA_FROM_DEVICE);
+
+       rxcb._page = rxb->page;
+       pkt = rxb_addr(&rxcb);
+
+       IWL_DEBUG_RX(trans, "%s, 0x%02x\n",
+                    get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
+
+
+       len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
+       len += sizeof(u32); /* account for status word */
+       trace_iwlwifi_dev_rx(trans->dev, pkt, len);
+
+       /* Reclaim a command buffer only if this packet is a response
+        *   to a (driver-originated) command.
+        * If the packet (e.g. Rx frame) originated from uCode,
+        *   there is no command buffer to reclaim.
+        * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
+        *   but apparently a few don't get set; catch them here. */
+       reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
+                 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
+                 (pkt->hdr.cmd != REPLY_RX) &&
+                 (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) &&
+                 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
+                 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
+                 (pkt->hdr.cmd != REPLY_TX);
+
+       sequence = le16_to_cpu(pkt->hdr.sequence);
+       index = SEQ_TO_INDEX(sequence);
+       cmd_index = get_cmd_index(&txq->q, index);
+
+       if (reclaim)
+               cmd = txq->cmd[cmd_index];
+       else
+               cmd = NULL;
+
+       /* warn if this is cmd response / notification and the uCode
+        * didn't set the SEQ_RX_FRAME for a frame that is
+        * uCode-originated
+        * If you saw this code after the second half of 2012, then
+        * please remove it
+        */
+       WARN(pkt->hdr.cmd != REPLY_TX && reclaim == false &&
+            (!(pkt->hdr.sequence & SEQ_RX_FRAME)),
+            "reclaim is false, SEQ_RX_FRAME unset: %s\n",
+            get_cmd_string(pkt->hdr.cmd));
+
+       err = iwl_op_mode_rx(trans->op_mode, &rxcb, cmd);
+
+       /*
+        * XXX: After here, we should always check rxcb._page
+        * against NULL before touching it or its virtual
+        * memory (pkt). Because some rx_handler might have
+        * already taken or freed the pages.
+        */
+
+       if (reclaim) {
+               /* Invoke any callbacks, transfer the buffer to caller,
+                * and fire off the (possibly) blocking
+                * iwl_trans_send_cmd()
+                * as we reclaim the driver command queue */
+               if (rxcb._page)
+                       iwl_tx_cmd_complete(trans, &rxcb, err);
+               else
+                       IWL_WARN(trans, "Claim null rxb?\n");
+       }
+
+       /* page was stolen from us */
+       if (rxcb._page == NULL)
+               rxb->page = NULL;
+
+       /* Reuse the page if possible. For notification packets and
+        * SKBs that fail to Rx correctly, add them back into the
+        * rx_free list for reuse later. */
+       spin_lock_irqsave(&rxq->lock, flags);
+       if (rxb->page != NULL) {
+               rxb->page_dma =
+                       dma_map_page(trans->dev, rxb->page, 0,
+                               PAGE_SIZE << hw_params(trans).rx_page_order,
+                               DMA_FROM_DEVICE);
+               list_add_tail(&rxb->list, &rxq->rx_free);
+               rxq->free_count++;
+       } else
+               list_add_tail(&rxb->list, &rxq->rx_used);
+       spin_unlock_irqrestore(&rxq->lock, flags);
+}
+
 /**
  * iwl_rx_handle - Main entry function for receiving responses from uCode
  *
@@ -366,20 +472,12 @@ void iwl_bg_rx_replenish(struct work_struct *data)
  */
 static void iwl_rx_handle(struct iwl_trans *trans)
 {
-       struct iwl_rx_mem_buffer *rxb;
-       struct iwl_rx_packet *pkt;
-       struct iwl_trans_pcie *trans_pcie =
-               IWL_TRANS_GET_PCIE_TRANS(trans);
+       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        struct iwl_rx_queue *rxq = &trans_pcie->rxq;
-       struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue];
-       struct iwl_device_cmd *cmd;
        u32 r, i;
-       int reclaim;
-       unsigned long flags;
        u8 fill_rx = 0;
        u32 count = 8;
        int total_empty;
-       int index, cmd_index;
 
        /* uCode's read index (stored in shared DRAM) indicates the last Rx
         * buffer that the driver may process (last buffer filled by ucode). */
@@ -399,102 +497,14 @@ static void iwl_rx_handle(struct iwl_trans *trans)
                fill_rx = 1;
 
        while (i != r) {
-               int len, err;
-               u16 sequence;
+               struct iwl_rx_mem_buffer *rxb;
 
                rxb = rxq->queue[i];
-
-               /* If an RXB doesn't have a Rx queue slot associated with it,
-                * then a bug has been introduced in the queue refilling
-                * routines -- catch it here */
-               if (WARN_ON(rxb == NULL)) {
-                       i = (i + 1) & RX_QUEUE_MASK;
-                       continue;
-               }
-
                rxq->queue[i] = NULL;
 
-               dma_unmap_page(trans->dev, rxb->page_dma,
-                              PAGE_SIZE << hw_params(trans).rx_page_order,
-                              DMA_FROM_DEVICE);
-               pkt = rxb_addr(rxb);
-
-               IWL_DEBUG_RX(trans, "r = %d, i = %d, %s, 0x%02x\n", r,
-                       i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
-
-               len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
-               len += sizeof(u32); /* account for status word */
-               trace_iwlwifi_dev_rx(priv(trans), pkt, len);
-
-               /* Reclaim a command buffer only if this packet is a response
-                *   to a (driver-originated) command.
-                * If the packet (e.g. Rx frame) originated from uCode,
-                *   there is no command buffer to reclaim.
-                * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
-                *   but apparently a few don't get set; catch them here. */
-               reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
-                       (pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
-                       (pkt->hdr.cmd != REPLY_RX) &&
-                       (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) &&
-                       (pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
-                       (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
-                       (pkt->hdr.cmd != REPLY_TX);
-
-               sequence = le16_to_cpu(pkt->hdr.sequence);
-               index = SEQ_TO_INDEX(sequence);
-               cmd_index = get_cmd_index(&txq->q, index);
-
-               if (reclaim)
-                       cmd = txq->cmd[cmd_index];
-               else
-                       cmd = NULL;
-
-               /* warn if this is cmd response / notification and the uCode
-                * didn't set the SEQ_RX_FRAME for a frame that is
-                * uCode-originated
-                * If you saw this code after the second half of 2012, then
-                * please remove it
-                */
-               WARN(pkt->hdr.cmd != REPLY_TX && reclaim == false &&
-                    (!(pkt->hdr.sequence & SEQ_RX_FRAME)),
-                    "reclaim is false, SEQ_RX_FRAME unset: %s\n",
-                    get_cmd_string(pkt->hdr.cmd));
-
-               err = iwl_rx_dispatch(priv(trans), rxb, cmd);
+               IWL_DEBUG_RX(trans, "rxbuf: r = %d, i = %d (%p)\n", rxb);
 
-               /*
-                * XXX: After here, we should always check rxb->page
-                * against NULL before touching it or its virtual
-                * memory (pkt). Because some rx_handler might have
-                * already taken or freed the pages.
-                */
-
-               if (reclaim) {
-                       /* Invoke any callbacks, transfer the buffer to caller,
-                        * and fire off the (possibly) blocking
-                        * iwl_trans_send_cmd()
-                        * as we reclaim the driver command queue */
-                       if (rxb->page)
-                               iwl_tx_cmd_complete(trans, rxb, err);
-                       else
-                               IWL_WARN(trans, "Claim null rxb?\n");
-               }
-
-               /* Reuse the page if possible. For notification packets and
-                * SKBs that fail to Rx correctly, add them back into the
-                * rx_free list for reuse later. */
-               spin_lock_irqsave(&rxq->lock, flags);
-               if (rxb->page != NULL) {
-                       rxb->page_dma = dma_map_page(trans->dev, rxb->page,
-                               0, PAGE_SIZE <<
-                                   hw_params(trans).rx_page_order,
-                               DMA_FROM_DEVICE);
-                       list_add_tail(&rxb->list, &rxq->rx_free);
-                       rxq->free_count++;
-               } else
-                       list_add_tail(&rxb->list, &rxq->rx_used);
-
-               spin_unlock_irqrestore(&rxq->lock, flags);
+               iwl_rx_handle_rxbuf(trans, rxb);
 
                i = (i + 1) & RX_QUEUE_MASK;
                /* If there are a lot of unused frames,
@@ -590,17 +600,16 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans)
 {
        u32 base;
        struct iwl_error_event_table table;
-       struct iwl_nic *nic = nic(trans);
        struct iwl_trans_pcie *trans_pcie =
                IWL_TRANS_GET_PCIE_TRANS(trans);
 
        base = trans->shrd->device_pointers.error_event_table;
        if (trans->shrd->ucode_type == IWL_UCODE_INIT) {
                if (!base)
-                       base = nic->init_errlog_ptr;
+                       base = trans->shrd->fw->init_errlog_ptr;
        } else {
                if (!base)
-                       base = nic->inst_errlog_ptr;
+                       base = trans->shrd->fw->inst_errlog_ptr;
        }
 
        if (!iwlagn_hw_valid_rtc_data_addr(base)) {
@@ -622,7 +631,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans)
 
        trans_pcie->isr_stats.err_code = table.error_id;
 
-       trace_iwlwifi_dev_ucode_error(priv(nic), table.error_id, table.tsf_low,
+       trace_iwlwifi_dev_ucode_error(trans->dev, table.error_id, table.tsf_low,
                                      table.data1, table.data2, table.line,
                                      table.blink1, table.blink2, table.ilink1,
                                      table.ilink2, table.bcon_time, table.gp1,
@@ -670,9 +679,8 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans)
  */
 static void iwl_irq_handle_error(struct iwl_trans *trans)
 {
-       struct iwl_priv *priv = priv(trans);
        /* W/A for WiFi/WiMAX coex and WiMAX own the RF */
-       if (cfg(priv)->internal_wimax_coex &&
+       if (cfg(trans)->internal_wimax_coex &&
            (!(iwl_read_prph(trans, APMG_CLK_CTRL_REG) &
                        APMS_CLK_VAL_MRB_FUNC_MODE) ||
             (iwl_read_prph(trans, APMG_PS_CTRL_REG) &
@@ -683,24 +691,20 @@ static void iwl_irq_handle_error(struct iwl_trans *trans)
                 */
                clear_bit(STATUS_READY, &trans->shrd->status);
                clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status);
-               wake_up(&priv->shrd->wait_command_queue);
+               wake_up(&trans->shrd->wait_command_queue);
                IWL_ERR(trans, "RF is used by WiMAX\n");
                return;
        }
 
        IWL_ERR(trans, "Loaded firmware version: %s\n",
-               priv->hw->wiphy->fw_version);
+               trans->shrd->fw->fw_version);
 
        iwl_dump_nic_error_log(trans);
        iwl_dump_csr(trans);
        iwl_dump_fh(trans, NULL, false);
        iwl_dump_nic_event_log(trans, false, NULL, false);
-#ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_get_debug_level(trans->shrd) & IWL_DL_FW_ERRORS)
-               iwl_print_rx_config_cmd(priv(trans), IWL_RXON_CTX_BSS);
-#endif
 
-       iwlagn_fw_error(priv, false);
+       iwl_op_mode_nic_error(trans->op_mode);
 }
 
 #define EVENT_START_OFFSET  (4 * sizeof(u32))
@@ -719,7 +723,6 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx,
        u32 ptr;        /* SRAM byte address of log data */
        u32 ev, time, data; /* event log data */
        unsigned long reg_flags;
-       struct iwl_nic *nic = nic(trans);
 
        if (num_events == 0)
                return pos;
@@ -727,10 +730,10 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx,
        base = trans->shrd->device_pointers.log_event_table;
        if (trans->shrd->ucode_type == IWL_UCODE_INIT) {
                if (!base)
-                       base = nic->init_evtlog_ptr;
+                       base = trans->shrd->fw->init_evtlog_ptr;
        } else {
                if (!base)
-                       base = nic->inst_evtlog_ptr;
+                       base = trans->shrd->fw->inst_evtlog_ptr;
        }
 
        if (mode == 0)
@@ -760,7 +763,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx,
                                                "EVT_LOG:0x%08x:%04u\n",
                                                time, ev);
                        } else {
-                               trace_iwlwifi_dev_ucode_event(priv(trans), 0,
+                               trace_iwlwifi_dev_ucode_event(trans->dev, 0,
                                        time, ev);
                                IWL_ERR(trans, "EVT_LOG:0x%08x:%04u\n",
                                        time, ev);
@@ -774,7 +777,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx,
                        } else {
                                IWL_ERR(trans, "EVT_LOGT:%010u:0x%08x:%04u\n",
                                        time, data, ev);
-                               trace_iwlwifi_dev_ucode_event(priv(trans), time,
+                               trace_iwlwifi_dev_ucode_event(trans->dev, time,
                                        data, ev);
                        }
                }
@@ -836,17 +839,16 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log,
        u32 logsize;
        int pos = 0;
        size_t bufsz = 0;
-       struct iwl_nic *nic = nic(trans);
 
        base = trans->shrd->device_pointers.log_event_table;
        if (trans->shrd->ucode_type == IWL_UCODE_INIT) {
-               logsize = nic->init_evtlog_size;
+               logsize = trans->shrd->fw->init_evtlog_size;
                if (!base)
-                       base = nic->init_evtlog_ptr;
+                       base = trans->shrd->fw->init_evtlog_ptr;
        } else {
-               logsize = nic->inst_evtlog_size;
+               logsize = trans->shrd->fw->inst_evtlog_size;
                if (!base)
-                       base = nic->inst_evtlog_ptr;
+                       base = trans->shrd->fw->inst_evtlog_ptr;
        }
 
        if (!iwlagn_hw_valid_rtc_data_addr(base)) {
@@ -885,7 +887,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log,
        }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (!(iwl_get_debug_level(trans->shrd) & IWL_DL_FW_ERRORS) && !full_log)
+       if (!(iwl_have_debug_level(IWL_DL_FW_ERRORS)) && !full_log)
                size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
                        ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
 #else
@@ -905,7 +907,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log,
                if (!*buf)
                        return -ENOMEM;
        }
-       if ((iwl_get_debug_level(trans->shrd) & IWL_DL_FW_ERRORS) || full_log) {
+       if (iwl_have_debug_level(IWL_DL_FW_ERRORS) || full_log) {
                /*
                 * if uCode has wrapped back to top of log,
                 * start at the oldest entry,
@@ -964,7 +966,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
        inta = trans_pcie->inta;
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_get_debug_level(trans->shrd) & IWL_DL_ISR) {
+       if (iwl_have_debug_level(IWL_DL_ISR)) {
                /* just for debug */
                inta_mask = iwl_read32(trans, CSR_INT_MASK);
                IWL_DEBUG_ISR(trans, "inta 0x%08x, enabled 0x%08x\n ",
@@ -993,7 +995,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
        }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_get_debug_level(trans->shrd) & (IWL_DL_ISR)) {
+       if (iwl_have_debug_level(IWL_DL_ISR)) {
                /* NIC fires this, but we don't use it, redundant with WAKEUP */
                if (inta & CSR_INT_BIT_SCD) {
                        IWL_DEBUG_ISR(trans, "Scheduler finished to transmit "
@@ -1013,30 +1015,16 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
 
        /* HW RF KILL switch toggled */
        if (inta & CSR_INT_BIT_RF_KILL) {
-               int hw_rf_kill = 0;
-               if (!(iwl_read32(trans, CSR_GP_CNTRL) &
-                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
-                       hw_rf_kill = 1;
+               bool hw_rfkill;
 
+               hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) &
+                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
                IWL_WARN(trans, "RF_KILL bit toggled to %s.\n",
-                               hw_rf_kill ? "disable radio" : "enable radio");
+                               hw_rfkill ? "disable radio" : "enable radio");
 
                isr_stats->rfkill++;
 
-               /* driver only loads ucode once setting the interface up.
-                * the driver allows loading the ucode even if the radio
-                * is killed. Hence update the killswitch state here. The
-                * rfkill handler will care about restarting if needed.
-                */
-               if (!test_bit(STATUS_ALIVE, &trans->shrd->status)) {
-                       if (hw_rf_kill)
-                               set_bit(STATUS_RF_KILL_HW,
-                                       &trans->shrd->status);
-                       else
-                               clear_bit(STATUS_RF_KILL_HW,
-                                         &trans->shrd->status);
-                       iwl_set_hw_rfkill_state(priv(trans), hw_rf_kill);
-               }
+               iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
 
                handled |= CSR_INT_BIT_RF_KILL;
        }
@@ -1126,8 +1114,8 @@ void iwl_irq_tasklet(struct iwl_trans *trans)
                isr_stats->tx++;
                handled |= CSR_INT_BIT_FH_TX;
                /* Wake up uCode load routine, now that load is complete */
-               trans->ucode_write_complete = 1;
-               wake_up(&trans->shrd->wait_command_queue);
+               trans_pcie->ucode_write_complete = true;
+               wake_up(&trans_pcie->ucode_write_waitq);
        }
 
        if (inta & ~handled) {
@@ -1273,7 +1261,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
        if (!trans)
                return IRQ_NONE;
 
-       trace_iwlwifi_dev_irq(priv(trans));
+       trace_iwlwifi_dev_irq(trans->dev);
 
        trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 
@@ -1305,7 +1293,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
        }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_get_debug_level(trans->shrd) & (IWL_DL_ISR)) {
+       if (iwl_have_debug_level(IWL_DL_ISR)) {
                inta_fh = iwl_read32(trans, CSR_FH_INT_STATUS);
                IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled 0x%08x, "
                              "fh 0x%08x\n", inta, inta_mask, inta_fh);
@@ -1363,7 +1351,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data)
        if (!trans_pcie->use_ict)
                return iwl_isr(irq, data);
 
-       trace_iwlwifi_dev_irq(priv(trans));
+       trace_iwlwifi_dev_irq(trans->dev);
 
        spin_lock_irqsave(&trans_pcie->irq_lock, flags);
 
@@ -1380,7 +1368,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data)
         * This may be due to IRQ shared with another device,
         * or due to sporadic interrupts thrown from our NIC. */
        read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]);
-       trace_iwlwifi_dev_ict_read(priv(trans), trans_pcie->ict_index, read);
+       trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index, read);
        if (!read) {
                IWL_DEBUG_ISR(trans, "Ignore interrupt, inta == 0\n");
                goto none;
@@ -1399,7 +1387,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data)
                        iwl_queue_inc_wrap(trans_pcie->ict_index, ICT_COUNT);
 
                read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]);
-               trace_iwlwifi_dev_ict_read(priv(trans), trans_pcie->ict_index,
+               trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index,
                                           read);
        } while (read);
 
index a3cebd76dc0cd6bd41db5ab4deb7d981a39d8a3b..73febc9726cbf4fc2cbae51b9d13911be7592c29 100644 (file)
 #include "iwl-prph.h"
 #include "iwl-io.h"
 #include "iwl-agn-hw.h"
+#include "iwl-op-mode.h"
 #include "iwl-trans-pcie-int.h"
 
 #define IWL_TX_CRC_SIZE 4
 #define IWL_TX_DELIMITER_SIZE 4
 
+/*
+ * mac80211 queues, ACs, hardware queues, FIFOs.
+ *
+ * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues
+ *
+ * Mac80211 uses the following numbers, which we get as from it
+ * by way of skb_get_queue_mapping(skb):
+ *
+ *     VO      0
+ *     VI      1
+ *     BE      2
+ *     BK      3
+ *
+ *
+ * Regular (not A-MPDU) frames are put into hardware queues corresponding
+ * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their
+ * own queue per aggregation session (RA/TID combination), such queues are
+ * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In
+ * order to map frames to the right queue, we also need an AC->hw queue
+ * mapping. This is implemented here.
+ *
+ * Due to the way hw queues are set up (by the hw specific code), the AC->hw
+ * queue mapping is the identity mapping.
+ */
+
+static const u8 tid_to_ac[] = {
+       IEEE80211_AC_BE,
+       IEEE80211_AC_BK,
+       IEEE80211_AC_BK,
+       IEEE80211_AC_BE,
+       IEEE80211_AC_VI,
+       IEEE80211_AC_VI,
+       IEEE80211_AC_VO,
+       IEEE80211_AC_VO
+};
+
+
 /**
  * iwl_trans_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
  */
@@ -98,7 +136,7 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, struct iwl_tx_queue *txq)
        if (txq->need_update == 0)
                return;
 
-       if (hw_params(trans).shadow_reg_enable) {
+       if (cfg(trans)->base_params->shadow_reg_enable) {
                /* shadow register enabled */
                iwl_write32(trans, HBUS_TARG_WRPTR,
                            txq->q.write_ptr | (txq_id << 8));
@@ -216,6 +254,8 @@ void iwlagn_txq_free_tfd(struct iwl_trans *trans, struct iwl_tx_queue *txq,
 {
        struct iwl_tfd *tfd_tmp = txq->tfds;
 
+       lockdep_assert_held(&txq->lock);
+
        iwlagn_unmap_tfd(trans, &txq->meta[index], &tfd_tmp[index], dma_dir);
 
        /* free SKB */
@@ -229,7 +269,7 @@ void iwlagn_txq_free_tfd(struct iwl_trans *trans, struct iwl_tx_queue *txq,
                 * freed and that the queue is not empty - free the skb
                 */
                if (skb) {
-                       iwl_free_skb(priv(trans), skb);
+                       iwl_op_mode_free_skb(trans->op_mode, skb);
                        txq->skbs[index] = NULL;
                }
        }
@@ -439,6 +479,15 @@ void iwl_trans_tx_queue_set_status(struct iwl_trans *trans,
                        scd_retry ? "BA" : "AC/CMD", txq_id);
 }
 
+static inline int get_ac_from_tid(u16 tid)
+{
+       if (likely(tid < ARRAY_SIZE(tid_to_ac)))
+               return tid_to_ac[tid];
+
+       /* no support for TIDs 8-15 yet */
+       return -EINVAL;
+}
+
 static inline int get_fifo_from_tid(struct iwl_trans_pcie *trans_pcie,
                                    u8 ctx, u16 tid)
 {
@@ -620,10 +669,8 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
        struct iwl_device_cmd *out_cmd;
        struct iwl_cmd_meta *out_meta;
        dma_addr_t phys_addr;
-       unsigned long flags;
        u32 idx;
        u16 copy_size, cmd_size;
-       bool is_ct_kill = false;
        bool had_nocopy = false;
        int i;
        u8 *cmd_dest;
@@ -638,12 +685,6 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
                return -EIO;
        }
 
-       if ((trans->shrd->ucode_owner == IWL_OWNERSHIP_TM) &&
-           !(cmd->flags & CMD_ON_DEMAND)) {
-               IWL_DEBUG_HC(trans, "tm own the uCode, no regular hcmd send\n");
-               return -EIO;
-       }
-
        copy_size = sizeof(out_cmd->hdr);
        cmd_size = sizeof(out_cmd->hdr);
 
@@ -673,23 +714,13 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
        if (WARN_ON(copy_size > TFD_MAX_PAYLOAD_SIZE))
                return -EINVAL;
 
-       if (iwl_is_rfkill(trans->shrd) || iwl_is_ctkill(trans->shrd)) {
-               IWL_WARN(trans, "Not sending command - %s KILL\n",
-                        iwl_is_rfkill(trans->shrd) ? "RF" : "CT");
-               return -EIO;
-       }
-
-       spin_lock_irqsave(&trans->hcmd_lock, flags);
+       spin_lock_bh(&txq->lock);
 
        if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
-               spin_unlock_irqrestore(&trans->hcmd_lock, flags);
+               spin_unlock_bh(&txq->lock);
 
                IWL_ERR(trans, "No space in command queue\n");
-               is_ct_kill = iwl_check_for_ct_kill(priv(trans));
-               if (!is_ct_kill) {
-                       IWL_ERR(trans, "Restarting adapter queue is full\n");
-                       iwlagn_fw_error(priv(trans), false);
-               }
+               iwl_op_mode_cmd_queue_full(trans->op_mode);
                return -ENOSPC;
        }
 
@@ -778,7 +809,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
        /* check that tracing gets all possible blocks */
        BUILD_BUG_ON(IWL_MAX_CMD_TFDS + 1 != 3);
 #ifdef CONFIG_IWLWIFI_DEVICE_TRACING
-       trace_iwlwifi_dev_hcmd(priv(trans), cmd->flags,
+       trace_iwlwifi_dev_hcmd(trans->dev, cmd->flags,
                               trace_bufs[0], trace_lens[0],
                               trace_bufs[1], trace_lens[1],
                               trace_bufs[2], trace_lens[2]);
@@ -789,7 +820,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
        iwl_txq_update_write_ptr(trans, txq);
 
  out:
-       spin_unlock_irqrestore(&trans->hcmd_lock, flags);
+       spin_unlock_bh(&txq->lock);
        return idx;
 }
 
@@ -808,6 +839,8 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id,
        struct iwl_queue *q = &txq->q;
        int nfreed = 0;
 
+       lockdep_assert_held(&txq->lock);
+
        if ((idx >= q->n_bd) || (iwl_queue_used(q, idx) == 0)) {
                IWL_ERR(trans, "%s: Read index for DMA queue txq id (%d), "
                          "index %d is out of range [0-%d] %d %d.\n", __func__,
@@ -821,7 +854,7 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id,
                if (nfreed++ > 0) {
                        IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n", idx,
                                        q->write_ptr, q->read_ptr);
-                       iwlagn_fw_error(priv(trans), false);
+                       iwl_op_mode_nic_error(trans->op_mode);
                }
 
        }
@@ -837,7 +870,7 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id,
  * will be executed.  The attached skb (if present) will only be freed
  * if the callback returns 1
  */
-void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb,
+void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb,
                         int handler_status)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
@@ -849,7 +882,6 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb,
        struct iwl_cmd_meta *meta;
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue];
-       unsigned long flags;
 
        /* If a Tx command is being handled and it isn't in the actual
         * command queue then there a command routing bug has been introduced
@@ -863,6 +895,8 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb,
                return;
        }
 
+       spin_lock(&txq->lock);
+
        cmd_index = get_cmd_index(&txq->q, index);
        cmd = txq->cmd[cmd_index];
        meta = &txq->meta[cmd_index];
@@ -874,13 +908,14 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb,
 
        /* Input error checking is done when commands are added to queue. */
        if (meta->flags & CMD_WANT_SKB) {
-               meta->source->reply_page = (unsigned long)rxb_addr(rxb);
+               struct page *p = rxb_steal_page(rxb);
+
+               meta->source->resp_pkt = pkt;
+               meta->source->_rx_page_addr = (unsigned long)page_address(p);
+               meta->source->_rx_page_order = hw_params(trans).rx_page_order;
                meta->source->handler_status = handler_status;
-               rxb->page = NULL;
        }
 
-       spin_lock_irqsave(&trans->hcmd_lock, flags);
-
        iwl_hcmd_queue_reclaim(trans, txq_id, index);
 
        if (!(meta->flags & CMD_ASYNC)) {
@@ -897,7 +932,7 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb,
 
        meta->flags = 0;
 
-       spin_unlock_irqrestore(&trans->hcmd_lock, flags);
+       spin_unlock(&txq->lock);
 }
 
 #define HOST_COMPLETE_TIMEOUT (2 * HZ)
@@ -911,12 +946,9 @@ static int iwl_send_cmd_async(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
                return -EINVAL;
 
 
-       if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status))
-               return -EBUSY;
-
        ret = iwl_enqueue_hcmd(trans, cmd);
        if (ret < 0) {
-               IWL_DEBUG_QUIET_RFKILL(trans,
+               IWL_ERR(trans,
                        "Error sending %s: enqueue_hcmd failed: %d\n",
                          get_cmd_string(cmd->id), ret);
                return ret;
@@ -930,26 +962,22 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
        int cmd_idx;
        int ret;
 
-       lockdep_assert_held(&trans->shrd->mutex);
-
        IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n",
                        get_cmd_string(cmd->id));
 
-       if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status))
-               return -EBUSY;
-
-
-       if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) {
-               IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n",
-                              get_cmd_string(cmd->id));
-               return -ECANCELED;
-       }
        if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) {
                IWL_ERR(trans, "Command %s failed: FW Error\n",
                               get_cmd_string(cmd->id));
                return -EIO;
        }
-       set_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status);
+
+       if (WARN_ON(test_and_set_bit(STATUS_HCMD_ACTIVE,
+                                    &trans->shrd->status))) {
+               IWL_ERR(trans, "Command %s: a command is already active!\n",
+                       get_cmd_string(cmd->id));
+               return -EIO;
+       }
+
        IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n",
                        get_cmd_string(cmd->id));
 
@@ -957,7 +985,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
        if (cmd_idx < 0) {
                ret = cmd_idx;
                clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status);
-               IWL_DEBUG_QUIET_RFKILL(trans,
+               IWL_ERR(trans,
                        "Error sending %s: enqueue_hcmd failed: %d\n",
                          get_cmd_string(cmd->id), ret);
                return ret;
@@ -972,12 +1000,12 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
                                &trans_pcie->txq[trans->shrd->cmd_queue];
                        struct iwl_queue *q = &txq->q;
 
-                       IWL_DEBUG_QUIET_RFKILL(trans,
+                       IWL_ERR(trans,
                                "Error sending %s: time out after %dms.\n",
                                get_cmd_string(cmd->id),
                                jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
 
-                       IWL_DEBUG_QUIET_RFKILL(trans,
+                       IWL_ERR(trans,
                                "Current CMD queue read_ptr %d write_ptr %d\n",
                                q->read_ptr, q->write_ptr);
 
@@ -989,7 +1017,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
                }
        }
 
-       if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) {
+       if ((cmd->flags & CMD_WANT_SKB) && !cmd->resp_pkt) {
                IWL_ERR(trans, "Error: Response NULL in '%s'\n",
                          get_cmd_string(cmd->id));
                ret = -EIO;
@@ -1010,9 +1038,9 @@ cancel:
                                                        ~CMD_WANT_SKB;
        }
 
-       if (cmd->reply_page) {
-               iwl_free_pages(trans->shrd, cmd->reply_page);
-               cmd->reply_page = 0;
+       if (cmd->resp_pkt) {
+               iwl_free_resp(cmd);
+               cmd->resp_pkt = NULL;
        }
 
        return ret;
@@ -1040,6 +1068,8 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index,
        if (WARN_ON(txq_id == trans->shrd->cmd_queue))
                return 0;
 
+       lockdep_assert_held(&txq->lock);
+
        /*Since we free until index _not_ inclusive, the one before index is
         * the last we will free. This one must be used */
        last_to_free = iwl_queue_dec_wrap(index, q->n_bd);
index 176063c4f78165b40c098adb0ca86cf9d78de888..26bb44242090b025f1d9c238ee503780468f712e 100644 (file)
@@ -75,7 +75,8 @@
 #include "iwl-shared.h"
 #include "iwl-eeprom.h"
 #include "iwl-agn-hw.h"
-#include "iwl-core.h"
+
+#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
 
 static int iwl_trans_rx_alloc(struct iwl_trans *trans)
 {
@@ -389,6 +390,8 @@ static int iwl_trans_txq_init(struct iwl_trans *trans, struct iwl_tx_queue *txq,
        if (ret)
                return ret;
 
+       spin_lock_init(&txq->lock);
+
        /*
         * Tell nic where to find circular buffer of Tx Frame Descriptors for
         * given Tx queue, and enable the DMA channel used for that queue.
@@ -408,8 +411,6 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id)
        struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id];
        struct iwl_queue *q = &txq->q;
        enum dma_data_direction dma_dir;
-       unsigned long flags;
-       spinlock_t *lock;
 
        if (!q->n_bd)
                return;
@@ -417,22 +418,19 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id)
        /* In the command queue, all the TBs are mapped as BIDI
         * so unmap them as such.
         */
-       if (txq_id == trans->shrd->cmd_queue) {
+       if (txq_id == trans->shrd->cmd_queue)
                dma_dir = DMA_BIDIRECTIONAL;
-               lock = &trans->hcmd_lock;
-       } else {
+       else
                dma_dir = DMA_TO_DEVICE;
-               lock = &trans->shrd->sta_lock;
-       }
 
-       spin_lock_irqsave(lock, flags);
+       spin_lock_bh(&txq->lock);
        while (q->write_ptr != q->read_ptr) {
                /* The read_ptr needs to bound by q->n_window */
                iwlagn_txq_free_tfd(trans, txq, get_cmd_index(q, q->read_ptr),
                                    dma_dir);
                q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
        }
-       spin_unlock_irqrestore(lock, flags);
+       spin_unlock_bh(&txq->lock);
 }
 
 /**
@@ -818,7 +816,7 @@ static int iwl_nic_init(struct iwl_trans *trans)
 
        iwl_set_pwr_vmain(trans);
 
-       iwl_nic_config(priv(trans));
+       iwl_op_mode_nic_config(trans->op_mode);
 
 #ifndef CONFIG_IWLWIFI_IDI
        /* Allocate the RX queue, or reset if it is already allocated */
@@ -829,7 +827,7 @@ static int iwl_nic_init(struct iwl_trans *trans)
        if (iwl_tx_init(trans))
                return -ENOMEM;
 
-       if (hw_params(trans).shadow_reg_enable) {
+       if (cfg(trans)->base_params->shadow_reg_enable) {
                /* enable shadow regs in HW */
                iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL,
                        0x800FFFFF);
@@ -947,13 +945,14 @@ static const u8 iwlagn_pan_ac_to_queue[] = {
  * ucode
  */
 static int iwl_load_section(struct iwl_trans *trans, const char *name,
-                               struct fw_desc *image, u32 dst_addr)
+                           const struct fw_desc *image, u32 dst_addr)
 {
+       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        dma_addr_t phy_addr = image->p_addr;
        u32 byte_cnt = image->len;
        int ret;
 
-       trans->ucode_write_complete = 0;
+       trans_pcie->ucode_write_complete = false;
 
        iwl_write_direct32(trans,
                FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
@@ -984,8 +983,8 @@ static int iwl_load_section(struct iwl_trans *trans, const char *name,
                FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
 
        IWL_DEBUG_FW(trans, "%s uCode section being loaded...\n", name);
-       ret = wait_event_timeout(trans->shrd->wait_command_queue,
-                                trans->ucode_write_complete, 5 * HZ);
+       ret = wait_event_timeout(trans_pcie->ucode_write_waitq,
+                                trans_pcie->ucode_write_complete, 5 * HZ);
        if (!ret) {
                IWL_ERR(trans, "Could not load the %s uCode section\n",
                        name);
@@ -995,7 +994,8 @@ static int iwl_load_section(struct iwl_trans *trans, const char *name,
        return 0;
 }
 
-static int iwl_load_given_ucode(struct iwl_trans *trans, struct fw_img *image)
+static int iwl_load_given_ucode(struct iwl_trans *trans,
+                               const struct fw_img *image)
 {
        int ret = 0;
 
@@ -1015,13 +1015,14 @@ static int iwl_load_given_ucode(struct iwl_trans *trans, struct fw_img *image)
        return 0;
 }
 
-static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw)
+static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
+                                  const struct fw_img *fw)
 {
        int ret;
        struct iwl_trans_pcie *trans_pcie =
                IWL_TRANS_GET_PCIE_TRANS(trans);
+       bool hw_rfkill;
 
-       trans->shrd->ucode_owner = IWL_OWNERSHIP_DRIVER;
        trans_pcie->ac_to_queue[IWL_RXON_CTX_BSS] = iwlagn_bss_ac_to_queue;
        trans_pcie->ac_to_queue[IWL_RXON_CTX_PAN] = iwlagn_pan_ac_to_queue;
 
@@ -1031,21 +1032,18 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw)
        trans_pcie->mcast_queue[IWL_RXON_CTX_BSS] = 0;
        trans_pcie->mcast_queue[IWL_RXON_CTX_PAN] = IWL_IPAN_MCAST_QUEUE;
 
-       if ((hw_params(trans).sku & EEPROM_SKU_CAP_AMT_ENABLE) &&
-            iwl_prepare_card_hw(trans)) {
+       /* This may fail if AMT took ownership of the device */
+       if (iwl_prepare_card_hw(trans)) {
                IWL_WARN(trans, "Exit HW not ready\n");
                return -EIO;
        }
 
        /* If platform's RF_KILL switch is NOT set to KILL */
-       if (iwl_read32(trans, CSR_GP_CNTRL) &
-                       CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
-               clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status);
-       else
-               set_bit(STATUS_RF_KILL_HW, &trans->shrd->status);
+       hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) &
+                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
+       iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
 
-       if (iwl_is_rfkill(trans->shrd)) {
-               iwl_set_hw_rfkill_state(priv(trans), true);
+       if (hw_rfkill) {
                iwl_enable_interrupts(trans);
                return -ERFKILL;
        }
@@ -1296,7 +1294,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
        spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
 
        /* wait to make sure we flush pending tasklet*/
-       synchronize_irq(trans->irq);
+       synchronize_irq(trans_pcie->irq);
        tasklet_kill(&trans_pcie->irq_tasklet);
 
        cancel_work_sync(&trans_pcie->rx_replenish);
@@ -1305,6 +1303,17 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
        iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
 }
 
+static void iwl_trans_pcie_wowlan_suspend(struct iwl_trans *trans)
+{
+       /* let the ucode operate on its own */
+       iwl_write32(trans, CSR_UCODE_DRV_GP1_SET,
+                   CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
+
+       iwl_disable_interrupts(trans);
+       iwl_clear_bit(trans, CSR_GP_CNTRL,
+                     CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
+}
+
 static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
                struct iwl_device_cmd *dev_cmd, enum iwl_rxon_context_id ctx,
                u8 sta_id, u8 tid)
@@ -1357,6 +1366,8 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
        txq = &trans_pcie->txq[txq_id];
        q = &txq->q;
 
+       spin_lock(&txq->lock);
+
        /* In AGG mode, the index in the ring must correspond to the WiFi
         * sequence number. This is a HW requirements to help the SCD to parse
         * the BA.
@@ -1403,7 +1414,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
                                    &dev_cmd->hdr, firstlen,
                                    DMA_BIDIRECTIONAL);
        if (unlikely(dma_mapping_error(trans->dev, txcmd_phys)))
-               return -1;
+               goto out_err;
        dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
        dma_unmap_len_set(out_meta, len, firstlen);
 
@@ -1425,7 +1436,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
                                         dma_unmap_addr(out_meta, mapping),
                                         dma_unmap_len(out_meta, len),
                                         DMA_BIDIRECTIONAL);
-                       return -1;
+                       goto out_err;
                }
        }
 
@@ -1456,7 +1467,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
        dma_sync_single_for_device(trans->dev, txcmd_phys, firstlen,
                        DMA_BIDIRECTIONAL);
 
-       trace_iwlwifi_dev_tx(priv(trans),
+       trace_iwlwifi_dev_tx(trans->dev,
                             &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],
                             sizeof(struct iwl_tfd),
                             &dev_cmd->hdr, firstlen,
@@ -1480,7 +1491,11 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
                        iwl_stop_queue(trans, txq, "Queue is full");
                }
        }
+       spin_unlock(&txq->lock);
        return 0;
+ out_err:
+       spin_unlock(&txq->lock);
+       return -1;
 }
 
 static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
@@ -1488,6 +1503,7 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
        struct iwl_trans_pcie *trans_pcie =
                IWL_TRANS_GET_PCIE_TRANS(trans);
        int err;
+       bool hw_rfkill;
 
        trans_pcie->inta_mask = CSR_INI_SET_MASK;
 
@@ -1497,11 +1513,11 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
 
                iwl_alloc_isr_ict(trans);
 
-               err = request_irq(trans->irq, iwl_isr_ict, IRQF_SHARED,
+               err = request_irq(trans_pcie->irq, iwl_isr_ict, IRQF_SHARED,
                        DRV_NAME, trans);
                if (err) {
                        IWL_ERR(trans, "Error allocating IRQ %d\n",
-                               trans->irq);
+                               trans_pcie->irq);
                        goto error;
                }
 
@@ -1517,21 +1533,14 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
 
        iwl_apm_init(trans);
 
-       /* If platform's RF_KILL switch is NOT set to KILL */
-       if (iwl_read32(trans,
-                       CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
-               clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status);
-       else
-               set_bit(STATUS_RF_KILL_HW, &trans->shrd->status);
-
-       iwl_set_hw_rfkill_state(priv(trans),
-                               test_bit(STATUS_RF_KILL_HW,
-                                        &trans->shrd->status));
+       hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) &
+                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
+       iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
 
        return err;
 
 err_free_irq:
-       free_irq(trans->irq, trans);
+       free_irq(trans_pcie->irq, trans);
 error:
        iwl_free_isr_ict(trans);
        tasklet_kill(&trans_pcie->irq_tasklet);
@@ -1559,6 +1568,8 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid,
        int tfd_num = ssn & (txq->q.n_bd - 1);
        int freed = 0;
 
+       spin_lock(&txq->lock);
+
        txq->time_stamp = jiffies;
 
        if (unlikely(txq_id >= IWLAGN_FIRST_AMPDU_QUEUE &&
@@ -1573,6 +1584,7 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid,
                IWL_DEBUG_TX_QUEUES(trans, "Bad queue mapping txq_id %d, "
                        "agg_txq[sta_id[tid] %d", txq_id,
                        trans_pcie->agg_txq[sta_id][tid]);
+               spin_unlock(&txq->lock);
                return 1;
        }
 
@@ -1586,6 +1598,8 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid,
                   status != TX_STATUS_FAIL_PASSIVE_NO_RX))
                        iwl_wake_queue(trans, txq, "Packets reclaimed");
        }
+
+       spin_unlock(&txq->lock);
        return 0;
 }
 
@@ -1610,13 +1624,12 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans)
        struct iwl_trans_pcie *trans_pcie =
                IWL_TRANS_GET_PCIE_TRANS(trans);
 
-       iwl_calib_free_results(trans);
        iwl_trans_pcie_tx_free(trans);
 #ifndef CONFIG_IWLWIFI_IDI
        iwl_trans_pcie_rx_free(trans);
 #endif
        if (trans_pcie->irq_requested == true) {
-               free_irq(trans->irq, trans);
+               free_irq(trans_pcie->irq, trans);
                iwl_free_isr_ict(trans);
        }
 
@@ -1632,44 +1645,18 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans)
 #ifdef CONFIG_PM_SLEEP
 static int iwl_trans_pcie_suspend(struct iwl_trans *trans)
 {
-       /*
-        * This function is called when system goes into suspend state
-        * mac80211 will call iwlagn_mac_stop() from the mac80211 suspend
-        * function first but since iwlagn_mac_stop() has no knowledge of
-        * who the caller is,
-        * it will not call apm_ops.stop() to stop the DMA operation.
-        * Calling apm_ops.stop here to make sure we stop the DMA.
-        *
-        * But of course ... if we have configured WoWLAN then we did other
-        * things already :-)
-        */
-       if (!trans->shrd->wowlan) {
-               iwl_apm_stop(trans);
-       } else {
-               iwl_disable_interrupts(trans);
-               iwl_clear_bit(trans, CSR_GP_CNTRL,
-                             CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
-       }
-
        return 0;
 }
 
 static int iwl_trans_pcie_resume(struct iwl_trans *trans)
 {
-       bool hw_rfkill = false;
+       bool hw_rfkill;
 
        iwl_enable_interrupts(trans);
 
-       if (!(iwl_read32(trans, CSR_GP_CNTRL) &
-                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
-               hw_rfkill = true;
-
-       if (hw_rfkill)
-               set_bit(STATUS_RF_KILL_HW, &trans->shrd->status);
-       else
-               clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status);
-
-       iwl_set_hw_rfkill_state(priv(trans), hw_rfkill);
+       hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) &
+                               CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
+       iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
 
        return 0;
 }
@@ -2218,6 +2205,8 @@ const struct iwl_trans_ops trans_ops_pcie = {
        .start_fw = iwl_trans_pcie_start_fw,
        .stop_device = iwl_trans_pcie_stop_device,
 
+       .wowlan_suspend = iwl_trans_pcie_wowlan_suspend,
+
        .wake_any_queue = iwl_trans_pcie_wake_any_queue,
 
        .send_cmd = iwl_trans_pcie_send_cmd,
@@ -2266,8 +2255,8 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
        trans->ops = &trans_ops_pcie;
        trans->shrd = shrd;
        trans_pcie->trans = trans;
-       spin_lock_init(&trans->hcmd_lock);
        spin_lock_init(&trans_pcie->irq_lock);
+       init_waitqueue_head(&trans_pcie->ucode_write_waitq);
 
        /* W/A - seems to solve weird behavior. We need to remove this if we
         * don't want to stay in L1 all the time. This wastes a lot of power */
@@ -2329,7 +2318,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
                        "pci_enable_msi failed(0X%x)", err);
 
        trans->dev = &pdev->dev;
-       trans->irq = pdev->irq;
+       trans_pcie->irq = pdev->irq;
        trans_pcie->pci_dev = pdev;
        trans->hw_rev = iwl_read32(trans, CSR_HW_REV);
        trans->hw_id = (pdev->device << 16) + pdev->subsystem_device;
index cc7a3cfb5f24386aa86ef53097e1364db4311d2b..15bb208ab347d22f11b8519c24e785eab637ab6d 100644 (file)
 #ifndef __iwl_trans_h__
 #define __iwl_trans_h__
 
-#include <linux/debugfs.h>
-#include <linux/skbuff.h>
+#include <linux/ieee80211.h>
+#include <linux/mm.h> /* for page_address */
 
 #include "iwl-shared.h"
-#include "iwl-commands.h"
-#include "iwl-ucode.h"
 #include "iwl-debug.h"
 
 /**
  *     6) Eventually, the free function will be called.
  */
 
-/**
- * DOC: API needed by the transport layer from the op_mode
- *
- * TODO
- */
-
 struct iwl_priv;
 struct iwl_shared;
+struct iwl_op_mode;
+struct fw_img;
+struct sk_buff;
+struct dentry;
 
 /**
  * DOC: Host command section
@@ -126,6 +122,62 @@ struct iwl_shared;
 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
+#define SEQ_TO_QUEUE(s)        (((s) >> 8) & 0x1f)
+#define QUEUE_TO_SEQ(q)        (((q) & 0x1f) << 8)
+#define SEQ_TO_INDEX(s)        ((s) & 0xff)
+#define INDEX_TO_SEQ(i)        ((i) & 0xff)
+#define SEQ_RX_FRAME   cpu_to_le16(0x8000)
+
+/**
+ * struct iwl_cmd_header
+ *
+ * This header format appears in the beginning of each command sent from the
+ * driver, and each response/notification received from uCode.
+ */
+struct iwl_cmd_header {
+       u8 cmd;         /* Command ID:  REPLY_RXON, etc. */
+       u8 flags;       /* 0:5 reserved, 6 abort, 7 internal */
+       /*
+        * The driver sets up the sequence number to values of its choosing.
+        * uCode does not use this value, but passes it back to the driver
+        * when sending the response to each driver-originated command, so
+        * the driver can match the response to the command.  Since the values
+        * don't get used by uCode, the driver may set up an arbitrary format.
+        *
+        * There is one exception:  uCode sets bit 15 when it originates
+        * the response/notification, i.e. when the response/notification
+        * is not a direct response to a command sent by the driver.  For
+        * example, uCode issues REPLY_RX when it sends a received frame
+        * to the driver; it is not a direct response to any driver command.
+        *
+        * The Linux driver uses the following format:
+        *
+        *  0:7         tfd index - position within TX queue
+        *  8:12        TX queue id
+        *  13:14       reserved
+        *  15          unsolicited RX or uCode-originated notification
+        */
+       __le16 sequence;
+} __packed;
+
+
+#define FH_RSCSR_FRAME_SIZE_MSK                0x00003FFF      /* bits 0-13 */
+
+struct iwl_rx_packet {
+       /*
+        * The first 4 bytes of the RX frame header contain both the RX frame
+        * size and some flags.
+        * Bit fields:
+        * 31:    flag flush RB request
+        * 30:    flag ignore TC (terminal counter) request
+        * 29:    flag fast IRQ request
+        * 28-14: Reserved
+        * 13-00: RX frame size
+        */
+       __le32 len_n_flags;
+       struct iwl_cmd_header hdr;
+       u8 data[];
+} __packed;
 
 /**
  * enum CMD_MODE - how to send the host commands ?
@@ -178,7 +230,9 @@ enum iwl_hcmd_dataflag {
  * struct iwl_host_cmd - Host command to the uCode
  *
  * @data: array of chunks that composes the data of the host command
- * @reply_page: pointer to the page that holds the response to the host command
+ * @resp_pkt: response packet, if %CMD_WANT_SKB was set
+ * @_rx_page_order: (internally used to free response packet)
+ * @_rx_page_addr: (internally used to free response packet)
  * @handler_status: return value of the handler of the command
  *     (put in setup_rx_handlers) - valid for SYNC mode only
  * @flags: can be CMD_*
@@ -188,7 +242,9 @@ enum iwl_hcmd_dataflag {
  */
 struct iwl_host_cmd {
        const void *data[IWL_MAX_CMD_TFDS];
-       unsigned long reply_page;
+       struct iwl_rx_packet *resp_pkt;
+       unsigned long _rx_page_addr;
+       u32 _rx_page_order;
        int handler_status;
 
        u32 flags;
@@ -197,6 +253,27 @@ struct iwl_host_cmd {
        u8 id;
 };
 
+static inline void iwl_free_resp(struct iwl_host_cmd *cmd)
+{
+       free_pages(cmd->_rx_page_addr, cmd->_rx_page_order);
+}
+
+struct iwl_rx_cmd_buffer {
+       struct page *_page;
+};
+
+static inline void *rxb_addr(struct iwl_rx_cmd_buffer *r)
+{
+       return page_address(r->_page);
+}
+
+static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r)
+{
+       struct page *p = r->_page;
+       r->_page = NULL;
+       return p;
+}
+
 /**
  * struct iwl_trans_ops - transport specific operations
  *
@@ -215,6 +292,9 @@ struct iwl_host_cmd {
  * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_*
  * @stop_device:stops the whole device (embedded CPU put to reset)
  *     May sleep
+ * @wowlan_suspend: put the device into the correct mode for WoWLAN during
+ *     suspend. This is optional, if not implemented WoWLAN will not be
+ *     supported. This callback may sleep.
  * @send_cmd:send a host command
  *     May sleep only if CMD_SYNC is set
  * @tx: send an skb
@@ -222,7 +302,7 @@ struct iwl_host_cmd {
  * @reclaim: free packet until ssn. Returns a list of freed packets.
  *     Must be atomic
  * @tx_agg_alloc: allocate resources for a TX BA session
- *     May sleep
+ *     Must be atomic
  * @tx_agg_setup: setup a tx queue for AMPDU - will be called once the HW is
  *     ready and a successful ADDBA response has been received.
  *     May sleep
@@ -248,10 +328,12 @@ struct iwl_trans_ops {
 
        int (*start_hw)(struct iwl_trans *iwl_trans);
        void (*stop_hw)(struct iwl_trans *iwl_trans);
-       int (*start_fw)(struct iwl_trans *trans, struct fw_img *fw);
+       int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw);
        void (*fw_alive)(struct iwl_trans *trans);
        void (*stop_device)(struct iwl_trans *trans);
 
+       void (*wowlan_suspend)(struct iwl_trans *trans);
+
        void (*wake_any_queue)(struct iwl_trans *trans,
                               enum iwl_rxon_context_id ctx,
                               const char *msg);
@@ -289,14 +371,6 @@ struct iwl_trans_ops {
        u32 (*read32)(struct iwl_trans *trans, u32 ofs);
 };
 
-/* Opaque calibration results */
-struct iwl_calib_result {
-       struct list_head list;
-       size_t cmd_len;
-       struct iwl_calib_hdr hdr;
-       /* data follows */
-};
-
 /**
  * enum iwl_trans_state - state of the transport layer
  *
@@ -312,44 +386,46 @@ enum iwl_trans_state {
  * struct iwl_trans - transport common data
  *
  * @ops - pointer to iwl_trans_ops
+ * @op_mode - pointer to the op_mode
  * @shrd - pointer to iwl_shared which holds shared data from the upper layer
- * @hcmd_lock: protects HCMD
  * @reg_lock - protect hw register access
  * @dev - pointer to struct device * that represents the device
- * @irq - the irq number for the device
  * @hw_id: a u32 with the ID of the device / subdevice.
  *     Set during transport allocation.
  * @hw_id_str: a string with info about HW ID. Set during transport allocation.
- * @ucode_write_complete: indicates that the ucode has been copied.
  * @nvm_device_type: indicates OTP or eeprom
  * @pm_support: set to true in start_hw if link pm is supported
- * @calib_results: list head for init calibration results
  */
 struct iwl_trans {
        const struct iwl_trans_ops *ops;
+       struct iwl_op_mode *op_mode;
        struct iwl_shared *shrd;
        enum iwl_trans_state state;
-       spinlock_t hcmd_lock;
        spinlock_t reg_lock;
 
        struct device *dev;
-       unsigned int irq;
        u32 hw_rev;
        u32 hw_id;
        char hw_id_str[52];
 
-       u8 ucode_write_complete;
-
        int    nvm_device_type;
        bool pm_support;
 
-       struct list_head calib_results;
-
        /* pointer to trans specific struct */
        /*Ensure that this pointer will always be aligned to sizeof pointer */
-       char trans_specific[0] __attribute__((__aligned__(sizeof(void *))));
+       char trans_specific[0] __aligned(sizeof(void *));
 };
 
+static inline void iwl_trans_configure(struct iwl_trans *trans,
+                                      struct iwl_op_mode *op_mode)
+{
+       /*
+        * only set the op_mode for the moment. Later on, this function will do
+        * more
+        */
+       trans->op_mode = op_mode;
+}
+
 static inline int iwl_trans_start_hw(struct iwl_trans *trans)
 {
        might_sleep();
@@ -375,7 +451,8 @@ static inline void iwl_trans_fw_alive(struct iwl_trans *trans)
        trans->state = IWL_TRANS_FW_ALIVE;
 }
 
-static inline int iwl_trans_start_fw(struct iwl_trans *trans, struct fw_img *fw)
+static inline int iwl_trans_start_fw(struct iwl_trans *trans,
+                                    const struct fw_img *fw)
 {
        might_sleep();
 
@@ -391,6 +468,12 @@ static inline void iwl_trans_stop_device(struct iwl_trans *trans)
        trans->state = IWL_TRANS_NO_FW;
 }
 
+static inline void iwl_trans_wowlan_suspend(struct iwl_trans *trans)
+{
+       might_sleep();
+       trans->ops->wowlan_suspend(trans);
+}
+
 static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans,
                                            enum iwl_rxon_context_id ctx,
                                            const char *msg)
@@ -411,9 +494,6 @@ static inline int iwl_trans_send_cmd(struct iwl_trans *trans,
        return trans->ops->send_cmd(trans, cmd);
 }
 
-int iwl_trans_send_cmd_pdu(struct iwl_trans *trans, u8 id,
-                          u32 flags, u16 len, const void *data);
-
 static inline int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb,
                struct iwl_device_cmd *dev_cmd, enum iwl_rxon_context_id ctx,
                u8 sta_id, u8 tid)
@@ -449,8 +529,6 @@ static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans,
 static inline int iwl_trans_tx_agg_alloc(struct iwl_trans *trans,
                                         int sta_id, int tid)
 {
-       might_sleep();
-
        if (trans->state != IWL_TRANS_FW_ALIVE)
                IWL_ERR(trans, "%s bad state = %d", __func__, trans->state);
 
@@ -533,14 +611,6 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs)
        return trans->ops->read32(trans, ofs);
 }
 
-/*****************************************************
-* Utils functions
-******************************************************/
-int iwl_send_calib_results(struct iwl_trans *trans);
-int iwl_calib_set(struct iwl_trans *trans,
-                 const struct iwl_calib_hdr *cmd, int len);
-void iwl_calib_free_results(struct iwl_trans *trans);
-
 /*****************************************************
 * Transport layers implementations + their allocation function
 ******************************************************/
@@ -550,6 +620,8 @@ extern const struct iwl_trans_ops trans_ops_pcie;
 struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
                                       struct pci_dev *pdev,
                                       const struct pci_device_id *ent);
+int __must_check iwl_pci_register_driver(void);
+void iwl_pci_unregister_driver(void);
 
 extern const struct iwl_trans_ops trans_ops_idi;
 struct iwl_trans *iwl_trans_idi_alloc(struct iwl_shared *shrd,
index 61c6c0568c1101d1e69dbfd6717cb80d090b0db9..8267dbe869d585e13703923d49fe38acb402b530 100644 (file)
  *****************************************************************************/
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/dma-mapping.h>
-#include <linux/firmware.h>
 
-#include "iwl-ucode.h"
-#include "iwl-wifi.h"
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-io.h"
@@ -44,6 +38,7 @@
 #include "iwl-agn-calib.h"
 #include "iwl-trans.h"
 #include "iwl-fh.h"
+#include "iwl-op-mode.h"
 
 static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
        {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP,
@@ -82,56 +77,16 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
  *
  ******************************************************************************/
 
-static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc)
-{
-       if (desc->v_addr)
-               dma_free_coherent(trans(nic)->dev, desc->len,
-                                 desc->v_addr, desc->p_addr);
-       desc->v_addr = NULL;
-       desc->len = 0;
-}
-
-static void iwl_free_fw_img(struct iwl_nic *nic, struct fw_img *img)
-{
-       iwl_free_fw_desc(nic, &img->code);
-       iwl_free_fw_desc(nic, &img->data);
-}
-
-void iwl_dealloc_ucode(struct iwl_nic *nic)
-{
-       iwl_free_fw_img(nic, &nic->fw.ucode_rt);
-       iwl_free_fw_img(nic, &nic->fw.ucode_init);
-       iwl_free_fw_img(nic, &nic->fw.ucode_wowlan);
-}
-
-static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc,
-                     const void *data, size_t len)
-{
-       if (!len) {
-               desc->v_addr = NULL;
-               return -EINVAL;
-       }
-
-       desc->v_addr = dma_alloc_coherent(trans(nic)->dev, len,
-                                         &desc->p_addr, GFP_KERNEL);
-       if (!desc->v_addr)
-               return -ENOMEM;
-
-       desc->len = len;
-       memcpy(desc->v_addr, data, len);
-       return 0;
-}
-
-static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic,
-                                       enum iwl_ucode_type ucode_type)
+static inline const struct fw_img *
+iwl_get_ucode_image(struct iwl_priv *priv, enum iwl_ucode_type ucode_type)
 {
        switch (ucode_type) {
        case IWL_UCODE_INIT:
-               return &nic->fw.ucode_init;
+               return &priv->fw->ucode_init;
        case IWL_UCODE_WOWLAN:
-               return &nic->fw.ucode_wowlan;
+               return &priv->fw->ucode_wowlan;
        case IWL_UCODE_REGULAR:
-               return &nic->fw.ucode_rt;
+               return &priv->fw->ucode_rt;
        case IWL_UCODE_NONE:
                break;
        }
@@ -141,23 +96,23 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic,
 /*
  *  Calibration
  */
-static int iwl_set_Xtal_calib(struct iwl_trans *trans)
+static int iwl_set_Xtal_calib(struct iwl_priv *priv)
 {
        struct iwl_calib_xtal_freq_cmd cmd;
        __le16 *xtal_calib =
-               (__le16 *)iwl_eeprom_query_addr(trans->shrd, EEPROM_XTAL);
+               (__le16 *)iwl_eeprom_query_addr(priv->shrd, EEPROM_XTAL);
 
        iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD);
        cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]);
        cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]);
-       return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd));
+       return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd));
 }
 
-static int iwl_set_temperature_offset_calib(struct iwl_trans *trans)
+static int iwl_set_temperature_offset_calib(struct iwl_priv *priv)
 {
        struct iwl_calib_temperature_offset_cmd cmd;
        __le16 *offset_calib =
-               (__le16 *)iwl_eeprom_query_addr(trans->shrd,
+               (__le16 *)iwl_eeprom_query_addr(priv->shrd,
                                                EEPROM_RAW_TEMPERATURE);
 
        memset(&cmd, 0, sizeof(cmd));
@@ -166,48 +121,48 @@ static int iwl_set_temperature_offset_calib(struct iwl_trans *trans)
        if (!(cmd.radio_sensor_offset))
                cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET;
 
-       IWL_DEBUG_CALIB(trans, "Radio sensor offset: %d\n",
+       IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n",
                        le16_to_cpu(cmd.radio_sensor_offset));
-       return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd));
+       return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd));
 }
 
-static int iwl_set_temperature_offset_calib_v2(struct iwl_trans *trans)
+static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv)
 {
        struct iwl_calib_temperature_offset_v2_cmd cmd;
-       __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(trans->shrd,
+       __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv->shrd,
                                     EEPROM_KELVIN_TEMPERATURE);
        __le16 *offset_calib_low =
-               (__le16 *)iwl_eeprom_query_addr(trans->shrd,
+               (__le16 *)iwl_eeprom_query_addr(priv->shrd,
                                                EEPROM_RAW_TEMPERATURE);
        struct iwl_eeprom_calib_hdr *hdr;
 
        memset(&cmd, 0, sizeof(cmd));
        iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD);
-       hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(trans->shrd,
+       hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv->shrd,
                                                        EEPROM_CALIB_ALL);
        memcpy(&cmd.radio_sensor_offset_high, offset_calib_high,
                sizeof(*offset_calib_high));
        memcpy(&cmd.radio_sensor_offset_low, offset_calib_low,
                sizeof(*offset_calib_low));
        if (!(cmd.radio_sensor_offset_low)) {
-               IWL_DEBUG_CALIB(trans, "no info in EEPROM, use default\n");
+               IWL_DEBUG_CALIB(priv, "no info in EEPROM, use default\n");
                cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET;
                cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET;
        }
        memcpy(&cmd.burntVoltageRef, &hdr->voltage,
                sizeof(hdr->voltage));
 
-       IWL_DEBUG_CALIB(trans, "Radio sensor offset high: %d\n",
+       IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n",
                        le16_to_cpu(cmd.radio_sensor_offset_high));
-       IWL_DEBUG_CALIB(trans, "Radio sensor offset low: %d\n",
+       IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n",
                        le16_to_cpu(cmd.radio_sensor_offset_low));
-       IWL_DEBUG_CALIB(trans, "Voltage Ref: %d\n",
+       IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n",
                        le16_to_cpu(cmd.burntVoltageRef));
 
-       return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd));
+       return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd));
 }
 
-static int iwl_send_calib_cfg(struct iwl_trans *trans)
+static int iwl_send_calib_cfg(struct iwl_priv *priv)
 {
        struct iwl_calib_cfg_cmd calib_cfg_cmd;
        struct iwl_host_cmd cmd = {
@@ -223,47 +178,47 @@ static int iwl_send_calib_cfg(struct iwl_trans *trans)
        calib_cfg_cmd.ucd_calib_cfg.flags =
                IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK;
 
-       return iwl_trans_send_cmd(trans, &cmd);
+       return iwl_dvm_send_cmd(priv, &cmd);
 }
 
 int iwlagn_rx_calib_result(struct iwl_priv *priv,
-                           struct iwl_rx_mem_buffer *rxb,
+                           struct iwl_rx_cmd_buffer *rxb,
                            struct iwl_device_cmd *cmd)
 {
        struct iwl_rx_packet *pkt = rxb_addr(rxb);
-       struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw;
+       struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->data;
        int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
 
        /* reduce the size of the length field itself */
        len -= 4;
 
-       if (iwl_calib_set(trans(priv), hdr, len))
+       if (iwl_calib_set(priv, hdr, len))
                IWL_ERR(priv, "Failed to record calibration data %d\n",
                        hdr->op_code);
 
        return 0;
 }
 
-int iwl_init_alive_start(struct iwl_trans *trans)
+int iwl_init_alive_start(struct iwl_priv *priv)
 {
        int ret;
 
-       if (cfg(trans)->bt_params &&
-           cfg(trans)->bt_params->advanced_bt_coexist) {
+       if (cfg(priv)->bt_params &&
+           cfg(priv)->bt_params->advanced_bt_coexist) {
                /*
                 * Tell uCode we are ready to perform calibration
                 * need to perform this before any calibration
                 * no need to close the envlope since we are going
                 * to load the runtime uCode later.
                 */
-               ret = iwl_send_bt_env(trans, IWL_BT_COEX_ENV_OPEN,
+               ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
                        BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
                if (ret)
                        return ret;
 
        }
 
-       ret = iwl_send_calib_cfg(trans);
+       ret = iwl_send_calib_cfg(priv);
        if (ret)
                return ret;
 
@@ -271,21 +226,21 @@ int iwl_init_alive_start(struct iwl_trans *trans)
         * temperature offset calibration is only needed for runtime ucode,
         * so prepare the value now.
         */
-       if (cfg(trans)->need_temp_offset_calib) {
-               if (cfg(trans)->temp_offset_v2)
-                       return iwl_set_temperature_offset_calib_v2(trans);
+       if (cfg(priv)->need_temp_offset_calib) {
+               if (cfg(priv)->temp_offset_v2)
+                       return iwl_set_temperature_offset_calib_v2(priv);
                else
-                       return iwl_set_temperature_offset_calib(trans);
+                       return iwl_set_temperature_offset_calib(priv);
        }
 
        return 0;
 }
 
-static int iwl_send_wimax_coex(struct iwl_trans *trans)
+static int iwl_send_wimax_coex(struct iwl_priv *priv)
 {
        struct iwl_wimax_coex_cmd coex_cmd;
 
-       if (cfg(trans)->base_params->support_wimax_coexist) {
+       if (cfg(priv)->base_params->support_wimax_coexist) {
                /* UnMask wake up src at associated sleep */
                coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK;
 
@@ -304,7 +259,7 @@ static int iwl_send_wimax_coex(struct iwl_trans *trans)
                /* coexistence is disabled */
                memset(&coex_cmd, 0, sizeof(coex_cmd));
        }
-       return iwl_trans_send_cmd_pdu(trans,
+       return iwl_dvm_send_cmd_pdu(priv,
                                COEX_PRIORITY_TABLE_CMD, CMD_SYNC,
                                sizeof(coex_cmd), &coex_cmd);
 }
@@ -331,37 +286,36 @@ static const u8 iwl_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = {
        0, 0, 0, 0, 0, 0, 0
 };
 
-void iwl_send_prio_tbl(struct iwl_trans *trans)
+void iwl_send_prio_tbl(struct iwl_priv *priv)
 {
        struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd;
 
        memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl,
                sizeof(iwl_bt_prio_tbl));
-       if (iwl_trans_send_cmd_pdu(trans,
+       if (iwl_dvm_send_cmd_pdu(priv,
                                REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC,
                                sizeof(prio_tbl_cmd), &prio_tbl_cmd))
-               IWL_ERR(trans, "failed to send BT prio tbl command\n");
+               IWL_ERR(priv, "failed to send BT prio tbl command\n");
 }
 
-int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type)
+int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
 {
        struct iwl_bt_coex_prot_env_cmd env_cmd;
        int ret;
 
        env_cmd.action = action;
        env_cmd.type = type;
-       ret = iwl_trans_send_cmd_pdu(trans,
+       ret = iwl_dvm_send_cmd_pdu(priv,
                               REPLY_BT_COEX_PROT_ENV, CMD_SYNC,
                               sizeof(env_cmd), &env_cmd);
        if (ret)
-               IWL_ERR(trans, "failed to send BT env command\n");
+               IWL_ERR(priv, "failed to send BT env command\n");
        return ret;
 }
 
 
-static int iwl_alive_notify(struct iwl_trans *trans)
+static int iwl_alive_notify(struct iwl_priv *priv)
 {
-       struct iwl_priv *priv = priv(trans);
        struct iwl_rxon_context *ctx;
        int ret;
 
@@ -374,21 +328,21 @@ static int iwl_alive_notify(struct iwl_trans *trans)
        if (!priv->tx_cmd_pool)
                return -ENOMEM;
 
-       iwl_trans_fw_alive(trans);
+       iwl_trans_fw_alive(trans(priv));
        for_each_context(priv, ctx)
                ctx->last_tx_rejected = false;
 
-       ret = iwl_send_wimax_coex(trans);
+       ret = iwl_send_wimax_coex(priv);
        if (ret)
                return ret;
 
        if (!cfg(priv)->no_xtal_calib) {
-               ret = iwl_set_Xtal_calib(trans);
+               ret = iwl_set_Xtal_calib(priv);
                if (ret)
                        return ret;
        }
 
-       return iwl_send_calib_results(trans);
+       return iwl_send_calib_results(priv);
 }
 
 
@@ -397,24 +351,23 @@ static int iwl_alive_notify(struct iwl_trans *trans)
  *   using sample data 100 bytes apart.  If these sample points are good,
  *   it's a pretty good bet that everything between them is good, too.
  */
-static int iwl_verify_inst_sparse(struct iwl_nic *nic,
-                                     struct fw_desc *fw_desc)
+static int iwl_verify_inst_sparse(struct iwl_priv *priv,
+                                 const struct fw_desc *fw_desc)
 {
-       struct iwl_trans *trans = trans(nic);
        __le32 *image = (__le32 *)fw_desc->v_addr;
        u32 len = fw_desc->len;
        u32 val;
        u32 i;
 
-       IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len);
+       IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len);
 
        for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
                /* read data comes through single port, auto-incr addr */
                /* NOTE: Use the debugless read so we don't flood kernel log
                 * if IWL_DL_IO is set */
-               iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR,
+               iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR,
                        i + IWLAGN_RTC_INST_LOWER_BOUND);
-               val = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
+               val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
                if (val != le32_to_cpu(*image))
                        return -EIO;
        }
@@ -422,28 +375,27 @@ static int iwl_verify_inst_sparse(struct iwl_nic *nic,
        return 0;
 }
 
-static void iwl_print_mismatch_inst(struct iwl_nic *nic,
-                                   struct fw_desc *fw_desc)
+static void iwl_print_mismatch_inst(struct iwl_priv *priv,
+                                   const struct fw_desc *fw_desc)
 {
-       struct iwl_trans *trans = trans(nic);
        __le32 *image = (__le32 *)fw_desc->v_addr;
        u32 len = fw_desc->len;
        u32 val;
        u32 offs;
        int errors = 0;
 
-       IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len);
+       IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len);
 
-       iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR,
+       iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR,
                           IWLAGN_RTC_INST_LOWER_BOUND);
 
        for (offs = 0;
             offs < len && errors < 20;
             offs += sizeof(u32), image++) {
                /* read data comes through single port, auto-incr addr */
-               val = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
+               val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
                if (val != le32_to_cpu(*image)) {
-                       IWL_ERR(nic, "uCode INST section at "
+                       IWL_ERR(priv, "uCode INST section at "
                                "offset 0x%x, is 0x%x, s/b 0x%x\n",
                                offs, val, le32_to_cpu(*image));
                        errors++;
@@ -455,24 +407,24 @@ static void iwl_print_mismatch_inst(struct iwl_nic *nic,
  * iwl_verify_ucode - determine which instruction image is in SRAM,
  *    and verify its contents
  */
-static int iwl_verify_ucode(struct iwl_nic *nic,
+static int iwl_verify_ucode(struct iwl_priv *priv,
                            enum iwl_ucode_type ucode_type)
 {
-       struct fw_img *img = iwl_get_ucode_image(nic, ucode_type);
+       const struct fw_img *img = iwl_get_ucode_image(priv, ucode_type);
 
        if (!img) {
-               IWL_ERR(nic, "Invalid ucode requested (%d)\n", ucode_type);
+               IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type);
                return -EINVAL;
        }
 
-       if (!iwl_verify_inst_sparse(nic, &img->code)) {
-               IWL_DEBUG_FW(nic, "uCode is good in inst SRAM\n");
+       if (!iwl_verify_inst_sparse(priv, &img->code)) {
+               IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n");
                return 0;
        }
 
-       IWL_ERR(nic, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
+       IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
 
-       iwl_print_mismatch_inst(nic, &img->code);
+       iwl_print_mismatch_inst(priv, &img->code);
        return -EIO;
 }
 
@@ -481,119 +433,57 @@ struct iwl_alive_data {
        u8 subtype;
 };
 
-static void iwl_alive_fn(struct iwl_trans *trans,
+static void iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
                            struct iwl_rx_packet *pkt,
                            void *data)
 {
+       struct iwl_priv *priv =
+               container_of(notif_wait, struct iwl_priv, notif_wait);
        struct iwl_alive_data *alive_data = data;
        struct iwl_alive_resp *palive;
 
-       palive = &pkt->u.alive_frame;
+       palive = (void *)pkt->data;
 
-       IWL_DEBUG_FW(trans, "Alive ucode status 0x%08X revision "
+       IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision "
                       "0x%01X 0x%01X\n",
                       palive->is_valid, palive->ver_type,
                       palive->ver_subtype);
 
-       trans->shrd->device_pointers.error_event_table =
+       priv->shrd->device_pointers.error_event_table =
                le32_to_cpu(palive->error_event_table_ptr);
-       trans->shrd->device_pointers.log_event_table =
+       priv->shrd->device_pointers.log_event_table =
                le32_to_cpu(palive->log_event_table_ptr);
 
        alive_data->subtype = palive->ver_subtype;
        alive_data->valid = palive->is_valid == UCODE_VALID_OK;
 }
 
-/* notification wait support */
-void iwl_init_notification_wait(struct iwl_shared *shrd,
-                                  struct iwl_notification_wait *wait_entry,
-                                  u8 cmd,
-                                  void (*fn)(struct iwl_trans *trans,
-                                             struct iwl_rx_packet *pkt,
-                                             void *data),
-                                  void *fn_data)
-{
-       wait_entry->fn = fn;
-       wait_entry->fn_data = fn_data;
-       wait_entry->cmd = cmd;
-       wait_entry->triggered = false;
-       wait_entry->aborted = false;
-
-       spin_lock_bh(&shrd->notif_wait_lock);
-       list_add(&wait_entry->list, &shrd->notif_waits);
-       spin_unlock_bh(&shrd->notif_wait_lock);
-}
-
-int iwl_wait_notification(struct iwl_shared *shrd,
-                            struct iwl_notification_wait *wait_entry,
-                            unsigned long timeout)
-{
-       int ret;
-
-       ret = wait_event_timeout(shrd->notif_waitq,
-                                wait_entry->triggered || wait_entry->aborted,
-                                timeout);
-
-       spin_lock_bh(&shrd->notif_wait_lock);
-       list_del(&wait_entry->list);
-       spin_unlock_bh(&shrd->notif_wait_lock);
-
-       if (wait_entry->aborted)
-               return -EIO;
-
-       /* return value is always >= 0 */
-       if (ret <= 0)
-               return -ETIMEDOUT;
-       return 0;
-}
-
-void iwl_remove_notification(struct iwl_shared *shrd,
-                               struct iwl_notification_wait *wait_entry)
-{
-       spin_lock_bh(&shrd->notif_wait_lock);
-       list_del(&wait_entry->list);
-       spin_unlock_bh(&shrd->notif_wait_lock);
-}
-
-void iwl_abort_notification_waits(struct iwl_shared *shrd)
-{
-       unsigned long flags;
-       struct iwl_notification_wait *wait_entry;
-
-       spin_lock_irqsave(&shrd->notif_wait_lock, flags);
-       list_for_each_entry(wait_entry, &shrd->notif_waits, list)
-               wait_entry->aborted = true;
-       spin_unlock_irqrestore(&shrd->notif_wait_lock, flags);
-
-       wake_up_all(&shrd->notif_waitq);
-}
-
 #define UCODE_ALIVE_TIMEOUT    HZ
 #define UCODE_CALIB_TIMEOUT    (2*HZ)
 
-int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
+int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
                                 enum iwl_ucode_type ucode_type)
 {
        struct iwl_notification_wait alive_wait;
        struct iwl_alive_data alive_data;
-       struct fw_img *fw;
+       const struct fw_img *fw;
        int ret;
        enum iwl_ucode_type old_type;
 
-       iwl_init_notification_wait(trans->shrd, &alive_wait, REPLY_ALIVE,
-                                     iwl_alive_fn, &alive_data);
-
-       old_type = trans->shrd->ucode_type;
-       trans->shrd->ucode_type = ucode_type;
-       fw = iwl_get_ucode_image(nic(trans), ucode_type);
+       old_type = priv->shrd->ucode_type;
+       priv->shrd->ucode_type = ucode_type;
+       fw = iwl_get_ucode_image(priv, ucode_type);
 
        if (!fw)
                return -EINVAL;
 
-       ret = iwl_trans_start_fw(trans, fw);
+       iwl_init_notification_wait(&priv->notif_wait, &alive_wait, REPLY_ALIVE,
+                                     iwl_alive_fn, &alive_data);
+
+       ret = iwl_trans_start_fw(trans(priv), fw);
        if (ret) {
-               trans->shrd->ucode_type = old_type;
-               iwl_remove_notification(trans->shrd, &alive_wait);
+               priv->shrd->ucode_type = old_type;
+               iwl_remove_notification(&priv->notif_wait, &alive_wait);
                return ret;
        }
 
@@ -601,16 +491,16 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
         * Some things may run in the background now, but we
         * just wait for the ALIVE notification here.
         */
-       ret = iwl_wait_notification(trans->shrd, &alive_wait,
+       ret = iwl_wait_notification(&priv->notif_wait, &alive_wait,
                                        UCODE_ALIVE_TIMEOUT);
        if (ret) {
-               trans->shrd->ucode_type = old_type;
+               priv->shrd->ucode_type = old_type;
                return ret;
        }
 
        if (!alive_data.valid) {
-               IWL_ERR(trans, "Loaded ucode is not valid!\n");
-               trans->shrd->ucode_type = old_type;
+               IWL_ERR(priv, "Loaded ucode is not valid!\n");
+               priv->shrd->ucode_type = old_type;
                return -EIO;
        }
 
@@ -620,9 +510,9 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
         * skip it for WoWLAN.
         */
        if (ucode_type != IWL_UCODE_WOWLAN) {
-               ret = iwl_verify_ucode(nic(trans), ucode_type);
+               ret = iwl_verify_ucode(priv, ucode_type);
                if (ret) {
-                       trans->shrd->ucode_type = old_type;
+                       priv->shrd->ucode_type = old_type;
                        return ret;
                }
 
@@ -630,41 +520,41 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
                msleep(5);
        }
 
-       ret = iwl_alive_notify(trans);
+       ret = iwl_alive_notify(priv);
        if (ret) {
-               IWL_WARN(trans,
+               IWL_WARN(priv,
                        "Could not complete ALIVE transition: %d\n", ret);
-               trans->shrd->ucode_type = old_type;
+               priv->shrd->ucode_type = old_type;
                return ret;
        }
 
        return 0;
 }
 
-int iwl_run_init_ucode(struct iwl_trans *trans)
+int iwl_run_init_ucode(struct iwl_priv *priv)
 {
        struct iwl_notification_wait calib_wait;
        int ret;
 
-       lockdep_assert_held(&trans->shrd->mutex);
+       lockdep_assert_held(&priv->mutex);
 
        /* No init ucode required? Curious, but maybe ok */
-       if (!nic(trans)->fw.ucode_init.code.len)
+       if (!priv->fw->ucode_init.code.len)
                return 0;
 
-       if (trans->shrd->ucode_type != IWL_UCODE_NONE)
+       if (priv->shrd->ucode_type != IWL_UCODE_NONE)
                return 0;
 
-       iwl_init_notification_wait(trans->shrd, &calib_wait,
+       iwl_init_notification_wait(&priv->notif_wait, &calib_wait,
                                      CALIBRATION_COMPLETE_NOTIFICATION,
                                      NULL, NULL);
 
        /* Will also start the device */
-       ret = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT);
+       ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);
        if (ret)
                goto error;
 
-       ret = iwl_init_alive_start(trans);
+       ret = iwl_init_alive_start(priv);
        if (ret)
                goto error;
 
@@ -672,626 +562,15 @@ int iwl_run_init_ucode(struct iwl_trans *trans)
         * Some things may run in the background now, but we
         * just wait for the calibration complete notification.
         */
-       ret = iwl_wait_notification(trans->shrd, &calib_wait,
+       ret = iwl_wait_notification(&priv->notif_wait, &calib_wait,
                                        UCODE_CALIB_TIMEOUT);
 
        goto out;
 
  error:
-       iwl_remove_notification(trans->shrd, &calib_wait);
+       iwl_remove_notification(&priv->notif_wait, &calib_wait);
  out:
        /* Whatever happened, stop the device */
-       iwl_trans_stop_device(trans);
+       iwl_trans_stop_device(trans(priv));
        return ret;
 }
-
-static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
-
-#define UCODE_EXPERIMENTAL_INDEX       100
-#define UCODE_EXPERIMENTAL_TAG         "exp"
-
-int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first)
-{
-       struct iwl_cfg *cfg = cfg(nic);
-       const char *name_pre = cfg->fw_name_pre;
-       char tag[8];
-
-       if (first) {
-#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
-               nic->fw_index = UCODE_EXPERIMENTAL_INDEX;
-               strcpy(tag, UCODE_EXPERIMENTAL_TAG);
-       } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) {
-#endif
-               nic->fw_index = cfg->ucode_api_max;
-               sprintf(tag, "%d", nic->fw_index);
-       } else {
-               nic->fw_index--;
-               sprintf(tag, "%d", nic->fw_index);
-       }
-
-       if (nic->fw_index < cfg->ucode_api_min) {
-               IWL_ERR(nic, "no suitable firmware found!\n");
-               return -ENOENT;
-       }
-
-       sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
-
-       IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n",
-                      (nic->fw_index == UCODE_EXPERIMENTAL_INDEX)
-                               ? "EXPERIMENTAL " : "",
-                      nic->firmware_name);
-
-       return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name,
-                                      trans(nic)->dev,
-                                      GFP_KERNEL, nic, iwl_ucode_callback);
-}
-
-struct iwlagn_firmware_pieces {
-       const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data;
-       size_t inst_size, data_size, init_size, init_data_size,
-              wowlan_inst_size, wowlan_data_size;
-
-       u32 build;
-
-       u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
-       u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
-};
-
-static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic,
-                                      const struct firmware *ucode_raw,
-                                      struct iwlagn_firmware_pieces *pieces)
-{
-       struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
-       u32 api_ver, hdr_size;
-       const u8 *src;
-
-       nic->fw.ucode_ver = le32_to_cpu(ucode->ver);
-       api_ver = IWL_UCODE_API(nic->fw.ucode_ver);
-
-       switch (api_ver) {
-       default:
-               hdr_size = 28;
-               if (ucode_raw->size < hdr_size) {
-                       IWL_ERR(nic, "File size too small!\n");
-                       return -EINVAL;
-               }
-               pieces->build = le32_to_cpu(ucode->u.v2.build);
-               pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size);
-               pieces->data_size = le32_to_cpu(ucode->u.v2.data_size);
-               pieces->init_size = le32_to_cpu(ucode->u.v2.init_size);
-               pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size);
-               src = ucode->u.v2.data;
-               break;
-       case 0:
-       case 1:
-       case 2:
-               hdr_size = 24;
-               if (ucode_raw->size < hdr_size) {
-                       IWL_ERR(nic, "File size too small!\n");
-                       return -EINVAL;
-               }
-               pieces->build = 0;
-               pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size);
-               pieces->data_size = le32_to_cpu(ucode->u.v1.data_size);
-               pieces->init_size = le32_to_cpu(ucode->u.v1.init_size);
-               pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size);
-               src = ucode->u.v1.data;
-               break;
-       }
-
-       /* Verify size of file vs. image size info in file's header */
-       if (ucode_raw->size != hdr_size + pieces->inst_size +
-                               pieces->data_size + pieces->init_size +
-                               pieces->init_data_size) {
-
-               IWL_ERR(nic,
-                       "uCode file size %d does not match expected size\n",
-                       (int)ucode_raw->size);
-               return -EINVAL;
-       }
-
-       pieces->inst = src;
-       src += pieces->inst_size;
-       pieces->data = src;
-       src += pieces->data_size;
-       pieces->init = src;
-       src += pieces->init_size;
-       pieces->init_data = src;
-       src += pieces->init_data_size;
-
-       return 0;
-}
-
-static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
-                               const struct firmware *ucode_raw,
-                               struct iwlagn_firmware_pieces *pieces,
-                               struct iwl_ucode_capabilities *capa)
-{
-       struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
-       struct iwl_ucode_tlv *tlv;
-       size_t len = ucode_raw->size;
-       const u8 *data;
-       int wanted_alternative = iwlagn_mod_params.wanted_ucode_alternative;
-       int tmp;
-       u64 alternatives;
-       u32 tlv_len;
-       enum iwl_ucode_tlv_type tlv_type;
-       const u8 *tlv_data;
-
-       if (len < sizeof(*ucode)) {
-               IWL_ERR(nic, "uCode has invalid length: %zd\n", len);
-               return -EINVAL;
-       }
-
-       if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
-               IWL_ERR(nic, "invalid uCode magic: 0X%x\n",
-                       le32_to_cpu(ucode->magic));
-               return -EINVAL;
-       }
-
-       /*
-        * Check which alternatives are present, and "downgrade"
-        * when the chosen alternative is not present, warning
-        * the user when that happens. Some files may not have
-        * any alternatives, so don't warn in that case.
-        */
-       alternatives = le64_to_cpu(ucode->alternatives);
-       tmp = wanted_alternative;
-       if (wanted_alternative > 63)
-               wanted_alternative = 63;
-       while (wanted_alternative && !(alternatives & BIT(wanted_alternative)))
-               wanted_alternative--;
-       if (wanted_alternative && wanted_alternative != tmp)
-               IWL_WARN(nic,
-                        "uCode alternative %d not available, choosing %d\n",
-                        tmp, wanted_alternative);
-
-       nic->fw.ucode_ver = le32_to_cpu(ucode->ver);
-       pieces->build = le32_to_cpu(ucode->build);
-       data = ucode->data;
-
-       len -= sizeof(*ucode);
-
-       while (len >= sizeof(*tlv)) {
-               u16 tlv_alt;
-
-               len -= sizeof(*tlv);
-               tlv = (void *)data;
-
-               tlv_len = le32_to_cpu(tlv->length);
-               tlv_type = le16_to_cpu(tlv->type);
-               tlv_alt = le16_to_cpu(tlv->alternative);
-               tlv_data = tlv->data;
-
-               if (len < tlv_len) {
-                       IWL_ERR(nic, "invalid TLV len: %zd/%u\n",
-                               len, tlv_len);
-                       return -EINVAL;
-               }
-               len -= ALIGN(tlv_len, 4);
-               data += sizeof(*tlv) + ALIGN(tlv_len, 4);
-
-               /*
-                * Alternative 0 is always valid.
-                *
-                * Skip alternative TLVs that are not selected.
-                */
-               if (tlv_alt != 0 && tlv_alt != wanted_alternative)
-                       continue;
-
-               switch (tlv_type) {
-               case IWL_UCODE_TLV_INST:
-                       pieces->inst = tlv_data;
-                       pieces->inst_size = tlv_len;
-                       break;
-               case IWL_UCODE_TLV_DATA:
-                       pieces->data = tlv_data;
-                       pieces->data_size = tlv_len;
-                       break;
-               case IWL_UCODE_TLV_INIT:
-                       pieces->init = tlv_data;
-                       pieces->init_size = tlv_len;
-                       break;
-               case IWL_UCODE_TLV_INIT_DATA:
-                       pieces->init_data = tlv_data;
-                       pieces->init_data_size = tlv_len;
-                       break;
-               case IWL_UCODE_TLV_BOOT:
-                       IWL_ERR(nic, "Found unexpected BOOT ucode\n");
-                       break;
-               case IWL_UCODE_TLV_PROBE_MAX_LEN:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       capa->max_probe_length =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_PAN:
-                       if (tlv_len)
-                               goto invalid_tlv_len;
-                       capa->flags |= IWL_UCODE_TLV_FLAGS_PAN;
-                       break;
-               case IWL_UCODE_TLV_FLAGS:
-                       /* must be at least one u32 */
-                       if (tlv_len < sizeof(u32))
-                               goto invalid_tlv_len;
-                       /* and a proper number of u32s */
-                       if (tlv_len % sizeof(u32))
-                               goto invalid_tlv_len;
-                       /*
-                        * This driver only reads the first u32 as
-                        * right now no more features are defined,
-                        * if that changes then either the driver
-                        * will not work with the new firmware, or
-                        * it'll not take advantage of new features.
-                        */
-                       capa->flags = le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       pieces->init_evtlog_ptr =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_INIT_EVTLOG_SIZE:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       pieces->init_evtlog_size =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_INIT_ERRLOG_PTR:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       pieces->init_errlog_ptr =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_RUNT_EVTLOG_PTR:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       pieces->inst_evtlog_ptr =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       pieces->inst_evtlog_size =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_RUNT_ERRLOG_PTR:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       pieces->inst_errlog_ptr =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
-                       if (tlv_len)
-                               goto invalid_tlv_len;
-                       nic->fw.enhance_sensitivity_table = true;
-                       break;
-               case IWL_UCODE_TLV_WOWLAN_INST:
-                       pieces->wowlan_inst = tlv_data;
-                       pieces->wowlan_inst_size = tlv_len;
-                       break;
-               case IWL_UCODE_TLV_WOWLAN_DATA:
-                       pieces->wowlan_data = tlv_data;
-                       pieces->wowlan_data_size = tlv_len;
-                       break;
-               case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
-                       if (tlv_len != sizeof(u32))
-                               goto invalid_tlv_len;
-                       capa->standard_phy_calibration_size =
-                                       le32_to_cpup((__le32 *)tlv_data);
-                       break;
-               default:
-                       IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type);
-                       break;
-               }
-       }
-
-       if (len) {
-               IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len);
-               iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len);
-               return -EINVAL;
-       }
-
-       return 0;
-
- invalid_tlv_len:
-       IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
-       iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len);
-
-       return -EINVAL;
-}
-
-/**
- * iwl_ucode_callback - callback when firmware was loaded
- *
- * If loaded successfully, copies the firmware into buffers
- * for the card to fetch (via DMA).
- */
-static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
-{
-       struct iwl_nic *nic = context;
-       struct iwl_cfg *cfg = cfg(nic);
-       struct iwl_fw *fw = &nic->fw;
-       struct iwl_priv *priv = priv(nic); /* temporary */
-       struct iwl_ucode_header *ucode;
-       int err;
-       struct iwlagn_firmware_pieces pieces;
-       const unsigned int api_max = cfg->ucode_api_max;
-       unsigned int api_ok = cfg->ucode_api_ok;
-       const unsigned int api_min = cfg->ucode_api_min;
-       u32 api_ver;
-       char buildstr[25];
-       u32 build;
-
-       fw->ucode_capa.max_probe_length = 200;
-       fw->ucode_capa.standard_phy_calibration_size =
-                       IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;
-
-       if (!api_ok)
-               api_ok = api_max;
-
-       memset(&pieces, 0, sizeof(pieces));
-
-       if (!ucode_raw) {
-               if (nic->fw_index <= api_ok)
-                       IWL_ERR(nic,
-                               "request for firmware file '%s' failed.\n",
-                               nic->firmware_name);
-               goto try_again;
-       }
-
-       IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n",
-                      nic->firmware_name, ucode_raw->size);
-
-       /* Make sure that we got at least the API version number */
-       if (ucode_raw->size < 4) {
-               IWL_ERR(nic, "File size way too small!\n");
-               goto try_again;
-       }
-
-       /* Data from ucode file:  header followed by uCode images */
-       ucode = (struct iwl_ucode_header *)ucode_raw->data;
-
-       if (ucode->ver)
-               err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces);
-       else
-               err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces,
-                                          &fw->ucode_capa);
-
-       if (err)
-               goto try_again;
-
-       api_ver = IWL_UCODE_API(nic->fw.ucode_ver);
-       build = pieces.build;
-
-       /*
-        * api_ver should match the api version forming part of the
-        * firmware filename ... but we don't check for that and only rely
-        * on the API version read from firmware header from here on forward
-        */
-       /* no api version check required for experimental uCode */
-       if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) {
-               if (api_ver < api_min || api_ver > api_max) {
-                       IWL_ERR(nic,
-                               "Driver unable to support your firmware API. "
-                               "Driver supports v%u, firmware is v%u.\n",
-                               api_max, api_ver);
-                       goto try_again;
-               }
-
-               if (api_ver < api_ok) {
-                       if (api_ok != api_max)
-                               IWL_ERR(nic, "Firmware has old API version, "
-                                       "expected v%u through v%u, got v%u.\n",
-                                       api_ok, api_max, api_ver);
-                       else
-                               IWL_ERR(nic, "Firmware has old API version, "
-                                       "expected v%u, got v%u.\n",
-                                       api_max, api_ver);
-                       IWL_ERR(nic, "New firmware can be obtained from "
-                                     "http://www.intellinuxwireless.org/.\n");
-               }
-       }
-
-       if (build)
-               sprintf(buildstr, " build %u%s", build,
-                      (nic->fw_index == UCODE_EXPERIMENTAL_INDEX)
-                               ? " (EXP)" : "");
-       else
-               buildstr[0] = '\0';
-
-       IWL_INFO(nic, "loaded firmware version %u.%u.%u.%u%s\n",
-                IWL_UCODE_MAJOR(nic->fw.ucode_ver),
-                IWL_UCODE_MINOR(nic->fw.ucode_ver),
-                IWL_UCODE_API(nic->fw.ucode_ver),
-                IWL_UCODE_SERIAL(nic->fw.ucode_ver),
-                buildstr);
-
-       snprintf(priv->hw->wiphy->fw_version,
-                sizeof(priv->hw->wiphy->fw_version),
-                "%u.%u.%u.%u%s",
-                IWL_UCODE_MAJOR(nic->fw.ucode_ver),
-                IWL_UCODE_MINOR(nic->fw.ucode_ver),
-                IWL_UCODE_API(nic->fw.ucode_ver),
-                IWL_UCODE_SERIAL(nic->fw.ucode_ver),
-                buildstr);
-
-       /*
-        * For any of the failures below (before allocating pci memory)
-        * we will try to load a version with a smaller API -- maybe the
-        * user just got a corrupted version of the latest API.
-        */
-
-       IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n",
-                      nic->fw.ucode_ver);
-       IWL_DEBUG_INFO(nic, "f/w package hdr runtime inst size = %Zd\n",
-                      pieces.inst_size);
-       IWL_DEBUG_INFO(nic, "f/w package hdr runtime data size = %Zd\n",
-                      pieces.data_size);
-       IWL_DEBUG_INFO(nic, "f/w package hdr init inst size = %Zd\n",
-                      pieces.init_size);
-       IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n",
-                      pieces.init_data_size);
-
-       /* Verify that uCode images will fit in card's SRAM */
-       if (pieces.inst_size > cfg->max_inst_size) {
-               IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n",
-                       pieces.inst_size);
-               goto try_again;
-       }
-
-       if (pieces.data_size > cfg->max_data_size) {
-               IWL_ERR(nic, "uCode data len %Zd too large to fit in\n",
-                       pieces.data_size);
-               goto try_again;
-       }
-
-       if (pieces.init_size > cfg->max_inst_size) {
-               IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n",
-                       pieces.init_size);
-               goto try_again;
-       }
-
-       if (pieces.init_data_size > cfg->max_data_size) {
-               IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n",
-                       pieces.init_data_size);
-               goto try_again;
-       }
-
-       /* Allocate ucode buffers for card's bus-master loading ... */
-
-       /* Runtime instructions and 2 copies of data:
-        * 1) unmodified from disk
-        * 2) backup cache for save/restore during power-downs */
-       if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code,
-                             pieces.inst, pieces.inst_size))
-               goto err_pci_alloc;
-       if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data,
-                             pieces.data, pieces.data_size))
-               goto err_pci_alloc;
-
-       /* Initialization instructions and data */
-       if (pieces.init_size && pieces.init_data_size) {
-               if (iwl_alloc_fw_desc(nic,
-                                     &nic->fw.ucode_init.code,
-                                     pieces.init, pieces.init_size))
-                       goto err_pci_alloc;
-               if (iwl_alloc_fw_desc(nic,
-                                     &nic->fw.ucode_init.data,
-                                     pieces.init_data, pieces.init_data_size))
-                       goto err_pci_alloc;
-       }
-
-       /* WoWLAN instructions and data */
-       if (pieces.wowlan_inst_size && pieces.wowlan_data_size) {
-               if (iwl_alloc_fw_desc(nic,
-                                     &nic->fw.ucode_wowlan.code,
-                                     pieces.wowlan_inst,
-                                     pieces.wowlan_inst_size))
-                       goto err_pci_alloc;
-               if (iwl_alloc_fw_desc(nic,
-                                     &nic->fw.ucode_wowlan.data,
-                                     pieces.wowlan_data,
-                                     pieces.wowlan_data_size))
-                       goto err_pci_alloc;
-       }
-
-       /* Now that we can no longer fail, copy information */
-
-       /*
-        * The (size - 16) / 12 formula is based on the information recorded
-        * for each event, which is of mode 1 (including timestamp) for all
-        * new microcodes that include this information.
-        */
-       nic->init_evtlog_ptr = pieces.init_evtlog_ptr;
-       if (pieces.init_evtlog_size)
-               nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12;
-       else
-               nic->init_evtlog_size =
-                       cfg->base_params->max_event_log_size;
-       nic->init_errlog_ptr = pieces.init_errlog_ptr;
-       nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr;
-       if (pieces.inst_evtlog_size)
-               nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12;
-       else
-               nic->inst_evtlog_size =
-                       cfg->base_params->max_event_log_size;
-       nic->inst_errlog_ptr = pieces.inst_errlog_ptr;
-#ifndef CONFIG_IWLWIFI_P2P
-       fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN;
-#endif
-
-       priv->new_scan_threshold_behaviour =
-               !!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN);
-
-       if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE))
-               fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN;
-
-       /*
-        * if not PAN, then don't support P2P -- might be a uCode
-        * packaging bug or due to the eeprom check above
-        */
-       if (!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN))
-               fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P;
-
-       if (fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) {
-               priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN;
-               nic->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM;
-       } else {
-               priv->sta_key_max_num = STA_KEY_MAX_NUM;
-               nic->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;
-       }
-       /*
-        * figure out the offset of chain noise reset and gain commands
-        * base on the size of standard phy calibration commands table size
-        */
-       if (fw->ucode_capa.standard_phy_calibration_size >
-           IWL_MAX_PHY_CALIBRATE_TBL_SIZE)
-               fw->ucode_capa.standard_phy_calibration_size =
-                       IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
-
-       priv->phy_calib_chain_noise_reset_cmd =
-               fw->ucode_capa.standard_phy_calibration_size;
-       priv->phy_calib_chain_noise_gain_cmd =
-               fw->ucode_capa.standard_phy_calibration_size + 1;
-
-       /* initialize all valid contexts */
-       iwl_init_context(priv, fw->ucode_capa.flags);
-
-       /**************************************************
-        * This is still part of probe() in a sense...
-        *
-        * 9. Setup and register with mac80211 and debugfs
-        **************************************************/
-       err = iwlagn_mac_setup_register(priv, &fw->ucode_capa);
-       if (err)
-               goto out_unbind;
-
-       err = iwl_dbgfs_register(priv, DRV_NAME);
-       if (err)
-               IWL_ERR(nic,
-                       "failed to create debugfs files. Ignoring error: %d\n",
-                       err);
-
-       /* We have our copies now, allow OS release its copies */
-       release_firmware(ucode_raw);
-       complete(&nic->request_firmware_complete);
-       return;
-
- try_again:
-       /* try next, if any */
-       if (iwl_request_firmware(nic, false))
-               goto out_unbind;
-       release_firmware(ucode_raw);
-       return;
-
- err_pci_alloc:
-       IWL_ERR(nic, "failed to allocate pci memory\n");
-       iwl_dealloc_ucode(nic);
- out_unbind:
-       complete(&nic->request_firmware_complete);
-       device_release_driver(trans(nic)->dev);
-       release_firmware(ucode_raw);
-}
-
index ba16f05df0fcd0ac68d625aa136fd0e261ec3cad..b4f6cb3298a46c08826fda462f963ef4b52a4459 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/etherdevice.h>
 #include <linux/debugfs.h>
 #include <linux/module.h>
+#include <linux/ktime.h>
 #include <net/genetlink.h>
 #include "mac80211_hwsim.h"
 
@@ -321,11 +322,15 @@ struct mac80211_hwsim_data {
        struct dentry *debugfs_group;
 
        int power_level;
+
+       /* difference between this hw's clock and the real clock, in usecs */
+       u64 tsf_offset;
 };
 
 
 struct hwsim_radiotap_hdr {
        struct ieee80211_radiotap_header hdr;
+       __le64 rt_tsft;
        u8 rt_flags;
        u8 rt_rate;
        __le16 rt_channel;
@@ -367,6 +372,28 @@ static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb,
        return NETDEV_TX_OK;
 }
 
+static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data)
+{
+       struct timeval tv = ktime_to_timeval(ktime_get_real());
+       u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+       return cpu_to_le64(now + data->tsf_offset);
+}
+
+static u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
+               struct ieee80211_vif *vif)
+{
+       struct mac80211_hwsim_data *data = hw->priv;
+       return le64_to_cpu(__mac80211_hwsim_get_tsf(data));
+}
+
+static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
+               struct ieee80211_vif *vif, u64 tsf)
+{
+       struct mac80211_hwsim_data *data = hw->priv;
+       struct timeval tv = ktime_to_timeval(ktime_get_real());
+       u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+       data->tsf_offset = tsf - now;
+}
 
 static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
                                      struct sk_buff *tx_skb)
@@ -391,7 +418,9 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
        hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
        hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
                                          (1 << IEEE80211_RADIOTAP_RATE) |
+                                         (1 << IEEE80211_RADIOTAP_TSFT) |
                                          (1 << IEEE80211_RADIOTAP_CHANNEL));
+       hdr->rt_tsft = __mac80211_hwsim_get_tsf(data);
        hdr->rt_flags = 0;
        hdr->rt_rate = txrate->bitrate / 5;
        hdr->rt_channel = cpu_to_le16(data->channel->center_freq);
@@ -610,7 +639,8 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
        }
 
        memset(&rx_status, 0, sizeof(rx_status));
-       /* TODO: set mactime */
+       rx_status.mactime = le64_to_cpu(__mac80211_hwsim_get_tsf(data));
+       rx_status.flag |= RX_FLAG_MACTIME_MPDU;
        rx_status.freq = data->channel->center_freq;
        rx_status.band = data->channel->band;
        rx_status.rate_idx = info->control.rates[0].idx;
@@ -667,6 +697,12 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
        bool ack;
        struct ieee80211_tx_info *txi;
        u32 _pid;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       struct mac80211_hwsim_data *data = hw->priv;
+
+       if (ieee80211_is_beacon(mgmt->frame_control) ||
+           ieee80211_is_probe_resp(mgmt->frame_control))
+               mgmt->u.beacon.timestamp = __mac80211_hwsim_get_tsf(data);
 
        mac80211_hwsim_monitor_rx(hw, skb);
 
@@ -763,9 +799,11 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
                                     struct ieee80211_vif *vif)
 {
        struct ieee80211_hw *hw = arg;
+       struct mac80211_hwsim_data *data = hw->priv;
        struct sk_buff *skb;
        struct ieee80211_tx_info *info;
        u32 _pid;
+       struct ieee80211_mgmt *mgmt;
 
        hwsim_check_magic(vif);
 
@@ -779,6 +817,9 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
                return;
        info = IEEE80211_SKB_CB(skb);
 
+       mgmt = (struct ieee80211_mgmt *) skb->data;
+       mgmt->u.beacon.timestamp = __mac80211_hwsim_get_tsf(data);
+
        mac80211_hwsim_monitor_rx(hw, skb);
 
        /* wmediumd mode check */
@@ -1199,6 +1240,8 @@ static struct ieee80211_ops mac80211_hwsim_ops =
        .sw_scan_start = mac80211_hwsim_sw_scan,
        .sw_scan_complete = mac80211_hwsim_sw_scan_complete,
        .flush = mac80211_hwsim_flush,
+       .get_tsf = mac80211_hwsim_get_tsf,
+       .set_tsf = mac80211_hwsim_set_tsf,
 };
 
 
index 8d8ee639fe5607ccab8502678bc0f68598cbd85d..b4890a01ba926990ca3359ded2f24bba028ebeb2 100644 (file)
@@ -146,7 +146,7 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
 
        /* Return if WEP key not configured */
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED)
+       if (!priv->sec_info.wep_enabled)
                return 0;
 
        if (mwifiex_set_encode(priv, NULL, 0, key_index, 0)) {
@@ -613,7 +613,6 @@ static struct ieee80211_rate mwifiex_rates[] = {
        {.bitrate = 20, .hw_value = 4, },
        {.bitrate = 55, .hw_value = 11, },
        {.bitrate = 110, .hw_value = 22, },
-       {.bitrate = 220, .hw_value = 44, },
        {.bitrate = 60, .hw_value = 12, },
        {.bitrate = 90, .hw_value = 18, },
        {.bitrate = 120, .hw_value = 24, },
@@ -622,7 +621,6 @@ static struct ieee80211_rate mwifiex_rates[] = {
        {.bitrate = 360, .hw_value = 72, },
        {.bitrate = 480, .hw_value = 96, },
        {.bitrate = 540, .hw_value = 108, },
-       {.bitrate = 720, .hw_value = 144, },
 };
 
 /* Channel definitions to be advertised to cfg80211 */
@@ -688,8 +686,8 @@ static struct ieee80211_channel mwifiex_channels_5ghz[] = {
 static struct ieee80211_supported_band mwifiex_band_5ghz = {
        .channels = mwifiex_channels_5ghz,
        .n_channels = ARRAY_SIZE(mwifiex_channels_5ghz),
-       .bitrates = mwifiex_rates - 4,
-       .n_bitrates = ARRAY_SIZE(mwifiex_rates) + 4,
+       .bitrates = mwifiex_rates + 4,
+       .n_bitrates = ARRAY_SIZE(mwifiex_rates) - 4,
 };
 
 
@@ -841,12 +839,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
                       u8 *bssid, int mode, struct ieee80211_channel *channel,
                       struct cfg80211_connect_params *sme, bool privacy)
 {
-       struct mwifiex_802_11_ssid req_ssid;
+       struct cfg80211_ssid req_ssid;
        int ret, auth_type = 0;
        struct cfg80211_bss *bss = NULL;
        u8 is_scanning_required = 0;
 
-       memset(&req_ssid, 0, sizeof(struct mwifiex_802_11_ssid));
+       memset(&req_ssid, 0, sizeof(struct cfg80211_ssid));
 
        req_ssid.ssid_len = ssid_len;
        if (ssid_len > IEEE80211_MAX_SSID_LEN) {
@@ -872,6 +870,8 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
        priv->sec_info.wpa_enabled = false;
        priv->sec_info.wpa2_enabled = false;
        priv->wep_key_curr_index = 0;
+       priv->sec_info.encryption_mode = 0;
+       priv->sec_info.is_authtype_auto = 0;
        ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);
 
        if (mode == NL80211_IFTYPE_ADHOC) {
@@ -893,11 +893,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
        }
 
        /* Now handle infra mode. "sme" is valid for infra mode only */
-       if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC
-                       || sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
+       if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) {
                auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
-       else if (sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
-               auth_type = NL80211_AUTHTYPE_SHARED_KEY;
+               priv->sec_info.is_authtype_auto = 1;
+       } else {
+               auth_type = sme->auth_type;
+       }
 
        if (sme->crypto.n_ciphers_pairwise) {
                priv->sec_info.encryption_mode =
@@ -923,12 +924,6 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
                }
        }
 done:
-       /* Do specific SSID scanning */
-       if (mwifiex_request_scan(priv, &req_ssid)) {
-               dev_err(priv->adapter->dev, "scan error\n");
-               return -EFAULT;
-       }
-
        /*
         * Scan entries are valid for some time (15 sec). So we can save one
         * active scan time if we just try cfg80211_get_bss first. If it fails
@@ -1111,12 +1106,10 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
                dev_err(priv->adapter->dev, "failed to alloc scan_req\n");
                return -ENOMEM;
        }
-       for (i = 0; i < request->n_ssids; i++) {
-               memcpy(priv->user_scan_cfg->ssid_list[i].ssid,
-                       request->ssids[i].ssid, request->ssids[i].ssid_len);
-               priv->user_scan_cfg->ssid_list[i].max_len =
-                       request->ssids[i].ssid_len;
-       }
+
+       priv->user_scan_cfg->num_ssids = request->n_ssids;
+       priv->user_scan_cfg->ssid_list = request->ssids;
+
        for (i = 0; i < request->n_channels; i++) {
                chan = request->channels[i];
                priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
index 6623db69e1571693df899ccd6e26d03c8b92620b..c82eb7ff2fa26bb381626ec8059a3b550a450fe0 100644 (file)
@@ -771,7 +771,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
 
        /* Check init command response */
        if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) {
-               if (ret == -1) {
+               if (ret) {
                        dev_err(adapter->dev, "%s: cmd %#x failed during "
                                "initialization\n", __func__, cmdresp_no);
                        mwifiex_init_fw_complete(adapter);
@@ -781,10 +781,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
        }
 
        if (adapter->curr_cmd) {
-               if (adapter->curr_cmd->wait_q_enabled && (!ret))
-                       adapter->cmd_wait_q.status = 0;
-               else if (adapter->curr_cmd->wait_q_enabled && (ret == -1))
-                       adapter->cmd_wait_q.status = -1;
+               if (adapter->curr_cmd->wait_q_enabled)
+                       adapter->cmd_wait_q.status = ret;
 
                /* Clean up and put current command back to cmd_free_q */
                mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
index 3735c775495c24d4d0b6ef01e0be55426f71a3b9..be5fd1652e53a3d5930f14c42f4ec77439858373 100644 (file)
@@ -91,11 +91,6 @@ struct mwifiex_fw_image {
        u32 fw_len;
 };
 
-struct mwifiex_802_11_ssid {
-       u32 ssid_len;
-       u8 ssid[IEEE80211_MAX_SSID_LEN];
-};
-
 struct mwifiex_wait_queue {
        wait_queue_head_t wait;
        int status;
index 51c5417c569c42570e0a3300c59529c2c6af767c..fc4ffee6c6b9ce4021a52b94b5a336f4d4207898 100644 (file)
@@ -86,11 +86,6 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
        MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
 };
 
-enum MWIFIEX_802_11_WEP_STATUS {
-       MWIFIEX_802_11_WEP_ENABLED,
-       MWIFIEX_802_11_WEP_DISABLED,
-};
-
 #define CAL_SNR(RSSI, NF)              ((s16)((s16)(RSSI)-(s16)(NF)))
 
 #define PROPRIETARY_TLV_BASE_ID                 0x0100
@@ -857,11 +852,6 @@ struct mwifiex_user_scan_chan {
        u32 scan_time;
 } __packed;
 
-struct mwifiex_user_scan_ssid {
-       u8 ssid[IEEE80211_MAX_SSID_LEN + 1];
-       u8 max_len;
-} __packed;
-
 struct mwifiex_user_scan_cfg {
        /*
         *  BSS mode to be sent in the firmware command
@@ -872,8 +862,9 @@ struct mwifiex_user_scan_cfg {
        u8 reserved;
        /* BSSID filter sent in the firmware command to limit the results */
        u8 specific_bssid[ETH_ALEN];
-       /* SSID filter list used in the to limit the scan results */
-       struct mwifiex_user_scan_ssid ssid_list[MWIFIEX_MAX_SSID_LIST_LENGTH];
+       /* SSID filter list used in the firmware to limit the scan results */
+       struct cfg80211_ssid *ssid_list;
+       u8 num_ssids;
        /* Variable number (fixed maximum) of channels to scan up */
        struct mwifiex_user_scan_chan chan_list[MWIFIEX_USER_SCAN_CHAN_MAX];
 } __packed;
index ca59cc0d013ef7785647a1c6fe075ecf9d5b7556..e81bf6ef1666d3a9c55b8521eef6f34531771099 100644 (file)
@@ -82,7 +82,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
        priv->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;
        priv->data_avg_factor = DEFAULT_DATA_AVG_FACTOR;
 
-       priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
+       priv->sec_info.wep_enabled = 0;
        priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM;
        priv->sec_info.encryption_mode = 0;
        for (i = 0; i < ARRAY_SIZE(priv->wep_key); i++)
index d5d81f1fe41c9c5b310e21cf0778284a43478f86..7ca4e8234f3ee6512dc9599a6a3d2a3d1bcaa012 100644 (file)
@@ -50,7 +50,7 @@ struct mwifiex_chan_freq {
 };
 
 struct mwifiex_ssid_bssid {
-       struct mwifiex_802_11_ssid ssid;
+       struct cfg80211_ssid ssid;
        u8 bssid[ETH_ALEN];
 };
 
@@ -122,7 +122,7 @@ struct mwifiex_ver_ext {
 
 struct mwifiex_bss_info {
        u32 bss_mode;
-       struct mwifiex_802_11_ssid ssid;
+       struct cfg80211_ssid ssid;
        u32 bss_chan;
        u32 region_code;
        u32 media_connected;
index 0b0eb5efba9dd4206d08b8f79c817319ab4c8037..bce9991612c8cea2a01ec73ac8433165c07c47ed 100644 (file)
@@ -417,7 +417,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
        auth_tlv = (struct mwifiex_ie_types_auth_type *) pos;
        auth_tlv->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE);
        auth_tlv->header.len = cpu_to_le16(sizeof(auth_tlv->auth_type));
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
+       if (priv->sec_info.wep_enabled)
                auth_tlv->auth_type = cpu_to_le16(
                                (u16) priv->sec_info.authentication_mode);
        else
@@ -585,7 +585,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
                       le16_to_cpu(assoc_rsp->cap_info_bitmap),
                       le16_to_cpu(assoc_rsp->a_id));
 
-               ret = -1;
+               ret = le16_to_cpu(assoc_rsp->status_code);
                goto done;
        }
 
@@ -714,7 +714,7 @@ done:
 int
 mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
                                struct host_cmd_ds_command *cmd,
-                               struct mwifiex_802_11_ssid *req_ssid)
+                               struct cfg80211_ssid *req_ssid)
 {
        int rsn_ie_len = 0;
        struct mwifiex_adapter *adapter = priv->adapter;
@@ -1069,8 +1069,7 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
        priv->curr_bss_params.bss_descriptor.channel = bss_desc->channel;
        priv->curr_bss_params.band = (u8) bss_desc->bss_band;
 
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED
-           || priv->sec_info.wpa_enabled)
+       if (priv->sec_info.wep_enabled || priv->sec_info.wpa_enabled)
                tmp_cap |= WLAN_CAPABILITY_PRIVACY;
 
        if (IS_SUPPORT_MULTI_BANDS(priv->adapter)) {
@@ -1246,7 +1245,7 @@ int mwifiex_associate(struct mwifiex_private *priv,
  */
 int
 mwifiex_adhoc_start(struct mwifiex_private *priv,
-                   struct mwifiex_802_11_ssid *adhoc_ssid)
+                   struct cfg80211_ssid *adhoc_ssid)
 {
        dev_dbg(priv->adapter->dev, "info: Adhoc Channel = %d\n",
                priv->adhoc_channel);
index 52810b1497eadbf1718ebc2b24c466c5f8c841db..6dc116647411255741f2157b9063cb070b27bee3 100644 (file)
@@ -217,8 +217,9 @@ struct mwifiex_802_11_security {
        u8 wpa2_enabled;
        u8 wapi_enabled;
        u8 wapi_key_on;
-       enum MWIFIEX_802_11_WEP_STATUS wep_status;
+       u8 wep_enabled;
        u32 authentication_mode;
+       u8 is_authtype_auto;
        u32 encryption_mode;
 };
 
@@ -243,7 +244,7 @@ struct ieee_types_generic {
 
 struct mwifiex_bssdescriptor {
        u8 mac_address[ETH_ALEN];
-       struct mwifiex_802_11_ssid ssid;
+       struct cfg80211_ssid ssid;
        u32 privacy;
        s32 rssi;
        u32 channel;
@@ -387,7 +388,7 @@ struct mwifiex_private {
        s16 bcn_rssi_avg;
        s16 bcn_nf_avg;
        struct mwifiex_bssdescriptor *attempted_bss_desc;
-       struct mwifiex_802_11_ssid prev_ssid;
+       struct cfg80211_ssid prev_ssid;
        u8 prev_bssid[ETH_ALEN];
        struct mwifiex_current_bss_params curr_bss_params;
        u16 beacon_period;
@@ -746,8 +747,7 @@ void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
                            struct cmd_ctrl_node *cmd_node);
 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
                            struct host_cmd_ds_command *resp);
-s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
-                      struct mwifiex_802_11_ssid *ssid2);
+s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
 int mwifiex_associate(struct mwifiex_private *priv,
                      struct mwifiex_bssdescriptor *bss_desc);
 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
@@ -759,12 +759,12 @@ void mwifiex_reset_connect_state(struct mwifiex_private *priv);
 u8 mwifiex_band_to_radio_type(u8 band);
 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
 int mwifiex_adhoc_start(struct mwifiex_private *priv,
-                       struct mwifiex_802_11_ssid *adhoc_ssid);
+                       struct cfg80211_ssid *adhoc_ssid);
 int mwifiex_adhoc_join(struct mwifiex_private *priv,
                       struct mwifiex_bssdescriptor *bss_desc);
 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
                                    struct host_cmd_ds_command *cmd,
-                                   struct mwifiex_802_11_ssid *req_ssid);
+                                   struct cfg80211_ssid *req_ssid);
 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
                                   struct host_cmd_ds_command *cmd,
                                   struct mwifiex_bssdescriptor *bss_desc);
@@ -897,7 +897,7 @@ int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
                            struct net_device *dev);
 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
-                     struct mwifiex_802_11_ssid *req_ssid);
+                     struct cfg80211_ssid *req_ssid);
 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
@@ -906,13 +906,12 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv,
 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
                              struct mwifiex_rate_cfg *rate);
 int mwifiex_request_scan(struct mwifiex_private *priv,
-                        struct mwifiex_802_11_ssid *req_ssid);
+                        struct cfg80211_ssid *req_ssid);
 int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
                                struct mwifiex_user_scan_cfg *scan_req);
-int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel);
 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
 
-int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel);
+int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel);
 
 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
                       int key_len, u8 key_index, int disable);
index 98f1ca9cd6d862cb4169d465c8a20db7d4b202b6..fd0302fe5bd84a9ecc75a77efee5150600a0c9c2 100644 (file)
@@ -163,8 +163,7 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
  * This function compares two SSIDs and checks if they match.
  */
 s32
-mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
-                struct mwifiex_802_11_ssid *ssid2)
+mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2)
 {
        if (!ssid1 || !ssid2 || (ssid1->ssid_len != ssid2->ssid_len))
                return -1;
@@ -196,9 +195,8 @@ static bool
 mwifiex_is_network_compatible_for_no_sec(struct mwifiex_private *priv,
                                       struct mwifiex_bssdescriptor *bss_desc)
 {
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED
-           && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled
-           && ((!bss_desc->bcn_wpa_ie) ||
+       if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
+           !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) ||
                ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id !=
            WLAN_EID_WPA))
            && ((!bss_desc->bcn_rsn_ie) ||
@@ -219,9 +217,8 @@ static bool
 mwifiex_is_network_compatible_for_static_wep(struct mwifiex_private *priv,
                                       struct mwifiex_bssdescriptor *bss_desc)
 {
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED
-           && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled
-           && bss_desc->privacy) {
+       if (priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
+           !priv->sec_info.wpa2_enabled && bss_desc->privacy) {
                return true;
        }
        return false;
@@ -235,10 +232,9 @@ static bool
 mwifiex_is_network_compatible_for_wpa(struct mwifiex_private *priv,
                                      struct mwifiex_bssdescriptor *bss_desc)
 {
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED
-           && priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled
-           && ((bss_desc->bcn_wpa_ie) && ((*(bss_desc->bcn_wpa_ie)).vend_hdr.
-                                               element_id == WLAN_EID_WPA))
+       if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled &&
+           !priv->sec_info.wpa2_enabled && ((bss_desc->bcn_wpa_ie) &&
+           ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id == WLAN_EID_WPA))
           /*
            * Privacy bit may NOT be set in some APs like
            * LinkSys WRT54G && bss_desc->privacy
@@ -253,8 +249,7 @@ mwifiex_is_network_compatible_for_wpa(struct mwifiex_private *priv,
                        (bss_desc->bcn_rsn_ie) ?
                        (*(bss_desc->bcn_rsn_ie)).
                        ieee_hdr.element_id : 0,
-                       (priv->sec_info.wep_status ==
-                       MWIFIEX_802_11_WEP_ENABLED) ? "e" : "d",
+                       (priv->sec_info.wep_enabled) ? "e" : "d",
                        (priv->sec_info.wpa_enabled) ? "e" : "d",
                        (priv->sec_info.wpa2_enabled) ? "e" : "d",
                        priv->sec_info.encryption_mode,
@@ -272,10 +267,9 @@ static bool
 mwifiex_is_network_compatible_for_wpa2(struct mwifiex_private *priv,
                                       struct mwifiex_bssdescriptor *bss_desc)
 {
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED
-          && !priv->sec_info.wpa_enabled && priv->sec_info.wpa2_enabled
-          && ((bss_desc->bcn_rsn_ie) && ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.
-                                               element_id == WLAN_EID_RSN))
+       if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
+           priv->sec_info.wpa2_enabled && ((bss_desc->bcn_rsn_ie) &&
+           ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id == WLAN_EID_RSN))
           /*
            * Privacy bit may NOT be set in some APs like
            * LinkSys WRT54G && bss_desc->privacy
@@ -290,8 +284,7 @@ mwifiex_is_network_compatible_for_wpa2(struct mwifiex_private *priv,
                        (bss_desc->bcn_rsn_ie) ?
                        (*(bss_desc->bcn_rsn_ie)).
                        ieee_hdr.element_id : 0,
-                       (priv->sec_info.wep_status ==
-                       MWIFIEX_802_11_WEP_ENABLED) ? "e" : "d",
+                       (priv->sec_info.wep_enabled) ? "e" : "d",
                        (priv->sec_info.wpa_enabled) ? "e" : "d",
                        (priv->sec_info.wpa2_enabled) ? "e" : "d",
                        priv->sec_info.encryption_mode,
@@ -309,10 +302,9 @@ static bool
 mwifiex_is_network_compatible_for_adhoc_aes(struct mwifiex_private *priv,
                                       struct mwifiex_bssdescriptor *bss_desc)
 {
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED
-           && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled
-           && ((!bss_desc->bcn_wpa_ie) || ((*(bss_desc->bcn_wpa_ie)).vend_hdr.
-                  element_id != WLAN_EID_WPA))
+       if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
+           !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) ||
+           ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA))
            && ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.
                   element_id != WLAN_EID_RSN))
            && !priv->sec_info.encryption_mode
@@ -330,10 +322,9 @@ static bool
 mwifiex_is_network_compatible_for_dynamic_wep(struct mwifiex_private *priv,
                                       struct mwifiex_bssdescriptor *bss_desc)
 {
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED
-           && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled
-           && ((!bss_desc->bcn_wpa_ie) || ((*(bss_desc->bcn_wpa_ie)).vend_hdr.
-                  element_id != WLAN_EID_WPA))
+       if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
+           !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) ||
+           ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA))
            && ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.
                   element_id != WLAN_EID_RSN))
            && priv->sec_info.encryption_mode
@@ -468,8 +459,7 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv,
                       (bss_desc->bcn_rsn_ie) ?
                       (*(bss_desc->bcn_rsn_ie)).ieee_hdr.
                       element_id : 0,
-                      (priv->sec_info.wep_status ==
-                               MWIFIEX_802_11_WEP_ENABLED) ? "e" : "d",
+                      (priv->sec_info.wep_enabled) ? "e" : "d",
                       (priv->sec_info.wpa_enabled) ? "e" : "d",
                       (priv->sec_info.wpa2_enabled) ? "e" : "d",
                       priv->sec_info.encryption_mode, bss_desc->privacy);
@@ -747,7 +737,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
        u16 scan_dur;
        u8 channel;
        u8 radio_type;
-       u32 ssid_idx;
+       int i;
        u8 ssid_filter;
        u8 rates[MWIFIEX_SUPPORTED_RATES];
        u32 rates_size;
@@ -802,14 +792,8 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
                       user_scan_in->specific_bssid,
                       sizeof(scan_cfg_out->specific_bssid));
 
-               for (ssid_idx = 0;
-                    ((ssid_idx < ARRAY_SIZE(user_scan_in->ssid_list))
-                     && (*user_scan_in->ssid_list[ssid_idx].ssid
-                         || user_scan_in->ssid_list[ssid_idx].max_len));
-                    ssid_idx++) {
-
-                       ssid_len = strlen(user_scan_in->ssid_list[ssid_idx].
-                                         ssid) + 1;
+               for (i = 0; i < user_scan_in->num_ssids; i++) {
+                       ssid_len = user_scan_in->ssid_list[i].ssid_len;
 
                        wildcard_ssid_tlv =
                                (struct mwifiex_ie_types_wildcard_ssid_params *)
@@ -820,19 +804,26 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
                                (u16) (ssid_len + sizeof(wildcard_ssid_tlv->
                                                         max_ssid_length)));
 
-                       /* max_ssid_length = 0 tells firmware to perform
-                          specific scan for the SSID filled */
-                       wildcard_ssid_tlv->max_ssid_length = 0;
+                       /*
+                        * max_ssid_length = 0 tells firmware to perform
+                        * specific scan for the SSID filled, whereas
+                        * max_ssid_length = IEEE80211_MAX_SSID_LEN is for
+                        * wildcard scan.
+                        */
+                       if (ssid_len)
+                               wildcard_ssid_tlv->max_ssid_length = 0;
+                       else
+                               wildcard_ssid_tlv->max_ssid_length =
+                                                       IEEE80211_MAX_SSID_LEN;
 
                        memcpy(wildcard_ssid_tlv->ssid,
-                              user_scan_in->ssid_list[ssid_idx].ssid,
-                              ssid_len);
+                              user_scan_in->ssid_list[i].ssid, ssid_len);
 
                        tlv_pos += (sizeof(wildcard_ssid_tlv->header)
                                + le16_to_cpu(wildcard_ssid_tlv->header.len));
 
-                       dev_dbg(adapter->dev, "info: scan: ssid_list[%d]: %s, %d\n",
-                               ssid_idx, wildcard_ssid_tlv->ssid,
+                       dev_dbg(adapter->dev, "info: scan: ssid[%d]: %s, %d\n",
+                               i, wildcard_ssid_tlv->ssid,
                                wildcard_ssid_tlv->max_ssid_length);
 
                        /* Empty wildcard ssid with a maxlen will match many or
@@ -841,7 +832,6 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
                           filtered. */
                        if (!ssid_len && wildcard_ssid_tlv->max_ssid_length)
                                ssid_filter = false;
-
                }
 
                /*
@@ -850,7 +840,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
                 *  truncate scan results.  That is not an issue with an SSID
                 *  or BSSID filter applied to the scan results in the firmware.
                 */
-               if ((ssid_idx && ssid_filter)
+               if ((i && ssid_filter)
                    || memcmp(scan_cfg_out->specific_bssid, &zero_mac,
                              sizeof(zero_mac)))
                        *filtered_scan = true;
@@ -1860,7 +1850,7 @@ mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  * firmware, filtered on a specific SSID.
  */
 static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
-                                     struct mwifiex_802_11_ssid *req_ssid)
+                                     struct cfg80211_ssid *req_ssid)
 {
        struct mwifiex_adapter *adapter = priv->adapter;
        int ret = 0;
@@ -1886,8 +1876,8 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
                return -ENOMEM;
        }
 
-       memcpy(scan_cfg->ssid_list[0].ssid, req_ssid->ssid,
-              req_ssid->ssid_len);
+       scan_cfg->ssid_list = req_ssid;
+       scan_cfg->num_ssids = 1;
 
        ret = mwifiex_scan_networks(priv, scan_cfg);
 
@@ -1905,7 +1895,7 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
  * scan, depending upon whether an SSID is provided or not.
  */
 int mwifiex_request_scan(struct mwifiex_private *priv,
-                        struct mwifiex_802_11_ssid *req_ssid)
+                        struct cfg80211_ssid *req_ssid)
 {
        int ret;
 
index d7aa21da84d0124fd78a181da4bd7d711094c6eb..b9b59db60454b900087086dc34789adf95cbf0d6 100644 (file)
@@ -101,7 +101,7 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv)
 
        memcpy(&priv->prev_ssid,
               &priv->curr_bss_params.bss_descriptor.ssid,
-              sizeof(struct mwifiex_802_11_ssid));
+              sizeof(struct cfg80211_ssid));
 
        memcpy(priv->prev_bssid,
               priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
index b0fbf5d4fea0bd6fbc9b8b340339f1db145059ee..0ae1209646c14859e76cc311f3cfdff585b501d8 100644 (file)
@@ -192,7 +192,7 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
  * first.
  */
 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
-                     struct mwifiex_802_11_ssid *req_ssid)
+                     struct cfg80211_ssid *req_ssid)
 {
        int ret;
        struct mwifiex_adapter *adapter = priv->adapter;
@@ -249,6 +249,17 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
                 * application retrieval */
                priv->assoc_rsp_size = 0;
                ret = mwifiex_associate(priv, bss_desc);
+
+               /* If auth type is auto and association fails using open mode,
+                * try to connect using shared mode */
+               if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG &&
+                   priv->sec_info.is_authtype_auto &&
+                   priv->sec_info.wep_enabled) {
+                       priv->sec_info.authentication_mode =
+                                               NL80211_AUTHTYPE_SHARED_KEY;
+                       ret = mwifiex_associate(priv, bss_desc);
+               }
+
                if (bss)
                        cfg80211_put_bss(bss);
        } else {
@@ -453,8 +464,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
 
        info->bss_mode = priv->bss_mode;
 
-       memcpy(&info->ssid, &bss_desc->ssid,
-              sizeof(struct mwifiex_802_11_ssid));
+       memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid));
 
        memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
 
@@ -471,7 +481,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
 
        info->bcn_nf_last = priv->bcn_nf_last;
 
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
+       if (priv->sec_info.wep_enabled)
                info->wep_status = true;
        else
                info->wep_status = false;
@@ -599,7 +609,7 @@ static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
  *          - Start/Join the IBSS
  */
 int
-mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
+mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel)
 {
        int ret;
        struct mwifiex_bss_info bss_info;
@@ -636,7 +646,7 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
        ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
 
        ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
-                                            (u16 *) &channel);
+                                            &channel);
 
        /* Do specific SSID scanning */
        if (mwifiex_request_scan(priv, &bss_info.ssid)) {
@@ -1020,7 +1030,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
        wep_key = &priv->wep_key[priv->wep_key_curr_index];
        index = encrypt_key->key_index;
        if (encrypt_key->key_disable) {
-               priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
+               priv->sec_info.wep_enabled = 0;
        } else if (!encrypt_key->key_len) {
                /* Copy the required key as the current key */
                wep_key = &priv->wep_key[index];
@@ -1030,7 +1040,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
                        return -1;
                }
                priv->wep_key_curr_index = (u16) index;
-               priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
+               priv->sec_info.wep_enabled = 1;
        } else {
                wep_key = &priv->wep_key[index];
                memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
@@ -1040,7 +1050,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
                       encrypt_key->key_len);
                wep_key->key_index = index;
                wep_key->key_length = encrypt_key->key_len;
-               priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
+               priv->sec_info.wep_enabled = 1;
        }
        if (wep_key->key_length) {
                /* Send request to firmware */
@@ -1050,7 +1060,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
                if (ret)
                        return ret;
        }
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
+       if (priv->sec_info.wep_enabled)
                priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
        else
                priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
index 40f4eb7da7b296e3d01227f625a24f4be401fdd6..ee8af1f047c8834f3f5cf5be4952616b6f44e5f9 100644 (file)
@@ -227,6 +227,7 @@ static int p54_add_interface(struct ieee80211_hw *dev,
                             struct ieee80211_vif *vif)
 {
        struct p54_common *priv = dev->priv;
+       int err;
 
        vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
 
@@ -251,9 +252,9 @@ static int p54_add_interface(struct ieee80211_hw *dev,
        }
 
        memcpy(priv->mac_addr, vif->addr, ETH_ALEN);
-       p54_setup_mac(priv);
+       err = p54_setup_mac(priv);
        mutex_unlock(&priv->conf_mutex);
-       return 0;
+       return err;
 }
 
 static void p54_remove_interface(struct ieee80211_hw *dev,
index b1f51a215792028783223984dec8f0b0ac1a8f17..45df728183fdec6b4bd12017a154103d7069821f 100644 (file)
@@ -624,36 +624,39 @@ static void __devexit p54p_remove(struct pci_dev *pdev)
 }
 
 #ifdef CONFIG_PM
-static int p54p_suspend(struct pci_dev *pdev, pm_message_t state)
+static int p54p_suspend(struct device *device)
 {
-       struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-       struct p54p_priv *priv = dev->priv;
-
-       if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
-               ieee80211_stop_queues(dev);
-               p54p_stop(dev);
-       }
+       struct pci_dev *pdev = to_pci_dev(device);
 
        pci_save_state(pdev);
-       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       pci_set_power_state(pdev, PCI_D3hot);
+       pci_disable_device(pdev);
        return 0;
 }
 
-static int p54p_resume(struct pci_dev *pdev)
+static int p54p_resume(struct device *device)
 {
-       struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-       struct p54p_priv *priv = dev->priv;
+       struct pci_dev *pdev = to_pci_dev(device);
+       int err;
 
-       pci_set_power_state(pdev, PCI_D0);
-       pci_restore_state(pdev);
+       err = pci_reenable_device(pdev);
+       if (err)
+               return err;
+       return pci_set_power_state(pdev, PCI_D0);
+}
 
-       if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
-               p54p_open(dev);
-               ieee80211_wake_queues(dev);
-       }
+static const struct dev_pm_ops p54pci_pm_ops = {
+       .suspend = p54p_suspend,
+       .resume = p54p_resume,
+       .freeze = p54p_suspend,
+       .thaw = p54p_resume,
+       .poweroff = p54p_suspend,
+       .restore = p54p_resume,
+};
 
-       return 0;
-}
+#define P54P_PM_OPS (&p54pci_pm_ops)
+#else
+#define P54P_PM_OPS (NULL)
 #endif /* CONFIG_PM */
 
 static struct pci_driver p54p_driver = {
@@ -661,10 +664,7 @@ static struct pci_driver p54p_driver = {
        .id_table       = p54p_table,
        .probe          = p54p_probe,
        .remove         = __devexit_p(p54p_remove),
-#ifdef CONFIG_PM
-       .suspend        = p54p_suspend,
-       .resume         = p54p_resume,
-#endif /* CONFIG_PM */
+       .driver.pm      = P54P_PM_OPS,
 };
 
 static int __init p54p_init(void)
index 7faed62c63786a629c64cfbd423dc228227e8768..f7929906d4371bd59ccdc0ad14ca6a9d5dff7a39 100644 (file)
@@ -618,19 +618,19 @@ static int __devinit p54spi_probe(struct spi_device *spi)
        ret = spi_setup(spi);
        if (ret < 0) {
                dev_err(&priv->spi->dev, "spi_setup failed");
-               goto err_free_common;
+               goto err_free;
        }
 
        ret = gpio_request(p54spi_gpio_power, "p54spi power");
        if (ret < 0) {
                dev_err(&priv->spi->dev, "power GPIO request failed: %d", ret);
-               goto err_free_common;
+               goto err_free;
        }
 
        ret = gpio_request(p54spi_gpio_irq, "p54spi irq");
        if (ret < 0) {
                dev_err(&priv->spi->dev, "irq GPIO request failed: %d", ret);
-               goto err_free_common;
+               goto err_free_gpio_power;
        }
 
        gpio_direction_output(p54spi_gpio_power, 0);
@@ -641,7 +641,7 @@ static int __devinit p54spi_probe(struct spi_device *spi)
                          priv->spi);
        if (ret < 0) {
                dev_err(&priv->spi->dev, "request_irq() failed");
-               goto err_free_common;
+               goto err_free_gpio_irq;
        }
 
        irq_set_irq_type(gpio_to_irq(p54spi_gpio_irq), IRQ_TYPE_EDGE_RISING);
@@ -673,6 +673,12 @@ static int __devinit p54spi_probe(struct spi_device *spi)
        return 0;
 
 err_free_common:
+       free_irq(gpio_to_irq(p54spi_gpio_irq), spi);
+err_free_gpio_irq:
+       gpio_free(p54spi_gpio_irq);
+err_free_gpio_power:
+       gpio_free(p54spi_gpio_power);
+err_free:
        p54_free_common(priv->hw);
        return ret;
 }
index 42b97bc3847717fa017d923fd840c6c12261bd8a..a08a6f0e4dd118064606754e3fbd3be369d7bee5 100644 (file)
@@ -690,7 +690,7 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
        if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))
                *flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
 
-       if (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)
+       if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)
                *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
 
        if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
index a330c69583d62a07dc935ebef2c617b4ee135496..d66e2980bc27bab54ddd06867a8fccd50f6cfb0c 100644 (file)
@@ -518,7 +518,7 @@ struct rndis_wlan_private {
        __le32 current_command_oid;
 
        /* encryption stuff */
-       int  encr_tx_key_index;
+       u8 encr_tx_key_index;
        struct rndis_wlan_encr_key encr_keys[RNDIS_WLAN_NUM_KEYS];
        int  wpa_version;
 
@@ -634,7 +634,7 @@ static u32 get_bcm4320_power_dbm(struct rndis_wlan_private *priv)
        }
 }
 
-static bool is_wpa_key(struct rndis_wlan_private *priv, int idx)
+static bool is_wpa_key(struct rndis_wlan_private *priv, u8 idx)
 {
        int cipher = priv->encr_keys[idx].cipher;
 
@@ -1350,7 +1350,7 @@ static int set_channel(struct usbnet *usbdev, int channel)
 }
 
 static struct ieee80211_channel *get_current_channel(struct usbnet *usbdev,
-                                                    u16 *beacon_interval)
+                                                    u32 *beacon_period)
 {
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
        struct ieee80211_channel *channel;
@@ -1370,14 +1370,14 @@ static struct ieee80211_channel *get_current_channel(struct usbnet *usbdev,
        if (!channel)
                return NULL;
 
-       if (beacon_interval)
-               *beacon_interval = le16_to_cpu(config.beacon_period);
+       if (beacon_period)
+               *beacon_period = le32_to_cpu(config.beacon_period);
        return channel;
 }
 
 /* index must be 0 - N, as per NDIS  */
 static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len,
-                                                               int index)
+                                                               u8 index)
 {
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
        struct ndis_80211_wep_key ndis_key;
@@ -1387,13 +1387,15 @@ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len,
        netdev_dbg(usbdev->net, "%s(idx: %d, len: %d)\n",
                   __func__, index, key_len);
 
-       if ((key_len != 5 && key_len != 13) || index < 0 || index > 3)
+       if (index >= RNDIS_WLAN_NUM_KEYS)
                return -EINVAL;
 
        if (key_len == 5)
                cipher = WLAN_CIPHER_SUITE_WEP40;
-       else
+       else if (key_len == 13)
                cipher = WLAN_CIPHER_SUITE_WEP104;
+       else
+               return -EINVAL;
 
        memset(&ndis_key, 0, sizeof(ndis_key));
 
@@ -1428,7 +1430,7 @@ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len,
 }
 
 static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
-                       int index, const u8 *addr, const u8 *rx_seq,
+                       u8 index, const u8 *addr, const u8 *rx_seq,
                        int seq_len, u32 cipher, __le32 flags)
 {
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
@@ -1436,7 +1438,7 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
        bool is_addr_ok;
        int ret;
 
-       if (index < 0 || index >= 4) {
+       if (index >= RNDIS_WLAN_NUM_KEYS) {
                netdev_dbg(usbdev->net, "%s(): index out of range (%i)\n",
                           __func__, index);
                return -EINVAL;
@@ -1524,7 +1526,7 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
        return 0;
 }
 
-static int restore_key(struct usbnet *usbdev, int key_idx)
+static int restore_key(struct usbnet *usbdev, u8 key_idx)
 {
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
        struct rndis_wlan_encr_key key;
@@ -1550,13 +1552,13 @@ static void restore_keys(struct usbnet *usbdev)
                restore_key(usbdev, i);
 }
 
-static void clear_key(struct rndis_wlan_private *priv, int idx)
+static void clear_key(struct rndis_wlan_private *priv, u8 idx)
 {
        memset(&priv->encr_keys[idx], 0, sizeof(priv->encr_keys[idx]));
 }
 
 /* remove_key is for both wep and wpa */
-static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid)
+static int remove_key(struct usbnet *usbdev, u8 index, const u8 *bssid)
 {
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
        struct ndis_80211_remove_key remove_key;
@@ -1790,9 +1792,9 @@ static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev,
                                                struct cfg80211_pmksa *pmksa,
                                                int max_pmkids)
 {
-       int i, len, count, newlen, err;
+       int i, newlen, err;
+       unsigned int count;
 
-       len = le32_to_cpu(pmkids->length);
        count = le32_to_cpu(pmkids->bssid_info_count);
 
        if (count > max_pmkids)
@@ -1831,9 +1833,9 @@ static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
                                                struct cfg80211_pmksa *pmksa,
                                                int max_pmkids)
 {
-       int i, err, len, count, newlen;
+       int i, err, newlen;
+       unsigned int count;
 
-       len = le32_to_cpu(pmkids->length);
        count = le32_to_cpu(pmkids->bssid_info_count);
 
        if (count > max_pmkids)
@@ -2683,7 +2685,7 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid,
        s32 signal;
        u64 timestamp;
        u16 capability;
-       u16 beacon_interval = 0;
+       u32 beacon_period = 0;
        __le32 rssi;
        u8 ie_buf[34];
        int len, ret, ie_len;
@@ -2708,7 +2710,7 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid,
        }
 
        /* Get channel and beacon interval */
-       channel = get_current_channel(usbdev, &beacon_interval);
+       channel = get_current_channel(usbdev, &beacon_period);
        if (!channel) {
                netdev_warn(usbdev->net, "%s(): could not get channel.\n",
                                        __func__);
@@ -2738,11 +2740,11 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid,
        netdev_dbg(usbdev->net, "%s(): channel:%d(freq), bssid:[%pM], tsf:%d, "
                "capa:%x, beacon int:%d, resp_ie(len:%d, essid:'%.32s'), "
                "signal:%d\n", __func__, (channel ? channel->center_freq : -1),
-               bssid, (u32)timestamp, capability, beacon_interval, ie_len,
+               bssid, (u32)timestamp, capability, beacon_period, ie_len,
                ssid.essid, signal);
 
        bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid,
-               timestamp, capability, beacon_interval, ie_buf, ie_len,
+               timestamp, capability, beacon_period, ie_buf, ie_len,
                signal, GFP_KERNEL);
        cfg80211_put_bss(bss);
 }
@@ -2755,9 +2757,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
        struct ndis_80211_assoc_info *info = NULL;
        u8 bssid[ETH_ALEN];
-       int resp_ie_len, req_ie_len;
+       unsigned int resp_ie_len, req_ie_len;
+       unsigned int offset;
        u8 *req_ie, *resp_ie;
-       int ret, offset;
+       int ret;
        bool roamed = false;
        bool match_bss;
 
@@ -2785,7 +2788,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
                ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
                if (!ret) {
                        req_ie_len = le32_to_cpu(info->req_ie_length);
-                       if (req_ie_len > 0) {
+                       if (req_ie_len > CONTROL_BUFFER_SIZE)
+                               req_ie_len = CONTROL_BUFFER_SIZE;
+                       if (req_ie_len != 0) {
                                offset = le32_to_cpu(info->offset_req_ies);
 
                                if (offset > CONTROL_BUFFER_SIZE)
@@ -2799,7 +2804,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
                        }
 
                        resp_ie_len = le32_to_cpu(info->resp_ie_length);
-                       if (resp_ie_len > 0) {
+                       if (resp_ie_len > CONTROL_BUFFER_SIZE)
+                               resp_ie_len = CONTROL_BUFFER_SIZE;
+                       if (resp_ie_len != 0) {
                                offset = le32_to_cpu(info->offset_resp_ies);
 
                                if (offset > CONTROL_BUFFER_SIZE)
@@ -3038,7 +3045,7 @@ static void rndis_wlan_media_specific_indication(struct usbnet *usbdev,
                        struct rndis_indicate *msg, int buflen)
 {
        struct ndis_80211_status_indication *indication;
-       int len, offset;
+       unsigned int len, offset;
 
        offset = offsetof(struct rndis_indicate, status) +
                        le32_to_cpu(msg->offset);
@@ -3050,7 +3057,7 @@ static void rndis_wlan_media_specific_indication(struct usbnet *usbdev,
                return;
        }
 
-       if (offset + len > buflen) {
+       if (len > buflen || offset > buflen || offset + len > buflen) {
                netdev_info(usbdev->net, "media specific indication, too large to fit to buffer (%i > %i)\n",
                            offset + len, buflen);
                return;
index dfe485a872f6cbaf1bb43a80e9eb6c9fb41d5155..49a51b4195ef7a4a652a428c75cab5d8e2887f26 100644 (file)
@@ -1236,7 +1236,8 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
                cancel_work_sync(&rt2x00dev->rxdone_work);
                cancel_work_sync(&rt2x00dev->txdone_work);
        }
-       destroy_workqueue(rt2x00dev->workqueue);
+       if (rt2x00dev->workqueue)
+               destroy_workqueue(rt2x00dev->workqueue);
 
        /*
         * Free the tx status fifo.
index 638fbef693e676372e39c2f20d7a2e7127c1a083..cf53ac9d6f23f2787561883f15985a974abb7f8d 100644 (file)
@@ -8,7 +8,7 @@
  * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al.
  *
  * The driver was extended to the RTL8187B in 2008 by:
- *     Herton Ronaldo Krzesinski <herton@mandriva.com.br>
+ *     Herton Ronaldo Krzesinski <herton@mandriva.com.br>
  *     Hin-Tak Leung <htl10@users.sourceforge.net>
  *     Larry Finger <Larry.Finger@lwfinger.net>
  *
@@ -232,6 +232,7 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
 {
        struct rtl8187_priv *priv = dev->priv;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_hdr *tx_hdr =  (struct ieee80211_hdr *)(skb->data);
        unsigned int ep;
        void *buf;
        struct urb *urb;
@@ -249,7 +250,7 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
        flags |= RTL818X_TX_DESC_FLAG_NO_ENC;
 
        flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24;
-       if (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control))
+       if (ieee80211_has_morefrags(tx_hdr->frame_control))
                flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
        if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
                flags |= RTL818X_TX_DESC_FLAG_RTS;
@@ -261,6 +262,13 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
                flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
        }
 
+       if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
+               if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
+                       priv->seqno += 0x10;
+               tx_hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
+               tx_hdr->seq_ctrl |= cpu_to_le16(priv->seqno);
+       }
+
        if (!priv->is_rtl8187b) {
                struct rtl8187_tx_hdr *hdr =
                        (struct rtl8187_tx_hdr *)skb_push(skb, sizeof(*hdr));
@@ -274,8 +282,6 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
        } else {
                /* fc needs to be calculated before skb_push() */
                unsigned int epmap[4] = { 6, 7, 5, 4 };
-               struct ieee80211_hdr *tx_hdr =
-                       (struct ieee80211_hdr *)(skb->data);
                u16 fc = le16_to_cpu(tx_hdr->frame_control);
 
                struct rtl8187b_tx_hdr *hdr =
@@ -1031,10 +1037,61 @@ static void rtl8187_stop(struct ieee80211_hw *dev)
                cancel_delayed_work_sync(&priv->work);
 }
 
+static u64 rtl8187_get_tsf(struct ieee80211_hw *dev, struct ieee80211_vif *vif)
+{
+       struct rtl8187_priv *priv = dev->priv;
+
+       return rtl818x_ioread32(priv, &priv->map->TSFT[0]) |
+              (u64)(rtl818x_ioread32(priv, &priv->map->TSFT[1])) << 32;
+}
+
+
+static void rtl8187_beacon_work(struct work_struct *work)
+{
+       struct rtl8187_vif *vif_priv =
+               container_of(work, struct rtl8187_vif, beacon_work.work);
+       struct ieee80211_vif *vif =
+               container_of((void *)vif_priv, struct ieee80211_vif, drv_priv);
+       struct ieee80211_hw *dev = vif_priv->dev;
+       struct ieee80211_mgmt *mgmt;
+       struct sk_buff *skb;
+
+       /* don't overflow the tx ring */
+       if (ieee80211_queue_stopped(dev, 0))
+               goto resched;
+
+       /* grab a fresh beacon */
+       skb = ieee80211_beacon_get(dev, vif);
+       if (!skb)
+               goto resched;
+
+       /*
+        * update beacon timestamp w/ TSF value
+        * TODO: make hardware update beacon timestamp
+        */
+       mgmt = (struct ieee80211_mgmt *)skb->data;
+       mgmt->u.beacon.timestamp = cpu_to_le64(rtl8187_get_tsf(dev, vif));
+
+       /* TODO: use actual beacon queue */
+       skb_set_queue_mapping(skb, 0);
+
+       rtl8187_tx(dev, skb);
+
+resched:
+       /*
+        * schedule next beacon
+        * TODO: use hardware support for beacon timing
+        */
+       schedule_delayed_work(&vif_priv->beacon_work,
+                       usecs_to_jiffies(1024 * vif->bss_conf.beacon_int));
+}
+
+
 static int rtl8187_add_interface(struct ieee80211_hw *dev,
                                 struct ieee80211_vif *vif)
 {
        struct rtl8187_priv *priv = dev->priv;
+       struct rtl8187_vif *vif_priv;
        int i;
        int ret = -EOPNOTSUPP;
 
@@ -1044,6 +1101,7 @@ static int rtl8187_add_interface(struct ieee80211_hw *dev,
 
        switch (vif->type) {
        case NL80211_IFTYPE_STATION:
+       case NL80211_IFTYPE_ADHOC:
                break;
        default:
                goto exit;
@@ -1052,6 +1110,13 @@ static int rtl8187_add_interface(struct ieee80211_hw *dev,
        ret = 0;
        priv->vif = vif;
 
+       /* Initialize driver private area */
+       vif_priv = (struct rtl8187_vif *)&vif->drv_priv;
+       vif_priv->dev = dev;
+       INIT_DELAYED_WORK(&vif_priv->beacon_work, rtl8187_beacon_work);
+       vif_priv->enable_beacon = false;
+
+
        rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
        for (i = 0; i < ETH_ALEN; i++)
                rtl818x_iowrite8(priv, &priv->map->MAC[i],
@@ -1175,9 +1240,12 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
                                     u32 changed)
 {
        struct rtl8187_priv *priv = dev->priv;
+       struct rtl8187_vif *vif_priv;
        int i;
        u8 reg;
 
+       vif_priv = (struct rtl8187_vif *)&vif->drv_priv;
+
        if (changed & BSS_CHANGED_BSSID) {
                mutex_lock(&priv->conf_mutex);
                for (i = 0; i < ETH_ALEN; i++)
@@ -1189,8 +1257,12 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
                else
                        reg = 0;
 
-               if (is_valid_ether_addr(info->bssid))
-                       reg |= RTL818X_MSR_INFRA;
+               if (is_valid_ether_addr(info->bssid)) {
+                       if (vif->type == NL80211_IFTYPE_ADHOC)
+                               reg |= RTL818X_MSR_ADHOC;
+                       else
+                               reg |= RTL818X_MSR_INFRA;
+               }
                else
                        reg |= RTL818X_MSR_NO_LINK;
 
@@ -1202,6 +1274,16 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
        if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_ERP_PREAMBLE))
                rtl8187_conf_erp(priv, info->use_short_slot,
                                 info->use_short_preamble);
+
+       if (changed & BSS_CHANGED_BEACON_ENABLED)
+               vif_priv->enable_beacon = info->enable_beacon;
+
+       if (changed & (BSS_CHANGED_BEACON_ENABLED | BSS_CHANGED_BEACON)) {
+               cancel_delayed_work_sync(&vif_priv->beacon_work);
+               if (vif_priv->enable_beacon)
+                       schedule_work(&vif_priv->beacon_work.work);
+       }
+
 }
 
 static u64 rtl8187_prepare_multicast(struct ieee80211_hw *dev,
@@ -1279,13 +1361,6 @@ static int rtl8187_conf_tx(struct ieee80211_hw *dev,
        return 0;
 }
 
-static u64 rtl8187_get_tsf(struct ieee80211_hw *dev, struct ieee80211_vif *vif)
-{
-       struct rtl8187_priv *priv = dev->priv;
-
-       return rtl818x_ioread32(priv, &priv->map->TSFT[0]) |
-              (u64)(rtl818x_ioread32(priv, &priv->map->TSFT[1])) << 32;
-}
 
 static const struct ieee80211_ops rtl8187_ops = {
        .tx                     = rtl8187_tx,
@@ -1514,12 +1589,9 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
                if (reg & 0xFF00)
                        priv->rfkill_mask = RFKILL_MASK_8198;
        }
-
-       /*
-        * XXX: Once this driver supports anything that requires
-        *      beacons it must implement IEEE80211_TX_CTL_ASSIGN_SEQ.
-        */
-       dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+       dev->vif_data_size = sizeof(struct rtl8187_vif);
+       dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
+                                     BIT(NL80211_IFTYPE_ADHOC) ;
 
        if ((id->driver_info == DEVICE_RTL8187) && priv->is_rtl8187b)
                printk(KERN_INFO "rtl8187: inconsistency between id with OEM"
index f1cc90751dbf519a576f5baee035e94aa183e378..e19a20a8e9558f38549df067334ad1b8ce81b793 100644 (file)
@@ -89,6 +89,14 @@ enum {
        DEVICE_RTL8187B
 };
 
+struct rtl8187_vif {
+       struct ieee80211_hw *dev;
+
+       /* beaconing */
+       struct delayed_work beacon_work;
+       bool enable_beacon;
+};
+
 struct rtl8187_priv {
        /* common between rtl818x drivers */
        struct rtl818x_csr *map;
@@ -141,6 +149,7 @@ struct rtl8187_priv {
                __le32 bits32;
        } *io_dmabuf;
        bool rfkill_off;
+       u16 seqno;
 };
 
 void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
index cb5535cf3ae2567c53919bf17cfdf7f14255ae46..d8d73dbb57804559d04ea92828455ed72f76c8ee 100644 (file)
@@ -520,6 +520,10 @@ void rtl92c_dm_write_dig(struct ieee80211_hw *hw)
                 dm_digtable.cur_igvalue, dm_digtable.pre_igvalue,
                 dm_digtable.backoff_val);
 
+       dm_digtable.cur_igvalue += 2;
+       if (dm_digtable.cur_igvalue > 0x3f)
+               dm_digtable.cur_igvalue = 0x3f;
+
        if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) {
                rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f,
                              dm_digtable.cur_igvalue);
@@ -1201,13 +1205,18 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw)
                                 "PreState = %d, CurState = %d\n",
                                 p_ra->pre_ratr_state, p_ra->ratr_state);
 
-                       rcu_read_lock();
-                       sta = ieee80211_find_sta(mac->vif, mac->bssid);
+                       /* Only the PCI card uses sta in the update rate table
+                        * callback routine */
+                       if (rtlhal->interface == INTF_PCI) {
+                               rcu_read_lock();
+                               sta = ieee80211_find_sta(mac->vif, mac->bssid);
+                       }
                        rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
                                        p_ra->ratr_state);
 
                        p_ra->pre_ratr_state = p_ra->ratr_state;
-                       rcu_read_unlock();
+                       if (rtlhal->interface == INTF_PCI)
+                               rcu_read_unlock();
                }
        }
 }
index ffcf89fe45e4045f457b02d95c2ffc22c54151d5..2e1e352864bb88ad33489402aee1f19ef2aa4154 100644 (file)
@@ -346,9 +346,14 @@ static int _rtl_usb_init(struct ieee80211_hw *hw)
                         pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize,
                         pep_desc->bInterval);
        }
-       if (rtlusb->in_ep_nums <  rtlpriv->cfg->usb_interface_cfg->in_ep_num)
-               return -EINVAL ;
-
+       if (rtlusb->in_ep_nums <  rtlpriv->cfg->usb_interface_cfg->in_ep_num) {
+               pr_err("Too few input end points found\n");
+               return -EINVAL;
+       }
+       if (rtlusb->out_ep_nums == 0) {
+               pr_err("No output end points found\n");
+               return -EINVAL;
+       }
        /* usb endpoint mapping */
        err = rtlpriv->cfg->usb_interface_cfg->usb_endpoint_mapping(hw);
        rtlusb->usb_mq_to_hwq =  rtlpriv->cfg->usb_interface_cfg->usb_mq_to_hwq;
@@ -357,7 +362,7 @@ static int _rtl_usb_init(struct ieee80211_hw *hw)
        return err;
 }
 
-static int _rtl_usb_init_sw(struct ieee80211_hw *hw)
+static void rtl_usb_init_sw(struct ieee80211_hw *hw)
 {
        struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -392,7 +397,6 @@ static int _rtl_usb_init_sw(struct ieee80211_hw *hw)
        /* HIMR_EX - turn all on */
        rtlusb->irq_mask[1] = 0xFFFFFFFF;
        rtlusb->disableHWSM =  true;
-       return 0;
 }
 
 #define __RADIO_TAP_SIZE_RSV   32
@@ -976,7 +980,9 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
        }
        rtlpriv->cfg->ops->init_sw_leds(hw);
        err = _rtl_usb_init(hw);
-       err = _rtl_usb_init_sw(hw);
+       if (err)
+               goto error_out;
+       rtl_usb_init_sw(hw);
        /* Init mac80211 sw */
        err = rtl_init_core(hw);
        if (err) {
index 98a574a4a465004728792a293551ae867f450d6c..9fcde36d5013d9435d0070e2eadd4c36f5dc21aa 100644 (file)
@@ -306,9 +306,19 @@ int zd_op_start(struct ieee80211_hw *hw)
        r = set_mc_hash(mac);
        if (r)
                goto disable_int;
+
+       /* Wait after setting the multicast hash table and powering on
+        * the radio otherwise interface bring up will fail. This matches
+        * what the vendor driver did.
+        */
+       msleep(10);
+
        r = zd_chip_switch_radio_on(chip);
-       if (r < 0)
+       if (r < 0) {
+               dev_err(zd_chip_dev(chip),
+                       "%s: failed to set radio on\n", __func__);
                goto disable_int;
+       }
        r = zd_chip_enable_rxtx(chip);
        if (r < 0)
                goto disable_radio;
index 1a1500bc845233dc1537ea2b05c35379c33907e5..cb6204f783002dc3ddcc79adebcc79fa61cc4392 100644 (file)
@@ -736,6 +736,8 @@ static int pn533_target_found_type_a(struct nfc_target *nfc_tgt, u8 *tgt_data,
 
        nfc_tgt->sens_res = be16_to_cpu(tgt_type_a->sens_res);
        nfc_tgt->sel_res = tgt_type_a->sel_res;
+       nfc_tgt->nfcid1_len = tgt_type_a->nfcid_len;
+       memcpy(nfc_tgt->nfcid1, tgt_type_a->nfcid_data, nfc_tgt->nfcid1_len);
 
        return 0;
 }
@@ -781,6 +783,9 @@ static int pn533_target_found_felica(struct nfc_target *nfc_tgt, u8 *tgt_data,
        else
                nfc_tgt->supported_protocols = NFC_PROTO_FELICA_MASK;
 
+       memcpy(nfc_tgt->sensf_res, &tgt_felica->opcode, 9);
+       nfc_tgt->sensf_res_len = 9;
+
        return 0;
 }
 
@@ -823,6 +828,8 @@ static int pn533_target_found_jewel(struct nfc_target *nfc_tgt, u8 *tgt_data,
 
        nfc_tgt->supported_protocols = NFC_PROTO_JEWEL_MASK;
        nfc_tgt->sens_res = be16_to_cpu(tgt_jewel->sens_res);
+       nfc_tgt->nfcid1_len = 4;
+       memcpy(nfc_tgt->nfcid1, tgt_jewel->jewelid, nfc_tgt->nfcid1_len);
 
        return 0;
 }
@@ -902,6 +909,8 @@ static int pn533_target_found(struct pn533 *dev,
        if (resp->tg != 1)
                return -EPROTO;
 
+       memset(&nfc_tgt, 0, sizeof(struct nfc_target));
+
        target_data_len = resp_len - sizeof(struct pn533_poll_response);
 
        switch (dev->poll_mod_curr) {
@@ -1307,6 +1316,8 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
                nfc_dev_dbg(&dev->interface->dev, "Creating new target");
 
                nfc_target.supported_protocols = NFC_PROTO_NFC_DEP_MASK;
+               nfc_target.nfcid1_len = 10;
+               memcpy(nfc_target.nfcid1, resp->nfcid3t, nfc_target.nfcid1_len);
                rc = nfc_targets_found(dev->nfc_dev, &nfc_target, 1);
                if (rc)
                        return 0;
@@ -1329,21 +1340,15 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
 }
 
 static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx,
-                                               u8 comm_mode, u8 rf_mode)
+                            u8 comm_mode, u8* gb, size_t gb_len)
 {
        struct pn533 *dev = nfc_get_drvdata(nfc_dev);
        struct pn533_cmd_jump_dep *cmd;
-       u8 cmd_len, local_gt_len, *local_gt;
+       u8 cmd_len;
        int rc;
 
        nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
 
-       if (rf_mode == NFC_RF_TARGET) {
-               nfc_dev_err(&dev->interface->dev, "Target mode not supported");
-               return -EOPNOTSUPP;
-       }
-
-
        if (dev->poll_mod_count) {
                nfc_dev_err(&dev->interface->dev,
                                "Cannot bring the DEP link up while polling");
@@ -1356,11 +1361,7 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx,
                return -EBUSY;
        }
 
-       local_gt = nfc_get_local_general_bytes(dev->nfc_dev, &local_gt_len);
-       if (local_gt_len > NFC_MAX_GT_LEN)
-               return -EINVAL;
-
-       cmd_len = sizeof(struct pn533_cmd_jump_dep) + local_gt_len;
+       cmd_len = sizeof(struct pn533_cmd_jump_dep) + gb_len;
        cmd = kzalloc(cmd_len, GFP_KERNEL);
        if (cmd == NULL)
                return -ENOMEM;
@@ -1369,9 +1370,9 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx,
 
        cmd->active = !comm_mode;
        cmd->baud = 0;
-       if (local_gt != NULL) {
+       if (gb != NULL && gb_len > 0) {
                cmd->next = 4; /* We have some Gi */
-               memcpy(cmd->gt, local_gt, local_gt_len);
+               memcpy(cmd->gt, gb, gb_len);
        } else {
                cmd->next = 0;
        }
index befa89eac6f3c9319d913744eb2ffd4b29a12ced..ed4124469a3a34493088db68b725c081620ab81d 100644 (file)
@@ -331,7 +331,6 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
 {
        int i;
        u16 v;
-       s8 gain;
        u16 loc[3];
 
        if (out->revision == 3)                 /* rev 3 moved MAC */
@@ -390,20 +389,12 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
                SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
 
        /* Extract the antenna gain values. */
-       gain = r123_extract_antgain(out->revision, in,
-                                   SSB_SPROM1_AGAIN_BG,
-                                   SSB_SPROM1_AGAIN_BG_SHIFT);
-       out->antenna_gain.ghz24.a0 = gain;
-       out->antenna_gain.ghz24.a1 = gain;
-       out->antenna_gain.ghz24.a2 = gain;
-       out->antenna_gain.ghz24.a3 = gain;
-       gain = r123_extract_antgain(out->revision, in,
-                                   SSB_SPROM1_AGAIN_A,
-                                   SSB_SPROM1_AGAIN_A_SHIFT);
-       out->antenna_gain.ghz5.a0 = gain;
-       out->antenna_gain.ghz5.a1 = gain;
-       out->antenna_gain.ghz5.a2 = gain;
-       out->antenna_gain.ghz5.a3 = gain;
+       out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
+                                                   SSB_SPROM1_AGAIN_BG,
+                                                   SSB_SPROM1_AGAIN_BG_SHIFT);
+       out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
+                                                   SSB_SPROM1_AGAIN_A,
+                                                   SSB_SPROM1_AGAIN_A_SHIFT);
 }
 
 /* Revs 4 5 and 8 have partially shared layout */
@@ -504,16 +495,14 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
        }
 
        /* Extract the antenna gain values. */
-       SPEX(antenna_gain.ghz24.a0, SSB_SPROM4_AGAIN01,
+       SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
             SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
-       SPEX(antenna_gain.ghz24.a1, SSB_SPROM4_AGAIN01,
+       SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
             SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
-       SPEX(antenna_gain.ghz24.a2, SSB_SPROM4_AGAIN23,
+       SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
             SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
-       SPEX(antenna_gain.ghz24.a3, SSB_SPROM4_AGAIN23,
+       SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
             SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
-       memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
-              sizeof(out->antenna_gain.ghz5));
 
        sprom_extract_r458(out, in);
 
@@ -602,16 +591,14 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
        SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
 
        /* Extract the antenna gain values. */
-       SPEX(antenna_gain.ghz24.a0, SSB_SPROM8_AGAIN01,
+       SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
             SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
-       SPEX(antenna_gain.ghz24.a1, SSB_SPROM8_AGAIN01,
+       SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
             SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
-       SPEX(antenna_gain.ghz24.a2, SSB_SPROM8_AGAIN23,
+       SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
             SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
-       SPEX(antenna_gain.ghz24.a3, SSB_SPROM8_AGAIN23,
+       SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
             SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
-       memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
-              sizeof(out->antenna_gain.ghz5));
 
        /* Extract cores power info info */
        for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
index c821c6b2a6a0b778da37a7994ad1ad2d57335428..fbafed5b729bdcf6ae57889c3c9d4f05ca0509c5 100644 (file)
@@ -676,14 +676,10 @@ static int ssb_pcmcia_do_get_invariants(struct pcmcia_device *p_dev,
        case SSB_PCMCIA_CIS_ANTGAIN:
                GOTO_ERROR_ON(tuple->TupleDataLen != 2,
                        "antg tpl size");
-               sprom->antenna_gain.ghz24.a0 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz24.a1 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz24.a2 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz24.a3 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz5.a0 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz5.a1 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz5.a2 = tuple->TupleData[1];
-               sprom->antenna_gain.ghz5.a3 = tuple->TupleData[1];
+               sprom->antenna_gain.a0 = tuple->TupleData[1];
+               sprom->antenna_gain.a1 = tuple->TupleData[1];
+               sprom->antenna_gain.a2 = tuple->TupleData[1];
+               sprom->antenna_gain.a3 = tuple->TupleData[1];
                break;
        case SSB_PCMCIA_CIS_BFLAGS:
                GOTO_ERROR_ON((tuple->TupleDataLen != 3) &&
index 63fd709038caed0d7bbb70121159f27028bd0b41..b2d36f7736c537ef5ba6ec65d6144f965b75f971 100644 (file)
@@ -551,14 +551,10 @@ int ssb_sdio_get_invariants(struct ssb_bus *bus,
                        case SSB_SDIO_CIS_ANTGAIN:
                                GOTO_ERROR_ON(tuple->size != 2,
                                              "antg tpl size");
-                               sprom->antenna_gain.ghz24.a0 = tuple->data[1];
-                               sprom->antenna_gain.ghz24.a1 = tuple->data[1];
-                               sprom->antenna_gain.ghz24.a2 = tuple->data[1];
-                               sprom->antenna_gain.ghz24.a3 = tuple->data[1];
-                               sprom->antenna_gain.ghz5.a0 = tuple->data[1];
-                               sprom->antenna_gain.ghz5.a1 = tuple->data[1];
-                               sprom->antenna_gain.ghz5.a2 = tuple->data[1];
-                               sprom->antenna_gain.ghz5.a3 = tuple->data[1];
+                               sprom->antenna_gain.a0 = tuple->data[1];
+                               sprom->antenna_gain.a1 = tuple->data[1];
+                               sprom->antenna_gain.a2 = tuple->data[1];
+                               sprom->antenna_gain.a3 = tuple->data[1];
                                break;
                        case SSB_SDIO_CIS_BFLAGS:
                                GOTO_ERROR_ON((tuple->size != 3) &&
index b9f65fbee42f0bdaa8515b46a180817092efda3f..5af9a075498f144fa3c6ea6d86744201a65428b7 100644 (file)
@@ -176,6 +176,12 @@ int __bcma_driver_register(struct bcma_driver *drv, struct module *owner);
 
 extern void bcma_driver_unregister(struct bcma_driver *drv);
 
+/* Set a fallback SPROM.
+ * See kdoc at the function definition for complete documentation. */
+extern int bcma_arch_register_fallback_sprom(
+               int (*sprom_callback)(struct bcma_bus *bus,
+               struct ssb_sprom *out));
+
 struct bcma_bus {
        /* The MMIO area. */
        void __iomem *mmio;
@@ -284,6 +290,7 @@ static inline void bcma_maskset16(struct bcma_device *cc,
        bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set);
 }
 
+extern struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid);
 extern bool bcma_core_is_enabled(struct bcma_device *core);
 extern void bcma_core_disable(struct bcma_device *core, u32 flags);
 extern int bcma_core_enable(struct bcma_device *core, u32 flags);
index e72938b1071431dcbef56e80d2bbd9fff5bfc228..8bbfe31fbac864db2fa60e9edeef149097d3a32e 100644 (file)
@@ -56,6 +56,9 @@
 #define         BCMA_CC_OTPS_HW_PROTECT        0x00000001
 #define         BCMA_CC_OTPS_SW_PROTECT        0x00000002
 #define         BCMA_CC_OTPS_CID_PROTECT       0x00000004
+#define  BCMA_CC_OTPS_GU_PROG_IND      0x00000F00      /* General Use programmed indication */
+#define  BCMA_CC_OTPS_GU_PROG_IND_SHIFT        8
+#define  BCMA_CC_OTPS_GU_PROG_HW       0x00000100      /* HW region programmed */
 #define BCMA_CC_OTPC                   0x0014          /* OTP control */
 #define         BCMA_CC_OTPC_RECWAIT           0xFF000000
 #define         BCMA_CC_OTPC_PROGWAIT          0x00FFFF00
@@ -72,6 +75,8 @@
 #define         BCMA_CC_OTPP_READ              0x40000000
 #define         BCMA_CC_OTPP_START             0x80000000
 #define         BCMA_CC_OTPP_BUSY              0x80000000
+#define BCMA_CC_OTPL                   0x001C          /* OTP layout */
+#define  BCMA_CC_OTPL_GURGN_OFFSET     0x00000FFF      /* offset of general use region */
 #define BCMA_CC_IRQSTAT                        0x0020
 #define BCMA_CC_IRQMASK                        0x0024
 #define         BCMA_CC_IRQ_GPIO               0x00000001      /* gpio intr */
 #define         BCMA_CC_IRQ_WDRESET            0x80000000      /* watchdog reset occurred */
 #define BCMA_CC_CHIPCTL                        0x0028          /* Rev >= 11 only */
 #define BCMA_CC_CHIPSTAT               0x002C          /* Rev >= 11 only */
+#define  BCMA_CC_CHIPST_4313_SPROM_PRESENT     1
+#define  BCMA_CC_CHIPST_4313_OTP_PRESENT       2
+#define  BCMA_CC_CHIPST_4331_SPROM_PRESENT     2
+#define  BCMA_CC_CHIPST_4331_OTP_PRESENT       4
 #define BCMA_CC_JCMD                   0x0030          /* Rev >= 10 only */
 #define  BCMA_CC_JCMD_START            0x80000000
 #define  BCMA_CC_JCMD_BUSY             0x80000000
 #define BCMA_CC_PLLCTL_ADDR            0x0660
 #define BCMA_CC_PLLCTL_DATA            0x0664
 #define BCMA_CC_SPROM                  0x0800 /* SPROM beginning */
-#define BCMA_CC_SPROM_PCIE6            0x0830 /* SPROM beginning on PCIe rev >= 6 */
 
 /* Divider allocation in 4716/47162/5356 */
 #define BCMA_CC_PMU5_MAINPLL_CPU       1
index b4999abcb2a240f28b1e1afa659ac9cb4ff78ee2..39c1fcf089c0a99ec654d4c5fb190eda696dd665 100644 (file)
@@ -107,6 +107,7 @@ enum nfc_attrs {
        NFC_ATTR_TARGET_SENSF_RES,
        NFC_ATTR_COMM_MODE,
        NFC_ATTR_RF_MODE,
+       NFC_ATTR_DEVICE_POWERED,
 /* private: internal use only */
        __NFC_ATTR_AFTER_LAST
 };
index be35a68746a7f7f932acc39b48f10511d47b3393..c37d67add090b0cc45cd9555ee886e5ff7d7f091 100644 (file)
  *     %NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID,
  *     %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE,
  *     %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS,
- *     %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY and
- *     %NL80211_ATTR_AUTH_TYPE.
+ *     %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ *     %NL80211_ATTR_AUTH_TYPE and %NL80211_ATTR_INACTIVITY_TIMEOUT.
  * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP
  * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface
  * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
@@ -1197,6 +1197,16 @@ enum nl80211_commands {
  * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of
  *      up to 16 TIDs.
  *
+ * @NL80211_ATTR_INACTIVITY_TIMEOUT: timeout value in seconds, this can be
+ *     used by the drivers which has MLME in firmware and does not have support
+ *     to report per station tx/rx activity to free up the staion entry from
+ *     the list. This needs to be used when the driver advertises the
+ *     capability to timeout the stations.
+ *
+ * @NL80211_ATTR_RX_SIGNAL_DBM: signal strength in dBm (as a 32-bit int);
+ *     this attribute is (depending on the driver capabilities) added to
+ *     received frames indicated with %NL80211_CMD_FRAME.
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -1442,6 +1452,10 @@ enum nl80211_attrs {
 
        NL80211_ATTR_NOACK_MAP,
 
+       NL80211_ATTR_INACTIVITY_TIMEOUT,
+
+       NL80211_ATTR_RX_SIGNAL_DBM,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
@@ -2112,6 +2126,10 @@ enum nl80211_mntr_flags {
  * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
  * or forwarding entity (default is TRUE - forwarding entity)
  *
+ * @NL80211_MESHCONF_RSSI_THRESHOLD: RSSI threshold in dBm. This specifies the
+ * threshold for average signal strength of candidate station to establish
+ * a peer link.
+ *
  * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
  *
  * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
@@ -2137,6 +2155,7 @@ enum nl80211_meshconf_params {
        NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
        NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
        NL80211_MESHCONF_FORWARDING,
+       NL80211_MESHCONF_RSSI_THRESHOLD,
 
        /* keep last */
        __NL80211_MESHCONF_ATTR_AFTER_LAST,
@@ -2804,10 +2823,13 @@ enum nl80211_ap_sme_features {
  *     TX status to the socket error queue when requested with the
  *     socket option.
  * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
+ * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
+ *     the connected inactive stations in AP mode.
  */
 enum nl80211_feature_flags {
        NL80211_FEATURE_SK_TX_STATUS    = 1 << 0,
        NL80211_FEATURE_HT_IBSS         = 1 << 1,
+       NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
 };
 
 /**
index bbc2612cb64a83b75dc03484eb8c345e4bac98de..d2768318002519510971a60a156ff32591f6790c 100644 (file)
@@ -19,7 +19,7 @@ struct ssb_driver;
 struct ssb_sprom_core_pwr_info {
        u8 itssi_2g, itssi_5g;
        u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
-       u16 pa_2g[3], pa_5gl[3], pa_5g[3], pa_5gh[3];
+       u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
 };
 
 struct ssb_sprom {
@@ -32,9 +32,12 @@ struct ssb_sprom {
        u8 et0mdcport;          /* MDIO for enet0 */
        u8 et1mdcport;          /* MDIO for enet1 */
        u16 board_rev;          /* Board revision number from SPROM. */
+       u16 board_num;          /* Board number from SPROM. */
+       u16 board_type;         /* Board type from SPROM. */
        u8 country_code;        /* Country Code */
-       u16 leddc_on_time;      /* LED Powersave Duty Cycle On Count */
-       u16 leddc_off_time;     /* LED Powersave Duty Cycle Off Count */
+       char alpha2[2];         /* Country Code as two chars like EU or US */
+       u8 leddc_on_time;       /* LED Powersave Duty Cycle On Count */
+       u8 leddc_off_time;      /* LED Powersave Duty Cycle Off Count */
        u8 ant_available_a;     /* 2GHz antenna available bits (up to 4) */
        u8 ant_available_bg;    /* 5GHz antenna available bits (up to 4) */
        u16 pa0b0;
@@ -53,10 +56,10 @@ struct ssb_sprom {
        u8 gpio1;               /* GPIO pin 1 */
        u8 gpio2;               /* GPIO pin 2 */
        u8 gpio3;               /* GPIO pin 3 */
-       u16 maxpwr_bg;          /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
-       u16 maxpwr_al;          /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
-       u16 maxpwr_a;           /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
-       u16 maxpwr_ah;          /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
+       u8 maxpwr_bg;           /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
+       u8 maxpwr_al;           /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
+       u8 maxpwr_a;            /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
+       u8 maxpwr_ah;           /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
        u8 itssi_a;             /* Idle TSSI Target for A-PHY */
        u8 itssi_bg;            /* Idle TSSI Target for B/G-PHY */
        u8 tri2g;               /* 2.4GHz TX isolation */
@@ -67,8 +70,8 @@ struct ssb_sprom {
        u8 txpid5gl[4];         /* 4.9 - 5.1GHz TX power index */
        u8 txpid5g[4];          /* 5.1 - 5.5GHz TX power index */
        u8 txpid5gh[4];         /* 5.5 - ...GHz TX power index */
-       u8 rxpo2g;              /* 2GHz RX power offset */
-       u8 rxpo5g;              /* 5GHz RX power offset */
+       s8 rxpo2g;              /* 2GHz RX power offset */
+       s8 rxpo5g;              /* 5GHz RX power offset */
        u8 rssisav2g;           /* 2GHz RSSI params */
        u8 rssismc2g;
        u8 rssismf2g;
@@ -94,12 +97,7 @@ struct ssb_sprom {
         * on each band. Values in dBm/4 (Q5.2). Negative gain means the
         * loss in the connectors is bigger than the gain. */
        struct {
-               struct {
-                       s8 a0, a1, a2, a3;
-               } ghz24;        /* 2.4GHz band */
-               struct {
-                       s8 a0, a1, a2, a3;
-               } ghz5;         /* 5GHz band */
+               s8 a0, a1, a2, a3;
        } antenna_gain;
 
        struct {
@@ -111,7 +109,79 @@ struct ssb_sprom {
                } ghz5;
        } fem;
 
-       /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */
+       u16 mcs2gpo[8];
+       u16 mcs5gpo[8];
+       u16 mcs5glpo[8];
+       u16 mcs5ghpo[8];
+       u8 opo;
+
+       u8 rxgainerr2ga[3];
+       u8 rxgainerr5gla[3];
+       u8 rxgainerr5gma[3];
+       u8 rxgainerr5gha[3];
+       u8 rxgainerr5gua[3];
+
+       u8 noiselvl2ga[3];
+       u8 noiselvl5gla[3];
+       u8 noiselvl5gma[3];
+       u8 noiselvl5gha[3];
+       u8 noiselvl5gua[3];
+
+       u8 regrev;
+       u8 txchain;
+       u8 rxchain;
+       u8 antswitch;
+       u16 cddpo;
+       u16 stbcpo;
+       u16 bw40po;
+       u16 bwduppo;
+
+       u8 tempthresh;
+       u8 tempoffset;
+       u16 rawtempsense;
+       u8 measpower;
+       u8 tempsense_slope;
+       u8 tempcorrx;
+       u8 tempsense_option;
+       u8 freqoffset_corr;
+       u8 iqcal_swp_dis;
+       u8 hw_iqcal_en;
+       u8 elna2g;
+       u8 elna5g;
+       u8 phycal_tempdelta;
+       u8 temps_period;
+       u8 temps_hysteresis;
+       u8 measpower1;
+       u8 measpower2;
+       u8 pcieingress_war;
+
+       /* power per rate from sromrev 9 */
+       u16 cckbw202gpo;
+       u16 cckbw20ul2gpo;
+       u32 legofdmbw202gpo;
+       u32 legofdmbw20ul2gpo;
+       u32 legofdmbw205glpo;
+       u32 legofdmbw20ul5glpo;
+       u32 legofdmbw205gmpo;
+       u32 legofdmbw20ul5gmpo;
+       u32 legofdmbw205ghpo;
+       u32 legofdmbw20ul5ghpo;
+       u32 mcsbw202gpo;
+       u32 mcsbw20ul2gpo;
+       u32 mcsbw402gpo;
+       u32 mcsbw205glpo;
+       u32 mcsbw20ul5glpo;
+       u32 mcsbw405glpo;
+       u32 mcsbw205gmpo;
+       u32 mcsbw20ul5gmpo;
+       u32 mcsbw405gmpo;
+       u32 mcsbw205ghpo;
+       u32 mcsbw20ul5ghpo;
+       u32 mcsbw405ghpo;
+       u16 mcs32po;
+       u16 legofdm40duppo;
+       u8 sar2g;
+       u8 sar5g;
 };
 
 /* Information about the PCB the circuitry is soldered on. */
index 755a7707a7c5c2ac27f20d87540d4a4dcd8ffc97..57c9fddc2acf41514a067622e33cf418d3b3d9a6 100644 (file)
@@ -413,6 +413,7 @@ struct cfg80211_beacon_data {
  * @crypto: crypto settings
  * @privacy: the BSS uses privacy
  * @auth_type: Authentication type (algorithm)
+ * @inactivity_timeout: time in seconds to determine station's inactivity.
  */
 struct cfg80211_ap_settings {
        struct cfg80211_beacon_data beacon;
@@ -424,6 +425,7 @@ struct cfg80211_ap_settings {
        struct cfg80211_crypto_settings crypto;
        bool privacy;
        enum nl80211_auth_type auth_type;
+       int inactivity_timeout;
 };
 
 /**
@@ -809,6 +811,7 @@ struct mesh_config {
         * Still keeping the same nomenclature to be in sync with the spec. */
        bool  dot11MeshGateAnnouncementProtocol;
        bool dot11MeshForwarding;
+       s32 rssi_threshold;
 };
 
 /**
@@ -1356,12 +1359,10 @@ struct cfg80211_gtk_rekey_data {
  *
  * @set_rekey_data: give the data necessary for GTK rekeying to the driver
  *
- * @add_beacon: Add a beacon with given parameters, @head, @interval
- *     and @dtim_period will be valid, @tail is optional.
- * @set_beacon: Change the beacon parameters for an access point mode
- *     interface. This should reject the call when no beacon has been
- *     configured.
- * @del_beacon: Remove beacon configuration and stop sending the beacon.
+ * @start_ap: Start acting in AP mode defined by the parameters.
+ * @change_beacon: Change the beacon parameters for an access point mode
+ *     interface. This should reject the call when AP mode wasn't started.
+ * @stop_ap: Stop being an AP, including stopping beaconing.
  *
  * @add_station: Add a new station.
  * @del_station: Remove a station; @mac may be NULL to remove all stations.
@@ -1587,11 +1588,9 @@ struct cfg80211_ops {
        int     (*assoc)(struct wiphy *wiphy, struct net_device *dev,
                         struct cfg80211_assoc_request *req);
        int     (*deauth)(struct wiphy *wiphy, struct net_device *dev,
-                         struct cfg80211_deauth_request *req,
-                         void *cookie);
+                         struct cfg80211_deauth_request *req);
        int     (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
-                           struct cfg80211_disassoc_request *req,
-                           void *cookie);
+                           struct cfg80211_disassoc_request *req);
 
        int     (*connect)(struct wiphy *wiphy, struct net_device *dev,
                           struct cfg80211_connect_params *sme);
@@ -3190,6 +3189,7 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
  * cfg80211_rx_mgmt - notification of received, unprocessed management frame
  * @dev: network device
  * @freq: Frequency on which the frame was received in MHz
+ * @sig_dbm: signal strength in mBm, or 0 if unknown
  * @buf: Management frame (header + body)
  * @len: length of the frame data
  * @gfp: context flags
@@ -3202,8 +3202,8 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
  * This function is called whenever an Action frame is received for a station
  * mode interface, but is not processed in kernel.
  */
-bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
-                     size_t len, gfp_t gfp);
+bool cfg80211_rx_mgmt(struct net_device *dev, int freq, int sig_dbm,
+                     const u8 *buf, size_t len, gfp_t gfp);
 
 /**
  * cfg80211_mgmt_tx_status - notification of TX status for management frame
@@ -3316,6 +3316,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
  * @frame: the frame
  * @len: length of the frame
  * @freq: frequency the frame was received on
+ * @sig_dbm: signal strength in mBm, or 0 if unknown
  * @gfp: allocation flags
  *
  * Use this function to report to userspace when a beacon was
@@ -3324,7 +3325,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
  */
 void cfg80211_report_obss_beacon(struct wiphy *wiphy,
                                 const u8 *frame, size_t len,
-                                int freq, gfp_t gfp);
+                                int freq, int sig_dbm, gfp_t gfp);
 
 /*
  * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
@@ -3336,6 +3337,14 @@ int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
                                 struct ieee80211_channel *chan,
                                 enum nl80211_channel_type channel_type);
 
+/*
+ * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
+ * @rate: given rate_info to calculate bitrate from
+ *
+ * return 0 if MCS index >= 32
+ */
+u16 cfg80211_calculate_bitrate(struct rate_info *rate);
+
 /* Logging, debugging and troubleshooting/diagnostic helpers. */
 
 /* wiphy_printk helpers, similar to dev_printk */
index cbff4f94a2002465db85e0143175e1ccef6c7f2f..c06974accfa661a5c61eddb60cf4b0ca1aaad3a9 100644 (file)
@@ -341,9 +341,9 @@ struct ieee80211_bss_conf {
  *     used to indicate that a frame was already retried due to PS
  * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
  *     used to indicate frame should not be encrypted
- * @IEEE80211_TX_CTL_POLL_RESPONSE: This frame is a response to a poll
- *     frame (PS-Poll or uAPSD) and should be sent although the station
- *     is in powersave mode.
+ * @IEEE80211_TX_CTL_NO_PS_BUFFER: This frame is a response to a poll
+ *     frame (PS-Poll or uAPSD) or a non-bufferable MMPDU and must
+ *     be sent although the station is in powersave mode.
  * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
  *     transmit function after the current frame, this can be used
  *     by drivers to kick the DMA queue only if unset or when the
@@ -399,7 +399,7 @@ enum mac80211_tx_control_flags {
        IEEE80211_TX_INTFL_NEED_TXPROCESSING    = BIT(14),
        IEEE80211_TX_INTFL_RETRIED              = BIT(15),
        IEEE80211_TX_INTFL_DONT_ENCRYPT         = BIT(16),
-       IEEE80211_TX_CTL_POLL_RESPONSE          = BIT(17),
+       IEEE80211_TX_CTL_NO_PS_BUFFER           = BIT(17),
        IEEE80211_TX_CTL_MORE_FRAMES            = BIT(18),
        IEEE80211_TX_INTFL_RETRANSMISSION       = BIT(19),
        /* hole at 20, use later */
@@ -425,7 +425,7 @@ enum mac80211_tx_control_flags {
        IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU |           \
        IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK |               \
        IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK |           \
-       IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_POLL_RESPONSE |   \
+       IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_NO_PS_BUFFER |    \
        IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC |                \
        IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP)
 
@@ -659,6 +659,8 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
  * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
  * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
  * @RX_FLAG_SHORT_GI: Short guard interval was used
+ * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present.
+ *     Valid only for data frames (mainly A-MPDU)
  */
 enum mac80211_rx_flags {
        RX_FLAG_MMIC_ERROR      = 1<<0,
@@ -672,6 +674,7 @@ enum mac80211_rx_flags {
        RX_FLAG_HT              = 1<<9,
        RX_FLAG_40MHZ           = 1<<10,
        RX_FLAG_SHORT_GI        = 1<<11,
+       RX_FLAG_NO_SIGNAL_VAL   = 1<<12,
 };
 
 /**
@@ -1634,7 +1637,7 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
  * the station sends a PS-Poll or a uAPSD trigger frame, mac80211
  * will inform the driver of this with the @allow_buffered_frames
  * callback; this callback is optional. mac80211 will then transmit
- * the frames as usual and set the %IEEE80211_TX_CTL_POLL_RESPONSE
+ * the frames as usual and set the %IEEE80211_TX_CTL_NO_PS_BUFFER
  * on each frame. The last frame in the service period (or the only
  * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to
  * indicate that it ends the service period; as this frame must have
@@ -1642,6 +1645,9 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
  * When TX status is reported for this frame, the service period is
  * marked has having ended and a new one can be started by the peer.
  *
+ * Additionally, non-bufferable MMPDUs can also be transmitted by
+ * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them.
+ *
  * Another race condition can happen on some devices like iwlwifi
  * when there are frames queued for the station and it wakes up
  * or polls; the frames that are already queued could end up being
@@ -2140,7 +2146,7 @@ enum ieee80211_frame_release_type {
  * @allow_buffered_frames: Prepare device to allow the given number of frames
  *     to go out to the given station. The frames will be sent by mac80211
  *     via the usual TX path after this call. The TX information for frames
- *     released will also have the %IEEE80211_TX_CTL_POLL_RESPONSE flag set
+ *     released will also have the %IEEE80211_TX_CTL_NO_PS_BUFFER flag set
  *     and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case
  *     frames from multiple TIDs are released and the driver might reorder
  *     them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag
index 86fee8b5c65c54f05471ad07969596710758487c..feba74027ff8bc18674c68625f8f6e5a9cd6562f 100644 (file)
@@ -141,17 +141,17 @@ struct nci_dev {
 
 /* ----- NCI Devices ----- */
 struct nci_dev *nci_allocate_device(struct nci_ops *ops,
-                               __u32 supported_protocols,
-                               int tx_headroom,
-                               int tx_tailroom);
+                                   __u32 supported_protocols,
+                                   int tx_headroom,
+                                   int tx_tailroom);
 void nci_free_device(struct nci_dev *ndev);
 int nci_register_device(struct nci_dev *ndev);
 void nci_unregister_device(struct nci_dev *ndev);
 int nci_recv_frame(struct sk_buff *skb);
 
 static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev,
-                                               unsigned int len,
-                                               gfp_t how)
+                                           unsigned int len,
+                                           gfp_t how)
 {
        struct sk_buff *skb;
 
index d253278e5a96e9af9ca8775b446f8811c807770d..bac070bf3514188c589b1769484abacfa8470ca1 100644 (file)
@@ -53,15 +53,15 @@ struct nfc_ops {
        int (*dev_down)(struct nfc_dev *dev);
        int (*start_poll)(struct nfc_dev *dev, u32 protocols);
        void (*stop_poll)(struct nfc_dev *dev);
-       int (*dep_link_up)(struct nfc_dev *dev, int target_idx,
-                               u8 comm_mode, u8 rf_mode);
+       int (*dep_link_up)(struct nfc_dev *dev, int target_idx, u8 comm_mode,
+                          u8 *gb, size_t gb_len);
        int (*dep_link_down)(struct nfc_dev *dev);
        int (*activate_target)(struct nfc_dev *dev, u32 target_idx,
-                                                       u32 protocol);
+                              u32 protocol);
        void (*deactivate_target)(struct nfc_dev *dev, u32 target_idx);
        int (*data_exchange)(struct nfc_dev *dev, u32 target_idx,
-                               struct sk_buff *skb, data_exchange_cb_t cb,
-                                                       void *cb_context);
+                            struct sk_buff *skb, data_exchange_cb_t cb,
+                            void *cb_context);
 };
 
 #define NFC_TARGET_IDX_ANY -1
@@ -110,9 +110,9 @@ struct nfc_dev {
 extern struct class nfc_class;
 
 struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
-                                       u32 supported_protocols,
-                                       int tx_headroom,
-                                       int tx_tailroom);
+                                   u32 supported_protocols,
+                                   int tx_headroom,
+                                   int tx_tailroom);
 
 /**
  * nfc_free_device - free nfc device
@@ -135,7 +135,7 @@ void nfc_unregister_device(struct nfc_dev *dev);
  * @dev: The parent device
  */
 static inline void nfc_set_parent_dev(struct nfc_dev *nfc_dev,
-                                       struct device *dev)
+                                     struct device *dev)
 {
        nfc_dev->dev.parent = dev;
 }
@@ -172,17 +172,15 @@ static inline const char *nfc_device_name(struct nfc_dev *dev)
 }
 
 struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
-                                       unsigned int flags, unsigned int size,
-                                       unsigned int *err);
+                                  unsigned int flags, unsigned int size,
+                                  unsigned int *err);
 struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp);
 
 int nfc_set_remote_general_bytes(struct nfc_dev *dev,
-                                       u8 *gt, u8 gt_len);
+                                u8 *gt, u8 gt_len);
 
-u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len);
-
-int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
-                                                       int ntargets);
+int nfc_targets_found(struct nfc_dev *dev,
+                     struct nfc_target *targets, int ntargets);
 
 int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
                       u8 comm_mode, u8 rf_mode);
index f7eb25aabf8ff12d1f117a38b549886156774698..677d65929780ad147a531657f30ee26f6b52ae82 100644 (file)
@@ -336,6 +336,20 @@ static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, in
                rate->mcs = idx;
 }
 
+void sta_set_rate_info_tx(struct sta_info *sta,
+                         const struct ieee80211_tx_rate *rate,
+                         struct rate_info *rinfo)
+{
+       rinfo->flags = 0;
+       if (rate->flags & IEEE80211_TX_RC_MCS)
+               rinfo->flags |= RATE_INFO_FLAGS_MCS;
+       if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+               rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
+       if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
+               rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
+       rate_idx_to_bitrate(rinfo, sta, rate->idx);
+}
+
 static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
 {
        struct ieee80211_sub_if_data *sdata = sta->sdata;
@@ -378,14 +392,7 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
                sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
        }
 
-       sinfo->txrate.flags = 0;
-       if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
-               sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
-       if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
-               sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
-       if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
-               sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
-       rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx);
+       sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
 
        sinfo->rxrate.flags = 0;
        if (sta->last_rx_rate_flag & RX_FLAG_HT)
@@ -1314,6 +1321,14 @@ static int ieee80211_update_mesh_config(struct wiphy *wiphy,
        }
        if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
                conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
+       if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
+               /* our RSSI threshold implementation is supported only for
+                * devices that report signal in dBm.
+                */
+               if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
+                       return -ENOTSUPP;
+               conf->rssi_threshold = nconf->rssi_threshold;
+       }
        return 0;
 }
 
@@ -1595,19 +1610,15 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
 }
 
 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
-                           struct cfg80211_deauth_request *req,
-                           void *cookie)
+                           struct cfg80211_deauth_request *req)
 {
-       return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev),
-                                   req, cookie);
+       return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
 }
 
 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
-                             struct cfg80211_disassoc_request *req,
-                             void *cookie)
+                             struct cfg80211_disassoc_request *req)
 {
-       return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev),
-                                     req, cookie);
+       return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
 }
 
 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
index 510ed1dab3c7eb1d9b179451f7f7c68a58a91272..f6de8a65f4020e70d7a630608eea166f6ef6b430 100644 (file)
@@ -443,6 +443,7 @@ IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol,
 IEEE80211_IF_FILE(dot11MeshHWMPRannInterval,
                u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC);
 IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC);
+IEEE80211_IF_FILE(rssi_threshold, u.mesh.mshcfg.rssi_threshold, DEC);
 #endif
 
 
@@ -537,11 +538,15 @@ static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
 
 #ifdef CONFIG_MAC80211_MESH
 
+static void add_mesh_files(struct ieee80211_sub_if_data *sdata)
+{
+       DEBUGFS_ADD_MODE(tsf, 0600);
+}
+
 static void add_mesh_stats(struct ieee80211_sub_if_data *sdata)
 {
        struct dentry *dir = debugfs_create_dir("mesh_stats",
                                                sdata->debugfs.dir);
-
 #define MESHSTATS_ADD(name)\
        debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
 
@@ -581,6 +586,7 @@ static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
        MESHPARAMS_ADD(dot11MeshHWMPRootMode);
        MESHPARAMS_ADD(dot11MeshHWMPRannInterval);
        MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol);
+       MESHPARAMS_ADD(rssi_threshold);
 #undef MESHPARAMS_ADD
 }
 #endif
@@ -593,6 +599,7 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
        switch (sdata->vif.type) {
        case NL80211_IFTYPE_MESH_POINT:
 #ifdef CONFIG_MAC80211_MESH
+               add_mesh_files(sdata);
                add_mesh_stats(sdata);
                add_mesh_config(sdata);
 #endif
index 7f9ac577600a27419ba8c5f8728117efe913cad8..33fd8d9f714ec05db8aeba88d0bb5c6bf97e8fd0 100644 (file)
@@ -66,7 +66,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
        skb_reset_tail_pointer(skb);
        skb_reserve(skb, sdata->local->hw.extra_tx_headroom);
 
-       if (memcmp(ifibss->bssid, bssid, ETH_ALEN))
+       if (compare_ether_addr(ifibss->bssid, bssid))
                sta_info_flush(sdata->local, sdata);
 
        /* if merging, indicate to driver that we leave the old IBSS */
@@ -403,7 +403,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                return;
 
        if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
-           memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) {
+           compare_ether_addr(mgmt->bssid, sdata->u.ibss.bssid) == 0) {
 
                rcu_read_lock();
                sta = sta_info_get(sdata, mgmt->sa);
@@ -508,7 +508,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                goto put_bss;
 
        /* same BSSID */
-       if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0)
+       if (compare_ether_addr(cbss->bssid, sdata->u.ibss.bssid) == 0)
                goto put_bss;
 
        if (rx_status->flag & RX_FLAG_MACTIME_MPDU) {
@@ -831,8 +831,8 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
        if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da))
                return;
 
-       if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 &&
-           memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0)
+       if (compare_ether_addr(mgmt->bssid, ifibss->bssid) != 0 &&
+           !is_broadcast_ether_addr(mgmt->bssid))
                return;
 
        end = ((u8 *) mgmt) + len;
index 4d1682950a60e4f107b662808463106245eee121..796b13bfc9532c1adcb5199934980c255443dbe0 100644 (file)
@@ -105,6 +105,44 @@ struct ieee80211_bss {
         */
        bool has_erp_value;
        u8 erp_value;
+
+       /* Keep track of the corruption of the last beacon/probe response. */
+       u8 corrupt_data;
+
+       /* Keep track of what bits of information we have valid info for. */
+       u8 valid_data;
+};
+
+/**
+ * enum ieee80211_corrupt_data_flags - BSS data corruption flags
+ * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
+ * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
+ *
+ * These are bss flags that are attached to a bss in the
+ * @corrupt_data field of &struct ieee80211_bss.
+ */
+enum ieee80211_bss_corrupt_data_flags {
+       IEEE80211_BSS_CORRUPT_BEACON            = BIT(0),
+       IEEE80211_BSS_CORRUPT_PROBE_RESP        = BIT(1)
+};
+
+/**
+ * enum ieee80211_valid_data_flags - BSS valid data flags
+ * @IEEE80211_BSS_VALID_DTIM: DTIM data was gathered from non-corrupt IE
+ * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
+ * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
+ * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
+ *
+ * These are bss flags that are attached to a bss in the
+ * @valid_data field of &struct ieee80211_bss.  They show which parts
+ * of the data structure were recieved as a result of an un-corrupted
+ * beacon/probe response.
+ */
+enum ieee80211_bss_valid_data_flags {
+       IEEE80211_BSS_VALID_DTIM                = BIT(0),
+       IEEE80211_BSS_VALID_WMM                 = BIT(1),
+       IEEE80211_BSS_VALID_RATES               = BIT(2),
+       IEEE80211_BSS_VALID_ERP                 = BIT(3)
 };
 
 static inline u8 *bss_mesh_cfg(struct ieee80211_bss *bss)
@@ -480,7 +518,7 @@ struct ieee80211_if_ibss {
 
        bool control_port;
 
-       u8 bssid[ETH_ALEN];
+       u8 bssid[ETH_ALEN] __aligned(2);
        u8 ssid[IEEE80211_MAX_SSID_LEN];
        u8 ssid_len, ie_len;
        u8 *ie;
@@ -1120,6 +1158,9 @@ struct ieee802_11_elems {
        u8 quiet_elem_len;
        u8 num_of_quiet_elem;   /* can be more the one */
        u8 timeout_int_len;
+
+       /* whether a parse error occurred while retrieving these elements */
+       bool parse_error;
 };
 
 static inline struct ieee80211_local *hw_to_local(
@@ -1150,11 +1191,9 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
 int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
                        struct cfg80211_assoc_request *req);
 int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
-                        struct cfg80211_deauth_request *req,
-                        void *cookie);
+                        struct cfg80211_deauth_request *req);
 int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
-                          struct cfg80211_disassoc_request *req,
-                          void *cookie);
+                          struct cfg80211_disassoc_request *req);
 void ieee80211_send_pspoll(struct ieee80211_local *local,
                           struct ieee80211_sub_if_data *sdata);
 void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
@@ -1350,7 +1389,8 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
 void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
                                     struct ieee80211_hdr *hdr, const u8 *tsc,
                                     gfp_t gfp);
-void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata);
+void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
+                              bool bss_notify);
 void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
 
 void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
index 60b240ce709ea27f93999d13c9ce4209a8e3b783..401c01f0731e996e5c22435f0066b53c97529559 100644 (file)
@@ -304,7 +304,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
                 * need to initialise the hardware if the hardware
                 * doesn't start up with sane defaults
                 */
-               ieee80211_set_wmm_default(sdata);
+               ieee80211_set_wmm_default(sdata, true);
        }
 
        set_bit(SDATA_STATE_RUNNING, &sdata->state);
@@ -1344,6 +1344,9 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local)
                hw_roc = true;
 
        list_for_each_entry(sdata, &local->interfaces, list) {
+               if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
+                   sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
+                       continue;
                if (sdata->old_idle == sdata->vif.bss_conf.idle)
                        continue;
                if (!ieee80211_sdata_running(sdata))
index c707c8bf6d2cbc1ee8e5e54b8d9776d59e5229a4..e5fbb7cf356250ce75968d8102d4dd87430ef551 100644 (file)
@@ -204,7 +204,7 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
                        kmem_cache_free(rm_cache, p);
                        --entries;
                } else if ((seqnum == p->seqnum) &&
-                          (memcmp(sa, p->sa, ETH_ALEN) == 0))
+                          (compare_ether_addr(sa, p->sa) == 0))
                        return -1;
        }
 
index c7e5c49471e5e8701f3ce602b189eb3acadb88ec..8d53b71378e3865cb38376ad35195be8c8193e41 100644 (file)
@@ -85,6 +85,8 @@ enum mesh_deferred_task_flags {
  * @state_lock: mesh path state lock used to protect changes to the
  * mpath itself.  No need to take this lock when adding or removing
  * an mpath to a hash bucket on a path table.
+ * @rann_snd_addr: the RANN sender address
+ * @is_root: the destination station of this path is a root node
  * @is_gate: the destination station of this path is a mesh gate
  *
  *
@@ -109,6 +111,8 @@ struct mesh_path {
        u8 discovery_retries;
        enum mesh_path_flags flags;
        spinlock_t state_lock;
+       u8 rann_snd_addr[ETH_ALEN];
+       bool is_root;
        bool is_gate;
 };
 
index 31bc762f209df80841fbc2956b3fb3bc9c352ff6..1c6f3d02aebf5a4f19630f604aae94cda6810247 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/slab.h>
+#include <linux/etherdevice.h>
 #include <asm/unaligned.h>
 #include "wme.h"
 #include "mesh.h"
@@ -323,6 +324,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
                                   struct sta_info *sta)
 {
        struct ieee80211_supported_band *sband;
+       struct rate_info rinfo;
        /* This should be adjusted for each device */
        int device_constant = 1 << ARITH_SHIFT;
        int test_frame_len = TEST_FRAME_LEN << ARITH_SHIFT;
@@ -336,7 +338,9 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
        if (sta->fail_avg >= 100)
                return MAX_METRIC;
 
-       if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
+       sta_set_rate_info_tx(sta, &sta->last_tx_rate, &rinfo);
+       rate = cfg80211_calculate_bitrate(&rinfo);
+       if (WARN_ON(!rate))
                return MAX_METRIC;
 
        err = (sta->fail_avg << ARITH_SHIFT) / 100;
@@ -344,7 +348,6 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
        /* bitrate is in units of 100 Kbps, while we need rate in units of
         * 1Mbps. This will be corrected on tx_time computation.
         */
-       rate = sband->bitrates[sta->last_tx_rate.idx].bitrate;
        tx_time = (device_constant + 10 * test_frame_len / rate);
        estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err));
        result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ;
@@ -419,7 +422,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
                new_metric = MAX_METRIC;
        exp_time = TU_TO_EXP_TIME(orig_lifetime);
 
-       if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) {
+       if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) {
                /* This MP is the originator, we are not interested in this
                 * frame, except for updating transmitter's path info.
                 */
@@ -469,7 +472,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
 
        /* Update and check transmitter routing info */
        ta = mgmt->sa;
-       if (memcmp(orig_addr, ta, ETH_ALEN) == 0)
+       if (compare_ether_addr(orig_addr, ta) == 0)
                fresh_info = false;
        else {
                fresh_info = true;
@@ -513,8 +516,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
                                    u8 *preq_elem, u32 metric)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
-       struct mesh_path *mpath;
+       struct mesh_path *mpath = NULL;
        u8 *target_addr, *orig_addr;
+       const u8 *da;
        u8 target_flags, ttl;
        u32 orig_sn, target_sn, lifetime;
        bool reply = false;
@@ -529,7 +533,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
 
        mhwmp_dbg("received PREQ from %pM", orig_addr);
 
-       if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) {
+       if (compare_ether_addr(target_addr, sdata->vif.addr) == 0) {
                mhwmp_dbg("PREQ is for us");
                forward = false;
                reply = true;
@@ -591,9 +595,11 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
                flags = PREQ_IE_FLAGS(preq_elem);
                preq_id = PREQ_IE_PREQ_ID(preq_elem);
                hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1;
+               da = (mpath && mpath->is_root) ?
+                       mpath->rann_snd_addr : broadcast_addr;
                mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr,
                                cpu_to_le32(orig_sn), target_flags, target_addr,
-                               cpu_to_le32(target_sn), broadcast_addr,
+                               cpu_to_le32(target_sn), da,
                                hopcount, ttl, cpu_to_le32(lifetime),
                                cpu_to_le32(metric), cpu_to_le32(preq_id),
                                sdata);
@@ -615,6 +621,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
                                    struct ieee80211_mgmt *mgmt,
                                    u8 *prep_elem, u32 metric)
 {
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        struct mesh_path *mpath;
        u8 *target_addr, *orig_addr;
        u8 ttl, hopcount, flags;
@@ -624,10 +631,13 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
        mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem));
 
        orig_addr = PREP_IE_ORIG_ADDR(prep_elem);
-       if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
+       if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0)
                /* destination, no forwarding required */
                return;
 
+       if (!ifmsh->mshcfg.dot11MeshForwarding)
+               return;
+
        ttl = PREP_IE_TTL(prep_elem);
        if (ttl <= 1) {
                sdata->u.mesh.mshstats.dropped_frames_ttl++;
@@ -694,21 +704,26 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
        rcu_read_lock();
        mpath = mesh_path_lookup(target_addr, sdata);
        if (mpath) {
+               struct sta_info *sta;
+
                spin_lock_bh(&mpath->state_lock);
+               sta = next_hop_deref_protected(mpath);
                if (mpath->flags & MESH_PATH_ACTIVE &&
-                   memcmp(ta, next_hop_deref_protected(mpath)->sta.addr,
-                                                       ETH_ALEN) == 0 &&
+                   compare_ether_addr(ta, sta->sta.addr) == 0 &&
                    (!(mpath->flags & MESH_PATH_SN_VALID) ||
                    SN_GT(target_sn, mpath->sn))) {
                        mpath->flags &= ~MESH_PATH_ACTIVE;
                        mpath->sn = target_sn;
                        spin_unlock_bh(&mpath->state_lock);
+                       if (!ifmsh->mshcfg.dot11MeshForwarding)
+                               goto endperr;
                        mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn),
                                           cpu_to_le16(target_rcode),
                                           broadcast_addr, sdata);
                } else
                        spin_unlock_bh(&mpath->state_lock);
        }
+endperr:
        rcu_read_unlock();
 }
 
@@ -739,11 +754,11 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
        metric = rann->rann_metric;
 
        /*  Ignore our own RANNs */
-       if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
+       if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0)
                return;
 
-       mhwmp_dbg("received RANN from %pM (is_gate=%d)", orig_addr,
-                       root_is_gate);
+       mhwmp_dbg("received RANN from %pM via neighbour %pM (is_gate=%d)",
+                       orig_addr, mgmt->sa, root_is_gate);
 
        rcu_read_lock();
        mpath = mesh_path_lookup(orig_addr, sdata);
@@ -765,7 +780,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
                mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH);
        }
 
-       if (mpath->sn < orig_sn) {
+       if (mpath->sn < orig_sn && ifmsh->mshcfg.dot11MeshForwarding) {
                mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr,
                                       cpu_to_le32(orig_sn),
                                       0, NULL, 0, broadcast_addr,
@@ -774,6 +789,11 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
                                       0, sdata);
                mpath->sn = orig_sn;
        }
+
+       /* Using individually addressed PREQ for root node */
+       memcpy(mpath->rann_snd_addr, mgmt->sa, ETH_ALEN);
+       mpath->is_root = true;
+
        if (root_is_gate)
                mesh_path_add_gate(mpath);
 
@@ -909,6 +929,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
        struct mesh_preq_queue *preq_node;
        struct mesh_path *mpath;
        u8 ttl, target_flags;
+       const u8 *da;
        u32 lifetime;
 
        spin_lock_bh(&ifmsh->mesh_preq_queue_lock);
@@ -971,9 +992,10 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
                target_flags = MP_F_RF;
 
        spin_unlock_bh(&mpath->state_lock);
+       da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr;
        mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr,
                        cpu_to_le32(ifmsh->sn), target_flags, mpath->dst,
-                       cpu_to_le32(mpath->sn), broadcast_addr, 0,
+                       cpu_to_le32(mpath->sn), da, 0,
                        ttl, cpu_to_le32(lifetime), 0,
                        cpu_to_le32(ifmsh->preq_id++), sdata);
        mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout);
@@ -1064,7 +1086,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
        if (time_after(jiffies,
                       mpath->exp_time -
                       msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) &&
-           !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) &&
+           !compare_ether_addr(sdata->vif.addr, hdr->addr4) &&
            !(mpath->flags & MESH_PATH_RESOLVING) &&
            !(mpath->flags & MESH_PATH_FIXED))
                mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH);
index dc51669e67d883bf59a97575bc1bd355a6ce5f39..be1361b5f7ada32953a080a573bb6574d0fe9ac9 100644 (file)
@@ -348,7 +348,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, u8 *dst,
        hlist_for_each_entry_rcu(node, n, bucket, list) {
                mpath = node->mpath;
                if (mpath->sdata == sdata &&
-                               memcmp(dst, mpath->dst, ETH_ALEN) == 0) {
+                               compare_ether_addr(dst, mpath->dst) == 0) {
                        if (MPATH_EXPIRED(mpath)) {
                                spin_lock_bh(&mpath->state_lock);
                                mpath->flags &= ~MESH_PATH_ACTIVE;
@@ -523,7 +523,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
        int err = 0;
        u32 hash_idx;
 
-       if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0)
+       if (compare_ether_addr(dst, sdata->vif.addr) == 0)
                /* never add ourselves as neighbours */
                return -ENOTSUPP;
 
@@ -559,12 +559,13 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
        hash_idx = mesh_table_hash(dst, sdata, tbl);
        bucket = &tbl->hash_buckets[hash_idx];
 
-       spin_lock_bh(&tbl->hashwlock[hash_idx]);
+       spin_lock(&tbl->hashwlock[hash_idx]);
 
        err = -EEXIST;
        hlist_for_each_entry(node, n, bucket, list) {
                mpath = node->mpath;
-               if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
+               if (mpath->sdata == sdata &&
+                   compare_ether_addr(dst, mpath->dst) == 0)
                        goto err_exists;
        }
 
@@ -575,7 +576,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
 
        mesh_paths_generation++;
 
-       spin_unlock_bh(&tbl->hashwlock[hash_idx]);
+       spin_unlock(&tbl->hashwlock[hash_idx]);
        read_unlock_bh(&pathtbl_resize_lock);
        if (grow) {
                set_bit(MESH_WORK_GROW_MPATH_TABLE,  &ifmsh->wrkq_flags);
@@ -584,7 +585,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
        return 0;
 
 err_exists:
-       spin_unlock_bh(&tbl->hashwlock[hash_idx]);
+       spin_unlock(&tbl->hashwlock[hash_idx]);
        read_unlock_bh(&pathtbl_resize_lock);
        kfree(new_node);
 err_node_alloc:
@@ -655,7 +656,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
        int err = 0;
        u32 hash_idx;
 
-       if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0)
+       if (compare_ether_addr(dst, sdata->vif.addr) == 0)
                /* never add ourselves as neighbours */
                return -ENOTSUPP;
 
@@ -687,12 +688,13 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
        hash_idx = mesh_table_hash(dst, sdata, tbl);
        bucket = &tbl->hash_buckets[hash_idx];
 
-       spin_lock_bh(&tbl->hashwlock[hash_idx]);
+       spin_lock(&tbl->hashwlock[hash_idx]);
 
        err = -EEXIST;
        hlist_for_each_entry(node, n, bucket, list) {
                mpath = node->mpath;
-               if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
+               if (mpath->sdata == sdata &&
+                   compare_ether_addr(dst, mpath->dst) == 0)
                        goto err_exists;
        }
 
@@ -701,7 +703,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
            tbl->mean_chain_len * (tbl->hash_mask + 1))
                grow = 1;
 
-       spin_unlock_bh(&tbl->hashwlock[hash_idx]);
+       spin_unlock(&tbl->hashwlock[hash_idx]);
        read_unlock_bh(&pathtbl_resize_lock);
        if (grow) {
                set_bit(MESH_WORK_GROW_MPP_TABLE,  &ifmsh->wrkq_flags);
@@ -710,7 +712,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
        return 0;
 
 err_exists:
-       spin_unlock_bh(&tbl->hashwlock[hash_idx]);
+       spin_unlock(&tbl->hashwlock[hash_idx]);
        read_unlock_bh(&pathtbl_resize_lock);
        kfree(new_node);
 err_node_alloc:
@@ -809,9 +811,9 @@ void mesh_path_flush_by_nexthop(struct sta_info *sta)
        for_each_mesh_entry(tbl, p, node, i) {
                mpath = node->mpath;
                if (rcu_dereference(mpath->next_hop) == sta) {
-                       spin_lock_bh(&tbl->hashwlock[i]);
+                       spin_lock(&tbl->hashwlock[i]);
                        __mesh_path_del(tbl, node);
-                       spin_unlock_bh(&tbl->hashwlock[i]);
+                       spin_unlock(&tbl->hashwlock[i]);
                }
        }
        read_unlock_bh(&pathtbl_resize_lock);
@@ -882,11 +884,11 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata)
        hash_idx = mesh_table_hash(addr, sdata, tbl);
        bucket = &tbl->hash_buckets[hash_idx];
 
-       spin_lock_bh(&tbl->hashwlock[hash_idx]);
+       spin_lock(&tbl->hashwlock[hash_idx]);
        hlist_for_each_entry(node, n, bucket, list) {
                mpath = node->mpath;
                if (mpath->sdata == sdata &&
-                   memcmp(addr, mpath->dst, ETH_ALEN) == 0) {
+                   compare_ether_addr(addr, mpath->dst) == 0) {
                        __mesh_path_del(tbl, node);
                        goto enddel;
                }
@@ -895,7 +897,7 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata)
        err = -ENXIO;
 enddel:
        mesh_paths_generation++;
-       spin_unlock_bh(&tbl->hashwlock[hash_idx]);
+       spin_unlock(&tbl->hashwlock[hash_idx]);
        read_unlock_bh(&pathtbl_resize_lock);
        return err;
 }
index 8806e5ef8ffecebb799504a16c338a2f496991a0..4e53c4cbca9e5248f26254a261796ffdd5236681 100644 (file)
 #define dot11MeshHoldingTimeout(s) (s->u.mesh.mshcfg.dot11MeshHoldingTimeout)
 #define dot11MeshMaxPeerLinks(s) (s->u.mesh.mshcfg.dot11MeshMaxPeerLinks)
 
+/* We only need a valid sta if user configured a minimum rssi_threshold. */
+#define rssi_threshold_check(sta, sdata) \
+               (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\
+               (sta && (s8) -ewma_read(&sta->avg_signal) > \
+               sdata->u.mesh.mshcfg.rssi_threshold))
+
 enum plink_event {
        PLINK_UNDEFINED,
        OPN_ACPT,
@@ -301,7 +307,8 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates,
        if (mesh_peer_accepts_plinks(elems) &&
                        sta->plink_state == NL80211_PLINK_LISTEN &&
                        sdata->u.mesh.accepting_plinks &&
-                       sdata->u.mesh.mshcfg.auto_open_plinks)
+                       sdata->u.mesh.mshcfg.auto_open_plinks &&
+                       rssi_threshold_check(sta, sdata))
                mesh_plink_open(sta);
 
        rcu_read_unlock();
@@ -531,6 +538,14 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                return;
        }
 
+       if (ftype == WLAN_SP_MESH_PEERING_OPEN &&
+           !rssi_threshold_check(sta, sdata)) {
+               mpl_dbg("Mesh plink: %pM does not meet rssi threshold\n",
+                       mgmt->sa);
+               rcu_read_unlock();
+               return;
+       }
+
        if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) {
                mpl_dbg("Mesh plink: Action frame from non-authed peer\n");
                rcu_read_unlock();
index 0c220e1b6c9cffac0103a78b408359bd460dee77..c08924aeac0017de011a3c305fcedf9faa4f8796 100644 (file)
@@ -88,6 +88,8 @@ MODULE_PARM_DESC(probe_wait_ms,
 #define TMR_RUNNING_TIMER      0
 #define TMR_RUNNING_CHANSW     1
 
+#define DEAUTH_DISASSOC_LEN    (24 /* hdr */ + 2 /* reason */)
+
 /*
  * All cfg80211 functions have to be called outside a locked
  * section so that they can acquire a lock themselves... This
@@ -612,47 +614,42 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
 }
 
 static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
-                                          const u8 *bssid, u16 stype, u16 reason,
-                                          void *cookie, bool send_frame)
+                                          const u8 *bssid, u16 stype,
+                                          u16 reason, bool send_frame,
+                                          u8 *frame_buf)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        struct sk_buff *skb;
-       struct ieee80211_mgmt *mgmt;
-
-       skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
-       if (!skb)
-               return;
+       struct ieee80211_mgmt *mgmt = (void *)frame_buf;
 
-       skb_reserve(skb, local->hw.extra_tx_headroom);
-
-       mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
-       memset(mgmt, 0, 24);
+       /* build frame */
+       mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
+       mgmt->duration = 0; /* initialize only */
+       mgmt->seq_ctrl = 0; /* initialize only */
        memcpy(mgmt->da, bssid, ETH_ALEN);
        memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
        memcpy(mgmt->bssid, bssid, ETH_ALEN);
-       mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
-       skb_put(skb, 2);
        /* u.deauth.reason_code == u.disassoc.reason_code */
        mgmt->u.deauth.reason_code = cpu_to_le16(reason);
 
-       if (stype == IEEE80211_STYPE_DEAUTH)
-               if (cookie)
-                       __cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len);
-               else
-                       cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len);
-       else
-               if (cookie)
-                       __cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len);
-               else
-                       cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len);
-       if (!(ifmgd->flags & IEEE80211_STA_MFP_ENABLED))
-               IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
+       if (send_frame) {
+               skb = dev_alloc_skb(local->hw.extra_tx_headroom +
+                                   DEAUTH_DISASSOC_LEN);
+               if (!skb)
+                       return;
+
+               skb_reserve(skb, local->hw.extra_tx_headroom);
+
+               /* copy in frame */
+               memcpy(skb_put(skb, DEAUTH_DISASSOC_LEN),
+                      mgmt, DEAUTH_DISASSOC_LEN);
 
-       if (send_frame)
+               if (!(ifmgd->flags & IEEE80211_STA_MFP_ENABLED))
+                       IEEE80211_SKB_CB(skb)->flags |=
+                               IEEE80211_TX_INTFL_DONT_ENCRYPT;
                ieee80211_tx_skb(sdata, skb);
-       else
-               kfree_skb(skb);
+       }
 }
 
 void ieee80211_send_pspoll(struct ieee80211_local *local,
@@ -1280,7 +1277,6 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
 
        /* enable WMM or activate new settings */
        sdata->vif.bss_conf.qos = true;
-       ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
 }
 
 static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
@@ -1392,7 +1388,8 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
 }
 
 static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
-                                  bool remove_sta, bool tx)
+                                  u16 stype, u16 reason, bool tx,
+                                  u8 *frame_buf)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        struct ieee80211_local *local = sdata->local;
@@ -1402,6 +1399,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
 
        ASSERT_MGD_MTX(ifmgd);
 
+       if (WARN_ON_ONCE(tx && !frame_buf))
+               return;
+
        if (WARN_ON(!ifmgd->associated))
                return;
 
@@ -1435,14 +1435,25 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
        }
        mutex_unlock(&local->sta_mtx);
 
+       /* deauthenticate/disassociate now */
+       if (tx || frame_buf)
+               ieee80211_send_deauth_disassoc(sdata, bssid, stype, reason,
+                                              tx, frame_buf);
+
+       /* flush out frame */
+       if (tx)
+               drv_flush(local, false);
+
+       /* remove AP and TDLS peers */
+       sta_info_flush(local, sdata);
+
+       /* finally reset all BSS / config parameters */
        changed |= ieee80211_reset_erp_info(sdata);
 
        ieee80211_led_assoc(local, 0);
        changed |= BSS_CHANGED_ASSOC;
        sdata->vif.bss_conf.assoc = false;
 
-       ieee80211_set_wmm_default(sdata);
-
        /* channel(_type) changes are handled by ieee80211_hw_config */
        WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT));
 
@@ -1470,13 +1481,15 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
                changed |= BSS_CHANGED_ARP_FILTER;
        }
 
+       sdata->vif.bss_conf.qos = false;
+       changed |= BSS_CHANGED_QOS;
+
        /* The BSSID (not really interesting) and HT changed */
        changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT;
        ieee80211_bss_info_change_notify(sdata, changed);
 
-       /* remove AP and TDLS peers */
-       if (remove_sta)
-               sta_info_flush(local, sdata);
+       /* disassociated - set to defaults now */
+       ieee80211_set_wmm_default(sdata, false);
 
        del_timer_sync(&sdata->u.mgd.conn_mon_timer);
        del_timer_sync(&sdata->u.mgd.bcn_mon_timer);
@@ -1674,6 +1687,7 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata)
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        struct ieee80211_local *local = sdata->local;
        u8 bssid[ETH_ALEN];
+       u8 frame_buf[DEAUTH_DISASSOC_LEN];
 
        mutex_lock(&ifmgd->mtx);
        if (!ifmgd->associated) {
@@ -1686,17 +1700,16 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata)
        printk(KERN_DEBUG "%s: Connection to AP %pM lost.\n",
               sdata->name, bssid);
 
-       ieee80211_set_disassoc(sdata, true, true);
+       ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
+                              WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
+                              false, frame_buf);
        mutex_unlock(&ifmgd->mtx);
 
        /*
         * must be outside lock due to cfg80211,
         * but that's not a problem.
         */
-       ieee80211_send_deauth_disassoc(sdata, bssid,
-                                      IEEE80211_STYPE_DEAUTH,
-                                      WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
-                                      NULL, true);
+       cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN);
 
        mutex_lock(&local->mtx);
        ieee80211_recalc_idle(local);
@@ -1812,7 +1825,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
 
        memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN);
 
-       if (memcmp(bssid, mgmt->bssid, ETH_ALEN))
+       if (compare_ether_addr(bssid, mgmt->bssid))
                return RX_MGMT_NONE;
 
        auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
@@ -1893,7 +1906,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
                return RX_MGMT_NONE;
 
        if (!ifmgd->associated ||
-           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
+           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
                return RX_MGMT_NONE;
 
        bssid = ifmgd->associated->bssid;
@@ -1903,7 +1916,8 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
        printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n",
                        sdata->name, bssid, reason_code);
 
-       ieee80211_set_disassoc(sdata, true, false);
+       ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
+
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
        mutex_unlock(&sdata->local->mtx);
@@ -1925,7 +1939,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
                return RX_MGMT_NONE;
 
        if (!ifmgd->associated ||
-           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
+           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
                return RX_MGMT_NONE;
 
        reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
@@ -1933,10 +1947,12 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
        printk(KERN_DEBUG "%s: disassociated from %pM (Reason: %u)\n",
                        sdata->name, mgmt->sa, reason_code);
 
-       ieee80211_set_disassoc(sdata, true, false);
+       ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
+
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
        mutex_unlock(&sdata->local->mtx);
+
        return RX_MGMT_CFG80211_DISASSOC;
 }
 
@@ -2142,7 +2158,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
                ieee80211_sta_wmm_params(local, sdata, elems.wmm_param,
                                         elems.wmm_param_len);
        else
-               ieee80211_set_wmm_default(sdata);
+               ieee80211_set_wmm_default(sdata, false);
+       changed |= BSS_CHANGED_QOS;
 
        if (elems.ht_info_elem && elems.wmm_param &&
            (sdata->local->hw.queues >= 4) &&
@@ -2190,7 +2207,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
 
        if (!assoc_data)
                return RX_MGMT_NONE;
-       if (memcmp(assoc_data->bss->bssid, mgmt->bssid, ETH_ALEN))
+       if (compare_ether_addr(assoc_data->bss->bssid, mgmt->bssid))
                return RX_MGMT_NONE;
 
        /*
@@ -2278,8 +2295,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
        bool need_ps = false;
 
        if (sdata->u.mgd.associated &&
-           memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid,
-                  ETH_ALEN) == 0) {
+           compare_ether_addr(mgmt->bssid, sdata->u.mgd.associated->bssid)
+           == 0) {
                bss = (void *)sdata->u.mgd.associated->priv;
                /* not previously set so we may need to recalc */
                need_ps = !bss->dtim_period;
@@ -2334,7 +2351,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
 
        ASSERT_MGD_MTX(ifmgd);
 
-       if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN))
+       if (compare_ether_addr(mgmt->da, sdata->vif.addr))
                return; /* ignore ProbeResp to foreign address */
 
        baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
@@ -2347,11 +2364,12 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
        ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
 
        if (ifmgd->associated &&
-           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0)
+           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid) == 0)
                ieee80211_reset_ap_probe(sdata);
 
        if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies &&
-           memcmp(mgmt->bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN) == 0) {
+           compare_ether_addr(mgmt->bssid, ifmgd->auth_data->bss->bssid)
+           == 0) {
                /* got probe response, continue with auth */
                printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name);
                ifmgd->auth_data->tries = 0;
@@ -2408,7 +2426,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
                return;
 
        if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon &&
-           memcmp(mgmt->bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN) == 0) {
+           compare_ether_addr(mgmt->bssid, ifmgd->assoc_data->bss->bssid)
+           == 0) {
                ieee802_11_parse_elems(mgmt->u.beacon.variable,
                                       len - baselen, &elems);
 
@@ -2423,7 +2442,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
        }
 
        if (!ifmgd->associated ||
-           memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN))
+           compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
                return;
        bssid = ifmgd->associated->bssid;
 
@@ -2695,19 +2714,20 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata,
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+       u8 frame_buf[DEAUTH_DISASSOC_LEN];
 
        ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
                          IEEE80211_STA_BEACON_POLL);
 
-       ieee80211_set_disassoc(sdata, true, true);
+       ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason,
+                              false, frame_buf);
        mutex_unlock(&ifmgd->mtx);
+
        /*
         * must be outside lock due to cfg80211,
         * but that's not a problem.
         */
-       ieee80211_send_deauth_disassoc(sdata, bssid,
-                       IEEE80211_STYPE_DEAUTH, reason,
-                       NULL, true);
+       cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN);
 
        mutex_lock(&local->mtx);
        ieee80211_recalc_idle(local);
@@ -3191,7 +3211,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
        ifmgd->auth_data = auth_data;
 
        if (ifmgd->associated)
-               ieee80211_set_disassoc(sdata, true, false);
+               ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
 
        printk(KERN_DEBUG "%s: authenticate with %pM\n",
               sdata->name, req->bss->bssid);
@@ -3269,7 +3289,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
        mutex_lock(&ifmgd->mtx);
 
        if (ifmgd->associated)
-               ieee80211_set_disassoc(sdata, true, false);
+               ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
 
        if (ifmgd->auth_data && !ifmgd->auth_data->done) {
                err = -EBUSY;
@@ -3285,7 +3305,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
                bool match;
 
                /* keep sta info, bssid if matching */
-               match = memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN) == 0;
+               match = compare_ether_addr(ifmgd->bssid, req->bss->bssid) == 0;
                ieee80211_destroy_auth_data(sdata, match);
        }
 
@@ -3407,7 +3427,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
                        goto err_clear;
                }
        } else
-               WARN_ON_ONCE(memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN));
+               WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, req->bss->bssid));
 
        if (!bss->dtim_period &&
            sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) {
@@ -3426,6 +3446,20 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
        }
        run_again(ifmgd, assoc_data->timeout);
 
+       if (bss->corrupt_data) {
+               char *corrupt_type = "data";
+               if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_BEACON) {
+                       if (bss->corrupt_data &
+                                       IEEE80211_BSS_CORRUPT_PROBE_RESP)
+                               corrupt_type = "beacon and probe response";
+                       else
+                               corrupt_type = "beacon";
+               } else if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP)
+                       corrupt_type = "probe response";
+               printk(KERN_DEBUG "%s: associating with AP with corrupt %s\n",
+                      sdata->name, corrupt_type);
+       }
+
        err = 0;
        goto out;
  err_clear:
@@ -3439,32 +3473,35 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
 }
 
 int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
-                        struct cfg80211_deauth_request *req,
-                        void *cookie)
+                        struct cfg80211_deauth_request *req)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
-       bool assoc_bss = false;
+       u8 frame_buf[DEAUTH_DISASSOC_LEN];
 
        mutex_lock(&ifmgd->mtx);
 
-       if (ifmgd->associated &&
-           memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) {
-               ieee80211_set_disassoc(sdata, false, true);
-               assoc_bss = true;
-       } else if (ifmgd->auth_data) {
+       if (ifmgd->auth_data) {
                ieee80211_destroy_auth_data(sdata, false);
                mutex_unlock(&ifmgd->mtx);
                return 0;
        }
-       mutex_unlock(&ifmgd->mtx);
 
-       printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n",
+       printk(KERN_DEBUG
+              "%s: deauthenticating from %pM by local choice (reason=%d)\n",
               sdata->name, req->bssid, req->reason_code);
 
-       ieee80211_send_deauth_disassoc(sdata, req->bssid, IEEE80211_STYPE_DEAUTH,
-                                      req->reason_code, cookie, true);
-       if (assoc_bss)
-               sta_info_flush(sdata->local, sdata);
+       if (ifmgd->associated &&
+           compare_ether_addr(ifmgd->associated->bssid, req->bssid) == 0)
+               ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
+                                      req->reason_code, true, frame_buf);
+       else
+               ieee80211_send_deauth_disassoc(sdata, req->bssid,
+                                              IEEE80211_STYPE_DEAUTH,
+                                              req->reason_code, true,
+                                              frame_buf);
+       mutex_unlock(&ifmgd->mtx);
+
+       __cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN);
 
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
@@ -3474,11 +3511,11 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
 }
 
 int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
-                          struct cfg80211_disassoc_request *req,
-                          void *cookie)
+                          struct cfg80211_disassoc_request *req)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        u8 bssid[ETH_ALEN];
+       u8 frame_buf[DEAUTH_DISASSOC_LEN];
 
        mutex_lock(&ifmgd->mtx);
 
@@ -3497,14 +3534,12 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
               sdata->name, req->bss->bssid, req->reason_code);
 
        memcpy(bssid, req->bss->bssid, ETH_ALEN);
-       ieee80211_set_disassoc(sdata, false, true);
-
+       ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DISASSOC,
+                              req->reason_code, !req->local_state_change,
+                              frame_buf);
        mutex_unlock(&ifmgd->mtx);
 
-       ieee80211_send_deauth_disassoc(sdata, req->bss->bssid,
-                       IEEE80211_STYPE_DISASSOC, req->reason_code,
-                       cookie, !req->local_state_change);
-       sta_info_flush(sdata->local, sdata);
+       __cfg80211_send_disassoc(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN);
 
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
index 111fba38be82d6095fcd4a72d2610517af4f2ace..b4f7600a3e36c010f6d428ad0461db2324087dc3 100644 (file)
@@ -447,7 +447,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
        for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
                info->control.rates[i].idx = -1;
                info->control.rates[i].flags = 0;
-               info->control.rates[i].count = 1;
+               info->control.rates[i].count = 0;
        }
 
        if (sdata->local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
index 7a4ff02af2618bb96a85875a6b51f2fdabb49ec1..5f6e32ca08585ff640fb790f4353f9ace120aaf6 100644 (file)
@@ -177,7 +177,8 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
        pos += 2;
 
        /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
-       if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
+       if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM &&
+           !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
                *pos = status->signal;
                rthdr->it_present |=
                        cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
@@ -227,7 +228,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
 {
        struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(origskb);
        struct ieee80211_sub_if_data *sdata;
-       int needed_headroom = 0;
+       int needed_headroom;
        struct sk_buff *skb, *skb2;
        struct net_device *prev_dev = NULL;
        int present_fcs_len = 0;
@@ -489,12 +490,12 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
                        if (ieee80211_has_tods(hdr->frame_control) ||
                                !ieee80211_has_fromds(hdr->frame_control))
                                return RX_DROP_MONITOR;
-                       if (memcmp(hdr->addr3, dev_addr, ETH_ALEN) == 0)
+                       if (compare_ether_addr(hdr->addr3, dev_addr) == 0)
                                return RX_DROP_MONITOR;
                } else {
                        if (!ieee80211_has_a4(hdr->frame_control))
                                return RX_DROP_MONITOR;
-                       if (memcmp(hdr->addr4, dev_addr, ETH_ALEN) == 0)
+                       if (compare_ether_addr(hdr->addr4, dev_addr) == 0)
                                return RX_DROP_MONITOR;
                }
        }
@@ -1309,8 +1310,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 
        sta->rx_fragments++;
        sta->rx_bytes += rx->skb->len;
-       sta->last_signal = status->signal;
-       ewma_add(&sta->avg_signal, -status->signal);
+       if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
+               sta->last_signal = status->signal;
+               ewma_add(&sta->avg_signal, -status->signal);
+       }
 
        /*
         * Change STA power saving mode only at the end of a frame
@@ -1957,6 +1960,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
                return RX_DROP_MONITOR;
        }
 
+       if (!ifmsh->mshcfg.dot11MeshForwarding)
+               goto out;
+
        fwd_skb = skb_copy(skb, GFP_ATOMIC);
        if (!fwd_skb) {
                if (net_ratelimit())
@@ -2182,9 +2188,14 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx)
        if (rx->sdata->vif.type == NL80211_IFTYPE_AP &&
            ieee80211_is_beacon(mgmt->frame_control) &&
            !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) {
+               int sig = 0;
+
+               if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
+                       sig = status->signal;
+
                cfg80211_report_obss_beacon(rx->local->hw.wiphy,
                                            rx->skb->data, rx->skb->len,
-                                           status->freq, GFP_ATOMIC);
+                                           status->freq, sig, GFP_ATOMIC);
                rx->flags |= IEEE80211_RX_BEACON_REPORTED;
        }
 
@@ -2336,7 +2347,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
                        if (sdata->vif.type != NL80211_IFTYPE_STATION)
                                break;
 
-                       if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN))
+                       if (compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid))
                                break;
 
                        goto queue;
@@ -2408,6 +2419,7 @@ static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
 {
        struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
+       int sig = 0;
 
        /* skip known-bad action frames and return them in the next handler */
        if (status->rx_flags & IEEE80211_RX_MALFORMED_ACTION_FRM)
@@ -2420,7 +2432,10 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
         * it transmitted were processed or returned.
         */
 
-       if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq,
+       if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
+               sig = status->signal;
+
+       if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, sig,
                             rx->skb->data, rx->skb->len,
                             GFP_ATOMIC)) {
                if (rx->sta)
@@ -2538,16 +2553,10 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
 {
        struct ieee80211_sub_if_data *sdata;
        struct ieee80211_local *local = rx->local;
-       struct ieee80211_rtap_hdr {
-               struct ieee80211_radiotap_header hdr;
-               u8 flags;
-               u8 rate_or_pad;
-               __le16 chan_freq;
-               __le16 chan_flags;
-       } __packed *rthdr;
        struct sk_buff *skb = rx->skb, *skb2;
        struct net_device *prev_dev = NULL;
        struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
+       int needed_headroom;
 
        /*
         * If cooked monitor has been processed already, then
@@ -2561,30 +2570,15 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
        if (!local->cooked_mntrs)
                goto out_free_skb;
 
-       if (skb_headroom(skb) < sizeof(*rthdr) &&
-           pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC))
-               goto out_free_skb;
-
-       rthdr = (void *)skb_push(skb, sizeof(*rthdr));
-       memset(rthdr, 0, sizeof(*rthdr));
-       rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
-       rthdr->hdr.it_present =
-               cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
-                           (1 << IEEE80211_RADIOTAP_CHANNEL));
+       /* room for the radiotap header based on driver features */
+       needed_headroom = ieee80211_rx_radiotap_len(local, status);
 
-       if (rate) {
-               rthdr->rate_or_pad = rate->bitrate / 5;
-               rthdr->hdr.it_present |=
-                       cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE);
-       }
-       rthdr->chan_freq = cpu_to_le16(status->freq);
+       if (skb_headroom(skb) < needed_headroom &&
+           pskb_expand_head(skb, needed_headroom, 0, GFP_ATOMIC))
+               goto out_free_skb;
 
-       if (status->band == IEEE80211_BAND_5GHZ)
-               rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_OFDM |
-                                               IEEE80211_CHAN_5GHZ);
-       else
-               rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_DYN |
-                                               IEEE80211_CHAN_2GHZ);
+       /* prepend radiotap information */
+       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom);
 
        skb_set_mac_header(skb, 0);
        skb->ip_summed = CHECKSUM_UNNECESSARY;
index 9270771702fe9a5a12fef9fcde4554f30b18b58d..33cd169013781321a813e10ebfb474c9595bd857 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/if_arp.h>
+#include <linux/etherdevice.h>
 #include <linux/rtnetlink.h>
 #include <linux/pm_qos.h>
 #include <net/sch_generic.h>
@@ -103,16 +104,35 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
        cbss->free_priv = ieee80211_rx_bss_free;
        bss = (void *)cbss->priv;
 
+       if (elems->parse_error) {
+               if (beacon)
+                       bss->corrupt_data |= IEEE80211_BSS_CORRUPT_BEACON;
+               else
+                       bss->corrupt_data |= IEEE80211_BSS_CORRUPT_PROBE_RESP;
+       } else {
+               if (beacon)
+                       bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_BEACON;
+               else
+                       bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_PROBE_RESP;
+       }
+
        /* save the ERP value so that it is available at association time */
-       if (elems->erp_info && elems->erp_info_len >= 1) {
+       if (elems->erp_info && elems->erp_info_len >= 1 &&
+                       (!elems->parse_error ||
+                        !(bss->valid_data & IEEE80211_BSS_VALID_ERP))) {
                bss->erp_value = elems->erp_info[0];
                bss->has_erp_value = true;
+               if (!elems->parse_error)
+                       bss->valid_data |= IEEE80211_BSS_VALID_ERP;
        }
 
-       if (elems->tim) {
+       if (elems->tim && (!elems->parse_error ||
+                          !(bss->valid_data & IEEE80211_BSS_VALID_DTIM))) {
                struct ieee80211_tim_ie *tim_ie =
                        (struct ieee80211_tim_ie *)elems->tim;
                bss->dtim_period = tim_ie->dtim_period;
+               if (!elems->parse_error)
+                               bss->valid_data |= IEEE80211_BSS_VALID_DTIM;
        }
 
        /* If the beacon had no TIM IE, or it was invalid, use 1 */
@@ -120,26 +140,38 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
                bss->dtim_period = 1;
 
        /* replace old supported rates if we get new values */
-       srlen = 0;
-       if (elems->supp_rates) {
-               clen = IEEE80211_MAX_SUPP_RATES;
-               if (clen > elems->supp_rates_len)
-                       clen = elems->supp_rates_len;
-               memcpy(bss->supp_rates, elems->supp_rates, clen);
-               srlen += clen;
-       }
-       if (elems->ext_supp_rates) {
-               clen = IEEE80211_MAX_SUPP_RATES - srlen;
-               if (clen > elems->ext_supp_rates_len)
-                       clen = elems->ext_supp_rates_len;
-               memcpy(bss->supp_rates + srlen, elems->ext_supp_rates, clen);
-               srlen += clen;
+       if (!elems->parse_error ||
+           !(bss->valid_data & IEEE80211_BSS_VALID_RATES)) {
+               srlen = 0;
+               if (elems->supp_rates) {
+                       clen = IEEE80211_MAX_SUPP_RATES;
+                       if (clen > elems->supp_rates_len)
+                               clen = elems->supp_rates_len;
+                       memcpy(bss->supp_rates, elems->supp_rates, clen);
+                       srlen += clen;
+               }
+               if (elems->ext_supp_rates) {
+                       clen = IEEE80211_MAX_SUPP_RATES - srlen;
+                       if (clen > elems->ext_supp_rates_len)
+                               clen = elems->ext_supp_rates_len;
+                       memcpy(bss->supp_rates + srlen, elems->ext_supp_rates,
+                              clen);
+                       srlen += clen;
+               }
+               if (srlen) {
+                       bss->supp_rates_len = srlen;
+                       if (!elems->parse_error)
+                               bss->valid_data |= IEEE80211_BSS_VALID_RATES;
+               }
        }
-       if (srlen)
-               bss->supp_rates_len = srlen;
 
-       bss->wmm_used = elems->wmm_param || elems->wmm_info;
-       bss->uapsd_supported = is_uapsd_supported(elems);
+       if (!elems->parse_error ||
+           !(bss->valid_data & IEEE80211_BSS_VALID_WMM)) {
+               bss->wmm_used = elems->wmm_param || elems->wmm_info;
+               bss->uapsd_supported = is_uapsd_supported(elems);
+               if (!elems->parse_error)
+                       bss->valid_data |= IEEE80211_BSS_VALID_WMM;
+       }
 
        if (!beacon)
                bss->last_probe_resp = jiffies;
@@ -176,7 +208,7 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
        presp = ieee80211_is_probe_resp(fc);
        if (presp) {
                /* ignore ProbeResp to foreign address */
-               if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN))
+               if (compare_ether_addr(mgmt->da, sdata->vif.addr))
                        return RX_DROP_MONITOR;
 
                presp = true;
index 98613c8f08cf4b9cbdf3101e1a9a8148611a8cd3..38137cb5f6f05877a6aadca7fcb846d0062df648 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/etherdevice.h>
 #include <linux/netdevice.h>
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -101,7 +102,7 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
                                    lockdep_is_held(&local->sta_mtx));
        while (sta) {
                if (sta->sdata == sdata &&
-                   memcmp(sta->sta.addr, addr, ETH_ALEN) == 0)
+                   compare_ether_addr(sta->sta.addr, addr) == 0)
                        break;
                sta = rcu_dereference_check(sta->hnext,
                                            lockdep_is_held(&local->sta_mtx));
@@ -124,7 +125,7 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
        while (sta) {
                if ((sta->sdata == sdata ||
                     (sta->sdata->bss && sta->sdata->bss == sdata->bss)) &&
-                   memcmp(sta->sta.addr, addr, ETH_ALEN) == 0)
+                   compare_ether_addr(sta->sta.addr, addr) == 0)
                        break;
                sta = rcu_dereference_check(sta->hnext,
                                            lockdep_is_held(&local->sta_mtx));
@@ -1050,7 +1051,7 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
         * exchange. Also set EOSP to indicate this packet
         * ends the poll/service period.
         */
-       info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE |
+       info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
                       IEEE80211_TX_STATUS_EOSP |
                       IEEE80211_TX_CTL_REQ_TX_STATUS;
 
@@ -1177,7 +1178,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
                         * STA may still remain is PS mode after this frame
                         * exchange.
                         */
-                       info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE;
+                       info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
 
                        /*
                         * Use MoreData flag to indicate whether there are
index 23a97c9dc042f9caa284e4536f2deb28f1ce44ab..ab0576827baf84c9b22a0b0aef2177699c856adf 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/if_ether.h>
 #include <linux/workqueue.h>
 #include <linux/average.h>
+#include <linux/etherdevice.h>
 #include "key.h"
 
 /**
@@ -489,7 +490,7 @@ void for_each_sta_info_type_check(struct ieee80211_local *local,
                nxt = _sta ? rcu_dereference(_sta->hnext) : NULL        \
             )                                                          \
        /* compare address and run code only if it matches */           \
-       if (memcmp(_sta->sta.addr, (_addr), ETH_ALEN) == 0)
+       if (compare_ether_addr(_sta->sta.addr, (_addr)) == 0)
 
 /*
  * Get STA info by index, BROKEN!
@@ -528,6 +529,9 @@ void sta_info_init(struct ieee80211_local *local);
 void sta_info_stop(struct ieee80211_local *local);
 int sta_info_flush(struct ieee80211_local *local,
                   struct ieee80211_sub_if_data *sdata);
+void sta_set_rate_info_tx(struct sta_info *sta,
+                         const struct ieee80211_tx_rate *rate,
+                         struct rate_info *rinfo);
 void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
                          unsigned long exp_time);
 
index c928e4a4effd99c75e2d179342fd56c1722358e8..5f8f89e89d6b446e989d9d3ae546174a711e016f 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/etherdevice.h>
 #include <net/mac80211.h>
 #include <asm/unaligned.h>
 #include "ieee80211_i.h"
@@ -377,7 +378,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
 
        for_each_sta_info(local, hdr->addr1, sta, tmp) {
                /* skip wrong virtual interface */
-               if (memcmp(hdr->addr2, sta->sdata->vif.addr, ETH_ALEN))
+               if (compare_ether_addr(hdr->addr2, sta->sdata->vif.addr))
                        continue;
 
                if (info->flags & IEEE80211_TX_STATUS_EOSP)
index 7c021f25571683510b77b7c19f7a5fd76276adfa..570737df2d2244e729c9c9928a902592ccc3d120 100644 (file)
@@ -448,18 +448,23 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
        struct ieee80211_local *local = tx->local;
 
-       if (unlikely(!sta ||
-                    ieee80211_is_probe_resp(hdr->frame_control) ||
-                    ieee80211_is_auth(hdr->frame_control) ||
-                    ieee80211_is_assoc_resp(hdr->frame_control) ||
-                    ieee80211_is_reassoc_resp(hdr->frame_control)))
+       if (unlikely(!sta))
                return TX_CONTINUE;
 
        if (unlikely((test_sta_flag(sta, WLAN_STA_PS_STA) ||
                      test_sta_flag(sta, WLAN_STA_PS_DRIVER)) &&
-                    !(info->flags & IEEE80211_TX_CTL_POLL_RESPONSE))) {
+                    !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {
                int ac = skb_get_queue_mapping(tx->skb);
 
+               /* only deauth, disassoc and action are bufferable MMPDUs */
+               if (ieee80211_is_mgmt(hdr->frame_control) &&
+                   !ieee80211_is_deauth(hdr->frame_control) &&
+                   !ieee80211_is_disassoc(hdr->frame_control) &&
+                   !ieee80211_is_action(hdr->frame_control)) {
+                       info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
+                       return TX_CONTINUE;
+               }
+
 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
                printk(KERN_DEBUG "STA %pM aid %d: PS buffer for AC %d\n",
                       sta->sta.addr, sta->sta.aid, ac);
index f6e4cef92021c438c4086b44b130e4d62844c8d7..32f7a3b3d43ce0f4232ef890f004af5186dceb51 100644 (file)
@@ -572,24 +572,40 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
        size_t left = len;
        u8 *pos = start;
        bool calc_crc = filter != 0;
+       DECLARE_BITMAP(seen_elems, 256);
 
+       bitmap_zero(seen_elems, 256);
        memset(elems, 0, sizeof(*elems));
        elems->ie_start = start;
        elems->total_len = len;
 
        while (left >= 2) {
                u8 id, elen;
+               bool elem_parse_failed;
 
                id = *pos++;
                elen = *pos++;
                left -= 2;
 
-               if (elen > left)
+               if (elen > left) {
+                       elems->parse_error = true;
                        break;
+               }
+
+               if (id != WLAN_EID_VENDOR_SPECIFIC &&
+                   id != WLAN_EID_QUIET &&
+                   test_bit(id, seen_elems)) {
+                       elems->parse_error = true;
+                       left -= elen;
+                       pos += elen;
+                       continue;
+               }
 
                if (calc_crc && id < 64 && (filter & (1ULL << id)))
                        crc = crc32_be(crc, pos - 2, elen + 2);
 
+               elem_parse_failed = false;
+
                switch (id) {
                case WLAN_EID_SSID:
                        elems->ssid = pos;
@@ -615,7 +631,8 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
                        if (elen >= sizeof(struct ieee80211_tim_ie)) {
                                elems->tim = (void *)pos;
                                elems->tim_len = elen;
-                       }
+                       } else
+                               elem_parse_failed = true;
                        break;
                case WLAN_EID_IBSS_PARAMS:
                        elems->ibss_params = pos;
@@ -664,10 +681,14 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
                case WLAN_EID_HT_CAPABILITY:
                        if (elen >= sizeof(struct ieee80211_ht_cap))
                                elems->ht_cap_elem = (void *)pos;
+                       else
+                               elem_parse_failed = true;
                        break;
                case WLAN_EID_HT_INFORMATION:
                        if (elen >= sizeof(struct ieee80211_ht_info))
                                elems->ht_info_elem = (void *)pos;
+                       else
+                               elem_parse_failed = true;
                        break;
                case WLAN_EID_MESH_ID:
                        elems->mesh_id = pos;
@@ -676,6 +697,8 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
                case WLAN_EID_MESH_CONFIG:
                        if (elen >= sizeof(struct ieee80211_meshconf_ie))
                                elems->mesh_config = (void *)pos;
+                       else
+                               elem_parse_failed = true;
                        break;
                case WLAN_EID_PEER_MGMT:
                        elems->peering = pos;
@@ -696,6 +719,8 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
                case WLAN_EID_RANN:
                        if (elen >= sizeof(struct ieee80211_rann_ie))
                                elems->rann = (void *)pos;
+                       else
+                               elem_parse_failed = true;
                        break;
                case WLAN_EID_CHANNEL_SWITCH:
                        elems->ch_switch_elem = pos;
@@ -724,10 +749,18 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
                        break;
                }
 
+               if (elem_parse_failed)
+                       elems->parse_error = true;
+               else
+                       set_bit(id, seen_elems);
+
                left -= elen;
                pos += elen;
        }
 
+       if (left != 0)
+               elems->parse_error = true;
+
        return crc;
 }
 
@@ -737,7 +770,8 @@ void ieee802_11_parse_elems(u8 *start, size_t len,
        ieee802_11_parse_elems_crc(start, len, elems, 0, 0);
 }
 
-void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata)
+void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
+                              bool bss_notify)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_tx_queue_params qparam;
@@ -807,7 +841,9 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata)
        if (sdata->vif.type != NL80211_IFTYPE_MONITOR) {
                sdata->vif.bss_conf.qos =
                        sdata->vif.type != NL80211_IFTYPE_STATION;
-               ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
+               if (bss_notify)
+                       ieee80211_bss_info_change_notify(sdata,
+                                                        BSS_CHANGED_QOS);
        }
 }
 
@@ -829,7 +865,7 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
        else
                sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
 
-       ieee80211_set_wmm_default(sdata);
+       ieee80211_set_wmm_default(sdata, true);
 }
 
 u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
index da67756425ce927f233bd9f490e58befbefd4390..9d68441e2a5ab571ab5e5d20891251bedd3b2d7b 100644 (file)
@@ -30,7 +30,7 @@ static DEFINE_RWLOCK(proto_tab_lock);
 static const struct nfc_protocol *proto_tab[NFC_SOCKPROTO_MAX];
 
 static int nfc_sock_create(struct net *net, struct socket *sock, int proto,
-                                                               int kern)
+                          int kern)
 {
        int rc = -EPROTONOSUPPORT;
 
index 6089aca67b14de1b3396d3eea1d8baa83c676547..295d129864d246cb6c1a3b993dfbc54ebc826bad 100644 (file)
@@ -181,13 +181,13 @@ error:
        return rc;
 }
 
-int nfc_dep_link_up(struct nfc_dev *dev, int target_index,
-                                       u8 comm_mode, u8 rf_mode)
+int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
 {
        int rc = 0;
+       u8 *gb;
+       size_t gb_len;
 
-       pr_debug("dev_name=%s comm:%d rf:%d\n",
-                       dev_name(&dev->dev), comm_mode, rf_mode);
+       pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode);
 
        if (!dev->ops->dep_link_up)
                return -EOPNOTSUPP;
@@ -204,7 +204,13 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index,
                goto error;
        }
 
-       rc = dev->ops->dep_link_up(dev, target_index, comm_mode, rf_mode);
+       gb = nfc_llcp_general_bytes(dev, &gb_len);
+       if (gb_len > NFC_MAX_GT_LEN) {
+               rc = -EINVAL;
+               goto error;
+       }
+
+       rc = dev->ops->dep_link_up(dev, target_index, comm_mode, gb, gb_len);
 
 error:
        device_unlock(&dev->dev);
@@ -250,7 +256,7 @@ error:
 }
 
 int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
-                                       u8 comm_mode, u8 rf_mode)
+                      u8 comm_mode, u8 rf_mode)
 {
        dev->dep_link_up = true;
        dev->dep_rf_mode = rf_mode;
@@ -330,10 +336,8 @@ error:
  *
  * The user must wait for the callback before calling this function again.
  */
-int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
-                                       struct sk_buff *skb,
-                                       data_exchange_cb_t cb,
-                                       void *cb_context)
+int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
+                     data_exchange_cb_t cb, void *cb_context)
 {
        int rc;
 
@@ -357,8 +361,7 @@ error:
 
 int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
 {
-       pr_debug("dev_name=%s gb_len=%d\n",
-                       dev_name(&dev->dev), gb_len);
+       pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
 
        if (gb_len > NFC_MAX_GT_LEN)
                return -EINVAL;
@@ -367,12 +370,6 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
 }
 EXPORT_SYMBOL(nfc_set_remote_general_bytes);
 
-u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len)
-{
-       return nfc_llcp_general_bytes(dev, gt_len);
-}
-EXPORT_SYMBOL(nfc_get_local_general_bytes);
-
 /**
  * nfc_alloc_send_skb - allocate a skb for data exchange responses
  *
@@ -380,8 +377,8 @@ EXPORT_SYMBOL(nfc_get_local_general_bytes);
  * @gfp: gfp flags
  */
 struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
-                                       unsigned int flags, unsigned int size,
-                                       unsigned int *err)
+                                  unsigned int flags, unsigned int size,
+                                  unsigned int *err)
 {
        struct sk_buff *skb;
        unsigned int total_size;
@@ -428,8 +425,8 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
  * are found. After calling this function, the device driver must stop
  * polling for targets.
  */
-int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
-                                                       int n_targets)
+int nfc_targets_found(struct nfc_dev *dev,
+                     struct nfc_target *targets, int n_targets)
 {
        pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);
 
@@ -441,7 +438,7 @@ int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
 
        kfree(dev->targets);
        dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target),
-                                                               GFP_ATOMIC);
+                              GFP_ATOMIC);
 
        if (!dev->targets) {
                dev->n_targets = 0;
@@ -501,15 +498,14 @@ struct nfc_dev *nfc_get_device(unsigned idx)
  * @supported_protocols: NFC protocols supported by the device
  */
 struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
-                                       u32 supported_protocols,
-                                       int tx_headroom,
-                                       int tx_tailroom)
+                                   u32 supported_protocols,
+                                   int tx_headroom, int tx_tailroom)
 {
        static atomic_t dev_no = ATOMIC_INIT(0);
        struct nfc_dev *dev;
 
        if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
-               !ops->deactivate_target || !ops->data_exchange)
+           !ops->deactivate_target || !ops->data_exchange)
                return NULL;
 
        if (!supported_protocols)
index 151f2ef429c4cf93708bdb6d1524ccf6f2b1cb55..7b76eb7192f37fc50167d39ff6d2a1d7ffc400e4 100644 (file)
@@ -118,7 +118,7 @@ u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length)
 }
 
 int nfc_llcp_parse_tlv(struct nfc_llcp_local *local,
-                       u8 *tlv_array, u16 tlv_array_len)
+                      u8 *tlv_array, u16 tlv_array_len)
 {
        u8 *tlv = tlv_array, type, length, offset = 0;
 
@@ -152,6 +152,8 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local,
                case LLCP_TLV_RW:
                        local->remote_rw = llcp_tlv_rw(tlv);
                        break;
+               case LLCP_TLV_SN:
+                       break;
                default:
                        pr_err("Invalid gt tlv value 0x%x\n", type);
                        break;
@@ -162,15 +164,15 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local,
        }
 
        pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x rw %d\n",
-               local->remote_version, local->remote_miu,
-               local->remote_lto, local->remote_opt,
-               local->remote_wks, local->remote_rw);
+                local->remote_version, local->remote_miu,
+                local->remote_lto, local->remote_opt,
+                local->remote_wks, local->remote_rw);
 
        return 0;
 }
 
 static struct sk_buff *llcp_add_header(struct sk_buff *pdu,
-                                       u8 dsap, u8 ssap, u8 ptype)
+                                      u8 dsap, u8 ssap, u8 ptype)
 {
        u8 header[2];
 
@@ -186,7 +188,8 @@ static struct sk_buff *llcp_add_header(struct sk_buff *pdu,
        return pdu;
 }
 
-static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length)
+static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv,
+                                   u8 tlv_length)
 {
        /* XXX Add an skb length check */
 
@@ -199,7 +202,7 @@ static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length)
 }
 
 static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock,
-                                                       u8 cmd, u16 size)
+                                        u8 cmd, u16 size)
 {
        struct sk_buff *skb;
        int err;
@@ -208,7 +211,7 @@ static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock,
                return NULL;
 
        skb = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT,
-                                       size + LLCP_HEADER_SIZE, &err);
+                                size + LLCP_HEADER_SIZE, &err);
        if (skb == NULL) {
                pr_err("Could not allocate PDU\n");
                return NULL;
@@ -276,7 +279,7 @@ int nfc_llcp_send_symm(struct nfc_dev *dev)
        skb = llcp_add_header(skb, 0, 0, LLCP_PDU_SYMM);
 
        return nfc_data_exchange(dev, local->target_idx, skb,
-                                       nfc_llcp_recv, local);
+                                nfc_llcp_recv, local);
 }
 
 int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
@@ -284,6 +287,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
        struct nfc_llcp_local *local;
        struct sk_buff *skb;
        u8 *service_name_tlv = NULL, service_name_tlv_length;
+       u8 *miux_tlv = NULL, miux_tlv_length;
+       u8 *rw_tlv = NULL, rw_tlv_length, rw;
+       __be16 miux;
        int err;
        u16 size = 0;
 
@@ -295,12 +301,21 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
 
        if (sock->service_name != NULL) {
                service_name_tlv = nfc_llcp_build_tlv(LLCP_TLV_SN,
-                                       sock->service_name,
-                                       sock->service_name_len,
-                                       &service_name_tlv_length);
+                                                     sock->service_name,
+                                                     sock->service_name_len,
+                                                     &service_name_tlv_length);
                size += service_name_tlv_length;
        }
 
+       miux = cpu_to_be16(LLCP_MAX_MIUX);
+       miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0,
+                                     &miux_tlv_length);
+       size += miux_tlv_length;
+
+       rw = LLCP_MAX_RW;
+       rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
+       size += rw_tlv_length;
+
        pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len);
 
        skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size);
@@ -311,7 +326,10 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
 
        if (service_name_tlv != NULL)
                skb = llcp_add_tlv(skb, service_name_tlv,
-                                       service_name_tlv_length);
+                                  service_name_tlv_length);
+
+       skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
+       skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
 
        skb_queue_tail(&local->tx_queue, skb);
 
@@ -321,6 +339,8 @@ error_tlv:
        pr_err("error %d\n", err);
 
        kfree(service_name_tlv);
+       kfree(miux_tlv);
+       kfree(rw_tlv);
 
        return err;
 }
@@ -329,6 +349,11 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
 {
        struct nfc_llcp_local *local;
        struct sk_buff *skb;
+       u8 *miux_tlv = NULL, miux_tlv_length;
+       u8 *rw_tlv = NULL, rw_tlv_length, rw;
+       __be16 miux;
+       int err;
+       u16 size = 0;
 
        pr_debug("Sending CC\n");
 
@@ -336,13 +361,35 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
        if (local == NULL)
                return -ENODEV;
 
-       skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, 0);
-       if (skb == NULL)
-               return -ENOMEM;
+       miux = cpu_to_be16(LLCP_MAX_MIUX);
+       miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0,
+                                     &miux_tlv_length);
+       size += miux_tlv_length;
+
+       rw = LLCP_MAX_RW;
+       rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
+       size += rw_tlv_length;
+
+       skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size);
+       if (skb == NULL) {
+               err = -ENOMEM;
+               goto error_tlv;
+       }
+
+       skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
+       skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
 
        skb_queue_tail(&local->tx_queue, skb);
 
        return 0;
+
+error_tlv:
+       pr_err("error %d\n", err);
+
+       kfree(miux_tlv);
+       kfree(rw_tlv);
+
+       return err;
 }
 
 int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason)
@@ -397,3 +444,87 @@ int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock)
 
        return 0;
 }
+
+int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
+                         struct msghdr *msg, size_t len)
+{
+       struct sk_buff *pdu;
+       struct sock *sk = &sock->sk;
+       struct nfc_llcp_local *local;
+       size_t frag_len = 0, remaining_len;
+       u8 *msg_data, *msg_ptr;
+
+       pr_debug("Send I frame len %zd\n", len);
+
+       local = sock->local;
+       if (local == NULL)
+               return -ENODEV;
+
+       msg_data = kzalloc(len, GFP_KERNEL);
+       if (msg_data == NULL)
+               return -ENOMEM;
+
+       if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) {
+               kfree(msg_data);
+               return -EFAULT;
+       }
+
+       remaining_len = len;
+       msg_ptr = msg_data;
+
+       while (remaining_len > 0) {
+
+               frag_len = min_t(u16, local->remote_miu, remaining_len);
+
+               pr_debug("Fragment %zd bytes remaining %zd",
+                        frag_len, remaining_len);
+
+               pdu = llcp_allocate_pdu(sock, LLCP_PDU_I,
+                                       frag_len + LLCP_SEQUENCE_SIZE);
+               if (pdu == NULL)
+                       return -ENOMEM;
+
+               skb_put(pdu, LLCP_SEQUENCE_SIZE);
+
+               memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
+
+               skb_queue_head(&sock->tx_queue, pdu);
+
+               lock_sock(sk);
+
+               nfc_llcp_queue_i_frames(sock);
+
+               release_sock(sk);
+
+               remaining_len -= frag_len;
+               msg_ptr += len;
+       }
+
+       kfree(msg_data);
+
+       return 0;
+}
+
+int nfc_llcp_send_rr(struct nfc_llcp_sock *sock)
+{
+       struct sk_buff *skb;
+       struct nfc_llcp_local *local;
+
+       pr_debug("Send rr nr %d\n", sock->recv_n);
+
+       local = sock->local;
+       if (local == NULL)
+               return -ENODEV;
+
+       skb = llcp_allocate_pdu(sock, LLCP_PDU_RR, LLCP_SEQUENCE_SIZE);
+       if (skb == NULL)
+               return -ENOMEM;
+
+       skb_put(skb, LLCP_SEQUENCE_SIZE);
+
+       skb->data[2] = sock->recv_n % 16;
+
+       skb_queue_head(&local->tx_queue, skb);
+
+       return 0;
+}
index 1d32680807d67f3729bb19724d9c09ba2f4cc599..17a578f641f12f8bf5b98a58996af292e5ef50a0 100644 (file)
@@ -37,7 +37,6 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
        struct sock *sk, *parent_sk;
        int i;
 
-
        mutex_lock(&local->socket_lock);
 
        for (i = 0; i < LLCP_MAX_SAP; i++) {
@@ -47,7 +46,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
 
                /* Release all child sockets */
                list_for_each_entry_safe(s, n, &parent->list, list) {
-                       list_del(&s->list);
+                       list_del_init(&s->list);
                        sk = &s->sk;
 
                        lock_sock(sk);
@@ -56,9 +55,12 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
                                nfc_put_device(s->dev);
 
                        sk->sk_state = LLCP_CLOSED;
-                       sock_set_flag(sk, SOCK_DEAD);
 
                        release_sock(sk);
+
+                       sock_orphan(sk);
+
+                       s->local = NULL;
                }
 
                parent_sk = &parent->sk;
@@ -70,18 +72,19 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
                        struct sock *accept_sk;
 
                        list_for_each_entry_safe(lsk, n, &parent->accept_queue,
-                                                               accept_queue) {
+                                                accept_queue) {
                                accept_sk = &lsk->sk;
                                lock_sock(accept_sk);
 
                                nfc_llcp_accept_unlink(accept_sk);
 
                                accept_sk->sk_state = LLCP_CLOSED;
-                               sock_set_flag(accept_sk, SOCK_DEAD);
 
                                release_sock(accept_sk);
 
                                sock_orphan(accept_sk);
+
+                               lsk->local = NULL;
                        }
                }
 
@@ -89,18 +92,32 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
                        nfc_put_device(parent->dev);
 
                parent_sk->sk_state = LLCP_CLOSED;
-               sock_set_flag(parent_sk, SOCK_DEAD);
 
                release_sock(parent_sk);
+
+               sock_orphan(parent_sk);
+
+               parent->local = NULL;
        }
 
        mutex_unlock(&local->socket_lock);
 }
 
+static void nfc_llcp_clear_sdp(struct nfc_llcp_local *local)
+{
+       mutex_lock(&local->sdp_lock);
+
+       local->local_wks = 0;
+       local->local_sdp = 0;
+       local->local_sap = 0;
+
+       mutex_unlock(&local->sdp_lock);
+}
+
 static void nfc_llcp_timeout_work(struct work_struct *work)
 {
        struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local,
-                                                       timeout_work);
+                                                   timeout_work);
 
        nfc_dep_link_down(local->dev);
 }
@@ -146,7 +163,7 @@ static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len)
 
        num_wks = ARRAY_SIZE(wks);
 
-       for (sap = 0 ; sap < num_wks; sap++) {
+       for (sap = 0; sap < num_wks; sap++) {
                if (wks[sap] == NULL)
                        continue;
 
@@ -158,13 +175,13 @@ static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len)
 }
 
 u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
-                               struct nfc_llcp_sock *sock)
+                        struct nfc_llcp_sock *sock)
 {
        mutex_lock(&local->sdp_lock);
 
        if (sock->service_name != NULL && sock->service_name_len > 0) {
                int ssap = nfc_llcp_wks_sap(sock->service_name,
-                                               sock->service_name_len);
+                                           sock->service_name_len);
 
                if (ssap > 0) {
                        pr_debug("WKS %d\n", ssap);
@@ -176,7 +193,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
                                return LLCP_SAP_MAX;
                        }
 
-                       set_bit(BIT(ssap), &local->local_wks);
+                       set_bit(ssap, &local->local_wks);
                        mutex_unlock(&local->sdp_lock);
 
                        return ssap;
@@ -195,25 +212,25 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
 
                pr_debug("SDP ssap %d\n", LLCP_WKS_NUM_SAP + ssap);
 
-               set_bit(BIT(ssap), &local->local_sdp);
+               set_bit(ssap, &local->local_sdp);
                mutex_unlock(&local->sdp_lock);
 
                return LLCP_WKS_NUM_SAP + ssap;
 
        } else if (sock->ssap != 0) {
                if (sock->ssap < LLCP_WKS_NUM_SAP) {
-                       if (!(local->local_wks & BIT(sock->ssap))) {
-                               set_bit(BIT(sock->ssap), &local->local_wks);
+                       if (!test_bit(sock->ssap, &local->local_wks)) {
+                               set_bit(sock->ssap, &local->local_wks);
                                mutex_unlock(&local->sdp_lock);
 
                                return sock->ssap;
                        }
 
                } else if (sock->ssap < LLCP_SDP_NUM_SAP) {
-                       if (!(local->local_sdp &
-                               BIT(sock->ssap - LLCP_WKS_NUM_SAP))) {
-                               set_bit(BIT(sock->ssap - LLCP_WKS_NUM_SAP),
-                                                       &local->local_sdp);
+                       if (!test_bit(sock->ssap - LLCP_WKS_NUM_SAP,
+                                     &local->local_sdp)) {
+                               set_bit(sock->ssap - LLCP_WKS_NUM_SAP,
+                                       &local->local_sdp);
                                mutex_unlock(&local->sdp_lock);
 
                                return sock->ssap;
@@ -238,7 +255,7 @@ u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local)
                return LLCP_SAP_MAX;
        }
 
-       set_bit(BIT(local_ssap), &local->local_sap);
+       set_bit(local_ssap, &local->local_sap);
 
        mutex_unlock(&local->sdp_lock);
 
@@ -265,12 +282,12 @@ void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap)
 
        mutex_lock(&local->sdp_lock);
 
-       clear_bit(1 << local_ssap, sdp);
+       clear_bit(local_ssap, sdp);
 
        mutex_unlock(&local->sdp_lock);
 }
 
-u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *general_bytes_len)
+u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len)
 {
        struct nfc_llcp_local *local;
 
@@ -294,7 +311,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local)
 
        version = LLCP_VERSION_11;
        version_tlv = nfc_llcp_build_tlv(LLCP_TLV_VERSION, &version,
-                                                       1, &version_length);
+                                        1, &version_length);
        gb_len += version_length;
 
        /* 1500 ms */
@@ -304,7 +321,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local)
 
        pr_debug("Local wks 0x%lx\n", local->local_wks);
        wks_tlv = nfc_llcp_build_tlv(LLCP_TLV_WKS, (u8 *)&local->local_wks, 2,
-                                                               &wks_length);
+                                    &wks_length);
        gb_len += wks_length;
 
        gb_len += ARRAY_SIZE(llcp_magic);
@@ -349,8 +366,7 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len)
        memcpy(local->remote_gb, gb, gb_len);
        local->remote_gb_len = gb_len;
 
-       if (local->remote_gb == NULL ||
-                       local->remote_gb_len == 0)
+       if (local->remote_gb == NULL || local->remote_gb_len == 0)
                return -ENODEV;
 
        if (memcmp(local->remote_gb, llcp_magic, 3)) {
@@ -359,26 +375,27 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len)
        }
 
        return nfc_llcp_parse_tlv(local,
-                       &local->remote_gb[3], local->remote_gb_len - 3);
+                                 &local->remote_gb[3],
+                                 local->remote_gb_len - 3);
 }
 
 static void nfc_llcp_tx_work(struct work_struct *work)
 {
        struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local,
-                                                       tx_work);
+                                                   tx_work);
        struct sk_buff *skb;
 
        skb = skb_dequeue(&local->tx_queue);
        if (skb != NULL) {
                pr_debug("Sending pending skb\n");
                nfc_data_exchange(local->dev, local->target_idx,
-                                       skb, nfc_llcp_recv, local);
+                                 skb, nfc_llcp_recv, local);
        } else {
                nfc_llcp_send_symm(local->dev);
        }
 
        mod_timer(&local->link_timer,
-                       jiffies + msecs_to_jiffies(local->remote_lto));
+                 jiffies + msecs_to_jiffies(local->remote_lto));
 }
 
 static u8 nfc_llcp_dsap(struct sk_buff *pdu)
@@ -408,13 +425,13 @@ static u8 nfc_llcp_nr(struct sk_buff *pdu)
 
 static void nfc_llcp_set_nrns(struct nfc_llcp_sock *sock, struct sk_buff *pdu)
 {
-       pdu->data[2] = (sock->send_n << 4) | ((sock->recv_n - 1) % 16);
+       pdu->data[2] = (sock->send_n << 4) | (sock->recv_n % 16);
        sock->send_n = (sock->send_n + 1) % 16;
        sock->recv_ack_n = (sock->recv_n - 1) % 16;
 }
 
 static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
-                                               u8 ssap, u8 dsap)
+                                              u8 ssap, u8 dsap)
 {
        struct nfc_llcp_sock *sock, *llcp_sock, *n;
 
@@ -438,7 +455,7 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
 
        list_for_each_entry_safe(llcp_sock, n, &sock->list, list) {
                pr_debug("llcp_sock %p sk %p dsap %d\n", llcp_sock,
-                               &llcp_sock->sk, llcp_sock->dsap);
+                        &llcp_sock->sk, llcp_sock->dsap);
                if (llcp_sock->dsap == dsap) {
                        sock_hold(&llcp_sock->sk);
                        mutex_unlock(&local->socket_lock);
@@ -482,7 +499,7 @@ static u8 *nfc_llcp_connect_sn(struct sk_buff *skb, size_t *sn_len)
 }
 
 static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
-                               struct sk_buff *skb)
+                                 struct sk_buff *skb)
 {
        struct sock *new_sk, *parent;
        struct nfc_llcp_sock *sock, *new_sock;
@@ -494,7 +511,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
        pr_debug("%d %d\n", dsap, ssap);
 
        nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE],
-                               skb->len - LLCP_HEADER_SIZE);
+                          skb->len - LLCP_HEADER_SIZE);
 
        if (dsap != LLCP_SAP_SDP) {
                bound_sap = dsap;
@@ -513,7 +530,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
                lock_sock(&sock->sk);
 
                if (sock->dsap == LLCP_SAP_SDP &&
-                               sock->sk.sk_state == LLCP_LISTEN)
+                   sock->sk.sk_state == LLCP_LISTEN)
                        goto enqueue;
        } else {
                u8 *sn;
@@ -529,23 +546,23 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
 
                mutex_lock(&local->socket_lock);
                for (bound_sap = 0; bound_sap < LLCP_LOCAL_SAP_OFFSET;
-                                                               bound_sap++) {
+                    bound_sap++) {
                        sock = local->sockets[bound_sap];
                        if (sock == NULL)
                                continue;
 
                        if (sock->service_name == NULL ||
-                               sock->service_name_len == 0)
+                           sock->service_name_len == 0)
                                        continue;
 
                        if (sock->service_name_len != sn_len)
                                continue;
 
                        if (sock->dsap == LLCP_SAP_SDP &&
-                                       sock->sk.sk_state == LLCP_LISTEN &&
-                                       !memcmp(sn, sock->service_name, sn_len)) {
+                           sock->sk.sk_state == LLCP_LISTEN &&
+                           !memcmp(sn, sock->service_name, sn_len)) {
                                pr_debug("Found service name at SAP %d\n",
-                                                               bound_sap);
+                                        bound_sap);
                                sock_hold(&sock->sk);
                                mutex_unlock(&local->socket_lock);
 
@@ -570,8 +587,7 @@ enqueue:
                goto fail;
        }
 
-       new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type,
-                                    GFP_ATOMIC);
+       new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, GFP_ATOMIC);
        if (new_sk == NULL) {
                reason = LLCP_DM_REJ;
                release_sock(&sock->sk);
@@ -616,8 +632,39 @@ fail:
 
 }
 
+int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
+{
+       int nr_frames = 0;
+       struct nfc_llcp_local *local = sock->local;
+
+       pr_debug("Remote ready %d tx queue len %d remote rw %d",
+                sock->remote_ready, skb_queue_len(&sock->tx_pending_queue),
+                local->remote_rw);
+
+       /* Try to queue some I frames for transmission */
+       while (sock->remote_ready &&
+              skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) {
+               struct sk_buff *pdu, *pending_pdu;
+
+               pdu = skb_dequeue(&sock->tx_queue);
+               if (pdu == NULL)
+                       break;
+
+               /* Update N(S)/N(R) */
+               nfc_llcp_set_nrns(sock, pdu);
+
+               pending_pdu = skb_clone(pdu, GFP_KERNEL);
+
+               skb_queue_tail(&local->tx_queue, pdu);
+               skb_queue_tail(&sock->tx_pending_queue, pending_pdu);
+               nr_frames++;
+       }
+
+       return nr_frames;
+}
+
 static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
-                               struct sk_buff *skb)
+                              struct sk_buff *skb)
 {
        struct nfc_llcp_sock *llcp_sock;
        struct sock *sk;
@@ -644,15 +691,15 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
                nfc_llcp_sock_put(llcp_sock);
        }
 
-       if (ns == llcp_sock->recv_n)
-               llcp_sock->recv_n = (llcp_sock->recv_n + 1) % 16;
-       else
-               pr_err("Received out of sequence I PDU\n");
-
        /* Pass the payload upstream */
        if (ptype == LLCP_PDU_I) {
                pr_debug("I frame, queueing on %p\n", &llcp_sock->sk);
 
+               if (ns == llcp_sock->recv_n)
+                       llcp_sock->recv_n = (llcp_sock->recv_n + 1) % 16;
+               else
+                       pr_err("Received out of sequence I PDU\n");
+
                skb_pull(skb, LLCP_HEADER_SIZE + LLCP_SEQUENCE_SIZE);
                if (sock_queue_rcv_skb(&llcp_sock->sk, skb)) {
                        pr_err("receive queue is full\n");
@@ -673,30 +720,20 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
                        }
        }
 
-       /* Queue some I frames for transmission */
-       while (llcp_sock->remote_ready &&
-               skb_queue_len(&llcp_sock->tx_pending_queue) <= local->remote_rw) {
-               struct sk_buff *pdu, *pending_pdu;
-
-               pdu = skb_dequeue(&llcp_sock->tx_queue);
-               if (pdu == NULL)
-                       break;
-
-               /* Update N(S)/N(R) */
-               nfc_llcp_set_nrns(llcp_sock, pdu);
+       if (ptype == LLCP_PDU_RR)
+               llcp_sock->remote_ready = true;
+       else if (ptype == LLCP_PDU_RNR)
+               llcp_sock->remote_ready = false;
 
-               pending_pdu = skb_clone(pdu, GFP_KERNEL);
-
-               skb_queue_tail(&local->tx_queue, pdu);
-               skb_queue_tail(&llcp_sock->tx_pending_queue, pending_pdu);
-       }
+       if (nfc_llcp_queue_i_frames(llcp_sock) == 0)
+               nfc_llcp_send_rr(llcp_sock);
 
        release_sock(sk);
        nfc_llcp_sock_put(llcp_sock);
 }
 
 static void nfc_llcp_recv_disc(struct nfc_llcp_local *local,
-                               struct sk_buff *skb)
+                              struct sk_buff *skb)
 {
        struct nfc_llcp_sock *llcp_sock;
        struct sock *sk;
@@ -718,7 +755,6 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local,
                nfc_llcp_sock_put(llcp_sock);
        }
 
-
        if (sk->sk_state == LLCP_CONNECTED) {
                nfc_put_device(local->dev);
                sk->sk_state = LLCP_CLOSED;
@@ -731,13 +767,11 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local,
        nfc_llcp_sock_put(llcp_sock);
 }
 
-static void nfc_llcp_recv_cc(struct nfc_llcp_local *local,
-                               struct sk_buff *skb)
+static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb)
 {
        struct nfc_llcp_sock *llcp_sock;
        u8 dsap, ssap;
 
-
        dsap = nfc_llcp_dsap(skb);
        ssap = nfc_llcp_ssap(skb);
 
@@ -756,7 +790,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local,
        llcp_sock->dsap = ssap;
 
        nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE],
-                               skb->len - LLCP_HEADER_SIZE);
+                          skb->len - LLCP_HEADER_SIZE);
 
        nfc_llcp_sock_put(llcp_sock);
 }
@@ -764,7 +798,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local,
 static void nfc_llcp_rx_work(struct work_struct *work)
 {
        struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local,
-                                                               rx_work);
+                                                   rx_work);
        u8 dsap, ssap, ptype;
        struct sk_buff *skb;
 
@@ -802,6 +836,7 @@ static void nfc_llcp_rx_work(struct work_struct *work)
 
        case LLCP_PDU_I:
        case LLCP_PDU_RR:
+       case LLCP_PDU_RNR:
                pr_debug("I frame\n");
                nfc_llcp_recv_hdlc(local, skb);
                break;
@@ -821,7 +856,7 @@ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err)
 
        pr_debug("Received an LLCP PDU\n");
        if (err < 0) {
-               pr_err("err %d", err);
+               pr_err("err %d\n", err);
                return;
        }
 
@@ -840,6 +875,8 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev)
        if (local == NULL)
                return;
 
+       nfc_llcp_clear_sdp(local);
+
        /* Close and purge all existing sockets */
        nfc_llcp_socket_release(local);
 }
@@ -865,7 +902,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
                queue_work(local->tx_wq, &local->tx_work);
        } else {
                mod_timer(&local->link_timer,
-                       jiffies + msecs_to_jiffies(local->remote_lto));
+                         jiffies + msecs_to_jiffies(local->remote_lto));
        }
 }
 
@@ -891,8 +928,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
        skb_queue_head_init(&local->tx_queue);
        INIT_WORK(&local->tx_work, nfc_llcp_tx_work);
        snprintf(name, sizeof(name), "%s_llcp_tx_wq", dev_name(dev));
-       local->tx_wq = alloc_workqueue(name,
-                       WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+       local->tx_wq =
+               alloc_workqueue(name,
+                               WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM,
+                               1);
        if (local->tx_wq == NULL) {
                err = -ENOMEM;
                goto err_local;
@@ -901,8 +940,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
        local->rx_pending = NULL;
        INIT_WORK(&local->rx_work, nfc_llcp_rx_work);
        snprintf(name, sizeof(name), "%s_llcp_rx_wq", dev_name(dev));
-       local->rx_wq = alloc_workqueue(name,
-                       WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+       local->rx_wq =
+               alloc_workqueue(name,
+                               WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM,
+                               1);
        if (local->rx_wq == NULL) {
                err = -ENOMEM;
                goto err_tx_wq;
@@ -910,8 +951,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
 
        INIT_WORK(&local->timeout_work, nfc_llcp_timeout_work);
        snprintf(name, sizeof(name), "%s_llcp_timeout_wq", dev_name(dev));
-       local->timeout_wq = alloc_workqueue(name,
-                       WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+       local->timeout_wq =
+               alloc_workqueue(name,
+                               WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM,
+                               1);
        if (local->timeout_wq == NULL) {
                err = -ENOMEM;
                goto err_rx_wq;
index 0ad2e3361584a074ab2c0a09b489d1056889f247..50680ce5ae4396435552936f22cf3a8d17e26a25 100644 (file)
@@ -28,6 +28,10 @@ enum llcp_state {
 #define LLCP_DEFAULT_RW  1
 #define LLCP_DEFAULT_MIU 128
 
+#define LLCP_MAX_LTO  0xff
+#define LLCP_MAX_RW   15
+#define LLCP_MAX_MIUX 0x7ff
+
 #define LLCP_WKS_NUM_SAP   16
 #define LLCP_SDP_NUM_SAP   16
 #define LLCP_LOCAL_NUM_SAP 32
@@ -162,9 +166,10 @@ struct nfc_llcp_sock {
 
 struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);
 u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
-                               struct nfc_llcp_sock *sock);
+                        struct nfc_llcp_sock *sock);
 u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local);
 void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap);
+int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock);
 
 /* Sock API */
 struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp);
@@ -175,7 +180,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock);
 
 /* TLV API */
 int nfc_llcp_parse_tlv(struct nfc_llcp_local *local,
-                       u8 *tlv_array, u16 tlv_array_len);
+                      u8 *tlv_array, u16 tlv_array_len);
 
 /* Commands API */
 void nfc_llcp_recv(void *data, struct sk_buff *skb, int err);
@@ -187,6 +192,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock);
 int nfc_llcp_send_cc(struct nfc_llcp_sock *sock);
 int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason);
 int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock);
+int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
+                         struct msghdr *msg, size_t len);
+int nfc_llcp_send_rr(struct nfc_llcp_sock *sock);
 
 /* Socket API */
 int __init nfc_llcp_sock_init(void);
index f738ccd535f1c984f3a741ac32c43acc6bc3c7c5..c13e02ebdef9b08e5c995f5cbb5a671db42d8e3c 100644 (file)
@@ -78,9 +78,11 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
        llcp_sock->local = local;
        llcp_sock->nfc_protocol = llcp_addr.nfc_protocol;
        llcp_sock->service_name_len = min_t(unsigned int,
-                       llcp_addr.service_name_len, NFC_LLCP_MAX_SERVICE_NAME);
+                                           llcp_addr.service_name_len,
+                                           NFC_LLCP_MAX_SERVICE_NAME);
        llcp_sock->service_name = kmemdup(llcp_addr.service_name,
-                               llcp_sock->service_name_len, GFP_KERNEL);
+                                         llcp_sock->service_name_len,
+                                         GFP_KERNEL);
 
        llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock);
        if (llcp_sock->ssap == LLCP_MAX_SAP)
@@ -110,7 +112,7 @@ static int llcp_sock_listen(struct socket *sock, int backlog)
        lock_sock(sk);
 
        if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM)
-                       || sk->sk_state != LLCP_BOUND) {
+           || sk->sk_state != LLCP_BOUND) {
                ret = -EBADFD;
                goto error;
        }
@@ -149,13 +151,13 @@ void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk)
        sock_hold(sk);
 
        list_add_tail(&llcp_sock->accept_queue,
-                       &llcp_sock_parent->accept_queue);
+                     &llcp_sock_parent->accept_queue);
        llcp_sock->parent = parent;
        sk_acceptq_added(parent);
 }
 
 struct sock *nfc_llcp_accept_dequeue(struct sock *parent,
-                                       struct socket *newsock)
+                                    struct socket *newsock)
 {
        struct nfc_llcp_sock *lsk, *n, *llcp_parent;
        struct sock *sk;
@@ -163,7 +165,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent,
        llcp_parent = nfc_llcp_sock(parent);
 
        list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue,
-                                                       accept_queue) {
+                                accept_queue) {
                sk = &lsk->sk;
                lock_sock(sk);
 
@@ -192,7 +194,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent,
 }
 
 static int llcp_sock_accept(struct socket *sock, struct socket *newsock,
-                                                               int flags)
+                           int flags)
 {
        DECLARE_WAITQUEUE(wait, current);
        struct sock *sk = sock->sk, *new_sk;
@@ -248,7 +250,7 @@ error:
 static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr,
                             int *len, int peer)
 {
-       struct sockaddr_nfc_llcp *llcp_addr = (struct sockaddr_nfc_llcp *) addr;
+       struct sockaddr_nfc_llcp *llcp_addr = (struct sockaddr_nfc_llcp *)addr;
        struct sock *sk = sock->sk;
        struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
 
@@ -262,7 +264,7 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr,
        llcp_addr->ssap = llcp_sock->ssap;
        llcp_addr->service_name_len = llcp_sock->service_name_len;
        memcpy(llcp_addr->service_name, llcp_sock->service_name,
-                                       llcp_addr->service_name_len);
+              llcp_addr->service_name_len);
 
        return 0;
 }
@@ -275,7 +277,7 @@ static inline unsigned int llcp_accept_poll(struct sock *parent)
        parent_sock = nfc_llcp_sock(parent);
 
        list_for_each_entry_safe(llcp_sock, n, &parent_sock->accept_queue,
-                                                               accept_queue) {
+                                accept_queue) {
                sk = &llcp_sock->sk;
 
                if (sk->sk_state == LLCP_CONNECTED)
@@ -286,7 +288,7 @@ static inline unsigned int llcp_accept_poll(struct sock *parent)
 }
 
 static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
-                                                       poll_table *wait)
+                                  poll_table *wait)
 {
        struct sock *sk = sock->sk;
        unsigned int mask = 0;
@@ -315,6 +317,7 @@ static int llcp_sock_release(struct socket *sock)
        struct sock *sk = sock->sk;
        struct nfc_llcp_local *local;
        struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
+       int err = 0;
 
        if (!sk)
                return 0;
@@ -322,25 +325,17 @@ static int llcp_sock_release(struct socket *sock)
        pr_debug("%p\n", sk);
 
        local = llcp_sock->local;
-       if (local == NULL)
-               return -ENODEV;
+       if (local == NULL) {
+               err = -ENODEV;
+               goto out;
+       }
 
        mutex_lock(&local->socket_lock);
 
-       if (llcp_sock == local->sockets[llcp_sock->ssap]) {
+       if (llcp_sock == local->sockets[llcp_sock->ssap])
                local->sockets[llcp_sock->ssap] = NULL;
-       } else {
-               struct nfc_llcp_sock *parent, *s, *n;
-
-               parent = local->sockets[llcp_sock->ssap];
-
-               list_for_each_entry_safe(s, n, &parent->list, list)
-                       if (llcp_sock == s) {
-                               list_del(&s->list);
-                               break;
-                       }
-
-       }
+       else
+               list_del_init(&llcp_sock->list);
 
        mutex_unlock(&local->socket_lock);
 
@@ -355,7 +350,7 @@ static int llcp_sock_release(struct socket *sock)
                struct sock *accept_sk;
 
                list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue,
-                                                               accept_queue) {
+                                        accept_queue) {
                        accept_sk = &lsk->sk;
                        lock_sock(accept_sk);
 
@@ -364,31 +359,27 @@ static int llcp_sock_release(struct socket *sock)
 
                        release_sock(accept_sk);
 
-                       sock_set_flag(sk, SOCK_DEAD);
                        sock_orphan(accept_sk);
-                       sock_put(accept_sk);
                }
        }
 
        /* Freeing the SAP */
        if ((sk->sk_state == LLCP_CONNECTED
-                       && llcp_sock->ssap > LLCP_LOCAL_SAP_OFFSET) ||
-           sk->sk_state == LLCP_BOUND ||
-           sk->sk_state == LLCP_LISTEN)
+            && llcp_sock->ssap > LLCP_LOCAL_SAP_OFFSET) ||
+           sk->sk_state == LLCP_BOUND || sk->sk_state == LLCP_LISTEN)
                nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap);
 
-       sock_set_flag(sk, SOCK_DEAD);
-
        release_sock(sk);
 
+out:
        sock_orphan(sk);
        sock_put(sk);
 
-       return 0;
+       return err;
 }
 
 static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
-                                                       int len, int flags)
+                            int len, int flags)
 {
        struct sock *sk = sock->sk;
        struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
@@ -400,7 +391,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
        pr_debug("sock %p sk %p flags 0x%x\n", sock, sk, flags);
 
        if (!addr || len < sizeof(struct sockaddr_nfc) ||
-                       addr->sa_family != AF_NFC) {
+           addr->sa_family != AF_NFC) {
                pr_err("Invalid socket\n");
                return -EINVAL;
        }
@@ -411,7 +402,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
        }
 
        pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n", addr->dev_idx,
-                                       addr->target_idx, addr->nfc_protocol);
+                addr->target_idx, addr->nfc_protocol);
 
        lock_sock(sk);
 
@@ -441,7 +432,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
        device_unlock(&dev->dev);
 
        if (local->rf_mode == NFC_RF_INITIATOR &&
-                       addr->target_idx != local->target_idx) {
+           addr->target_idx != local->target_idx) {
                ret = -ENOLINK;
                goto put_dev;
        }
@@ -459,9 +450,11 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
                llcp_sock->dsap = LLCP_SAP_SDP;
        llcp_sock->nfc_protocol = addr->nfc_protocol;
        llcp_sock->service_name_len = min_t(unsigned int,
-                       addr->service_name_len, NFC_LLCP_MAX_SERVICE_NAME);
+                                           addr->service_name_len,
+                                           NFC_LLCP_MAX_SERVICE_NAME);
        llcp_sock->service_name = kmemdup(addr->service_name,
-                                llcp_sock->service_name_len, GFP_KERNEL);
+                                         llcp_sock->service_name_len,
+                                         GFP_KERNEL);
 
        local->sockets[llcp_sock->ssap] = llcp_sock;
 
@@ -482,6 +475,34 @@ error:
        return ret;
 }
 
+static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
+                            struct msghdr *msg, size_t len)
+{
+       struct sock *sk = sock->sk;
+       struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
+       int ret;
+
+       pr_debug("sock %p sk %p", sock, sk);
+
+       ret = sock_error(sk);
+       if (ret)
+               return ret;
+
+       if (msg->msg_flags & MSG_OOB)
+               return -EOPNOTSUPP;
+
+       lock_sock(sk);
+
+       if (sk->sk_state != LLCP_CONNECTED) {
+               release_sock(sk);
+               return -ENOTCONN;
+       }
+
+       release_sock(sk);
+
+       return nfc_llcp_send_i_frame(llcp_sock, msg, len);
+}
+
 static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
                             struct msghdr *msg, size_t len, int flags)
 {
@@ -496,7 +517,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
        lock_sock(sk);
 
        if (sk->sk_state == LLCP_CLOSED &&
-                       skb_queue_empty(&sk->sk_receive_queue)) {
+           skb_queue_empty(&sk->sk_receive_queue)) {
                release_sock(sk);
                return 0;
        }
@@ -509,7 +530,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
        skb = skb_recv_datagram(sk, flags, noblock, &err);
        if (!skb) {
                pr_err("Recv datagram failed state %d %d %d",
-                               sk->sk_state, err, sock_error(sk));
+                      sk->sk_state, err, sock_error(sk));
 
                if (sk->sk_shutdown & RCV_SHUTDOWN)
                        return 0;
@@ -517,7 +538,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
                return err;
        }
 
-       rlen   = skb->len;              /* real length of skb */
+       rlen = skb->len;                /* real length of skb */
        copied = min_t(unsigned int, rlen, len);
 
        cskb = skb;
@@ -567,7 +588,7 @@ static const struct proto_ops llcp_sock_ops = {
        .shutdown       = sock_no_shutdown,
        .setsockopt     = sock_no_setsockopt,
        .getsockopt     = sock_no_getsockopt,
-       .sendmsg        = sock_no_sendmsg,
+       .sendmsg        = llcp_sock_sendmsg,
        .recvmsg        = llcp_sock_recvmsg,
        .mmap           = sock_no_mmap,
 };
@@ -627,6 +648,8 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp)
 
 void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
 {
+       struct nfc_llcp_local *local = sock->local;
+
        kfree(sock->service_name);
 
        skb_queue_purge(&sock->tx_queue);
@@ -635,11 +658,16 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
 
        list_del_init(&sock->accept_queue);
 
+       if (local != NULL && sock == local->sockets[sock->ssap])
+               local->sockets[sock->ssap] = NULL;
+       else
+               list_del_init(&sock->list);
+
        sock->parent = NULL;
 }
 
 static int llcp_sock_create(struct net *net, struct socket *sock,
-                               const struct nfc_protocol *nfc_proto)
+                           const struct nfc_protocol *nfc_proto)
 {
        struct sock *sk;
 
index a47e90c7d9d139067439ecbc117e29a9a1a837ba..9ec065bb9ee1e78b96321a8f2f1e5c6827dd15bc 100644 (file)
@@ -66,9 +66,8 @@ static void nci_req_cancel(struct nci_dev *ndev, int err)
 
 /* Execute request and wait for completion. */
 static int __nci_request(struct nci_dev *ndev,
-       void (*req)(struct nci_dev *ndev, unsigned long opt),
-       unsigned long opt,
-       __u32 timeout)
+                        void (*req)(struct nci_dev *ndev, unsigned long opt),
+                        unsigned long opt, __u32 timeout)
 {
        int rc = 0;
        long completion_rc;
@@ -77,9 +76,9 @@ static int __nci_request(struct nci_dev *ndev,
 
        init_completion(&ndev->req_completion);
        req(ndev, opt);
-       completion_rc = wait_for_completion_interruptible_timeout(
-                                                       &ndev->req_completion,
-                                                       timeout);
+       completion_rc =
+               wait_for_completion_interruptible_timeout(&ndev->req_completion,
+                                                         timeout);
 
        pr_debug("wait_for_completion return %ld\n", completion_rc);
 
@@ -110,8 +109,9 @@ static int __nci_request(struct nci_dev *ndev,
 }
 
 static inline int nci_request(struct nci_dev *ndev,
-               void (*req)(struct nci_dev *ndev, unsigned long opt),
-               unsigned long opt, __u32 timeout)
+                             void (*req)(struct nci_dev *ndev,
+                                         unsigned long opt),
+                             unsigned long opt, __u32 timeout)
 {
        int rc;
 
@@ -152,14 +152,14 @@ static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt)
        /* by default mapping is set to NCI_RF_INTERFACE_FRAME */
        for (i = 0; i < ndev->num_supported_rf_interfaces; i++) {
                if (ndev->supported_rf_interfaces[i] ==
-                       NCI_RF_INTERFACE_ISO_DEP) {
+                   NCI_RF_INTERFACE_ISO_DEP) {
                        cfg[*num].rf_protocol = NCI_RF_PROTOCOL_ISO_DEP;
                        cfg[*num].mode = NCI_DISC_MAP_MODE_POLL |
                                NCI_DISC_MAP_MODE_LISTEN;
                        cfg[*num].rf_interface = NCI_RF_INTERFACE_ISO_DEP;
                        (*num)++;
                } else if (ndev->supported_rf_interfaces[i] ==
-                       NCI_RF_INTERFACE_NFC_DEP) {
+                          NCI_RF_INTERFACE_NFC_DEP) {
                        cfg[*num].rf_protocol = NCI_RF_PROTOCOL_NFC_DEP;
                        cfg[*num].mode = NCI_DISC_MAP_MODE_POLL |
                                NCI_DISC_MAP_MODE_LISTEN;
@@ -172,8 +172,7 @@ static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt)
        }
 
        nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_MAP_CMD,
-               (1 + ((*num)*sizeof(struct disc_map_config))),
-               &cmd);
+                    (1 + ((*num) * sizeof(struct disc_map_config))), &cmd);
 }
 
 static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
@@ -184,36 +183,36 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
        cmd.num_disc_configs = 0;
 
        if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
-               (protocols & NFC_PROTO_JEWEL_MASK
-               || protocols & NFC_PROTO_MIFARE_MASK
-               || protocols & NFC_PROTO_ISO14443_MASK
-               || protocols & NFC_PROTO_NFC_DEP_MASK)) {
+           (protocols & NFC_PROTO_JEWEL_MASK
+            || protocols & NFC_PROTO_MIFARE_MASK
+            || protocols & NFC_PROTO_ISO14443_MASK
+            || protocols & NFC_PROTO_NFC_DEP_MASK)) {
                cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
-               NCI_NFC_A_PASSIVE_POLL_MODE;
+                       NCI_NFC_A_PASSIVE_POLL_MODE;
                cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
                cmd.num_disc_configs++;
        }
 
        if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
-               (protocols & NFC_PROTO_ISO14443_MASK)) {
+           (protocols & NFC_PROTO_ISO14443_MASK)) {
                cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
-               NCI_NFC_B_PASSIVE_POLL_MODE;
+                       NCI_NFC_B_PASSIVE_POLL_MODE;
                cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
                cmd.num_disc_configs++;
        }
 
        if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) &&
-               (protocols & NFC_PROTO_FELICA_MASK
-               || protocols & NFC_PROTO_NFC_DEP_MASK)) {
+           (protocols & NFC_PROTO_FELICA_MASK
+            || protocols & NFC_PROTO_NFC_DEP_MASK)) {
                cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode =
-               NCI_NFC_F_PASSIVE_POLL_MODE;
+                       NCI_NFC_F_PASSIVE_POLL_MODE;
                cmd.disc_configs[cmd.num_disc_configs].frequency = 1;
                cmd.num_disc_configs++;
        }
 
        nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD,
-               (1 + (cmd.num_disc_configs*sizeof(struct disc_config))),
-               &cmd);
+                    (1 + (cmd.num_disc_configs * sizeof(struct disc_config))),
+                    &cmd);
 }
 
 struct nci_rf_discover_select_param {
@@ -224,7 +223,7 @@ struct nci_rf_discover_select_param {
 static void nci_rf_discover_select_req(struct nci_dev *ndev, unsigned long opt)
 {
        struct nci_rf_discover_select_param *param =
-                               (struct nci_rf_discover_select_param *)opt;
+               (struct nci_rf_discover_select_param *)opt;
        struct nci_rf_discover_select_cmd cmd;
 
        cmd.rf_discovery_id = param->rf_discovery_id;
@@ -245,8 +244,7 @@ static void nci_rf_discover_select_req(struct nci_dev *ndev, unsigned long opt)
        }
 
        nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_SELECT_CMD,
-                       sizeof(struct nci_rf_discover_select_cmd),
-                       &cmd);
+                    sizeof(struct nci_rf_discover_select_cmd), &cmd);
 }
 
 static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt)
@@ -256,8 +254,7 @@ static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt)
        cmd.type = NCI_DEACTIVATE_TYPE_IDLE_MODE;
 
        nci_send_cmd(ndev, NCI_OP_RF_DEACTIVATE_CMD,
-                       sizeof(struct nci_rf_deactivate_cmd),
-                       &cmd);
+                    sizeof(struct nci_rf_deactivate_cmd), &cmd);
 }
 
 static int nci_open_device(struct nci_dev *ndev)
@@ -281,16 +278,16 @@ static int nci_open_device(struct nci_dev *ndev)
        set_bit(NCI_INIT, &ndev->flags);
 
        rc = __nci_request(ndev, nci_reset_req, 0,
-                               msecs_to_jiffies(NCI_RESET_TIMEOUT));
+                          msecs_to_jiffies(NCI_RESET_TIMEOUT));
 
        if (!rc) {
                rc = __nci_request(ndev, nci_init_req, 0,
-                               msecs_to_jiffies(NCI_INIT_TIMEOUT));
+                                  msecs_to_jiffies(NCI_INIT_TIMEOUT));
        }
 
        if (!rc) {
                rc = __nci_request(ndev, nci_init_complete_req, 0,
-                               msecs_to_jiffies(NCI_INIT_TIMEOUT));
+                                  msecs_to_jiffies(NCI_INIT_TIMEOUT));
        }
 
        clear_bit(NCI_INIT, &ndev->flags);
@@ -340,7 +337,7 @@ static int nci_close_device(struct nci_dev *ndev)
 
        set_bit(NCI_INIT, &ndev->flags);
        __nci_request(ndev, nci_reset_req, 0,
-                               msecs_to_jiffies(NCI_RESET_TIMEOUT));
+                     msecs_to_jiffies(NCI_RESET_TIMEOUT));
        clear_bit(NCI_INIT, &ndev->flags);
 
        /* Flush cmd wq */
@@ -396,7 +393,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols)
        int rc;
 
        if ((atomic_read(&ndev->state) == NCI_DISCOVERY) ||
-               (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) {
+           (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) {
                pr_err("unable to start poll, since poll is already active\n");
                return -EBUSY;
        }
@@ -407,17 +404,17 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols)
        }
 
        if ((atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) ||
-               (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) {
+           (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) {
                pr_debug("target active or w4 select, implicitly deactivate\n");
 
                rc = nci_request(ndev, nci_rf_deactivate_req, 0,
-                       msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
+                                msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
                if (rc)
                        return -EBUSY;
        }
 
        rc = nci_request(ndev, nci_rf_discover_req, protocols,
-               msecs_to_jiffies(NCI_RF_DISC_TIMEOUT));
+                        msecs_to_jiffies(NCI_RF_DISC_TIMEOUT));
 
        if (!rc)
                ndev->poll_prots = protocols;
@@ -430,17 +427,17 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev)
        struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
 
        if ((atomic_read(&ndev->state) != NCI_DISCOVERY) &&
-               (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) {
+           (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) {
                pr_err("unable to stop poll, since poll is not active\n");
                return;
        }
 
        nci_request(ndev, nci_rf_deactivate_req, 0,
-               msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
+                   msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
 }
 
 static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
-                               __u32 protocol)
+                              __u32 protocol)
 {
        struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
        struct nci_rf_discover_select_param param;
@@ -451,7 +448,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
        pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol);
 
        if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) &&
-               (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
+           (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
                pr_err("there is no available target to activate\n");
                return -EINVAL;
        }
@@ -494,8 +491,8 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
                        param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP;
 
                rc = nci_request(ndev, nci_rf_discover_select_req,
-                               (unsigned long)&param,
-                               msecs_to_jiffies(NCI_RF_DISC_SELECT_TIMEOUT));
+                                (unsigned long)&param,
+                                msecs_to_jiffies(NCI_RF_DISC_SELECT_TIMEOUT));
        }
 
        if (!rc)
@@ -519,14 +516,13 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx)
 
        if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) {
                nci_request(ndev, nci_rf_deactivate_req, 0,
-                       msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
+                           msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
        }
 }
 
 static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx,
-                                               struct sk_buff *skb,
-                                               data_exchange_cb_t cb,
-                                               void *cb_context)
+                            struct sk_buff *skb,
+                            data_exchange_cb_t cb, void *cb_context)
 {
        struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
        int rc;
@@ -571,9 +567,8 @@ static struct nfc_ops nci_nfc_ops = {
  * @supported_protocols: NFC protocols supported by the device
  */
 struct nci_dev *nci_allocate_device(struct nci_ops *ops,
-                                       __u32 supported_protocols,
-                                       int tx_headroom,
-                                       int tx_tailroom)
+                                   __u32 supported_protocols,
+                                   int tx_headroom, int tx_tailroom)
 {
        struct nci_dev *ndev;
 
@@ -594,9 +589,9 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops,
        ndev->tx_tailroom = tx_tailroom;
 
        ndev->nfc_dev = nfc_allocate_device(&nci_nfc_ops,
-                                               supported_protocols,
-                                               tx_headroom + NCI_DATA_HDR_SIZE,
-                                               tx_tailroom);
+                                           supported_protocols,
+                                           tx_headroom + NCI_DATA_HDR_SIZE,
+                                           tx_tailroom);
        if (!ndev->nfc_dev)
                goto free_exit;
 
@@ -668,9 +663,9 @@ int nci_register_device(struct nci_dev *ndev)
        skb_queue_head_init(&ndev->tx_q);
 
        setup_timer(&ndev->cmd_timer, nci_cmd_timer,
-                       (unsigned long) ndev);
+                   (unsigned long) ndev);
        setup_timer(&ndev->data_timer, nci_data_timer,
-                       (unsigned long) ndev);
+                   (unsigned long) ndev);
 
        mutex_init(&ndev->req_lock);
 
@@ -719,7 +714,7 @@ int nci_recv_frame(struct sk_buff *skb)
        pr_debug("len %d\n", skb->len);
 
        if (!ndev || (!test_bit(NCI_UP, &ndev->flags)
-               && !test_bit(NCI_INIT, &ndev->flags))) {
+                     && !test_bit(NCI_INIT, &ndev->flags))) {
                kfree_skb(skb);
                return -ENXIO;
        }
@@ -799,7 +794,7 @@ static void nci_tx_work(struct work_struct *work)
 
                /* Check if data flow control is used */
                if (atomic_read(&ndev->credits_cnt) !=
-                               NCI_DATA_FLOW_CONTROL_NOT_USED)
+                   NCI_DATA_FLOW_CONTROL_NOT_USED)
                        atomic_dec(&ndev->credits_cnt);
 
                pr_debug("NCI TX: MT=data, PBF=%d, conn_id=%d, plen=%d\n",
@@ -810,7 +805,7 @@ static void nci_tx_work(struct work_struct *work)
                nci_send_frame(skb);
 
                mod_timer(&ndev->data_timer,
-                       jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT));
+                         jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT));
        }
 }
 
@@ -879,6 +874,6 @@ static void nci_cmd_work(struct work_struct *work)
                nci_send_frame(skb);
 
                mod_timer(&ndev->cmd_timer,
-                       jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT));
+                         jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT));
        }
 }
index 7880ae924d5e623db609df4feaf260ad2406535a..a0bc326308a56911c4f3b26358971df21ad65399 100644 (file)
@@ -35,8 +35,7 @@
 #include <linux/nfc.h>
 
 /* Complete data exchange transaction and forward skb to nfc core */
-void nci_data_exchange_complete(struct nci_dev *ndev,
-                               struct sk_buff *skb,
+void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,
                                int err)
 {
        data_exchange_cb_t cb = ndev->data_exchange_cb;
@@ -67,9 +66,9 @@ void nci_data_exchange_complete(struct nci_dev *ndev,
 /* ----------------- NCI TX Data ----------------- */
 
 static inline void nci_push_data_hdr(struct nci_dev *ndev,
-                                       __u8 conn_id,
-                                       struct sk_buff *skb,
-                                       __u8 pbf)
+                                    __u8 conn_id,
+                                    struct sk_buff *skb,
+                                    __u8 pbf)
 {
        struct nci_data_hdr *hdr;
        int plen = skb->len;
@@ -86,8 +85,8 @@ static inline void nci_push_data_hdr(struct nci_dev *ndev,
 }
 
 static int nci_queue_tx_data_frags(struct nci_dev *ndev,
-                                       __u8 conn_id,
-                                       struct sk_buff *skb) {
+                                  __u8 conn_id,
+                                  struct sk_buff *skb) {
        int total_len = skb->len;
        unsigned char *data = skb->data;
        unsigned long flags;
@@ -105,8 +104,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,
                        min_t(int, total_len, ndev->max_data_pkt_payload_size);
 
                skb_frag = nci_skb_alloc(ndev,
-                                       (NCI_DATA_HDR_SIZE + frag_len),
-                                       GFP_KERNEL);
+                                        (NCI_DATA_HDR_SIZE + frag_len),
+                                        GFP_KERNEL);
                if (skb_frag == NULL) {
                        rc = -ENOMEM;
                        goto free_exit;
@@ -118,7 +117,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,
 
                /* second, set the header */
                nci_push_data_hdr(ndev, conn_id, skb_frag,
-               ((total_len == frag_len) ? (NCI_PBF_LAST) : (NCI_PBF_CONT)));
+                                 ((total_len == frag_len) ?
+                                  (NCI_PBF_LAST) : (NCI_PBF_CONT)));
 
                __skb_queue_tail(&frags_q, skb_frag);
 
@@ -186,8 +186,8 @@ exit:
 /* ----------------- NCI RX Data ----------------- */
 
 static void nci_add_rx_data_frag(struct nci_dev *ndev,
-                               struct sk_buff *skb,
-                               __u8 pbf)
+                                struct sk_buff *skb,
+                                __u8 pbf)
 {
        int reassembly_len;
        int err = 0;
@@ -211,8 +211,8 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev,
 
                /* second, combine the two fragments */
                memcpy(skb_push(skb, reassembly_len),
-                               ndev->rx_data_reassembly->data,
-                               reassembly_len);
+                      ndev->rx_data_reassembly->data,
+                      reassembly_len);
 
                /* third, free old reassembly */
                kfree_skb(ndev->rx_data_reassembly);
index 03e7b4626a3e05772b3b13405ffe9ebc4fde54a8..2e3dee42196d064d0fdcf5ad7c6e4fe50945d57b 100644 (file)
@@ -40,7 +40,7 @@
 /* Handle NCI Notification packets */
 
 static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
-                                               struct sk_buff *skb)
+                                            struct sk_buff *skb)
 {
        struct nci_core_conn_credit_ntf *ntf = (void *) skb->data;
        int i;
@@ -62,7 +62,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
                if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) {
                        /* found static rf connection */
                        atomic_add(ntf->conn_entries[i].credits,
-                               &ndev->credits_cnt);
+                                  &ndev->credits_cnt);
                }
        }
 
@@ -72,7 +72,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
 }
 
 static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev,
-                                               struct sk_buff *skb)
+                                             struct sk_buff *skb)
 {
        __u8 status = skb->data[0];
 
@@ -80,7 +80,7 @@ static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev,
 
        if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) {
                /* Activation failed, so complete the request
-               (the state remains the same) */
+                  (the state remains the same) */
                nci_req_complete(ndev, status);
        }
 }
@@ -101,7 +101,7 @@ static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev,
 
 static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
                        struct rf_tech_specific_params_nfca_poll *nfca_poll,
-                       __u8 *data)
+                                                    __u8 *data)
 {
        nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data));
        data += 2;
@@ -128,7 +128,7 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
 
 static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,
                        struct rf_tech_specific_params_nfcb_poll *nfcb_poll,
-                       __u8 *data)
+                                                    __u8 *data)
 {
        nfcb_poll->sensb_res_len = *data++;
 
@@ -142,13 +142,13 @@ static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,
 
 static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,
                        struct rf_tech_specific_params_nfcf_poll *nfcf_poll,
-                       __u8 *data)
+                                                    __u8 *data)
 {
        nfcf_poll->bit_rate = *data++;
        nfcf_poll->sensf_res_len = *data++;
 
        pr_debug("bit_rate %d, sensf_res_len %d\n",
-               nfcf_poll->bit_rate, nfcf_poll->sensf_res_len);
+                nfcf_poll->bit_rate, nfcf_poll->sensf_res_len);
 
        memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len);
        data += nfcf_poll->sensf_res_len;
@@ -189,7 +189,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
                target->nfcid1_len = nfca_poll->nfcid1_len;
                if (target->nfcid1_len > 0) {
                        memcpy(target->nfcid1, nfca_poll->nfcid1,
-                               target->nfcid1_len);
+                              target->nfcid1_len);
                }
        } else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) {
                nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params;
@@ -197,7 +197,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
                target->sensb_res_len = nfcb_poll->sensb_res_len;
                if (target->sensb_res_len > 0) {
                        memcpy(target->sensb_res, nfcb_poll->sensb_res,
-                               target->sensb_res_len);
+                              target->sensb_res_len);
                }
        } else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) {
                nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params;
@@ -205,7 +205,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
                target->sensf_res_len = nfcf_poll->sensf_res_len;
                if (target->sensf_res_len > 0) {
                        memcpy(target->sensf_res, nfcf_poll->sensf_res,
-                               target->sensf_res_len);
+                              target->sensf_res_len);
                }
        } else {
                pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
@@ -220,7 +220,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
 }
 
 static void nci_add_new_target(struct nci_dev *ndev,
-                               struct nci_rf_discover_ntf *ntf)
+                              struct nci_rf_discover_ntf *ntf)
 {
        struct nfc_target *target;
        int i, rc;
@@ -230,8 +230,8 @@ static void nci_add_new_target(struct nci_dev *ndev,
                if (target->idx == ntf->rf_discovery_id) {
                        /* This target already exists, add the new protocol */
                        nci_add_new_protocol(ndev, target, ntf->rf_protocol,
-                                               ntf->rf_tech_and_mode,
-                                               &ntf->rf_tech_specific_params);
+                                            ntf->rf_tech_and_mode,
+                                            &ntf->rf_tech_specific_params);
                        return;
                }
        }
@@ -245,27 +245,27 @@ static void nci_add_new_target(struct nci_dev *ndev,
        target = &ndev->targets[ndev->n_targets];
 
        rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
-                                       ntf->rf_tech_and_mode,
-                                       &ntf->rf_tech_specific_params);
+                                 ntf->rf_tech_and_mode,
+                                 &ntf->rf_tech_specific_params);
        if (!rc) {
                target->idx = ntf->rf_discovery_id;
                ndev->n_targets++;
 
                pr_debug("target_idx %d, n_targets %d\n", target->idx,
-                               ndev->n_targets);
+                        ndev->n_targets);
        }
 }
 
 void nci_clear_target_list(struct nci_dev *ndev)
 {
        memset(ndev->targets, 0,
-               (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS));
+              (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS));
 
        ndev->n_targets = 0;
 }
 
 static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
-                                       struct sk_buff *skb)
+                                      struct sk_buff *skb)
 {
        struct nci_rf_discover_ntf ntf;
        __u8 *data = skb->data;
@@ -280,7 +280,7 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
        pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol);
        pr_debug("rf_tech_and_mode 0x%x\n", ntf.rf_tech_and_mode);
        pr_debug("rf_tech_specific_params_len %d\n",
-                       ntf.rf_tech_specific_params_len);
+                ntf.rf_tech_specific_params_len);
 
        if (ntf.rf_tech_specific_params_len > 0) {
                switch (ntf.rf_tech_and_mode) {
@@ -318,7 +318,7 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
        } else {
                atomic_set(&ndev->state, NCI_W4_HOST_SELECT);
                nfc_targets_found(ndev->nfc_dev, ndev->targets,
-                                       ndev->n_targets);
+                                 ndev->n_targets);
        }
 }
 
@@ -335,20 +335,17 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
                pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len);
                if (nfca_poll->rats_res_len > 0) {
                        memcpy(nfca_poll->rats_res,
-                               data,
-                               nfca_poll->rats_res_len);
+                              data, nfca_poll->rats_res_len);
                }
                break;
 
        case NCI_NFC_B_PASSIVE_POLL_MODE:
                nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;
                nfcb_poll->attrib_res_len = *data++;
-               pr_debug("attrib_res_len %d\n",
-                       nfcb_poll->attrib_res_len);
+               pr_debug("attrib_res_len %d\n", nfcb_poll->attrib_res_len);
                if (nfcb_poll->attrib_res_len > 0) {
                        memcpy(nfcb_poll->attrib_res,
-                               data,
-                               nfcb_poll->attrib_res_len);
+                              data, nfcb_poll->attrib_res_len);
                }
                break;
 
@@ -362,7 +359,7 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
 }
 
 static void nci_target_auto_activated(struct nci_dev *ndev,
-                                       struct nci_rf_intf_activated_ntf *ntf)
+                                     struct nci_rf_intf_activated_ntf *ntf)
 {
        struct nfc_target *target;
        int rc;
@@ -370,8 +367,8 @@ static void nci_target_auto_activated(struct nci_dev *ndev,
        target = &ndev->targets[ndev->n_targets];
 
        rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
-                                       ntf->activation_rf_tech_and_mode,
-                                       &ntf->rf_tech_specific_params);
+                                 ntf->activation_rf_tech_and_mode,
+                                 &ntf->rf_tech_specific_params);
        if (rc)
                return;
 
@@ -384,7 +381,7 @@ static void nci_target_auto_activated(struct nci_dev *ndev,
 }
 
 static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
-                                               struct sk_buff *skb)
+                                            struct sk_buff *skb)
 {
        struct nci_rf_intf_activated_ntf ntf;
        __u8 *data = skb->data;
@@ -405,7 +402,8 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
                 ntf.activation_rf_tech_and_mode);
        pr_debug("max_data_pkt_payload_size 0x%x\n",
                 ntf.max_data_pkt_payload_size);
-       pr_debug("initial_num_credits 0x%x\n", ntf.initial_num_credits);
+       pr_debug("initial_num_credits 0x%x\n",
+                ntf.initial_num_credits);
        pr_debug("rf_tech_specific_params_len %d\n",
                 ntf.rf_tech_specific_params_len);
 
@@ -441,18 +439,15 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
 
        pr_debug("data_exch_rf_tech_and_mode 0x%x\n",
                 ntf.data_exch_rf_tech_and_mode);
-       pr_debug("data_exch_tx_bit_rate 0x%x\n",
-                ntf.data_exch_tx_bit_rate);
-       pr_debug("data_exch_rx_bit_rate 0x%x\n",
-                ntf.data_exch_rx_bit_rate);
-       pr_debug("activation_params_len %d\n",
-                ntf.activation_params_len);
+       pr_debug("data_exch_tx_bit_rate 0x%x\n", ntf.data_exch_tx_bit_rate);
+       pr_debug("data_exch_rx_bit_rate 0x%x\n", ntf.data_exch_rx_bit_rate);
+       pr_debug("activation_params_len %d\n", ntf.activation_params_len);
 
        if (ntf.activation_params_len > 0) {
                switch (ntf.rf_interface) {
                case NCI_RF_INTERFACE_ISO_DEP:
                        err = nci_extract_activation_params_iso_dep(ndev,
-                               &ntf, data);
+                                                                   &ntf, data);
                        break;
 
                case NCI_RF_INTERFACE_FRAME:
@@ -489,7 +484,7 @@ exit:
 }
 
 static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
-                                       struct sk_buff *skb)
+                                        struct sk_buff *skb)
 {
        struct nci_rf_deactivate_ntf *ntf = (void *) skb->data;
 
index aa63b1e99188672e799c428c814ac26a289118ad..3003c3390e492c18907cc7f5076949439dd7273d 100644 (file)
@@ -67,19 +67,18 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
        ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;
 
        if (ndev->num_supported_rf_interfaces >
-                       NCI_MAX_SUPPORTED_RF_INTERFACES) {
+           NCI_MAX_SUPPORTED_RF_INTERFACES) {
                ndev->num_supported_rf_interfaces =
                        NCI_MAX_SUPPORTED_RF_INTERFACES;
        }
 
        memcpy(ndev->supported_rf_interfaces,
-               rsp_1->supported_rf_interfaces,
-               ndev->num_supported_rf_interfaces);
+              rsp_1->supported_rf_interfaces,
+              ndev->num_supported_rf_interfaces);
 
        rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces);
 
-       ndev->max_logical_connections =
-               rsp_2->max_logical_connections;
+       ndev->max_logical_connections = rsp_2->max_logical_connections;
        ndev->max_routing_table_size =
                __le16_to_cpu(rsp_2->max_routing_table_size);
        ndev->max_ctrl_pkt_payload_len =
@@ -121,7 +120,7 @@ exit:
 }
 
 static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev,
-                                       struct sk_buff *skb)
+                                      struct sk_buff *skb)
 {
        __u8 status = skb->data[0];
 
@@ -143,7 +142,7 @@ static void nci_rf_disc_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
 }
 
 static void nci_rf_disc_select_rsp_packet(struct nci_dev *ndev,
-                                               struct sk_buff *skb)
+                                         struct sk_buff *skb)
 {
        __u8 status = skb->data[0];
 
@@ -155,7 +154,7 @@ static void nci_rf_disc_select_rsp_packet(struct nci_dev *ndev,
 }
 
 static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev,
-                                       struct sk_buff *skb)
+                                        struct sk_buff *skb)
 {
        __u8 status = skb->data[0];
 
@@ -163,7 +162,7 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev,
 
        /* If target was active, complete the request only in deactivate_ntf */
        if ((status != NCI_STATUS_OK) ||
-               (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
+           (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
                nci_clear_target_list(ndev);
                atomic_set(&ndev->state, NCI_IDLE);
                nci_req_complete(ndev, status);
index 07f0348aabf564789b2c9a1cae2be7e07a3478c9..6404052d6c070ccf8f54c4827408d5f9291d6b67 100644 (file)
@@ -48,34 +48,34 @@ static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = {
        [NFC_ATTR_PROTOCOLS] = { .type = NLA_U32 },
        [NFC_ATTR_COMM_MODE] = { .type = NLA_U8 },
        [NFC_ATTR_RF_MODE] = { .type = NLA_U8 },
+       [NFC_ATTR_DEVICE_POWERED] = { .type = NLA_U8 },
 };
 
 static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
-                                       struct netlink_callback *cb, int flags)
+                               struct netlink_callback *cb, int flags)
 {
        void *hdr;
 
        hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
-                               &nfc_genl_family, flags, NFC_CMD_GET_TARGET);
+                         &nfc_genl_family, flags, NFC_CMD_GET_TARGET);
        if (!hdr)
                return -EMSGSIZE;
 
        genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
 
        NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target->idx);
-       NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS,
-                               target->supported_protocols);
+       NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, target->supported_protocols);
        NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res);
        NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res);
        if (target->nfcid1_len > 0)
                NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len,
-                               target->nfcid1);
+                       target->nfcid1);
        if (target->sensb_res_len > 0)
                NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len,
-                               target->sensb_res);
+                       target->sensb_res);
        if (target->sensf_res_len > 0)
                NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len,
-                               target->sensf_res);
+                       target->sensf_res);
 
        return genlmsg_end(msg, hdr);
 
@@ -91,9 +91,9 @@ static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb)
        u32 idx;
 
        rc = nlmsg_parse(cb->nlh, GENL_HDRLEN + nfc_genl_family.hdrsize,
-                                               nfc_genl_family.attrbuf,
-                                               nfc_genl_family.maxattr,
-                                               nfc_genl_policy);
+                        nfc_genl_family.attrbuf,
+                        nfc_genl_family.maxattr,
+                        nfc_genl_policy);
        if (rc < 0)
                return ERR_PTR(rc);
 
@@ -110,7 +110,7 @@ static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb)
 }
 
 static int nfc_genl_dump_targets(struct sk_buff *skb,
-                               struct netlink_callback *cb)
+                                struct netlink_callback *cb)
 {
        int i = cb->args[0];
        struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
@@ -130,7 +130,7 @@ static int nfc_genl_dump_targets(struct sk_buff *skb,
 
        while (i < dev->n_targets) {
                rc = nfc_genl_send_target(skb, &dev->targets[i], cb,
-                                                               NLM_F_MULTI);
+                                         NLM_F_MULTI);
                if (rc < 0)
                        break;
 
@@ -166,7 +166,7 @@ int nfc_genl_targets_found(struct nfc_dev *dev)
                return -ENOMEM;
 
        hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
-                               NFC_EVENT_TARGETS_FOUND);
+                         NFC_EVENT_TARGETS_FOUND);
        if (!hdr)
                goto free_msg;
 
@@ -193,13 +193,14 @@ int nfc_genl_device_added(struct nfc_dev *dev)
                return -ENOMEM;
 
        hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
-                               NFC_EVENT_DEVICE_ADDED);
+                         NFC_EVENT_DEVICE_ADDED);
        if (!hdr)
                goto free_msg;
 
        NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
        NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
        NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols);
+       NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up);
 
        genlmsg_end(msg, hdr);
 
@@ -224,7 +225,7 @@ int nfc_genl_device_removed(struct nfc_dev *dev)
                return -ENOMEM;
 
        hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
-                               NFC_EVENT_DEVICE_REMOVED);
+                         NFC_EVENT_DEVICE_REMOVED);
        if (!hdr)
                goto free_msg;
 
@@ -244,14 +245,14 @@ free_msg:
 }
 
 static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
-                                               u32 pid, u32 seq,
-                                               struct netlink_callback *cb,
-                                               int flags)
+                               u32 pid, u32 seq,
+                               struct netlink_callback *cb,
+                               int flags)
 {
        void *hdr;
 
        hdr = genlmsg_put(msg, pid, seq, &nfc_genl_family, flags,
-                                                       NFC_CMD_GET_DEVICE);
+                         NFC_CMD_GET_DEVICE);
        if (!hdr)
                return -EMSGSIZE;
 
@@ -261,6 +262,7 @@ static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
        NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
        NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
        NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols);
+       NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up);
 
        return genlmsg_end(msg, hdr);
 
@@ -270,7 +272,7 @@ nla_put_failure:
 }
 
 static int nfc_genl_dump_devices(struct sk_buff *skb,
-                               struct netlink_callback *cb)
+                                struct netlink_callback *cb)
 {
        struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
        struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
@@ -297,8 +299,7 @@ static int nfc_genl_dump_devices(struct sk_buff *skb,
                int rc;
 
                rc = nfc_genl_send_device(skb, dev, NETLINK_CB(cb->skb).pid,
-                                                       cb->nlh->nlmsg_seq,
-                                                       cb, NLM_F_MULTI);
+                                         cb->nlh->nlmsg_seq, cb, NLM_F_MULTI);
                if (rc < 0)
                        break;
 
@@ -323,7 +324,7 @@ static int nfc_genl_dump_devices_done(struct netlink_callback *cb)
 }
 
 int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
-                                               u8 comm_mode, u8 rf_mode)
+                              u8 comm_mode, u8 rf_mode)
 {
        struct sk_buff *msg;
        void *hdr;
@@ -334,8 +335,7 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
        if (!msg)
                return -ENOMEM;
 
-       hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
-                               NFC_CMD_DEP_LINK_UP);
+       hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, NFC_CMD_DEP_LINK_UP);
        if (!hdr)
                goto free_msg;
 
@@ -372,7 +372,7 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev)
                return -ENOMEM;
 
        hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
-                               NFC_CMD_DEP_LINK_DOWN);
+                         NFC_CMD_DEP_LINK_DOWN);
        if (!hdr)
                goto free_msg;
 
@@ -414,7 +414,7 @@ static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info)
        }
 
        rc = nfc_genl_send_device(msg, dev, info->snd_pid, info->snd_seq,
-                                                               NULL, 0);
+                                 NULL, 0);
        if (rc < 0)
                goto out_free;
 
@@ -481,7 +481,7 @@ static int nfc_genl_start_poll(struct sk_buff *skb, struct genl_info *info)
        pr_debug("Poll start\n");
 
        if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
-               !info->attrs[NFC_ATTR_PROTOCOLS])
+           !info->attrs[NFC_ATTR_PROTOCOLS])
                return -EINVAL;
 
        idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
@@ -539,13 +539,12 @@ static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info)
        struct nfc_dev *dev;
        int rc, tgt_idx;
        u32 idx;
-       u8 comm, rf;
+       u8 comm;
 
        pr_debug("DEP link up\n");
 
        if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
-                       !info->attrs[NFC_ATTR_COMM_MODE] ||
-                       !info->attrs[NFC_ATTR_RF_MODE])
+           !info->attrs[NFC_ATTR_COMM_MODE])
                return -EINVAL;
 
        idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
@@ -555,19 +554,15 @@ static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info)
                tgt_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]);
 
        comm = nla_get_u8(info->attrs[NFC_ATTR_COMM_MODE]);
-       rf = nla_get_u8(info->attrs[NFC_ATTR_RF_MODE]);
 
        if (comm != NFC_COMM_ACTIVE && comm != NFC_COMM_PASSIVE)
                return -EINVAL;
 
-       if (rf != NFC_RF_INITIATOR && comm != NFC_RF_TARGET)
-               return -EINVAL;
-
        dev = nfc_get_device(idx);
        if (!dev)
                return -ENODEV;
 
-       rc = nfc_dep_link_up(dev, tgt_idx, comm, rf);
+       rc = nfc_dep_link_up(dev, tgt_idx, comm);
 
        nfc_put_device(dev);
 
@@ -642,7 +637,7 @@ static struct genl_ops nfc_genl_ops[] = {
 };
 
 static int nfc_genl_rcv_nl_event(struct notifier_block *this,
-                                               unsigned long event, void *ptr)
+                                unsigned long event, void *ptr)
 {
        struct netlink_notify *n = ptr;
        struct class_dev_iter iter;
@@ -695,7 +690,7 @@ int __init nfc_genl_init(void)
        int rc;
 
        rc = genl_register_family_with_ops(&nfc_genl_family, nfc_genl_ops,
-                                       ARRAY_SIZE(nfc_genl_ops));
+                                          ARRAY_SIZE(nfc_genl_ops));
        if (rc)
                return rc;
 
index 6d28d75995b036e2da23410836313716efd9318f..ec8794c1099c9c2961446f101d9f0846caa96aca 100644 (file)
@@ -32,7 +32,7 @@ struct nfc_protocol {
        struct proto *proto;
        struct module *owner;
        int (*create)(struct net *net, struct socket *sock,
-                       const struct nfc_protocol *nfc_proto);
+                     const struct nfc_protocol *nfc_proto);
 };
 
 struct nfc_rawsock {
@@ -54,7 +54,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
 int nfc_llcp_register_device(struct nfc_dev *dev);
 void nfc_llcp_unregister_device(struct nfc_dev *dev);
 int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len);
-u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *general_bytes_len);
+u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len);
 int __init nfc_llcp_init(void);
 void nfc_llcp_exit(void);
 
@@ -65,7 +65,7 @@ static inline void nfc_llcp_mac_is_down(struct nfc_dev *dev)
 }
 
 static inline void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
-                       u8 comm_mode, u8 rf_mode)
+                                     u8 comm_mode, u8 rf_mode)
 {
 }
 
@@ -78,7 +78,8 @@ static inline void nfc_llcp_unregister_device(struct nfc_dev *dev)
 {
 }
 
-static inline int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len)
+static inline int nfc_llcp_set_remote_gb(struct nfc_dev *dev,
+                                        u8 *gb, u8 gb_len)
 {
        return 0;
 }
@@ -160,8 +161,7 @@ int nfc_start_poll(struct nfc_dev *dev, u32 protocols);
 
 int nfc_stop_poll(struct nfc_dev *dev);
 
-int nfc_dep_link_up(struct nfc_dev *dev, int target_idx,
-                               u8 comm_mode, u8 rf_mode);
+int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, u8 comm_mode);
 
 int nfc_dep_link_down(struct nfc_dev *dev);
 
@@ -169,9 +169,7 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol);
 
 int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx);
 
-int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
-                                       struct sk_buff *skb,
-                                       data_exchange_cb_t cb,
-                                       void *cb_context);
+int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
+                     data_exchange_cb_t cb, void *cb_context);
 
 #endif /* __LOCAL_NFC_H */
index 5325439b0c60872d4bd003074e2fbb8713f21157..5a839ceb2e82f1f23e45595ae836526b9589fefd 100644 (file)
@@ -63,7 +63,7 @@ static int rawsock_release(struct socket *sock)
 }
 
 static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
-                                                       int len, int flags)
+                          int len, int flags)
 {
        struct sock *sk = sock->sk;
        struct sockaddr_nfc *addr = (struct sockaddr_nfc *)_addr;
@@ -73,7 +73,7 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
        pr_debug("sock=%p sk=%p flags=%d\n", sock, sk, flags);
 
        if (!addr || len < sizeof(struct sockaddr_nfc) ||
-               addr->sa_family != AF_NFC)
+           addr->sa_family != AF_NFC)
                return -EINVAL;
 
        pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n",
@@ -120,7 +120,7 @@ static int rawsock_add_header(struct sk_buff *skb)
 }
 
 static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb,
-                                                               int err)
+                                          int err)
 {
        struct sock *sk = (struct sock *) context;
 
@@ -173,7 +173,7 @@ static void rawsock_tx_work(struct work_struct *work)
 
        sock_hold(sk);
        rc = nfc_data_exchange(dev, target_idx, skb,
-                               rawsock_data_exchange_complete, sk);
+                              rawsock_data_exchange_complete, sk);
        if (rc) {
                rawsock_report_error(sk, rc);
                sock_put(sk);
@@ -181,7 +181,7 @@ static void rawsock_tx_work(struct work_struct *work)
 }
 
 static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
-                                       struct msghdr *msg, size_t len)
+                          struct msghdr *msg, size_t len)
 {
        struct sock *sk = sock->sk;
        struct nfc_dev *dev = nfc_rawsock(sk)->dev;
@@ -218,7 +218,7 @@ static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
 }
 
 static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
-                               struct msghdr *msg, size_t len, int flags)
+                          struct msghdr *msg, size_t len, int flags)
 {
        int noblock = flags & MSG_DONTWAIT;
        struct sock *sk = sock->sk;
@@ -274,7 +274,7 @@ static void rawsock_destruct(struct sock *sk)
 
        if (sk->sk_state == TCP_ESTABLISHED) {
                nfc_deactivate_target(nfc_rawsock(sk)->dev,
-                                       nfc_rawsock(sk)->target_idx);
+                                     nfc_rawsock(sk)->target_idx);
                nfc_put_device(nfc_rawsock(sk)->dev);
        }
 
@@ -287,7 +287,7 @@ static void rawsock_destruct(struct sock *sk)
 }
 
 static int rawsock_create(struct net *net, struct socket *sock,
-                               const struct nfc_protocol *nfc_proto)
+                         const struct nfc_protocol *nfc_proto)
 {
        struct sock *sk;
 
index 9d3e3b6bfcf4c20f6a0e484dd097319a3a63eefa..ba21ab22187bef366394743d9d94d6ee33d72b6a 100644 (file)
@@ -23,6 +23,8 @@
 #define MESH_PERR_MIN_INT      100
 #define MESH_DIAM_TRAVERSAL_TIME 50
 
+#define MESH_RSSI_THRESHOLD    0
+
 /*
  * A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds
  * before timing out.  This way it will remain ACTIVE and no data frames
@@ -56,6 +58,7 @@ const struct mesh_config default_mesh_config = {
        .dot11MeshHWMPRannInterval = MESH_RANN_INTERVAL,
        .dot11MeshGateAnnouncementProtocol = false,
        .dot11MeshForwarding = true,
+       .rssi_threshold = MESH_RSSI_THRESHOLD,
 };
 
 const struct mesh_setup default_mesh_setup = {
index d553d365e7512aa1796926e6ab7e88f9b4950574..f5a7ac3a0939ab0e782bf31bc538c0fa2a22cb3d 100644 (file)
@@ -455,7 +455,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
                return 0;
        }
 
-       return rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
+       return rdev->ops->deauth(&rdev->wiphy, dev, &req);
 }
 
 int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
@@ -500,7 +500,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
        else
                return -ENOTCONN;
 
-       return rdev->ops->disassoc(&rdev->wiphy, dev, &req, wdev);
+       return rdev->ops->disassoc(&rdev->wiphy, dev, &req);
 }
 
 int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
@@ -541,7 +541,7 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
 
        memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
        req.bssid = bssid;
-       rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
+       rdev->ops->deauth(&rdev->wiphy, dev, &req);
 
        if (wdev->current_bss) {
                cfg80211_unhold_bss(wdev->current_bss);
@@ -814,8 +814,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
                                  cookie);
 }
 
-bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
-                     size_t len, gfp_t gfp)
+bool cfg80211_rx_mgmt(struct net_device *dev, int freq, int sig_mbm,
+                     const u8 *buf, size_t len, gfp_t gfp)
 {
        struct wireless_dev *wdev = dev->ieee80211_ptr;
        struct wiphy *wiphy = wdev->wiphy;
@@ -854,7 +854,8 @@ bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
                /* found match! */
 
                /* Indicate the received Action frame to user space */
-               if (nl80211_send_mgmt(rdev, dev, reg->nlpid, freq,
+               if (nl80211_send_mgmt(rdev, dev, reg->nlpid,
+                                     freq, sig_mbm,
                                      buf, len, gfp))
                        continue;
 
index 1998c3682774094c23c4102385c7923e610a2102..39dbdf2adb12969b100e91a5e87dc3507bd3f110 100644 (file)
@@ -204,6 +204,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
                .len = NL80211_HT_CAPABILITY_LEN
        },
        [NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 },
+       [NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 },
 };
 
 /* policy for the key attributes */
@@ -2214,6 +2215,13 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
        if (err)
                return err;
 
+       if (info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]) {
+               if (!(rdev->wiphy.features & NL80211_FEATURE_INACTIVITY_TIMER))
+                       return -EOPNOTSUPP;
+               params.inactivity_timeout = nla_get_u16(
+                       info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]);
+       }
+
        err = rdev->ops->start_ap(&rdev->wiphy, dev, &params);
        if (!err)
                wdev->beacon_interval = params.beacon_interval;
@@ -3290,6 +3298,8 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
                        cur_params.dot11MeshGateAnnouncementProtocol);
        NLA_PUT_U8(msg, NL80211_MESHCONF_FORWARDING,
                        cur_params.dot11MeshForwarding);
+       NLA_PUT_U32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
+                       cur_params.rssi_threshold);
        nla_nest_end(msg, pinfoattr);
        genlmsg_end(msg, hdr);
        return genlmsg_reply(msg, info);
@@ -3322,6 +3332,7 @@ static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_A
        [NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 },
        [NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 },
        [NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 },
+       [NL80211_MESHCONF_RSSI_THRESHOLD] = { .type = NLA_U32},
 };
 
 static const struct nla_policy
@@ -3413,6 +3424,8 @@ do {\
                        nla_get_u8);
        FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding,
                        mask, NL80211_MESHCONF_FORWARDING, nla_get_u8);
+       FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold,
+                       mask, NL80211_MESHCONF_RSSI_THRESHOLD, nla_get_u32);
        if (mask_out)
                *mask_out = mask;
 
@@ -7673,7 +7686,8 @@ bool nl80211_unexpected_4addr_frame(struct net_device *dev,
 
 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
                      struct net_device *netdev, u32 nlpid,
-                     int freq, const u8 *buf, size_t len, gfp_t gfp)
+                     int freq, int sig_dbm,
+                     const u8 *buf, size_t len, gfp_t gfp)
 {
        struct sk_buff *msg;
        void *hdr;
@@ -7691,6 +7705,8 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
        NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx);
        NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex);
        NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+       if (sig_dbm)
+               NLA_PUT_U32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm);
        NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf);
 
        genlmsg_end(msg, hdr);
@@ -7952,7 +7968,7 @@ EXPORT_SYMBOL(cfg80211_probe_status);
 
 void cfg80211_report_obss_beacon(struct wiphy *wiphy,
                                 const u8 *frame, size_t len,
-                                int freq, gfp_t gfp)
+                                int freq, int sig_dbm, gfp_t gfp)
 {
        struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
        struct sk_buff *msg;
@@ -7975,6 +7991,8 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
        NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx);
        if (freq)
                NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+       if (sig_dbm)
+               NLA_PUT_U32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm);
        NLA_PUT(msg, NL80211_ATTR_FRAME, len, frame);
 
        genlmsg_end(msg, hdr);
index 12bf4d185abe7dd1f0e89494261c3441faab3680..4ffe50df9f31461e84c426aeb54e46fb1cd8c897 100644 (file)
@@ -92,7 +92,8 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
                                gfp_t gfp);
 
 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
-                     struct net_device *netdev, u32 nlpid, int freq,
+                     struct net_device *netdev, u32 nlpid,
+                     int freq, int sig_dbm,
                      const u8 *buf, size_t len, gfp_t gfp);
 void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev,
                                 struct net_device *netdev, u64 cookie,
index 9aa9db6c81411ddfcd77c34de8128fcd57e2e5d2..1b7a08df933c79bf4ffe62455747464468c84bdb 100644 (file)
@@ -904,6 +904,7 @@ u16 cfg80211_calculate_bitrate(struct rate_info *rate)
        /* do NOT round down here */
        return (bitrate + 50000) / 100000;
 }
+EXPORT_SYMBOL(cfg80211_calculate_bitrate);
 
 int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
                                 u32 beacon_int)