aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS14
-rw-r--r--drivers/net/wireless/ath/ar9170/ar9170.h1
-rw-r--r--drivers/net/wireless/ath/ar9170/mac.c24
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c20
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h4
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c21
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c121
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c29
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile3
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h5
-rw-r--r--drivers/net/wireless/ath/ath9k/btcoex.c319
-rw-r--r--drivers/net/wireless/ath/ath9k/btcoex.h98
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c35
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h7
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c16
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c239
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h58
-rw-r--r--drivers/net/wireless/ath/ath9k/initvals.h10
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c40
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h64
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c9
-rw-r--r--drivers/net/wireless/b43/Kconfig4
-rw-r--r--drivers/net/wireless/b43/main.c3
-rw-r--r--drivers/net/wireless/b43/phy_a.c2
-rw-r--r--drivers/net/wireless/b43/phy_common.c27
-rw-r--r--drivers/net/wireless/b43/phy_common.h13
-rw-r--r--drivers/net/wireless/b43/phy_g.c2
-rw-r--r--drivers/net/wireless/b43/phy_lp.c129
-rw-r--r--drivers/net/wireless/b43/phy_lp.h3
-rw-r--r--drivers/net/wireless/b43/tables_lpphy.c79
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c206
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.h16
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c1043
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.h16
-rw-r--r--drivers/net/wireless/ipw2x00/libipw.h (renamed from drivers/net/wireless/ipw2x00/ieee80211.h)666
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_geo.c82
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_module.c124
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_rx.c403
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_tx.c70
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_wx.c94
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c55
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c54
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c252
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h80
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c9
-rw-r--r--drivers/net/wireless/libertas/assoc.c57
-rw-r--r--drivers/net/wireless/libertas/debugfs.c28
-rw-r--r--drivers/net/wireless/libertas/if_cs.c39
-rw-r--r--drivers/net/wireless/mwl8k.c30
-rw-r--r--drivers/net/wireless/p54/txrx.c3
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c4
-rw-r--r--drivers/net/wireless/rndis_wlan.c1411
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c8
-rw-r--r--drivers/net/wireless/rtl818x/Makefile2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187.h1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c31
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_leds.c4
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_rfkill.c63
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_rfkill.h8
-rw-r--r--drivers/net/wireless/rtl818x/rtl818x.h5
-rw-r--r--drivers/ssb/driver_chipcommon_pmu.c94
-rw-r--r--include/linux/ieee80211.h2
-rw-r--r--include/linux/ssb/ssb_driver_chipcommon.h10
-rw-r--r--include/net/iw_handler.h6
-rw-r--r--include/net/mac80211.h11
-rw-r--r--net/mac80211/driver-ops.h14
-rw-r--r--net/mac80211/ieee80211_i.h8
-rw-r--r--net/mac80211/iface.c41
-rw-r--r--net/mac80211/main.c2
-rw-r--r--net/mac80211/mesh.c49
-rw-r--r--net/mac80211/mlme.c28
-rw-r--r--net/mac80211/pm.c13
-rw-r--r--net/mac80211/rc80211_minstrel.h1
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c2
-rw-r--r--net/mac80211/rx.c39
-rw-r--r--net/mac80211/scan.c9
-rw-r--r--net/mac80211/util.c10
-rw-r--r--net/wireless/Kconfig17
-rw-r--r--net/wireless/core.c58
-rw-r--r--net/wireless/core.h17
-rw-r--r--net/wireless/ibss.c4
-rw-r--r--net/wireless/nl80211.c18
-rw-r--r--net/wireless/scan.c21
-rw-r--r--net/wireless/sme.c12
-rw-r--r--net/wireless/util.c108
-rw-r--r--net/wireless/wext-compat.c16
100 files changed, 4299 insertions, 2659 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index baa0aa812be8..0ab47e7fc2ec 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2653,25 +2653,21 @@ F: drivers/net/ixgbe/
2653 2653
2654INTEL PRO/WIRELESS 2100 NETWORK CONNECTION SUPPORT 2654INTEL PRO/WIRELESS 2100 NETWORK CONNECTION SUPPORT
2655M: Zhu Yi <yi.zhu@intel.com> 2655M: Zhu Yi <yi.zhu@intel.com>
2656M: James Ketrenos <jketreno@linux.intel.com>
2657M: Reinette Chatre <reinette.chatre@intel.com> 2656M: Reinette Chatre <reinette.chatre@intel.com>
2657M: Intel Linux Wireless <ilw@linux.intel.com>
2658L: linux-wireless@vger.kernel.org 2658L: linux-wireless@vger.kernel.org
2659L: ipw2100-devel@lists.sourceforge.net
2660W: http://lists.sourceforge.net/mailman/listinfo/ipw2100-devel
2661W: http://ipw2100.sourceforge.net 2659W: http://ipw2100.sourceforge.net
2662S: Supported 2660S: Odd Fixes
2663F: Documentation/networking/README.ipw2100 2661F: Documentation/networking/README.ipw2100
2664F: drivers/net/wireless/ipw2x00/ipw2100.* 2662F: drivers/net/wireless/ipw2x00/ipw2100.*
2665 2663
2666INTEL PRO/WIRELESS 2915ABG NETWORK CONNECTION SUPPORT 2664INTEL PRO/WIRELESS 2915ABG NETWORK CONNECTION SUPPORT
2667M: Zhu Yi <yi.zhu@intel.com> 2665M: Zhu Yi <yi.zhu@intel.com>
2668M: James Ketrenos <jketreno@linux.intel.com>
2669M: Reinette Chatre <reinette.chatre@intel.com> 2666M: Reinette Chatre <reinette.chatre@intel.com>
2667M: Intel Linux Wireless <ilw@linux.intel.com>
2670L: linux-wireless@vger.kernel.org 2668L: linux-wireless@vger.kernel.org
2671L: ipw2100-devel@lists.sourceforge.net
2672W: http://lists.sourceforge.net/mailman/listinfo/ipw2100-devel
2673W: http://ipw2200.sourceforge.net 2669W: http://ipw2200.sourceforge.net
2674S: Supported 2670S: Odd Fixes
2675F: Documentation/networking/README.ipw2200 2671F: Documentation/networking/README.ipw2200
2676F: drivers/net/wireless/ipw2x00/ipw2200.* 2672F: drivers/net/wireless/ipw2x00/ipw2200.*
2677 2673
@@ -2688,8 +2684,8 @@ F: include/linux/wimax/i2400m.h
2688INTEL WIRELESS WIFI LINK (iwlwifi) 2684INTEL WIRELESS WIFI LINK (iwlwifi)
2689M: Zhu Yi <yi.zhu@intel.com> 2685M: Zhu Yi <yi.zhu@intel.com>
2690M: Reinette Chatre <reinette.chatre@intel.com> 2686M: Reinette Chatre <reinette.chatre@intel.com>
2687M: Intel Linux Wireless <ilw@linux.intel.com>
2691L: linux-wireless@vger.kernel.org 2688L: linux-wireless@vger.kernel.org
2692L: ipw3945-devel@lists.sourceforge.net
2693W: http://intellinuxwireless.org 2689W: http://intellinuxwireless.org
2694T: git git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6.git 2690T: git git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6.git
2695S: Supported 2691S: Supported
diff --git a/drivers/net/wireless/ath/ar9170/ar9170.h b/drivers/net/wireless/ath/ar9170/ar9170.h
index ce407248d7d8..914e4718a9a8 100644
--- a/drivers/net/wireless/ath/ar9170/ar9170.h
+++ b/drivers/net/wireless/ath/ar9170/ar9170.h
@@ -178,6 +178,7 @@ struct ar9170 {
178 /* beaconing */ 178 /* beaconing */
179 struct sk_buff *beacon; 179 struct sk_buff *beacon;
180 struct work_struct beacon_work; 180 struct work_struct beacon_work;
181 bool enable_beacon;
181 182
182 /* cryptographic engine */ 183 /* cryptographic engine */
183 u64 usedkeys; 184 u64 usedkeys;
diff --git a/drivers/net/wireless/ath/ar9170/mac.c b/drivers/net/wireless/ath/ar9170/mac.c
index 60049366e863..614e3218a2bc 100644
--- a/drivers/net/wireless/ath/ar9170/mac.c
+++ b/drivers/net/wireless/ath/ar9170/mac.c
@@ -383,24 +383,26 @@ int ar9170_set_beacon_timers(struct ar9170 *ar)
383 if (ar->vif) { 383 if (ar->vif) {
384 v |= ar->vif->bss_conf.beacon_int; 384 v |= ar->vif->bss_conf.beacon_int;
385 385
386 switch (ar->vif->type) { 386 if (ar->enable_beacon) {
387 case NL80211_IFTYPE_MESH_POINT: 387 switch (ar->vif->type) {
388 case NL80211_IFTYPE_ADHOC: 388 case NL80211_IFTYPE_MESH_POINT:
389 v |= BIT(25); 389 case NL80211_IFTYPE_ADHOC:
390 break; 390 v |= BIT(25);
391 case NL80211_IFTYPE_AP: 391 break;
392 v |= BIT(24); 392 case NL80211_IFTYPE_AP:
393 pretbtt = (ar->vif->bss_conf.beacon_int - 6) << 16; 393 v |= BIT(24);
394 break; 394 pretbtt = (ar->vif->bss_conf.beacon_int - 6) <<
395 default: 395 16;
396 break;
397 default:
396 break; 398 break;
399 }
397 } 400 }
398 401
399 v |= ar->vif->bss_conf.dtim_period << 16; 402 v |= ar->vif->bss_conf.dtim_period << 16;
400 } 403 }
401 404
402 ar9170_regwrite_begin(ar); 405 ar9170_regwrite_begin(ar);
403
404 ar9170_regwrite(AR9170_MAC_REG_PRETBTT, pretbtt); 406 ar9170_regwrite(AR9170_MAC_REG_PRETBTT, pretbtt);
405 ar9170_regwrite(AR9170_MAC_REG_BCN_PERIOD, v); 407 ar9170_regwrite(AR9170_MAC_REG_BCN_PERIOD, v);
406 ar9170_regwrite_finish(); 408 ar9170_regwrite_finish();
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 658b32312caf..c1f8c69db165 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -2031,12 +2031,6 @@ static int ar9170_op_config(struct ieee80211_hw *hw, u32 changed)
2031 goto out; 2031 goto out;
2032 } 2032 }
2033 2033
2034 if (changed & BSS_CHANGED_BEACON_INT) {
2035 err = ar9170_set_beacon_timers(ar);
2036 if (err)
2037 goto out;
2038 }
2039
2040 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 2034 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
2041 2035
2042 /* adjust slot time for 5 GHz */ 2036 /* adjust slot time for 5 GHz */
@@ -2148,11 +2142,17 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
2148 goto out; 2142 goto out;
2149 } 2143 }
2150 2144
2151 if (changed & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED)) { 2145 if (changed & BSS_CHANGED_BEACON_ENABLED)
2146 ar->enable_beacon = bss_conf->enable_beacon;
2147
2148 if (changed & BSS_CHANGED_BEACON) {
2152 err = ar9170_update_beacon(ar); 2149 err = ar9170_update_beacon(ar);
2153 if (err) 2150 if (err)
2154 goto out; 2151 goto out;
2152 }
2155 2153
2154 if (changed & (BSS_CHANGED_BEACON_ENABLED | BSS_CHANGED_BEACON |
2155 BSS_CHANGED_BEACON_INT)) {
2156 err = ar9170_set_beacon_timers(ar); 2156 err = ar9170_set_beacon_timers(ar);
2157 if (err) 2157 if (err)
2158 goto out; 2158 goto out;
@@ -2165,12 +2165,6 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
2165#endif /* CONFIG_AR9170_LEDS */ 2165#endif /* CONFIG_AR9170_LEDS */
2166 } 2166 }
2167 2167
2168 if (changed & BSS_CHANGED_BEACON_INT) {
2169 err = ar9170_set_beacon_timers(ar);
2170 if (err)
2171 goto out;
2172 }
2173
2174 if (changed & BSS_CHANGED_HT) { 2168 if (changed & BSS_CHANGED_HT) {
2175 /* TODO */ 2169 /* TODO */
2176 err = 0; 2170 err = 0;
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 862762cea54c..6cd5efcec417 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -306,6 +306,7 @@ struct ath5k_srev_name {
306#define AR5K_SREV_AR5311B 0x30 /* Spirit */ 306#define AR5K_SREV_AR5311B 0x30 /* Spirit */
307#define AR5K_SREV_AR5211 0x40 /* Oahu */ 307#define AR5K_SREV_AR5211 0x40 /* Oahu */
308#define AR5K_SREV_AR5212 0x50 /* Venice */ 308#define AR5K_SREV_AR5212 0x50 /* Venice */
309#define AR5K_SREV_AR5212_V4 0x54 /* ??? */
309#define AR5K_SREV_AR5213 0x55 /* ??? */ 310#define AR5K_SREV_AR5213 0x55 /* ??? */
310#define AR5K_SREV_AR5213A 0x59 /* Hainan */ 311#define AR5K_SREV_AR5213A 0x59 /* Hainan */
311#define AR5K_SREV_AR2413 0x78 /* Griffin lite */ 312#define AR5K_SREV_AR2413 0x78 /* Griffin lite */
@@ -1037,6 +1038,7 @@ struct ath5k_hw {
1037 bool ah_turbo; 1038 bool ah_turbo;
1038 bool ah_calibration; 1039 bool ah_calibration;
1039 bool ah_single_chip; 1040 bool ah_single_chip;
1041 bool ah_aes_support;
1040 bool ah_combined_mic; 1042 bool ah_combined_mic;
1041 1043
1042 enum ath5k_version ah_version; 1044 enum ath5k_version ah_version;
@@ -1158,7 +1160,7 @@ struct ath5k_hw {
1158 */ 1160 */
1159 1161
1160/* Attach/Detach Functions */ 1162/* Attach/Detach Functions */
1161extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version); 1163extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc);
1162extern void ath5k_hw_detach(struct ath5k_hw *ah); 1164extern void ath5k_hw_detach(struct ath5k_hw *ah);
1163 1165
1164/* LED functions */ 1166/* LED functions */
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 65d438b59f64..71a1bd254517 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -95,17 +95,17 @@ static int ath5k_hw_post(struct ath5k_hw *ah)
95 * ath5k_hw_attach - Check if hw is supported and init the needed structs 95 * ath5k_hw_attach - Check if hw is supported and init the needed structs
96 * 96 *
97 * @sc: The &struct ath5k_softc we got from the driver's attach function 97 * @sc: The &struct ath5k_softc we got from the driver's attach function
98 * @mac_version: The mac version id (check out ath5k.h) based on pci id
99 * 98 *
100 * Check if the device is supported, perform a POST and initialize the needed 99 * Check if the device is supported, perform a POST and initialize the needed
101 * structs. Returns -ENOMEM if we don't have memory for the needed structs, 100 * structs. Returns -ENOMEM if we don't have memory for the needed structs,
102 * -ENODEV if the device is not supported or prints an error msg if something 101 * -ENODEV if the device is not supported or prints an error msg if something
103 * else went wrong. 102 * else went wrong.
104 */ 103 */
105struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version) 104struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc)
106{ 105{
107 struct ath5k_hw *ah; 106 struct ath5k_hw *ah;
108 struct pci_dev *pdev = sc->pdev; 107 struct pci_dev *pdev = sc->pdev;
108 struct ath5k_eeprom_info *ee;
109 int ret; 109 int ret;
110 u32 srev; 110 u32 srev;
111 111
@@ -135,9 +135,15 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
135 ah->ah_software_retry = false; 135 ah->ah_software_retry = false;
136 136
137 /* 137 /*
138 * Set the mac version based on the pci id 138 * Find the mac version
139 */ 139 */
140 ah->ah_version = mac_version; 140 srev = ath5k_hw_reg_read(ah, AR5K_SREV);
141 if (srev < AR5K_SREV_AR5311)
142 ah->ah_version = AR5K_AR5210;
143 else if (srev < AR5K_SREV_AR5212)
144 ah->ah_version = AR5K_AR5211;
145 else
146 ah->ah_version = AR5K_AR5212;
141 147
142 /*Fill the ath5k_hw struct with the needed functions*/ 148 /*Fill the ath5k_hw struct with the needed functions*/
143 ret = ath5k_hw_init_desc_functions(ah); 149 ret = ath5k_hw_init_desc_functions(ah);
@@ -150,7 +156,6 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
150 goto err_free; 156 goto err_free;
151 157
152 /* Get MAC, PHY and RADIO revisions */ 158 /* Get MAC, PHY and RADIO revisions */
153 srev = ath5k_hw_reg_read(ah, AR5K_SREV);
154 ah->ah_mac_srev = srev; 159 ah->ah_mac_srev = srev;
155 ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER); 160 ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER);
156 ah->ah_mac_revision = AR5K_REG_MS(srev, AR5K_SREV_REV); 161 ah->ah_mac_revision = AR5K_REG_MS(srev, AR5K_SREV_REV);
@@ -315,6 +320,12 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
315 goto err_free; 320 goto err_free;
316 } 321 }
317 322
323 /* Crypto settings */
324 ee = &ah->ah_capabilities.cap_eeprom;
325 ah->ah_aes_support = srev >= AR5K_SREV_AR5212_V4 &&
326 (ee->ee_version >= AR5K_EEPROM_VERSION_5_0 &&
327 !AR5K_EEPROM_AES_DIS(ee->ee_misc5));
328
318 if (srev >= AR5K_SREV_AR2414) { 329 if (srev >= AR5K_SREV_AR2414) {
319 ah->ah_combined_mic = true; 330 ah->ah_combined_mic = true;
320 AR5K_REG_ENABLE_BITS(ah, AR5K_MISC_MODE, 331 AR5K_REG_ENABLE_BITS(ah, AR5K_MISC_MODE,
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 5056410d788a..9c6ab5378f6e 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -84,24 +84,24 @@ MODULE_VERSION("0.6.0 (EXPERIMENTAL)");
84 84
85/* Known PCI ids */ 85/* Known PCI ids */
86static const struct pci_device_id ath5k_pci_id_table[] = { 86static const struct pci_device_id ath5k_pci_id_table[] = {
87 { PCI_VDEVICE(ATHEROS, 0x0207), .driver_data = AR5K_AR5210 }, /* 5210 early */ 87 { PCI_VDEVICE(ATHEROS, 0x0207) }, /* 5210 early */
88 { PCI_VDEVICE(ATHEROS, 0x0007), .driver_data = AR5K_AR5210 }, /* 5210 */ 88 { PCI_VDEVICE(ATHEROS, 0x0007) }, /* 5210 */
89 { PCI_VDEVICE(ATHEROS, 0x0011), .driver_data = AR5K_AR5211 }, /* 5311 - this is on AHB bus !*/ 89 { PCI_VDEVICE(ATHEROS, 0x0011) }, /* 5311 - this is on AHB bus !*/
90 { PCI_VDEVICE(ATHEROS, 0x0012), .driver_data = AR5K_AR5211 }, /* 5211 */ 90 { PCI_VDEVICE(ATHEROS, 0x0012) }, /* 5211 */
91 { PCI_VDEVICE(ATHEROS, 0x0013), .driver_data = AR5K_AR5212 }, /* 5212 */ 91 { PCI_VDEVICE(ATHEROS, 0x0013) }, /* 5212 */
92 { PCI_VDEVICE(3COM_2, 0x0013), .driver_data = AR5K_AR5212 }, /* 3com 5212 */ 92 { PCI_VDEVICE(3COM_2, 0x0013) }, /* 3com 5212 */
93 { PCI_VDEVICE(3COM, 0x0013), .driver_data = AR5K_AR5212 }, /* 3com 3CRDAG675 5212 */ 93 { PCI_VDEVICE(3COM, 0x0013) }, /* 3com 3CRDAG675 5212 */
94 { PCI_VDEVICE(ATHEROS, 0x1014), .driver_data = AR5K_AR5212 }, /* IBM minipci 5212 */ 94 { PCI_VDEVICE(ATHEROS, 0x1014) }, /* IBM minipci 5212 */
95 { PCI_VDEVICE(ATHEROS, 0x0014), .driver_data = AR5K_AR5212 }, /* 5212 combatible */ 95 { PCI_VDEVICE(ATHEROS, 0x0014) }, /* 5212 combatible */
96 { PCI_VDEVICE(ATHEROS, 0x0015), .driver_data = AR5K_AR5212 }, /* 5212 combatible */ 96 { PCI_VDEVICE(ATHEROS, 0x0015) }, /* 5212 combatible */
97 { PCI_VDEVICE(ATHEROS, 0x0016), .driver_data = AR5K_AR5212 }, /* 5212 combatible */ 97 { PCI_VDEVICE(ATHEROS, 0x0016) }, /* 5212 combatible */
98 { PCI_VDEVICE(ATHEROS, 0x0017), .driver_data = AR5K_AR5212 }, /* 5212 combatible */ 98 { PCI_VDEVICE(ATHEROS, 0x0017) }, /* 5212 combatible */
99 { PCI_VDEVICE(ATHEROS, 0x0018), .driver_data = AR5K_AR5212 }, /* 5212 combatible */ 99 { PCI_VDEVICE(ATHEROS, 0x0018) }, /* 5212 combatible */
100 { PCI_VDEVICE(ATHEROS, 0x0019), .driver_data = AR5K_AR5212 }, /* 5212 combatible */ 100 { PCI_VDEVICE(ATHEROS, 0x0019) }, /* 5212 combatible */
101 { PCI_VDEVICE(ATHEROS, 0x001a), .driver_data = AR5K_AR5212 }, /* 2413 Griffin-lite */ 101 { PCI_VDEVICE(ATHEROS, 0x001a) }, /* 2413 Griffin-lite */
102 { PCI_VDEVICE(ATHEROS, 0x001b), .driver_data = AR5K_AR5212 }, /* 5413 Eagle */ 102 { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */
103 { PCI_VDEVICE(ATHEROS, 0x001c), .driver_data = AR5K_AR5212 }, /* PCI-E cards */ 103 { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */
104 { PCI_VDEVICE(ATHEROS, 0x001d), .driver_data = AR5K_AR5212 }, /* 2417 Nala */ 104 { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */
105 { 0 } 105 { 0 }
106}; 106};
107MODULE_DEVICE_TABLE(pci, ath5k_pci_id_table); 107MODULE_DEVICE_TABLE(pci, ath5k_pci_id_table);
@@ -566,7 +566,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
566 } 566 }
567 567
568 /* Initialize device */ 568 /* Initialize device */
569 sc->ah = ath5k_hw_attach(sc, id->driver_data); 569 sc->ah = ath5k_hw_attach(sc);
570 if (IS_ERR(sc->ah)) { 570 if (IS_ERR(sc->ah)) {
571 ret = PTR_ERR(sc->ah); 571 ret = PTR_ERR(sc->ah);
572 goto err_irq; 572 goto err_irq;
@@ -1741,7 +1741,7 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,
1741static void 1741static void
1742ath5k_tasklet_rx(unsigned long data) 1742ath5k_tasklet_rx(unsigned long data)
1743{ 1743{
1744 struct ieee80211_rx_status rxs = {}; 1744 struct ieee80211_rx_status *rxs;
1745 struct ath5k_rx_status rs = {}; 1745 struct ath5k_rx_status rs = {};
1746 struct sk_buff *skb, *next_skb; 1746 struct sk_buff *skb, *next_skb;
1747 dma_addr_t next_skb_addr; 1747 dma_addr_t next_skb_addr;
@@ -1751,6 +1751,7 @@ ath5k_tasklet_rx(unsigned long data)
1751 int ret; 1751 int ret;
1752 int hdrlen; 1752 int hdrlen;
1753 int padsize; 1753 int padsize;
1754 int rx_flag;
1754 1755
1755 spin_lock(&sc->rxbuflock); 1756 spin_lock(&sc->rxbuflock);
1756 if (list_empty(&sc->rxbuf)) { 1757 if (list_empty(&sc->rxbuf)) {
@@ -1758,7 +1759,7 @@ ath5k_tasklet_rx(unsigned long data)
1758 goto unlock; 1759 goto unlock;
1759 } 1760 }
1760 do { 1761 do {
1761 rxs.flag = 0; 1762 rx_flag = 0;
1762 1763
1763 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list); 1764 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list);
1764 BUG_ON(bf->skb == NULL); 1765 BUG_ON(bf->skb == NULL);
@@ -1802,7 +1803,7 @@ ath5k_tasklet_rx(unsigned long data)
1802 goto accept; 1803 goto accept;
1803 } 1804 }
1804 if (rs.rs_status & AR5K_RXERR_MIC) { 1805 if (rs.rs_status & AR5K_RXERR_MIC) {
1805 rxs.flag |= RX_FLAG_MMIC_ERROR; 1806 rx_flag |= RX_FLAG_MMIC_ERROR;
1806 goto accept; 1807 goto accept;
1807 } 1808 }
1808 1809
@@ -1840,6 +1841,7 @@ accept:
1840 memmove(skb->data + padsize, skb->data, hdrlen); 1841 memmove(skb->data + padsize, skb->data, hdrlen);
1841 skb_pull(skb, padsize); 1842 skb_pull(skb, padsize);
1842 } 1843 }
1844 rxs = IEEE80211_SKB_RXCB(skb);
1843 1845
1844 /* 1846 /*
1845 * always extend the mac timestamp, since this information is 1847 * always extend the mac timestamp, since this information is
@@ -1861,41 +1863,40 @@ accept:
1861 * impossible to comply to that. This affects IBSS merge only 1863 * impossible to comply to that. This affects IBSS merge only
1862 * right now, so it's not too bad... 1864 * right now, so it's not too bad...
1863 */ 1865 */
1864 rxs.mactime = ath5k_extend_tsf(sc->ah, rs.rs_tstamp); 1866 rxs->mactime = ath5k_extend_tsf(sc->ah, rs.rs_tstamp);
1865 rxs.flag |= RX_FLAG_TSFT; 1867 rxs->flag = rx_flag | RX_FLAG_TSFT;
1866 1868
1867 rxs.freq = sc->curchan->center_freq; 1869 rxs->freq = sc->curchan->center_freq;
1868 rxs.band = sc->curband->band; 1870 rxs->band = sc->curband->band;
1869 1871
1870 rxs.noise = sc->ah->ah_noise_floor; 1872 rxs->noise = sc->ah->ah_noise_floor;
1871 rxs.signal = rxs.noise + rs.rs_rssi; 1873 rxs->signal = rxs->noise + rs.rs_rssi;
1872 1874
1873 /* An rssi of 35 indicates you should be able use 1875 /* An rssi of 35 indicates you should be able use
1874 * 54 Mbps reliably. A more elaborate scheme can be used 1876 * 54 Mbps reliably. A more elaborate scheme can be used
1875 * here but it requires a map of SNR/throughput for each 1877 * here but it requires a map of SNR/throughput for each
1876 * possible mode used */ 1878 * possible mode used */
1877 rxs.qual = rs.rs_rssi * 100 / 35; 1879 rxs->qual = rs.rs_rssi * 100 / 35;
1878 1880
1879 /* rssi can be more than 35 though, anything above that 1881 /* rssi can be more than 35 though, anything above that
1880 * should be considered at 100% */ 1882 * should be considered at 100% */
1881 if (rxs.qual > 100) 1883 if (rxs->qual > 100)
1882 rxs.qual = 100; 1884 rxs->qual = 100;
1883 1885
1884 rxs.antenna = rs.rs_antenna; 1886 rxs->antenna = rs.rs_antenna;
1885 rxs.rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate); 1887 rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
1886 rxs.flag |= ath5k_rx_decrypted(sc, ds, skb, &rs); 1888 rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs);
1887 1889
1888 if (rxs.rate_idx >= 0 && rs.rs_rate == 1890 if (rxs->rate_idx >= 0 && rs.rs_rate ==
1889 sc->curband->bitrates[rxs.rate_idx].hw_value_short) 1891 sc->curband->bitrates[rxs->rate_idx].hw_value_short)
1890 rxs.flag |= RX_FLAG_SHORTPRE; 1892 rxs->flag |= RX_FLAG_SHORTPRE;
1891 1893
1892 ath5k_debug_dump_skb(sc, skb, "RX ", 0); 1894 ath5k_debug_dump_skb(sc, skb, "RX ", 0);
1893 1895
1894 /* check beacons in IBSS mode */ 1896 /* check beacons in IBSS mode */
1895 if (sc->opmode == NL80211_IFTYPE_ADHOC) 1897 if (sc->opmode == NL80211_IFTYPE_ADHOC)
1896 ath5k_check_ibss_tsf(sc, skb, &rxs); 1898 ath5k_check_ibss_tsf(sc, skb, rxs);
1897 1899
1898 memcpy(IEEE80211_SKB_RXCB(skb), &rxs, sizeof(rxs));
1899 ieee80211_rx(sc->hw, skb); 1900 ieee80211_rx(sc->hw, skb);
1900 1901
1901 bf->skb = next_skb; 1902 bf->skb = next_skb;
@@ -2918,6 +2919,8 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2918 struct ath5k_hw *ah = sc->ah; 2919 struct ath5k_hw *ah = sc->ah;
2919 u32 mfilt[2], rfilt; 2920 u32 mfilt[2], rfilt;
2920 2921
2922 mutex_lock(&sc->lock);
2923
2921 mfilt[0] = multicast; 2924 mfilt[0] = multicast;
2922 mfilt[1] = multicast >> 32; 2925 mfilt[1] = multicast >> 32;
2923 2926
@@ -2968,22 +2971,25 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2968 2971
2969 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */ 2972 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */
2970 2973
2971 if (sc->opmode == NL80211_IFTYPE_MONITOR) 2974 switch (sc->opmode) {
2972 rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON | 2975 case NL80211_IFTYPE_MESH_POINT:
2973 AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM; 2976 case NL80211_IFTYPE_MONITOR:
2974 if (sc->opmode != NL80211_IFTYPE_STATION) 2977 rfilt |= AR5K_RX_FILTER_CONTROL |
2975 rfilt |= AR5K_RX_FILTER_PROBEREQ; 2978 AR5K_RX_FILTER_BEACON |
2976 if (sc->opmode != NL80211_IFTYPE_AP && 2979 AR5K_RX_FILTER_PROBEREQ |
2977 sc->opmode != NL80211_IFTYPE_MESH_POINT && 2980 AR5K_RX_FILTER_PROM;
2978 test_bit(ATH_STAT_PROMISC, sc->status)) 2981 break;
2979 rfilt |= AR5K_RX_FILTER_PROM; 2982 case NL80211_IFTYPE_AP:
2980 if ((sc->opmode == NL80211_IFTYPE_STATION && sc->assoc) || 2983 case NL80211_IFTYPE_ADHOC:
2981 sc->opmode == NL80211_IFTYPE_ADHOC || 2984 rfilt |= AR5K_RX_FILTER_PROBEREQ |
2982 sc->opmode == NL80211_IFTYPE_AP) 2985 AR5K_RX_FILTER_BEACON;
2983 rfilt |= AR5K_RX_FILTER_BEACON; 2986 break;
2984 if (sc->opmode == NL80211_IFTYPE_MESH_POINT) 2987 case NL80211_IFTYPE_STATION:
2985 rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON | 2988 if (sc->assoc)
2986 AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM; 2989 rfilt |= AR5K_RX_FILTER_BEACON;
2990 default:
2991 break;
2992 }
2987 2993
2988 /* Set filters */ 2994 /* Set filters */
2989 ath5k_hw_set_rx_filter(ah, rfilt); 2995 ath5k_hw_set_rx_filter(ah, rfilt);
@@ -2993,6 +2999,8 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2993 /* Set the cached hw filter flags, this will alter actually 2999 /* Set the cached hw filter flags, this will alter actually
2994 * be set in HW */ 3000 * be set in HW */
2995 sc->filter_flags = rfilt; 3001 sc->filter_flags = rfilt;
3002
3003 mutex_unlock(&sc->lock);
2996} 3004}
2997 3005
2998static int 3006static int
@@ -3014,6 +3022,9 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3014 case ALG_TKIP: 3022 case ALG_TKIP:
3015 break; 3023 break;
3016 case ALG_CCMP: 3024 case ALG_CCMP:
3025 if (sc->ah->ah_aes_support)
3026 break;
3027
3017 return -EOPNOTSUPP; 3028 return -EOPNOTSUPP;
3018 default: 3029 default:
3019 WARN_ON(1); 3030 WARN_ON(1);
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 8af477dd6fc7..644962adda97 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -414,27 +414,11 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
414 break; 414 break;
415 } 415 }
416 416
417done: 417 /*
418 /* return new offset */ 418 * Read turbo mode information on newer EEPROM versions
419 *offset = o; 419 */
420
421 return 0;
422}
423
424/*
425 * Read turbo mode information on newer EEPROM versions
426 */
427static int
428ath5k_eeprom_read_turbo_modes(struct ath5k_hw *ah,
429 u32 *offset, unsigned int mode)
430{
431 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
432 u32 o = *offset;
433 u16 val;
434 int ret;
435
436 if (ee->ee_version < AR5K_EEPROM_VERSION_5_0) 420 if (ee->ee_version < AR5K_EEPROM_VERSION_5_0)
437 return 0; 421 goto done;
438 422
439 switch (mode){ 423 switch (mode){
440 case AR5K_EEPROM_MODE_11A: 424 case AR5K_EEPROM_MODE_11A:
@@ -468,6 +452,7 @@ ath5k_eeprom_read_turbo_modes(struct ath5k_hw *ah,
468 break; 452 break;
469 } 453 }
470 454
455done:
471 /* return new offset */ 456 /* return new offset */
472 *offset = o; 457 *offset = o;
473 458
@@ -504,10 +489,6 @@ ath5k_eeprom_init_modes(struct ath5k_hw *ah)
504 ret = ath5k_eeprom_read_modes(ah, &offset, mode); 489 ret = ath5k_eeprom_read_modes(ah, &offset, mode);
505 if (ret) 490 if (ret)
506 return ret; 491 return ret;
507
508 ret = ath5k_eeprom_read_turbo_modes(ah, &offset, mode);
509 if (ret)
510 return ret;
511 } 492 }
512 493
513 /* override for older eeprom versions for better performance */ 494 /* override for older eeprom versions for better performance */
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index 876725f08b6c..b767c3b67b24 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -69,6 +69,8 @@ static const struct pci_device_id ath5k_led_devices[] = {
69 { ATH_SDEVICE(PCI_VENDOR_ID_AZWAVE, 0x1026), ATH_LED(3, 0) }, 69 { ATH_SDEVICE(PCI_VENDOR_ID_AZWAVE, 0x1026), ATH_LED(3, 0) },
70 /* IBM ThinkPad AR5BXB6 (legovini@spiro.fisica.unipd.it) */ 70 /* IBM ThinkPad AR5BXB6 (legovini@spiro.fisica.unipd.it) */
71 { ATH_SDEVICE(PCI_VENDOR_ID_IBM, 0x058a), ATH_LED(1, 0) }, 71 { ATH_SDEVICE(PCI_VENDOR_ID_IBM, 0x058a), ATH_LED(1, 0) },
72 /* HP Compaq C700 (nitrousnrg@gmail.com) */
73 { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) },
72 /* IBM-specific AR5212 (all others) */ 74 /* IBM-specific AR5212 (all others) */
73 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) }, 75 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) },
74 { } 76 { }
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index 28443e05ec10..ff2c9a26c10c 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -12,7 +12,8 @@ ath9k-y += hw.o \
12 recv.o \ 12 recv.o \
13 xmit.o \ 13 xmit.o \
14 virtual.o \ 14 virtual.o \
15 rc.o 15 rc.o \
16 btcoex.o
16 17
17ath9k-$(CONFIG_PCI) += pci.o 18ath9k-$(CONFIG_PCI) += pci.o
18ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o 19ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 7705da1103f4..1c68a9da22d4 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -26,6 +26,7 @@
26#include "rc.h" 26#include "rc.h"
27#include "debug.h" 27#include "debug.h"
28#include "../ath.h" 28#include "../ath.h"
29#include "btcoex.h"
29 30
30struct ath_node; 31struct ath_node;
31 32
@@ -521,6 +522,8 @@ struct ath_led {
521#define SC_OP_WAIT_FOR_PSPOLL_DATA BIT(17) 522#define SC_OP_WAIT_FOR_PSPOLL_DATA BIT(17)
522#define SC_OP_WAIT_FOR_TX_ACK BIT(18) 523#define SC_OP_WAIT_FOR_TX_ACK BIT(18)
523#define SC_OP_BEACON_SYNC BIT(19) 524#define SC_OP_BEACON_SYNC BIT(19)
525#define SC_OP_BTCOEX_ENABLED BIT(20)
526#define SC_OP_BT_PRIORITY_DETECTED BIT(21)
524 527
525struct ath_bus_ops { 528struct ath_bus_ops {
526 void (*read_cachesize)(struct ath_softc *sc, int *csz); 529 void (*read_cachesize)(struct ath_softc *sc, int *csz);
@@ -609,6 +612,7 @@ struct ath_softc {
609 struct ath_bus_ops *bus_ops; 612 struct ath_bus_ops *bus_ops;
610 struct ath_beacon_config cur_beacon_conf; 613 struct ath_beacon_config cur_beacon_conf;
611 struct delayed_work tx_complete_work; 614 struct delayed_work tx_complete_work;
615 struct ath_btcoex_info btcoex_info;
612}; 616};
613 617
614struct ath_wiphy { 618struct ath_wiphy {
@@ -705,4 +709,5 @@ bool ath9k_all_wiphys_idle(struct ath_softc *sc);
705void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val); 709void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val);
706unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset); 710unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset);
707 711
712int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype);
708#endif /* ATH9K_H */ 713#endif /* ATH9K_H */
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c
new file mode 100644
index 000000000000..8fb356748823
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/btcoex.c
@@ -0,0 +1,319 @@
1/*
2 * Copyright (c) 2009 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "ath9k.h"
18
19static const struct ath_btcoex_config ath_bt_config = { 0, true, true,
20 ATH_BT_COEX_MODE_SLOTTED, true, true, 2, 5, true };
21
22
23/*
24 * Detects if there is any priority bt traffic
25 */
26static void ath_detect_bt_priority(struct ath_softc *sc)
27{
28 struct ath_btcoex_info *btinfo = &sc->btcoex_info;
29
30 if (ath9k_hw_gpio_get(sc->sc_ah, btinfo->btpriority_gpio))
31 btinfo->bt_priority_cnt++;
32
33 if (time_after(jiffies, btinfo->bt_priority_time +
34 msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) {
35 if (btinfo->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
36 DPRINTF(sc, ATH_DBG_BTCOEX,
37 "BT priority traffic detected");
38 sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED;
39 } else {
40 sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED;
41 }
42
43 btinfo->bt_priority_cnt = 0;
44 btinfo->bt_priority_time = jiffies;
45 }
46}
47
48/*
49 * Configures appropriate weight based on stomp type.
50 */
51static void ath_btcoex_bt_stomp(struct ath_softc *sc,
52 struct ath_btcoex_info *btinfo,
53 int stomp_type)
54{
55
56 switch (stomp_type) {
57 case ATH_BTCOEX_STOMP_ALL:
58 ath_btcoex_set_weight(btinfo, AR_BT_COEX_WGHT,
59 AR_STOMP_ALL_WLAN_WGHT);
60 break;
61 case ATH_BTCOEX_STOMP_LOW:
62 ath_btcoex_set_weight(btinfo, AR_BT_COEX_WGHT,
63 AR_STOMP_LOW_WLAN_WGHT);
64 break;
65 case ATH_BTCOEX_STOMP_NONE:
66 ath_btcoex_set_weight(btinfo, AR_BT_COEX_WGHT,
67 AR_STOMP_NONE_WLAN_WGHT);
68 break;
69 default:
70 DPRINTF(sc, ATH_DBG_BTCOEX, "Invalid Stomptype\n");
71 break;
72 }
73
74 ath9k_hw_btcoex_enable(sc->sc_ah);
75}
76
77/*
78 * This is the master bt coex timer which runs for every
79 * 45ms, bt traffic will be given priority during 55% of this
80 * period while wlan gets remaining 45%
81 */
82
83static void ath_btcoex_period_timer(unsigned long data)
84{
85 struct ath_softc *sc = (struct ath_softc *) data;
86 struct ath_btcoex_info *btinfo = &sc->btcoex_info;
87 unsigned long flags;
88
89 ath_detect_bt_priority(sc);
90
91 spin_lock_irqsave(&btinfo->btcoex_lock, flags);
92
93 ath_btcoex_bt_stomp(sc, btinfo, btinfo->bt_stomp_type);
94
95 spin_unlock_irqrestore(&btinfo->btcoex_lock, flags);
96
97 if (btinfo->btcoex_period != btinfo->btcoex_no_stomp) {
98 if (btinfo->hw_timer_enabled)
99 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer);
100
101 ath_gen_timer_start(sc->sc_ah,
102 btinfo->no_stomp_timer,
103 (ath9k_hw_gettsf32(sc->sc_ah) +
104 btinfo->btcoex_no_stomp),
105 btinfo->btcoex_no_stomp * 10);
106 btinfo->hw_timer_enabled = true;
107 }
108
109 mod_timer(&btinfo->period_timer, jiffies +
110 msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD));
111}
112
113/*
114 * Generic tsf based hw timer which configures weight
115 * registers to time slice between wlan and bt traffic
116 */
117
118static void ath_btcoex_no_stomp_timer(void *arg)
119{
120 struct ath_softc *sc = (struct ath_softc *)arg;
121 struct ath_btcoex_info *btinfo = &sc->btcoex_info;
122 unsigned long flags;
123
124 DPRINTF(sc, ATH_DBG_BTCOEX, "no stomp timer running \n");
125
126 spin_lock_irqsave(&btinfo->btcoex_lock, flags);
127
128 if (btinfo->bt_stomp_type == ATH_BTCOEX_STOMP_LOW)
129 ath_btcoex_bt_stomp(sc, btinfo, ATH_BTCOEX_STOMP_NONE);
130 else if (btinfo->bt_stomp_type == ATH_BTCOEX_STOMP_ALL)
131 ath_btcoex_bt_stomp(sc, btinfo, ATH_BTCOEX_STOMP_LOW);
132
133 spin_unlock_irqrestore(&btinfo->btcoex_lock, flags);
134}
135
136static int ath_init_btcoex_info(struct ath_hw *hw,
137 struct ath_btcoex_info *btcoex_info)
138{
139 u32 i;
140 int qnum;
141
142 qnum = ath_tx_get_qnum(hw->ah_sc, ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE);
143
144 btcoex_info->bt_coex_mode =
145 (btcoex_info->bt_coex_mode & AR_BT_QCU_THRESH) |
146 SM(ath_bt_config.bt_time_extend, AR_BT_TIME_EXTEND) |
147 SM(ath_bt_config.bt_txstate_extend, AR_BT_TXSTATE_EXTEND) |
148 SM(ath_bt_config.bt_txframe_extend, AR_BT_TX_FRAME_EXTEND) |
149 SM(ath_bt_config.bt_mode, AR_BT_MODE) |
150 SM(ath_bt_config.bt_quiet_collision, AR_BT_QUIET) |
151 SM(ath_bt_config.bt_rxclear_polarity, AR_BT_RX_CLEAR_POLARITY) |
152 SM(ath_bt_config.bt_priority_time, AR_BT_PRIORITY_TIME) |
153 SM(ath_bt_config.bt_first_slot_time, AR_BT_FIRST_SLOT_TIME) |
154 SM(qnum, AR_BT_QCU_THRESH);
155
156 btcoex_info->bt_coex_mode2 =
157 SM(ath_bt_config.bt_hold_rx_clear, AR_BT_HOLD_RX_CLEAR) |
158 SM(ATH_BTCOEX_BMISS_THRESH, AR_BT_BCN_MISS_THRESH) |
159 AR_BT_DISABLE_BT_ANT;
160
161 btcoex_info->bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
162
163 btcoex_info->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000;
164
165 btcoex_info->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
166 btcoex_info->btcoex_period / 100;
167
168 for (i = 0; i < 32; i++)
169 hw->hw_gen_timers.gen_timer_index[(debruijn32 << i) >> 27] = i;
170
171 setup_timer(&btcoex_info->period_timer, ath_btcoex_period_timer,
172 (unsigned long) hw->ah_sc);
173
174 btcoex_info->no_stomp_timer = ath_gen_timer_alloc(hw,
175 ath_btcoex_no_stomp_timer,
176 ath_btcoex_no_stomp_timer,
177 (void *)hw->ah_sc, AR_FIRST_NDP_TIMER);
178
179 if (btcoex_info->no_stomp_timer == NULL)
180 return -ENOMEM;
181
182 spin_lock_init(&btcoex_info->btcoex_lock);
183
184 return 0;
185}
186
187int ath9k_hw_btcoex_init(struct ath_hw *ah)
188{
189 struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
190 int ret = 0;
191
192 if (btcoex_info->btcoex_scheme == ATH_BTCOEX_CFG_2WIRE) {
193 /* connect bt_active to baseband */
194 REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
195 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF |
196 AR_GPIO_INPUT_EN_VAL_BT_FREQUENCY_DEF));
197
198 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
199 AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB);
200
201 /* Set input mux for bt_active to gpio pin */
202 REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
203 AR_GPIO_INPUT_MUX1_BT_ACTIVE,
204 btcoex_info->btactive_gpio);
205
206 /* Configure the desired gpio port for input */
207 ath9k_hw_cfg_gpio_input(ah, btcoex_info->btactive_gpio);
208 } else {
209 /* btcoex 3-wire */
210 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
211 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB |
212 AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB));
213
214 /* Set input mux for bt_prority_async and
215 * bt_active_async to GPIO pins */
216 REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
217 AR_GPIO_INPUT_MUX1_BT_ACTIVE,
218 btcoex_info->btactive_gpio);
219
220 REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
221 AR_GPIO_INPUT_MUX1_BT_PRIORITY,
222 btcoex_info->btpriority_gpio);
223
224 /* Configure the desired GPIO ports for input */
225
226 ath9k_hw_cfg_gpio_input(ah, btcoex_info->btactive_gpio);
227 ath9k_hw_cfg_gpio_input(ah, btcoex_info->btpriority_gpio);
228
229 ret = ath_init_btcoex_info(ah, btcoex_info);
230 }
231
232 return ret;
233}
234
235void ath9k_hw_btcoex_enable(struct ath_hw *ah)
236{
237 struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
238
239 if (btcoex_info->btcoex_scheme == ATH_BTCOEX_CFG_2WIRE) {
240 /* Configure the desired GPIO port for TX_FRAME output */
241 ath9k_hw_cfg_output(ah, btcoex_info->wlanactive_gpio,
242 AR_GPIO_OUTPUT_MUX_AS_TX_FRAME);
243 } else {
244 /*
245 * Program coex mode and weight registers to
246 * enable coex 3-wire
247 */
248 REG_WRITE(ah, AR_BT_COEX_MODE, btcoex_info->bt_coex_mode);
249 REG_WRITE(ah, AR_BT_COEX_WEIGHT, btcoex_info->bt_coex_weights);
250 REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex_info->bt_coex_mode2);
251
252 REG_RMW_FIELD(ah, AR_QUIET1,
253 AR_QUIET1_QUIET_ACK_CTS_ENABLE, 1);
254 REG_RMW_FIELD(ah, AR_PCU_MISC,
255 AR_PCU_BT_ANT_PREVENT_RX, 0);
256
257 ath9k_hw_cfg_output(ah, btcoex_info->wlanactive_gpio,
258 AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL);
259 }
260
261 REG_RMW(ah, AR_GPIO_PDPU,
262 (0x2 << (btcoex_info->btactive_gpio * 2)),
263 (0x3 << (btcoex_info->btactive_gpio * 2)));
264
265 ah->ah_sc->sc_flags |= SC_OP_BTCOEX_ENABLED;
266}
267
268void ath9k_hw_btcoex_disable(struct ath_hw *ah)
269{
270 struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
271
272 ath9k_hw_set_gpio(ah, btcoex_info->wlanactive_gpio, 0);
273
274 ath9k_hw_cfg_output(ah, btcoex_info->wlanactive_gpio,
275 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
276
277 if (btcoex_info->btcoex_scheme == ATH_BTCOEX_CFG_3WIRE) {
278 REG_WRITE(ah, AR_BT_COEX_MODE, AR_BT_QUIET | AR_BT_MODE);
279 REG_WRITE(ah, AR_BT_COEX_WEIGHT, 0);
280 REG_WRITE(ah, AR_BT_COEX_MODE2, 0);
281 }
282
283 ah->ah_sc->sc_flags &= ~SC_OP_BTCOEX_ENABLED;
284}
285
286/*
287 * Pause btcoex timer and bt duty cycle timer
288 */
289void ath_btcoex_timer_pause(struct ath_softc *sc,
290 struct ath_btcoex_info *btinfo)
291{
292
293 del_timer_sync(&btinfo->period_timer);
294
295 if (btinfo->hw_timer_enabled)
296 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer);
297
298 btinfo->hw_timer_enabled = false;
299}
300
301/*
302 * (Re)start btcoex timers
303 */
304void ath_btcoex_timer_resume(struct ath_softc *sc,
305 struct ath_btcoex_info *btinfo)
306{
307
308 DPRINTF(sc, ATH_DBG_BTCOEX, "Starting btcoex timers");
309
310 /* make sure duty cycle timer is also stopped when resuming */
311 if (btinfo->hw_timer_enabled)
312 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer);
313
314 btinfo->bt_priority_cnt = 0;
315 btinfo->bt_priority_time = jiffies;
316 sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED;
317
318 mod_timer(&btinfo->period_timer, jiffies);
319}
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h
new file mode 100644
index 000000000000..45568196c59a
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/btcoex.h
@@ -0,0 +1,98 @@
1/*
2 * Copyright (c) 2009 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef BTCOEX_H
18#define BTCOEX_H
19
20#define ATH_WLANACTIVE_GPIO 5
21#define ATH_BTACTIVE_GPIO 6
22
23#define ATH_BTCOEX_DEF_BT_PERIOD 45
24#define ATH_BTCOEX_DEF_DUTY_CYCLE 55
25#define ATH_BTCOEX_BMISS_THRESH 50
26
27#define ATH_BT_PRIORITY_TIME_THRESHOLD 1000 /* ms */
28#define ATH_BT_CNT_THRESHOLD 3
29
30enum ath_btcoex_scheme {
31 ATH_BTCOEX_CFG_NONE,
32 ATH_BTCOEX_CFG_2WIRE,
33 ATH_BTCOEX_CFG_3WIRE,
34};
35
36enum ath_stomp_type {
37 ATH_BTCOEX_NO_STOMP,
38 ATH_BTCOEX_STOMP_ALL,
39 ATH_BTCOEX_STOMP_LOW,
40 ATH_BTCOEX_STOMP_NONE
41};
42
43enum ath_bt_mode {
44 ATH_BT_COEX_MODE_LEGACY, /* legacy rx_clear mode */
45 ATH_BT_COEX_MODE_UNSLOTTED, /* untimed/unslotted mode */
46 ATH_BT_COEX_MODE_SLOTTED, /* slotted mode */
47 ATH_BT_COEX_MODE_DISALBED, /* coexistence disabled */
48};
49
50struct ath_btcoex_config {
51 u8 bt_time_extend;
52 bool bt_txstate_extend;
53 bool bt_txframe_extend;
54 enum ath_bt_mode bt_mode; /* coexistence mode */
55 bool bt_quiet_collision;
56 bool bt_rxclear_polarity; /* invert rx_clear as WLAN_ACTIVE*/
57 u8 bt_priority_time;
58 u8 bt_first_slot_time;
59 bool bt_hold_rx_clear;
60};
61
62struct ath_btcoex_info {
63 enum ath_btcoex_scheme btcoex_scheme;
64 u8 wlanactive_gpio;
65 u8 btactive_gpio;
66 u8 btpriority_gpio;
67 u8 bt_duty_cycle; /* BT duty cycle in percentage */
68 int bt_stomp_type; /* Types of BT stomping */
69 u32 bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */
70 u32 bt_coex_weights; /* Register setting for AR_BT_COEX_WEIGHT */
71 u32 bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */
72 u32 btcoex_no_stomp; /* in usec */
73 u32 btcoex_period; /* in usec */
74 u32 bt_priority_cnt;
75 unsigned long bt_priority_time;
76 bool hw_timer_enabled;
77 spinlock_t btcoex_lock;
78 struct timer_list period_timer; /* Timer for BT period */
79 struct ath_gen_timer *no_stomp_timer; /*Timer for no BT stomping*/
80};
81
82int ath9k_hw_btcoex_init(struct ath_hw *ah);
83void ath9k_hw_btcoex_enable(struct ath_hw *ah);
84void ath9k_hw_btcoex_disable(struct ath_hw *ah);
85void ath_btcoex_timer_resume(struct ath_softc *sc,
86 struct ath_btcoex_info *btinfo);
87void ath_btcoex_timer_pause(struct ath_softc *sc,
88 struct ath_btcoex_info *btinfo);
89
90static inline void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info,
91 u32 bt_weight,
92 u32 wlan_weight)
93{
94 btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
95 SM(wlan_weight, AR_BTCOEX_WL_WGHT);
96}
97
98#endif
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 20f74b5b5703..3234995e8881 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -861,7 +861,7 @@ static void ath9k_hw_9271_pa_cal(struct ath_hw *ah)
861 REG_WRITE(ah, regList[i][0], regList[i][1]); 861 REG_WRITE(ah, regList[i][0], regList[i][1]);
862} 862}
863 863
864static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah) 864static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah, bool is_reset)
865{ 865{
866 866
867 u32 regVal; 867 u32 regVal;
@@ -877,6 +877,13 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
877 { 0x7838, 0 }, 877 { 0x7838, 0 },
878 }; 878 };
879 879
880 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, "Running PA Calibration\n");
881
882 /* PA CAL is not needed for high power solution */
883 if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) ==
884 AR5416_EEP_TXGAIN_HIGH_POWER)
885 return;
886
880 if (AR_SREV_9285_11(ah)) { 887 if (AR_SREV_9285_11(ah)) {
881 REG_WRITE(ah, AR9285_AN_TOP4, (AR9285_AN_TOP4_DEFAULT | 0x14)); 888 REG_WRITE(ah, AR9285_AN_TOP4, (AR9285_AN_TOP4_DEFAULT | 0x14));
882 udelay(10); 889 udelay(10);
@@ -899,13 +906,13 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
899 REG_RMW_FIELD(ah, AR9285_AN_RF2G2, AR9285_AN_RF2G2_OFFCAL, 0); 906 REG_RMW_FIELD(ah, AR9285_AN_RF2G2, AR9285_AN_RF2G2_OFFCAL, 0);
900 REG_RMW_FIELD(ah, AR9285_AN_RF2G7, AR9285_AN_RF2G7_PWDDB, 0); 907 REG_RMW_FIELD(ah, AR9285_AN_RF2G7, AR9285_AN_RF2G7_PWDDB, 0);
901 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_ENPACAL, 0); 908 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_ENPACAL, 0);
902 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPADRV1, 1); 909 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPADRV1, 0);
903 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPADRV2, 0); 910 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPADRV2, 0);
904 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPAOUT, 0); 911 REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPAOUT, 0);
905 REG_RMW_FIELD(ah, AR9285_AN_RF2G8, AR9285_AN_RF2G8_PADRVGN2TAB0, 7); 912 REG_RMW_FIELD(ah, AR9285_AN_RF2G8, AR9285_AN_RF2G8_PADRVGN2TAB0, 7);
906 REG_RMW_FIELD(ah, AR9285_AN_RF2G7, AR9285_AN_RF2G7_PADRVGN2TAB0, 0); 913 REG_RMW_FIELD(ah, AR9285_AN_RF2G7, AR9285_AN_RF2G7_PADRVGN2TAB0, 0);
907 ccomp_org = MS(REG_READ(ah, AR9285_AN_RF2G6), AR9285_AN_RF2G6_CCOMP); 914 ccomp_org = MS(REG_READ(ah, AR9285_AN_RF2G6), AR9285_AN_RF2G6_CCOMP);
908 REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_CCOMP, 7); 915 REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_CCOMP, 0xf);
909 916
910 REG_WRITE(ah, AR9285_AN_TOP2, 0xca0358a0); 917 REG_WRITE(ah, AR9285_AN_TOP2, 0xca0358a0);
911 udelay(30); 918 udelay(30);
@@ -917,7 +924,6 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
917 regVal |= (1 << (19 + i)); 924 regVal |= (1 << (19 + i));
918 REG_WRITE(ah, 0x7834, regVal); 925 REG_WRITE(ah, 0x7834, regVal);
919 udelay(1); 926 udelay(1);
920 regVal = REG_READ(ah, 0x7834);
921 regVal &= (~(0x1 << (19 + i))); 927 regVal &= (~(0x1 << (19 + i)));
922 reg_field = MS(REG_READ(ah, 0x7840), AR9285_AN_RXTXBB1_SPARE9); 928 reg_field = MS(REG_READ(ah, 0x7840), AR9285_AN_RXTXBB1_SPARE9);
923 regVal |= (reg_field << (19 + i)); 929 regVal |= (reg_field << (19 + i));
@@ -936,6 +942,17 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
936 offs_6_1 = offset>>1; 942 offs_6_1 = offset>>1;
937 offs_0 = offset & 1; 943 offs_0 = offset & 1;
938 944
945 if ((!is_reset) && (ah->pacal_info.prev_offset == offset)) {
946 if (ah->pacal_info.max_skipcount < MAX_PACAL_SKIPCOUNT)
947 ah->pacal_info.max_skipcount =
948 2 * ah->pacal_info.max_skipcount;
949 ah->pacal_info.skipcount = ah->pacal_info.max_skipcount;
950 } else {
951 ah->pacal_info.max_skipcount = 1;
952 ah->pacal_info.skipcount = 0;
953 ah->pacal_info.prev_offset = offset;
954 }
955
939 REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_OFFS, offs_6_1); 956 REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_OFFS, offs_6_1);
940 REG_RMW_FIELD(ah, AR9285_AN_RF2G3, AR9285_AN_RF2G3_PDVCCOMP, offs_0); 957 REG_RMW_FIELD(ah, AR9285_AN_RF2G3, AR9285_AN_RF2G3_PDVCCOMP, offs_0);
941 958
@@ -982,8 +999,12 @@ bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
982 /* Do periodic PAOffset Cal */ 999 /* Do periodic PAOffset Cal */
983 if (AR_SREV_9271(ah)) 1000 if (AR_SREV_9271(ah))
984 ath9k_hw_9271_pa_cal(ah); 1001 ath9k_hw_9271_pa_cal(ah);
985 else if (AR_SREV_9285_11_OR_LATER(ah)) 1002 else if (AR_SREV_9285_11_OR_LATER(ah)) {
986 ath9k_hw_9285_pa_cal(ah); 1003 if (!ah->pacal_info.skipcount)
1004 ath9k_hw_9285_pa_cal(ah, false);
1005 else
1006 ah->pacal_info.skipcount--;
1007 }
987 1008
988 if (OLC_FOR_AR9280_20_LATER || OLC_FOR_AR9287_10_LATER) 1009 if (OLC_FOR_AR9280_20_LATER || OLC_FOR_AR9287_10_LATER)
989 ath9k_olc_temp_compensation(ah); 1010 ath9k_olc_temp_compensation(ah);
@@ -1081,7 +1102,7 @@ bool ath9k_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
1081 1102
1082 /* Do PA Calibration */ 1103 /* Do PA Calibration */
1083 if (AR_SREV_9285_11_OR_LATER(ah)) 1104 if (AR_SREV_9285_11_OR_LATER(ah))
1084 ath9k_hw_9285_pa_cal(ah); 1105 ath9k_hw_9285_pa_cal(ah, true);
1085 1106
1086 /* Do NF Calibration after DC offset and other calibrations */ 1107 /* Do NF Calibration after DC offset and other calibrations */
1087 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 1108 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index 547e697b9055..019bcbba40ed 100644
--- a/drivers/net/wireless/ath/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -110,6 +110,13 @@ struct ath9k_nfcal_hist {
110 u8 invalidNFcount; 110 u8 invalidNFcount;
111}; 111};
112 112
113#define MAX_PACAL_SKIPCOUNT 8
114struct ath9k_pacal_info{
115 int32_t prev_offset; /* Previous value of PA offset value */
116 int8_t max_skipcount; /* Max No. of times PACAL can be skipped */
117 int8_t skipcount; /* No. of times the PACAL to be skipped */
118};
119
113bool ath9k_hw_reset_calvalid(struct ath_hw *ah); 120bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
114void ath9k_hw_start_nfcal(struct ath_hw *ah); 121void ath9k_hw_start_nfcal(struct ath_hw *ah);
115void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan); 122void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 9e369208f7dc..2be4c2252047 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -93,6 +93,8 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
93 int i, qcuOffset = 0, dcuOffset = 0; 93 int i, qcuOffset = 0, dcuOffset = 0;
94 u32 *qcuBase = &val[0], *dcuBase = &val[4]; 94 u32 *qcuBase = &val[0], *dcuBase = &val[4];
95 95
96 ath9k_ps_wakeup(sc);
97
96 REG_WRITE(ah, AR_MACMISC, 98 REG_WRITE(ah, AR_MACMISC,
97 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 99 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
98 (AR_MACMISC_MISC_OBS_BUS_1 << 100 (AR_MACMISC_MISC_OBS_BUS_1 <<
@@ -159,6 +161,8 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
159 len += snprintf(buf + len, sizeof(buf) - len, 161 len += snprintf(buf + len, sizeof(buf) - len,
160 "AR_CR: 0x%x \n", REG_READ(ah, AR_CR)); 162 "AR_CR: 0x%x \n", REG_READ(ah, AR_CR));
161 163
164 ath9k_ps_restore(sc);
165
162 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 166 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
163} 167}
164 168
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 5e56b79d0cb0..7241f4748338 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -30,6 +30,8 @@ enum ATH_DEBUG {
30 ATH_DBG_CONFIG = 0x00000200, 30 ATH_DBG_CONFIG = 0x00000200,
31 ATH_DBG_FATAL = 0x00000400, 31 ATH_DBG_FATAL = 0x00000400,
32 ATH_DBG_PS = 0x00000800, 32 ATH_DBG_PS = 0x00000800,
33 ATH_DBG_HWTIMER = 0x00001000,
34 ATH_DBG_BTCOEX = 0x00002000,
33 ATH_DBG_ANY = 0xffffffff 35 ATH_DBG_ANY = 0xffffffff
34}; 36};
35 37
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index 958948bc73fd..b6e52d0f8c48 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -143,10 +143,10 @@ void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah,
143 IS_CHAN_2GHZ(chan))) { 143 IS_CHAN_2GHZ(chan))) {
144 matchIndex = i; 144 matchIndex = i;
145 break; 145 break;
146 } else if ((freq < ath9k_hw_fbin2freq(powInfo[i].bChannel, 146 } else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
147 IS_CHAN_2GHZ(chan))) && 147 IS_CHAN_2GHZ(chan)) && i > 0 &&
148 (freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel, 148 freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
149 IS_CHAN_2GHZ(chan)))) { 149 IS_CHAN_2GHZ(chan))) {
150 lowIndex = i - 1; 150 lowIndex = i - 1;
151 break; 151 break;
152 } 152 }
@@ -198,10 +198,10 @@ void ath9k_hw_get_target_powers(struct ath_hw *ah,
198 matchIndex = i; 198 matchIndex = i;
199 break; 199 break;
200 } else 200 } else
201 if ((freq < ath9k_hw_fbin2freq(powInfo[i].bChannel, 201 if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
202 IS_CHAN_2GHZ(chan))) && 202 IS_CHAN_2GHZ(chan)) && i > 0 &&
203 (freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel, 203 freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
204 IS_CHAN_2GHZ(chan)))) { 204 IS_CHAN_2GHZ(chan))) {
205 lowIndex = i - 1; 205 lowIndex = i - 1;
206 break; 206 break;
207 } 207 }
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 4f3d5ea34812..e340dacc6ebe 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2555,6 +2555,9 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2555#endif 2555#endif
2556 } 2556 }
2557 2557
2558 if (ah->ah_sc->sc_flags & SC_OP_BTCOEX_ENABLED)
2559 ath9k_hw_btcoex_enable(ah);
2560
2558 return 0; 2561 return 0;
2559} 2562}
2560 2563
@@ -3212,6 +3215,23 @@ bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked)
3212 if (AR_SREV_9100(ah)) 3215 if (AR_SREV_9100(ah))
3213 return true; 3216 return true;
3214 3217
3218 if (isr & AR_ISR_GENTMR) {
3219 u32 s5_s;
3220
3221 s5_s = REG_READ(ah, AR_ISR_S5_S);
3222 if (isr & AR_ISR_GENTMR) {
3223 ah->intr_gen_timer_trigger =
3224 MS(s5_s, AR_ISR_S5_GENTIMER_TRIG);
3225
3226 ah->intr_gen_timer_thresh =
3227 MS(s5_s, AR_ISR_S5_GENTIMER_THRESH);
3228
3229 if (ah->intr_gen_timer_trigger)
3230 *masked |= ATH9K_INT_GENTIMER;
3231
3232 }
3233 }
3234
3215 if (sync_cause) { 3235 if (sync_cause) {
3216 fatal_int = 3236 fatal_int =
3217 (sync_cause & 3237 (sync_cause &
@@ -3486,6 +3506,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
3486{ 3506{
3487 struct ath9k_hw_capabilities *pCap = &ah->caps; 3507 struct ath9k_hw_capabilities *pCap = &ah->caps;
3488 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); 3508 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
3509 struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
3489 3510
3490 u16 capField = 0, eeval; 3511 u16 capField = 0, eeval;
3491 3512
@@ -3662,9 +3683,15 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
3662 ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_2GHZ); 3683 ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_2GHZ);
3663 3684
3664 if (AR_SREV_9280_10_OR_LATER(ah) && btcoex_enable) { 3685 if (AR_SREV_9280_10_OR_LATER(ah) && btcoex_enable) {
3665 pCap->hw_caps |= ATH9K_HW_CAP_BT_COEX; 3686 btcoex_info->btactive_gpio = ATH_BTACTIVE_GPIO;
3666 ah->btactive_gpio = 6; 3687 btcoex_info->wlanactive_gpio = ATH_WLANACTIVE_GPIO;
3667 ah->wlanactive_gpio = 5; 3688
3689 if (AR_SREV_9285(ah))
3690 btcoex_info->btcoex_scheme = ATH_BTCOEX_CFG_3WIRE;
3691 else
3692 btcoex_info->btcoex_scheme = ATH_BTCOEX_CFG_2WIRE;
3693 } else {
3694 btcoex_info->btcoex_scheme = ATH_BTCOEX_CFG_NONE;
3668 } 3695 }
3669} 3696}
3670 3697
@@ -4069,29 +4096,197 @@ void ath9k_hw_set11nmac2040(struct ath_hw *ah, enum ath9k_ht_macmode mode)
4069 REG_WRITE(ah, AR_2040_MODE, macmode); 4096 REG_WRITE(ah, AR_2040_MODE, macmode);
4070} 4097}
4071 4098
4072/***************************/ 4099/* HW Generic timers configuration */
4073/* Bluetooth Coexistence */
4074/***************************/
4075 4100
4076void ath9k_hw_btcoex_enable(struct ath_hw *ah) 4101static const struct ath_gen_timer_configuration gen_tmr_configuration[] =
4102{
4103 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4104 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4105 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4106 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4107 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4108 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4109 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4110 {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080},
4111 {AR_NEXT_NDP2_TIMER, AR_NDP2_PERIOD, AR_NDP2_TIMER_MODE, 0x0001},
4112 {AR_NEXT_NDP2_TIMER + 1*4, AR_NDP2_PERIOD + 1*4,
4113 AR_NDP2_TIMER_MODE, 0x0002},
4114 {AR_NEXT_NDP2_TIMER + 2*4, AR_NDP2_PERIOD + 2*4,
4115 AR_NDP2_TIMER_MODE, 0x0004},
4116 {AR_NEXT_NDP2_TIMER + 3*4, AR_NDP2_PERIOD + 3*4,
4117 AR_NDP2_TIMER_MODE, 0x0008},
4118 {AR_NEXT_NDP2_TIMER + 4*4, AR_NDP2_PERIOD + 4*4,
4119 AR_NDP2_TIMER_MODE, 0x0010},
4120 {AR_NEXT_NDP2_TIMER + 5*4, AR_NDP2_PERIOD + 5*4,
4121 AR_NDP2_TIMER_MODE, 0x0020},
4122 {AR_NEXT_NDP2_TIMER + 6*4, AR_NDP2_PERIOD + 6*4,
4123 AR_NDP2_TIMER_MODE, 0x0040},
4124 {AR_NEXT_NDP2_TIMER + 7*4, AR_NDP2_PERIOD + 7*4,
4125 AR_NDP2_TIMER_MODE, 0x0080}
4126};
4127
4128/* HW generic timer primitives */
4129
4130/* compute and clear index of rightmost 1 */
4131static u32 rightmost_index(struct ath_gen_timer_table *timer_table, u32 *mask)
4077{ 4132{
4078 /* connect bt_active to baseband */ 4133 u32 b;
4079 REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL,
4080 (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF |
4081 AR_GPIO_INPUT_EN_VAL_BT_FREQUENCY_DEF));
4082 4134
4083 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, 4135 b = *mask;
4084 AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB); 4136 b &= (0-b);
4137 *mask &= ~b;
4138 b *= debruijn32;
4139 b >>= 27;
4140
4141 return timer_table->gen_timer_index[b];
4142}
4143
4144u32 ath9k_hw_gettsf32(struct ath_hw *ah)
4145{
4146 return REG_READ(ah, AR_TSF_L32);
4147}
4148
4149struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
4150 void (*trigger)(void *),
4151 void (*overflow)(void *),
4152 void *arg,
4153 u8 timer_index)
4154{
4155 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
4156 struct ath_gen_timer *timer;
4157
4158 timer = kzalloc(sizeof(struct ath_gen_timer), GFP_KERNEL);
4159
4160 if (timer == NULL) {
4161 printk(KERN_DEBUG "Failed to allocate memory"
4162 "for hw timer[%d]\n", timer_index);
4163 return NULL;
4164 }
4165
4166 /* allocate a hardware generic timer slot */
4167 timer_table->timers[timer_index] = timer;
4168 timer->index = timer_index;
4169 timer->trigger = trigger;
4170 timer->overflow = overflow;
4171 timer->arg = arg;
4172
4173 return timer;
4174}
4175
4176void ath_gen_timer_start(struct ath_hw *ah,
4177 struct ath_gen_timer *timer,
4178 u32 timer_next, u32 timer_period)
4179{
4180 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
4181 u32 tsf;
4182
4183 BUG_ON(!timer_period);
4184
4185 set_bit(timer->index, &timer_table->timer_mask.timer_bits);
4085 4186
4086 /* Set input mux for bt_active to gpio pin */ 4187 tsf = ath9k_hw_gettsf32(ah);
4087 REG_RMW_FIELD(ah, AR_GPIO_INPUT_MUX1,
4088 AR_GPIO_INPUT_MUX1_BT_ACTIVE,
4089 ah->btactive_gpio);
4090 4188
4091 /* Configure the desired gpio port for input */ 4189 DPRINTF(ah->ah_sc, ATH_DBG_HWTIMER, "curent tsf %x period %x"
4092 ath9k_hw_cfg_gpio_input(ah, ah->btactive_gpio); 4190 "timer_next %x\n", tsf, timer_period, timer_next);
4093 4191
4094 /* Configure the desired GPIO port for TX_FRAME output */ 4192 /*
4095 ath9k_hw_cfg_output(ah, ah->wlanactive_gpio, 4193 * Pull timer_next forward if the current TSF already passed it
4096 AR_GPIO_OUTPUT_MUX_AS_TX_FRAME); 4194 * because of software latency
4195 */
4196 if (timer_next < tsf)
4197 timer_next = tsf + timer_period;
4198
4199 /*
4200 * Program generic timer registers
4201 */
4202 REG_WRITE(ah, gen_tmr_configuration[timer->index].next_addr,
4203 timer_next);
4204 REG_WRITE(ah, gen_tmr_configuration[timer->index].period_addr,
4205 timer_period);
4206 REG_SET_BIT(ah, gen_tmr_configuration[timer->index].mode_addr,
4207 gen_tmr_configuration[timer->index].mode_mask);
4208
4209 /* Enable both trigger and thresh interrupt masks */
4210 REG_SET_BIT(ah, AR_IMR_S5,
4211 (SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_THRESH) |
4212 SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_TRIG)));
4213
4214 if ((ah->ah_sc->imask & ATH9K_INT_GENTIMER) == 0) {
4215 ath9k_hw_set_interrupts(ah, 0);
4216 ah->ah_sc->imask |= ATH9K_INT_GENTIMER;
4217 ath9k_hw_set_interrupts(ah, ah->ah_sc->imask);
4218 }
4219}
4220
4221void ath_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer)
4222{
4223 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
4224
4225 if ((timer->index < AR_FIRST_NDP_TIMER) ||
4226 (timer->index >= ATH_MAX_GEN_TIMER)) {
4227 return;
4228 }
4229
4230 /* Clear generic timer enable bits. */
4231 REG_CLR_BIT(ah, gen_tmr_configuration[timer->index].mode_addr,
4232 gen_tmr_configuration[timer->index].mode_mask);
4233
4234 /* Disable both trigger and thresh interrupt masks */
4235 REG_CLR_BIT(ah, AR_IMR_S5,
4236 (SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_THRESH) |
4237 SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_TRIG)));
4238
4239 clear_bit(timer->index, &timer_table->timer_mask.timer_bits);
4240
4241 /* if no timer is enabled, turn off interrupt mask */
4242 if (timer_table->timer_mask.val == 0) {
4243 ath9k_hw_set_interrupts(ah, 0);
4244 ah->ah_sc->imask &= ~ATH9K_INT_GENTIMER;
4245 ath9k_hw_set_interrupts(ah, ah->ah_sc->imask);
4246 }
4247}
4248
4249void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer)
4250{
4251 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
4252
4253 /* free the hardware generic timer slot */
4254 timer_table->timers[timer->index] = NULL;
4255 kfree(timer);
4256}
4257
4258/*
4259 * Generic Timer Interrupts handling
4260 */
4261void ath_gen_timer_isr(struct ath_hw *ah)
4262{
4263 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers;
4264 struct ath_gen_timer *timer;
4265 u32 trigger_mask, thresh_mask, index;
4266
4267 /* get hardware generic timer interrupt status */
4268 trigger_mask = ah->intr_gen_timer_trigger;
4269 thresh_mask = ah->intr_gen_timer_thresh;
4270 trigger_mask &= timer_table->timer_mask.val;
4271 thresh_mask &= timer_table->timer_mask.val;
4272
4273 trigger_mask &= ~thresh_mask;
4274
4275 while (thresh_mask) {
4276 index = rightmost_index(timer_table, &thresh_mask);
4277 timer = timer_table->timers[index];
4278 BUG_ON(!timer);
4279 DPRINTF(ah->ah_sc, ATH_DBG_HWTIMER,
4280 "TSF overflow for Gen timer %d\n", index);
4281 timer->overflow(timer->arg);
4282 }
4283
4284 while (trigger_mask) {
4285 index = rightmost_index(timer_table, &trigger_mask);
4286 timer = timer_table->timers[index];
4287 BUG_ON(!timer);
4288 DPRINTF(ah->ah_sc, ATH_DBG_HWTIMER,
4289 "Gen timer[%d] trigger\n", index);
4290 timer->trigger(timer->arg);
4291 }
4097} 4292}
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 24b30631d93e..5ca6ffa70912 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -79,6 +79,7 @@
79#define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1 79#define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1
80#define AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED 2 80#define AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED 2
81#define AR_GPIO_OUTPUT_MUX_AS_TX_FRAME 3 81#define AR_GPIO_OUTPUT_MUX_AS_TX_FRAME 3
82#define AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL 4
82#define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5 83#define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5
83#define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6 84#define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6
84 85
@@ -151,7 +152,6 @@ enum ath9k_hw_caps {
151 ATH9K_HW_CAP_ENHANCEDPM = BIT(14), 152 ATH9K_HW_CAP_ENHANCEDPM = BIT(14),
152 ATH9K_HW_CAP_AUTOSLEEP = BIT(15), 153 ATH9K_HW_CAP_AUTOSLEEP = BIT(15),
153 ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(16), 154 ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(16),
154 ATH9K_HW_CAP_BT_COEX = BIT(17)
155}; 155};
156 156
157enum ath9k_capability_type { 157enum ath9k_capability_type {
@@ -238,6 +238,7 @@ enum ath9k_int {
238 ATH9K_INT_GPIO = 0x01000000, 238 ATH9K_INT_GPIO = 0x01000000,
239 ATH9K_INT_CABEND = 0x02000000, 239 ATH9K_INT_CABEND = 0x02000000,
240 ATH9K_INT_TSFOOR = 0x04000000, 240 ATH9K_INT_TSFOOR = 0x04000000,
241 ATH9K_INT_GENTIMER = 0x08000000,
241 ATH9K_INT_CST = 0x10000000, 242 ATH9K_INT_CST = 0x10000000,
242 ATH9K_INT_GTT = 0x20000000, 243 ATH9K_INT_GTT = 0x20000000,
243 ATH9K_INT_FATAL = 0x40000000, 244 ATH9K_INT_FATAL = 0x40000000,
@@ -391,6 +392,41 @@ struct ath9k_hw_version {
391 u16 analog2GhzRev; 392 u16 analog2GhzRev;
392}; 393};
393 394
395/* Generic TSF timer definitions */
396
397#define ATH_MAX_GEN_TIMER 16
398
399#define AR_GENTMR_BIT(_index) (1 << (_index))
400
401/*
402 * Using de Bruijin sequence to to look up 1's index in a 32 bit number
403 * debruijn32 = 0000 0111 0111 1100 1011 0101 0011 0001
404 */
405#define debruijn32 0x077CB531UL
406
407struct ath_gen_timer_configuration {
408 u32 next_addr;
409 u32 period_addr;
410 u32 mode_addr;
411 u32 mode_mask;
412};
413
414struct ath_gen_timer {
415 void (*trigger)(void *arg);
416 void (*overflow)(void *arg);
417 void *arg;
418 u8 index;
419};
420
421struct ath_gen_timer_table {
422 u32 gen_timer_index[32];
423 struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER];
424 union {
425 unsigned long timer_bits;
426 u16 val;
427 } timer_mask;
428};
429
394struct ath_hw { 430struct ath_hw {
395 struct ath_softc *ah_sc; 431 struct ath_softc *ah_sc;
396 struct ath9k_hw_version hw_version; 432 struct ath9k_hw_version hw_version;
@@ -414,8 +450,6 @@ struct ath_hw {
414 u16 rfsilent; 450 u16 rfsilent;
415 u32 rfkill_gpio; 451 u32 rfkill_gpio;
416 u32 rfkill_polarity; 452 u32 rfkill_polarity;
417 u32 btactive_gpio;
418 u32 wlanactive_gpio;
419 u32 ah_flags; 453 u32 ah_flags;
420 454
421 bool htc_reset_init; 455 bool htc_reset_init;
@@ -424,6 +458,7 @@ struct ath_hw {
424 enum ath9k_power_mode power_mode; 458 enum ath9k_power_mode power_mode;
425 459
426 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 460 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
461 struct ath9k_pacal_info pacal_info;
427 struct ar5416Stats stats; 462 struct ar5416Stats stats;
428 struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; 463 struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES];
429 464
@@ -538,6 +573,10 @@ struct ath_hw {
538 struct ar5416IniArray iniModesAdditional; 573 struct ar5416IniArray iniModesAdditional;
539 struct ar5416IniArray iniModesRxGain; 574 struct ar5416IniArray iniModesRxGain;
540 struct ar5416IniArray iniModesTxGain; 575 struct ar5416IniArray iniModesTxGain;
576
577 u32 intr_gen_timer_trigger;
578 u32 intr_gen_timer_thresh;
579 struct ath_gen_timer_table hw_gen_timers;
541}; 580};
542 581
543/* Initialization, Detach, Reset */ 582/* Initialization, Detach, Reset */
@@ -613,6 +652,17 @@ bool ath9k_hw_intrpend(struct ath_hw *ah);
613bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked); 652bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked);
614enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints); 653enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints);
615 654
616void ath9k_hw_btcoex_enable(struct ath_hw *ah); 655/* Generic hw timer primitives */
656struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
657 void (*trigger)(void *),
658 void (*overflow)(void *),
659 void *arg,
660 u8 timer_index);
661void ath_gen_timer_start(struct ath_hw *ah, struct ath_gen_timer *timer,
662 u32 timer_next, u32 timer_period);
663void ath_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer);
664void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer);
665void ath_gen_timer_isr(struct ath_hw *hw);
666u32 ath9k_hw_gettsf32(struct ath_hw *ah);
617 667
618#endif 668#endif
diff --git a/drivers/net/wireless/ath/ath9k/initvals.h b/drivers/net/wireless/ath/ath9k/initvals.h
index 27a86bb7c4c8..8622265a030a 100644
--- a/drivers/net/wireless/ath/ath9k/initvals.h
+++ b/drivers/net/wireless/ath/ath9k/initvals.h
@@ -4133,7 +4133,7 @@ static const u_int32_t ar9285Modes_9285_1_2[][6] = {
4133 { 0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440, 0x00006880 }, 4133 { 0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440, 0x00006880 },
4134 { 0x00009804, 0x00000300, 0x000003c4, 0x000003c4, 0x00000300, 0x00000303 }, 4134 { 0x00009804, 0x00000300, 0x000003c4, 0x000003c4, 0x00000300, 0x00000303 },
4135 { 0x00009820, 0x02020200, 0x02020200, 0x02020200, 0x02020200, 0x02020200 }, 4135 { 0x00009820, 0x02020200, 0x02020200, 0x02020200, 0x02020200, 0x02020200 },
4136 { 0x00009824, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e }, 4136 { 0x00009824, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e },
4137 { 0x00009828, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001 }, 4137 { 0x00009828, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001 },
4138 { 0x00009834, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e }, 4138 { 0x00009834, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e },
4139 { 0x00009838, 0x00000007, 0x00000007, 0x00000007, 0x00000007, 0x00000007 }, 4139 { 0x00009838, 0x00000007, 0x00000007, 0x00000007, 0x00000007, 0x00000007 },
@@ -4158,7 +4158,7 @@ static const u_int32_t ar9285Modes_9285_1_2[][6] = {
4158 { 0x000099bc, 0x00000600, 0x00000600, 0x00000c00, 0x00000c00, 0x00000c00 }, 4158 { 0x000099bc, 0x00000600, 0x00000600, 0x00000c00, 0x00000c00, 0x00000c00 },
4159 { 0x000099c0, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4 }, 4159 { 0x000099c0, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4 },
4160 { 0x000099c4, 0x06336f77, 0x06336f77, 0x06336f77, 0x06336f77, 0x06336f77 }, 4160 { 0x000099c4, 0x06336f77, 0x06336f77, 0x06336f77, 0x06336f77, 0x06336f77 },
4161 { 0x000099c8, 0x6af65329, 0x6af65329, 0x6af65329, 0x6af65329, 0x6af65329 }, 4161 { 0x000099c8, 0x6af6532f, 0x6af6532f, 0x6af6532f, 0x6af6532f, 0x6af6532f },
4162 { 0x000099cc, 0x08f186c8, 0x08f186c8, 0x08f186c8, 0x08f186c8, 0x08f186c8 }, 4162 { 0x000099cc, 0x08f186c8, 0x08f186c8, 0x08f186c8, 0x08f186c8, 0x08f186c8 },
4163 { 0x000099d0, 0x00046384, 0x00046384, 0x00046384, 0x00046384, 0x00046384 }, 4163 { 0x000099d0, 0x00046384, 0x00046384, 0x00046384, 0x00046384, 0x00046384 },
4164 { 0x000099d4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, 4164 { 0x000099d4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
@@ -4601,7 +4601,7 @@ static const u_int32_t ar9285Common_9285_1_2[][2] = {
4601 { 0x00008258, 0x00000000 }, 4601 { 0x00008258, 0x00000000 },
4602 { 0x0000825c, 0x400000ff }, 4602 { 0x0000825c, 0x400000ff },
4603 { 0x00008260, 0x00080922 }, 4603 { 0x00008260, 0x00080922 },
4604 { 0x00008264, 0xa8a00010 }, 4604 { 0x00008264, 0x88a00010 },
4605 { 0x00008270, 0x00000000 }, 4605 { 0x00008270, 0x00000000 },
4606 { 0x00008274, 0x40000000 }, 4606 { 0x00008274, 0x40000000 },
4607 { 0x00008278, 0x003e4180 }, 4607 { 0x00008278, 0x003e4180 },
@@ -4650,7 +4650,7 @@ static const u_int32_t ar9285Common_9285_1_2[][2] = {
4650 { 0x00009954, 0x5f3ca3de }, 4650 { 0x00009954, 0x5f3ca3de },
4651 { 0x00009958, 0x2108ecff }, 4651 { 0x00009958, 0x2108ecff },
4652 { 0x00009968, 0x000003ce }, 4652 { 0x00009968, 0x000003ce },
4653 { 0x00009970, 0x192bb515 }, 4653 { 0x00009970, 0x192bb514 },
4654 { 0x00009974, 0x00000000 }, 4654 { 0x00009974, 0x00000000 },
4655 { 0x00009978, 0x00000001 }, 4655 { 0x00009978, 0x00000001 },
4656 { 0x0000997c, 0x00000000 }, 4656 { 0x0000997c, 0x00000000 },
@@ -4728,7 +4728,7 @@ static const u_int32_t ar9285Common_9285_1_2[][2] = {
4728 { 0x00007800, 0x00140000 }, 4728 { 0x00007800, 0x00140000 },
4729 { 0x00007804, 0x0e4548d8 }, 4729 { 0x00007804, 0x0e4548d8 },
4730 { 0x00007808, 0x54214514 }, 4730 { 0x00007808, 0x54214514 },
4731 { 0x0000780c, 0x02025820 }, 4731 { 0x0000780c, 0x02025830 },
4732 { 0x00007810, 0x71c0d388 }, 4732 { 0x00007810, 0x71c0d388 },
4733 { 0x00007814, 0x924934a8 }, 4733 { 0x00007814, 0x924934a8 },
4734 { 0x0000781c, 0x00000000 }, 4734 { 0x0000781c, 0x00000000 },
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 9b9b4e8ee1ea..4fae699a53c2 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -439,8 +439,8 @@ static void ath_start_ani(struct ath_softc *sc)
439 */ 439 */
440void ath_update_chainmask(struct ath_softc *sc, int is_ht) 440void ath_update_chainmask(struct ath_softc *sc, int is_ht)
441{ 441{
442 if (is_ht || 442 if ((sc->sc_flags & SC_OP_SCANNING) || is_ht ||
443 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BT_COEX)) { 443 (sc->btcoex_info.btcoex_scheme != ATH_BTCOEX_CFG_NONE)) {
444 sc->tx_chainmask = sc->sc_ah->caps.tx_chainmask; 444 sc->tx_chainmask = sc->sc_ah->caps.tx_chainmask;
445 sc->rx_chainmask = sc->sc_ah->caps.rx_chainmask; 445 sc->rx_chainmask = sc->sc_ah->caps.rx_chainmask;
446 } else { 446 } else {
@@ -602,6 +602,10 @@ irqreturn_t ath_isr(int irq, void *dev)
602 sc->sc_flags |= SC_OP_WAIT_FOR_BEACON; 602 sc->sc_flags |= SC_OP_WAIT_FOR_BEACON;
603 } 603 }
604 604
605 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE)
606 if (status & ATH9K_INT_GENTIMER)
607 ath_gen_timer_isr(ah);
608
605chip_reset: 609chip_reset:
606 610
607 ath_debug_stat_interrupt(sc, status); 611 ath_debug_stat_interrupt(sc, status);
@@ -1279,6 +1283,10 @@ void ath_detach(struct ath_softc *sc)
1279 if (ATH_TXQ_SETUP(sc, i)) 1283 if (ATH_TXQ_SETUP(sc, i))
1280 ath_tx_cleanupq(sc, &sc->tx.txq[i]); 1284 ath_tx_cleanupq(sc, &sc->tx.txq[i]);
1281 1285
1286 if ((sc->btcoex_info.no_stomp_timer) &&
1287 sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE)
1288 ath_gen_timer_free(sc->sc_ah, sc->btcoex_info.no_stomp_timer);
1289
1282 ath9k_hw_detach(sc->sc_ah); 1290 ath9k_hw_detach(sc->sc_ah);
1283 sc->sc_ah = NULL; 1291 sc->sc_ah = NULL;
1284 ath9k_exit_debug(sc); 1292 ath9k_exit_debug(sc);
@@ -1509,8 +1517,11 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc)
1509 ARRAY_SIZE(ath9k_5ghz_chantable); 1517 ARRAY_SIZE(ath9k_5ghz_chantable);
1510 } 1518 }
1511 1519
1512 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BT_COEX) 1520 if (sc->btcoex_info.btcoex_scheme != ATH_BTCOEX_CFG_NONE) {
1513 ath9k_hw_btcoex_enable(sc->sc_ah); 1521 r = ath9k_hw_btcoex_init(ah);
1522 if (r)
1523 goto bad2;
1524 }
1514 1525
1515 return 0; 1526 return 0;
1516bad2: 1527bad2:
@@ -1992,6 +2003,16 @@ static int ath9k_start(struct ieee80211_hw *hw)
1992 2003
1993 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); 2004 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
1994 2005
2006 if ((sc->btcoex_info.btcoex_scheme != ATH_BTCOEX_CFG_NONE) &&
2007 !(sc->sc_flags & SC_OP_BTCOEX_ENABLED)) {
2008 ath_btcoex_set_weight(&sc->btcoex_info, AR_BT_COEX_WGHT,
2009 AR_STOMP_LOW_WLAN_WGHT);
2010 ath9k_hw_btcoex_enable(sc->sc_ah);
2011
2012 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE)
2013 ath_btcoex_timer_resume(sc, &sc->btcoex_info);
2014 }
2015
1995mutex_unlock: 2016mutex_unlock:
1996 mutex_unlock(&sc->mutex); 2017 mutex_unlock(&sc->mutex);
1997 2018
@@ -2125,6 +2146,12 @@ static void ath9k_stop(struct ieee80211_hw *hw)
2125 return; /* another wiphy still in use */ 2146 return; /* another wiphy still in use */
2126 } 2147 }
2127 2148
2149 if (sc->sc_flags & SC_OP_BTCOEX_ENABLED) {
2150 ath9k_hw_btcoex_disable(sc->sc_ah);
2151 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE)
2152 ath_btcoex_timer_pause(sc, &sc->btcoex_info);
2153 }
2154
2128 /* make sure h/w will not generate any interrupt 2155 /* make sure h/w will not generate any interrupt
2129 * before setting the invalid flag. */ 2156 * before setting the invalid flag. */
2130 ath9k_hw_set_interrupts(sc->sc_ah, 0); 2157 ath9k_hw_set_interrupts(sc->sc_ah, 0);
@@ -2713,6 +2740,7 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2713 struct ath_wiphy *aphy = hw->priv; 2740 struct ath_wiphy *aphy = hw->priv;
2714 struct ath_softc *sc = aphy->sc; 2741 struct ath_softc *sc = aphy->sc;
2715 2742
2743 mutex_lock(&sc->mutex);
2716 if (ath9k_wiphy_scanning(sc)) { 2744 if (ath9k_wiphy_scanning(sc)) {
2717 printk(KERN_DEBUG "ath9k: Two wiphys trying to scan at the " 2745 printk(KERN_DEBUG "ath9k: Two wiphys trying to scan at the "
2718 "same time\n"); 2746 "same time\n");
@@ -2720,6 +2748,7 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2720 * Do not allow the concurrent scanning state for now. This 2748 * Do not allow the concurrent scanning state for now. This
2721 * could be improved with scanning control moved into ath9k. 2749 * could be improved with scanning control moved into ath9k.
2722 */ 2750 */
2751 mutex_unlock(&sc->mutex);
2723 return; 2752 return;
2724 } 2753 }
2725 2754
@@ -2729,6 +2758,7 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2729 spin_lock_bh(&sc->ani_lock); 2758 spin_lock_bh(&sc->ani_lock);
2730 sc->sc_flags |= SC_OP_SCANNING; 2759 sc->sc_flags |= SC_OP_SCANNING;
2731 spin_unlock_bh(&sc->ani_lock); 2760 spin_unlock_bh(&sc->ani_lock);
2761 mutex_unlock(&sc->mutex);
2732} 2762}
2733 2763
2734static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) 2764static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
@@ -2736,11 +2766,13 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2736 struct ath_wiphy *aphy = hw->priv; 2766 struct ath_wiphy *aphy = hw->priv;
2737 struct ath_softc *sc = aphy->sc; 2767 struct ath_softc *sc = aphy->sc;
2738 2768
2769 mutex_lock(&sc->mutex);
2739 spin_lock_bh(&sc->ani_lock); 2770 spin_lock_bh(&sc->ani_lock);
2740 aphy->state = ATH_WIPHY_ACTIVE; 2771 aphy->state = ATH_WIPHY_ACTIVE;
2741 sc->sc_flags &= ~SC_OP_SCANNING; 2772 sc->sc_flags &= ~SC_OP_SCANNING;
2742 sc->sc_flags |= SC_OP_FULL_RESET; 2773 sc->sc_flags |= SC_OP_FULL_RESET;
2743 spin_unlock_bh(&sc->ani_lock); 2774 spin_unlock_bh(&sc->ani_lock);
2775 mutex_unlock(&sc->mutex);
2744} 2776}
2745 2777
2746struct ieee80211_ops ath9k_ops = { 2778struct ieee80211_ops ath9k_ops = {
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 7b62c220d5fd..52e62daad3ce 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -423,11 +423,12 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
423 if (sc->rx.rxfilter & FIF_PSPOLL) 423 if (sc->rx.rxfilter & FIF_PSPOLL)
424 rfilt |= ATH9K_RX_FILTER_PSPOLL; 424 rfilt |= ATH9K_RX_FILTER_PSPOLL;
425 425
426 if (sc->sec_wiphy) { 426 if (sc->sec_wiphy || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
427 /* TODO: only needed if more than one BSSID is in use in 427 /* TODO: only needed if more than one BSSID is in use in
428 * station/adhoc mode */ 428 * station/adhoc mode */
429 /* TODO: for older chips, may need to add ATH9K_RX_FILTER_PROM 429 /* The following may also be needed for other older chips */
430 */ 430 if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160)
431 rfilt |= ATH9K_RX_FILTER_PROM;
431 rfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL; 432 rfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL;
432 } 433 }
433 434
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index c9e1ac92d0e9..3ddb243f0000 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -234,7 +234,15 @@
234#define AR_IMR_S5 0x00b8 234#define AR_IMR_S5 0x00b8
235#define AR_IMR_S5_TIM_TIMER 0x00000010 235#define AR_IMR_S5_TIM_TIMER 0x00000010
236#define AR_IMR_S5_DTIM_TIMER 0x00000020 236#define AR_IMR_S5_DTIM_TIMER 0x00000020
237 237#define AR_ISR_S5_GENTIMER_TRIG 0x0000FF80
238#define AR_ISR_S5_GENTIMER_TRIG_S 0
239#define AR_ISR_S5_GENTIMER_THRESH 0xFF800000
240#define AR_ISR_S5_GENTIMER_THRESH_S 16
241#define AR_ISR_S5_S 0x00d8
242#define AR_IMR_S5_GENTIMER_TRIG 0x0000FF80
243#define AR_IMR_S5_GENTIMER_TRIG_S 0
244#define AR_IMR_S5_GENTIMER_THRESH 0xFF800000
245#define AR_IMR_S5_GENTIMER_THRESH_S 16
238 246
239#define AR_IMR 0x00a0 247#define AR_IMR 0x00a0
240#define AR_IMR_RXOK 0x00000001 248#define AR_IMR_RXOK 0x00000001
@@ -962,6 +970,8 @@ enum {
962#define AR_GPIO_INPUT_EN_VAL_RFSILENT_DEF_S 7 970#define AR_GPIO_INPUT_EN_VAL_RFSILENT_DEF_S 7
963#define AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB 0x00001000 971#define AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB 0x00001000
964#define AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB_S 12 972#define AR_GPIO_INPUT_EN_VAL_BT_ACTIVE_BB_S 12
973#define AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB 0x00001000
974#define AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB_S 1
965#define AR_GPIO_INPUT_EN_VAL_RFSILENT_BB 0x00008000 975#define AR_GPIO_INPUT_EN_VAL_RFSILENT_BB 0x00008000
966#define AR_GPIO_INPUT_EN_VAL_RFSILENT_BB_S 15 976#define AR_GPIO_INPUT_EN_VAL_RFSILENT_BB_S 15
967#define AR_GPIO_RTC_RESET_OVERRIDE_ENABLE 0x00010000 977#define AR_GPIO_RTC_RESET_OVERRIDE_ENABLE 0x00010000
@@ -970,6 +980,8 @@ enum {
970#define AR_GPIO_INPUT_MUX1 0x4058 980#define AR_GPIO_INPUT_MUX1 0x4058
971#define AR_GPIO_INPUT_MUX1_BT_ACTIVE 0x000f0000 981#define AR_GPIO_INPUT_MUX1_BT_ACTIVE 0x000f0000
972#define AR_GPIO_INPUT_MUX1_BT_ACTIVE_S 16 982#define AR_GPIO_INPUT_MUX1_BT_ACTIVE_S 16
983#define AR_GPIO_INPUT_MUX1_BT_PRIORITY 0x00000f00
984#define AR_GPIO_INPUT_MUX1_BT_PRIORITY_S 8
973 985
974#define AR_GPIO_INPUT_MUX2 0x405c 986#define AR_GPIO_INPUT_MUX2 0x405c
975#define AR_GPIO_INPUT_MUX2_CLK25 0x0000000f 987#define AR_GPIO_INPUT_MUX2_CLK25 0x0000000f
@@ -995,6 +1007,8 @@ enum {
995 1007
996#define AR_OBS 0x4080 1008#define AR_OBS 0x4080
997 1009
1010#define AR_GPIO_PDPU 0x4088
1011
998#define AR_PCIE_MSI 0x4094 1012#define AR_PCIE_MSI 0x4094
999#define AR_PCIE_MSI_ENABLE 0x00000001 1013#define AR_PCIE_MSI_ENABLE 0x00000001
1000 1014
@@ -1428,6 +1442,7 @@ enum {
1428#define AR_QUIET1_NEXT_QUIET_M 0x0000ffff 1442#define AR_QUIET1_NEXT_QUIET_M 0x0000ffff
1429#define AR_QUIET1_QUIET_ENABLE 0x00010000 1443#define AR_QUIET1_QUIET_ENABLE 0x00010000
1430#define AR_QUIET1_QUIET_ACK_CTS_ENABLE 0x00020000 1444#define AR_QUIET1_QUIET_ACK_CTS_ENABLE 0x00020000
1445#define AR_QUIET1_QUIET_ACK_CTS_ENABLE_S 17
1431#define AR_QUIET2 0x8100 1446#define AR_QUIET2 0x8100
1432#define AR_QUIET2_QUIET_PERIOD_S 0 1447#define AR_QUIET2_QUIET_PERIOD_S 0
1433#define AR_QUIET2_QUIET_PERIOD_M 0x0000ffff 1448#define AR_QUIET2_QUIET_PERIOD_M 0x0000ffff
@@ -1473,6 +1488,8 @@ enum {
1473#define AR_PCU_CLEAR_VMF 0x01000000 1488#define AR_PCU_CLEAR_VMF 0x01000000
1474#define AR_PCU_CLEAR_BA_VALID 0x04000000 1489#define AR_PCU_CLEAR_BA_VALID 0x04000000
1475 1490
1491#define AR_PCU_BT_ANT_PREVENT_RX 0x00100000
1492#define AR_PCU_BT_ANT_PREVENT_RX_S 20
1476 1493
1477#define AR_FILT_OFDM 0x8124 1494#define AR_FILT_OFDM 0x8124
1478#define AR_FILT_OFDM_COUNT 0x00FFFFFF 1495#define AR_FILT_OFDM_COUNT 0x00FFFFFF
@@ -1500,6 +1517,46 @@ enum {
1500#define AR_PHY_ERR_3_COUNT 0x00FFFFFF 1517#define AR_PHY_ERR_3_COUNT 0x00FFFFFF
1501#define AR_PHY_ERR_MASK_3 0x816c 1518#define AR_PHY_ERR_MASK_3 0x816c
1502 1519
1520#define AR_BT_COEX_MODE 0x8170
1521#define AR_BT_TIME_EXTEND 0x000000ff
1522#define AR_BT_TIME_EXTEND_S 0
1523#define AR_BT_TXSTATE_EXTEND 0x00000100
1524#define AR_BT_TXSTATE_EXTEND_S 8
1525#define AR_BT_TX_FRAME_EXTEND 0x00000200
1526#define AR_BT_TX_FRAME_EXTEND_S 9
1527#define AR_BT_MODE 0x00000c00
1528#define AR_BT_MODE_S 10
1529#define AR_BT_QUIET 0x00001000
1530#define AR_BT_QUIET_S 12
1531#define AR_BT_QCU_THRESH 0x0001e000
1532#define AR_BT_QCU_THRESH_S 13
1533#define AR_BT_RX_CLEAR_POLARITY 0x00020000
1534#define AR_BT_RX_CLEAR_POLARITY_S 17
1535#define AR_BT_PRIORITY_TIME 0x00fc0000
1536#define AR_BT_PRIORITY_TIME_S 18
1537#define AR_BT_FIRST_SLOT_TIME 0xff000000
1538#define AR_BT_FIRST_SLOT_TIME_S 24
1539
1540#define AR_BT_COEX_WEIGHT 0x8174
1541#define AR_BT_COEX_WGHT 0xff55
1542#define AR_STOMP_ALL_WLAN_WGHT 0xffcc
1543#define AR_STOMP_LOW_WLAN_WGHT 0xaaa8
1544#define AR_STOMP_NONE_WLAN_WGHT 0xaa00
1545#define AR_BTCOEX_BT_WGHT 0x0000ffff
1546#define AR_BTCOEX_BT_WGHT_S 0
1547#define AR_BTCOEX_WL_WGHT 0xffff0000
1548#define AR_BTCOEX_WL_WGHT_S 16
1549
1550#define AR_BT_COEX_MODE2 0x817c
1551#define AR_BT_BCN_MISS_THRESH 0x000000ff
1552#define AR_BT_BCN_MISS_THRESH_S 0
1553#define AR_BT_BCN_MISS_CNT 0x0000ff00
1554#define AR_BT_BCN_MISS_CNT_S 8
1555#define AR_BT_HOLD_RX_CLEAR 0x00010000
1556#define AR_BT_HOLD_RX_CLEAR_S 16
1557#define AR_BT_DISABLE_BT_ANT 0x00100000
1558#define AR_BT_DISABLE_BT_ANT_S 20
1559
1503#define AR_TXSIFS 0x81d0 1560#define AR_TXSIFS 0x81d0
1504#define AR_TXSIFS_TIME 0x000000FF 1561#define AR_TXSIFS_TIME 0x000000FF
1505#define AR_TXSIFS_TX_LATENCY 0x00000F00 1562#define AR_TXSIFS_TX_LATENCY 0x00000F00
@@ -1516,7 +1573,10 @@ enum {
1516#define AR_TXOP_8_11 0x81f8 1573#define AR_TXOP_8_11 0x81f8
1517#define AR_TXOP_12_15 0x81fc 1574#define AR_TXOP_12_15 0x81fc
1518 1575
1519 1576#define AR_NEXT_NDP2_TIMER 0x8180
1577#define AR_FIRST_NDP_TIMER 7
1578#define AR_NDP2_PERIOD 0x81a0
1579#define AR_NDP2_TIMER_MODE 0x81c0
1520#define AR_NEXT_TBTT_TIMER 0x8200 1580#define AR_NEXT_TBTT_TIMER 0x8200
1521#define AR_NEXT_DMA_BEACON_ALERT 0x8204 1581#define AR_NEXT_DMA_BEACON_ALERT 0x8204
1522#define AR_NEXT_SWBA 0x8208 1582#define AR_NEXT_SWBA 0x8208
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 87762da0383b..42551a48c8ac 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -493,7 +493,12 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
493 if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) 493 if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy)
494 return 0; 494 return 0;
495 495
496 aggr_limit = min(max_4ms_framelen, (u32)ATH_AMPDU_LIMIT_MAX); 496 if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED)
497 aggr_limit = min((max_4ms_framelen * 3) / 8,
498 (u32)ATH_AMPDU_LIMIT_MAX);
499 else
500 aggr_limit = min(max_4ms_framelen,
501 (u32)ATH_AMPDU_LIMIT_MAX);
497 502
498 /* 503 /*
499 * h/w can accept aggregates upto 16 bit lengths (65535). 504 * h/w can accept aggregates upto 16 bit lengths (65535).
@@ -872,7 +877,7 @@ struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype)
872 return &sc->tx.txq[qnum]; 877 return &sc->tx.txq[qnum];
873} 878}
874 879
875static int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype) 880int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype)
876{ 881{
877 int qnum; 882 int qnum;
878 883
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index 237b1aadf9b6..2af3b3522322 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -82,15 +82,13 @@ config B43_NPHY
82config B43_PHY_LP 82config B43_PHY_LP
83 bool "Support for low-power (LP-PHY) devices (EXPERIMENTAL)" 83 bool "Support for low-power (LP-PHY) devices (EXPERIMENTAL)"
84 depends on B43 && EXPERIMENTAL 84 depends on B43 && EXPERIMENTAL
85 default y
85 ---help--- 86 ---help---
86 Support for the LP-PHY. 87 Support for the LP-PHY.
87 The LP-PHY is a low-power PHY built into some notebooks 88 The LP-PHY is a low-power PHY built into some notebooks
88 and embedded devices. It supports 802.11a/g 89 and embedded devices. It supports 802.11a/g
89 (802.11a support is optional, and currently disabled). 90 (802.11a support is optional, and currently disabled).
90 91
91 This is heavily experimental, and probably will not work for you.
92 Say N unless you want to help debug the driver.
93
94# This config option automatically enables b43 LEDS support, 92# This config option automatically enables b43 LEDS support,
95# if it's possible. 93# if it's possible.
96config B43_LEDS 94config B43_LEDS
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index f5bdf1cae1d1..0f168443ad49 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1456,7 +1456,8 @@ static u16 b43_antenna_to_phyctl(int antenna)
1456 return B43_TXH_PHY_ANT2; 1456 return B43_TXH_PHY_ANT2;
1457 case B43_ANTENNA3: 1457 case B43_ANTENNA3:
1458 return B43_TXH_PHY_ANT3; 1458 return B43_TXH_PHY_ANT3;
1459 case B43_ANTENNA_AUTO: 1459 case B43_ANTENNA_AUTO0:
1460 case B43_ANTENNA_AUTO1:
1460 return B43_TXH_PHY_ANT01AUTO; 1461 return B43_TXH_PHY_ANT01AUTO;
1461 } 1462 }
1462 B43_WARN_ON(1); 1463 B43_WARN_ON(1);
diff --git a/drivers/net/wireless/b43/phy_a.c b/drivers/net/wireless/b43/phy_a.c
index 816e028a2620..809ec97031cb 100644
--- a/drivers/net/wireless/b43/phy_a.c
+++ b/drivers/net/wireless/b43/phy_a.c
@@ -531,7 +531,7 @@ static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
531 531
532 tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); 532 tmp = b43_phy_read(dev, B43_PHY_BBANDCFG);
533 tmp &= ~B43_PHY_BBANDCFG_RXANT; 533 tmp &= ~B43_PHY_BBANDCFG_RXANT;
534 tmp |= (autodiv ? B43_ANTENNA_AUTO0 : antenna) 534 tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna)
535 << B43_PHY_BBANDCFG_RXANT_SHIFT; 535 << B43_PHY_BBANDCFG_RXANT_SHIFT;
536 b43_phy_write(dev, B43_PHY_BBANDCFG, tmp); 536 b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
537 537
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 51686ec96984..6e704becda6f 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -249,20 +249,35 @@ void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
249 249
250void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask) 250void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask)
251{ 251{
252 b43_phy_write(dev, offset, 252 if (dev->phy.ops->phy_maskset) {
253 b43_phy_read(dev, offset) & mask); 253 assert_mac_suspended(dev);
254 dev->phy.ops->phy_maskset(dev, offset, mask, 0);
255 } else {
256 b43_phy_write(dev, offset,
257 b43_phy_read(dev, offset) & mask);
258 }
254} 259}
255 260
256void b43_phy_set(struct b43_wldev *dev, u16 offset, u16 set) 261void b43_phy_set(struct b43_wldev *dev, u16 offset, u16 set)
257{ 262{
258 b43_phy_write(dev, offset, 263 if (dev->phy.ops->phy_maskset) {
259 b43_phy_read(dev, offset) | set); 264 assert_mac_suspended(dev);
265 dev->phy.ops->phy_maskset(dev, offset, 0xFFFF, set);
266 } else {
267 b43_phy_write(dev, offset,
268 b43_phy_read(dev, offset) | set);
269 }
260} 270}
261 271
262void b43_phy_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set) 272void b43_phy_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set)
263{ 273{
264 b43_phy_write(dev, offset, 274 if (dev->phy.ops->phy_maskset) {
265 (b43_phy_read(dev, offset) & mask) | set); 275 assert_mac_suspended(dev);
276 dev->phy.ops->phy_maskset(dev, offset, mask, set);
277 } else {
278 b43_phy_write(dev, offset,
279 (b43_phy_read(dev, offset) & mask) | set);
280 }
266} 281}
267 282
268int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel) 283int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel)
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 9f9f23cab72a..28e384633c34 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -49,11 +49,11 @@ enum b43_interference_mitigation {
49 49
50/* Antenna identifiers */ 50/* Antenna identifiers */
51enum { 51enum {
52 B43_ANTENNA0, /* Antenna 0 */ 52 B43_ANTENNA0 = 0, /* Antenna 0 */
53 B43_ANTENNA1, /* Antenna 0 */ 53 B43_ANTENNA1 = 1, /* Antenna 1 */
54 B43_ANTENNA_AUTO1, /* Automatic, starting with antenna 1 */ 54 B43_ANTENNA_AUTO0 = 2, /* Automatic, starting with antenna 0 */
55 B43_ANTENNA_AUTO0, /* Automatic, starting with antenna 0 */ 55 B43_ANTENNA_AUTO1 = 3, /* Automatic, starting with antenna 1 */
56 B43_ANTENNA2, 56 B43_ANTENNA2 = 4,
57 B43_ANTENNA3 = 8, 57 B43_ANTENNA3 = 8,
58 58
59 B43_ANTENNA_AUTO = B43_ANTENNA_AUTO0, 59 B43_ANTENNA_AUTO = B43_ANTENNA_AUTO0,
@@ -95,6 +95,8 @@ enum b43_txpwr_result {
95 * Must not be NULL. 95 * Must not be NULL.
96 * @phy_write: Write to a PHY register. 96 * @phy_write: Write to a PHY register.
97 * Must not be NULL. 97 * Must not be NULL.
98 * @phy_maskset: Maskset a PHY register, taking shortcuts.
99 * If it is NULL, a generic algorithm is used.
98 * @radio_read: Read from a Radio register. 100 * @radio_read: Read from a Radio register.
99 * Must not be NULL. 101 * Must not be NULL.
100 * @radio_write: Write to a Radio register. 102 * @radio_write: Write to a Radio register.
@@ -154,6 +156,7 @@ struct b43_phy_operations {
154 /* Register access */ 156 /* Register access */
155 u16 (*phy_read)(struct b43_wldev *dev, u16 reg); 157 u16 (*phy_read)(struct b43_wldev *dev, u16 reg);
156 void (*phy_write)(struct b43_wldev *dev, u16 reg, u16 value); 158 void (*phy_write)(struct b43_wldev *dev, u16 reg, u16 value);
159 void (*phy_maskset)(struct b43_wldev *dev, u16 reg, u16 mask, u16 set);
157 u16 (*radio_read)(struct b43_wldev *dev, u16 reg); 160 u16 (*radio_read)(struct b43_wldev *dev, u16 reg);
158 void (*radio_write)(struct b43_wldev *dev, u16 reg, u16 value); 161 void (*radio_write)(struct b43_wldev *dev, u16 reg, u16 value);
159 162
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c
index e47131216a67..bdff9afe3f81 100644
--- a/drivers/net/wireless/b43/phy_g.c
+++ b/drivers/net/wireless/b43/phy_g.c
@@ -2664,7 +2664,7 @@ static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
2664 2664
2665 tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); 2665 tmp = b43_phy_read(dev, B43_PHY_BBANDCFG);
2666 tmp &= ~B43_PHY_BBANDCFG_RXANT; 2666 tmp &= ~B43_PHY_BBANDCFG_RXANT;
2667 tmp |= (autodiv ? B43_ANTENNA_AUTO0 : antenna) 2667 tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna)
2668 << B43_PHY_BBANDCFG_RXANT_SHIFT; 2668 << B43_PHY_BBANDCFG_RXANT_SHIFT;
2669 b43_phy_write(dev, B43_PHY_BBANDCFG, tmp); 2669 b43_phy_write(dev, B43_PHY_BBANDCFG, tmp);
2670 2670
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index 2d3a5d812c42..1ab00b034cbd 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -182,8 +182,8 @@ static void lpphy_adjust_gain_table(struct b43_wldev *dev, u32 freq)
182 temp[1] = temp[0] + 0x1000; 182 temp[1] = temp[0] + 0x1000;
183 temp[2] = temp[0] + 0x2000; 183 temp[2] = temp[0] + 0x2000;
184 184
185 b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0), 3, temp);
186 b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0), 3, temp); 185 b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0), 3, temp);
186 b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0), 3, temp);
187} 187}
188 188
189static void lpphy_table_init(struct b43_wldev *dev) 189static void lpphy_table_init(struct b43_wldev *dev)
@@ -223,8 +223,8 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev)
223 b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0xFF00, 0x0006); 223 b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0xFF00, 0x0006);
224 b43_phy_mask(dev, B43_LPPHY_RX_RADIO_CTL, 0xFFFE); 224 b43_phy_mask(dev, B43_LPPHY_RX_RADIO_CTL, 0xFFFE);
225 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFFE0, 0x0005); 225 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFFE0, 0x0005);
226 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFC10, 0x0180); 226 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFC1F, 0x0180);
227 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0x83FF, 0x3800); 227 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0x83FF, 0x3C00);
228 b43_phy_maskset(dev, B43_LPPHY_GAINDIRECTMISMATCH, 0xFFF0, 0x0005); 228 b43_phy_maskset(dev, B43_LPPHY_GAINDIRECTMISMATCH, 0xFFF0, 0x0005);
229 b43_phy_maskset(dev, B43_LPPHY_GAIN_MISMATCH_LIMIT, 0xFFC0, 0x001A); 229 b43_phy_maskset(dev, B43_LPPHY_GAIN_MISMATCH_LIMIT, 0xFFC0, 0x001A);
230 b43_phy_maskset(dev, B43_LPPHY_CRS_ED_THRESH, 0xFF00, 0x00B3); 230 b43_phy_maskset(dev, B43_LPPHY_CRS_ED_THRESH, 0xFF00, 0x00B3);
@@ -234,19 +234,15 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev)
234 if ((bus->sprom.boardflags_lo & B43_BFL_FEM) && 234 if ((bus->sprom.boardflags_lo & B43_BFL_FEM) &&
235 ((b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) || 235 ((b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) ||
236 (bus->sprom.boardflags_hi & B43_BFH_PAREF))) { 236 (bus->sprom.boardflags_hi & B43_BFH_PAREF))) {
237 /* TODO: 237 ssb_pmu_set_ldo_voltage(&bus->chipco, LDO_PAREF, 0x28);
238 * Set the LDO voltage to 0x0028 - FIXME: What is this? 238 ssb_pmu_set_ldo_paref(&bus->chipco, true);
239 * Call sb_pmu_set_ldo_voltage with 4 and the LDO voltage
240 * as arguments
241 * Call sb_pmu_paref_ldo_enable with argument TRUE
242 */
243 if (dev->phy.rev == 0) { 239 if (dev->phy.rev == 0) {
244 b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT, 240 b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT,
245 0xFFCF, 0x0010); 241 0xFFCF, 0x0010);
246 } 242 }
247 b43_lptab_write(dev, B43_LPTAB16(11, 7), 60); 243 b43_lptab_write(dev, B43_LPTAB16(11, 7), 60);
248 } else { 244 } else {
249 //TODO: Call ssb_pmu_paref_ldo_enable with argument FALSE 245 ssb_pmu_set_ldo_paref(&bus->chipco, false);
250 b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT, 246 b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT,
251 0xFFCF, 0x0020); 247 0xFFCF, 0x0020);
252 b43_lptab_write(dev, B43_LPTAB16(11, 7), 100); 248 b43_lptab_write(dev, B43_LPTAB16(11, 7), 100);
@@ -340,11 +336,11 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev)
340 if (dev->phy.rev == 1) { 336 if (dev->phy.rev == 1) {
341 tmp = b43_phy_read(dev, B43_LPPHY_CLIPCTRTHRESH); 337 tmp = b43_phy_read(dev, B43_LPPHY_CLIPCTRTHRESH);
342 tmp2 = (tmp & 0x03E0) >> 5; 338 tmp2 = (tmp & 0x03E0) >> 5;
343 tmp2 |= tmp << 5; 339 tmp2 |= tmp2 << 5;
344 b43_phy_write(dev, B43_LPPHY_4C3, tmp2); 340 b43_phy_write(dev, B43_LPPHY_4C3, tmp2);
345 tmp = b43_phy_read(dev, B43_LPPHY_OFDMSYNCTHRESH0); 341 tmp = b43_phy_read(dev, B43_LPPHY_GAINDIRECTMISMATCH);
346 tmp2 = (tmp & 0x1F00) >> 8; 342 tmp2 = (tmp & 0x1F00) >> 8;
347 tmp2 |= tmp << 5; 343 tmp2 |= tmp2 << 5;
348 b43_phy_write(dev, B43_LPPHY_4C4, tmp2); 344 b43_phy_write(dev, B43_LPPHY_4C4, tmp2);
349 tmp = b43_phy_read(dev, B43_LPPHY_VERYLOWGAINDB); 345 tmp = b43_phy_read(dev, B43_LPPHY_VERYLOWGAINDB);
350 tmp2 = tmp & 0x00FF; 346 tmp2 = tmp & 0x00FF;
@@ -705,7 +701,7 @@ static void lpphy_set_rc_cap(struct b43_wldev *dev)
705 u8 rc_cap = (lpphy->rc_cap & 0x1F) >> 1; 701 u8 rc_cap = (lpphy->rc_cap & 0x1F) >> 1;
706 702
707 if (dev->phy.rev == 1) //FIXME check channel 14! 703 if (dev->phy.rev == 1) //FIXME check channel 14!
708 rc_cap = max_t(u8, rc_cap + 5, 15); 704 rc_cap = min_t(u8, rc_cap + 5, 15);
709 705
710 b43_radio_write(dev, B2062_N_RXBB_CALIB2, 706 b43_radio_write(dev, B2062_N_RXBB_CALIB2,
711 max_t(u8, lpphy->rc_cap - 4, 0x80)); 707 max_t(u8, lpphy->rc_cap - 4, 0x80));
@@ -761,7 +757,7 @@ static void lpphy_disable_crs(struct b43_wldev *dev, bool user)
761 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3); 757 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3);
762 b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFB); 758 b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFB);
763 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x4); 759 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x4);
764 b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_0, 0xFFF7); 760 b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFF7);
765 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x8); 761 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x8);
766 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x10); 762 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x10);
767 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x10); 763 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x10);
@@ -956,7 +952,7 @@ static void lpphy_run_ddfs(struct b43_wldev *dev, int i_on, int q_on,
956 b43_phy_maskset(dev, B43_LPPHY_AFE_DDFS, 0xFF9F, scale_idx << 5); 952 b43_phy_maskset(dev, B43_LPPHY_AFE_DDFS, 0xFF9F, scale_idx << 5);
957 b43_phy_mask(dev, B43_LPPHY_AFE_DDFS, 0xFFFB); 953 b43_phy_mask(dev, B43_LPPHY_AFE_DDFS, 0xFFFB);
958 b43_phy_set(dev, B43_LPPHY_AFE_DDFS, 0x2); 954 b43_phy_set(dev, B43_LPPHY_AFE_DDFS, 0x2);
959 b43_phy_set(dev, B43_LPPHY_AFE_DDFS, 0x20); 955 b43_phy_set(dev, B43_LPPHY_LP_PHY_CTL, 0x20);
960} 956}
961 957
962static bool lpphy_rx_iq_est(struct b43_wldev *dev, u16 samples, u8 time, 958static bool lpphy_rx_iq_est(struct b43_wldev *dev, u16 samples, u8 time,
@@ -968,7 +964,7 @@ static bool lpphy_rx_iq_est(struct b43_wldev *dev, u16 samples, u8 time,
968 b43_phy_write(dev, B43_LPPHY_IQ_NUM_SMPLS_ADDR, samples); 964 b43_phy_write(dev, B43_LPPHY_IQ_NUM_SMPLS_ADDR, samples);
969 b43_phy_maskset(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFF00, time); 965 b43_phy_maskset(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFF00, time);
970 b43_phy_mask(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFEFF); 966 b43_phy_mask(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFEFF);
971 b43_phy_set(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFDFF); 967 b43_phy_set(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0x200);
972 968
973 for (i = 0; i < 500; i++) { 969 for (i = 0; i < 500; i++) {
974 if (!(b43_phy_read(dev, 970 if (!(b43_phy_read(dev,
@@ -1008,6 +1004,7 @@ static int lpphy_loopback(struct b43_wldev *dev)
1008 1004
1009 b43_phy_maskset(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFC, 0x3); 1005 b43_phy_maskset(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFC, 0x3);
1010 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3); 1006 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3);
1007 b43_phy_set(dev, B43_LPPHY_AFE_CTL_OVR, 1);
1011 b43_phy_mask(dev, B43_LPPHY_AFE_CTL_OVRVAL, 0xFFFE); 1008 b43_phy_mask(dev, B43_LPPHY_AFE_CTL_OVRVAL, 0xFFFE);
1012 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x800); 1009 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x800);
1013 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x800); 1010 b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x800);
@@ -1031,9 +1028,10 @@ static int lpphy_loopback(struct b43_wldev *dev)
1031 return index; 1028 return index;
1032} 1029}
1033 1030
1031/* Fixed-point division algorithm using only integer math. */
1034static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) 1032static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision)
1035{ 1033{
1036 u32 quotient, remainder, rbit, roundup, tmp; 1034 u32 quotient, remainder;
1037 1035
1038 if (divisor == 0) 1036 if (divisor == 0)
1039 return 0; 1037 return 0;
@@ -1041,20 +1039,16 @@ static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision)
1041 quotient = dividend / divisor; 1039 quotient = dividend / divisor;
1042 remainder = dividend % divisor; 1040 remainder = dividend % divisor;
1043 1041
1044 rbit = divisor & 0x1; 1042 while (precision > 0) {
1045 roundup = (divisor >> 1) + rbit;
1046
1047 while (precision != 0) {
1048 tmp = remainder - roundup;
1049 quotient <<= 1; 1043 quotient <<= 1;
1050 if (remainder >= roundup) 1044 if (remainder << 1 >= divisor) {
1051 remainder = (tmp << 1) + rbit; 1045 quotient++;
1052 else 1046 remainder = (remainder << 1) - divisor;
1053 remainder <<= 1; 1047 }
1054 precision--; 1048 precision--;
1055 } 1049 }
1056 1050
1057 if (remainder >= roundup) 1051 if (remainder << 1 >= divisor)
1058 quotient++; 1052 quotient++;
1059 1053
1060 return quotient; 1054 return quotient;
@@ -1137,9 +1131,9 @@ static void lpphy_set_tx_power_control(struct b43_wldev *dev,
1137 } 1131 }
1138 if (dev->phy.rev >= 2) { 1132 if (dev->phy.rev >= 2) {
1139 if (mode == B43_LPPHY_TXPCTL_HW) 1133 if (mode == B43_LPPHY_TXPCTL_HW)
1140 b43_phy_maskset(dev, B43_PHY_OFDM(0xD0), 0xFD, 0x2); 1134 b43_phy_set(dev, B43_PHY_OFDM(0xD0), 0x2);
1141 else 1135 else
1142 b43_phy_maskset(dev, B43_PHY_OFDM(0xD0), 0xFD, 0); 1136 b43_phy_mask(dev, B43_PHY_OFDM(0xD0), 0xFFFD);
1143 } 1137 }
1144 lpphy_write_tx_pctl_mode_to_hardware(dev); 1138 lpphy_write_tx_pctl_mode_to_hardware(dev);
1145} 1139}
@@ -1171,7 +1165,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev *dev)
1171 err = b43_lpphy_op_switch_channel(dev, 7); 1165 err = b43_lpphy_op_switch_channel(dev, 7);
1172 if (err) { 1166 if (err) {
1173 b43dbg(dev->wl, 1167 b43dbg(dev->wl,
1174 "RC calib: Failed to switch to channel 7, error = %d", 1168 "RC calib: Failed to switch to channel 7, error = %d\n",
1175 err); 1169 err);
1176 } 1170 }
1177 old_txg_ovr = !!(b43_phy_read(dev, B43_LPPHY_AFE_CTL_OVR) & 0x40); 1171 old_txg_ovr = !!(b43_phy_read(dev, B43_LPPHY_AFE_CTL_OVR) & 0x40);
@@ -1213,7 +1207,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev *dev)
1213 mean_sq_pwr = ideal_pwr - normal_pwr; 1207 mean_sq_pwr = ideal_pwr - normal_pwr;
1214 mean_sq_pwr *= mean_sq_pwr; 1208 mean_sq_pwr *= mean_sq_pwr;
1215 inner_sum += mean_sq_pwr; 1209 inner_sum += mean_sq_pwr;
1216 if ((i = 128) || (inner_sum < mean_sq_pwr_min)) { 1210 if ((i == 128) || (inner_sum < mean_sq_pwr_min)) {
1217 lpphy->rc_cap = i; 1211 lpphy->rc_cap = i;
1218 mean_sq_pwr_min = inner_sum; 1212 mean_sq_pwr_min = inner_sum;
1219 } 1213 }
@@ -1506,6 +1500,14 @@ static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
1506 b43_write16(dev, B43_MMIO_PHY_DATA, value); 1500 b43_write16(dev, B43_MMIO_PHY_DATA, value);
1507} 1501}
1508 1502
1503static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
1504 u16 set)
1505{
1506 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
1507 b43_write16(dev, B43_MMIO_PHY_DATA,
1508 (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
1509}
1510
1509static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg) 1511static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg)
1510{ 1512{
1511 /* Register 1 is a 32-bit register. */ 1513 /* Register 1 is a 32-bit register. */
@@ -1922,8 +1924,8 @@ static void lpphy_b2062_reset_pll_bias(struct b43_wldev *dev)
1922 1924
1923static void lpphy_b2062_vco_calib(struct b43_wldev *dev) 1925static void lpphy_b2062_vco_calib(struct b43_wldev *dev)
1924{ 1926{
1925 b43_phy_write(dev, B2062_S_RFPLL_CTL21, 0x42); 1927 b43_radio_write(dev, B2062_S_RFPLL_CTL21, 0x42);
1926 b43_phy_write(dev, B2062_S_RFPLL_CTL21, 0x62); 1928 b43_radio_write(dev, B2062_S_RFPLL_CTL21, 0x62);
1927 udelay(200); 1929 udelay(200);
1928} 1930}
1929 1931
@@ -1982,7 +1984,7 @@ static int lpphy_b2062_tune(struct b43_wldev *dev,
1982 tmp6 = tmp5 / tmp4; 1984 tmp6 = tmp5 / tmp4;
1983 tmp7 = tmp5 % tmp4; 1985 tmp7 = tmp5 % tmp4;
1984 b43_radio_write(dev, B2062_S_RFPLL_CTL29, tmp6 + ((2 * tmp7) / tmp4)); 1986 b43_radio_write(dev, B2062_S_RFPLL_CTL29, tmp6 + ((2 * tmp7) / tmp4));
1985 tmp8 = b43_phy_read(dev, B2062_S_RFPLL_CTL19); 1987 tmp8 = b43_radio_read(dev, B2062_S_RFPLL_CTL19);
1986 tmp9 = ((2 * tmp3 * (tmp8 + 1)) + (3 * tmp1)) / (6 * tmp1); 1988 tmp9 = ((2 * tmp3 * (tmp8 + 1)) + (3 * tmp1)) / (6 * tmp1);
1987 b43_radio_write(dev, B2062_S_RFPLL_CTL23, (tmp9 >> 8) + 16); 1989 b43_radio_write(dev, B2062_S_RFPLL_CTL23, (tmp9 >> 8) + 16);
1988 b43_radio_write(dev, B2062_S_RFPLL_CTL24, tmp9 & 0xFF); 1990 b43_radio_write(dev, B2062_S_RFPLL_CTL24, tmp9 & 0xFF);
@@ -2021,17 +2023,17 @@ static void lpphy_b2063_vco_calib(struct b43_wldev *dev)
2021{ 2023{
2022 u16 tmp; 2024 u16 tmp;
2023 2025
2024 b43_phy_mask(dev, B2063_PLL_SP1, ~0x40); 2026 b43_radio_mask(dev, B2063_PLL_SP1, ~0x40);
2025 tmp = b43_phy_read(dev, B2063_PLL_JTAG_CALNRST) & 0xF8; 2027 tmp = b43_radio_read(dev, B2063_PLL_JTAG_CALNRST) & 0xF8;
2026 b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp); 2028 b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp);
2027 udelay(1); 2029 udelay(1);
2028 b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x4); 2030 b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x4);
2029 udelay(1); 2031 udelay(1);
2030 b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x6); 2032 b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x6);
2031 udelay(1); 2033 udelay(1);
2032 b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x7); 2034 b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x7);
2033 udelay(300); 2035 udelay(300);
2034 b43_phy_set(dev, B2063_PLL_SP1, 0x40); 2036 b43_radio_set(dev, B2063_PLL_SP1, 0x40);
2035} 2037}
2036 2038
2037static int lpphy_b2063_tune(struct b43_wldev *dev, 2039static int lpphy_b2063_tune(struct b43_wldev *dev,
@@ -2126,31 +2128,31 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
2126 scale = 0; 2128 scale = 0;
2127 tmp5 = ((tmp4 + (tmp3 >> 1)) / tmp3) - 8; 2129 tmp5 = ((tmp4 + (tmp3 >> 1)) / tmp3) - 8;
2128 } 2130 }
2129 b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFC0, tmp5); 2131 b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFC0, tmp5);
2130 b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFBF, scale << 6); 2132 b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFBF, scale << 6);
2131 2133
2132 tmp6 = lpphy_qdiv_roundup(100 * val1, val3, 16); 2134 tmp6 = lpphy_qdiv_roundup(100 * val1, val3, 16);
2133 tmp6 *= (tmp5 * 8) * (scale + 1); 2135 tmp6 *= (tmp5 * 8) * (scale + 1);
2134 if (tmp6 > 150) 2136 if (tmp6 > 150)
2135 tmp6 = 0; 2137 tmp6 = 0;
2136 2138
2137 b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFE0, tmp6); 2139 b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFE0, tmp6);
2138 b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFDF, scale << 5); 2140 b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFDF, scale << 5);
2139 2141
2140 b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFFFB, 0x4); 2142 b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFFFB, 0x4);
2141 if (crystal_freq > 26000000) 2143 if (crystal_freq > 26000000)
2142 b43_phy_set(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0x2); 2144 b43_radio_set(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0x2);
2143 else 2145 else
2144 b43_phy_mask(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFD); 2146 b43_radio_mask(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFD);
2145 2147
2146 if (val1 == 45) 2148 if (val1 == 45)
2147 b43_phy_set(dev, B2063_PLL_JTAG_PLL_VCO1, 0x2); 2149 b43_radio_set(dev, B2063_PLL_JTAG_PLL_VCO1, 0x2);
2148 else 2150 else
2149 b43_phy_mask(dev, B2063_PLL_JTAG_PLL_VCO1, 0xFD); 2151 b43_radio_mask(dev, B2063_PLL_JTAG_PLL_VCO1, 0xFD);
2150 2152
2151 b43_phy_set(dev, B2063_PLL_SP2, 0x3); 2153 b43_radio_set(dev, B2063_PLL_SP2, 0x3);
2152 udelay(1); 2154 udelay(1);
2153 b43_phy_mask(dev, B2063_PLL_SP2, 0xFFFC); 2155 b43_radio_mask(dev, B2063_PLL_SP2, 0xFFFC);
2154 lpphy_b2063_vco_calib(dev); 2156 lpphy_b2063_vco_calib(dev);
2155 b43_radio_write(dev, B2063_COMM15, old_comm15); 2157 b43_radio_write(dev, B2063_COMM15, old_comm15);
2156 2158
@@ -2160,10 +2162,9 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
2160static int b43_lpphy_op_switch_channel(struct b43_wldev *dev, 2162static int b43_lpphy_op_switch_channel(struct b43_wldev *dev,
2161 unsigned int new_channel) 2163 unsigned int new_channel)
2162{ 2164{
2165 struct b43_phy_lp *lpphy = dev->phy.lp;
2163 int err; 2166 int err;
2164 2167
2165 b43_write16(dev, B43_MMIO_CHANNEL, new_channel);
2166
2167 if (dev->phy.radio_ver == 0x2063) { 2168 if (dev->phy.radio_ver == 0x2063) {
2168 err = lpphy_b2063_tune(dev, new_channel); 2169 err = lpphy_b2063_tune(dev, new_channel);
2169 if (err) 2170 if (err)
@@ -2176,6 +2177,9 @@ static int b43_lpphy_op_switch_channel(struct b43_wldev *dev,
2176 lpphy_adjust_gain_table(dev, channel2freq_lp(new_channel)); 2177 lpphy_adjust_gain_table(dev, channel2freq_lp(new_channel));
2177 } 2178 }
2178 2179
2180 lpphy->channel = new_channel;
2181 b43_write16(dev, B43_MMIO_CHANNEL, new_channel);
2182
2179 return 0; 2183 return 0;
2180} 2184}
2181 2185
@@ -2187,10 +2191,9 @@ static int b43_lpphy_op_init(struct b43_wldev *dev)
2187 lpphy_baseband_init(dev); 2191 lpphy_baseband_init(dev);
2188 lpphy_radio_init(dev); 2192 lpphy_radio_init(dev);
2189 lpphy_calibrate_rc(dev); 2193 lpphy_calibrate_rc(dev);
2190 err = b43_lpphy_op_switch_channel(dev, 2194 err = b43_lpphy_op_switch_channel(dev, 7);
2191 b43_lpphy_op_get_default_chan(dev));
2192 if (err) { 2195 if (err) {
2193 b43dbg(dev->wl, "Switch to init channel failed, error = %d.\n", 2196 b43dbg(dev->wl, "Switch to channel 7 failed, error = %d.\n",
2194 err); 2197 err);
2195 } 2198 }
2196 lpphy_tx_pctl_init(dev); 2199 lpphy_tx_pctl_init(dev);
@@ -2202,7 +2205,14 @@ static int b43_lpphy_op_init(struct b43_wldev *dev)
2202 2205
2203static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) 2206static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
2204{ 2207{
2205 //TODO 2208 if (dev->phy.rev >= 2)
2209 return; // rev2+ doesn't support antenna diversity
2210
2211 if (B43_WARN_ON(antenna > B43_ANTENNA_AUTO1))
2212 return;
2213
2214 b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFD, antenna & 0x2);
2215 b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFE, antenna & 0x1);
2206} 2216}
2207 2217
2208static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev) 2218static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev)
@@ -2224,6 +2234,7 @@ const struct b43_phy_operations b43_phyops_lp = {
2224 .init = b43_lpphy_op_init, 2234 .init = b43_lpphy_op_init,
2225 .phy_read = b43_lpphy_op_read, 2235 .phy_read = b43_lpphy_op_read,
2226 .phy_write = b43_lpphy_op_write, 2236 .phy_write = b43_lpphy_op_write,
2237 .phy_maskset = b43_lpphy_op_maskset,
2227 .radio_read = b43_lpphy_op_radio_read, 2238 .radio_read = b43_lpphy_op_radio_read,
2228 .radio_write = b43_lpphy_op_radio_write, 2239 .radio_write = b43_lpphy_op_radio_write,
2229 .software_rfkill = b43_lpphy_op_software_rfkill, 2240 .software_rfkill = b43_lpphy_op_software_rfkill,
diff --git a/drivers/net/wireless/b43/phy_lp.h b/drivers/net/wireless/b43/phy_lp.h
index e158d1f66c0e..c3232c17b60a 100644
--- a/drivers/net/wireless/b43/phy_lp.h
+++ b/drivers/net/wireless/b43/phy_lp.h
@@ -888,6 +888,9 @@ struct b43_phy_lp {
888 bool crs_usr_disable, crs_sys_disable; 888 bool crs_usr_disable, crs_sys_disable;
889 889
890 unsigned int pdiv; 890 unsigned int pdiv;
891
892 /* The channel we are tuned to */
893 u8 channel;
891}; 894};
892 895
893enum tssi_mux_mode { 896enum tssi_mux_mode {
diff --git a/drivers/net/wireless/b43/tables_lpphy.c b/drivers/net/wireless/b43/tables_lpphy.c
index 60d472f285af..c784def19b19 100644
--- a/drivers/net/wireless/b43/tables_lpphy.c
+++ b/drivers/net/wireless/b43/tables_lpphy.c
@@ -624,30 +624,35 @@ u32 b43_lptab_read(struct b43_wldev *dev, u32 offset)
624void b43_lptab_read_bulk(struct b43_wldev *dev, u32 offset, 624void b43_lptab_read_bulk(struct b43_wldev *dev, u32 offset,
625 unsigned int nr_elements, void *_data) 625 unsigned int nr_elements, void *_data)
626{ 626{
627 u32 type, value; 627 u32 type;
628 u8 *data = _data; 628 u8 *data = _data;
629 unsigned int i; 629 unsigned int i;
630 630
631 type = offset & B43_LPTAB_TYPEMASK; 631 type = offset & B43_LPTAB_TYPEMASK;
632 offset &= ~B43_LPTAB_TYPEMASK;
633 B43_WARN_ON(offset > 0xFFFF);
634
635 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
636
632 for (i = 0; i < nr_elements; i++) { 637 for (i = 0; i < nr_elements; i++) {
633 value = b43_lptab_read(dev, offset);
634 switch (type) { 638 switch (type) {
635 case B43_LPTAB_8BIT: 639 case B43_LPTAB_8BIT:
636 *data = value; 640 *data = b43_phy_read(dev, B43_LPPHY_TABLEDATALO) & 0xFF;
637 data++; 641 data++;
638 break; 642 break;
639 case B43_LPTAB_16BIT: 643 case B43_LPTAB_16BIT:
640 *((u16 *)data) = value; 644 *((u16 *)data) = b43_phy_read(dev, B43_LPPHY_TABLEDATALO);
641 data += 2; 645 data += 2;
642 break; 646 break;
643 case B43_LPTAB_32BIT: 647 case B43_LPTAB_32BIT:
644 *((u32 *)data) = value; 648 *((u32 *)data) = b43_phy_read(dev, B43_LPPHY_TABLEDATAHI);
649 *((u32 *)data) <<= 16;
650 *((u32 *)data) |= b43_phy_read(dev, B43_LPPHY_TABLEDATALO);
645 data += 4; 651 data += 4;
646 break; 652 break;
647 default: 653 default:
648 B43_WARN_ON(1); 654 B43_WARN_ON(1);
649 } 655 }
650 offset++;
651 } 656 }
652} 657}
653 658
@@ -688,26 +693,34 @@ void b43_lptab_write_bulk(struct b43_wldev *dev, u32 offset,
688 unsigned int i; 693 unsigned int i;
689 694
690 type = offset & B43_LPTAB_TYPEMASK; 695 type = offset & B43_LPTAB_TYPEMASK;
696 offset &= ~B43_LPTAB_TYPEMASK;
697 B43_WARN_ON(offset > 0xFFFF);
698
699 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
700
691 for (i = 0; i < nr_elements; i++) { 701 for (i = 0; i < nr_elements; i++) {
692 switch (type) { 702 switch (type) {
693 case B43_LPTAB_8BIT: 703 case B43_LPTAB_8BIT:
694 value = *data; 704 value = *data;
695 data++; 705 data++;
706 B43_WARN_ON(value & ~0xFF);
707 b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
696 break; 708 break;
697 case B43_LPTAB_16BIT: 709 case B43_LPTAB_16BIT:
698 value = *((u16 *)data); 710 value = *((u16 *)data);
699 data += 2; 711 data += 2;
712 B43_WARN_ON(value & ~0xFFFF);
713 b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
700 break; 714 break;
701 case B43_LPTAB_32BIT: 715 case B43_LPTAB_32BIT:
702 value = *((u32 *)data); 716 value = *((u32 *)data);
703 data += 4; 717 data += 4;
718 b43_phy_write(dev, B43_LPPHY_TABLEDATAHI, value >> 16);
719 b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
704 break; 720 break;
705 default: 721 default:
706 B43_WARN_ON(1); 722 B43_WARN_ON(1);
707 value = 0;
708 } 723 }
709 b43_lptab_write(dev, offset, value);
710 offset++;
711 } 724 }
712} 725}
713 726
@@ -777,7 +790,7 @@ static const u8 lpphy_pll_fraction_table[] = {
777 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 790 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
778}; 791};
779 792
780static const u16 lpphy_iq_local_table[] = { 793static const u16 lpphy_iqlo_cal_table[] = {
781 0x0200, 0x0300, 0x0400, 0x0600, 0x0800, 0x0b00, 0x1000, 0x1001, 0x1002, 794 0x0200, 0x0300, 0x0400, 0x0600, 0x0800, 0x0b00, 0x1000, 0x1001, 0x1002,
782 0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1707, 0x2007, 0x2d07, 0x4007, 795 0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1707, 0x2007, 0x2d07, 0x4007,
783 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 796 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -789,10 +802,17 @@ static const u16 lpphy_iq_local_table[] = {
789 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 802 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
790 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000, 803 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000,
791 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 804 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
792 0x0000, 0x0000, 805 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
793}; 806};
794 807
795static const u16 lpphy_ofdm_cck_gain_table[] = { 808static const u16 lpphy_rev0_ofdm_cck_gain_table[] = {
809 0x0001, 0x0001, 0x0001, 0x0001, 0x1001, 0x2001, 0x3001, 0x4001, 0x5001,
810 0x6001, 0x7001, 0x7011, 0x7021, 0x2035, 0x2045, 0x2055, 0x2065, 0x2075,
811 0x006d, 0x007d, 0x014d, 0x015d, 0x115d, 0x035d, 0x135d, 0x055d, 0x155d,
812 0x0d5d, 0x1d5d, 0x2d5d, 0x555d, 0x655d, 0x755d,
813};
814
815static const u16 lpphy_rev1_ofdm_cck_gain_table[] = {
796 0x5000, 0x6000, 0x7000, 0x0001, 0x1001, 0x2001, 0x3001, 0x4001, 0x5001, 816 0x5000, 0x6000, 0x7000, 0x0001, 0x1001, 0x2001, 0x3001, 0x4001, 0x5001,
797 0x6001, 0x7001, 0x7011, 0x7021, 0x2035, 0x2045, 0x2055, 0x2065, 0x2075, 817 0x6001, 0x7001, 0x7011, 0x7021, 0x2035, 0x2045, 0x2055, 0x2065, 0x2075,
798 0x006d, 0x007d, 0x014d, 0x015d, 0x115d, 0x035d, 0x135d, 0x055d, 0x155d, 818 0x006d, 0x007d, 0x014d, 0x015d, 0x115d, 0x035d, 0x135d, 0x055d, 0x155d,
@@ -2263,11 +2283,18 @@ void lpphy_rev0_1_table_init(struct b43_wldev *dev)
2263 b43_lptab_write_bulk(dev, B43_LPTAB8(6, 0), 2283 b43_lptab_write_bulk(dev, B43_LPTAB8(6, 0),
2264 ARRAY_SIZE(lpphy_pll_fraction_table), lpphy_pll_fraction_table); 2284 ARRAY_SIZE(lpphy_pll_fraction_table), lpphy_pll_fraction_table);
2265 b43_lptab_write_bulk(dev, B43_LPTAB16(0, 0), 2285 b43_lptab_write_bulk(dev, B43_LPTAB16(0, 0),
2266 ARRAY_SIZE(lpphy_iq_local_table), lpphy_iq_local_table); 2286 ARRAY_SIZE(lpphy_iqlo_cal_table), lpphy_iqlo_cal_table);
2267 b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0), 2287 if (dev->phy.rev == 0) {
2268 ARRAY_SIZE(lpphy_ofdm_cck_gain_table), lpphy_ofdm_cck_gain_table); 2288 b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0),
2269 b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0), 2289 ARRAY_SIZE(lpphy_rev0_ofdm_cck_gain_table), lpphy_rev0_ofdm_cck_gain_table);
2270 ARRAY_SIZE(lpphy_ofdm_cck_gain_table), lpphy_ofdm_cck_gain_table); 2290 b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0),
2291 ARRAY_SIZE(lpphy_rev0_ofdm_cck_gain_table), lpphy_rev0_ofdm_cck_gain_table);
2292 } else {
2293 b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0),
2294 ARRAY_SIZE(lpphy_rev1_ofdm_cck_gain_table), lpphy_rev1_ofdm_cck_gain_table);
2295 b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0),
2296 ARRAY_SIZE(lpphy_rev1_ofdm_cck_gain_table), lpphy_rev1_ofdm_cck_gain_table);
2297}
2271 b43_lptab_write_bulk(dev, B43_LPTAB16(15, 0), 2298 b43_lptab_write_bulk(dev, B43_LPTAB16(15, 0),
2272 ARRAY_SIZE(lpphy_gain_delta_table), lpphy_gain_delta_table); 2299 ARRAY_SIZE(lpphy_gain_delta_table), lpphy_gain_delta_table);
2273 b43_lptab_write_bulk(dev, B43_LPTAB32(10, 0), 2300 b43_lptab_write_bulk(dev, B43_LPTAB32(10, 0),
@@ -2281,22 +2308,6 @@ void lpphy_rev2plus_table_init(struct b43_wldev *dev)
2281 2308
2282 B43_WARN_ON(dev->phy.rev < 2); 2309 B43_WARN_ON(dev->phy.rev < 2);
2283 2310
2284 /*
2285 * FIXME This code follows the specs, but it looks wrong:
2286 * In each pass, it writes 4 bytes to an offset in table ID 7,
2287 * then increments the offset by 1 for the next pass. This results
2288 * in the first 3 bytes of each pass except the first one getting
2289 * written to a location that has already been zeroed in the previous
2290 * pass.
2291 * This is what the vendor driver does, but it still looks suspicious.
2292 *
2293 * This should probably suffice:
2294 *
2295 * for (i = 0; i < 704; i+=4)
2296 * b43_lptab_write(dev, B43_LPTAB32(7, i), 0)
2297 *
2298 * This should be tested once the code is functional.
2299 */
2300 for (i = 0; i < 704; i++) 2311 for (i = 0; i < 704; i++)
2301 b43_lptab_write(dev, B43_LPTAB32(7, i), 0); 2312 b43_lptab_write(dev, B43_LPTAB32(7, i), 0);
2302 2313
@@ -2323,7 +2334,7 @@ void lpphy_rev2plus_table_init(struct b43_wldev *dev)
2323 b43_lptab_write_bulk(dev, B43_LPTAB8(6, 0), 2334 b43_lptab_write_bulk(dev, B43_LPTAB8(6, 0),
2324 ARRAY_SIZE(lpphy_pll_fraction_table), lpphy_pll_fraction_table); 2335 ARRAY_SIZE(lpphy_pll_fraction_table), lpphy_pll_fraction_table);
2325 b43_lptab_write_bulk(dev, B43_LPTAB16(0, 0), 2336 b43_lptab_write_bulk(dev, B43_LPTAB16(0, 0),
2326 ARRAY_SIZE(lpphy_iq_local_table), lpphy_iq_local_table); 2337 ARRAY_SIZE(lpphy_iqlo_cal_table), lpphy_iqlo_cal_table);
2327 b43_lptab_write_bulk(dev, B43_LPTAB32(9, 0), 2338 b43_lptab_write_bulk(dev, B43_LPTAB32(9, 0),
2328 ARRAY_SIZE(lpphy_papd_eps_table), lpphy_papd_eps_table); 2339 ARRAY_SIZE(lpphy_papd_eps_table), lpphy_papd_eps_table);
2329 b43_lptab_write_bulk(dev, B43_LPTAB32(10, 0), 2340 b43_lptab_write_bulk(dev, B43_LPTAB32(10, 0),
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index dee50ed0897d..77457386e0aa 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -19,7 +19,7 @@
19 file called LICENSE. 19 file called LICENSE.
20 20
21 Contact Information: 21 Contact Information:
22 James P. Ketrenos <ipw2100-admin@linux.intel.com> 22 Intel Linux Wireless <ilw@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 24
25 Portions of this file are based on the sample_* files provided by Wireless 25 Portions of this file are based on the sample_* files provided by Wireless
@@ -1673,7 +1673,7 @@ static int ipw2100_start_scan(struct ipw2100_priv *priv)
1673 return err; 1673 return err;
1674} 1674}
1675 1675
1676static const struct ieee80211_geo ipw_geos[] = { 1676static const struct libipw_geo ipw_geos[] = {
1677 { /* Restricted */ 1677 { /* Restricted */
1678 "---", 1678 "---",
1679 .bg_channels = 14, 1679 .bg_channels = 14,
@@ -1694,7 +1694,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1694 1694
1695 /* Age scan list entries found before suspend */ 1695 /* Age scan list entries found before suspend */
1696 if (priv->suspend_time) { 1696 if (priv->suspend_time) {
1697 ieee80211_networks_age(priv->ieee, priv->suspend_time); 1697 libipw_networks_age(priv->ieee, priv->suspend_time);
1698 priv->suspend_time = 0; 1698 priv->suspend_time = 0;
1699 } 1699 }
1700 1700
@@ -1752,11 +1752,11 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1752 } 1752 }
1753 1753
1754 /* Initialize the geo */ 1754 /* Initialize the geo */
1755 if (ieee80211_set_geo(priv->ieee, &ipw_geos[0])) { 1755 if (libipw_set_geo(priv->ieee, &ipw_geos[0])) {
1756 printk(KERN_WARNING DRV_NAME "Could not set geo\n"); 1756 printk(KERN_WARNING DRV_NAME "Could not set geo\n");
1757 return 0; 1757 return 0;
1758 } 1758 }
1759 priv->ieee->freq_band = IEEE80211_24GHZ_BAND; 1759 priv->ieee->freq_band = LIBIPW_24GHZ_BAND;
1760 1760
1761 lock = LOCK_NONE; 1761 lock = LOCK_NONE;
1762 if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) { 1762 if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) {
@@ -1817,7 +1817,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1817/* Called by register_netdev() */ 1817/* Called by register_netdev() */
1818static int ipw2100_net_init(struct net_device *dev) 1818static int ipw2100_net_init(struct net_device *dev)
1819{ 1819{
1820 struct ipw2100_priv *priv = ieee80211_priv(dev); 1820 struct ipw2100_priv *priv = libipw_priv(dev);
1821 return ipw2100_up(priv, 1); 1821 return ipw2100_up(priv, 1);
1822} 1822}
1823 1823
@@ -2340,8 +2340,8 @@ static u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 * in_buf,
2340 * 2340 *
2341 * When packet is provided by the firmware, it contains the following: 2341 * When packet is provided by the firmware, it contains the following:
2342 * 2342 *
2343 * . ieee80211_hdr 2343 * . libipw_hdr
2344 * . ieee80211_snap_hdr 2344 * . libipw_snap_hdr
2345 * 2345 *
2346 * The size of the constructed ethernet 2346 * The size of the constructed ethernet
2347 * 2347 *
@@ -2396,7 +2396,7 @@ static void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
2396} 2396}
2397 2397
2398static void isr_rx(struct ipw2100_priv *priv, int i, 2398static void isr_rx(struct ipw2100_priv *priv, int i,
2399 struct ieee80211_rx_stats *stats) 2399 struct libipw_rx_stats *stats)
2400{ 2400{
2401 struct net_device *dev = priv->net_dev; 2401 struct net_device *dev = priv->net_dev;
2402 struct ipw2100_status *status = &priv->status_queue.drv[i]; 2402 struct ipw2100_status *status = &priv->status_queue.drv[i];
@@ -2435,13 +2435,13 @@ static void isr_rx(struct ipw2100_priv *priv, int i,
2435 2435
2436#ifdef IPW2100_RX_DEBUG 2436#ifdef IPW2100_RX_DEBUG
2437 /* Make a copy of the frame so we can dump it to the logs if 2437 /* Make a copy of the frame so we can dump it to the logs if
2438 * ieee80211_rx fails */ 2438 * libipw_rx fails */
2439 skb_copy_from_linear_data(packet->skb, packet_data, 2439 skb_copy_from_linear_data(packet->skb, packet_data,
2440 min_t(u32, status->frame_size, 2440 min_t(u32, status->frame_size,
2441 IPW_RX_NIC_BUFFER_LENGTH)); 2441 IPW_RX_NIC_BUFFER_LENGTH));
2442#endif 2442#endif
2443 2443
2444 if (!ieee80211_rx(priv->ieee, packet->skb, stats)) { 2444 if (!libipw_rx(priv->ieee, packet->skb, stats)) {
2445#ifdef IPW2100_RX_DEBUG 2445#ifdef IPW2100_RX_DEBUG
2446 IPW_DEBUG_DROP("%s: Non consumed packet:\n", 2446 IPW_DEBUG_DROP("%s: Non consumed packet:\n",
2447 dev->name); 2447 dev->name);
@@ -2449,7 +2449,7 @@ static void isr_rx(struct ipw2100_priv *priv, int i,
2449#endif 2449#endif
2450 dev->stats.rx_errors++; 2450 dev->stats.rx_errors++;
2451 2451
2452 /* ieee80211_rx failed, so it didn't free the SKB */ 2452 /* libipw_rx failed, so it didn't free the SKB */
2453 dev_kfree_skb_any(packet->skb); 2453 dev_kfree_skb_any(packet->skb);
2454 packet->skb = NULL; 2454 packet->skb = NULL;
2455 } 2455 }
@@ -2470,7 +2470,7 @@ static void isr_rx(struct ipw2100_priv *priv, int i,
2470#ifdef CONFIG_IPW2100_MONITOR 2470#ifdef CONFIG_IPW2100_MONITOR
2471 2471
2472static void isr_rx_monitor(struct ipw2100_priv *priv, int i, 2472static void isr_rx_monitor(struct ipw2100_priv *priv, int i,
2473 struct ieee80211_rx_stats *stats) 2473 struct libipw_rx_stats *stats)
2474{ 2474{
2475 struct net_device *dev = priv->net_dev; 2475 struct net_device *dev = priv->net_dev;
2476 struct ipw2100_status *status = &priv->status_queue.drv[i]; 2476 struct ipw2100_status *status = &priv->status_queue.drv[i];
@@ -2528,10 +2528,10 @@ static void isr_rx_monitor(struct ipw2100_priv *priv, int i,
2528 2528
2529 skb_put(packet->skb, status->frame_size + sizeof(struct ipw_rt_hdr)); 2529 skb_put(packet->skb, status->frame_size + sizeof(struct ipw_rt_hdr));
2530 2530
2531 if (!ieee80211_rx(priv->ieee, packet->skb, stats)) { 2531 if (!libipw_rx(priv->ieee, packet->skb, stats)) {
2532 dev->stats.rx_errors++; 2532 dev->stats.rx_errors++;
2533 2533
2534 /* ieee80211_rx failed, so it didn't free the SKB */ 2534 /* libipw_rx failed, so it didn't free the SKB */
2535 dev_kfree_skb_any(packet->skb); 2535 dev_kfree_skb_any(packet->skb);
2536 packet->skb = NULL; 2536 packet->skb = NULL;
2537 } 2537 }
@@ -2615,7 +2615,7 @@ static void __ipw2100_rx_process(struct ipw2100_priv *priv)
2615 u16 frame_type; 2615 u16 frame_type;
2616 u32 r, w, i, s; 2616 u32 r, w, i, s;
2617 struct ipw2100_rx *u; 2617 struct ipw2100_rx *u;
2618 struct ieee80211_rx_stats stats = { 2618 struct libipw_rx_stats stats = {
2619 .mac_time = jiffies, 2619 .mac_time = jiffies,
2620 }; 2620 };
2621 2621
@@ -2661,8 +2661,8 @@ static void __ipw2100_rx_process(struct ipw2100_priv *priv)
2661 2661
2662 stats.mask = 0; 2662 stats.mask = 0;
2663 if (stats.rssi != 0) 2663 if (stats.rssi != 0)
2664 stats.mask |= IEEE80211_STATMASK_RSSI; 2664 stats.mask |= LIBIPW_STATMASK_RSSI;
2665 stats.freq = IEEE80211_24GHZ_BAND; 2665 stats.freq = LIBIPW_24GHZ_BAND;
2666 2666
2667 IPW_DEBUG_RX("%s: '%s' frame type received (%d).\n", 2667 IPW_DEBUG_RX("%s: '%s' frame type received (%d).\n",
2668 priv->net_dev->name, frame_types[frame_type], 2668 priv->net_dev->name, frame_types[frame_type],
@@ -2686,11 +2686,11 @@ static void __ipw2100_rx_process(struct ipw2100_priv *priv)
2686 break; 2686 break;
2687 } 2687 }
2688#endif 2688#endif
2689 if (stats.len < sizeof(struct ieee80211_hdr_3addr)) 2689 if (stats.len < sizeof(struct libipw_hdr_3addr))
2690 break; 2690 break;
2691 switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) { 2691 switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) {
2692 case IEEE80211_FTYPE_MGMT: 2692 case IEEE80211_FTYPE_MGMT:
2693 ieee80211_rx_mgt(priv->ieee, 2693 libipw_rx_mgt(priv->ieee,
2694 &u->rx_data.header, &stats); 2694 &u->rx_data.header, &stats);
2695 break; 2695 break;
2696 2696
@@ -2884,7 +2884,7 @@ static int __ipw2100_tx_process(struct ipw2100_priv *priv)
2884 tbd->buf_length, PCI_DMA_TODEVICE); 2884 tbd->buf_length, PCI_DMA_TODEVICE);
2885 } 2885 }
2886 2886
2887 ieee80211_txb_free(packet->info.d_struct.txb); 2887 libipw_txb_free(packet->info.d_struct.txb);
2888 packet->info.d_struct.txb = NULL; 2888 packet->info.d_struct.txb = NULL;
2889 2889
2890 list_add_tail(element, &priv->tx_free_list); 2890 list_add_tail(element, &priv->tx_free_list);
@@ -3028,7 +3028,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3028 int next = txq->next; 3028 int next = txq->next;
3029 int i = 0; 3029 int i = 0;
3030 struct ipw2100_data_header *ipw_hdr; 3030 struct ipw2100_data_header *ipw_hdr;
3031 struct ieee80211_hdr_3addr *hdr; 3031 struct libipw_hdr_3addr *hdr;
3032 3032
3033 while (!list_empty(&priv->tx_pend_list)) { 3033 while (!list_empty(&priv->tx_pend_list)) {
3034 /* if there isn't enough space in TBD queue, then 3034 /* if there isn't enough space in TBD queue, then
@@ -3062,7 +3062,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3062 packet->index = txq->next; 3062 packet->index = txq->next;
3063 3063
3064 ipw_hdr = packet->info.d_struct.data; 3064 ipw_hdr = packet->info.d_struct.data;
3065 hdr = (struct ieee80211_hdr_3addr *)packet->info.d_struct.txb-> 3065 hdr = (struct libipw_hdr_3addr *)packet->info.d_struct.txb->
3066 fragments[0]->data; 3066 fragments[0]->data;
3067 3067
3068 if (priv->ieee->iw_mode == IW_MODE_INFRA) { 3068 if (priv->ieee->iw_mode == IW_MODE_INFRA) {
@@ -3086,7 +3086,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3086 if (packet->info.d_struct.txb->nr_frags > 1) 3086 if (packet->info.d_struct.txb->nr_frags > 1)
3087 ipw_hdr->fragment_size = 3087 ipw_hdr->fragment_size =
3088 packet->info.d_struct.txb->frag_size - 3088 packet->info.d_struct.txb->frag_size -
3089 IEEE80211_3ADDR_LEN; 3089 LIBIPW_3ADDR_LEN;
3090 else 3090 else
3091 ipw_hdr->fragment_size = 0; 3091 ipw_hdr->fragment_size = 0;
3092 3092
@@ -3119,13 +3119,13 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3119 IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; 3119 IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT;
3120 3120
3121 tbd->buf_length = packet->info.d_struct.txb-> 3121 tbd->buf_length = packet->info.d_struct.txb->
3122 fragments[i]->len - IEEE80211_3ADDR_LEN; 3122 fragments[i]->len - LIBIPW_3ADDR_LEN;
3123 3123
3124 tbd->host_addr = pci_map_single(priv->pci_dev, 3124 tbd->host_addr = pci_map_single(priv->pci_dev,
3125 packet->info.d_struct. 3125 packet->info.d_struct.
3126 txb->fragments[i]-> 3126 txb->fragments[i]->
3127 data + 3127 data +
3128 IEEE80211_3ADDR_LEN, 3128 LIBIPW_3ADDR_LEN,
3129 tbd->buf_length, 3129 tbd->buf_length,
3130 PCI_DMA_TODEVICE); 3130 PCI_DMA_TODEVICE);
3131 3131
@@ -3330,10 +3330,10 @@ static irqreturn_t ipw2100_interrupt(int irq, void *data)
3330 return IRQ_NONE; 3330 return IRQ_NONE;
3331} 3331}
3332 3332
3333static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev, 3333static int ipw2100_tx(struct libipw_txb *txb, struct net_device *dev,
3334 int pri) 3334 int pri)
3335{ 3335{
3336 struct ipw2100_priv *priv = ieee80211_priv(dev); 3336 struct ipw2100_priv *priv = libipw_priv(dev);
3337 struct list_head *element; 3337 struct list_head *element;
3338 struct ipw2100_tx_packet *packet; 3338 struct ipw2100_tx_packet *packet;
3339 unsigned long flags; 3339 unsigned long flags;
@@ -4488,7 +4488,7 @@ static void ipw2100_tx_initialize(struct ipw2100_priv *priv)
4488 /* We simply drop any SKBs that have been queued for 4488 /* We simply drop any SKBs that have been queued for
4489 * transmit */ 4489 * transmit */
4490 if (priv->tx_buffers[i].info.d_struct.txb) { 4490 if (priv->tx_buffers[i].info.d_struct.txb) {
4491 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct. 4491 libipw_txb_free(priv->tx_buffers[i].info.d_struct.
4492 txb); 4492 txb);
4493 priv->tx_buffers[i].info.d_struct.txb = NULL; 4493 priv->tx_buffers[i].info.d_struct.txb = NULL;
4494 } 4494 }
@@ -4527,7 +4527,7 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv)
4527 4527
4528 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { 4528 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4529 if (priv->tx_buffers[i].info.d_struct.txb) { 4529 if (priv->tx_buffers[i].info.d_struct.txb) {
4530 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct. 4530 libipw_txb_free(priv->tx_buffers[i].info.d_struct.
4531 txb); 4531 txb);
4532 priv->tx_buffers[i].info.d_struct.txb = NULL; 4532 priv->tx_buffers[i].info.d_struct.txb = NULL;
4533 } 4533 }
@@ -5558,9 +5558,9 @@ static void ipw2100_security_work(struct work_struct *work)
5558} 5558}
5559 5559
5560static void shim__set_security(struct net_device *dev, 5560static void shim__set_security(struct net_device *dev,
5561 struct ieee80211_security *sec) 5561 struct libipw_security *sec)
5562{ 5562{
5563 struct ipw2100_priv *priv = ieee80211_priv(dev); 5563 struct ipw2100_priv *priv = libipw_priv(dev);
5564 int i, force_update = 0; 5564 int i, force_update = 0;
5565 5565
5566 mutex_lock(&priv->action_mutex); 5566 mutex_lock(&priv->action_mutex);
@@ -5753,7 +5753,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5753 * method as well) to talk to the firmware */ 5753 * method as well) to talk to the firmware */
5754static int ipw2100_set_address(struct net_device *dev, void *p) 5754static int ipw2100_set_address(struct net_device *dev, void *p)
5755{ 5755{
5756 struct ipw2100_priv *priv = ieee80211_priv(dev); 5756 struct ipw2100_priv *priv = libipw_priv(dev);
5757 struct sockaddr *addr = p; 5757 struct sockaddr *addr = p;
5758 int err = 0; 5758 int err = 0;
5759 5759
@@ -5781,7 +5781,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p)
5781 5781
5782static int ipw2100_open(struct net_device *dev) 5782static int ipw2100_open(struct net_device *dev)
5783{ 5783{
5784 struct ipw2100_priv *priv = ieee80211_priv(dev); 5784 struct ipw2100_priv *priv = libipw_priv(dev);
5785 unsigned long flags; 5785 unsigned long flags;
5786 IPW_DEBUG_INFO("dev->open\n"); 5786 IPW_DEBUG_INFO("dev->open\n");
5787 5787
@@ -5797,7 +5797,7 @@ static int ipw2100_open(struct net_device *dev)
5797 5797
5798static int ipw2100_close(struct net_device *dev) 5798static int ipw2100_close(struct net_device *dev)
5799{ 5799{
5800 struct ipw2100_priv *priv = ieee80211_priv(dev); 5800 struct ipw2100_priv *priv = libipw_priv(dev);
5801 unsigned long flags; 5801 unsigned long flags;
5802 struct list_head *element; 5802 struct list_head *element;
5803 struct ipw2100_tx_packet *packet; 5803 struct ipw2100_tx_packet *packet;
@@ -5818,7 +5818,7 @@ static int ipw2100_close(struct net_device *dev)
5818 list_del(element); 5818 list_del(element);
5819 DEC_STAT(&priv->tx_pend_stat); 5819 DEC_STAT(&priv->tx_pend_stat);
5820 5820
5821 ieee80211_txb_free(packet->info.d_struct.txb); 5821 libipw_txb_free(packet->info.d_struct.txb);
5822 packet->info.d_struct.txb = NULL; 5822 packet->info.d_struct.txb = NULL;
5823 5823
5824 list_add_tail(element, &priv->tx_free_list); 5824 list_add_tail(element, &priv->tx_free_list);
@@ -5836,7 +5836,7 @@ static int ipw2100_close(struct net_device *dev)
5836 */ 5836 */
5837static void ipw2100_tx_timeout(struct net_device *dev) 5837static void ipw2100_tx_timeout(struct net_device *dev)
5838{ 5838{
5839 struct ipw2100_priv *priv = ieee80211_priv(dev); 5839 struct ipw2100_priv *priv = libipw_priv(dev);
5840 5840
5841 dev->stats.tx_errors++; 5841 dev->stats.tx_errors++;
5842 5842
@@ -5861,8 +5861,8 @@ static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value)
5861static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value) 5861static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value)
5862{ 5862{
5863 5863
5864 struct ieee80211_device *ieee = priv->ieee; 5864 struct libipw_device *ieee = priv->ieee;
5865 struct ieee80211_security sec = { 5865 struct libipw_security sec = {
5866 .flags = SEC_AUTH_MODE, 5866 .flags = SEC_AUTH_MODE,
5867 }; 5867 };
5868 int ret = 0; 5868 int ret = 0;
@@ -5907,7 +5907,7 @@ static void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv,
5907static void ipw_ethtool_get_drvinfo(struct net_device *dev, 5907static void ipw_ethtool_get_drvinfo(struct net_device *dev,
5908 struct ethtool_drvinfo *info) 5908 struct ethtool_drvinfo *info)
5909{ 5909{
5910 struct ipw2100_priv *priv = ieee80211_priv(dev); 5910 struct ipw2100_priv *priv = libipw_priv(dev);
5911 char fw_ver[64], ucode_ver[64]; 5911 char fw_ver[64], ucode_ver[64];
5912 5912
5913 strcpy(info->driver, DRV_NAME); 5913 strcpy(info->driver, DRV_NAME);
@@ -5924,7 +5924,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
5924 5924
5925static u32 ipw2100_ethtool_get_link(struct net_device *dev) 5925static u32 ipw2100_ethtool_get_link(struct net_device *dev)
5926{ 5926{
5927 struct ipw2100_priv *priv = ieee80211_priv(dev); 5927 struct ipw2100_priv *priv = libipw_priv(dev);
5928 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0; 5928 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0;
5929} 5929}
5930 5930
@@ -6011,8 +6011,8 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv);
6011static const struct net_device_ops ipw2100_netdev_ops = { 6011static const struct net_device_ops ipw2100_netdev_ops = {
6012 .ndo_open = ipw2100_open, 6012 .ndo_open = ipw2100_open,
6013 .ndo_stop = ipw2100_close, 6013 .ndo_stop = ipw2100_close,
6014 .ndo_start_xmit = ieee80211_xmit, 6014 .ndo_start_xmit = libipw_xmit,
6015 .ndo_change_mtu = ieee80211_change_mtu, 6015 .ndo_change_mtu = libipw_change_mtu,
6016 .ndo_init = ipw2100_net_init, 6016 .ndo_init = ipw2100_net_init,
6017 .ndo_tx_timeout = ipw2100_tx_timeout, 6017 .ndo_tx_timeout = ipw2100_tx_timeout,
6018 .ndo_set_mac_address = ipw2100_set_address, 6018 .ndo_set_mac_address = ipw2100_set_address,
@@ -6029,10 +6029,10 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6029 struct ipw2100_priv *priv; 6029 struct ipw2100_priv *priv;
6030 struct net_device *dev; 6030 struct net_device *dev;
6031 6031
6032 dev = alloc_ieee80211(sizeof(struct ipw2100_priv)); 6032 dev = alloc_ieee80211(sizeof(struct ipw2100_priv), 0);
6033 if (!dev) 6033 if (!dev)
6034 return NULL; 6034 return NULL;
6035 priv = ieee80211_priv(dev); 6035 priv = libipw_priv(dev);
6036 priv->ieee = netdev_priv(dev); 6036 priv->ieee = netdev_priv(dev);
6037 priv->pci_dev = pci_dev; 6037 priv->pci_dev = pci_dev;
6038 priv->net_dev = dev; 6038 priv->net_dev = dev;
@@ -6046,7 +6046,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6046 dev->netdev_ops = &ipw2100_netdev_ops; 6046 dev->netdev_ops = &ipw2100_netdev_ops;
6047 dev->ethtool_ops = &ipw2100_ethtool_ops; 6047 dev->ethtool_ops = &ipw2100_ethtool_ops;
6048 dev->wireless_handlers = &ipw2100_wx_handler_def; 6048 dev->wireless_handlers = &ipw2100_wx_handler_def;
6049 priv->wireless_data.ieee80211 = priv->ieee; 6049 priv->wireless_data.libipw = priv->ieee;
6050 dev->wireless_data = &priv->wireless_data; 6050 dev->wireless_data = &priv->wireless_data;
6051 dev->watchdog_timeo = 3 * HZ; 6051 dev->watchdog_timeo = 3 * HZ;
6052 dev->irq = 0; 6052 dev->irq = 0;
@@ -6202,7 +6202,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6202 return err; 6202 return err;
6203 } 6203 }
6204 6204
6205 priv = ieee80211_priv(dev); 6205 priv = libipw_priv(dev);
6206 6206
6207 pci_set_master(pci_dev); 6207 pci_set_master(pci_dev);
6208 pci_set_drvdata(pci_dev, priv); 6208 pci_set_drvdata(pci_dev, priv);
@@ -6342,7 +6342,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6342 sysfs_remove_group(&pci_dev->dev.kobj, 6342 sysfs_remove_group(&pci_dev->dev.kobj,
6343 &ipw2100_attribute_group); 6343 &ipw2100_attribute_group);
6344 6344
6345 free_ieee80211(dev); 6345 free_ieee80211(dev, 0);
6346 pci_set_drvdata(pci_dev, NULL); 6346 pci_set_drvdata(pci_dev, NULL);
6347 } 6347 }
6348 6348
@@ -6400,7 +6400,7 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
6400 if (dev->base_addr) 6400 if (dev->base_addr)
6401 iounmap((void __iomem *)dev->base_addr); 6401 iounmap((void __iomem *)dev->base_addr);
6402 6402
6403 free_ieee80211(dev); 6403 free_ieee80211(dev, 0);
6404 } 6404 }
6405 6405
6406 pci_release_regions(pci_dev); 6406 pci_release_regions(pci_dev);
@@ -6629,7 +6629,7 @@ static int ipw2100_wx_get_name(struct net_device *dev,
6629 * This can be called at any time. No action lock required 6629 * This can be called at any time. No action lock required
6630 */ 6630 */
6631 6631
6632 struct ipw2100_priv *priv = ieee80211_priv(dev); 6632 struct ipw2100_priv *priv = libipw_priv(dev);
6633 if (!(priv->status & STATUS_ASSOCIATED)) 6633 if (!(priv->status & STATUS_ASSOCIATED))
6634 strcpy(wrqu->name, "unassociated"); 6634 strcpy(wrqu->name, "unassociated");
6635 else 6635 else
@@ -6643,7 +6643,7 @@ static int ipw2100_wx_set_freq(struct net_device *dev,
6643 struct iw_request_info *info, 6643 struct iw_request_info *info,
6644 union iwreq_data *wrqu, char *extra) 6644 union iwreq_data *wrqu, char *extra)
6645{ 6645{
6646 struct ipw2100_priv *priv = ieee80211_priv(dev); 6646 struct ipw2100_priv *priv = libipw_priv(dev);
6647 struct iw_freq *fwrq = &wrqu->freq; 6647 struct iw_freq *fwrq = &wrqu->freq;
6648 int err = 0; 6648 int err = 0;
6649 6649
@@ -6693,7 +6693,7 @@ static int ipw2100_wx_get_freq(struct net_device *dev,
6693 * This can be called at any time. No action lock required 6693 * This can be called at any time. No action lock required
6694 */ 6694 */
6695 6695
6696 struct ipw2100_priv *priv = ieee80211_priv(dev); 6696 struct ipw2100_priv *priv = libipw_priv(dev);
6697 6697
6698 wrqu->freq.e = 0; 6698 wrqu->freq.e = 0;
6699 6699
@@ -6714,7 +6714,7 @@ static int ipw2100_wx_set_mode(struct net_device *dev,
6714 struct iw_request_info *info, 6714 struct iw_request_info *info,
6715 union iwreq_data *wrqu, char *extra) 6715 union iwreq_data *wrqu, char *extra)
6716{ 6716{
6717 struct ipw2100_priv *priv = ieee80211_priv(dev); 6717 struct ipw2100_priv *priv = libipw_priv(dev);
6718 int err = 0; 6718 int err = 0;
6719 6719
6720 IPW_DEBUG_WX("SET Mode -> %d \n", wrqu->mode); 6720 IPW_DEBUG_WX("SET Mode -> %d \n", wrqu->mode);
@@ -6757,7 +6757,7 @@ static int ipw2100_wx_get_mode(struct net_device *dev,
6757 * This can be called at any time. No action lock required 6757 * This can be called at any time. No action lock required
6758 */ 6758 */
6759 6759
6760 struct ipw2100_priv *priv = ieee80211_priv(dev); 6760 struct ipw2100_priv *priv = libipw_priv(dev);
6761 6761
6762 wrqu->mode = priv->ieee->iw_mode; 6762 wrqu->mode = priv->ieee->iw_mode;
6763 IPW_DEBUG_WX("GET Mode -> %d\n", wrqu->mode); 6763 IPW_DEBUG_WX("GET Mode -> %d\n", wrqu->mode);
@@ -6792,7 +6792,7 @@ static int ipw2100_wx_get_range(struct net_device *dev,
6792 * This can be called at any time. No action lock required 6792 * This can be called at any time. No action lock required
6793 */ 6793 */
6794 6794
6795 struct ipw2100_priv *priv = ieee80211_priv(dev); 6795 struct ipw2100_priv *priv = libipw_priv(dev);
6796 struct iw_range *range = (struct iw_range *)extra; 6796 struct iw_range *range = (struct iw_range *)extra;
6797 u16 val; 6797 u16 val;
6798 int i, level; 6798 int i, level;
@@ -6913,7 +6913,7 @@ static int ipw2100_wx_set_wap(struct net_device *dev,
6913 struct iw_request_info *info, 6913 struct iw_request_info *info,
6914 union iwreq_data *wrqu, char *extra) 6914 union iwreq_data *wrqu, char *extra)
6915{ 6915{
6916 struct ipw2100_priv *priv = ieee80211_priv(dev); 6916 struct ipw2100_priv *priv = libipw_priv(dev);
6917 int err = 0; 6917 int err = 0;
6918 6918
6919 static const unsigned char any[] = { 6919 static const unsigned char any[] = {
@@ -6962,7 +6962,7 @@ static int ipw2100_wx_get_wap(struct net_device *dev,
6962 * This can be called at any time. No action lock required 6962 * This can be called at any time. No action lock required
6963 */ 6963 */
6964 6964
6965 struct ipw2100_priv *priv = ieee80211_priv(dev); 6965 struct ipw2100_priv *priv = libipw_priv(dev);
6966 6966
6967 /* If we are associated, trying to associate, or have a statically 6967 /* If we are associated, trying to associate, or have a statically
6968 * configured BSSID then return that; otherwise return ANY */ 6968 * configured BSSID then return that; otherwise return ANY */
@@ -6980,7 +6980,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
6980 struct iw_request_info *info, 6980 struct iw_request_info *info,
6981 union iwreq_data *wrqu, char *extra) 6981 union iwreq_data *wrqu, char *extra)
6982{ 6982{
6983 struct ipw2100_priv *priv = ieee80211_priv(dev); 6983 struct ipw2100_priv *priv = libipw_priv(dev);
6984 char *essid = ""; /* ANY */ 6984 char *essid = ""; /* ANY */
6985 int length = 0; 6985 int length = 0;
6986 int err = 0; 6986 int err = 0;
@@ -7035,7 +7035,7 @@ static int ipw2100_wx_get_essid(struct net_device *dev,
7035 * This can be called at any time. No action lock required 7035 * This can be called at any time. No action lock required
7036 */ 7036 */
7037 7037
7038 struct ipw2100_priv *priv = ieee80211_priv(dev); 7038 struct ipw2100_priv *priv = libipw_priv(dev);
7039 DECLARE_SSID_BUF(ssid); 7039 DECLARE_SSID_BUF(ssid);
7040 7040
7041 /* If we are associated, trying to associate, or have a statically 7041 /* If we are associated, trying to associate, or have a statically
@@ -7063,7 +7063,7 @@ static int ipw2100_wx_set_nick(struct net_device *dev,
7063 * This can be called at any time. No action lock required 7063 * This can be called at any time. No action lock required
7064 */ 7064 */
7065 7065
7066 struct ipw2100_priv *priv = ieee80211_priv(dev); 7066 struct ipw2100_priv *priv = libipw_priv(dev);
7067 7067
7068 if (wrqu->data.length > IW_ESSID_MAX_SIZE) 7068 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
7069 return -E2BIG; 7069 return -E2BIG;
@@ -7085,7 +7085,7 @@ static int ipw2100_wx_get_nick(struct net_device *dev,
7085 * This can be called at any time. No action lock required 7085 * This can be called at any time. No action lock required
7086 */ 7086 */
7087 7087
7088 struct ipw2100_priv *priv = ieee80211_priv(dev); 7088 struct ipw2100_priv *priv = libipw_priv(dev);
7089 7089
7090 wrqu->data.length = strlen(priv->nick); 7090 wrqu->data.length = strlen(priv->nick);
7091 memcpy(extra, priv->nick, wrqu->data.length); 7091 memcpy(extra, priv->nick, wrqu->data.length);
@@ -7100,7 +7100,7 @@ static int ipw2100_wx_set_rate(struct net_device *dev,
7100 struct iw_request_info *info, 7100 struct iw_request_info *info,
7101 union iwreq_data *wrqu, char *extra) 7101 union iwreq_data *wrqu, char *extra)
7102{ 7102{
7103 struct ipw2100_priv *priv = ieee80211_priv(dev); 7103 struct ipw2100_priv *priv = libipw_priv(dev);
7104 u32 target_rate = wrqu->bitrate.value; 7104 u32 target_rate = wrqu->bitrate.value;
7105 u32 rate; 7105 u32 rate;
7106 int err = 0; 7106 int err = 0;
@@ -7140,7 +7140,7 @@ static int ipw2100_wx_get_rate(struct net_device *dev,
7140 struct iw_request_info *info, 7140 struct iw_request_info *info,
7141 union iwreq_data *wrqu, char *extra) 7141 union iwreq_data *wrqu, char *extra)
7142{ 7142{
7143 struct ipw2100_priv *priv = ieee80211_priv(dev); 7143 struct ipw2100_priv *priv = libipw_priv(dev);
7144 int val; 7144 int val;
7145 unsigned int len = sizeof(val); 7145 unsigned int len = sizeof(val);
7146 int err = 0; 7146 int err = 0;
@@ -7192,7 +7192,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev,
7192 struct iw_request_info *info, 7192 struct iw_request_info *info,
7193 union iwreq_data *wrqu, char *extra) 7193 union iwreq_data *wrqu, char *extra)
7194{ 7194{
7195 struct ipw2100_priv *priv = ieee80211_priv(dev); 7195 struct ipw2100_priv *priv = libipw_priv(dev);
7196 int value, err; 7196 int value, err;
7197 7197
7198 /* Auto RTS not yet supported */ 7198 /* Auto RTS not yet supported */
@@ -7231,7 +7231,7 @@ static int ipw2100_wx_get_rts(struct net_device *dev,
7231 * This can be called at any time. No action lock required 7231 * This can be called at any time. No action lock required
7232 */ 7232 */
7233 7233
7234 struct ipw2100_priv *priv = ieee80211_priv(dev); 7234 struct ipw2100_priv *priv = libipw_priv(dev);
7235 7235
7236 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED; 7236 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED;
7237 wrqu->rts.fixed = 1; /* no auto select */ 7237 wrqu->rts.fixed = 1; /* no auto select */
@@ -7248,7 +7248,7 @@ static int ipw2100_wx_set_txpow(struct net_device *dev,
7248 struct iw_request_info *info, 7248 struct iw_request_info *info,
7249 union iwreq_data *wrqu, char *extra) 7249 union iwreq_data *wrqu, char *extra)
7250{ 7250{
7251 struct ipw2100_priv *priv = ieee80211_priv(dev); 7251 struct ipw2100_priv *priv = libipw_priv(dev);
7252 int err = 0, value; 7252 int err = 0, value;
7253 7253
7254 if (ipw_radio_kill_sw(priv, wrqu->txpower.disabled)) 7254 if (ipw_radio_kill_sw(priv, wrqu->txpower.disabled))
@@ -7293,7 +7293,7 @@ static int ipw2100_wx_get_txpow(struct net_device *dev,
7293 * This can be called at any time. No action lock required 7293 * This can be called at any time. No action lock required
7294 */ 7294 */
7295 7295
7296 struct ipw2100_priv *priv = ieee80211_priv(dev); 7296 struct ipw2100_priv *priv = libipw_priv(dev);
7297 7297
7298 wrqu->txpower.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; 7298 wrqu->txpower.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0;
7299 7299
@@ -7320,7 +7320,7 @@ static int ipw2100_wx_set_frag(struct net_device *dev,
7320 * This can be called at any time. No action lock required 7320 * This can be called at any time. No action lock required
7321 */ 7321 */
7322 7322
7323 struct ipw2100_priv *priv = ieee80211_priv(dev); 7323 struct ipw2100_priv *priv = libipw_priv(dev);
7324 7324
7325 if (!wrqu->frag.fixed) 7325 if (!wrqu->frag.fixed)
7326 return -EINVAL; 7326 return -EINVAL;
@@ -7350,7 +7350,7 @@ static int ipw2100_wx_get_frag(struct net_device *dev,
7350 * This can be called at any time. No action lock required 7350 * This can be called at any time. No action lock required
7351 */ 7351 */
7352 7352
7353 struct ipw2100_priv *priv = ieee80211_priv(dev); 7353 struct ipw2100_priv *priv = libipw_priv(dev);
7354 wrqu->frag.value = priv->frag_threshold & ~FRAG_DISABLED; 7354 wrqu->frag.value = priv->frag_threshold & ~FRAG_DISABLED;
7355 wrqu->frag.fixed = 0; /* no auto select */ 7355 wrqu->frag.fixed = 0; /* no auto select */
7356 wrqu->frag.disabled = (priv->frag_threshold & FRAG_DISABLED) ? 1 : 0; 7356 wrqu->frag.disabled = (priv->frag_threshold & FRAG_DISABLED) ? 1 : 0;
@@ -7364,7 +7364,7 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7364 struct iw_request_info *info, 7364 struct iw_request_info *info,
7365 union iwreq_data *wrqu, char *extra) 7365 union iwreq_data *wrqu, char *extra)
7366{ 7366{
7367 struct ipw2100_priv *priv = ieee80211_priv(dev); 7367 struct ipw2100_priv *priv = libipw_priv(dev);
7368 int err = 0; 7368 int err = 0;
7369 7369
7370 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled) 7370 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled)
@@ -7412,7 +7412,7 @@ static int ipw2100_wx_get_retry(struct net_device *dev,
7412 * This can be called at any time. No action lock required 7412 * This can be called at any time. No action lock required
7413 */ 7413 */
7414 7414
7415 struct ipw2100_priv *priv = ieee80211_priv(dev); 7415 struct ipw2100_priv *priv = libipw_priv(dev);
7416 7416
7417 wrqu->retry.disabled = 0; /* can't be disabled */ 7417 wrqu->retry.disabled = 0; /* can't be disabled */
7418 7418
@@ -7440,7 +7440,7 @@ static int ipw2100_wx_set_scan(struct net_device *dev,
7440 struct iw_request_info *info, 7440 struct iw_request_info *info,
7441 union iwreq_data *wrqu, char *extra) 7441 union iwreq_data *wrqu, char *extra)
7442{ 7442{
7443 struct ipw2100_priv *priv = ieee80211_priv(dev); 7443 struct ipw2100_priv *priv = libipw_priv(dev);
7444 int err = 0; 7444 int err = 0;
7445 7445
7446 mutex_lock(&priv->action_mutex); 7446 mutex_lock(&priv->action_mutex);
@@ -7472,8 +7472,8 @@ static int ipw2100_wx_get_scan(struct net_device *dev,
7472 * This can be called at any time. No action lock required 7472 * This can be called at any time. No action lock required
7473 */ 7473 */
7474 7474
7475 struct ipw2100_priv *priv = ieee80211_priv(dev); 7475 struct ipw2100_priv *priv = libipw_priv(dev);
7476 return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra); 7476 return libipw_wx_get_scan(priv->ieee, info, wrqu, extra);
7477} 7477}
7478 7478
7479/* 7479/*
@@ -7487,8 +7487,8 @@ static int ipw2100_wx_set_encode(struct net_device *dev,
7487 * No check of STATUS_INITIALIZED required 7487 * No check of STATUS_INITIALIZED required
7488 */ 7488 */
7489 7489
7490 struct ipw2100_priv *priv = ieee80211_priv(dev); 7490 struct ipw2100_priv *priv = libipw_priv(dev);
7491 return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key); 7491 return libipw_wx_set_encode(priv->ieee, info, wrqu, key);
7492} 7492}
7493 7493
7494static int ipw2100_wx_get_encode(struct net_device *dev, 7494static int ipw2100_wx_get_encode(struct net_device *dev,
@@ -7499,15 +7499,15 @@ static int ipw2100_wx_get_encode(struct net_device *dev,
7499 * This can be called at any time. No action lock required 7499 * This can be called at any time. No action lock required
7500 */ 7500 */
7501 7501
7502 struct ipw2100_priv *priv = ieee80211_priv(dev); 7502 struct ipw2100_priv *priv = libipw_priv(dev);
7503 return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key); 7503 return libipw_wx_get_encode(priv->ieee, info, wrqu, key);
7504} 7504}
7505 7505
7506static int ipw2100_wx_set_power(struct net_device *dev, 7506static int ipw2100_wx_set_power(struct net_device *dev,
7507 struct iw_request_info *info, 7507 struct iw_request_info *info,
7508 union iwreq_data *wrqu, char *extra) 7508 union iwreq_data *wrqu, char *extra)
7509{ 7509{
7510 struct ipw2100_priv *priv = ieee80211_priv(dev); 7510 struct ipw2100_priv *priv = libipw_priv(dev);
7511 int err = 0; 7511 int err = 0;
7512 7512
7513 mutex_lock(&priv->action_mutex); 7513 mutex_lock(&priv->action_mutex);
@@ -7556,7 +7556,7 @@ static int ipw2100_wx_get_power(struct net_device *dev,
7556 * This can be called at any time. No action lock required 7556 * This can be called at any time. No action lock required
7557 */ 7557 */
7558 7558
7559 struct ipw2100_priv *priv = ieee80211_priv(dev); 7559 struct ipw2100_priv *priv = libipw_priv(dev);
7560 7560
7561 if (!(priv->power_mode & IPW_POWER_ENABLED)) 7561 if (!(priv->power_mode & IPW_POWER_ENABLED))
7562 wrqu->power.disabled = 1; 7562 wrqu->power.disabled = 1;
@@ -7580,8 +7580,8 @@ static int ipw2100_wx_set_genie(struct net_device *dev,
7580 union iwreq_data *wrqu, char *extra) 7580 union iwreq_data *wrqu, char *extra)
7581{ 7581{
7582 7582
7583 struct ipw2100_priv *priv = ieee80211_priv(dev); 7583 struct ipw2100_priv *priv = libipw_priv(dev);
7584 struct ieee80211_device *ieee = priv->ieee; 7584 struct libipw_device *ieee = priv->ieee;
7585 u8 *buf; 7585 u8 *buf;
7586 7586
7587 if (!ieee->wpa_enabled) 7587 if (!ieee->wpa_enabled)
@@ -7615,8 +7615,8 @@ static int ipw2100_wx_get_genie(struct net_device *dev,
7615 struct iw_request_info *info, 7615 struct iw_request_info *info,
7616 union iwreq_data *wrqu, char *extra) 7616 union iwreq_data *wrqu, char *extra)
7617{ 7617{
7618 struct ipw2100_priv *priv = ieee80211_priv(dev); 7618 struct ipw2100_priv *priv = libipw_priv(dev);
7619 struct ieee80211_device *ieee = priv->ieee; 7619 struct libipw_device *ieee = priv->ieee;
7620 7620
7621 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { 7621 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
7622 wrqu->data.length = 0; 7622 wrqu->data.length = 0;
@@ -7637,8 +7637,8 @@ static int ipw2100_wx_set_auth(struct net_device *dev,
7637 struct iw_request_info *info, 7637 struct iw_request_info *info,
7638 union iwreq_data *wrqu, char *extra) 7638 union iwreq_data *wrqu, char *extra)
7639{ 7639{
7640 struct ipw2100_priv *priv = ieee80211_priv(dev); 7640 struct ipw2100_priv *priv = libipw_priv(dev);
7641 struct ieee80211_device *ieee = priv->ieee; 7641 struct libipw_device *ieee = priv->ieee;
7642 struct iw_param *param = &wrqu->param; 7642 struct iw_param *param = &wrqu->param;
7643 struct lib80211_crypt_data *crypt; 7643 struct lib80211_crypt_data *crypt;
7644 unsigned long flags; 7644 unsigned long flags;
@@ -7682,7 +7682,7 @@ static int ipw2100_wx_set_auth(struct net_device *dev,
7682 * can use this to determine if the CAP_PRIVACY_ON bit should 7682 * can use this to determine if the CAP_PRIVACY_ON bit should
7683 * be set. 7683 * be set.
7684 */ 7684 */
7685 struct ieee80211_security sec = { 7685 struct libipw_security sec = {
7686 .flags = SEC_ENABLED, 7686 .flags = SEC_ENABLED,
7687 .enabled = param->value, 7687 .enabled = param->value,
7688 }; 7688 };
@@ -7730,8 +7730,8 @@ static int ipw2100_wx_get_auth(struct net_device *dev,
7730 struct iw_request_info *info, 7730 struct iw_request_info *info,
7731 union iwreq_data *wrqu, char *extra) 7731 union iwreq_data *wrqu, char *extra)
7732{ 7732{
7733 struct ipw2100_priv *priv = ieee80211_priv(dev); 7733 struct ipw2100_priv *priv = libipw_priv(dev);
7734 struct ieee80211_device *ieee = priv->ieee; 7734 struct libipw_device *ieee = priv->ieee;
7735 struct lib80211_crypt_data *crypt; 7735 struct lib80211_crypt_data *crypt;
7736 struct iw_param *param = &wrqu->param; 7736 struct iw_param *param = &wrqu->param;
7737 int ret = 0; 7737 int ret = 0;
@@ -7792,8 +7792,8 @@ static int ipw2100_wx_set_encodeext(struct net_device *dev,
7792 struct iw_request_info *info, 7792 struct iw_request_info *info,
7793 union iwreq_data *wrqu, char *extra) 7793 union iwreq_data *wrqu, char *extra)
7794{ 7794{
7795 struct ipw2100_priv *priv = ieee80211_priv(dev); 7795 struct ipw2100_priv *priv = libipw_priv(dev);
7796 return ieee80211_wx_set_encodeext(priv->ieee, info, wrqu, extra); 7796 return libipw_wx_set_encodeext(priv->ieee, info, wrqu, extra);
7797} 7797}
7798 7798
7799/* SIOCGIWENCODEEXT */ 7799/* SIOCGIWENCODEEXT */
@@ -7801,8 +7801,8 @@ static int ipw2100_wx_get_encodeext(struct net_device *dev,
7801 struct iw_request_info *info, 7801 struct iw_request_info *info,
7802 union iwreq_data *wrqu, char *extra) 7802 union iwreq_data *wrqu, char *extra)
7803{ 7803{
7804 struct ipw2100_priv *priv = ieee80211_priv(dev); 7804 struct ipw2100_priv *priv = libipw_priv(dev);
7805 return ieee80211_wx_get_encodeext(priv->ieee, info, wrqu, extra); 7805 return libipw_wx_get_encodeext(priv->ieee, info, wrqu, extra);
7806} 7806}
7807 7807
7808/* SIOCSIWMLME */ 7808/* SIOCSIWMLME */
@@ -7810,7 +7810,7 @@ static int ipw2100_wx_set_mlme(struct net_device *dev,
7810 struct iw_request_info *info, 7810 struct iw_request_info *info,
7811 union iwreq_data *wrqu, char *extra) 7811 union iwreq_data *wrqu, char *extra)
7812{ 7812{
7813 struct ipw2100_priv *priv = ieee80211_priv(dev); 7813 struct ipw2100_priv *priv = libipw_priv(dev);
7814 struct iw_mlme *mlme = (struct iw_mlme *)extra; 7814 struct iw_mlme *mlme = (struct iw_mlme *)extra;
7815 __le16 reason; 7815 __le16 reason;
7816 7816
@@ -7841,7 +7841,7 @@ static int ipw2100_wx_set_promisc(struct net_device *dev,
7841 struct iw_request_info *info, 7841 struct iw_request_info *info,
7842 union iwreq_data *wrqu, char *extra) 7842 union iwreq_data *wrqu, char *extra)
7843{ 7843{
7844 struct ipw2100_priv *priv = ieee80211_priv(dev); 7844 struct ipw2100_priv *priv = libipw_priv(dev);
7845 int *parms = (int *)extra; 7845 int *parms = (int *)extra;
7846 int enable = (parms[0] > 0); 7846 int enable = (parms[0] > 0);
7847 int err = 0; 7847 int err = 0;
@@ -7872,7 +7872,7 @@ static int ipw2100_wx_reset(struct net_device *dev,
7872 struct iw_request_info *info, 7872 struct iw_request_info *info,
7873 union iwreq_data *wrqu, char *extra) 7873 union iwreq_data *wrqu, char *extra)
7874{ 7874{
7875 struct ipw2100_priv *priv = ieee80211_priv(dev); 7875 struct ipw2100_priv *priv = libipw_priv(dev);
7876 if (priv->status & STATUS_INITIALIZED) 7876 if (priv->status & STATUS_INITIALIZED)
7877 schedule_reset(priv); 7877 schedule_reset(priv);
7878 return 0; 7878 return 0;
@@ -7884,7 +7884,7 @@ static int ipw2100_wx_set_powermode(struct net_device *dev,
7884 struct iw_request_info *info, 7884 struct iw_request_info *info,
7885 union iwreq_data *wrqu, char *extra) 7885 union iwreq_data *wrqu, char *extra)
7886{ 7886{
7887 struct ipw2100_priv *priv = ieee80211_priv(dev); 7887 struct ipw2100_priv *priv = libipw_priv(dev);
7888 int err = 0, mode = *(int *)extra; 7888 int err = 0, mode = *(int *)extra;
7889 7889
7890 mutex_lock(&priv->action_mutex); 7890 mutex_lock(&priv->action_mutex);
@@ -7912,7 +7912,7 @@ static int ipw2100_wx_get_powermode(struct net_device *dev,
7912 * This can be called at any time. No action lock required 7912 * This can be called at any time. No action lock required
7913 */ 7913 */
7914 7914
7915 struct ipw2100_priv *priv = ieee80211_priv(dev); 7915 struct ipw2100_priv *priv = libipw_priv(dev);
7916 int level = IPW_POWER_LEVEL(priv->power_mode); 7916 int level = IPW_POWER_LEVEL(priv->power_mode);
7917 s32 timeout, period; 7917 s32 timeout, period;
7918 7918
@@ -7948,7 +7948,7 @@ static int ipw2100_wx_set_preamble(struct net_device *dev,
7948 struct iw_request_info *info, 7948 struct iw_request_info *info,
7949 union iwreq_data *wrqu, char *extra) 7949 union iwreq_data *wrqu, char *extra)
7950{ 7950{
7951 struct ipw2100_priv *priv = ieee80211_priv(dev); 7951 struct ipw2100_priv *priv = libipw_priv(dev);
7952 int err, mode = *(int *)extra; 7952 int err, mode = *(int *)extra;
7953 7953
7954 mutex_lock(&priv->action_mutex); 7954 mutex_lock(&priv->action_mutex);
@@ -7981,7 +7981,7 @@ static int ipw2100_wx_get_preamble(struct net_device *dev,
7981 * This can be called at any time. No action lock required 7981 * This can be called at any time. No action lock required
7982 */ 7982 */
7983 7983
7984 struct ipw2100_priv *priv = ieee80211_priv(dev); 7984 struct ipw2100_priv *priv = libipw_priv(dev);
7985 7985
7986 if (priv->config & CFG_LONG_PREAMBLE) 7986 if (priv->config & CFG_LONG_PREAMBLE)
7987 snprintf(wrqu->name, IFNAMSIZ, "long (1)"); 7987 snprintf(wrqu->name, IFNAMSIZ, "long (1)");
@@ -7996,7 +7996,7 @@ static int ipw2100_wx_set_crc_check(struct net_device *dev,
7996 struct iw_request_info *info, 7996 struct iw_request_info *info,
7997 union iwreq_data *wrqu, char *extra) 7997 union iwreq_data *wrqu, char *extra)
7998{ 7998{
7999 struct ipw2100_priv *priv = ieee80211_priv(dev); 7999 struct ipw2100_priv *priv = libipw_priv(dev);
8000 int err, mode = *(int *)extra; 8000 int err, mode = *(int *)extra;
8001 8001
8002 mutex_lock(&priv->action_mutex); 8002 mutex_lock(&priv->action_mutex);
@@ -8028,7 +8028,7 @@ static int ipw2100_wx_get_crc_check(struct net_device *dev,
8028 * This can be called at any time. No action lock required 8028 * This can be called at any time. No action lock required
8029 */ 8029 */
8030 8030
8031 struct ipw2100_priv *priv = ieee80211_priv(dev); 8031 struct ipw2100_priv *priv = libipw_priv(dev);
8032 8032
8033 if (priv->config & CFG_CRC_CHECK) 8033 if (priv->config & CFG_CRC_CHECK)
8034 snprintf(wrqu->name, IFNAMSIZ, "CRC checked (1)"); 8034 snprintf(wrqu->name, IFNAMSIZ, "CRC checked (1)");
@@ -8181,7 +8181,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
8181 int beacon_qual; 8181 int beacon_qual;
8182 int quality; 8182 int quality;
8183 8183
8184 struct ipw2100_priv *priv = ieee80211_priv(dev); 8184 struct ipw2100_priv *priv = libipw_priv(dev);
8185 struct iw_statistics *wstats; 8185 struct iw_statistics *wstats;
8186 u32 rssi, tx_retries, missed_beacons, tx_failures; 8186 u32 rssi, tx_retries, missed_beacons, tx_failures;
8187 u32 ord_len = sizeof(u32); 8187 u32 ord_len = sizeof(u32);
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.h b/drivers/net/wireless/ipw2x00/ipw2100.h
index f183d951cd32..1eab0d698f4d 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.h
+++ b/drivers/net/wireless/ipw2x00/ipw2100.h
@@ -19,7 +19,7 @@
19 file called LICENSE. 19 file called LICENSE.
20 20
21 Contact Information: 21 Contact Information:
22 James P. Ketrenos <ipw2100-admin@linux.intel.com> 22 Intel Linux Wireless <ilw@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 24
25******************************************************************************/ 25******************************************************************************/
@@ -46,7 +46,7 @@
46#include <linux/workqueue.h> 46#include <linux/workqueue.h>
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48 48
49#include "ieee80211.h" 49#include "libipw.h"
50 50
51struct ipw2100_priv; 51struct ipw2100_priv;
52struct ipw2100_tx_packet; 52struct ipw2100_tx_packet;
@@ -343,7 +343,7 @@ struct ipw2100_tx_packet {
343 struct { /* DATA */ 343 struct { /* DATA */
344 struct ipw2100_data_header *data; 344 struct ipw2100_data_header *data;
345 dma_addr_t data_phys; 345 dma_addr_t data_phys;
346 struct ieee80211_txb *txb; 346 struct libipw_txb *txb;
347 } d_struct; 347 } d_struct;
348 } info; 348 } info;
349 int jiffy_start; 349 int jiffy_start;
@@ -492,7 +492,7 @@ struct ipw2100_priv {
492 int stop_hang_check; /* Set 1 when shutting down to kill hang_check */ 492 int stop_hang_check; /* Set 1 when shutting down to kill hang_check */
493 int stop_rf_kill; /* Set 1 when shutting down to kill rf_kill */ 493 int stop_rf_kill; /* Set 1 when shutting down to kill rf_kill */
494 494
495 struct ieee80211_device *ieee; 495 struct libipw_device *ieee;
496 unsigned long status; 496 unsigned long status;
497 unsigned long config; 497 unsigned long config;
498 unsigned long capability; 498 unsigned long capability;
@@ -788,7 +788,7 @@ struct ipw2100_priv {
788#define IPW_CARD_DISABLE_PHY_OFF_COMPLETE_WAIT 100 // 100 milli 788#define IPW_CARD_DISABLE_PHY_OFF_COMPLETE_WAIT 100 // 100 milli
789#define IPW_PREPARE_POWER_DOWN_COMPLETE_WAIT 100 // 100 milli 789#define IPW_PREPARE_POWER_DOWN_COMPLETE_WAIT 100 // 100 milli
790 790
791#define IPW_HEADER_802_11_SIZE sizeof(struct ieee80211_hdr_3addr) 791#define IPW_HEADER_802_11_SIZE sizeof(struct libipw_hdr_3addr)
792#define IPW_MAX_80211_PAYLOAD_SIZE 2304U 792#define IPW_MAX_80211_PAYLOAD_SIZE 2304U
793#define IPW_MAX_802_11_PAYLOAD_LENGTH 2312 793#define IPW_MAX_802_11_PAYLOAD_LENGTH 2312
794#define IPW_MAX_ACCEPTABLE_TX_FRAME_LENGTH 1536 794#define IPW_MAX_ACCEPTABLE_TX_FRAME_LENGTH 1536
@@ -803,13 +803,13 @@ struct ipw2100_priv {
803 IPW_802_11_FCS_LENGTH) 803 IPW_802_11_FCS_LENGTH)
804 804
805#define IPW_802_11_PAYLOAD_OFFSET \ 805#define IPW_802_11_PAYLOAD_OFFSET \
806 (sizeof(struct ieee80211_hdr_3addr) + \ 806 (sizeof(struct libipw_hdr_3addr) + \
807 sizeof(struct ieee80211_snap_hdr)) 807 sizeof(struct libipw_snap_hdr))
808 808
809struct ipw2100_rx { 809struct ipw2100_rx {
810 union { 810 union {
811 unsigned char payload[IPW_RX_NIC_BUFFER_LENGTH]; 811 unsigned char payload[IPW_RX_NIC_BUFFER_LENGTH];
812 struct ieee80211_hdr_4addr header; 812 struct libipw_hdr_4addr header;
813 u32 status; 813 u32 status;
814 struct ipw2100_notification notification; 814 struct ipw2100_notification notification;
815 struct ipw2100_cmd_header command; 815 struct ipw2100_cmd_header command;
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 8e18d5348350..3f8372daf46a 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -25,7 +25,7 @@
25 file called LICENSE. 25 file called LICENSE.
26 26
27 Contact Information: 27 Contact Information:
28 James P. Ketrenos <ipw2100-admin@linux.intel.com> 28 Intel Linux Wireless <ilw@linux.intel.com>
29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 30
31******************************************************************************/ 31******************************************************************************/
@@ -103,6 +103,25 @@ static int antenna = CFG_SYS_ANTENNA_BOTH;
103static int rtap_iface = 0; /* def: 0 -- do not create rtap interface */ 103static int rtap_iface = 0; /* def: 0 -- do not create rtap interface */
104#endif 104#endif
105 105
106static struct ieee80211_rate ipw2200_rates[] = {
107 { .bitrate = 10 },
108 { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
109 { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
110 { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
111 { .bitrate = 60 },
112 { .bitrate = 90 },
113 { .bitrate = 120 },
114 { .bitrate = 180 },
115 { .bitrate = 240 },
116 { .bitrate = 360 },
117 { .bitrate = 480 },
118 { .bitrate = 540 }
119};
120
121#define ipw2200_a_rates (ipw2200_rates + 4)
122#define ipw2200_num_a_rates 8
123#define ipw2200_bg_rates (ipw2200_rates + 0)
124#define ipw2200_num_bg_rates 12
106 125
107#ifdef CONFIG_IPW2200_QOS 126#ifdef CONFIG_IPW2200_QOS
108static int qos_enable = 0; 127static int qos_enable = 0;
@@ -111,7 +130,7 @@ static int qos_no_ack_mask = 0;
111static int burst_duration_CCK = 0; 130static int burst_duration_CCK = 0;
112static int burst_duration_OFDM = 0; 131static int burst_duration_OFDM = 0;
113 132
114static struct ieee80211_qos_parameters def_qos_parameters_OFDM = { 133static struct libipw_qos_parameters def_qos_parameters_OFDM = {
115 {QOS_TX0_CW_MIN_OFDM, QOS_TX1_CW_MIN_OFDM, QOS_TX2_CW_MIN_OFDM, 134 {QOS_TX0_CW_MIN_OFDM, QOS_TX1_CW_MIN_OFDM, QOS_TX2_CW_MIN_OFDM,
116 QOS_TX3_CW_MIN_OFDM}, 135 QOS_TX3_CW_MIN_OFDM},
117 {QOS_TX0_CW_MAX_OFDM, QOS_TX1_CW_MAX_OFDM, QOS_TX2_CW_MAX_OFDM, 136 {QOS_TX0_CW_MAX_OFDM, QOS_TX1_CW_MAX_OFDM, QOS_TX2_CW_MAX_OFDM,
@@ -122,7 +141,7 @@ static struct ieee80211_qos_parameters def_qos_parameters_OFDM = {
122 QOS_TX2_TXOP_LIMIT_OFDM, QOS_TX3_TXOP_LIMIT_OFDM} 141 QOS_TX2_TXOP_LIMIT_OFDM, QOS_TX3_TXOP_LIMIT_OFDM}
123}; 142};
124 143
125static struct ieee80211_qos_parameters def_qos_parameters_CCK = { 144static struct libipw_qos_parameters def_qos_parameters_CCK = {
126 {QOS_TX0_CW_MIN_CCK, QOS_TX1_CW_MIN_CCK, QOS_TX2_CW_MIN_CCK, 145 {QOS_TX0_CW_MIN_CCK, QOS_TX1_CW_MIN_CCK, QOS_TX2_CW_MIN_CCK,
127 QOS_TX3_CW_MIN_CCK}, 146 QOS_TX3_CW_MIN_CCK},
128 {QOS_TX0_CW_MAX_CCK, QOS_TX1_CW_MAX_CCK, QOS_TX2_CW_MAX_CCK, 147 {QOS_TX0_CW_MAX_CCK, QOS_TX1_CW_MAX_CCK, QOS_TX2_CW_MAX_CCK,
@@ -133,7 +152,7 @@ static struct ieee80211_qos_parameters def_qos_parameters_CCK = {
133 QOS_TX3_TXOP_LIMIT_CCK} 152 QOS_TX3_TXOP_LIMIT_CCK}
134}; 153};
135 154
136static struct ieee80211_qos_parameters def_parameters_OFDM = { 155static struct libipw_qos_parameters def_parameters_OFDM = {
137 {DEF_TX0_CW_MIN_OFDM, DEF_TX1_CW_MIN_OFDM, DEF_TX2_CW_MIN_OFDM, 156 {DEF_TX0_CW_MIN_OFDM, DEF_TX1_CW_MIN_OFDM, DEF_TX2_CW_MIN_OFDM,
138 DEF_TX3_CW_MIN_OFDM}, 157 DEF_TX3_CW_MIN_OFDM},
139 {DEF_TX0_CW_MAX_OFDM, DEF_TX1_CW_MAX_OFDM, DEF_TX2_CW_MAX_OFDM, 158 {DEF_TX0_CW_MAX_OFDM, DEF_TX1_CW_MAX_OFDM, DEF_TX2_CW_MAX_OFDM,
@@ -144,7 +163,7 @@ static struct ieee80211_qos_parameters def_parameters_OFDM = {
144 DEF_TX2_TXOP_LIMIT_OFDM, DEF_TX3_TXOP_LIMIT_OFDM} 163 DEF_TX2_TXOP_LIMIT_OFDM, DEF_TX3_TXOP_LIMIT_OFDM}
145}; 164};
146 165
147static struct ieee80211_qos_parameters def_parameters_CCK = { 166static struct libipw_qos_parameters def_parameters_CCK = {
148 {DEF_TX0_CW_MIN_CCK, DEF_TX1_CW_MIN_CCK, DEF_TX2_CW_MIN_CCK, 167 {DEF_TX0_CW_MIN_CCK, DEF_TX1_CW_MIN_CCK, DEF_TX2_CW_MIN_CCK,
149 DEF_TX3_CW_MIN_CCK}, 168 DEF_TX3_CW_MIN_CCK},
150 {DEF_TX0_CW_MAX_CCK, DEF_TX1_CW_MAX_CCK, DEF_TX2_CW_MAX_CCK, 169 {DEF_TX0_CW_MAX_CCK, DEF_TX1_CW_MAX_CCK, DEF_TX2_CW_MAX_CCK,
@@ -164,9 +183,9 @@ static int from_priority_to_tx_queue[] = {
164 183
165static u32 ipw_qos_get_burst_duration(struct ipw_priv *priv); 184static u32 ipw_qos_get_burst_duration(struct ipw_priv *priv);
166 185
167static int ipw_send_qos_params_command(struct ipw_priv *priv, struct ieee80211_qos_parameters 186static int ipw_send_qos_params_command(struct ipw_priv *priv, struct libipw_qos_parameters
168 *qos_param); 187 *qos_param);
169static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element 188static int ipw_send_qos_info_command(struct ipw_priv *priv, struct libipw_qos_information_element
170 *qos_param); 189 *qos_param);
171#endif /* CONFIG_IPW2200_QOS */ 190#endif /* CONFIG_IPW2200_QOS */
172 191
@@ -1830,7 +1849,7 @@ static ssize_t store_speed_scan(struct device *d, struct device_attribute *attr,
1830 break; 1849 break;
1831 } 1850 }
1832 1851
1833 if (ieee80211_is_valid_channel(priv->ieee, channel)) 1852 if (libipw_is_valid_channel(priv->ieee, channel))
1834 priv->speed_scan[pos++] = channel; 1853 priv->speed_scan[pos++] = channel;
1835 else 1854 else
1836 IPW_WARNING("Skipping invalid channel request: %d\n", 1855 IPW_WARNING("Skipping invalid channel request: %d\n",
@@ -1882,7 +1901,7 @@ static ssize_t show_channels(struct device *d,
1882 char *buf) 1901 char *buf)
1883{ 1902{
1884 struct ipw_priv *priv = dev_get_drvdata(d); 1903 struct ipw_priv *priv = dev_get_drvdata(d);
1885 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee); 1904 const struct libipw_geo *geo = libipw_get_geo(priv->ieee);
1886 int len = 0, i; 1905 int len = 0, i;
1887 1906
1888 len = sprintf(&buf[len], 1907 len = sprintf(&buf[len],
@@ -1892,14 +1911,14 @@ static ssize_t show_channels(struct device *d,
1892 for (i = 0; i < geo->bg_channels; i++) { 1911 for (i = 0; i < geo->bg_channels; i++) {
1893 len += sprintf(&buf[len], "%d: BSS%s%s, %s, Band %s.\n", 1912 len += sprintf(&buf[len], "%d: BSS%s%s, %s, Band %s.\n",
1894 geo->bg[i].channel, 1913 geo->bg[i].channel,
1895 geo->bg[i].flags & IEEE80211_CH_RADAR_DETECT ? 1914 geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT ?
1896 " (radar spectrum)" : "", 1915 " (radar spectrum)" : "",
1897 ((geo->bg[i].flags & IEEE80211_CH_NO_IBSS) || 1916 ((geo->bg[i].flags & LIBIPW_CH_NO_IBSS) ||
1898 (geo->bg[i].flags & IEEE80211_CH_RADAR_DETECT)) 1917 (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT))
1899 ? "" : ", IBSS", 1918 ? "" : ", IBSS",
1900 geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY ? 1919 geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY ?
1901 "passive only" : "active/passive", 1920 "passive only" : "active/passive",
1902 geo->bg[i].flags & IEEE80211_CH_B_ONLY ? 1921 geo->bg[i].flags & LIBIPW_CH_B_ONLY ?
1903 "B" : "B/G"); 1922 "B" : "B/G");
1904 } 1923 }
1905 1924
@@ -1909,12 +1928,12 @@ static ssize_t show_channels(struct device *d,
1909 for (i = 0; i < geo->a_channels; i++) { 1928 for (i = 0; i < geo->a_channels; i++) {
1910 len += sprintf(&buf[len], "%d: BSS%s%s, %s.\n", 1929 len += sprintf(&buf[len], "%d: BSS%s%s, %s.\n",
1911 geo->a[i].channel, 1930 geo->a[i].channel,
1912 geo->a[i].flags & IEEE80211_CH_RADAR_DETECT ? 1931 geo->a[i].flags & LIBIPW_CH_RADAR_DETECT ?
1913 " (radar spectrum)" : "", 1932 " (radar spectrum)" : "",
1914 ((geo->a[i].flags & IEEE80211_CH_NO_IBSS) || 1933 ((geo->a[i].flags & LIBIPW_CH_NO_IBSS) ||
1915 (geo->a[i].flags & IEEE80211_CH_RADAR_DETECT)) 1934 (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT))
1916 ? "" : ", IBSS", 1935 ? "" : ", IBSS",
1917 geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY ? 1936 geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY ?
1918 "passive only" : "active/passive"); 1937 "passive only" : "active/passive");
1919 } 1938 }
1920 1939
@@ -2429,7 +2448,7 @@ static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power)
2429 2448
2430static int ipw_set_tx_power(struct ipw_priv *priv) 2449static int ipw_set_tx_power(struct ipw_priv *priv)
2431{ 2450{
2432 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee); 2451 const struct libipw_geo *geo = libipw_get_geo(priv->ieee);
2433 struct ipw_tx_power tx_power; 2452 struct ipw_tx_power tx_power;
2434 s8 max_power; 2453 s8 max_power;
2435 int i; 2454 int i;
@@ -2960,12 +2979,12 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv)
2960static void ipw_remove_current_network(struct ipw_priv *priv) 2979static void ipw_remove_current_network(struct ipw_priv *priv)
2961{ 2980{
2962 struct list_head *element, *safe; 2981 struct list_head *element, *safe;
2963 struct ieee80211_network *network = NULL; 2982 struct libipw_network *network = NULL;
2964 unsigned long flags; 2983 unsigned long flags;
2965 2984
2966 spin_lock_irqsave(&priv->ieee->lock, flags); 2985 spin_lock_irqsave(&priv->ieee->lock, flags);
2967 list_for_each_safe(element, safe, &priv->ieee->network_list) { 2986 list_for_each_safe(element, safe, &priv->ieee->network_list) {
2968 network = list_entry(element, struct ieee80211_network, list); 2987 network = list_entry(element, struct libipw_network, list);
2969 if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) { 2988 if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
2970 list_del(element); 2989 list_del(element);
2971 list_add_tail(&network->list, 2990 list_add_tail(&network->list,
@@ -3751,7 +3770,7 @@ static void ipw_queue_tx_free_tfd(struct ipw_priv *priv,
3751 le16_to_cpu(bd->u.data.chunk_len[i]), 3770 le16_to_cpu(bd->u.data.chunk_len[i]),
3752 PCI_DMA_TODEVICE); 3771 PCI_DMA_TODEVICE);
3753 if (txq->txb[txq->q.last_used]) { 3772 if (txq->txb[txq->q.last_used]) {
3754 ieee80211_txb_free(txq->txb[txq->q.last_used]); 3773 libipw_txb_free(txq->txb[txq->q.last_used]);
3755 txq->txb[txq->q.last_used] = NULL; 3774 txq->txb[txq->q.last_used] = NULL;
3756 } 3775 }
3757 } 3776 }
@@ -4070,7 +4089,7 @@ static u32 ipw_get_max_rate(struct ipw_priv *priv)
4070 /* If currently associated in B mode, restrict the maximum 4089 /* If currently associated in B mode, restrict the maximum
4071 * rate match to B rates */ 4090 * rate match to B rates */
4072 if (priv->assoc_request.ieee_mode == IPW_B_MODE) 4091 if (priv->assoc_request.ieee_mode == IPW_B_MODE)
4073 mask &= IEEE80211_CCK_RATES_MASK; 4092 mask &= LIBIPW_CCK_RATES_MASK;
4074 4093
4075 /* TODO: Verify that the rate is supported by the current rates 4094 /* TODO: Verify that the rate is supported by the current rates
4076 * list. */ 4095 * list. */
@@ -4078,29 +4097,29 @@ static u32 ipw_get_max_rate(struct ipw_priv *priv)
4078 while (i && !(mask & i)) 4097 while (i && !(mask & i))
4079 i >>= 1; 4098 i >>= 1;
4080 switch (i) { 4099 switch (i) {
4081 case IEEE80211_CCK_RATE_1MB_MASK: 4100 case LIBIPW_CCK_RATE_1MB_MASK:
4082 return 1000000; 4101 return 1000000;
4083 case IEEE80211_CCK_RATE_2MB_MASK: 4102 case LIBIPW_CCK_RATE_2MB_MASK:
4084 return 2000000; 4103 return 2000000;
4085 case IEEE80211_CCK_RATE_5MB_MASK: 4104 case LIBIPW_CCK_RATE_5MB_MASK:
4086 return 5500000; 4105 return 5500000;
4087 case IEEE80211_OFDM_RATE_6MB_MASK: 4106 case LIBIPW_OFDM_RATE_6MB_MASK:
4088 return 6000000; 4107 return 6000000;
4089 case IEEE80211_OFDM_RATE_9MB_MASK: 4108 case LIBIPW_OFDM_RATE_9MB_MASK:
4090 return 9000000; 4109 return 9000000;
4091 case IEEE80211_CCK_RATE_11MB_MASK: 4110 case LIBIPW_CCK_RATE_11MB_MASK:
4092 return 11000000; 4111 return 11000000;
4093 case IEEE80211_OFDM_RATE_12MB_MASK: 4112 case LIBIPW_OFDM_RATE_12MB_MASK:
4094 return 12000000; 4113 return 12000000;
4095 case IEEE80211_OFDM_RATE_18MB_MASK: 4114 case LIBIPW_OFDM_RATE_18MB_MASK:
4096 return 18000000; 4115 return 18000000;
4097 case IEEE80211_OFDM_RATE_24MB_MASK: 4116 case LIBIPW_OFDM_RATE_24MB_MASK:
4098 return 24000000; 4117 return 24000000;
4099 case IEEE80211_OFDM_RATE_36MB_MASK: 4118 case LIBIPW_OFDM_RATE_36MB_MASK:
4100 return 36000000; 4119 return 36000000;
4101 case IEEE80211_OFDM_RATE_48MB_MASK: 4120 case LIBIPW_OFDM_RATE_48MB_MASK:
4102 return 48000000; 4121 return 48000000;
4103 case IEEE80211_OFDM_RATE_54MB_MASK: 4122 case LIBIPW_OFDM_RATE_54MB_MASK:
4104 return 54000000; 4123 return 54000000;
4105 } 4124 }
4106 4125
@@ -4466,11 +4485,11 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4466 == IEEE80211_STYPE_ASSOC_RESP)) { 4485 == IEEE80211_STYPE_ASSOC_RESP)) {
4467 if ((sizeof 4486 if ((sizeof
4468 (struct 4487 (struct
4469 ieee80211_assoc_response) 4488 libipw_assoc_response)
4470 <= size) 4489 <= size)
4471 && (size <= 2314)) { 4490 && (size <= 2314)) {
4472 struct 4491 struct
4473 ieee80211_rx_stats 4492 libipw_rx_stats
4474 stats = { 4493 stats = {
4475 .len = size - 1, 4494 .len = size - 1,
4476 }; 4495 };
@@ -4478,10 +4497,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4478 IPW_DEBUG_QOS 4497 IPW_DEBUG_QOS
4479 ("QoS Associate " 4498 ("QoS Associate "
4480 "size %d\n", size); 4499 "size %d\n", size);
4481 ieee80211_rx_mgt(priv-> 4500 libipw_rx_mgt(priv->
4482 ieee, 4501 ieee,
4483 (struct 4502 (struct
4484 ieee80211_hdr_4addr 4503 libipw_hdr_4addr
4485 *) 4504 *)
4486 &notif->u.raw, &stats); 4505 &notif->u.raw, &stats);
4487 } 4506 }
@@ -4537,11 +4556,11 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4537 case CMAS_INIT:{ 4556 case CMAS_INIT:{
4538 if (priv->status & STATUS_AUTH) { 4557 if (priv->status & STATUS_AUTH) {
4539 struct 4558 struct
4540 ieee80211_assoc_response 4559 libipw_assoc_response
4541 *resp; 4560 *resp;
4542 resp = 4561 resp =
4543 (struct 4562 (struct
4544 ieee80211_assoc_response 4563 libipw_assoc_response
4545 *)&notif->u.raw; 4564 *)&notif->u.raw;
4546 IPW_DEBUG(IPW_DL_NOTIF | 4565 IPW_DEBUG(IPW_DL_NOTIF |
4547 IPW_DL_STATE | 4566 IPW_DL_STATE |
@@ -5227,33 +5246,33 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *priv)
5227 5246
5228static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate) 5247static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate)
5229{ 5248{
5230 rate &= ~IEEE80211_BASIC_RATE_MASK; 5249 rate &= ~LIBIPW_BASIC_RATE_MASK;
5231 if (ieee_mode == IEEE_A) { 5250 if (ieee_mode == IEEE_A) {
5232 switch (rate) { 5251 switch (rate) {
5233 case IEEE80211_OFDM_RATE_6MB: 5252 case LIBIPW_OFDM_RATE_6MB:
5234 return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ? 5253 return priv->rates_mask & LIBIPW_OFDM_RATE_6MB_MASK ?
5235 1 : 0; 5254 1 : 0;
5236 case IEEE80211_OFDM_RATE_9MB: 5255 case LIBIPW_OFDM_RATE_9MB:
5237 return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ? 5256 return priv->rates_mask & LIBIPW_OFDM_RATE_9MB_MASK ?
5238 1 : 0; 5257 1 : 0;
5239 case IEEE80211_OFDM_RATE_12MB: 5258 case LIBIPW_OFDM_RATE_12MB:
5240 return priv-> 5259 return priv->
5241 rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 1 : 0; 5260 rates_mask & LIBIPW_OFDM_RATE_12MB_MASK ? 1 : 0;
5242 case IEEE80211_OFDM_RATE_18MB: 5261 case LIBIPW_OFDM_RATE_18MB:
5243 return priv-> 5262 return priv->
5244 rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 1 : 0; 5263 rates_mask & LIBIPW_OFDM_RATE_18MB_MASK ? 1 : 0;
5245 case IEEE80211_OFDM_RATE_24MB: 5264 case LIBIPW_OFDM_RATE_24MB:
5246 return priv-> 5265 return priv->
5247 rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 1 : 0; 5266 rates_mask & LIBIPW_OFDM_RATE_24MB_MASK ? 1 : 0;
5248 case IEEE80211_OFDM_RATE_36MB: 5267 case LIBIPW_OFDM_RATE_36MB:
5249 return priv-> 5268 return priv->
5250 rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 1 : 0; 5269 rates_mask & LIBIPW_OFDM_RATE_36MB_MASK ? 1 : 0;
5251 case IEEE80211_OFDM_RATE_48MB: 5270 case LIBIPW_OFDM_RATE_48MB:
5252 return priv-> 5271 return priv->
5253 rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 1 : 0; 5272 rates_mask & LIBIPW_OFDM_RATE_48MB_MASK ? 1 : 0;
5254 case IEEE80211_OFDM_RATE_54MB: 5273 case LIBIPW_OFDM_RATE_54MB:
5255 return priv-> 5274 return priv->
5256 rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 1 : 0; 5275 rates_mask & LIBIPW_OFDM_RATE_54MB_MASK ? 1 : 0;
5257 default: 5276 default:
5258 return 0; 5277 return 0;
5259 } 5278 }
@@ -5261,14 +5280,14 @@ static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate)
5261 5280
5262 /* B and G mixed */ 5281 /* B and G mixed */
5263 switch (rate) { 5282 switch (rate) {
5264 case IEEE80211_CCK_RATE_1MB: 5283 case LIBIPW_CCK_RATE_1MB:
5265 return priv->rates_mask & IEEE80211_CCK_RATE_1MB_MASK ? 1 : 0; 5284 return priv->rates_mask & LIBIPW_CCK_RATE_1MB_MASK ? 1 : 0;
5266 case IEEE80211_CCK_RATE_2MB: 5285 case LIBIPW_CCK_RATE_2MB:
5267 return priv->rates_mask & IEEE80211_CCK_RATE_2MB_MASK ? 1 : 0; 5286 return priv->rates_mask & LIBIPW_CCK_RATE_2MB_MASK ? 1 : 0;
5268 case IEEE80211_CCK_RATE_5MB: 5287 case LIBIPW_CCK_RATE_5MB:
5269 return priv->rates_mask & IEEE80211_CCK_RATE_5MB_MASK ? 1 : 0; 5288 return priv->rates_mask & LIBIPW_CCK_RATE_5MB_MASK ? 1 : 0;
5270 case IEEE80211_CCK_RATE_11MB: 5289 case LIBIPW_CCK_RATE_11MB:
5271 return priv->rates_mask & IEEE80211_CCK_RATE_11MB_MASK ? 1 : 0; 5290 return priv->rates_mask & LIBIPW_CCK_RATE_11MB_MASK ? 1 : 0;
5272 } 5291 }
5273 5292
5274 /* If we are limited to B modulations, bail at this point */ 5293 /* If we are limited to B modulations, bail at this point */
@@ -5277,29 +5296,29 @@ static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate)
5277 5296
5278 /* G */ 5297 /* G */
5279 switch (rate) { 5298 switch (rate) {
5280 case IEEE80211_OFDM_RATE_6MB: 5299 case LIBIPW_OFDM_RATE_6MB:
5281 return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ? 1 : 0; 5300 return priv->rates_mask & LIBIPW_OFDM_RATE_6MB_MASK ? 1 : 0;
5282 case IEEE80211_OFDM_RATE_9MB: 5301 case LIBIPW_OFDM_RATE_9MB:
5283 return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ? 1 : 0; 5302 return priv->rates_mask & LIBIPW_OFDM_RATE_9MB_MASK ? 1 : 0;
5284 case IEEE80211_OFDM_RATE_12MB: 5303 case LIBIPW_OFDM_RATE_12MB:
5285 return priv->rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 1 : 0; 5304 return priv->rates_mask & LIBIPW_OFDM_RATE_12MB_MASK ? 1 : 0;
5286 case IEEE80211_OFDM_RATE_18MB: 5305 case LIBIPW_OFDM_RATE_18MB:
5287 return priv->rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 1 : 0; 5306 return priv->rates_mask & LIBIPW_OFDM_RATE_18MB_MASK ? 1 : 0;
5288 case IEEE80211_OFDM_RATE_24MB: 5307 case LIBIPW_OFDM_RATE_24MB:
5289 return priv->rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 1 : 0; 5308 return priv->rates_mask & LIBIPW_OFDM_RATE_24MB_MASK ? 1 : 0;
5290 case IEEE80211_OFDM_RATE_36MB: 5309 case LIBIPW_OFDM_RATE_36MB:
5291 return priv->rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 1 : 0; 5310 return priv->rates_mask & LIBIPW_OFDM_RATE_36MB_MASK ? 1 : 0;
5292 case IEEE80211_OFDM_RATE_48MB: 5311 case LIBIPW_OFDM_RATE_48MB:
5293 return priv->rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 1 : 0; 5312 return priv->rates_mask & LIBIPW_OFDM_RATE_48MB_MASK ? 1 : 0;
5294 case IEEE80211_OFDM_RATE_54MB: 5313 case LIBIPW_OFDM_RATE_54MB:
5295 return priv->rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 1 : 0; 5314 return priv->rates_mask & LIBIPW_OFDM_RATE_54MB_MASK ? 1 : 0;
5296 } 5315 }
5297 5316
5298 return 0; 5317 return 0;
5299} 5318}
5300 5319
5301static int ipw_compatible_rates(struct ipw_priv *priv, 5320static int ipw_compatible_rates(struct ipw_priv *priv,
5302 const struct ieee80211_network *network, 5321 const struct libipw_network *network,
5303 struct ipw_supported_rates *rates) 5322 struct ipw_supported_rates *rates)
5304{ 5323{
5305 int num_rates, i; 5324 int num_rates, i;
@@ -5311,7 +5330,7 @@ static int ipw_compatible_rates(struct ipw_priv *priv,
5311 if (!ipw_is_rate_in_mask(priv, network->mode, 5330 if (!ipw_is_rate_in_mask(priv, network->mode,
5312 network->rates[i])) { 5331 network->rates[i])) {
5313 5332
5314 if (network->rates[i] & IEEE80211_BASIC_RATE_MASK) { 5333 if (network->rates[i] & LIBIPW_BASIC_RATE_MASK) {
5315 IPW_DEBUG_SCAN("Adding masked mandatory " 5334 IPW_DEBUG_SCAN("Adding masked mandatory "
5316 "rate %02X\n", 5335 "rate %02X\n",
5317 network->rates[i]); 5336 network->rates[i]);
@@ -5333,7 +5352,7 @@ static int ipw_compatible_rates(struct ipw_priv *priv,
5333 for (i = 0; i < num_rates; i++) { 5352 for (i = 0; i < num_rates; i++) {
5334 if (!ipw_is_rate_in_mask(priv, network->mode, 5353 if (!ipw_is_rate_in_mask(priv, network->mode,
5335 network->rates_ex[i])) { 5354 network->rates_ex[i])) {
5336 if (network->rates_ex[i] & IEEE80211_BASIC_RATE_MASK) { 5355 if (network->rates_ex[i] & LIBIPW_BASIC_RATE_MASK) {
5337 IPW_DEBUG_SCAN("Adding masked mandatory " 5356 IPW_DEBUG_SCAN("Adding masked mandatory "
5338 "rate %02X\n", 5357 "rate %02X\n",
5339 network->rates_ex[i]); 5358 network->rates_ex[i]);
@@ -5369,73 +5388,73 @@ static void ipw_copy_rates(struct ipw_supported_rates *dest,
5369static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates, 5388static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates,
5370 u8 modulation, u32 rate_mask) 5389 u8 modulation, u32 rate_mask)
5371{ 5390{
5372 u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? 5391 u8 basic_mask = (LIBIPW_OFDM_MODULATION == modulation) ?
5373 IEEE80211_BASIC_RATE_MASK : 0; 5392 LIBIPW_BASIC_RATE_MASK : 0;
5374 5393
5375 if (rate_mask & IEEE80211_CCK_RATE_1MB_MASK) 5394 if (rate_mask & LIBIPW_CCK_RATE_1MB_MASK)
5376 rates->supported_rates[rates->num_rates++] = 5395 rates->supported_rates[rates->num_rates++] =
5377 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; 5396 LIBIPW_BASIC_RATE_MASK | LIBIPW_CCK_RATE_1MB;
5378 5397
5379 if (rate_mask & IEEE80211_CCK_RATE_2MB_MASK) 5398 if (rate_mask & LIBIPW_CCK_RATE_2MB_MASK)
5380 rates->supported_rates[rates->num_rates++] = 5399 rates->supported_rates[rates->num_rates++] =
5381 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; 5400 LIBIPW_BASIC_RATE_MASK | LIBIPW_CCK_RATE_2MB;
5382 5401
5383 if (rate_mask & IEEE80211_CCK_RATE_5MB_MASK) 5402 if (rate_mask & LIBIPW_CCK_RATE_5MB_MASK)
5384 rates->supported_rates[rates->num_rates++] = basic_mask | 5403 rates->supported_rates[rates->num_rates++] = basic_mask |
5385 IEEE80211_CCK_RATE_5MB; 5404 LIBIPW_CCK_RATE_5MB;
5386 5405
5387 if (rate_mask & IEEE80211_CCK_RATE_11MB_MASK) 5406 if (rate_mask & LIBIPW_CCK_RATE_11MB_MASK)
5388 rates->supported_rates[rates->num_rates++] = basic_mask | 5407 rates->supported_rates[rates->num_rates++] = basic_mask |
5389 IEEE80211_CCK_RATE_11MB; 5408 LIBIPW_CCK_RATE_11MB;
5390} 5409}
5391 5410
5392static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates, 5411static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates,
5393 u8 modulation, u32 rate_mask) 5412 u8 modulation, u32 rate_mask)
5394{ 5413{
5395 u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? 5414 u8 basic_mask = (LIBIPW_OFDM_MODULATION == modulation) ?
5396 IEEE80211_BASIC_RATE_MASK : 0; 5415 LIBIPW_BASIC_RATE_MASK : 0;
5397 5416
5398 if (rate_mask & IEEE80211_OFDM_RATE_6MB_MASK) 5417 if (rate_mask & LIBIPW_OFDM_RATE_6MB_MASK)
5399 rates->supported_rates[rates->num_rates++] = basic_mask | 5418 rates->supported_rates[rates->num_rates++] = basic_mask |
5400 IEEE80211_OFDM_RATE_6MB; 5419 LIBIPW_OFDM_RATE_6MB;
5401 5420
5402 if (rate_mask & IEEE80211_OFDM_RATE_9MB_MASK) 5421 if (rate_mask & LIBIPW_OFDM_RATE_9MB_MASK)
5403 rates->supported_rates[rates->num_rates++] = 5422 rates->supported_rates[rates->num_rates++] =
5404 IEEE80211_OFDM_RATE_9MB; 5423 LIBIPW_OFDM_RATE_9MB;
5405 5424
5406 if (rate_mask & IEEE80211_OFDM_RATE_12MB_MASK) 5425 if (rate_mask & LIBIPW_OFDM_RATE_12MB_MASK)
5407 rates->supported_rates[rates->num_rates++] = basic_mask | 5426 rates->supported_rates[rates->num_rates++] = basic_mask |
5408 IEEE80211_OFDM_RATE_12MB; 5427 LIBIPW_OFDM_RATE_12MB;
5409 5428
5410 if (rate_mask & IEEE80211_OFDM_RATE_18MB_MASK) 5429 if (rate_mask & LIBIPW_OFDM_RATE_18MB_MASK)
5411 rates->supported_rates[rates->num_rates++] = 5430 rates->supported_rates[rates->num_rates++] =
5412 IEEE80211_OFDM_RATE_18MB; 5431 LIBIPW_OFDM_RATE_18MB;
5413 5432
5414 if (rate_mask & IEEE80211_OFDM_RATE_24MB_MASK) 5433 if (rate_mask & LIBIPW_OFDM_RATE_24MB_MASK)
5415 rates->supported_rates[rates->num_rates++] = basic_mask | 5434 rates->supported_rates[rates->num_rates++] = basic_mask |
5416 IEEE80211_OFDM_RATE_24MB; 5435 LIBIPW_OFDM_RATE_24MB;
5417 5436
5418 if (rate_mask & IEEE80211_OFDM_RATE_36MB_MASK) 5437 if (rate_mask & LIBIPW_OFDM_RATE_36MB_MASK)
5419 rates->supported_rates[rates->num_rates++] = 5438 rates->supported_rates[rates->num_rates++] =
5420 IEEE80211_OFDM_RATE_36MB; 5439 LIBIPW_OFDM_RATE_36MB;
5421 5440
5422 if (rate_mask & IEEE80211_OFDM_RATE_48MB_MASK) 5441 if (rate_mask & LIBIPW_OFDM_RATE_48MB_MASK)
5423 rates->supported_rates[rates->num_rates++] = 5442 rates->supported_rates[rates->num_rates++] =
5424 IEEE80211_OFDM_RATE_48MB; 5443 LIBIPW_OFDM_RATE_48MB;
5425 5444
5426 if (rate_mask & IEEE80211_OFDM_RATE_54MB_MASK) 5445 if (rate_mask & LIBIPW_OFDM_RATE_54MB_MASK)
5427 rates->supported_rates[rates->num_rates++] = 5446 rates->supported_rates[rates->num_rates++] =
5428 IEEE80211_OFDM_RATE_54MB; 5447 LIBIPW_OFDM_RATE_54MB;
5429} 5448}
5430 5449
5431struct ipw_network_match { 5450struct ipw_network_match {
5432 struct ieee80211_network *network; 5451 struct libipw_network *network;
5433 struct ipw_supported_rates rates; 5452 struct ipw_supported_rates rates;
5434}; 5453};
5435 5454
5436static int ipw_find_adhoc_network(struct ipw_priv *priv, 5455static int ipw_find_adhoc_network(struct ipw_priv *priv,
5437 struct ipw_network_match *match, 5456 struct ipw_network_match *match,
5438 struct ieee80211_network *network, 5457 struct libipw_network *network,
5439 int roaming) 5458 int roaming)
5440{ 5459{
5441 struct ipw_supported_rates rates; 5460 struct ipw_supported_rates rates;
@@ -5556,7 +5575,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5556 } 5575 }
5557 5576
5558 /* Filter out any incompatible freq / mode combinations */ 5577 /* Filter out any incompatible freq / mode combinations */
5559 if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) { 5578 if (!libipw_is_valid_mode(priv->ieee, network->mode)) {
5560 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded " 5579 IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
5561 "because of invalid frequency/mode " 5580 "because of invalid frequency/mode "
5562 "combination.\n", 5581 "combination.\n",
@@ -5606,7 +5625,7 @@ static void ipw_merge_adhoc_network(struct work_struct *work)
5606 DECLARE_SSID_BUF(ssid); 5625 DECLARE_SSID_BUF(ssid);
5607 struct ipw_priv *priv = 5626 struct ipw_priv *priv =
5608 container_of(work, struct ipw_priv, merge_networks); 5627 container_of(work, struct ipw_priv, merge_networks);
5609 struct ieee80211_network *network = NULL; 5628 struct libipw_network *network = NULL;
5610 struct ipw_network_match match = { 5629 struct ipw_network_match match = {
5611 .network = priv->assoc_network 5630 .network = priv->assoc_network
5612 }; 5631 };
@@ -5648,7 +5667,7 @@ static void ipw_merge_adhoc_network(struct work_struct *work)
5648 5667
5649static int ipw_best_network(struct ipw_priv *priv, 5668static int ipw_best_network(struct ipw_priv *priv,
5650 struct ipw_network_match *match, 5669 struct ipw_network_match *match,
5651 struct ieee80211_network *network, int roaming) 5670 struct libipw_network *network, int roaming)
5652{ 5671{
5653 struct ipw_supported_rates rates; 5672 struct ipw_supported_rates rates;
5654 DECLARE_SSID_BUF(ssid); 5673 DECLARE_SSID_BUF(ssid);
@@ -5782,7 +5801,7 @@ static int ipw_best_network(struct ipw_priv *priv,
5782 } 5801 }
5783 5802
5784 /* Filter out any incompatible freq / mode combinations */ 5803 /* Filter out any incompatible freq / mode combinations */
5785 if (!ieee80211_is_valid_mode(priv->ieee, network->mode)) { 5804 if (!libipw_is_valid_mode(priv->ieee, network->mode)) {
5786 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded " 5805 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5787 "because of invalid frequency/mode " 5806 "because of invalid frequency/mode "
5788 "combination.\n", 5807 "combination.\n",
@@ -5793,7 +5812,7 @@ static int ipw_best_network(struct ipw_priv *priv,
5793 } 5812 }
5794 5813
5795 /* Filter out invalid channel in current GEO */ 5814 /* Filter out invalid channel in current GEO */
5796 if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) { 5815 if (!libipw_is_valid_channel(priv->ieee, network->channel)) {
5797 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded " 5816 IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
5798 "because of invalid channel in current GEO\n", 5817 "because of invalid channel in current GEO\n",
5799 print_ssid(ssid, network->ssid, 5818 print_ssid(ssid, network->ssid,
@@ -5839,9 +5858,9 @@ static int ipw_best_network(struct ipw_priv *priv,
5839} 5858}
5840 5859
5841static void ipw_adhoc_create(struct ipw_priv *priv, 5860static void ipw_adhoc_create(struct ipw_priv *priv,
5842 struct ieee80211_network *network) 5861 struct libipw_network *network)
5843{ 5862{
5844 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee); 5863 const struct libipw_geo *geo = libipw_get_geo(priv->ieee);
5845 int i; 5864 int i;
5846 5865
5847 /* 5866 /*
@@ -5856,25 +5875,25 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
5856 * FW fatal error. 5875 * FW fatal error.
5857 * 5876 *
5858 */ 5877 */
5859 switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) { 5878 switch (libipw_is_valid_channel(priv->ieee, priv->channel)) {
5860 case IEEE80211_52GHZ_BAND: 5879 case LIBIPW_52GHZ_BAND:
5861 network->mode = IEEE_A; 5880 network->mode = IEEE_A;
5862 i = ieee80211_channel_to_index(priv->ieee, priv->channel); 5881 i = libipw_channel_to_index(priv->ieee, priv->channel);
5863 BUG_ON(i == -1); 5882 BUG_ON(i == -1);
5864 if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) { 5883 if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY) {
5865 IPW_WARNING("Overriding invalid channel\n"); 5884 IPW_WARNING("Overriding invalid channel\n");
5866 priv->channel = geo->a[0].channel; 5885 priv->channel = geo->a[0].channel;
5867 } 5886 }
5868 break; 5887 break;
5869 5888
5870 case IEEE80211_24GHZ_BAND: 5889 case LIBIPW_24GHZ_BAND:
5871 if (priv->ieee->mode & IEEE_G) 5890 if (priv->ieee->mode & IEEE_G)
5872 network->mode = IEEE_G; 5891 network->mode = IEEE_G;
5873 else 5892 else
5874 network->mode = IEEE_B; 5893 network->mode = IEEE_B;
5875 i = ieee80211_channel_to_index(priv->ieee, priv->channel); 5894 i = libipw_channel_to_index(priv->ieee, priv->channel);
5876 BUG_ON(i == -1); 5895 BUG_ON(i == -1);
5877 if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) { 5896 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY) {
5878 IPW_WARNING("Overriding invalid channel\n"); 5897 IPW_WARNING("Overriding invalid channel\n");
5879 priv->channel = geo->bg[0].channel; 5898 priv->channel = geo->bg[0].channel;
5880 } 5899 }
@@ -6110,9 +6129,9 @@ static void ipw_set_fixed_rate(struct ipw_priv *priv, int mode)
6110 * Tx rates */ 6129 * Tx rates */
6111 6130
6112 switch (priv->ieee->freq_band) { 6131 switch (priv->ieee->freq_band) {
6113 case IEEE80211_52GHZ_BAND: /* A only */ 6132 case LIBIPW_52GHZ_BAND: /* A only */
6114 /* IEEE_A */ 6133 /* IEEE_A */
6115 if (priv->rates_mask & ~IEEE80211_OFDM_RATES_MASK) { 6134 if (priv->rates_mask & ~LIBIPW_OFDM_RATES_MASK) {
6116 /* Invalid fixed rate mask */ 6135 /* Invalid fixed rate mask */
6117 IPW_DEBUG_WX 6136 IPW_DEBUG_WX
6118 ("invalid fixed rate mask in ipw_set_fixed_rate\n"); 6137 ("invalid fixed rate mask in ipw_set_fixed_rate\n");
@@ -6120,13 +6139,13 @@ static void ipw_set_fixed_rate(struct ipw_priv *priv, int mode)
6120 break; 6139 break;
6121 } 6140 }
6122 6141
6123 new_tx_rates >>= IEEE80211_OFDM_SHIFT_MASK_A; 6142 new_tx_rates >>= LIBIPW_OFDM_SHIFT_MASK_A;
6124 break; 6143 break;
6125 6144
6126 default: /* 2.4Ghz or Mixed */ 6145 default: /* 2.4Ghz or Mixed */
6127 /* IEEE_B */ 6146 /* IEEE_B */
6128 if (mode == IEEE_B) { 6147 if (mode == IEEE_B) {
6129 if (new_tx_rates & ~IEEE80211_CCK_RATES_MASK) { 6148 if (new_tx_rates & ~LIBIPW_CCK_RATES_MASK) {
6130 /* Invalid fixed rate mask */ 6149 /* Invalid fixed rate mask */
6131 IPW_DEBUG_WX 6150 IPW_DEBUG_WX
6132 ("invalid fixed rate mask in ipw_set_fixed_rate\n"); 6151 ("invalid fixed rate mask in ipw_set_fixed_rate\n");
@@ -6136,8 +6155,8 @@ static void ipw_set_fixed_rate(struct ipw_priv *priv, int mode)
6136 } 6155 }
6137 6156
6138 /* IEEE_G */ 6157 /* IEEE_G */
6139 if (new_tx_rates & ~(IEEE80211_CCK_RATES_MASK | 6158 if (new_tx_rates & ~(LIBIPW_CCK_RATES_MASK |
6140 IEEE80211_OFDM_RATES_MASK)) { 6159 LIBIPW_OFDM_RATES_MASK)) {
6141 /* Invalid fixed rate mask */ 6160 /* Invalid fixed rate mask */
6142 IPW_DEBUG_WX 6161 IPW_DEBUG_WX
6143 ("invalid fixed rate mask in ipw_set_fixed_rate\n"); 6162 ("invalid fixed rate mask in ipw_set_fixed_rate\n");
@@ -6145,19 +6164,19 @@ static void ipw_set_fixed_rate(struct ipw_priv *priv, int mode)
6145 break; 6164 break;
6146 } 6165 }
6147 6166
6148 if (IEEE80211_OFDM_RATE_6MB_MASK & new_tx_rates) { 6167 if (LIBIPW_OFDM_RATE_6MB_MASK & new_tx_rates) {
6149 mask |= (IEEE80211_OFDM_RATE_6MB_MASK >> 1); 6168 mask |= (LIBIPW_OFDM_RATE_6MB_MASK >> 1);
6150 new_tx_rates &= ~IEEE80211_OFDM_RATE_6MB_MASK; 6169 new_tx_rates &= ~LIBIPW_OFDM_RATE_6MB_MASK;
6151 } 6170 }
6152 6171
6153 if (IEEE80211_OFDM_RATE_9MB_MASK & new_tx_rates) { 6172 if (LIBIPW_OFDM_RATE_9MB_MASK & new_tx_rates) {
6154 mask |= (IEEE80211_OFDM_RATE_9MB_MASK >> 1); 6173 mask |= (LIBIPW_OFDM_RATE_9MB_MASK >> 1);
6155 new_tx_rates &= ~IEEE80211_OFDM_RATE_9MB_MASK; 6174 new_tx_rates &= ~LIBIPW_OFDM_RATE_9MB_MASK;
6156 } 6175 }
6157 6176
6158 if (IEEE80211_OFDM_RATE_12MB_MASK & new_tx_rates) { 6177 if (LIBIPW_OFDM_RATE_12MB_MASK & new_tx_rates) {
6159 mask |= (IEEE80211_OFDM_RATE_12MB_MASK >> 1); 6178 mask |= (LIBIPW_OFDM_RATE_12MB_MASK >> 1);
6160 new_tx_rates &= ~IEEE80211_OFDM_RATE_12MB_MASK; 6179 new_tx_rates &= ~LIBIPW_OFDM_RATE_12MB_MASK;
6161 } 6180 }
6162 6181
6163 new_tx_rates |= mask; 6182 new_tx_rates |= mask;
@@ -6190,12 +6209,12 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6190 int scan_type) 6209 int scan_type)
6191{ 6210{
6192 int channel_index = 0; 6211 int channel_index = 0;
6193 const struct ieee80211_geo *geo; 6212 const struct libipw_geo *geo;
6194 int i; 6213 int i;
6195 6214
6196 geo = ieee80211_get_geo(priv->ieee); 6215 geo = libipw_get_geo(priv->ieee);
6197 6216
6198 if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { 6217 if (priv->ieee->freq_band & LIBIPW_52GHZ_BAND) {
6199 int start = channel_index; 6218 int start = channel_index;
6200 for (i = 0; i < geo->a_channels; i++) { 6219 for (i = 0; i < geo->a_channels; i++) {
6201 if ((priv->status & STATUS_ASSOCIATED) && 6220 if ((priv->status & STATUS_ASSOCIATED) &&
@@ -6205,7 +6224,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6205 scan->channels_list[channel_index] = geo->a[i].channel; 6224 scan->channels_list[channel_index] = geo->a[i].channel;
6206 ipw_set_scan_type(scan, channel_index, 6225 ipw_set_scan_type(scan, channel_index,
6207 geo->a[i]. 6226 geo->a[i].
6208 flags & IEEE80211_CH_PASSIVE_ONLY ? 6227 flags & LIBIPW_CH_PASSIVE_ONLY ?
6209 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN : 6228 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN :
6210 scan_type); 6229 scan_type);
6211 } 6230 }
@@ -6217,11 +6236,11 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6217 } 6236 }
6218 } 6237 }
6219 6238
6220 if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) { 6239 if (priv->ieee->freq_band & LIBIPW_24GHZ_BAND) {
6221 int start = channel_index; 6240 int start = channel_index;
6222 if (priv->config & CFG_SPEED_SCAN) { 6241 if (priv->config & CFG_SPEED_SCAN) {
6223 int index; 6242 int index;
6224 u8 channels[IEEE80211_24GHZ_CHANNELS] = { 6243 u8 channels[LIBIPW_24GHZ_CHANNELS] = {
6225 /* nop out the list */ 6244 /* nop out the list */
6226 [0] = 0 6245 [0] = 0
6227 }; 6246 };
@@ -6253,11 +6272,11 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6253 channel_index++; 6272 channel_index++;
6254 scan->channels_list[channel_index] = channel; 6273 scan->channels_list[channel_index] = channel;
6255 index = 6274 index =
6256 ieee80211_channel_to_index(priv->ieee, channel); 6275 libipw_channel_to_index(priv->ieee, channel);
6257 ipw_set_scan_type(scan, channel_index, 6276 ipw_set_scan_type(scan, channel_index,
6258 geo->bg[index]. 6277 geo->bg[index].
6259 flags & 6278 flags &
6260 IEEE80211_CH_PASSIVE_ONLY ? 6279 LIBIPW_CH_PASSIVE_ONLY ?
6261 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN 6280 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
6262 : scan_type); 6281 : scan_type);
6263 } 6282 }
@@ -6272,7 +6291,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6272 ipw_set_scan_type(scan, channel_index, 6291 ipw_set_scan_type(scan, channel_index,
6273 geo->bg[i]. 6292 geo->bg[i].
6274 flags & 6293 flags &
6275 IEEE80211_CH_PASSIVE_ONLY ? 6294 LIBIPW_CH_PASSIVE_ONLY ?
6276 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN 6295 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
6277 : scan_type); 6296 : scan_type);
6278 } 6297 }
@@ -6339,7 +6358,7 @@ static int ipw_request_scan_helper(struct ipw_priv *priv, int type, int direct)
6339 } 6358 }
6340 6359
6341 memset(&scan, 0, sizeof(scan)); 6360 memset(&scan, 0, sizeof(scan));
6342 scan.full_scan_index = cpu_to_le32(ieee80211_get_scans(priv->ieee)); 6361 scan.full_scan_index = cpu_to_le32(libipw_get_scans(priv->ieee));
6343 6362
6344 if (type == IW_SCAN_TYPE_PASSIVE) { 6363 if (type == IW_SCAN_TYPE_PASSIVE) {
6345 IPW_DEBUG_WX("use passive scanning\n"); 6364 IPW_DEBUG_WX("use passive scanning\n");
@@ -6370,13 +6389,13 @@ static int ipw_request_scan_helper(struct ipw_priv *priv, int type, int direct)
6370 u8 channel; 6389 u8 channel;
6371 u8 band = 0; 6390 u8 band = 0;
6372 6391
6373 switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) { 6392 switch (libipw_is_valid_channel(priv->ieee, priv->channel)) {
6374 case IEEE80211_52GHZ_BAND: 6393 case LIBIPW_52GHZ_BAND:
6375 band = (u8) (IPW_A_MODE << 6) | 1; 6394 band = (u8) (IPW_A_MODE << 6) | 1;
6376 channel = priv->channel; 6395 channel = priv->channel;
6377 break; 6396 break;
6378 6397
6379 case IEEE80211_24GHZ_BAND: 6398 case LIBIPW_24GHZ_BAND:
6380 band = (u8) (IPW_B_MODE << 6) | 1; 6399 band = (u8) (IPW_B_MODE << 6) | 1;
6381 channel = priv->channel; 6400 channel = priv->channel;
6382 break; 6401 break;
@@ -6497,8 +6516,8 @@ static int ipw_wpa_enable(struct ipw_priv *priv, int value)
6497 6516
6498static int ipw_wpa_set_auth_algs(struct ipw_priv *priv, int value) 6517static int ipw_wpa_set_auth_algs(struct ipw_priv *priv, int value)
6499{ 6518{
6500 struct ieee80211_device *ieee = priv->ieee; 6519 struct libipw_device *ieee = priv->ieee;
6501 struct ieee80211_security sec = { 6520 struct libipw_security sec = {
6502 .flags = SEC_AUTH_MODE, 6521 .flags = SEC_AUTH_MODE,
6503 }; 6522 };
6504 int ret = 0; 6523 int ret = 0;
@@ -6548,8 +6567,8 @@ static int ipw_wx_set_genie(struct net_device *dev,
6548 struct iw_request_info *info, 6567 struct iw_request_info *info,
6549 union iwreq_data *wrqu, char *extra) 6568 union iwreq_data *wrqu, char *extra)
6550{ 6569{
6551 struct ipw_priv *priv = ieee80211_priv(dev); 6570 struct ipw_priv *priv = libipw_priv(dev);
6552 struct ieee80211_device *ieee = priv->ieee; 6571 struct libipw_device *ieee = priv->ieee;
6553 u8 *buf; 6572 u8 *buf;
6554 int err = 0; 6573 int err = 0;
6555 6574
@@ -6584,8 +6603,8 @@ static int ipw_wx_get_genie(struct net_device *dev,
6584 struct iw_request_info *info, 6603 struct iw_request_info *info,
6585 union iwreq_data *wrqu, char *extra) 6604 union iwreq_data *wrqu, char *extra)
6586{ 6605{
6587 struct ipw_priv *priv = ieee80211_priv(dev); 6606 struct ipw_priv *priv = libipw_priv(dev);
6588 struct ieee80211_device *ieee = priv->ieee; 6607 struct libipw_device *ieee = priv->ieee;
6589 int err = 0; 6608 int err = 0;
6590 6609
6591 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { 6610 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
@@ -6627,8 +6646,8 @@ static int ipw_wx_set_auth(struct net_device *dev,
6627 struct iw_request_info *info, 6646 struct iw_request_info *info,
6628 union iwreq_data *wrqu, char *extra) 6647 union iwreq_data *wrqu, char *extra)
6629{ 6648{
6630 struct ipw_priv *priv = ieee80211_priv(dev); 6649 struct ipw_priv *priv = libipw_priv(dev);
6631 struct ieee80211_device *ieee = priv->ieee; 6650 struct libipw_device *ieee = priv->ieee;
6632 struct iw_param *param = &wrqu->param; 6651 struct iw_param *param = &wrqu->param;
6633 struct lib80211_crypt_data *crypt; 6652 struct lib80211_crypt_data *crypt;
6634 unsigned long flags; 6653 unsigned long flags;
@@ -6679,7 +6698,7 @@ static int ipw_wx_set_auth(struct net_device *dev,
6679 * can use this to determine if the CAP_PRIVACY_ON bit should 6698 * can use this to determine if the CAP_PRIVACY_ON bit should
6680 * be set. 6699 * be set.
6681 */ 6700 */
6682 struct ieee80211_security sec = { 6701 struct libipw_security sec = {
6683 .flags = SEC_ENABLED, 6702 .flags = SEC_ENABLED,
6684 .enabled = param->value, 6703 .enabled = param->value,
6685 }; 6704 };
@@ -6727,8 +6746,8 @@ static int ipw_wx_get_auth(struct net_device *dev,
6727 struct iw_request_info *info, 6746 struct iw_request_info *info,
6728 union iwreq_data *wrqu, char *extra) 6747 union iwreq_data *wrqu, char *extra)
6729{ 6748{
6730 struct ipw_priv *priv = ieee80211_priv(dev); 6749 struct ipw_priv *priv = libipw_priv(dev);
6731 struct ieee80211_device *ieee = priv->ieee; 6750 struct libipw_device *ieee = priv->ieee;
6732 struct lib80211_crypt_data *crypt; 6751 struct lib80211_crypt_data *crypt;
6733 struct iw_param *param = &wrqu->param; 6752 struct iw_param *param = &wrqu->param;
6734 int ret = 0; 6753 int ret = 0;
@@ -6786,7 +6805,7 @@ static int ipw_wx_set_encodeext(struct net_device *dev,
6786 struct iw_request_info *info, 6805 struct iw_request_info *info,
6787 union iwreq_data *wrqu, char *extra) 6806 union iwreq_data *wrqu, char *extra)
6788{ 6807{
6789 struct ipw_priv *priv = ieee80211_priv(dev); 6808 struct ipw_priv *priv = libipw_priv(dev);
6790 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 6809 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6791 6810
6792 if (hwcrypto) { 6811 if (hwcrypto) {
@@ -6808,7 +6827,7 @@ static int ipw_wx_set_encodeext(struct net_device *dev,
6808 } 6827 }
6809 } 6828 }
6810 6829
6811 return ieee80211_wx_set_encodeext(priv->ieee, info, wrqu, extra); 6830 return libipw_wx_set_encodeext(priv->ieee, info, wrqu, extra);
6812} 6831}
6813 6832
6814/* SIOCGIWENCODEEXT */ 6833/* SIOCGIWENCODEEXT */
@@ -6816,8 +6835,8 @@ static int ipw_wx_get_encodeext(struct net_device *dev,
6816 struct iw_request_info *info, 6835 struct iw_request_info *info,
6817 union iwreq_data *wrqu, char *extra) 6836 union iwreq_data *wrqu, char *extra)
6818{ 6837{
6819 struct ipw_priv *priv = ieee80211_priv(dev); 6838 struct ipw_priv *priv = libipw_priv(dev);
6820 return ieee80211_wx_get_encodeext(priv->ieee, info, wrqu, extra); 6839 return libipw_wx_get_encodeext(priv->ieee, info, wrqu, extra);
6821} 6840}
6822 6841
6823/* SIOCSIWMLME */ 6842/* SIOCSIWMLME */
@@ -6825,7 +6844,7 @@ static int ipw_wx_set_mlme(struct net_device *dev,
6825 struct iw_request_info *info, 6844 struct iw_request_info *info,
6826 union iwreq_data *wrqu, char *extra) 6845 union iwreq_data *wrqu, char *extra)
6827{ 6846{
6828 struct ipw_priv *priv = ieee80211_priv(dev); 6847 struct ipw_priv *priv = libipw_priv(dev);
6829 struct iw_mlme *mlme = (struct iw_mlme *)extra; 6848 struct iw_mlme *mlme = (struct iw_mlme *)extra;
6830 __le16 reason; 6849 __le16 reason;
6831 6850
@@ -6875,9 +6894,9 @@ static u8 ipw_qos_current_mode(struct ipw_priv * priv)
6875*/ 6894*/
6876static int ipw_qos_handle_probe_response(struct ipw_priv *priv, 6895static int ipw_qos_handle_probe_response(struct ipw_priv *priv,
6877 int active_network, 6896 int active_network,
6878 struct ieee80211_network *network) 6897 struct libipw_network *network)
6879{ 6898{
6880 u32 size = sizeof(struct ieee80211_qos_parameters); 6899 u32 size = sizeof(struct libipw_qos_parameters);
6881 6900
6882 if (network->capability & WLAN_CAPABILITY_IBSS) 6901 if (network->capability & WLAN_CAPABILITY_IBSS)
6883 network->qos_data.active = network->qos_data.supported; 6902 network->qos_data.active = network->qos_data.supported;
@@ -6935,12 +6954,12 @@ static int ipw_qos_handle_probe_response(struct ipw_priv *priv,
6935* IPW_CMD_QOS_PARAMETERS and IPW_CMD_WME_INFO 6954* IPW_CMD_QOS_PARAMETERS and IPW_CMD_WME_INFO
6936*/ 6955*/
6937static int ipw_qos_activate(struct ipw_priv *priv, 6956static int ipw_qos_activate(struct ipw_priv *priv,
6938 struct ieee80211_qos_data *qos_network_data) 6957 struct libipw_qos_data *qos_network_data)
6939{ 6958{
6940 int err; 6959 int err;
6941 struct ieee80211_qos_parameters qos_parameters[QOS_QOS_SETS]; 6960 struct libipw_qos_parameters qos_parameters[QOS_QOS_SETS];
6942 struct ieee80211_qos_parameters *active_one = NULL; 6961 struct libipw_qos_parameters *active_one = NULL;
6943 u32 size = sizeof(struct ieee80211_qos_parameters); 6962 u32 size = sizeof(struct libipw_qos_parameters);
6944 u32 burst_duration; 6963 u32 burst_duration;
6945 int i; 6964 int i;
6946 u8 type; 6965 u8 type;
@@ -7001,7 +7020,7 @@ static int ipw_qos_activate(struct ipw_priv *priv,
7001 7020
7002 IPW_DEBUG_QOS("QoS sending IPW_CMD_QOS_PARAMETERS\n"); 7021 IPW_DEBUG_QOS("QoS sending IPW_CMD_QOS_PARAMETERS\n");
7003 err = ipw_send_qos_params_command(priv, 7022 err = ipw_send_qos_params_command(priv,
7004 (struct ieee80211_qos_parameters *) 7023 (struct libipw_qos_parameters *)
7005 &(qos_parameters[0])); 7024 &(qos_parameters[0]));
7006 if (err) 7025 if (err)
7007 IPW_DEBUG_QOS("QoS IPW_CMD_QOS_PARAMETERS failed\n"); 7026 IPW_DEBUG_QOS("QoS IPW_CMD_QOS_PARAMETERS failed\n");
@@ -7015,13 +7034,13 @@ static int ipw_qos_activate(struct ipw_priv *priv,
7015static int ipw_qos_set_info_element(struct ipw_priv *priv) 7034static int ipw_qos_set_info_element(struct ipw_priv *priv)
7016{ 7035{
7017 int ret = 0; 7036 int ret = 0;
7018 struct ieee80211_qos_information_element qos_info; 7037 struct libipw_qos_information_element qos_info;
7019 7038
7020 if (priv == NULL) 7039 if (priv == NULL)
7021 return -1; 7040 return -1;
7022 7041
7023 qos_info.elementID = QOS_ELEMENT_ID; 7042 qos_info.elementID = QOS_ELEMENT_ID;
7024 qos_info.length = sizeof(struct ieee80211_qos_information_element) - 2; 7043 qos_info.length = sizeof(struct libipw_qos_information_element) - 2;
7025 7044
7026 qos_info.version = QOS_VERSION_1; 7045 qos_info.version = QOS_VERSION_1;
7027 qos_info.ac_info = 0; 7046 qos_info.ac_info = 0;
@@ -7041,11 +7060,11 @@ static int ipw_qos_set_info_element(struct ipw_priv *priv)
7041* Set the QoS parameter with the association request structure 7060* Set the QoS parameter with the association request structure
7042*/ 7061*/
7043static int ipw_qos_association(struct ipw_priv *priv, 7062static int ipw_qos_association(struct ipw_priv *priv,
7044 struct ieee80211_network *network) 7063 struct libipw_network *network)
7045{ 7064{
7046 int err = 0; 7065 int err = 0;
7047 struct ieee80211_qos_data *qos_data = NULL; 7066 struct libipw_qos_data *qos_data = NULL;
7048 struct ieee80211_qos_data ibss_data = { 7067 struct libipw_qos_data ibss_data = {
7049 .supported = 1, 7068 .supported = 1,
7050 .active = 1, 7069 .active = 1,
7051 }; 7070 };
@@ -7087,11 +7106,11 @@ static int ipw_qos_association(struct ipw_priv *priv,
7087* setting 7106* setting
7088*/ 7107*/
7089static int ipw_qos_association_resp(struct ipw_priv *priv, 7108static int ipw_qos_association_resp(struct ipw_priv *priv,
7090 struct ieee80211_network *network) 7109 struct libipw_network *network)
7091{ 7110{
7092 int ret = 0; 7111 int ret = 0;
7093 unsigned long flags; 7112 unsigned long flags;
7094 u32 size = sizeof(struct ieee80211_qos_parameters); 7113 u32 size = sizeof(struct libipw_qos_parameters);
7095 int set_qos_param = 0; 7114 int set_qos_param = 0;
7096 7115
7097 if ((priv == NULL) || (network == NULL) || 7116 if ((priv == NULL) || (network == NULL) ||
@@ -7107,7 +7126,7 @@ static int ipw_qos_association_resp(struct ipw_priv *priv,
7107 spin_lock_irqsave(&priv->ieee->lock, flags); 7126 spin_lock_irqsave(&priv->ieee->lock, flags);
7108 if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { 7127 if (network->flags & NETWORK_HAS_QOS_PARAMETERS) {
7109 memcpy(&priv->assoc_network->qos_data, &network->qos_data, 7128 memcpy(&priv->assoc_network->qos_data, &network->qos_data,
7110 sizeof(struct ieee80211_qos_data)); 7129 sizeof(struct libipw_qos_data));
7111 priv->assoc_network->qos_data.active = 1; 7130 priv->assoc_network->qos_data.active = 1;
7112 if ((network->qos_data.old_param_count != 7131 if ((network->qos_data.old_param_count !=
7113 network->qos_data.param_count)) { 7132 network->qos_data.param_count)) {
@@ -7143,7 +7162,7 @@ static u32 ipw_qos_get_burst_duration(struct ipw_priv *priv)
7143 if ((priv == NULL)) 7162 if ((priv == NULL))
7144 return 0; 7163 return 0;
7145 7164
7146 if (!(priv->ieee->modulation & IEEE80211_OFDM_MODULATION)) 7165 if (!(priv->ieee->modulation & LIBIPW_OFDM_MODULATION))
7147 ret = priv->qos_data.burst_duration_CCK; 7166 ret = priv->qos_data.burst_duration_CCK;
7148 else 7167 else
7149 ret = priv->qos_data.burst_duration_OFDM; 7168 ret = priv->qos_data.burst_duration_OFDM;
@@ -7195,8 +7214,8 @@ static int ipw_get_tx_queue_number(struct ipw_priv *priv, u16 priority)
7195static int ipw_is_qos_active(struct net_device *dev, 7214static int ipw_is_qos_active(struct net_device *dev,
7196 struct sk_buff *skb) 7215 struct sk_buff *skb)
7197{ 7216{
7198 struct ipw_priv *priv = ieee80211_priv(dev); 7217 struct ipw_priv *priv = libipw_priv(dev);
7199 struct ieee80211_qos_data *qos_data = NULL; 7218 struct libipw_qos_data *qos_data = NULL;
7200 int active, supported; 7219 int active, supported;
7201 u8 *daddr = skb->data + ETH_ALEN; 7220 u8 *daddr = skb->data + ETH_ALEN;
7202 int unicast = !is_multicast_ether_addr(daddr); 7221 int unicast = !is_multicast_ether_addr(daddr);
@@ -7260,10 +7279,10 @@ static void ipw_bg_qos_activate(struct work_struct *work)
7260} 7279}
7261 7280
7262static int ipw_handle_probe_response(struct net_device *dev, 7281static int ipw_handle_probe_response(struct net_device *dev,
7263 struct ieee80211_probe_response *resp, 7282 struct libipw_probe_response *resp,
7264 struct ieee80211_network *network) 7283 struct libipw_network *network)
7265{ 7284{
7266 struct ipw_priv *priv = ieee80211_priv(dev); 7285 struct ipw_priv *priv = libipw_priv(dev);
7267 int active_network = ((priv->status & STATUS_ASSOCIATED) && 7286 int active_network = ((priv->status & STATUS_ASSOCIATED) &&
7268 (network == priv->assoc_network)); 7287 (network == priv->assoc_network));
7269 7288
@@ -7273,10 +7292,10 @@ static int ipw_handle_probe_response(struct net_device *dev,
7273} 7292}
7274 7293
7275static int ipw_handle_beacon(struct net_device *dev, 7294static int ipw_handle_beacon(struct net_device *dev,
7276 struct ieee80211_beacon *resp, 7295 struct libipw_beacon *resp,
7277 struct ieee80211_network *network) 7296 struct libipw_network *network)
7278{ 7297{
7279 struct ipw_priv *priv = ieee80211_priv(dev); 7298 struct ipw_priv *priv = libipw_priv(dev);
7280 int active_network = ((priv->status & STATUS_ASSOCIATED) && 7299 int active_network = ((priv->status & STATUS_ASSOCIATED) &&
7281 (network == priv->assoc_network)); 7300 (network == priv->assoc_network));
7282 7301
@@ -7286,22 +7305,22 @@ static int ipw_handle_beacon(struct net_device *dev,
7286} 7305}
7287 7306
7288static int ipw_handle_assoc_response(struct net_device *dev, 7307static int ipw_handle_assoc_response(struct net_device *dev,
7289 struct ieee80211_assoc_response *resp, 7308 struct libipw_assoc_response *resp,
7290 struct ieee80211_network *network) 7309 struct libipw_network *network)
7291{ 7310{
7292 struct ipw_priv *priv = ieee80211_priv(dev); 7311 struct ipw_priv *priv = libipw_priv(dev);
7293 ipw_qos_association_resp(priv, network); 7312 ipw_qos_association_resp(priv, network);
7294 return 0; 7313 return 0;
7295} 7314}
7296 7315
7297static int ipw_send_qos_params_command(struct ipw_priv *priv, struct ieee80211_qos_parameters 7316static int ipw_send_qos_params_command(struct ipw_priv *priv, struct libipw_qos_parameters
7298 *qos_param) 7317 *qos_param)
7299{ 7318{
7300 return ipw_send_cmd_pdu(priv, IPW_CMD_QOS_PARAMETERS, 7319 return ipw_send_cmd_pdu(priv, IPW_CMD_QOS_PARAMETERS,
7301 sizeof(*qos_param) * 3, qos_param); 7320 sizeof(*qos_param) * 3, qos_param);
7302} 7321}
7303 7322
7304static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element 7323static int ipw_send_qos_info_command(struct ipw_priv *priv, struct libipw_qos_information_element
7305 *qos_param) 7324 *qos_param)
7306{ 7325{
7307 return ipw_send_cmd_pdu(priv, IPW_CMD_WME_INFO, sizeof(*qos_param), 7326 return ipw_send_cmd_pdu(priv, IPW_CMD_WME_INFO, sizeof(*qos_param),
@@ -7311,7 +7330,7 @@ static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos
7311#endif /* CONFIG_IPW2200_QOS */ 7330#endif /* CONFIG_IPW2200_QOS */
7312 7331
7313static int ipw_associate_network(struct ipw_priv *priv, 7332static int ipw_associate_network(struct ipw_priv *priv,
7314 struct ieee80211_network *network, 7333 struct libipw_network *network,
7315 struct ipw_supported_rates *rates, int roaming) 7334 struct ipw_supported_rates *rates, int roaming)
7316{ 7335{
7317 int err; 7336 int err;
@@ -7493,7 +7512,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
7493static void ipw_roam(void *data) 7512static void ipw_roam(void *data)
7494{ 7513{
7495 struct ipw_priv *priv = data; 7514 struct ipw_priv *priv = data;
7496 struct ieee80211_network *network = NULL; 7515 struct libipw_network *network = NULL;
7497 struct ipw_network_match match = { 7516 struct ipw_network_match match = {
7498 .network = priv->assoc_network 7517 .network = priv->assoc_network
7499 }; 7518 };
@@ -7568,7 +7587,7 @@ static int ipw_associate(void *data)
7568{ 7587{
7569 struct ipw_priv *priv = data; 7588 struct ipw_priv *priv = data;
7570 7589
7571 struct ieee80211_network *network = NULL; 7590 struct libipw_network *network = NULL;
7572 struct ipw_network_match match = { 7591 struct ipw_network_match match = {
7573 .network = NULL 7592 .network = NULL
7574 }; 7593 };
@@ -7622,8 +7641,8 @@ static int ipw_associate(void *data)
7622 priv->config & CFG_STATIC_CHANNEL) { 7641 priv->config & CFG_STATIC_CHANNEL) {
7623 /* Use oldest network if the free list is empty */ 7642 /* Use oldest network if the free list is empty */
7624 if (list_empty(&priv->ieee->network_free_list)) { 7643 if (list_empty(&priv->ieee->network_free_list)) {
7625 struct ieee80211_network *oldest = NULL; 7644 struct libipw_network *oldest = NULL;
7626 struct ieee80211_network *target; 7645 struct libipw_network *target;
7627 7646
7628 list_for_each_entry(target, &priv->ieee->network_list, list) { 7647 list_for_each_entry(target, &priv->ieee->network_list, list) {
7629 if ((oldest == NULL) || 7648 if ((oldest == NULL) ||
@@ -7644,7 +7663,7 @@ static int ipw_associate(void *data)
7644 } 7663 }
7645 7664
7646 element = priv->ieee->network_free_list.next; 7665 element = priv->ieee->network_free_list.next;
7647 network = list_entry(element, struct ieee80211_network, list); 7666 network = list_entry(element, struct libipw_network, list);
7648 ipw_adhoc_create(priv, network); 7667 ipw_adhoc_create(priv, network);
7649 rates = &priv->rates; 7668 rates = &priv->rates;
7650 list_del(element); 7669 list_del(element);
@@ -7700,18 +7719,18 @@ static void ipw_rebuild_decrypted_skb(struct ipw_priv *priv,
7700 switch (priv->ieee->sec.level) { 7719 switch (priv->ieee->sec.level) {
7701 case SEC_LEVEL_3: 7720 case SEC_LEVEL_3:
7702 /* Remove CCMP HDR */ 7721 /* Remove CCMP HDR */
7703 memmove(skb->data + IEEE80211_3ADDR_LEN, 7722 memmove(skb->data + LIBIPW_3ADDR_LEN,
7704 skb->data + IEEE80211_3ADDR_LEN + 8, 7723 skb->data + LIBIPW_3ADDR_LEN + 8,
7705 skb->len - IEEE80211_3ADDR_LEN - 8); 7724 skb->len - LIBIPW_3ADDR_LEN - 8);
7706 skb_trim(skb, skb->len - 16); /* CCMP_HDR_LEN + CCMP_MIC_LEN */ 7725 skb_trim(skb, skb->len - 16); /* CCMP_HDR_LEN + CCMP_MIC_LEN */
7707 break; 7726 break;
7708 case SEC_LEVEL_2: 7727 case SEC_LEVEL_2:
7709 break; 7728 break;
7710 case SEC_LEVEL_1: 7729 case SEC_LEVEL_1:
7711 /* Remove IV */ 7730 /* Remove IV */
7712 memmove(skb->data + IEEE80211_3ADDR_LEN, 7731 memmove(skb->data + LIBIPW_3ADDR_LEN,
7713 skb->data + IEEE80211_3ADDR_LEN + 4, 7732 skb->data + LIBIPW_3ADDR_LEN + 4,
7714 skb->len - IEEE80211_3ADDR_LEN - 4); 7733 skb->len - LIBIPW_3ADDR_LEN - 4);
7715 skb_trim(skb, skb->len - 8); /* IV + ICV */ 7734 skb_trim(skb, skb->len - 8); /* IV + ICV */
7716 break; 7735 break;
7717 case SEC_LEVEL_0: 7736 case SEC_LEVEL_0:
@@ -7725,10 +7744,10 @@ static void ipw_rebuild_decrypted_skb(struct ipw_priv *priv,
7725 7744
7726static void ipw_handle_data_packet(struct ipw_priv *priv, 7745static void ipw_handle_data_packet(struct ipw_priv *priv,
7727 struct ipw_rx_mem_buffer *rxb, 7746 struct ipw_rx_mem_buffer *rxb,
7728 struct ieee80211_rx_stats *stats) 7747 struct libipw_rx_stats *stats)
7729{ 7748{
7730 struct net_device *dev = priv->net_dev; 7749 struct net_device *dev = priv->net_dev;
7731 struct ieee80211_hdr_4addr *hdr; 7750 struct libipw_hdr_4addr *hdr;
7732 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; 7751 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
7733 7752
7734 /* We received data from the HW, so stop the watchdog */ 7753 /* We received data from the HW, so stop the watchdog */
@@ -7758,15 +7777,15 @@ static void ipw_handle_data_packet(struct ipw_priv *priv,
7758 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len); 7777 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len);
7759 7778
7760 /* HW decrypt will not clear the WEP bit, MIC, PN, etc. */ 7779 /* HW decrypt will not clear the WEP bit, MIC, PN, etc. */
7761 hdr = (struct ieee80211_hdr_4addr *)rxb->skb->data; 7780 hdr = (struct libipw_hdr_4addr *)rxb->skb->data;
7762 if (priv->ieee->iw_mode != IW_MODE_MONITOR && 7781 if (priv->ieee->iw_mode != IW_MODE_MONITOR &&
7763 (is_multicast_ether_addr(hdr->addr1) ? 7782 (is_multicast_ether_addr(hdr->addr1) ?
7764 !priv->ieee->host_mc_decrypt : !priv->ieee->host_decrypt)) 7783 !priv->ieee->host_mc_decrypt : !priv->ieee->host_decrypt))
7765 ipw_rebuild_decrypted_skb(priv, rxb->skb); 7784 ipw_rebuild_decrypted_skb(priv, rxb->skb);
7766 7785
7767 if (!ieee80211_rx(priv->ieee, rxb->skb, stats)) 7786 if (!libipw_rx(priv->ieee, rxb->skb, stats))
7768 dev->stats.rx_errors++; 7787 dev->stats.rx_errors++;
7769 else { /* ieee80211_rx succeeded, so it now owns the SKB */ 7788 else { /* libipw_rx succeeded, so it now owns the SKB */
7770 rxb->skb = NULL; 7789 rxb->skb = NULL;
7771 __ipw_led_activity_on(priv); 7790 __ipw_led_activity_on(priv);
7772 } 7791 }
@@ -7775,7 +7794,7 @@ static void ipw_handle_data_packet(struct ipw_priv *priv,
7775#ifdef CONFIG_IPW2200_RADIOTAP 7794#ifdef CONFIG_IPW2200_RADIOTAP
7776static void ipw_handle_data_packet_monitor(struct ipw_priv *priv, 7795static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7777 struct ipw_rx_mem_buffer *rxb, 7796 struct ipw_rx_mem_buffer *rxb,
7778 struct ieee80211_rx_stats *stats) 7797 struct libipw_rx_stats *stats)
7779{ 7798{
7780 struct net_device *dev = priv->net_dev; 7799 struct net_device *dev = priv->net_dev;
7781 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; 7800 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
@@ -7921,9 +7940,9 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7921 7940
7922 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len); 7941 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len);
7923 7942
7924 if (!ieee80211_rx(priv->ieee, rxb->skb, stats)) 7943 if (!libipw_rx(priv->ieee, rxb->skb, stats))
7925 dev->stats.rx_errors++; 7944 dev->stats.rx_errors++;
7926 else { /* ieee80211_rx succeeded, so it now owns the SKB */ 7945 else { /* libipw_rx succeeded, so it now owns the SKB */
7927 rxb->skb = NULL; 7946 rxb->skb = NULL;
7928 /* no LED during capture */ 7947 /* no LED during capture */
7929 } 7948 }
@@ -7931,28 +7950,28 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7931#endif 7950#endif
7932 7951
7933#ifdef CONFIG_IPW2200_PROMISCUOUS 7952#ifdef CONFIG_IPW2200_PROMISCUOUS
7934#define ieee80211_is_probe_response(fc) \ 7953#define libipw_is_probe_response(fc) \
7935 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && \ 7954 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && \
7936 (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP ) 7955 (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP )
7937 7956
7938#define ieee80211_is_management(fc) \ 7957#define libipw_is_management(fc) \
7939 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) 7958 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)
7940 7959
7941#define ieee80211_is_control(fc) \ 7960#define libipw_is_control(fc) \
7942 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) 7961 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL)
7943 7962
7944#define ieee80211_is_data(fc) \ 7963#define libipw_is_data(fc) \
7945 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) 7964 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
7946 7965
7947#define ieee80211_is_assoc_request(fc) \ 7966#define libipw_is_assoc_request(fc) \
7948 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ) 7967 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ)
7949 7968
7950#define ieee80211_is_reassoc_request(fc) \ 7969#define libipw_is_reassoc_request(fc) \
7951 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) 7970 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ)
7952 7971
7953static void ipw_handle_promiscuous_rx(struct ipw_priv *priv, 7972static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7954 struct ipw_rx_mem_buffer *rxb, 7973 struct ipw_rx_mem_buffer *rxb,
7955 struct ieee80211_rx_stats *stats) 7974 struct libipw_rx_stats *stats)
7956{ 7975{
7957 struct net_device *dev = priv->prom_net_dev; 7976 struct net_device *dev = priv->prom_net_dev;
7958 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; 7977 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
@@ -8002,17 +8021,17 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
8002 } 8021 }
8003 8022
8004 hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE; 8023 hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE;
8005 if (ieee80211_is_management(le16_to_cpu(hdr->frame_control))) { 8024 if (libipw_is_management(le16_to_cpu(hdr->frame_control))) {
8006 if (filter & IPW_PROM_NO_MGMT) 8025 if (filter & IPW_PROM_NO_MGMT)
8007 return; 8026 return;
8008 if (filter & IPW_PROM_MGMT_HEADER_ONLY) 8027 if (filter & IPW_PROM_MGMT_HEADER_ONLY)
8009 hdr_only = 1; 8028 hdr_only = 1;
8010 } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_control))) { 8029 } else if (libipw_is_control(le16_to_cpu(hdr->frame_control))) {
8011 if (filter & IPW_PROM_NO_CTL) 8030 if (filter & IPW_PROM_NO_CTL)
8012 return; 8031 return;
8013 if (filter & IPW_PROM_CTL_HEADER_ONLY) 8032 if (filter & IPW_PROM_CTL_HEADER_ONLY)
8014 hdr_only = 1; 8033 hdr_only = 1;
8015 } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_control))) { 8034 } else if (libipw_is_data(le16_to_cpu(hdr->frame_control))) {
8016 if (filter & IPW_PROM_NO_DATA) 8035 if (filter & IPW_PROM_NO_DATA)
8017 return; 8036 return;
8018 if (filter & IPW_PROM_DATA_HEADER_ONLY) 8037 if (filter & IPW_PROM_DATA_HEADER_ONLY)
@@ -8030,7 +8049,7 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
8030 ipw_rt = (void *)skb->data; 8049 ipw_rt = (void *)skb->data;
8031 8050
8032 if (hdr_only) 8051 if (hdr_only)
8033 len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); 8052 len = libipw_get_hdrlen(le16_to_cpu(hdr->frame_control));
8034 8053
8035 memcpy(ipw_rt->payload, hdr, len); 8054 memcpy(ipw_rt->payload, hdr, len);
8036 8055
@@ -8127,7 +8146,7 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
8127 8146
8128 IPW_DEBUG_RX("Rx packet of %d bytes.\n", skb->len); 8147 IPW_DEBUG_RX("Rx packet of %d bytes.\n", skb->len);
8129 8148
8130 if (!ieee80211_rx(priv->prom_priv->ieee, skb, stats)) { 8149 if (!libipw_rx(priv->prom_priv->ieee, skb, stats)) {
8131 dev->stats.rx_errors++; 8150 dev->stats.rx_errors++;
8132 dev_kfree_skb_any(skb); 8151 dev_kfree_skb_any(skb);
8133 } 8152 }
@@ -8135,7 +8154,7 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
8135#endif 8154#endif
8136 8155
8137static int is_network_packet(struct ipw_priv *priv, 8156static int is_network_packet(struct ipw_priv *priv,
8138 struct ieee80211_hdr_4addr *header) 8157 struct libipw_hdr_4addr *header)
8139{ 8158{
8140 /* Filter incoming packets to determine if they are targetted toward 8159 /* Filter incoming packets to determine if they are targetted toward
8141 * this network, discarding packets coming from ourselves */ 8160 * this network, discarding packets coming from ourselves */
@@ -8173,7 +8192,7 @@ static int is_network_packet(struct ipw_priv *priv,
8173#define IPW_PACKET_RETRY_TIME HZ 8192#define IPW_PACKET_RETRY_TIME HZ
8174 8193
8175static int is_duplicate_packet(struct ipw_priv *priv, 8194static int is_duplicate_packet(struct ipw_priv *priv,
8176 struct ieee80211_hdr_4addr *header) 8195 struct libipw_hdr_4addr *header)
8177{ 8196{
8178 u16 sc = le16_to_cpu(header->seq_ctl); 8197 u16 sc = le16_to_cpu(header->seq_ctl);
8179 u16 seq = WLAN_GET_SEQ_SEQ(sc); 8198 u16 seq = WLAN_GET_SEQ_SEQ(sc);
@@ -8247,14 +8266,14 @@ static int is_duplicate_packet(struct ipw_priv *priv,
8247 8266
8248static void ipw_handle_mgmt_packet(struct ipw_priv *priv, 8267static void ipw_handle_mgmt_packet(struct ipw_priv *priv,
8249 struct ipw_rx_mem_buffer *rxb, 8268 struct ipw_rx_mem_buffer *rxb,
8250 struct ieee80211_rx_stats *stats) 8269 struct libipw_rx_stats *stats)
8251{ 8270{
8252 struct sk_buff *skb = rxb->skb; 8271 struct sk_buff *skb = rxb->skb;
8253 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)skb->data; 8272 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)skb->data;
8254 struct ieee80211_hdr_4addr *header = (struct ieee80211_hdr_4addr *) 8273 struct libipw_hdr_4addr *header = (struct libipw_hdr_4addr *)
8255 (skb->data + IPW_RX_FRAME_SIZE); 8274 (skb->data + IPW_RX_FRAME_SIZE);
8256 8275
8257 ieee80211_rx_mgt(priv->ieee, header, stats); 8276 libipw_rx_mgt(priv->ieee, header, stats);
8258 8277
8259 if (priv->ieee->iw_mode == IW_MODE_ADHOC && 8278 if (priv->ieee->iw_mode == IW_MODE_ADHOC &&
8260 ((WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) == 8279 ((WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) ==
@@ -8276,12 +8295,12 @@ static void ipw_handle_mgmt_packet(struct ipw_priv *priv,
8276 /* Advance past the ipw packet header to the 802.11 frame */ 8295 /* Advance past the ipw packet header to the 802.11 frame */
8277 skb_pull(skb, IPW_RX_FRAME_SIZE); 8296 skb_pull(skb, IPW_RX_FRAME_SIZE);
8278 8297
8279 /* Push the ieee80211_rx_stats before the 802.11 frame */ 8298 /* Push the libipw_rx_stats before the 802.11 frame */
8280 memcpy(skb_push(skb, sizeof(*stats)), stats, sizeof(*stats)); 8299 memcpy(skb_push(skb, sizeof(*stats)), stats, sizeof(*stats));
8281 8300
8282 skb->dev = priv->ieee->dev; 8301 skb->dev = priv->ieee->dev;
8283 8302
8284 /* Point raw at the ieee80211_stats */ 8303 /* Point raw at the libipw_stats */
8285 skb_reset_mac_header(skb); 8304 skb_reset_mac_header(skb);
8286 8305
8287 skb->pkt_type = PACKET_OTHERHOST; 8306 skb->pkt_type = PACKET_OTHERHOST;
@@ -8301,7 +8320,7 @@ static void ipw_rx(struct ipw_priv *priv)
8301{ 8320{
8302 struct ipw_rx_mem_buffer *rxb; 8321 struct ipw_rx_mem_buffer *rxb;
8303 struct ipw_rx_packet *pkt; 8322 struct ipw_rx_packet *pkt;
8304 struct ieee80211_hdr_4addr *header; 8323 struct libipw_hdr_4addr *header;
8305 u32 r, w, i; 8324 u32 r, w, i;
8306 u8 network_packet; 8325 u8 network_packet;
8307 u8 fill_rx = 0; 8326 u8 fill_rx = 0;
@@ -8332,7 +8351,7 @@ static void ipw_rx(struct ipw_priv *priv)
8332 8351
8333 switch (pkt->header.message_type) { 8352 switch (pkt->header.message_type) {
8334 case RX_FRAME_TYPE: /* 802.11 frame */ { 8353 case RX_FRAME_TYPE: /* 802.11 frame */ {
8335 struct ieee80211_rx_stats stats = { 8354 struct libipw_rx_stats stats = {
8336 .rssi = pkt->u.frame.rssi_dbm - 8355 .rssi = pkt->u.frame.rssi_dbm -
8337 IPW_RSSI_TO_DBM, 8356 IPW_RSSI_TO_DBM,
8338 .signal = 8357 .signal =
@@ -8347,19 +8366,19 @@ static void ipw_rx(struct ipw_priv *priv)
8347 .freq = 8366 .freq =
8348 (pkt->u.frame. 8367 (pkt->u.frame.
8349 control & (1 << 0)) ? 8368 control & (1 << 0)) ?
8350 IEEE80211_24GHZ_BAND : 8369 LIBIPW_24GHZ_BAND :
8351 IEEE80211_52GHZ_BAND, 8370 LIBIPW_52GHZ_BAND,
8352 .len = le16_to_cpu(pkt->u.frame.length), 8371 .len = le16_to_cpu(pkt->u.frame.length),
8353 }; 8372 };
8354 8373
8355 if (stats.rssi != 0) 8374 if (stats.rssi != 0)
8356 stats.mask |= IEEE80211_STATMASK_RSSI; 8375 stats.mask |= LIBIPW_STATMASK_RSSI;
8357 if (stats.signal != 0) 8376 if (stats.signal != 0)
8358 stats.mask |= IEEE80211_STATMASK_SIGNAL; 8377 stats.mask |= LIBIPW_STATMASK_SIGNAL;
8359 if (stats.noise != 0) 8378 if (stats.noise != 0)
8360 stats.mask |= IEEE80211_STATMASK_NOISE; 8379 stats.mask |= LIBIPW_STATMASK_NOISE;
8361 if (stats.rate != 0) 8380 if (stats.rate != 0)
8362 stats.mask |= IEEE80211_STATMASK_RATE; 8381 stats.mask |= LIBIPW_STATMASK_RATE;
8363 8382
8364 priv->rx_packets++; 8383 priv->rx_packets++;
8365 8384
@@ -8384,7 +8403,7 @@ static void ipw_rx(struct ipw_priv *priv)
8384#endif 8403#endif
8385 8404
8386 header = 8405 header =
8387 (struct ieee80211_hdr_4addr *)(rxb->skb-> 8406 (struct libipw_hdr_4addr *)(rxb->skb->
8388 data + 8407 data +
8389 IPW_RX_FRAME_SIZE); 8408 IPW_RX_FRAME_SIZE);
8390 /* TODO: Check Ad-Hoc dest/source and make sure 8409 /* TODO: Check Ad-Hoc dest/source and make sure
@@ -8407,7 +8426,7 @@ static void ipw_rx(struct ipw_priv *priv)
8407 le16_to_cpu(pkt->u.frame.length)); 8426 le16_to_cpu(pkt->u.frame.length));
8408 8427
8409 if (le16_to_cpu(pkt->u.frame.length) < 8428 if (le16_to_cpu(pkt->u.frame.length) <
8410 ieee80211_get_hdrlen(le16_to_cpu( 8429 libipw_get_hdrlen(le16_to_cpu(
8411 header->frame_ctl))) { 8430 header->frame_ctl))) {
8412 IPW_DEBUG_DROP 8431 IPW_DEBUG_DROP
8413 ("Received packet is too small. " 8432 ("Received packet is too small. "
@@ -8592,9 +8611,9 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
8592 ": Detected Intel PRO/Wireless 2915ABG Network " 8611 ": Detected Intel PRO/Wireless 2915ABG Network "
8593 "Connection\n"); 8612 "Connection\n");
8594 priv->ieee->abg_true = 1; 8613 priv->ieee->abg_true = 1;
8595 band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND; 8614 band = LIBIPW_52GHZ_BAND | LIBIPW_24GHZ_BAND;
8596 modulation = IEEE80211_OFDM_MODULATION | 8615 modulation = LIBIPW_OFDM_MODULATION |
8597 IEEE80211_CCK_MODULATION; 8616 LIBIPW_CCK_MODULATION;
8598 priv->adapter = IPW_2915ABG; 8617 priv->adapter = IPW_2915ABG;
8599 priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B; 8618 priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B;
8600 } else { 8619 } else {
@@ -8604,9 +8623,9 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
8604 "Connection\n"); 8623 "Connection\n");
8605 8624
8606 priv->ieee->abg_true = 0; 8625 priv->ieee->abg_true = 0;
8607 band = IEEE80211_24GHZ_BAND; 8626 band = LIBIPW_24GHZ_BAND;
8608 modulation = IEEE80211_OFDM_MODULATION | 8627 modulation = LIBIPW_OFDM_MODULATION |
8609 IEEE80211_CCK_MODULATION; 8628 LIBIPW_CCK_MODULATION;
8610 priv->adapter = IPW_2200BG; 8629 priv->adapter = IPW_2200BG;
8611 priv->ieee->mode = IEEE_G | IEEE_B; 8630 priv->ieee->mode = IEEE_G | IEEE_B;
8612 } 8631 }
@@ -8614,7 +8633,7 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
8614 priv->ieee->freq_band = band; 8633 priv->ieee->freq_band = band;
8615 priv->ieee->modulation = modulation; 8634 priv->ieee->modulation = modulation;
8616 8635
8617 priv->rates_mask = IEEE80211_DEFAULT_RATES_MASK; 8636 priv->rates_mask = LIBIPW_DEFAULT_RATES_MASK;
8618 8637
8619 priv->disassociate_threshold = IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT; 8638 priv->disassociate_threshold = IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT;
8620 priv->roaming_threshold = IPW_MB_ROAMING_THRESHOLD_DEFAULT; 8639 priv->roaming_threshold = IPW_MB_ROAMING_THRESHOLD_DEFAULT;
@@ -8640,24 +8659,6 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
8640 * 8659 *
8641 */ 8660 */
8642 8661
8643static int ipw_wx_get_name(struct net_device *dev,
8644 struct iw_request_info *info,
8645 union iwreq_data *wrqu, char *extra)
8646{
8647 struct ipw_priv *priv = ieee80211_priv(dev);
8648 mutex_lock(&priv->mutex);
8649 if (priv->status & STATUS_RF_KILL_MASK)
8650 strcpy(wrqu->name, "radio off");
8651 else if (!(priv->status & STATUS_ASSOCIATED))
8652 strcpy(wrqu->name, "unassociated");
8653 else
8654 snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11%c",
8655 ipw_modes[priv->assoc_request.ieee_mode]);
8656 IPW_DEBUG_WX("Name: %s\n", wrqu->name);
8657 mutex_unlock(&priv->mutex);
8658 return 0;
8659}
8660
8661static int ipw_set_channel(struct ipw_priv *priv, u8 channel) 8662static int ipw_set_channel(struct ipw_priv *priv, u8 channel)
8662{ 8663{
8663 if (channel == 0) { 8664 if (channel == 0) {
@@ -8714,8 +8715,8 @@ static int ipw_wx_set_freq(struct net_device *dev,
8714 struct iw_request_info *info, 8715 struct iw_request_info *info,
8715 union iwreq_data *wrqu, char *extra) 8716 union iwreq_data *wrqu, char *extra)
8716{ 8717{
8717 struct ipw_priv *priv = ieee80211_priv(dev); 8718 struct ipw_priv *priv = libipw_priv(dev);
8718 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee); 8719 const struct libipw_geo *geo = libipw_get_geo(priv->ieee);
8719 struct iw_freq *fwrq = &wrqu->freq; 8720 struct iw_freq *fwrq = &wrqu->freq;
8720 int ret = 0, i; 8721 int ret = 0, i;
8721 u8 channel, flags; 8722 u8 channel, flags;
@@ -8730,23 +8731,23 @@ static int ipw_wx_set_freq(struct net_device *dev,
8730 } 8731 }
8731 /* if setting by freq convert to channel */ 8732 /* if setting by freq convert to channel */
8732 if (fwrq->e == 1) { 8733 if (fwrq->e == 1) {
8733 channel = ieee80211_freq_to_channel(priv->ieee, fwrq->m); 8734 channel = libipw_freq_to_channel(priv->ieee, fwrq->m);
8734 if (channel == 0) 8735 if (channel == 0)
8735 return -EINVAL; 8736 return -EINVAL;
8736 } else 8737 } else
8737 channel = fwrq->m; 8738 channel = fwrq->m;
8738 8739
8739 if (!(band = ieee80211_is_valid_channel(priv->ieee, channel))) 8740 if (!(band = libipw_is_valid_channel(priv->ieee, channel)))
8740 return -EINVAL; 8741 return -EINVAL;
8741 8742
8742 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 8743 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
8743 i = ieee80211_channel_to_index(priv->ieee, channel); 8744 i = libipw_channel_to_index(priv->ieee, channel);
8744 if (i == -1) 8745 if (i == -1)
8745 return -EINVAL; 8746 return -EINVAL;
8746 8747
8747 flags = (band == IEEE80211_24GHZ_BAND) ? 8748 flags = (band == LIBIPW_24GHZ_BAND) ?
8748 geo->bg[i].flags : geo->a[i].flags; 8749 geo->bg[i].flags : geo->a[i].flags;
8749 if (flags & IEEE80211_CH_PASSIVE_ONLY) { 8750 if (flags & LIBIPW_CH_PASSIVE_ONLY) {
8750 IPW_DEBUG_WX("Invalid Ad-Hoc channel for 802.11a\n"); 8751 IPW_DEBUG_WX("Invalid Ad-Hoc channel for 802.11a\n");
8751 return -EINVAL; 8752 return -EINVAL;
8752 } 8753 }
@@ -8763,7 +8764,7 @@ static int ipw_wx_get_freq(struct net_device *dev,
8763 struct iw_request_info *info, 8764 struct iw_request_info *info,
8764 union iwreq_data *wrqu, char *extra) 8765 union iwreq_data *wrqu, char *extra)
8765{ 8766{
8766 struct ipw_priv *priv = ieee80211_priv(dev); 8767 struct ipw_priv *priv = libipw_priv(dev);
8767 8768
8768 wrqu->freq.e = 0; 8769 wrqu->freq.e = 0;
8769 8770
@@ -8774,16 +8775,16 @@ static int ipw_wx_get_freq(struct net_device *dev,
8774 priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) { 8775 priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) {
8775 int i; 8776 int i;
8776 8777
8777 i = ieee80211_channel_to_index(priv->ieee, priv->channel); 8778 i = libipw_channel_to_index(priv->ieee, priv->channel);
8778 BUG_ON(i == -1); 8779 BUG_ON(i == -1);
8779 wrqu->freq.e = 1; 8780 wrqu->freq.e = 1;
8780 8781
8781 switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) { 8782 switch (libipw_is_valid_channel(priv->ieee, priv->channel)) {
8782 case IEEE80211_52GHZ_BAND: 8783 case LIBIPW_52GHZ_BAND:
8783 wrqu->freq.m = priv->ieee->geo.a[i].freq * 100000; 8784 wrqu->freq.m = priv->ieee->geo.a[i].freq * 100000;
8784 break; 8785 break;
8785 8786
8786 case IEEE80211_24GHZ_BAND: 8787 case LIBIPW_24GHZ_BAND:
8787 wrqu->freq.m = priv->ieee->geo.bg[i].freq * 100000; 8788 wrqu->freq.m = priv->ieee->geo.bg[i].freq * 100000;
8788 break; 8789 break;
8789 8790
@@ -8802,7 +8803,7 @@ static int ipw_wx_set_mode(struct net_device *dev,
8802 struct iw_request_info *info, 8803 struct iw_request_info *info,
8803 union iwreq_data *wrqu, char *extra) 8804 union iwreq_data *wrqu, char *extra)
8804{ 8805{
8805 struct ipw_priv *priv = ieee80211_priv(dev); 8806 struct ipw_priv *priv = libipw_priv(dev);
8806 int err = 0; 8807 int err = 0;
8807 8808
8808 IPW_DEBUG_WX("Set MODE: %d\n", wrqu->mode); 8809 IPW_DEBUG_WX("Set MODE: %d\n", wrqu->mode);
@@ -8854,7 +8855,7 @@ static int ipw_wx_get_mode(struct net_device *dev,
8854 struct iw_request_info *info, 8855 struct iw_request_info *info,
8855 union iwreq_data *wrqu, char *extra) 8856 union iwreq_data *wrqu, char *extra)
8856{ 8857{
8857 struct ipw_priv *priv = ieee80211_priv(dev); 8858 struct ipw_priv *priv = libipw_priv(dev);
8858 mutex_lock(&priv->mutex); 8859 mutex_lock(&priv->mutex);
8859 wrqu->mode = priv->ieee->iw_mode; 8860 wrqu->mode = priv->ieee->iw_mode;
8860 IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode); 8861 IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode);
@@ -8883,9 +8884,9 @@ static int ipw_wx_get_range(struct net_device *dev,
8883 struct iw_request_info *info, 8884 struct iw_request_info *info,
8884 union iwreq_data *wrqu, char *extra) 8885 union iwreq_data *wrqu, char *extra)
8885{ 8886{
8886 struct ipw_priv *priv = ieee80211_priv(dev); 8887 struct ipw_priv *priv = libipw_priv(dev);
8887 struct iw_range *range = (struct iw_range *)extra; 8888 struct iw_range *range = (struct iw_range *)extra;
8888 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee); 8889 const struct libipw_geo *geo = libipw_get_geo(priv->ieee);
8889 int i = 0, j; 8890 int i = 0, j;
8890 8891
8891 wrqu->data.length = sizeof(*range); 8892 wrqu->data.length = sizeof(*range);
@@ -8929,7 +8930,7 @@ static int ipw_wx_get_range(struct net_device *dev,
8929 if (priv->ieee->mode & (IEEE_B | IEEE_G)) { 8930 if (priv->ieee->mode & (IEEE_B | IEEE_G)) {
8930 for (j = 0; j < geo->bg_channels && i < IW_MAX_FREQUENCIES; j++) { 8931 for (j = 0; j < geo->bg_channels && i < IW_MAX_FREQUENCIES; j++) {
8931 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && 8932 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) &&
8932 (geo->bg[j].flags & IEEE80211_CH_PASSIVE_ONLY)) 8933 (geo->bg[j].flags & LIBIPW_CH_PASSIVE_ONLY))
8933 continue; 8934 continue;
8934 8935
8935 range->freq[i].i = geo->bg[j].channel; 8936 range->freq[i].i = geo->bg[j].channel;
@@ -8942,7 +8943,7 @@ static int ipw_wx_get_range(struct net_device *dev,
8942 if (priv->ieee->mode & IEEE_A) { 8943 if (priv->ieee->mode & IEEE_A) {
8943 for (j = 0; j < geo->a_channels && i < IW_MAX_FREQUENCIES; j++) { 8944 for (j = 0; j < geo->a_channels && i < IW_MAX_FREQUENCIES; j++) {
8944 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && 8945 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) &&
8945 (geo->a[j].flags & IEEE80211_CH_PASSIVE_ONLY)) 8946 (geo->a[j].flags & LIBIPW_CH_PASSIVE_ONLY))
8946 continue; 8947 continue;
8947 8948
8948 range->freq[i].i = geo->a[j].channel; 8949 range->freq[i].i = geo->a[j].channel;
@@ -8977,7 +8978,7 @@ static int ipw_wx_set_wap(struct net_device *dev,
8977 struct iw_request_info *info, 8978 struct iw_request_info *info,
8978 union iwreq_data *wrqu, char *extra) 8979 union iwreq_data *wrqu, char *extra)
8979{ 8980{
8980 struct ipw_priv *priv = ieee80211_priv(dev); 8981 struct ipw_priv *priv = libipw_priv(dev);
8981 8982
8982 static const unsigned char any[] = { 8983 static const unsigned char any[] = {
8983 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 8984 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
@@ -9026,7 +9027,7 @@ static int ipw_wx_get_wap(struct net_device *dev,
9026 struct iw_request_info *info, 9027 struct iw_request_info *info,
9027 union iwreq_data *wrqu, char *extra) 9028 union iwreq_data *wrqu, char *extra)
9028{ 9029{
9029 struct ipw_priv *priv = ieee80211_priv(dev); 9030 struct ipw_priv *priv = libipw_priv(dev);
9030 9031
9031 /* If we are associated, trying to associate, or have a statically 9032 /* If we are associated, trying to associate, or have a statically
9032 * configured BSSID then return that; otherwise return ANY */ 9033 * configured BSSID then return that; otherwise return ANY */
@@ -9048,7 +9049,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
9048 struct iw_request_info *info, 9049 struct iw_request_info *info,
9049 union iwreq_data *wrqu, char *extra) 9050 union iwreq_data *wrqu, char *extra)
9050{ 9051{
9051 struct ipw_priv *priv = ieee80211_priv(dev); 9052 struct ipw_priv *priv = libipw_priv(dev);
9052 int length; 9053 int length;
9053 DECLARE_SSID_BUF(ssid); 9054 DECLARE_SSID_BUF(ssid);
9054 9055
@@ -9094,7 +9095,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
9094 struct iw_request_info *info, 9095 struct iw_request_info *info,
9095 union iwreq_data *wrqu, char *extra) 9096 union iwreq_data *wrqu, char *extra)
9096{ 9097{
9097 struct ipw_priv *priv = ieee80211_priv(dev); 9098 struct ipw_priv *priv = libipw_priv(dev);
9098 DECLARE_SSID_BUF(ssid); 9099 DECLARE_SSID_BUF(ssid);
9099 9100
9100 /* If we are associated, trying to associate, or have a statically 9101 /* If we are associated, trying to associate, or have a statically
@@ -9120,7 +9121,7 @@ static int ipw_wx_set_nick(struct net_device *dev,
9120 struct iw_request_info *info, 9121 struct iw_request_info *info,
9121 union iwreq_data *wrqu, char *extra) 9122 union iwreq_data *wrqu, char *extra)
9122{ 9123{
9123 struct ipw_priv *priv = ieee80211_priv(dev); 9124 struct ipw_priv *priv = libipw_priv(dev);
9124 9125
9125 IPW_DEBUG_WX("Setting nick to '%s'\n", extra); 9126 IPW_DEBUG_WX("Setting nick to '%s'\n", extra);
9126 if (wrqu->data.length > IW_ESSID_MAX_SIZE) 9127 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
@@ -9139,7 +9140,7 @@ static int ipw_wx_get_nick(struct net_device *dev,
9139 struct iw_request_info *info, 9140 struct iw_request_info *info,
9140 union iwreq_data *wrqu, char *extra) 9141 union iwreq_data *wrqu, char *extra)
9141{ 9142{
9142 struct ipw_priv *priv = ieee80211_priv(dev); 9143 struct ipw_priv *priv = libipw_priv(dev);
9143 IPW_DEBUG_WX("Getting nick\n"); 9144 IPW_DEBUG_WX("Getting nick\n");
9144 mutex_lock(&priv->mutex); 9145 mutex_lock(&priv->mutex);
9145 wrqu->data.length = strlen(priv->nick); 9146 wrqu->data.length = strlen(priv->nick);
@@ -9153,7 +9154,7 @@ static int ipw_wx_set_sens(struct net_device *dev,
9153 struct iw_request_info *info, 9154 struct iw_request_info *info,
9154 union iwreq_data *wrqu, char *extra) 9155 union iwreq_data *wrqu, char *extra)
9155{ 9156{
9156 struct ipw_priv *priv = ieee80211_priv(dev); 9157 struct ipw_priv *priv = libipw_priv(dev);
9157 int err = 0; 9158 int err = 0;
9158 9159
9159 IPW_DEBUG_WX("Setting roaming threshold to %d\n", wrqu->sens.value); 9160 IPW_DEBUG_WX("Setting roaming threshold to %d\n", wrqu->sens.value);
@@ -9183,7 +9184,7 @@ static int ipw_wx_get_sens(struct net_device *dev,
9183 struct iw_request_info *info, 9184 struct iw_request_info *info,
9184 union iwreq_data *wrqu, char *extra) 9185 union iwreq_data *wrqu, char *extra)
9185{ 9186{
9186 struct ipw_priv *priv = ieee80211_priv(dev); 9187 struct ipw_priv *priv = libipw_priv(dev);
9187 mutex_lock(&priv->mutex); 9188 mutex_lock(&priv->mutex);
9188 wrqu->sens.fixed = 1; 9189 wrqu->sens.fixed = 1;
9189 wrqu->sens.value = priv->roaming_threshold; 9190 wrqu->sens.value = priv->roaming_threshold;
@@ -9200,7 +9201,7 @@ static int ipw_wx_set_rate(struct net_device *dev,
9200 union iwreq_data *wrqu, char *extra) 9201 union iwreq_data *wrqu, char *extra)
9201{ 9202{
9202 /* TODO: We should use semaphores or locks for access to priv */ 9203 /* TODO: We should use semaphores or locks for access to priv */
9203 struct ipw_priv *priv = ieee80211_priv(dev); 9204 struct ipw_priv *priv = libipw_priv(dev);
9204 u32 target_rate = wrqu->bitrate.value; 9205 u32 target_rate = wrqu->bitrate.value;
9205 u32 fixed, mask; 9206 u32 fixed, mask;
9206 9207
@@ -9210,7 +9211,7 @@ static int ipw_wx_set_rate(struct net_device *dev,
9210 9211
9211 if (target_rate == -1) { 9212 if (target_rate == -1) {
9212 fixed = 0; 9213 fixed = 0;
9213 mask = IEEE80211_DEFAULT_RATES_MASK; 9214 mask = LIBIPW_DEFAULT_RATES_MASK;
9214 /* Now we should reassociate */ 9215 /* Now we should reassociate */
9215 goto apply; 9216 goto apply;
9216 } 9217 }
@@ -9219,62 +9220,62 @@ static int ipw_wx_set_rate(struct net_device *dev,
9219 fixed = wrqu->bitrate.fixed; 9220 fixed = wrqu->bitrate.fixed;
9220 9221
9221 if (target_rate == 1000000 || !fixed) 9222 if (target_rate == 1000000 || !fixed)
9222 mask |= IEEE80211_CCK_RATE_1MB_MASK; 9223 mask |= LIBIPW_CCK_RATE_1MB_MASK;
9223 if (target_rate == 1000000) 9224 if (target_rate == 1000000)
9224 goto apply; 9225 goto apply;
9225 9226
9226 if (target_rate == 2000000 || !fixed) 9227 if (target_rate == 2000000 || !fixed)
9227 mask |= IEEE80211_CCK_RATE_2MB_MASK; 9228 mask |= LIBIPW_CCK_RATE_2MB_MASK;
9228 if (target_rate == 2000000) 9229 if (target_rate == 2000000)
9229 goto apply; 9230 goto apply;
9230 9231
9231 if (target_rate == 5500000 || !fixed) 9232 if (target_rate == 5500000 || !fixed)
9232 mask |= IEEE80211_CCK_RATE_5MB_MASK; 9233 mask |= LIBIPW_CCK_RATE_5MB_MASK;
9233 if (target_rate == 5500000) 9234 if (target_rate == 5500000)
9234 goto apply; 9235 goto apply;
9235 9236
9236 if (target_rate == 6000000 || !fixed) 9237 if (target_rate == 6000000 || !fixed)
9237 mask |= IEEE80211_OFDM_RATE_6MB_MASK; 9238 mask |= LIBIPW_OFDM_RATE_6MB_MASK;
9238 if (target_rate == 6000000) 9239 if (target_rate == 6000000)
9239 goto apply; 9240 goto apply;
9240 9241
9241 if (target_rate == 9000000 || !fixed) 9242 if (target_rate == 9000000 || !fixed)
9242 mask |= IEEE80211_OFDM_RATE_9MB_MASK; 9243 mask |= LIBIPW_OFDM_RATE_9MB_MASK;
9243 if (target_rate == 9000000) 9244 if (target_rate == 9000000)
9244 goto apply; 9245 goto apply;
9245 9246
9246 if (target_rate == 11000000 || !fixed) 9247 if (target_rate == 11000000 || !fixed)
9247 mask |= IEEE80211_CCK_RATE_11MB_MASK; 9248 mask |= LIBIPW_CCK_RATE_11MB_MASK;
9248 if (target_rate == 11000000) 9249 if (target_rate == 11000000)
9249 goto apply; 9250 goto apply;
9250 9251
9251 if (target_rate == 12000000 || !fixed) 9252 if (target_rate == 12000000 || !fixed)
9252 mask |= IEEE80211_OFDM_RATE_12MB_MASK; 9253 mask |= LIBIPW_OFDM_RATE_12MB_MASK;
9253 if (target_rate == 12000000) 9254 if (target_rate == 12000000)
9254 goto apply; 9255 goto apply;
9255 9256
9256 if (target_rate == 18000000 || !fixed) 9257 if (target_rate == 18000000 || !fixed)
9257 mask |= IEEE80211_OFDM_RATE_18MB_MASK; 9258 mask |= LIBIPW_OFDM_RATE_18MB_MASK;
9258 if (target_rate == 18000000) 9259 if (target_rate == 18000000)
9259 goto apply; 9260 goto apply;
9260 9261
9261 if (target_rate == 24000000 || !fixed) 9262 if (target_rate == 24000000 || !fixed)
9262 mask |= IEEE80211_OFDM_RATE_24MB_MASK; 9263 mask |= LIBIPW_OFDM_RATE_24MB_MASK;
9263 if (target_rate == 24000000) 9264 if (target_rate == 24000000)
9264 goto apply; 9265 goto apply;
9265 9266
9266 if (target_rate == 36000000 || !fixed) 9267 if (target_rate == 36000000 || !fixed)
9267 mask |= IEEE80211_OFDM_RATE_36MB_MASK; 9268 mask |= LIBIPW_OFDM_RATE_36MB_MASK;
9268 if (target_rate == 36000000) 9269 if (target_rate == 36000000)
9269 goto apply; 9270 goto apply;
9270 9271
9271 if (target_rate == 48000000 || !fixed) 9272 if (target_rate == 48000000 || !fixed)
9272 mask |= IEEE80211_OFDM_RATE_48MB_MASK; 9273 mask |= LIBIPW_OFDM_RATE_48MB_MASK;
9273 if (target_rate == 48000000) 9274 if (target_rate == 48000000)
9274 goto apply; 9275 goto apply;
9275 9276
9276 if (target_rate == 54000000 || !fixed) 9277 if (target_rate == 54000000 || !fixed)
9277 mask |= IEEE80211_OFDM_RATE_54MB_MASK; 9278 mask |= LIBIPW_OFDM_RATE_54MB_MASK;
9278 if (target_rate == 54000000) 9279 if (target_rate == 54000000)
9279 goto apply; 9280 goto apply;
9280 9281
@@ -9285,7 +9286,7 @@ static int ipw_wx_set_rate(struct net_device *dev,
9285 IPW_DEBUG_WX("Setting rate mask to 0x%08X [%s]\n", 9286 IPW_DEBUG_WX("Setting rate mask to 0x%08X [%s]\n",
9286 mask, fixed ? "fixed" : "sub-rates"); 9287 mask, fixed ? "fixed" : "sub-rates");
9287 mutex_lock(&priv->mutex); 9288 mutex_lock(&priv->mutex);
9288 if (mask == IEEE80211_DEFAULT_RATES_MASK) { 9289 if (mask == LIBIPW_DEFAULT_RATES_MASK) {
9289 priv->config &= ~CFG_FIXED_RATE; 9290 priv->config &= ~CFG_FIXED_RATE;
9290 ipw_set_fixed_rate(priv, priv->ieee->mode); 9291 ipw_set_fixed_rate(priv, priv->ieee->mode);
9291 } else 9292 } else
@@ -9312,7 +9313,7 @@ static int ipw_wx_get_rate(struct net_device *dev,
9312 struct iw_request_info *info, 9313 struct iw_request_info *info,
9313 union iwreq_data *wrqu, char *extra) 9314 union iwreq_data *wrqu, char *extra)
9314{ 9315{
9315 struct ipw_priv *priv = ieee80211_priv(dev); 9316 struct ipw_priv *priv = libipw_priv(dev);
9316 mutex_lock(&priv->mutex); 9317 mutex_lock(&priv->mutex);
9317 wrqu->bitrate.value = priv->last_rate; 9318 wrqu->bitrate.value = priv->last_rate;
9318 wrqu->bitrate.fixed = (priv->config & CFG_FIXED_RATE) ? 1 : 0; 9319 wrqu->bitrate.fixed = (priv->config & CFG_FIXED_RATE) ? 1 : 0;
@@ -9325,7 +9326,7 @@ static int ipw_wx_set_rts(struct net_device *dev,
9325 struct iw_request_info *info, 9326 struct iw_request_info *info,
9326 union iwreq_data *wrqu, char *extra) 9327 union iwreq_data *wrqu, char *extra)
9327{ 9328{
9328 struct ipw_priv *priv = ieee80211_priv(dev); 9329 struct ipw_priv *priv = libipw_priv(dev);
9329 mutex_lock(&priv->mutex); 9330 mutex_lock(&priv->mutex);
9330 if (wrqu->rts.disabled || !wrqu->rts.fixed) 9331 if (wrqu->rts.disabled || !wrqu->rts.fixed)
9331 priv->rts_threshold = DEFAULT_RTS_THRESHOLD; 9332 priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
@@ -9348,7 +9349,7 @@ static int ipw_wx_get_rts(struct net_device *dev,
9348 struct iw_request_info *info, 9349 struct iw_request_info *info,
9349 union iwreq_data *wrqu, char *extra) 9350 union iwreq_data *wrqu, char *extra)
9350{ 9351{
9351 struct ipw_priv *priv = ieee80211_priv(dev); 9352 struct ipw_priv *priv = libipw_priv(dev);
9352 mutex_lock(&priv->mutex); 9353 mutex_lock(&priv->mutex);
9353 wrqu->rts.value = priv->rts_threshold; 9354 wrqu->rts.value = priv->rts_threshold;
9354 wrqu->rts.fixed = 0; /* no auto select */ 9355 wrqu->rts.fixed = 0; /* no auto select */
@@ -9362,7 +9363,7 @@ static int ipw_wx_set_txpow(struct net_device *dev,
9362 struct iw_request_info *info, 9363 struct iw_request_info *info,
9363 union iwreq_data *wrqu, char *extra) 9364 union iwreq_data *wrqu, char *extra)
9364{ 9365{
9365 struct ipw_priv *priv = ieee80211_priv(dev); 9366 struct ipw_priv *priv = libipw_priv(dev);
9366 int err = 0; 9367 int err = 0;
9367 9368
9368 mutex_lock(&priv->mutex); 9369 mutex_lock(&priv->mutex);
@@ -9396,7 +9397,7 @@ static int ipw_wx_get_txpow(struct net_device *dev,
9396 struct iw_request_info *info, 9397 struct iw_request_info *info,
9397 union iwreq_data *wrqu, char *extra) 9398 union iwreq_data *wrqu, char *extra)
9398{ 9399{
9399 struct ipw_priv *priv = ieee80211_priv(dev); 9400 struct ipw_priv *priv = libipw_priv(dev);
9400 mutex_lock(&priv->mutex); 9401 mutex_lock(&priv->mutex);
9401 wrqu->power.value = priv->tx_power; 9402 wrqu->power.value = priv->tx_power;
9402 wrqu->power.fixed = 1; 9403 wrqu->power.fixed = 1;
@@ -9414,7 +9415,7 @@ static int ipw_wx_set_frag(struct net_device *dev,
9414 struct iw_request_info *info, 9415 struct iw_request_info *info,
9415 union iwreq_data *wrqu, char *extra) 9416 union iwreq_data *wrqu, char *extra)
9416{ 9417{
9417 struct ipw_priv *priv = ieee80211_priv(dev); 9418 struct ipw_priv *priv = libipw_priv(dev);
9418 mutex_lock(&priv->mutex); 9419 mutex_lock(&priv->mutex);
9419 if (wrqu->frag.disabled || !wrqu->frag.fixed) 9420 if (wrqu->frag.disabled || !wrqu->frag.fixed)
9420 priv->ieee->fts = DEFAULT_FTS; 9421 priv->ieee->fts = DEFAULT_FTS;
@@ -9438,7 +9439,7 @@ static int ipw_wx_get_frag(struct net_device *dev,
9438 struct iw_request_info *info, 9439 struct iw_request_info *info,
9439 union iwreq_data *wrqu, char *extra) 9440 union iwreq_data *wrqu, char *extra)
9440{ 9441{
9441 struct ipw_priv *priv = ieee80211_priv(dev); 9442 struct ipw_priv *priv = libipw_priv(dev);
9442 mutex_lock(&priv->mutex); 9443 mutex_lock(&priv->mutex);
9443 wrqu->frag.value = priv->ieee->fts; 9444 wrqu->frag.value = priv->ieee->fts;
9444 wrqu->frag.fixed = 0; /* no auto select */ 9445 wrqu->frag.fixed = 0; /* no auto select */
@@ -9453,7 +9454,7 @@ static int ipw_wx_set_retry(struct net_device *dev,
9453 struct iw_request_info *info, 9454 struct iw_request_info *info,
9454 union iwreq_data *wrqu, char *extra) 9455 union iwreq_data *wrqu, char *extra)
9455{ 9456{
9456 struct ipw_priv *priv = ieee80211_priv(dev); 9457 struct ipw_priv *priv = libipw_priv(dev);
9457 9458
9458 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled) 9459 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled)
9459 return -EINVAL; 9460 return -EINVAL;
@@ -9486,7 +9487,7 @@ static int ipw_wx_get_retry(struct net_device *dev,
9486 struct iw_request_info *info, 9487 struct iw_request_info *info,
9487 union iwreq_data *wrqu, char *extra) 9488 union iwreq_data *wrqu, char *extra)
9488{ 9489{
9489 struct ipw_priv *priv = ieee80211_priv(dev); 9490 struct ipw_priv *priv = libipw_priv(dev);
9490 9491
9491 mutex_lock(&priv->mutex); 9492 mutex_lock(&priv->mutex);
9492 wrqu->retry.disabled = 0; 9493 wrqu->retry.disabled = 0;
@@ -9517,7 +9518,7 @@ static int ipw_wx_set_scan(struct net_device *dev,
9517 struct iw_request_info *info, 9518 struct iw_request_info *info,
9518 union iwreq_data *wrqu, char *extra) 9519 union iwreq_data *wrqu, char *extra)
9519{ 9520{
9520 struct ipw_priv *priv = ieee80211_priv(dev); 9521 struct ipw_priv *priv = libipw_priv(dev);
9521 struct iw_scan_req *req = (struct iw_scan_req *)extra; 9522 struct iw_scan_req *req = (struct iw_scan_req *)extra;
9522 struct delayed_work *work = NULL; 9523 struct delayed_work *work = NULL;
9523 9524
@@ -9553,20 +9554,20 @@ static int ipw_wx_get_scan(struct net_device *dev,
9553 struct iw_request_info *info, 9554 struct iw_request_info *info,
9554 union iwreq_data *wrqu, char *extra) 9555 union iwreq_data *wrqu, char *extra)
9555{ 9556{
9556 struct ipw_priv *priv = ieee80211_priv(dev); 9557 struct ipw_priv *priv = libipw_priv(dev);
9557 return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra); 9558 return libipw_wx_get_scan(priv->ieee, info, wrqu, extra);
9558} 9559}
9559 9560
9560static int ipw_wx_set_encode(struct net_device *dev, 9561static int ipw_wx_set_encode(struct net_device *dev,
9561 struct iw_request_info *info, 9562 struct iw_request_info *info,
9562 union iwreq_data *wrqu, char *key) 9563 union iwreq_data *wrqu, char *key)
9563{ 9564{
9564 struct ipw_priv *priv = ieee80211_priv(dev); 9565 struct ipw_priv *priv = libipw_priv(dev);
9565 int ret; 9566 int ret;
9566 u32 cap = priv->capability; 9567 u32 cap = priv->capability;
9567 9568
9568 mutex_lock(&priv->mutex); 9569 mutex_lock(&priv->mutex);
9569 ret = ieee80211_wx_set_encode(priv->ieee, info, wrqu, key); 9570 ret = libipw_wx_set_encode(priv->ieee, info, wrqu, key);
9570 9571
9571 /* In IBSS mode, we need to notify the firmware to update 9572 /* In IBSS mode, we need to notify the firmware to update
9572 * the beacon info after we changed the capability. */ 9573 * the beacon info after we changed the capability. */
@@ -9583,15 +9584,15 @@ static int ipw_wx_get_encode(struct net_device *dev,
9583 struct iw_request_info *info, 9584 struct iw_request_info *info,
9584 union iwreq_data *wrqu, char *key) 9585 union iwreq_data *wrqu, char *key)
9585{ 9586{
9586 struct ipw_priv *priv = ieee80211_priv(dev); 9587 struct ipw_priv *priv = libipw_priv(dev);
9587 return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key); 9588 return libipw_wx_get_encode(priv->ieee, info, wrqu, key);
9588} 9589}
9589 9590
9590static int ipw_wx_set_power(struct net_device *dev, 9591static int ipw_wx_set_power(struct net_device *dev,
9591 struct iw_request_info *info, 9592 struct iw_request_info *info,
9592 union iwreq_data *wrqu, char *extra) 9593 union iwreq_data *wrqu, char *extra)
9593{ 9594{
9594 struct ipw_priv *priv = ieee80211_priv(dev); 9595 struct ipw_priv *priv = libipw_priv(dev);
9595 int err; 9596 int err;
9596 mutex_lock(&priv->mutex); 9597 mutex_lock(&priv->mutex);
9597 if (wrqu->power.disabled) { 9598 if (wrqu->power.disabled) {
@@ -9642,7 +9643,7 @@ static int ipw_wx_get_power(struct net_device *dev,
9642 struct iw_request_info *info, 9643 struct iw_request_info *info,
9643 union iwreq_data *wrqu, char *extra) 9644 union iwreq_data *wrqu, char *extra)
9644{ 9645{
9645 struct ipw_priv *priv = ieee80211_priv(dev); 9646 struct ipw_priv *priv = libipw_priv(dev);
9646 mutex_lock(&priv->mutex); 9647 mutex_lock(&priv->mutex);
9647 if (!(priv->power_mode & IPW_POWER_ENABLED)) 9648 if (!(priv->power_mode & IPW_POWER_ENABLED))
9648 wrqu->power.disabled = 1; 9649 wrqu->power.disabled = 1;
@@ -9659,7 +9660,7 @@ static int ipw_wx_set_powermode(struct net_device *dev,
9659 struct iw_request_info *info, 9660 struct iw_request_info *info,
9660 union iwreq_data *wrqu, char *extra) 9661 union iwreq_data *wrqu, char *extra)
9661{ 9662{
9662 struct ipw_priv *priv = ieee80211_priv(dev); 9663 struct ipw_priv *priv = libipw_priv(dev);
9663 int mode = *(int *)extra; 9664 int mode = *(int *)extra;
9664 int err; 9665 int err;
9665 9666
@@ -9685,7 +9686,7 @@ static int ipw_wx_get_powermode(struct net_device *dev,
9685 struct iw_request_info *info, 9686 struct iw_request_info *info,
9686 union iwreq_data *wrqu, char *extra) 9687 union iwreq_data *wrqu, char *extra)
9687{ 9688{
9688 struct ipw_priv *priv = ieee80211_priv(dev); 9689 struct ipw_priv *priv = libipw_priv(dev);
9689 int level = IPW_POWER_LEVEL(priv->power_mode); 9690 int level = IPW_POWER_LEVEL(priv->power_mode);
9690 char *p = extra; 9691 char *p = extra;
9691 9692
@@ -9717,7 +9718,7 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
9717 struct iw_request_info *info, 9718 struct iw_request_info *info,
9718 union iwreq_data *wrqu, char *extra) 9719 union iwreq_data *wrqu, char *extra)
9719{ 9720{
9720 struct ipw_priv *priv = ieee80211_priv(dev); 9721 struct ipw_priv *priv = libipw_priv(dev);
9721 int mode = *(int *)extra; 9722 int mode = *(int *)extra;
9722 u8 band = 0, modulation = 0; 9723 u8 band = 0, modulation = 0;
9723 9724
@@ -9729,8 +9730,8 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
9729 if (priv->adapter == IPW_2915ABG) { 9730 if (priv->adapter == IPW_2915ABG) {
9730 priv->ieee->abg_true = 1; 9731 priv->ieee->abg_true = 1;
9731 if (mode & IEEE_A) { 9732 if (mode & IEEE_A) {
9732 band |= IEEE80211_52GHZ_BAND; 9733 band |= LIBIPW_52GHZ_BAND;
9733 modulation |= IEEE80211_OFDM_MODULATION; 9734 modulation |= LIBIPW_OFDM_MODULATION;
9734 } else 9735 } else
9735 priv->ieee->abg_true = 0; 9736 priv->ieee->abg_true = 0;
9736 } else { 9737 } else {
@@ -9745,14 +9746,14 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
9745 } 9746 }
9746 9747
9747 if (mode & IEEE_B) { 9748 if (mode & IEEE_B) {
9748 band |= IEEE80211_24GHZ_BAND; 9749 band |= LIBIPW_24GHZ_BAND;
9749 modulation |= IEEE80211_CCK_MODULATION; 9750 modulation |= LIBIPW_CCK_MODULATION;
9750 } else 9751 } else
9751 priv->ieee->abg_true = 0; 9752 priv->ieee->abg_true = 0;
9752 9753
9753 if (mode & IEEE_G) { 9754 if (mode & IEEE_G) {
9754 band |= IEEE80211_24GHZ_BAND; 9755 band |= LIBIPW_24GHZ_BAND;
9755 modulation |= IEEE80211_OFDM_MODULATION; 9756 modulation |= LIBIPW_OFDM_MODULATION;
9756 } else 9757 } else
9757 priv->ieee->abg_true = 0; 9758 priv->ieee->abg_true = 0;
9758 9759
@@ -9782,7 +9783,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev,
9782 struct iw_request_info *info, 9783 struct iw_request_info *info,
9783 union iwreq_data *wrqu, char *extra) 9784 union iwreq_data *wrqu, char *extra)
9784{ 9785{
9785 struct ipw_priv *priv = ieee80211_priv(dev); 9786 struct ipw_priv *priv = libipw_priv(dev);
9786 mutex_lock(&priv->mutex); 9787 mutex_lock(&priv->mutex);
9787 switch (priv->ieee->mode) { 9788 switch (priv->ieee->mode) {
9788 case IEEE_A: 9789 case IEEE_A:
@@ -9823,7 +9824,7 @@ static int ipw_wx_set_preamble(struct net_device *dev,
9823 struct iw_request_info *info, 9824 struct iw_request_info *info,
9824 union iwreq_data *wrqu, char *extra) 9825 union iwreq_data *wrqu, char *extra)
9825{ 9826{
9826 struct ipw_priv *priv = ieee80211_priv(dev); 9827 struct ipw_priv *priv = libipw_priv(dev);
9827 int mode = *(int *)extra; 9828 int mode = *(int *)extra;
9828 mutex_lock(&priv->mutex); 9829 mutex_lock(&priv->mutex);
9829 /* Switching from SHORT -> LONG requires a disassociation */ 9830 /* Switching from SHORT -> LONG requires a disassociation */
@@ -9856,7 +9857,7 @@ static int ipw_wx_get_preamble(struct net_device *dev,
9856 struct iw_request_info *info, 9857 struct iw_request_info *info,
9857 union iwreq_data *wrqu, char *extra) 9858 union iwreq_data *wrqu, char *extra)
9858{ 9859{
9859 struct ipw_priv *priv = ieee80211_priv(dev); 9860 struct ipw_priv *priv = libipw_priv(dev);
9860 mutex_lock(&priv->mutex); 9861 mutex_lock(&priv->mutex);
9861 if (priv->config & CFG_PREAMBLE_LONG) 9862 if (priv->config & CFG_PREAMBLE_LONG)
9862 snprintf(wrqu->name, IFNAMSIZ, "long (1)"); 9863 snprintf(wrqu->name, IFNAMSIZ, "long (1)");
@@ -9871,7 +9872,7 @@ static int ipw_wx_set_monitor(struct net_device *dev,
9871 struct iw_request_info *info, 9872 struct iw_request_info *info,
9872 union iwreq_data *wrqu, char *extra) 9873 union iwreq_data *wrqu, char *extra)
9873{ 9874{
9874 struct ipw_priv *priv = ieee80211_priv(dev); 9875 struct ipw_priv *priv = libipw_priv(dev);
9875 int *parms = (int *)extra; 9876 int *parms = (int *)extra;
9876 int enable = (parms[0] > 0); 9877 int enable = (parms[0] > 0);
9877 mutex_lock(&priv->mutex); 9878 mutex_lock(&priv->mutex);
@@ -9905,7 +9906,7 @@ static int ipw_wx_reset(struct net_device *dev,
9905 struct iw_request_info *info, 9906 struct iw_request_info *info,
9906 union iwreq_data *wrqu, char *extra) 9907 union iwreq_data *wrqu, char *extra)
9907{ 9908{
9908 struct ipw_priv *priv = ieee80211_priv(dev); 9909 struct ipw_priv *priv = libipw_priv(dev);
9909 IPW_DEBUG_WX("RESET\n"); 9910 IPW_DEBUG_WX("RESET\n");
9910 queue_work(priv->workqueue, &priv->adapter_restart); 9911 queue_work(priv->workqueue, &priv->adapter_restart);
9911 return 0; 9912 return 0;
@@ -9915,7 +9916,7 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9915 struct iw_request_info *info, 9916 struct iw_request_info *info,
9916 union iwreq_data *wrqu, char *extra) 9917 union iwreq_data *wrqu, char *extra)
9917{ 9918{
9918 struct ipw_priv *priv = ieee80211_priv(dev); 9919 struct ipw_priv *priv = libipw_priv(dev);
9919 union iwreq_data wrqu_sec = { 9920 union iwreq_data wrqu_sec = {
9920 .encoding = { 9921 .encoding = {
9921 .flags = IW_ENCODE_DISABLED, 9922 .flags = IW_ENCODE_DISABLED,
@@ -9938,7 +9939,7 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9938 ipw_radio_kill_sw(priv, priv->status & STATUS_RF_KILL_SW); 9939 ipw_radio_kill_sw(priv, priv->status & STATUS_RF_KILL_SW);
9939 9940
9940 mutex_unlock(&priv->mutex); 9941 mutex_unlock(&priv->mutex);
9941 ieee80211_wx_set_encode(priv->ieee, info, &wrqu_sec, NULL); 9942 libipw_wx_set_encode(priv->ieee, info, &wrqu_sec, NULL);
9942 mutex_lock(&priv->mutex); 9943 mutex_lock(&priv->mutex);
9943 9944
9944 if (!(priv->status & STATUS_RF_KILL_MASK)) { 9945 if (!(priv->status & STATUS_RF_KILL_MASK)) {
@@ -9957,7 +9958,7 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9957/* Rebase the WE IOCTLs to zero for the handler array */ 9958/* Rebase the WE IOCTLs to zero for the handler array */
9958#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] 9959#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
9959static iw_handler ipw_wx_handlers[] = { 9960static iw_handler ipw_wx_handlers[] = {
9960 IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, 9961 IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname,
9961 IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, 9962 IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq,
9962 IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, 9963 IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq,
9963 IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, 9964 IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode,
@@ -10083,7 +10084,7 @@ static struct iw_handler_def ipw_wx_handler_def = {
10083 */ 10084 */
10084static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev) 10085static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev)
10085{ 10086{
10086 struct ipw_priv *priv = ieee80211_priv(dev); 10087 struct ipw_priv *priv = libipw_priv(dev);
10087 struct iw_statistics *wstats; 10088 struct iw_statistics *wstats;
10088 10089
10089 wstats = &priv->wstats; 10090 wstats = &priv->wstats;
@@ -10164,13 +10165,13 @@ static int ipw_net_stop(struct net_device *dev)
10164todo: 10165todo:
10165 10166
10166modify to send one tfd per fragment instead of using chunking. otherwise 10167modify to send one tfd per fragment instead of using chunking. otherwise
10167we need to heavily modify the ieee80211_skb_to_txb. 10168we need to heavily modify the libipw_skb_to_txb.
10168*/ 10169*/
10169 10170
10170static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb, 10171static int ipw_tx_skb(struct ipw_priv *priv, struct libipw_txb *txb,
10171 int pri) 10172 int pri)
10172{ 10173{
10173 struct ieee80211_hdr_3addrqos *hdr = (struct ieee80211_hdr_3addrqos *) 10174 struct libipw_hdr_3addrqos *hdr = (struct libipw_hdr_3addrqos *)
10174 txb->fragments[0]->data; 10175 txb->fragments[0]->data;
10175 int i = 0; 10176 int i = 0;
10176 struct tfd_frame *tfd; 10177 struct tfd_frame *tfd;
@@ -10187,7 +10188,7 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
10187 if (!(priv->status & STATUS_ASSOCIATED)) 10188 if (!(priv->status & STATUS_ASSOCIATED))
10188 goto drop; 10189 goto drop;
10189 10190
10190 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 10191 hdr_len = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
10191 switch (priv->ieee->iw_mode) { 10192 switch (priv->ieee->iw_mode) {
10192 case IW_MODE_ADHOC: 10193 case IW_MODE_ADHOC:
10193 unicast = !is_multicast_ether_addr(hdr->addr1); 10194 unicast = !is_multicast_ether_addr(hdr->addr1);
@@ -10356,13 +10357,13 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
10356 10357
10357 drop: 10358 drop:
10358 IPW_DEBUG_DROP("Silently dropping Tx packet.\n"); 10359 IPW_DEBUG_DROP("Silently dropping Tx packet.\n");
10359 ieee80211_txb_free(txb); 10360 libipw_txb_free(txb);
10360 return NETDEV_TX_OK; 10361 return NETDEV_TX_OK;
10361} 10362}
10362 10363
10363static int ipw_net_is_queue_full(struct net_device *dev, int pri) 10364static int ipw_net_is_queue_full(struct net_device *dev, int pri)
10364{ 10365{
10365 struct ipw_priv *priv = ieee80211_priv(dev); 10366 struct ipw_priv *priv = libipw_priv(dev);
10366#ifdef CONFIG_IPW2200_QOS 10367#ifdef CONFIG_IPW2200_QOS
10367 int tx_id = ipw_get_tx_queue_number(priv, pri); 10368 int tx_id = ipw_get_tx_queue_number(priv, pri);
10368 struct clx2_tx_queue *txq = &priv->txq[tx_id]; 10369 struct clx2_tx_queue *txq = &priv->txq[tx_id];
@@ -10378,9 +10379,9 @@ static int ipw_net_is_queue_full(struct net_device *dev, int pri)
10378 10379
10379#ifdef CONFIG_IPW2200_PROMISCUOUS 10380#ifdef CONFIG_IPW2200_PROMISCUOUS
10380static void ipw_handle_promiscuous_tx(struct ipw_priv *priv, 10381static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10381 struct ieee80211_txb *txb) 10382 struct libipw_txb *txb)
10382{ 10383{
10383 struct ieee80211_rx_stats dummystats; 10384 struct libipw_rx_stats dummystats;
10384 struct ieee80211_hdr *hdr; 10385 struct ieee80211_hdr *hdr;
10385 u8 n; 10386 u8 n;
10386 u16 filter = priv->prom_priv->filter; 10387 u16 filter = priv->prom_priv->filter;
@@ -10393,17 +10394,17 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10393 10394
10394 /* Filtering of fragment chains is done agains the first fragment */ 10395 /* Filtering of fragment chains is done agains the first fragment */
10395 hdr = (void *)txb->fragments[0]->data; 10396 hdr = (void *)txb->fragments[0]->data;
10396 if (ieee80211_is_management(le16_to_cpu(hdr->frame_control))) { 10397 if (libipw_is_management(le16_to_cpu(hdr->frame_control))) {
10397 if (filter & IPW_PROM_NO_MGMT) 10398 if (filter & IPW_PROM_NO_MGMT)
10398 return; 10399 return;
10399 if (filter & IPW_PROM_MGMT_HEADER_ONLY) 10400 if (filter & IPW_PROM_MGMT_HEADER_ONLY)
10400 hdr_only = 1; 10401 hdr_only = 1;
10401 } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_control))) { 10402 } else if (libipw_is_control(le16_to_cpu(hdr->frame_control))) {
10402 if (filter & IPW_PROM_NO_CTL) 10403 if (filter & IPW_PROM_NO_CTL)
10403 return; 10404 return;
10404 if (filter & IPW_PROM_CTL_HEADER_ONLY) 10405 if (filter & IPW_PROM_CTL_HEADER_ONLY)
10405 hdr_only = 1; 10406 hdr_only = 1;
10406 } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_control))) { 10407 } else if (libipw_is_data(le16_to_cpu(hdr->frame_control))) {
10407 if (filter & IPW_PROM_NO_DATA) 10408 if (filter & IPW_PROM_NO_DATA)
10408 return; 10409 return;
10409 if (filter & IPW_PROM_DATA_HEADER_ONLY) 10410 if (filter & IPW_PROM_DATA_HEADER_ONLY)
@@ -10418,7 +10419,7 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10418 10419
10419 if (hdr_only) { 10420 if (hdr_only) {
10420 hdr = (void *)src->data; 10421 hdr = (void *)src->data;
10421 len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); 10422 len = libipw_get_hdrlen(le16_to_cpu(hdr->frame_control));
10422 } else 10423 } else
10423 len = src->len; 10424 len = src->len;
10424 10425
@@ -10452,16 +10453,16 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10452 10453
10453 skb_copy_from_linear_data(src, skb_put(dst, len), len); 10454 skb_copy_from_linear_data(src, skb_put(dst, len), len);
10454 10455
10455 if (!ieee80211_rx(priv->prom_priv->ieee, dst, &dummystats)) 10456 if (!libipw_rx(priv->prom_priv->ieee, dst, &dummystats))
10456 dev_kfree_skb_any(dst); 10457 dev_kfree_skb_any(dst);
10457 } 10458 }
10458} 10459}
10459#endif 10460#endif
10460 10461
10461static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb, 10462static int ipw_net_hard_start_xmit(struct libipw_txb *txb,
10462 struct net_device *dev, int pri) 10463 struct net_device *dev, int pri)
10463{ 10464{
10464 struct ipw_priv *priv = ieee80211_priv(dev); 10465 struct ipw_priv *priv = libipw_priv(dev);
10465 unsigned long flags; 10466 unsigned long flags;
10466 int ret; 10467 int ret;
10467 10468
@@ -10488,7 +10489,7 @@ static void ipw_net_set_multicast_list(struct net_device *dev)
10488 10489
10489static int ipw_net_set_mac_address(struct net_device *dev, void *p) 10490static int ipw_net_set_mac_address(struct net_device *dev, void *p)
10490{ 10491{
10491 struct ipw_priv *priv = ieee80211_priv(dev); 10492 struct ipw_priv *priv = libipw_priv(dev);
10492 struct sockaddr *addr = p; 10493 struct sockaddr *addr = p;
10493 10494
10494 if (!is_valid_ether_addr(addr->sa_data)) 10495 if (!is_valid_ether_addr(addr->sa_data))
@@ -10506,7 +10507,7 @@ static int ipw_net_set_mac_address(struct net_device *dev, void *p)
10506static void ipw_ethtool_get_drvinfo(struct net_device *dev, 10507static void ipw_ethtool_get_drvinfo(struct net_device *dev,
10507 struct ethtool_drvinfo *info) 10508 struct ethtool_drvinfo *info)
10508{ 10509{
10509 struct ipw_priv *p = ieee80211_priv(dev); 10510 struct ipw_priv *p = libipw_priv(dev);
10510 char vers[64]; 10511 char vers[64];
10511 char date[32]; 10512 char date[32];
10512 u32 len; 10513 u32 len;
@@ -10527,7 +10528,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
10527 10528
10528static u32 ipw_ethtool_get_link(struct net_device *dev) 10529static u32 ipw_ethtool_get_link(struct net_device *dev)
10529{ 10530{
10530 struct ipw_priv *priv = ieee80211_priv(dev); 10531 struct ipw_priv *priv = libipw_priv(dev);
10531 return (priv->status & STATUS_ASSOCIATED) != 0; 10532 return (priv->status & STATUS_ASSOCIATED) != 0;
10532} 10533}
10533 10534
@@ -10539,7 +10540,7 @@ static int ipw_ethtool_get_eeprom_len(struct net_device *dev)
10539static int ipw_ethtool_get_eeprom(struct net_device *dev, 10540static int ipw_ethtool_get_eeprom(struct net_device *dev,
10540 struct ethtool_eeprom *eeprom, u8 * bytes) 10541 struct ethtool_eeprom *eeprom, u8 * bytes)
10541{ 10542{
10542 struct ipw_priv *p = ieee80211_priv(dev); 10543 struct ipw_priv *p = libipw_priv(dev);
10543 10544
10544 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) 10545 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE)
10545 return -EINVAL; 10546 return -EINVAL;
@@ -10552,7 +10553,7 @@ static int ipw_ethtool_get_eeprom(struct net_device *dev,
10552static int ipw_ethtool_set_eeprom(struct net_device *dev, 10553static int ipw_ethtool_set_eeprom(struct net_device *dev,
10553 struct ethtool_eeprom *eeprom, u8 * bytes) 10554 struct ethtool_eeprom *eeprom, u8 * bytes)
10554{ 10555{
10555 struct ipw_priv *p = ieee80211_priv(dev); 10556 struct ipw_priv *p = libipw_priv(dev);
10556 int i; 10557 int i;
10557 10558
10558 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) 10559 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE)
@@ -10768,9 +10769,9 @@ static int __devinit ipw_setup_deferred_work(struct ipw_priv *priv)
10768} 10769}
10769 10770
10770static void shim__set_security(struct net_device *dev, 10771static void shim__set_security(struct net_device *dev,
10771 struct ieee80211_security *sec) 10772 struct libipw_security *sec)
10772{ 10773{
10773 struct ipw_priv *priv = ieee80211_priv(dev); 10774 struct ipw_priv *priv = libipw_priv(dev);
10774 int i; 10775 int i;
10775 for (i = 0; i < 4; i++) { 10776 for (i = 0; i < 4; i++) {
10776 if (sec->flags & (1 << i)) { 10777 if (sec->flags & (1 << i)) {
@@ -10855,21 +10856,21 @@ static int init_supported_rates(struct ipw_priv *priv,
10855 memset(rates, 0, sizeof(*rates)); 10856 memset(rates, 0, sizeof(*rates));
10856 /* configure supported rates */ 10857 /* configure supported rates */
10857 switch (priv->ieee->freq_band) { 10858 switch (priv->ieee->freq_band) {
10858 case IEEE80211_52GHZ_BAND: 10859 case LIBIPW_52GHZ_BAND:
10859 rates->ieee_mode = IPW_A_MODE; 10860 rates->ieee_mode = IPW_A_MODE;
10860 rates->purpose = IPW_RATE_CAPABILITIES; 10861 rates->purpose = IPW_RATE_CAPABILITIES;
10861 ipw_add_ofdm_scan_rates(rates, IEEE80211_CCK_MODULATION, 10862 ipw_add_ofdm_scan_rates(rates, LIBIPW_CCK_MODULATION,
10862 IEEE80211_OFDM_DEFAULT_RATES_MASK); 10863 LIBIPW_OFDM_DEFAULT_RATES_MASK);
10863 break; 10864 break;
10864 10865
10865 default: /* Mixed or 2.4Ghz */ 10866 default: /* Mixed or 2.4Ghz */
10866 rates->ieee_mode = IPW_G_MODE; 10867 rates->ieee_mode = IPW_G_MODE;
10867 rates->purpose = IPW_RATE_CAPABILITIES; 10868 rates->purpose = IPW_RATE_CAPABILITIES;
10868 ipw_add_cck_scan_rates(rates, IEEE80211_CCK_MODULATION, 10869 ipw_add_cck_scan_rates(rates, LIBIPW_CCK_MODULATION,
10869 IEEE80211_CCK_DEFAULT_RATES_MASK); 10870 LIBIPW_CCK_DEFAULT_RATES_MASK);
10870 if (priv->ieee->modulation & IEEE80211_OFDM_MODULATION) { 10871 if (priv->ieee->modulation & LIBIPW_OFDM_MODULATION) {
10871 ipw_add_ofdm_scan_rates(rates, IEEE80211_CCK_MODULATION, 10872 ipw_add_ofdm_scan_rates(rates, LIBIPW_CCK_MODULATION,
10872 IEEE80211_OFDM_DEFAULT_RATES_MASK); 10873 LIBIPW_OFDM_DEFAULT_RATES_MASK);
10873 } 10874 }
10874 break; 10875 break;
10875 } 10876 }
@@ -10975,7 +10976,7 @@ static int ipw_config(struct ipw_priv *priv)
10975 * table. 10976 * table.
10976 * 10977 *
10977 */ 10978 */
10978static const struct ieee80211_geo ipw_geos[] = { 10979static const struct libipw_geo ipw_geos[] = {
10979 { /* Restricted */ 10980 { /* Restricted */
10980 "---", 10981 "---",
10981 .bg_channels = 11, 10982 .bg_channels = 11,
@@ -10997,10 +10998,10 @@ static const struct ieee80211_geo ipw_geos[] = {
10997 {5200, 40}, 10998 {5200, 40},
10998 {5220, 44}, 10999 {5220, 44},
10999 {5240, 48}, 11000 {5240, 48},
11000 {5260, 52, IEEE80211_CH_PASSIVE_ONLY}, 11001 {5260, 52, LIBIPW_CH_PASSIVE_ONLY},
11001 {5280, 56, IEEE80211_CH_PASSIVE_ONLY}, 11002 {5280, 56, LIBIPW_CH_PASSIVE_ONLY},
11002 {5300, 60, IEEE80211_CH_PASSIVE_ONLY}, 11003 {5300, 60, LIBIPW_CH_PASSIVE_ONLY},
11003 {5320, 64, IEEE80211_CH_PASSIVE_ONLY}}, 11004 {5320, 64, LIBIPW_CH_PASSIVE_ONLY}},
11004 }, 11005 },
11005 11006
11006 { /* Rest of World */ 11007 { /* Rest of World */
@@ -11025,10 +11026,10 @@ static const struct ieee80211_geo ipw_geos[] = {
11025 {5200, 40}, 11026 {5200, 40},
11026 {5220, 44}, 11027 {5220, 44},
11027 {5240, 48}, 11028 {5240, 48},
11028 {5260, 52, IEEE80211_CH_PASSIVE_ONLY}, 11029 {5260, 52, LIBIPW_CH_PASSIVE_ONLY},
11029 {5280, 56, IEEE80211_CH_PASSIVE_ONLY}, 11030 {5280, 56, LIBIPW_CH_PASSIVE_ONLY},
11030 {5300, 60, IEEE80211_CH_PASSIVE_ONLY}, 11031 {5300, 60, LIBIPW_CH_PASSIVE_ONLY},
11031 {5320, 64, IEEE80211_CH_PASSIVE_ONLY}, 11032 {5320, 64, LIBIPW_CH_PASSIVE_ONLY},
11032 {5745, 149}, 11033 {5745, 149},
11033 {5765, 153}, 11034 {5765, 153},
11034 {5785, 157}, 11035 {5785, 157},
@@ -11048,15 +11049,15 @@ static const struct ieee80211_geo ipw_geos[] = {
11048 {5200, 40}, 11049 {5200, 40},
11049 {5220, 44}, 11050 {5220, 44},
11050 {5240, 48}, 11051 {5240, 48},
11051 {5260, 52, IEEE80211_CH_PASSIVE_ONLY}, 11052 {5260, 52, LIBIPW_CH_PASSIVE_ONLY},
11052 {5280, 56, IEEE80211_CH_PASSIVE_ONLY}, 11053 {5280, 56, LIBIPW_CH_PASSIVE_ONLY},
11053 {5300, 60, IEEE80211_CH_PASSIVE_ONLY}, 11054 {5300, 60, LIBIPW_CH_PASSIVE_ONLY},
11054 {5320, 64, IEEE80211_CH_PASSIVE_ONLY}, 11055 {5320, 64, LIBIPW_CH_PASSIVE_ONLY},
11055 {5745, 149, IEEE80211_CH_PASSIVE_ONLY}, 11056 {5745, 149, LIBIPW_CH_PASSIVE_ONLY},
11056 {5765, 153, IEEE80211_CH_PASSIVE_ONLY}, 11057 {5765, 153, LIBIPW_CH_PASSIVE_ONLY},
11057 {5785, 157, IEEE80211_CH_PASSIVE_ONLY}, 11058 {5785, 157, LIBIPW_CH_PASSIVE_ONLY},
11058 {5805, 161, IEEE80211_CH_PASSIVE_ONLY}, 11059 {5805, 161, LIBIPW_CH_PASSIVE_ONLY},
11059 {5825, 165, IEEE80211_CH_PASSIVE_ONLY}}, 11060 {5825, 165, LIBIPW_CH_PASSIVE_ONLY}},
11060 }, 11061 },
11061 11062
11062 { /* Custom Japan */ 11063 { /* Custom Japan */
@@ -11093,21 +11094,21 @@ static const struct ieee80211_geo ipw_geos[] = {
11093 {5200, 40}, 11094 {5200, 40},
11094 {5220, 44}, 11095 {5220, 44},
11095 {5240, 48}, 11096 {5240, 48},
11096 {5260, 52, IEEE80211_CH_PASSIVE_ONLY}, 11097 {5260, 52, LIBIPW_CH_PASSIVE_ONLY},
11097 {5280, 56, IEEE80211_CH_PASSIVE_ONLY}, 11098 {5280, 56, LIBIPW_CH_PASSIVE_ONLY},
11098 {5300, 60, IEEE80211_CH_PASSIVE_ONLY}, 11099 {5300, 60, LIBIPW_CH_PASSIVE_ONLY},
11099 {5320, 64, IEEE80211_CH_PASSIVE_ONLY}, 11100 {5320, 64, LIBIPW_CH_PASSIVE_ONLY},
11100 {5500, 100, IEEE80211_CH_PASSIVE_ONLY}, 11101 {5500, 100, LIBIPW_CH_PASSIVE_ONLY},
11101 {5520, 104, IEEE80211_CH_PASSIVE_ONLY}, 11102 {5520, 104, LIBIPW_CH_PASSIVE_ONLY},
11102 {5540, 108, IEEE80211_CH_PASSIVE_ONLY}, 11103 {5540, 108, LIBIPW_CH_PASSIVE_ONLY},
11103 {5560, 112, IEEE80211_CH_PASSIVE_ONLY}, 11104 {5560, 112, LIBIPW_CH_PASSIVE_ONLY},
11104 {5580, 116, IEEE80211_CH_PASSIVE_ONLY}, 11105 {5580, 116, LIBIPW_CH_PASSIVE_ONLY},
11105 {5600, 120, IEEE80211_CH_PASSIVE_ONLY}, 11106 {5600, 120, LIBIPW_CH_PASSIVE_ONLY},
11106 {5620, 124, IEEE80211_CH_PASSIVE_ONLY}, 11107 {5620, 124, LIBIPW_CH_PASSIVE_ONLY},
11107 {5640, 128, IEEE80211_CH_PASSIVE_ONLY}, 11108 {5640, 128, LIBIPW_CH_PASSIVE_ONLY},
11108 {5660, 132, IEEE80211_CH_PASSIVE_ONLY}, 11109 {5660, 132, LIBIPW_CH_PASSIVE_ONLY},
11109 {5680, 136, IEEE80211_CH_PASSIVE_ONLY}, 11110 {5680, 136, LIBIPW_CH_PASSIVE_ONLY},
11110 {5700, 140, IEEE80211_CH_PASSIVE_ONLY}}, 11111 {5700, 140, LIBIPW_CH_PASSIVE_ONLY}},
11111 }, 11112 },
11112 11113
11113 { /* Custom Japan */ 11114 { /* Custom Japan */
@@ -11117,7 +11118,7 @@ static const struct ieee80211_geo ipw_geos[] = {
11117 {2427, 4}, {2432, 5}, {2437, 6}, 11118 {2427, 4}, {2432, 5}, {2437, 6},
11118 {2442, 7}, {2447, 8}, {2452, 9}, 11119 {2442, 7}, {2447, 8}, {2452, 9},
11119 {2457, 10}, {2462, 11}, {2467, 12}, 11120 {2457, 10}, {2462, 11}, {2467, 12},
11120 {2472, 13}, {2484, 14, IEEE80211_CH_B_ONLY}}, 11121 {2472, 13}, {2484, 14, LIBIPW_CH_B_ONLY}},
11121 .a_channels = 4, 11122 .a_channels = 4,
11122 .a = {{5170, 34}, {5190, 38}, 11123 .a = {{5170, 34}, {5190, 38},
11123 {5210, 42}, {5230, 46}}, 11124 {5210, 42}, {5230, 46}},
@@ -11130,8 +11131,8 @@ static const struct ieee80211_geo ipw_geos[] = {
11130 {2427, 4}, {2432, 5}, {2437, 6}, 11131 {2427, 4}, {2432, 5}, {2437, 6},
11131 {2442, 7}, {2447, 8}, {2452, 9}, 11132 {2442, 7}, {2447, 8}, {2452, 9},
11132 {2457, 10}, {2462, 11}, {2467, 12}, 11133 {2457, 10}, {2462, 11}, {2467, 12},
11133 {2472, 13}, {2484, 14, IEEE80211_CH_B_ONLY | 11134 {2472, 13}, {2484, 14, LIBIPW_CH_B_ONLY |
11134 IEEE80211_CH_PASSIVE_ONLY}}, 11135 LIBIPW_CH_PASSIVE_ONLY}},
11135 }, 11136 },
11136 11137
11137 { /* High Band */ 11138 { /* High Band */
@@ -11141,8 +11142,8 @@ static const struct ieee80211_geo ipw_geos[] = {
11141 {2427, 4}, {2432, 5}, {2437, 6}, 11142 {2427, 4}, {2432, 5}, {2437, 6},
11142 {2442, 7}, {2447, 8}, {2452, 9}, 11143 {2442, 7}, {2447, 8}, {2452, 9},
11143 {2457, 10}, {2462, 11}, 11144 {2457, 10}, {2462, 11},
11144 {2467, 12, IEEE80211_CH_PASSIVE_ONLY}, 11145 {2467, 12, LIBIPW_CH_PASSIVE_ONLY},
11145 {2472, 13, IEEE80211_CH_PASSIVE_ONLY}}, 11146 {2472, 13, LIBIPW_CH_PASSIVE_ONLY}},
11146 .a_channels = 4, 11147 .a_channels = 4,
11147 .a = {{5745, 149}, {5765, 153}, 11148 .a = {{5745, 149}, {5765, 153},
11148 {5785, 157}, {5805, 161}}, 11149 {5785, 157}, {5805, 161}},
@@ -11168,33 +11169,33 @@ static const struct ieee80211_geo ipw_geos[] = {
11168 {2427, 4}, {2432, 5}, {2437, 6}, 11169 {2427, 4}, {2432, 5}, {2437, 6},
11169 {2442, 7}, {2447, 8}, {2452, 9}, 11170 {2442, 7}, {2447, 8}, {2452, 9},
11170 {2457, 10}, {2462, 11}, 11171 {2457, 10}, {2462, 11},
11171 {2467, 12, IEEE80211_CH_PASSIVE_ONLY}, 11172 {2467, 12, LIBIPW_CH_PASSIVE_ONLY},
11172 {2472, 13, IEEE80211_CH_PASSIVE_ONLY}}, 11173 {2472, 13, LIBIPW_CH_PASSIVE_ONLY}},
11173 .a_channels = 24, 11174 .a_channels = 24,
11174 .a = {{5180, 36, IEEE80211_CH_PASSIVE_ONLY}, 11175 .a = {{5180, 36, LIBIPW_CH_PASSIVE_ONLY},
11175 {5200, 40, IEEE80211_CH_PASSIVE_ONLY}, 11176 {5200, 40, LIBIPW_CH_PASSIVE_ONLY},
11176 {5220, 44, IEEE80211_CH_PASSIVE_ONLY}, 11177 {5220, 44, LIBIPW_CH_PASSIVE_ONLY},
11177 {5240, 48, IEEE80211_CH_PASSIVE_ONLY}, 11178 {5240, 48, LIBIPW_CH_PASSIVE_ONLY},
11178 {5260, 52, IEEE80211_CH_PASSIVE_ONLY}, 11179 {5260, 52, LIBIPW_CH_PASSIVE_ONLY},
11179 {5280, 56, IEEE80211_CH_PASSIVE_ONLY}, 11180 {5280, 56, LIBIPW_CH_PASSIVE_ONLY},
11180 {5300, 60, IEEE80211_CH_PASSIVE_ONLY}, 11181 {5300, 60, LIBIPW_CH_PASSIVE_ONLY},
11181 {5320, 64, IEEE80211_CH_PASSIVE_ONLY}, 11182 {5320, 64, LIBIPW_CH_PASSIVE_ONLY},
11182 {5500, 100, IEEE80211_CH_PASSIVE_ONLY}, 11183 {5500, 100, LIBIPW_CH_PASSIVE_ONLY},
11183 {5520, 104, IEEE80211_CH_PASSIVE_ONLY}, 11184 {5520, 104, LIBIPW_CH_PASSIVE_ONLY},
11184 {5540, 108, IEEE80211_CH_PASSIVE_ONLY}, 11185 {5540, 108, LIBIPW_CH_PASSIVE_ONLY},
11185 {5560, 112, IEEE80211_CH_PASSIVE_ONLY}, 11186 {5560, 112, LIBIPW_CH_PASSIVE_ONLY},
11186 {5580, 116, IEEE80211_CH_PASSIVE_ONLY}, 11187 {5580, 116, LIBIPW_CH_PASSIVE_ONLY},
11187 {5600, 120, IEEE80211_CH_PASSIVE_ONLY}, 11188 {5600, 120, LIBIPW_CH_PASSIVE_ONLY},
11188 {5620, 124, IEEE80211_CH_PASSIVE_ONLY}, 11189 {5620, 124, LIBIPW_CH_PASSIVE_ONLY},
11189 {5640, 128, IEEE80211_CH_PASSIVE_ONLY}, 11190 {5640, 128, LIBIPW_CH_PASSIVE_ONLY},
11190 {5660, 132, IEEE80211_CH_PASSIVE_ONLY}, 11191 {5660, 132, LIBIPW_CH_PASSIVE_ONLY},
11191 {5680, 136, IEEE80211_CH_PASSIVE_ONLY}, 11192 {5680, 136, LIBIPW_CH_PASSIVE_ONLY},
11192 {5700, 140, IEEE80211_CH_PASSIVE_ONLY}, 11193 {5700, 140, LIBIPW_CH_PASSIVE_ONLY},
11193 {5745, 149, IEEE80211_CH_PASSIVE_ONLY}, 11194 {5745, 149, LIBIPW_CH_PASSIVE_ONLY},
11194 {5765, 153, IEEE80211_CH_PASSIVE_ONLY}, 11195 {5765, 153, LIBIPW_CH_PASSIVE_ONLY},
11195 {5785, 157, IEEE80211_CH_PASSIVE_ONLY}, 11196 {5785, 157, LIBIPW_CH_PASSIVE_ONLY},
11196 {5805, 161, IEEE80211_CH_PASSIVE_ONLY}, 11197 {5805, 161, LIBIPW_CH_PASSIVE_ONLY},
11197 {5825, 165, IEEE80211_CH_PASSIVE_ONLY}}, 11198 {5825, 165, LIBIPW_CH_PASSIVE_ONLY}},
11198 }, 11199 },
11199 11200
11200 { /* Europe */ 11201 { /* Europe */
@@ -11205,19 +11206,19 @@ static const struct ieee80211_geo ipw_geos[] = {
11205 {2442, 7}, {2447, 8}, {2452, 9}, 11206 {2442, 7}, {2447, 8}, {2452, 9},
11206 {2457, 10}, {2462, 11}}, 11207 {2457, 10}, {2462, 11}},
11207 .a_channels = 13, 11208 .a_channels = 13,
11208 .a = {{5180, 36, IEEE80211_CH_PASSIVE_ONLY}, 11209 .a = {{5180, 36, LIBIPW_CH_PASSIVE_ONLY},
11209 {5200, 40, IEEE80211_CH_PASSIVE_ONLY}, 11210 {5200, 40, LIBIPW_CH_PASSIVE_ONLY},
11210 {5220, 44, IEEE80211_CH_PASSIVE_ONLY}, 11211 {5220, 44, LIBIPW_CH_PASSIVE_ONLY},
11211 {5240, 48, IEEE80211_CH_PASSIVE_ONLY}, 11212 {5240, 48, LIBIPW_CH_PASSIVE_ONLY},
11212 {5260, 52, IEEE80211_CH_PASSIVE_ONLY}, 11213 {5260, 52, LIBIPW_CH_PASSIVE_ONLY},
11213 {5280, 56, IEEE80211_CH_PASSIVE_ONLY}, 11214 {5280, 56, LIBIPW_CH_PASSIVE_ONLY},
11214 {5300, 60, IEEE80211_CH_PASSIVE_ONLY}, 11215 {5300, 60, LIBIPW_CH_PASSIVE_ONLY},
11215 {5320, 64, IEEE80211_CH_PASSIVE_ONLY}, 11216 {5320, 64, LIBIPW_CH_PASSIVE_ONLY},
11216 {5745, 149, IEEE80211_CH_PASSIVE_ONLY}, 11217 {5745, 149, LIBIPW_CH_PASSIVE_ONLY},
11217 {5765, 153, IEEE80211_CH_PASSIVE_ONLY}, 11218 {5765, 153, LIBIPW_CH_PASSIVE_ONLY},
11218 {5785, 157, IEEE80211_CH_PASSIVE_ONLY}, 11219 {5785, 157, LIBIPW_CH_PASSIVE_ONLY},
11219 {5805, 161, IEEE80211_CH_PASSIVE_ONLY}, 11220 {5805, 161, LIBIPW_CH_PASSIVE_ONLY},
11220 {5825, 165, IEEE80211_CH_PASSIVE_ONLY}}, 11221 {5825, 165, LIBIPW_CH_PASSIVE_ONLY}},
11221 } 11222 }
11222}; 11223};
11223 11224
@@ -11228,7 +11229,7 @@ static int ipw_up(struct ipw_priv *priv)
11228 11229
11229 /* Age scan list entries found before suspend */ 11230 /* Age scan list entries found before suspend */
11230 if (priv->suspend_time) { 11231 if (priv->suspend_time) {
11231 ieee80211_networks_age(priv->ieee, priv->suspend_time); 11232 libipw_networks_age(priv->ieee, priv->suspend_time);
11232 priv->suspend_time = 0; 11233 priv->suspend_time = 0;
11233 } 11234 }
11234 11235
@@ -11273,7 +11274,7 @@ static int ipw_up(struct ipw_priv *priv)
11273 priv->eeprom[EEPROM_COUNTRY_CODE + 2]); 11274 priv->eeprom[EEPROM_COUNTRY_CODE + 2]);
11274 j = 0; 11275 j = 0;
11275 } 11276 }
11276 if (ieee80211_set_geo(priv->ieee, &ipw_geos[j])) { 11277 if (libipw_set_geo(priv->ieee, &ipw_geos[j])) {
11277 IPW_WARNING("Could not set geography."); 11278 IPW_WARNING("Could not set geography.");
11278 return 0; 11279 return 0;
11279 } 11280 }
@@ -11401,16 +11402,100 @@ static void ipw_bg_down(struct work_struct *work)
11401/* Called by register_netdev() */ 11402/* Called by register_netdev() */
11402static int ipw_net_init(struct net_device *dev) 11403static int ipw_net_init(struct net_device *dev)
11403{ 11404{
11404 struct ipw_priv *priv = ieee80211_priv(dev); 11405 int i, rc = 0;
11406 struct ipw_priv *priv = libipw_priv(dev);
11407 const struct libipw_geo *geo = libipw_get_geo(priv->ieee);
11408 struct wireless_dev *wdev = &priv->ieee->wdev;
11405 mutex_lock(&priv->mutex); 11409 mutex_lock(&priv->mutex);
11406 11410
11407 if (ipw_up(priv)) { 11411 if (ipw_up(priv)) {
11408 mutex_unlock(&priv->mutex); 11412 rc = -EIO;
11409 return -EIO; 11413 goto out;
11410 } 11414 }
11411 11415
11416 memcpy(wdev->wiphy->perm_addr, priv->mac_addr, ETH_ALEN);
11417
11418 /* fill-out priv->ieee->bg_band */
11419 if (geo->bg_channels) {
11420 struct ieee80211_supported_band *bg_band = &priv->ieee->bg_band;
11421
11422 bg_band->band = IEEE80211_BAND_2GHZ;
11423 bg_band->n_channels = geo->bg_channels;
11424 bg_band->channels =
11425 kzalloc(geo->bg_channels *
11426 sizeof(struct ieee80211_channel), GFP_KERNEL);
11427 /* translate geo->bg to bg_band.channels */
11428 for (i = 0; i < geo->bg_channels; i++) {
11429 bg_band->channels[i].band = IEEE80211_BAND_2GHZ;
11430 bg_band->channels[i].center_freq = geo->bg[i].freq;
11431 bg_band->channels[i].hw_value = geo->bg[i].channel;
11432 bg_band->channels[i].max_power = geo->bg[i].max_power;
11433 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
11434 bg_band->channels[i].flags |=
11435 IEEE80211_CHAN_PASSIVE_SCAN;
11436 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
11437 bg_band->channels[i].flags |=
11438 IEEE80211_CHAN_NO_IBSS;
11439 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
11440 bg_band->channels[i].flags |=
11441 IEEE80211_CHAN_RADAR;
11442 /* No equivalent for LIBIPW_CH_80211H_RULES,
11443 LIBIPW_CH_UNIFORM_SPREADING, or
11444 LIBIPW_CH_B_ONLY... */
11445 }
11446 /* point at bitrate info */
11447 bg_band->bitrates = ipw2200_bg_rates;
11448 bg_band->n_bitrates = ipw2200_num_bg_rates;
11449
11450 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = bg_band;
11451 }
11452
11453 /* fill-out priv->ieee->a_band */
11454 if (geo->a_channels) {
11455 struct ieee80211_supported_band *a_band = &priv->ieee->a_band;
11456
11457 a_band->band = IEEE80211_BAND_5GHZ;
11458 a_band->n_channels = geo->a_channels;
11459 a_band->channels =
11460 kzalloc(geo->a_channels *
11461 sizeof(struct ieee80211_channel), GFP_KERNEL);
11462 /* translate geo->bg to a_band.channels */
11463 for (i = 0; i < geo->a_channels; i++) {
11464 a_band->channels[i].band = IEEE80211_BAND_2GHZ;
11465 a_band->channels[i].center_freq = geo->a[i].freq;
11466 a_band->channels[i].hw_value = geo->a[i].channel;
11467 a_band->channels[i].max_power = geo->a[i].max_power;
11468 if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY)
11469 a_band->channels[i].flags |=
11470 IEEE80211_CHAN_PASSIVE_SCAN;
11471 if (geo->a[i].flags & LIBIPW_CH_NO_IBSS)
11472 a_band->channels[i].flags |=
11473 IEEE80211_CHAN_NO_IBSS;
11474 if (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT)
11475 a_band->channels[i].flags |=
11476 IEEE80211_CHAN_RADAR;
11477 /* No equivalent for LIBIPW_CH_80211H_RULES,
11478 LIBIPW_CH_UNIFORM_SPREADING, or
11479 LIBIPW_CH_B_ONLY... */
11480 }
11481 /* point at bitrate info */
11482 a_band->bitrates = ipw2200_a_rates;
11483 a_band->n_bitrates = ipw2200_num_a_rates;
11484
11485 wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = a_band;
11486 }
11487
11488 set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev);
11489
11490 /* With that information in place, we can now register the wiphy... */
11491 if (wiphy_register(wdev->wiphy)) {
11492 rc = -EIO;
11493 goto out;
11494 }
11495
11496out:
11412 mutex_unlock(&priv->mutex); 11497 mutex_unlock(&priv->mutex);
11413 return 0; 11498 return rc;
11414} 11499}
11415 11500
11416/* PCI driver stuff */ 11501/* PCI driver stuff */
@@ -11480,7 +11565,7 @@ static struct attribute_group ipw_attribute_group = {
11480#ifdef CONFIG_IPW2200_PROMISCUOUS 11565#ifdef CONFIG_IPW2200_PROMISCUOUS
11481static int ipw_prom_open(struct net_device *dev) 11566static int ipw_prom_open(struct net_device *dev)
11482{ 11567{
11483 struct ipw_prom_priv *prom_priv = ieee80211_priv(dev); 11568 struct ipw_prom_priv *prom_priv = libipw_priv(dev);
11484 struct ipw_priv *priv = prom_priv->priv; 11569 struct ipw_priv *priv = prom_priv->priv;
11485 11570
11486 IPW_DEBUG_INFO("prom dev->open\n"); 11571 IPW_DEBUG_INFO("prom dev->open\n");
@@ -11500,7 +11585,7 @@ static int ipw_prom_open(struct net_device *dev)
11500 11585
11501static int ipw_prom_stop(struct net_device *dev) 11586static int ipw_prom_stop(struct net_device *dev)
11502{ 11587{
11503 struct ipw_prom_priv *prom_priv = ieee80211_priv(dev); 11588 struct ipw_prom_priv *prom_priv = libipw_priv(dev);
11504 struct ipw_priv *priv = prom_priv->priv; 11589 struct ipw_priv *priv = prom_priv->priv;
11505 11590
11506 IPW_DEBUG_INFO("prom dev->stop\n"); 11591 IPW_DEBUG_INFO("prom dev->stop\n");
@@ -11528,7 +11613,7 @@ static const struct net_device_ops ipw_prom_netdev_ops = {
11528 .ndo_open = ipw_prom_open, 11613 .ndo_open = ipw_prom_open,
11529 .ndo_stop = ipw_prom_stop, 11614 .ndo_stop = ipw_prom_stop,
11530 .ndo_start_xmit = ipw_prom_hard_start_xmit, 11615 .ndo_start_xmit = ipw_prom_hard_start_xmit,
11531 .ndo_change_mtu = ieee80211_change_mtu, 11616 .ndo_change_mtu = libipw_change_mtu,
11532 .ndo_set_mac_address = eth_mac_addr, 11617 .ndo_set_mac_address = eth_mac_addr,
11533 .ndo_validate_addr = eth_validate_addr, 11618 .ndo_validate_addr = eth_validate_addr,
11534}; 11619};
@@ -11540,11 +11625,11 @@ static int ipw_prom_alloc(struct ipw_priv *priv)
11540 if (priv->prom_net_dev) 11625 if (priv->prom_net_dev)
11541 return -EPERM; 11626 return -EPERM;
11542 11627
11543 priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv)); 11628 priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv), 1);
11544 if (priv->prom_net_dev == NULL) 11629 if (priv->prom_net_dev == NULL)
11545 return -ENOMEM; 11630 return -ENOMEM;
11546 11631
11547 priv->prom_priv = ieee80211_priv(priv->prom_net_dev); 11632 priv->prom_priv = libipw_priv(priv->prom_net_dev);
11548 priv->prom_priv->ieee = netdev_priv(priv->prom_net_dev); 11633 priv->prom_priv->ieee = netdev_priv(priv->prom_net_dev);
11549 priv->prom_priv->priv = priv; 11634 priv->prom_priv->priv = priv;
11550 11635
@@ -11559,7 +11644,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv)
11559 11644
11560 rc = register_netdev(priv->prom_net_dev); 11645 rc = register_netdev(priv->prom_net_dev);
11561 if (rc) { 11646 if (rc) {
11562 free_ieee80211(priv->prom_net_dev); 11647 free_ieee80211(priv->prom_net_dev, 1);
11563 priv->prom_net_dev = NULL; 11648 priv->prom_net_dev = NULL;
11564 return rc; 11649 return rc;
11565 } 11650 }
@@ -11573,7 +11658,7 @@ static void ipw_prom_free(struct ipw_priv *priv)
11573 return; 11658 return;
11574 11659
11575 unregister_netdev(priv->prom_net_dev); 11660 unregister_netdev(priv->prom_net_dev);
11576 free_ieee80211(priv->prom_net_dev); 11661 free_ieee80211(priv->prom_net_dev, 1);
11577 11662
11578 priv->prom_net_dev = NULL; 11663 priv->prom_net_dev = NULL;
11579} 11664}
@@ -11586,8 +11671,8 @@ static const struct net_device_ops ipw_netdev_ops = {
11586 .ndo_stop = ipw_net_stop, 11671 .ndo_stop = ipw_net_stop,
11587 .ndo_set_multicast_list = ipw_net_set_multicast_list, 11672 .ndo_set_multicast_list = ipw_net_set_multicast_list,
11588 .ndo_set_mac_address = ipw_net_set_mac_address, 11673 .ndo_set_mac_address = ipw_net_set_mac_address,
11589 .ndo_start_xmit = ieee80211_xmit, 11674 .ndo_start_xmit = libipw_xmit,
11590 .ndo_change_mtu = ieee80211_change_mtu, 11675 .ndo_change_mtu = libipw_change_mtu,
11591 .ndo_validate_addr = eth_validate_addr, 11676 .ndo_validate_addr = eth_validate_addr,
11592}; 11677};
11593 11678
@@ -11601,13 +11686,13 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
11601 struct ipw_priv *priv; 11686 struct ipw_priv *priv;
11602 int i; 11687 int i;
11603 11688
11604 net_dev = alloc_ieee80211(sizeof(struct ipw_priv)); 11689 net_dev = alloc_ieee80211(sizeof(struct ipw_priv), 0);
11605 if (net_dev == NULL) { 11690 if (net_dev == NULL) {
11606 err = -ENOMEM; 11691 err = -ENOMEM;
11607 goto out; 11692 goto out;
11608 } 11693 }
11609 11694
11610 priv = ieee80211_priv(net_dev); 11695 priv = libipw_priv(net_dev);
11611 priv->ieee = netdev_priv(net_dev); 11696 priv->ieee = netdev_priv(net_dev);
11612 11697
11613 priv->net_dev = net_dev; 11698 priv->net_dev = net_dev;
@@ -11749,7 +11834,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
11749 pci_disable_device(pdev); 11834 pci_disable_device(pdev);
11750 pci_set_drvdata(pdev, NULL); 11835 pci_set_drvdata(pdev, NULL);
11751 out_free_ieee80211: 11836 out_free_ieee80211:
11752 free_ieee80211(priv->net_dev); 11837 free_ieee80211(priv->net_dev, 0);
11753 out: 11838 out:
11754 return err; 11839 return err;
11755} 11840}
@@ -11816,7 +11901,7 @@ static void __devexit ipw_pci_remove(struct pci_dev *pdev)
11816 pci_release_regions(pdev); 11901 pci_release_regions(pdev);
11817 pci_disable_device(pdev); 11902 pci_disable_device(pdev);
11818 pci_set_drvdata(pdev, NULL); 11903 pci_set_drvdata(pdev, NULL);
11819 free_ieee80211(priv->net_dev); 11904 free_ieee80211(priv->net_dev, 0);
11820 free_firmware(); 11905 free_firmware();
11821} 11906}
11822 11907
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.h b/drivers/net/wireless/ipw2x00/ipw2200.h
index 05e8ccf01c5f..bf0eeb2e873a 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.h
+++ b/drivers/net/wireless/ipw2x00/ipw2200.h
@@ -19,7 +19,7 @@
19 file called LICENSE. 19 file called LICENSE.
20 20
21 Contact Information: 21 Contact Information:
22 James P. Ketrenos <ipw2100-admin@linux.intel.com> 22 Intel Linux Wireless <ilw@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 24
25******************************************************************************/ 25******************************************************************************/
@@ -55,7 +55,7 @@
55 55
56#include <linux/workqueue.h> 56#include <linux/workqueue.h>
57 57
58#include "ieee80211.h" 58#include "libipw.h"
59 59
60/* Authentication and Association States */ 60/* Authentication and Association States */
61enum connection_manager_assoc_states { 61enum connection_manager_assoc_states {
@@ -365,8 +365,8 @@ enum connection_manager_assoc_states {
365/* QoS sturctures */ 365/* QoS sturctures */
366struct ipw_qos_info { 366struct ipw_qos_info {
367 int qos_enable; 367 int qos_enable;
368 struct ieee80211_qos_parameters *def_qos_parm_OFDM; 368 struct libipw_qos_parameters *def_qos_parm_OFDM;
369 struct ieee80211_qos_parameters *def_qos_parm_CCK; 369 struct libipw_qos_parameters *def_qos_parm_CCK;
370 u32 burst_duration_CCK; 370 u32 burst_duration_CCK;
371 u32 burst_duration_OFDM; 371 u32 burst_duration_OFDM;
372 u16 qos_no_ack_mask; 372 u16 qos_no_ack_mask;
@@ -534,7 +534,7 @@ typedef void destructor_func(const void *);
534struct clx2_tx_queue { 534struct clx2_tx_queue {
535 struct clx2_queue q; 535 struct clx2_queue q;
536 struct tfd_frame *bd; 536 struct tfd_frame *bd;
537 struct ieee80211_txb **txb; 537 struct libipw_txb **txb;
538}; 538};
539 539
540/* 540/*
@@ -1144,7 +1144,7 @@ enum ipw_prom_filter {
1144struct ipw_priv; 1144struct ipw_priv;
1145struct ipw_prom_priv { 1145struct ipw_prom_priv {
1146 struct ipw_priv *priv; 1146 struct ipw_priv *priv;
1147 struct ieee80211_device *ieee; 1147 struct libipw_device *ieee;
1148 enum ipw_prom_filter filter; 1148 enum ipw_prom_filter filter;
1149 int tx_packets; 1149 int tx_packets;
1150 int rx_packets; 1150 int rx_packets;
@@ -1175,7 +1175,7 @@ struct ipw_rt_hdr {
1175 1175
1176struct ipw_priv { 1176struct ipw_priv {
1177 /* ieee device used by generic ieee processing code */ 1177 /* ieee device used by generic ieee processing code */
1178 struct ieee80211_device *ieee; 1178 struct libipw_device *ieee;
1179 1179
1180 spinlock_t lock; 1180 spinlock_t lock;
1181 spinlock_t irq_lock; 1181 spinlock_t irq_lock;
@@ -1222,7 +1222,7 @@ struct ipw_priv {
1222 u32 roaming_threshold; 1222 u32 roaming_threshold;
1223 1223
1224 struct ipw_associate assoc_request; 1224 struct ipw_associate assoc_request;
1225 struct ieee80211_network *assoc_network; 1225 struct libipw_network *assoc_network;
1226 1226
1227 unsigned long ts_scan_abort; 1227 unsigned long ts_scan_abort;
1228 struct ipw_supported_rates rates; 1228 struct ipw_supported_rates rates;
diff --git a/drivers/net/wireless/ipw2x00/ieee80211.h b/drivers/net/wireless/ipw2x00/libipw.h
index 70755c1336d5..8f91d3427ce5 100644
--- a/drivers/net/wireless/ipw2x00/ieee80211.h
+++ b/drivers/net/wireless/ipw2x00/libipw.h
@@ -20,21 +20,22 @@
20 * 20 *
21 * API Version History 21 * API Version History
22 * 1.0.x -- Initial version 22 * 1.0.x -- Initial version
23 * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs, 23 * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs,
24 * various structure changes, and crypto API init method 24 * various structure changes, and crypto API init method
25 */ 25 */
26#ifndef IEEE80211_H 26#ifndef LIBIPW_H
27#define IEEE80211_H 27#define LIBIPW_H
28#include <linux/if_ether.h> /* ETH_ALEN */ 28#include <linux/if_ether.h> /* ETH_ALEN */
29#include <linux/kernel.h> /* ARRAY_SIZE */ 29#include <linux/kernel.h> /* ARRAY_SIZE */
30#include <linux/wireless.h> 30#include <linux/wireless.h>
31#include <linux/ieee80211.h> 31#include <linux/ieee80211.h>
32 32
33#include <net/lib80211.h> 33#include <net/lib80211.h>
34#include <net/cfg80211.h>
34 35
35#define IEEE80211_VERSION "git-1.1.13" 36#define LIBIPW_VERSION "git-1.1.13"
36 37
37#define IEEE80211_DATA_LEN 2304 38#define LIBIPW_DATA_LEN 2304
38/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 39/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
39 6.2.1.1.2. 40 6.2.1.1.2.
40 41
@@ -43,35 +44,35 @@
43 represents the 2304 bytes of real data, plus a possible 8 bytes of 44 represents the 2304 bytes of real data, plus a possible 8 bytes of
44 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 45 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
45 46
46#define IEEE80211_1ADDR_LEN 10 47#define LIBIPW_1ADDR_LEN 10
47#define IEEE80211_2ADDR_LEN 16 48#define LIBIPW_2ADDR_LEN 16
48#define IEEE80211_3ADDR_LEN 24 49#define LIBIPW_3ADDR_LEN 24
49#define IEEE80211_4ADDR_LEN 30 50#define LIBIPW_4ADDR_LEN 30
50#define IEEE80211_FCS_LEN 4 51#define LIBIPW_FCS_LEN 4
51#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) 52#define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
52#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) 53#define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
53 54
54#define MIN_FRAG_THRESHOLD 256U 55#define MIN_FRAG_THRESHOLD 256U
55#define MAX_FRAG_THRESHOLD 2346U 56#define MAX_FRAG_THRESHOLD 2346U
56 57
57/* QOS control */ 58/* QOS control */
58#define IEEE80211_QCTL_TID 0x000F 59#define LIBIPW_QCTL_TID 0x000F
59 60
60/* debug macros */ 61/* debug macros */
61 62
62#ifdef CONFIG_LIBIPW_DEBUG 63#ifdef CONFIG_LIBIPW_DEBUG
63extern u32 ieee80211_debug_level; 64extern u32 libipw_debug_level;
64#define IEEE80211_DEBUG(level, fmt, args...) \ 65#define LIBIPW_DEBUG(level, fmt, args...) \
65do { if (ieee80211_debug_level & (level)) \ 66do { if (libipw_debug_level & (level)) \
66 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 67 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
67 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) 68 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
68static inline bool ieee80211_ratelimit_debug(u32 level) 69static inline bool libipw_ratelimit_debug(u32 level)
69{ 70{
70 return (ieee80211_debug_level & level) && net_ratelimit(); 71 return (libipw_debug_level & level) && net_ratelimit();
71} 72}
72#else 73#else
73#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 74#define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
74static inline bool ieee80211_ratelimit_debug(u32 level) 75static inline bool libipw_ratelimit_debug(u32 level)
75{ 76{
76 return false; 77 return false;
77} 78}
@@ -83,51 +84,51 @@ static inline bool ieee80211_ratelimit_debug(u32 level)
83 * If you are defining a new debug classification, simply add it to the #define 84 * If you are defining a new debug classification, simply add it to the #define
84 * list here in the form of: 85 * list here in the form of:
85 * 86 *
86 * #define IEEE80211_DL_xxxx VALUE 87 * #define LIBIPW_DL_xxxx VALUE
87 * 88 *
88 * shifting value to the left one bit from the previous entry. xxxx should be 89 * shifting value to the left one bit from the previous entry. xxxx should be
89 * the name of the classification (for example, WEP) 90 * the name of the classification (for example, WEP)
90 * 91 *
91 * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your 92 * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
92 * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want 93 * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
93 * to send output to that classification. 94 * to send output to that classification.
94 * 95 *
95 * To add your debug level to the list of levels seen when you perform 96 * To add your debug level to the list of levels seen when you perform
96 * 97 *
97 * % cat /proc/net/ieee80211/debug_level 98 * % cat /proc/net/ieee80211/debug_level
98 * 99 *
99 * you simply need to add your entry to the ieee80211_debug_level array. 100 * you simply need to add your entry to the libipw_debug_level array.
100 * 101 *
101 * If you do not see debug_level in /proc/net/ieee80211 then you do not have 102 * If you do not see debug_level in /proc/net/ieee80211 then you do not have
102 * CONFIG_LIBIPW_DEBUG defined in your kernel configuration 103 * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
103 * 104 *
104 */ 105 */
105 106
106#define IEEE80211_DL_INFO (1<<0) 107#define LIBIPW_DL_INFO (1<<0)
107#define IEEE80211_DL_WX (1<<1) 108#define LIBIPW_DL_WX (1<<1)
108#define IEEE80211_DL_SCAN (1<<2) 109#define LIBIPW_DL_SCAN (1<<2)
109#define IEEE80211_DL_STATE (1<<3) 110#define LIBIPW_DL_STATE (1<<3)
110#define IEEE80211_DL_MGMT (1<<4) 111#define LIBIPW_DL_MGMT (1<<4)
111#define IEEE80211_DL_FRAG (1<<5) 112#define LIBIPW_DL_FRAG (1<<5)
112#define IEEE80211_DL_DROP (1<<7) 113#define LIBIPW_DL_DROP (1<<7)
113 114
114#define IEEE80211_DL_TX (1<<8) 115#define LIBIPW_DL_TX (1<<8)
115#define IEEE80211_DL_RX (1<<9) 116#define LIBIPW_DL_RX (1<<9)
116#define IEEE80211_DL_QOS (1<<31) 117#define LIBIPW_DL_QOS (1<<31)
117 118
118#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) 119#define LIBIPW_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
119#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) 120#define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
120#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a) 121#define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
121 122
122#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a) 123#define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
123#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a) 124#define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
124#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a) 125#define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
125#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a) 126#define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
126#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a) 127#define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
127#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a) 128#define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
128#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a) 129#define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
129#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) 130#define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
130#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a) 131#define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
131#include <linux/netdevice.h> 132#include <linux/netdevice.h>
132#include <linux/if_arp.h> /* ARPHRD_ETHER */ 133#include <linux/if_arp.h> /* ARPHRD_ETHER */
133 134
@@ -146,7 +147,7 @@ static inline bool ieee80211_ratelimit_debug(u32 level)
146 147
147#define P80211_OUI_LEN 3 148#define P80211_OUI_LEN 3
148 149
149struct ieee80211_snap_hdr { 150struct libipw_snap_hdr {
150 151
151 u8 dsap; /* always 0xAA */ 152 u8 dsap; /* always 0xAA */
152 u8 ssap; /* always 0xAA */ 153 u8 ssap; /* always 0xAA */
@@ -155,7 +156,7 @@ struct ieee80211_snap_hdr {
155 156
156} __attribute__ ((packed)); 157} __attribute__ ((packed));
157 158
158#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) 159#define SNAP_SIZE sizeof(struct libipw_snap_hdr)
159 160
160#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) 161#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
161#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) 162#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
@@ -164,74 +165,74 @@ struct ieee80211_snap_hdr {
164#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) 165#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
165#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 166#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
166 167
167#define IEEE80211_STATMASK_SIGNAL (1<<0) 168#define LIBIPW_STATMASK_SIGNAL (1<<0)
168#define IEEE80211_STATMASK_RSSI (1<<1) 169#define LIBIPW_STATMASK_RSSI (1<<1)
169#define IEEE80211_STATMASK_NOISE (1<<2) 170#define LIBIPW_STATMASK_NOISE (1<<2)
170#define IEEE80211_STATMASK_RATE (1<<3) 171#define LIBIPW_STATMASK_RATE (1<<3)
171#define IEEE80211_STATMASK_WEMASK 0x7 172#define LIBIPW_STATMASK_WEMASK 0x7
172 173
173#define IEEE80211_CCK_MODULATION (1<<0) 174#define LIBIPW_CCK_MODULATION (1<<0)
174#define IEEE80211_OFDM_MODULATION (1<<1) 175#define LIBIPW_OFDM_MODULATION (1<<1)
175 176
176#define IEEE80211_24GHZ_BAND (1<<0) 177#define LIBIPW_24GHZ_BAND (1<<0)
177#define IEEE80211_52GHZ_BAND (1<<1) 178#define LIBIPW_52GHZ_BAND (1<<1)
178 179
179#define IEEE80211_CCK_RATE_1MB 0x02 180#define LIBIPW_CCK_RATE_1MB 0x02
180#define IEEE80211_CCK_RATE_2MB 0x04 181#define LIBIPW_CCK_RATE_2MB 0x04
181#define IEEE80211_CCK_RATE_5MB 0x0B 182#define LIBIPW_CCK_RATE_5MB 0x0B
182#define IEEE80211_CCK_RATE_11MB 0x16 183#define LIBIPW_CCK_RATE_11MB 0x16
183#define IEEE80211_OFDM_RATE_6MB 0x0C 184#define LIBIPW_OFDM_RATE_6MB 0x0C
184#define IEEE80211_OFDM_RATE_9MB 0x12 185#define LIBIPW_OFDM_RATE_9MB 0x12
185#define IEEE80211_OFDM_RATE_12MB 0x18 186#define LIBIPW_OFDM_RATE_12MB 0x18
186#define IEEE80211_OFDM_RATE_18MB 0x24 187#define LIBIPW_OFDM_RATE_18MB 0x24
187#define IEEE80211_OFDM_RATE_24MB 0x30 188#define LIBIPW_OFDM_RATE_24MB 0x30
188#define IEEE80211_OFDM_RATE_36MB 0x48 189#define LIBIPW_OFDM_RATE_36MB 0x48
189#define IEEE80211_OFDM_RATE_48MB 0x60 190#define LIBIPW_OFDM_RATE_48MB 0x60
190#define IEEE80211_OFDM_RATE_54MB 0x6C 191#define LIBIPW_OFDM_RATE_54MB 0x6C
191#define IEEE80211_BASIC_RATE_MASK 0x80 192#define LIBIPW_BASIC_RATE_MASK 0x80
192 193
193#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) 194#define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
194#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) 195#define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
195#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) 196#define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
196#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) 197#define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
197#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) 198#define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
198#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) 199#define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
199#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) 200#define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
200#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) 201#define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
201#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) 202#define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
202#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) 203#define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
203#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) 204#define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
204#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) 205#define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
205 206
206#define IEEE80211_CCK_RATES_MASK 0x0000000F 207#define LIBIPW_CCK_RATES_MASK 0x0000000F
207#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ 208#define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
208 IEEE80211_CCK_RATE_2MB_MASK) 209 LIBIPW_CCK_RATE_2MB_MASK)
209#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ 210#define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
210 IEEE80211_CCK_RATE_5MB_MASK | \ 211 LIBIPW_CCK_RATE_5MB_MASK | \
211 IEEE80211_CCK_RATE_11MB_MASK) 212 LIBIPW_CCK_RATE_11MB_MASK)
212 213
213#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 214#define LIBIPW_OFDM_RATES_MASK 0x00000FF0
214#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ 215#define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
215 IEEE80211_OFDM_RATE_12MB_MASK | \ 216 LIBIPW_OFDM_RATE_12MB_MASK | \
216 IEEE80211_OFDM_RATE_24MB_MASK) 217 LIBIPW_OFDM_RATE_24MB_MASK)
217#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ 218#define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
218 IEEE80211_OFDM_RATE_9MB_MASK | \ 219 LIBIPW_OFDM_RATE_9MB_MASK | \
219 IEEE80211_OFDM_RATE_18MB_MASK | \ 220 LIBIPW_OFDM_RATE_18MB_MASK | \
220 IEEE80211_OFDM_RATE_36MB_MASK | \ 221 LIBIPW_OFDM_RATE_36MB_MASK | \
221 IEEE80211_OFDM_RATE_48MB_MASK | \ 222 LIBIPW_OFDM_RATE_48MB_MASK | \
222 IEEE80211_OFDM_RATE_54MB_MASK) 223 LIBIPW_OFDM_RATE_54MB_MASK)
223#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ 224#define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
224 IEEE80211_CCK_DEFAULT_RATES_MASK) 225 LIBIPW_CCK_DEFAULT_RATES_MASK)
225 226
226#define IEEE80211_NUM_OFDM_RATES 8 227#define LIBIPW_NUM_OFDM_RATES 8
227#define IEEE80211_NUM_CCK_RATES 4 228#define LIBIPW_NUM_CCK_RATES 4
228#define IEEE80211_OFDM_SHIFT_MASK_A 4 229#define LIBIPW_OFDM_SHIFT_MASK_A 4
229 230
230/* NOTE: This data is for statistical purposes; not all hardware provides this 231/* NOTE: This data is for statistical purposes; not all hardware provides this
231 * information for frames received. 232 * information for frames received.
232 * For ieee80211_rx_mgt, you need to set at least the 'len' parameter. 233 * For libipw_rx_mgt, you need to set at least the 'len' parameter.
233 */ 234 */
234struct ieee80211_rx_stats { 235struct libipw_rx_stats {
235 u32 mac_time; 236 u32 mac_time;
236 s8 rssi; 237 s8 rssi;
237 u8 signal; 238 u8 signal;
@@ -250,9 +251,9 @@ struct ieee80211_rx_stats {
250 * three fragmented frames. This define can be increased to support more 251 * three fragmented frames. This define can be increased to support more
251 * concurrent frames, but it should be noted that each entry can consume about 252 * concurrent frames, but it should be noted that each entry can consume about
252 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 253 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
253#define IEEE80211_FRAG_CACHE_LEN 4 254#define LIBIPW_FRAG_CACHE_LEN 4
254 255
255struct ieee80211_frag_entry { 256struct libipw_frag_entry {
256 unsigned long first_frag_time; 257 unsigned long first_frag_time;
257 unsigned int seq; 258 unsigned int seq;
258 unsigned int last_frag; 259 unsigned int last_frag;
@@ -261,7 +262,7 @@ struct ieee80211_frag_entry {
261 u8 dst_addr[ETH_ALEN]; 262 u8 dst_addr[ETH_ALEN];
262}; 263};
263 264
264struct ieee80211_stats { 265struct libipw_stats {
265 unsigned int tx_unicast_frames; 266 unsigned int tx_unicast_frames;
266 unsigned int tx_multicast_frames; 267 unsigned int tx_multicast_frames;
267 unsigned int tx_fragments; 268 unsigned int tx_fragments;
@@ -285,7 +286,7 @@ struct ieee80211_stats {
285 unsigned int rx_message_in_bad_msg_fragments; 286 unsigned int rx_message_in_bad_msg_fragments;
286}; 287};
287 288
288struct ieee80211_device; 289struct libipw_device;
289 290
290#define SEC_KEY_1 (1<<0) 291#define SEC_KEY_1 (1<<0)
291#define SEC_KEY_2 (1<<1) 292#define SEC_KEY_2 (1<<1)
@@ -314,7 +315,7 @@ struct ieee80211_device;
314#define SCM_KEY_LEN 32 315#define SCM_KEY_LEN 32
315#define SCM_TEMPORAL_KEY_LENGTH 16 316#define SCM_TEMPORAL_KEY_LENGTH 16
316 317
317struct ieee80211_security { 318struct libipw_security {
318 u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1; 319 u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
319 u8 auth_mode; 320 u8 auth_mode;
320 u8 encode_alg[WEP_KEYS]; 321 u8 encode_alg[WEP_KEYS];
@@ -341,14 +342,14 @@ Total: 28-2340 bytes
341 342
342#define BEACON_PROBE_SSID_ID_POSITION 12 343#define BEACON_PROBE_SSID_ID_POSITION 12
343 344
344struct ieee80211_hdr_1addr { 345struct libipw_hdr_1addr {
345 __le16 frame_ctl; 346 __le16 frame_ctl;
346 __le16 duration_id; 347 __le16 duration_id;
347 u8 addr1[ETH_ALEN]; 348 u8 addr1[ETH_ALEN];
348 u8 payload[0]; 349 u8 payload[0];
349} __attribute__ ((packed)); 350} __attribute__ ((packed));
350 351
351struct ieee80211_hdr_2addr { 352struct libipw_hdr_2addr {
352 __le16 frame_ctl; 353 __le16 frame_ctl;
353 __le16 duration_id; 354 __le16 duration_id;
354 u8 addr1[ETH_ALEN]; 355 u8 addr1[ETH_ALEN];
@@ -356,7 +357,7 @@ struct ieee80211_hdr_2addr {
356 u8 payload[0]; 357 u8 payload[0];
357} __attribute__ ((packed)); 358} __attribute__ ((packed));
358 359
359struct ieee80211_hdr_3addr { 360struct libipw_hdr_3addr {
360 __le16 frame_ctl; 361 __le16 frame_ctl;
361 __le16 duration_id; 362 __le16 duration_id;
362 u8 addr1[ETH_ALEN]; 363 u8 addr1[ETH_ALEN];
@@ -366,7 +367,7 @@ struct ieee80211_hdr_3addr {
366 u8 payload[0]; 367 u8 payload[0];
367} __attribute__ ((packed)); 368} __attribute__ ((packed));
368 369
369struct ieee80211_hdr_4addr { 370struct libipw_hdr_4addr {
370 __le16 frame_ctl; 371 __le16 frame_ctl;
371 __le16 duration_id; 372 __le16 duration_id;
372 u8 addr1[ETH_ALEN]; 373 u8 addr1[ETH_ALEN];
@@ -377,7 +378,7 @@ struct ieee80211_hdr_4addr {
377 u8 payload[0]; 378 u8 payload[0];
378} __attribute__ ((packed)); 379} __attribute__ ((packed));
379 380
380struct ieee80211_hdr_3addrqos { 381struct libipw_hdr_3addrqos {
381 __le16 frame_ctl; 382 __le16 frame_ctl;
382 __le16 duration_id; 383 __le16 duration_id;
383 u8 addr1[ETH_ALEN]; 384 u8 addr1[ETH_ALEN];
@@ -388,7 +389,7 @@ struct ieee80211_hdr_3addrqos {
388 __le16 qos_ctl; 389 __le16 qos_ctl;
389} __attribute__ ((packed)); 390} __attribute__ ((packed));
390 391
391struct ieee80211_info_element { 392struct libipw_info_element {
392 u8 id; 393 u8 id;
393 u8 len; 394 u8 len;
394 u8 data[0]; 395 u8 data[0];
@@ -411,16 +412,16 @@ struct ieee80211_info_element {
411 u16 status; 412 u16 status;
412*/ 413*/
413 414
414struct ieee80211_auth { 415struct libipw_auth {
415 struct ieee80211_hdr_3addr header; 416 struct libipw_hdr_3addr header;
416 __le16 algorithm; 417 __le16 algorithm;
417 __le16 transaction; 418 __le16 transaction;
418 __le16 status; 419 __le16 status;
419 /* challenge */ 420 /* challenge */
420 struct ieee80211_info_element info_element[0]; 421 struct libipw_info_element info_element[0];
421} __attribute__ ((packed)); 422} __attribute__ ((packed));
422 423
423struct ieee80211_channel_switch { 424struct libipw_channel_switch {
424 u8 id; 425 u8 id;
425 u8 len; 426 u8 len;
426 u8 mode; 427 u8 mode;
@@ -428,73 +429,73 @@ struct ieee80211_channel_switch {
428 u8 count; 429 u8 count;
429} __attribute__ ((packed)); 430} __attribute__ ((packed));
430 431
431struct ieee80211_action { 432struct libipw_action {
432 struct ieee80211_hdr_3addr header; 433 struct libipw_hdr_3addr header;
433 u8 category; 434 u8 category;
434 u8 action; 435 u8 action;
435 union { 436 union {
436 struct ieee80211_action_exchange { 437 struct libipw_action_exchange {
437 u8 token; 438 u8 token;
438 struct ieee80211_info_element info_element[0]; 439 struct libipw_info_element info_element[0];
439 } exchange; 440 } exchange;
440 struct ieee80211_channel_switch channel_switch; 441 struct libipw_channel_switch channel_switch;
441 442
442 } format; 443 } format;
443} __attribute__ ((packed)); 444} __attribute__ ((packed));
444 445
445struct ieee80211_disassoc { 446struct libipw_disassoc {
446 struct ieee80211_hdr_3addr header; 447 struct libipw_hdr_3addr header;
447 __le16 reason; 448 __le16 reason;
448} __attribute__ ((packed)); 449} __attribute__ ((packed));
449 450
450/* Alias deauth for disassoc */ 451/* Alias deauth for disassoc */
451#define ieee80211_deauth ieee80211_disassoc 452#define libipw_deauth libipw_disassoc
452 453
453struct ieee80211_probe_request { 454struct libipw_probe_request {
454 struct ieee80211_hdr_3addr header; 455 struct libipw_hdr_3addr header;
455 /* SSID, supported rates */ 456 /* SSID, supported rates */
456 struct ieee80211_info_element info_element[0]; 457 struct libipw_info_element info_element[0];
457} __attribute__ ((packed)); 458} __attribute__ ((packed));
458 459
459struct ieee80211_probe_response { 460struct libipw_probe_response {
460 struct ieee80211_hdr_3addr header; 461 struct libipw_hdr_3addr header;
461 __le32 time_stamp[2]; 462 __le32 time_stamp[2];
462 __le16 beacon_interval; 463 __le16 beacon_interval;
463 __le16 capability; 464 __le16 capability;
464 /* SSID, supported rates, FH params, DS params, 465 /* SSID, supported rates, FH params, DS params,
465 * CF params, IBSS params, TIM (if beacon), RSN */ 466 * CF params, IBSS params, TIM (if beacon), RSN */
466 struct ieee80211_info_element info_element[0]; 467 struct libipw_info_element info_element[0];
467} __attribute__ ((packed)); 468} __attribute__ ((packed));
468 469
469/* Alias beacon for probe_response */ 470/* Alias beacon for probe_response */
470#define ieee80211_beacon ieee80211_probe_response 471#define libipw_beacon libipw_probe_response
471 472
472struct ieee80211_assoc_request { 473struct libipw_assoc_request {
473 struct ieee80211_hdr_3addr header; 474 struct libipw_hdr_3addr header;
474 __le16 capability; 475 __le16 capability;
475 __le16 listen_interval; 476 __le16 listen_interval;
476 /* SSID, supported rates, RSN */ 477 /* SSID, supported rates, RSN */
477 struct ieee80211_info_element info_element[0]; 478 struct libipw_info_element info_element[0];
478} __attribute__ ((packed)); 479} __attribute__ ((packed));
479 480
480struct ieee80211_reassoc_request { 481struct libipw_reassoc_request {
481 struct ieee80211_hdr_3addr header; 482 struct libipw_hdr_3addr header;
482 __le16 capability; 483 __le16 capability;
483 __le16 listen_interval; 484 __le16 listen_interval;
484 u8 current_ap[ETH_ALEN]; 485 u8 current_ap[ETH_ALEN];
485 struct ieee80211_info_element info_element[0]; 486 struct libipw_info_element info_element[0];
486} __attribute__ ((packed)); 487} __attribute__ ((packed));
487 488
488struct ieee80211_assoc_response { 489struct libipw_assoc_response {
489 struct ieee80211_hdr_3addr header; 490 struct libipw_hdr_3addr header;
490 __le16 capability; 491 __le16 capability;
491 __le16 status; 492 __le16 status;
492 __le16 aid; 493 __le16 aid;
493 /* supported rates */ 494 /* supported rates */
494 struct ieee80211_info_element info_element[0]; 495 struct libipw_info_element info_element[0];
495} __attribute__ ((packed)); 496} __attribute__ ((packed));
496 497
497struct ieee80211_txb { 498struct libipw_txb {
498 u8 nr_frags; 499 u8 nr_frags;
499 u8 encrypted; 500 u8 encrypted;
500 u8 rts_included; 501 u8 rts_included;
@@ -546,7 +547,7 @@ struct ieee80211_txb {
546#define QOS_VERSION_1 1 547#define QOS_VERSION_1 1
547#define QOS_AIFSN_MIN_VALUE 2 548#define QOS_AIFSN_MIN_VALUE 2
548 549
549struct ieee80211_qos_information_element { 550struct libipw_qos_information_element {
550 u8 elementID; 551 u8 elementID;
551 u8 length; 552 u8 length;
552 u8 qui[QOS_OUI_LEN]; 553 u8 qui[QOS_OUI_LEN];
@@ -556,19 +557,19 @@ struct ieee80211_qos_information_element {
556 u8 ac_info; 557 u8 ac_info;
557} __attribute__ ((packed)); 558} __attribute__ ((packed));
558 559
559struct ieee80211_qos_ac_parameter { 560struct libipw_qos_ac_parameter {
560 u8 aci_aifsn; 561 u8 aci_aifsn;
561 u8 ecw_min_max; 562 u8 ecw_min_max;
562 __le16 tx_op_limit; 563 __le16 tx_op_limit;
563} __attribute__ ((packed)); 564} __attribute__ ((packed));
564 565
565struct ieee80211_qos_parameter_info { 566struct libipw_qos_parameter_info {
566 struct ieee80211_qos_information_element info_element; 567 struct libipw_qos_information_element info_element;
567 u8 reserved; 568 u8 reserved;
568 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; 569 struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
569} __attribute__ ((packed)); 570} __attribute__ ((packed));
570 571
571struct ieee80211_qos_parameters { 572struct libipw_qos_parameters {
572 __le16 cw_min[QOS_QUEUE_NUM]; 573 __le16 cw_min[QOS_QUEUE_NUM];
573 __le16 cw_max[QOS_QUEUE_NUM]; 574 __le16 cw_max[QOS_QUEUE_NUM];
574 u8 aifs[QOS_QUEUE_NUM]; 575 u8 aifs[QOS_QUEUE_NUM];
@@ -576,107 +577,107 @@ struct ieee80211_qos_parameters {
576 __le16 tx_op_limit[QOS_QUEUE_NUM]; 577 __le16 tx_op_limit[QOS_QUEUE_NUM];
577} __attribute__ ((packed)); 578} __attribute__ ((packed));
578 579
579struct ieee80211_qos_data { 580struct libipw_qos_data {
580 struct ieee80211_qos_parameters parameters; 581 struct libipw_qos_parameters parameters;
581 int active; 582 int active;
582 int supported; 583 int supported;
583 u8 param_count; 584 u8 param_count;
584 u8 old_param_count; 585 u8 old_param_count;
585}; 586};
586 587
587struct ieee80211_tim_parameters { 588struct libipw_tim_parameters {
588 u8 tim_count; 589 u8 tim_count;
589 u8 tim_period; 590 u8 tim_period;
590} __attribute__ ((packed)); 591} __attribute__ ((packed));
591 592
592/*******************************************************/ 593/*******************************************************/
593 594
594enum { /* ieee80211_basic_report.map */ 595enum { /* libipw_basic_report.map */
595 IEEE80211_BASIC_MAP_BSS = (1 << 0), 596 LIBIPW_BASIC_MAP_BSS = (1 << 0),
596 IEEE80211_BASIC_MAP_OFDM = (1 << 1), 597 LIBIPW_BASIC_MAP_OFDM = (1 << 1),
597 IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2), 598 LIBIPW_BASIC_MAP_UNIDENTIFIED = (1 << 2),
598 IEEE80211_BASIC_MAP_RADAR = (1 << 3), 599 LIBIPW_BASIC_MAP_RADAR = (1 << 3),
599 IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4), 600 LIBIPW_BASIC_MAP_UNMEASURED = (1 << 4),
600 /* Bits 5-7 are reserved */ 601 /* Bits 5-7 are reserved */
601 602
602}; 603};
603struct ieee80211_basic_report { 604struct libipw_basic_report {
604 u8 channel; 605 u8 channel;
605 __le64 start_time; 606 __le64 start_time;
606 __le16 duration; 607 __le16 duration;
607 u8 map; 608 u8 map;
608} __attribute__ ((packed)); 609} __attribute__ ((packed));
609 610
610enum { /* ieee80211_measurement_request.mode */ 611enum { /* libipw_measurement_request.mode */
611 /* Bit 0 is reserved */ 612 /* Bit 0 is reserved */
612 IEEE80211_MEASUREMENT_ENABLE = (1 << 1), 613 LIBIPW_MEASUREMENT_ENABLE = (1 << 1),
613 IEEE80211_MEASUREMENT_REQUEST = (1 << 2), 614 LIBIPW_MEASUREMENT_REQUEST = (1 << 2),
614 IEEE80211_MEASUREMENT_REPORT = (1 << 3), 615 LIBIPW_MEASUREMENT_REPORT = (1 << 3),
615 /* Bits 4-7 are reserved */ 616 /* Bits 4-7 are reserved */
616}; 617};
617 618
618enum { 619enum {
619 IEEE80211_REPORT_BASIC = 0, /* required */ 620 LIBIPW_REPORT_BASIC = 0, /* required */
620 IEEE80211_REPORT_CCA = 1, /* optional */ 621 LIBIPW_REPORT_CCA = 1, /* optional */
621 IEEE80211_REPORT_RPI = 2, /* optional */ 622 LIBIPW_REPORT_RPI = 2, /* optional */
622 /* 3-255 reserved */ 623 /* 3-255 reserved */
623}; 624};
624 625
625struct ieee80211_measurement_params { 626struct libipw_measurement_params {
626 u8 channel; 627 u8 channel;
627 __le64 start_time; 628 __le64 start_time;
628 __le16 duration; 629 __le16 duration;
629} __attribute__ ((packed)); 630} __attribute__ ((packed));
630 631
631struct ieee80211_measurement_request { 632struct libipw_measurement_request {
632 struct ieee80211_info_element ie; 633 struct libipw_info_element ie;
633 u8 token; 634 u8 token;
634 u8 mode; 635 u8 mode;
635 u8 type; 636 u8 type;
636 struct ieee80211_measurement_params params[0]; 637 struct libipw_measurement_params params[0];
637} __attribute__ ((packed)); 638} __attribute__ ((packed));
638 639
639struct ieee80211_measurement_report { 640struct libipw_measurement_report {
640 struct ieee80211_info_element ie; 641 struct libipw_info_element ie;
641 u8 token; 642 u8 token;
642 u8 mode; 643 u8 mode;
643 u8 type; 644 u8 type;
644 union { 645 union {
645 struct ieee80211_basic_report basic[0]; 646 struct libipw_basic_report basic[0];
646 } u; 647 } u;
647} __attribute__ ((packed)); 648} __attribute__ ((packed));
648 649
649struct ieee80211_tpc_report { 650struct libipw_tpc_report {
650 u8 transmit_power; 651 u8 transmit_power;
651 u8 link_margin; 652 u8 link_margin;
652} __attribute__ ((packed)); 653} __attribute__ ((packed));
653 654
654struct ieee80211_channel_map { 655struct libipw_channel_map {
655 u8 channel; 656 u8 channel;
656 u8 map; 657 u8 map;
657} __attribute__ ((packed)); 658} __attribute__ ((packed));
658 659
659struct ieee80211_ibss_dfs { 660struct libipw_ibss_dfs {
660 struct ieee80211_info_element ie; 661 struct libipw_info_element ie;
661 u8 owner[ETH_ALEN]; 662 u8 owner[ETH_ALEN];
662 u8 recovery_interval; 663 u8 recovery_interval;
663 struct ieee80211_channel_map channel_map[0]; 664 struct libipw_channel_map channel_map[0];
664}; 665};
665 666
666struct ieee80211_csa { 667struct libipw_csa {
667 u8 mode; 668 u8 mode;
668 u8 channel; 669 u8 channel;
669 u8 count; 670 u8 count;
670} __attribute__ ((packed)); 671} __attribute__ ((packed));
671 672
672struct ieee80211_quiet { 673struct libipw_quiet {
673 u8 count; 674 u8 count;
674 u8 period; 675 u8 period;
675 u8 duration; 676 u8 duration;
676 u8 offset; 677 u8 offset;
677} __attribute__ ((packed)); 678} __attribute__ ((packed));
678 679
679struct ieee80211_network { 680struct libipw_network {
680 /* These entries are used to identify a unique network */ 681 /* These entries are used to identify a unique network */
681 u8 bssid[ETH_ALEN]; 682 u8 bssid[ETH_ALEN];
682 u8 channel; 683 u8 channel;
@@ -684,10 +685,10 @@ struct ieee80211_network {
684 u8 ssid[IW_ESSID_MAX_SIZE + 1]; 685 u8 ssid[IW_ESSID_MAX_SIZE + 1];
685 u8 ssid_len; 686 u8 ssid_len;
686 687
687 struct ieee80211_qos_data qos_data; 688 struct libipw_qos_data qos_data;
688 689
689 /* These are network statistics */ 690 /* These are network statistics */
690 struct ieee80211_rx_stats stats; 691 struct libipw_rx_stats stats;
691 u16 capability; 692 u16 capability;
692 u8 rates[MAX_RATES_LENGTH]; 693 u8 rates[MAX_RATES_LENGTH];
693 u8 rates_len; 694 u8 rates_len;
@@ -706,7 +707,7 @@ struct ieee80211_network {
706 size_t wpa_ie_len; 707 size_t wpa_ie_len;
707 u8 rsn_ie[MAX_WPA_IE_LEN]; 708 u8 rsn_ie[MAX_WPA_IE_LEN];
708 size_t rsn_ie_len; 709 size_t rsn_ie_len;
709 struct ieee80211_tim_parameters tim; 710 struct libipw_tim_parameters tim;
710 711
711 /* 802.11h info */ 712 /* 802.11h info */
712 713
@@ -714,86 +715,89 @@ struct ieee80211_network {
714 u8 power_constraint; 715 u8 power_constraint;
715 716
716 /* TPC Report - mandatory if spctrm mgmt required */ 717 /* TPC Report - mandatory if spctrm mgmt required */
717 struct ieee80211_tpc_report tpc_report; 718 struct libipw_tpc_report tpc_report;
718 719
719 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS 720 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
720 * NOTE: This is variable length and so must be allocated dynamically */ 721 * NOTE: This is variable length and so must be allocated dynamically */
721 struct ieee80211_ibss_dfs *ibss_dfs; 722 struct libipw_ibss_dfs *ibss_dfs;
722 723
723 /* Channel Switch Announcement - optional if spctrm mgmt required */ 724 /* Channel Switch Announcement - optional if spctrm mgmt required */
724 struct ieee80211_csa csa; 725 struct libipw_csa csa;
725 726
726 /* Quiet - optional if spctrm mgmt required */ 727 /* Quiet - optional if spctrm mgmt required */
727 struct ieee80211_quiet quiet; 728 struct libipw_quiet quiet;
728 729
729 struct list_head list; 730 struct list_head list;
730}; 731};
731 732
732enum ieee80211_state { 733enum libipw_state {
733 IEEE80211_UNINITIALIZED = 0, 734 LIBIPW_UNINITIALIZED = 0,
734 IEEE80211_INITIALIZED, 735 LIBIPW_INITIALIZED,
735 IEEE80211_ASSOCIATING, 736 LIBIPW_ASSOCIATING,
736 IEEE80211_ASSOCIATED, 737 LIBIPW_ASSOCIATED,
737 IEEE80211_AUTHENTICATING, 738 LIBIPW_AUTHENTICATING,
738 IEEE80211_AUTHENTICATED, 739 LIBIPW_AUTHENTICATED,
739 IEEE80211_SHUTDOWN 740 LIBIPW_SHUTDOWN
740}; 741};
741 742
742#define DEFAULT_MAX_SCAN_AGE (15 * HZ) 743#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
743#define DEFAULT_FTS 2346 744#define DEFAULT_FTS 2346
744 745
745#define CFG_IEEE80211_RESERVE_FCS (1<<0) 746#define CFG_LIBIPW_RESERVE_FCS (1<<0)
746#define CFG_IEEE80211_COMPUTE_FCS (1<<1) 747#define CFG_LIBIPW_COMPUTE_FCS (1<<1)
747#define CFG_IEEE80211_RTS (1<<2) 748#define CFG_LIBIPW_RTS (1<<2)
748 749
749#define IEEE80211_24GHZ_MIN_CHANNEL 1 750#define LIBIPW_24GHZ_MIN_CHANNEL 1
750#define IEEE80211_24GHZ_MAX_CHANNEL 14 751#define LIBIPW_24GHZ_MAX_CHANNEL 14
751#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \ 752#define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
752 IEEE80211_24GHZ_MIN_CHANNEL + 1) 753 LIBIPW_24GHZ_MIN_CHANNEL + 1)
753 754
754#define IEEE80211_52GHZ_MIN_CHANNEL 34 755#define LIBIPW_52GHZ_MIN_CHANNEL 34
755#define IEEE80211_52GHZ_MAX_CHANNEL 165 756#define LIBIPW_52GHZ_MAX_CHANNEL 165
756#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \ 757#define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
757 IEEE80211_52GHZ_MIN_CHANNEL + 1) 758 LIBIPW_52GHZ_MIN_CHANNEL + 1)
758 759
759enum { 760enum {
760 IEEE80211_CH_PASSIVE_ONLY = (1 << 0), 761 LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
761 IEEE80211_CH_80211H_RULES = (1 << 1), 762 LIBIPW_CH_80211H_RULES = (1 << 1),
762 IEEE80211_CH_B_ONLY = (1 << 2), 763 LIBIPW_CH_B_ONLY = (1 << 2),
763 IEEE80211_CH_NO_IBSS = (1 << 3), 764 LIBIPW_CH_NO_IBSS = (1 << 3),
764 IEEE80211_CH_UNIFORM_SPREADING = (1 << 4), 765 LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
765 IEEE80211_CH_RADAR_DETECT = (1 << 5), 766 LIBIPW_CH_RADAR_DETECT = (1 << 5),
766 IEEE80211_CH_INVALID = (1 << 6), 767 LIBIPW_CH_INVALID = (1 << 6),
767}; 768};
768 769
769struct ieee80211_channel { 770struct libipw_channel {
770 u32 freq; /* in MHz */ 771 u32 freq; /* in MHz */
771 u8 channel; 772 u8 channel;
772 u8 flags; 773 u8 flags;
773 u8 max_power; /* in dBm */ 774 u8 max_power; /* in dBm */
774}; 775};
775 776
776struct ieee80211_geo { 777struct libipw_geo {
777 u8 name[4]; 778 u8 name[4];
778 u8 bg_channels; 779 u8 bg_channels;
779 u8 a_channels; 780 u8 a_channels;
780 struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS]; 781 struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS];
781 struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS]; 782 struct libipw_channel a[LIBIPW_52GHZ_CHANNELS];
782}; 783};
783 784
784struct ieee80211_device { 785struct libipw_device {
785 struct net_device *dev; 786 struct net_device *dev;
786 struct ieee80211_security sec; 787 struct wireless_dev wdev;
788 struct libipw_security sec;
787 789
788 /* Bookkeeping structures */ 790 /* Bookkeeping structures */
789 struct ieee80211_stats ieee_stats; 791 struct libipw_stats ieee_stats;
790 792
791 struct ieee80211_geo geo; 793 struct libipw_geo geo;
794 struct ieee80211_supported_band bg_band;
795 struct ieee80211_supported_band a_band;
792 796
793 /* Probe / Beacon management */ 797 /* Probe / Beacon management */
794 struct list_head network_free_list; 798 struct list_head network_free_list;
795 struct list_head network_list; 799 struct list_head network_list;
796 struct ieee80211_network *networks; 800 struct libipw_network *networks;
797 int scans; 801 int scans;
798 int scan_age; 802 int scan_age;
799 803
@@ -840,7 +844,7 @@ struct ieee80211_device {
840 * with RX of broad/multicast frames */ 844 * with RX of broad/multicast frames */
841 845
842 /* Fragmentation structures */ 846 /* Fragmentation structures */
843 struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN]; 847 struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN];
844 unsigned int frag_next_idx; 848 unsigned int frag_next_idx;
845 u16 fts; /* Fragmentation Threshold */ 849 u16 fts; /* Fragmentation Threshold */
846 u16 rts; /* RTS threshold */ 850 u16 rts; /* RTS threshold */
@@ -848,7 +852,7 @@ struct ieee80211_device {
848 /* Association info */ 852 /* Association info */
849 u8 bssid[ETH_ALEN]; 853 u8 bssid[ETH_ALEN];
850 854
851 enum ieee80211_state state; 855 enum libipw_state state;
852 856
853 int mode; /* A, B, G */ 857 int mode; /* A, B, G */
854 int modulation; /* CCK, OFDM */ 858 int modulation; /* CCK, OFDM */
@@ -862,43 +866,43 @@ struct ieee80211_device {
862 866
863 /* Callback functions */ 867 /* Callback functions */
864 void (*set_security) (struct net_device * dev, 868 void (*set_security) (struct net_device * dev,
865 struct ieee80211_security * sec); 869 struct libipw_security * sec);
866 int (*hard_start_xmit) (struct ieee80211_txb * txb, 870 int (*hard_start_xmit) (struct libipw_txb * txb,
867 struct net_device * dev, int pri); 871 struct net_device * dev, int pri);
868 int (*reset_port) (struct net_device * dev); 872 int (*reset_port) (struct net_device * dev);
869 int (*is_queue_full) (struct net_device * dev, int pri); 873 int (*is_queue_full) (struct net_device * dev, int pri);
870 874
871 int (*handle_management) (struct net_device * dev, 875 int (*handle_management) (struct net_device * dev,
872 struct ieee80211_network * network, u16 type); 876 struct libipw_network * network, u16 type);
873 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); 877 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
874 878
875 /* Typical STA methods */ 879 /* Typical STA methods */
876 int (*handle_auth) (struct net_device * dev, 880 int (*handle_auth) (struct net_device * dev,
877 struct ieee80211_auth * auth); 881 struct libipw_auth * auth);
878 int (*handle_deauth) (struct net_device * dev, 882 int (*handle_deauth) (struct net_device * dev,
879 struct ieee80211_deauth * auth); 883 struct libipw_deauth * auth);
880 int (*handle_action) (struct net_device * dev, 884 int (*handle_action) (struct net_device * dev,
881 struct ieee80211_action * action, 885 struct libipw_action * action,
882 struct ieee80211_rx_stats * stats); 886 struct libipw_rx_stats * stats);
883 int (*handle_disassoc) (struct net_device * dev, 887 int (*handle_disassoc) (struct net_device * dev,
884 struct ieee80211_disassoc * assoc); 888 struct libipw_disassoc * assoc);
885 int (*handle_beacon) (struct net_device * dev, 889 int (*handle_beacon) (struct net_device * dev,
886 struct ieee80211_beacon * beacon, 890 struct libipw_beacon * beacon,
887 struct ieee80211_network * network); 891 struct libipw_network * network);
888 int (*handle_probe_response) (struct net_device * dev, 892 int (*handle_probe_response) (struct net_device * dev,
889 struct ieee80211_probe_response * resp, 893 struct libipw_probe_response * resp,
890 struct ieee80211_network * network); 894 struct libipw_network * network);
891 int (*handle_probe_request) (struct net_device * dev, 895 int (*handle_probe_request) (struct net_device * dev,
892 struct ieee80211_probe_request * req, 896 struct libipw_probe_request * req,
893 struct ieee80211_rx_stats * stats); 897 struct libipw_rx_stats * stats);
894 int (*handle_assoc_response) (struct net_device * dev, 898 int (*handle_assoc_response) (struct net_device * dev,
895 struct ieee80211_assoc_response * resp, 899 struct libipw_assoc_response * resp,
896 struct ieee80211_network * network); 900 struct libipw_network * network);
897 901
898 /* Typical AP methods */ 902 /* Typical AP methods */
899 int (*handle_assoc_request) (struct net_device * dev); 903 int (*handle_assoc_request) (struct net_device * dev);
900 int (*handle_reassoc_request) (struct net_device * dev, 904 int (*handle_reassoc_request) (struct net_device * dev,
901 struct ieee80211_reassoc_request * req); 905 struct libipw_reassoc_request * req);
902 906
903 /* This must be the last item so that it points to the data 907 /* This must be the last item so that it points to the data
904 * allocated beyond this structure by alloc_ieee80211 */ 908 * allocated beyond this structure by alloc_ieee80211 */
@@ -910,12 +914,12 @@ struct ieee80211_device {
910#define IEEE_G (1<<2) 914#define IEEE_G (1<<2)
911#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) 915#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
912 916
913static inline void *ieee80211_priv(struct net_device *dev) 917static inline void *libipw_priv(struct net_device *dev)
914{ 918{
915 return ((struct ieee80211_device *)netdev_priv(dev))->priv; 919 return ((struct libipw_device *)netdev_priv(dev))->priv;
916} 920}
917 921
918static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, 922static inline int libipw_is_valid_mode(struct libipw_device *ieee,
919 int mode) 923 int mode)
920{ 924{
921 /* 925 /*
@@ -925,32 +929,32 @@ static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
925 * 929 *
926 */ 930 */
927 if ((mode & IEEE_A) && 931 if ((mode & IEEE_A) &&
928 (ieee->modulation & IEEE80211_OFDM_MODULATION) && 932 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
929 (ieee->freq_band & IEEE80211_52GHZ_BAND)) 933 (ieee->freq_band & LIBIPW_52GHZ_BAND))
930 return 1; 934 return 1;
931 935
932 if ((mode & IEEE_G) && 936 if ((mode & IEEE_G) &&
933 (ieee->modulation & IEEE80211_OFDM_MODULATION) && 937 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
934 (ieee->freq_band & IEEE80211_24GHZ_BAND)) 938 (ieee->freq_band & LIBIPW_24GHZ_BAND))
935 return 1; 939 return 1;
936 940
937 if ((mode & IEEE_B) && 941 if ((mode & IEEE_B) &&
938 (ieee->modulation & IEEE80211_CCK_MODULATION) && 942 (ieee->modulation & LIBIPW_CCK_MODULATION) &&
939 (ieee->freq_band & IEEE80211_24GHZ_BAND)) 943 (ieee->freq_band & LIBIPW_24GHZ_BAND))
940 return 1; 944 return 1;
941 945
942 return 0; 946 return 0;
943} 947}
944 948
945static inline int ieee80211_get_hdrlen(u16 fc) 949static inline int libipw_get_hdrlen(u16 fc)
946{ 950{
947 int hdrlen = IEEE80211_3ADDR_LEN; 951 int hdrlen = LIBIPW_3ADDR_LEN;
948 u16 stype = WLAN_FC_GET_STYPE(fc); 952 u16 stype = WLAN_FC_GET_STYPE(fc);
949 953
950 switch (WLAN_FC_GET_TYPE(fc)) { 954 switch (WLAN_FC_GET_TYPE(fc)) {
951 case IEEE80211_FTYPE_DATA: 955 case IEEE80211_FTYPE_DATA:
952 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) 956 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
953 hdrlen = IEEE80211_4ADDR_LEN; 957 hdrlen = LIBIPW_4ADDR_LEN;
954 if (stype & IEEE80211_STYPE_QOS_DATA) 958 if (stype & IEEE80211_STYPE_QOS_DATA)
955 hdrlen += 2; 959 hdrlen += 2;
956 break; 960 break;
@@ -958,10 +962,10 @@ static inline int ieee80211_get_hdrlen(u16 fc)
958 switch (WLAN_FC_GET_STYPE(fc)) { 962 switch (WLAN_FC_GET_STYPE(fc)) {
959 case IEEE80211_STYPE_CTS: 963 case IEEE80211_STYPE_CTS:
960 case IEEE80211_STYPE_ACK: 964 case IEEE80211_STYPE_ACK:
961 hdrlen = IEEE80211_1ADDR_LEN; 965 hdrlen = LIBIPW_1ADDR_LEN;
962 break; 966 break;
963 default: 967 default:
964 hdrlen = IEEE80211_2ADDR_LEN; 968 hdrlen = LIBIPW_2ADDR_LEN;
965 break; 969 break;
966 } 970 }
967 break; 971 break;
@@ -970,118 +974,118 @@ static inline int ieee80211_get_hdrlen(u16 fc)
970 return hdrlen; 974 return hdrlen;
971} 975}
972 976
973static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr) 977static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
974{ 978{
975 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control))) { 979 switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
976 case IEEE80211_1ADDR_LEN: 980 case LIBIPW_1ADDR_LEN:
977 return ((struct ieee80211_hdr_1addr *)hdr)->payload; 981 return ((struct libipw_hdr_1addr *)hdr)->payload;
978 case IEEE80211_2ADDR_LEN: 982 case LIBIPW_2ADDR_LEN:
979 return ((struct ieee80211_hdr_2addr *)hdr)->payload; 983 return ((struct libipw_hdr_2addr *)hdr)->payload;
980 case IEEE80211_3ADDR_LEN: 984 case LIBIPW_3ADDR_LEN:
981 return ((struct ieee80211_hdr_3addr *)hdr)->payload; 985 return ((struct libipw_hdr_3addr *)hdr)->payload;
982 case IEEE80211_4ADDR_LEN: 986 case LIBIPW_4ADDR_LEN:
983 return ((struct ieee80211_hdr_4addr *)hdr)->payload; 987 return ((struct libipw_hdr_4addr *)hdr)->payload;
984 } 988 }
985 return NULL; 989 return NULL;
986} 990}
987 991
988static inline int ieee80211_is_ofdm_rate(u8 rate) 992static inline int libipw_is_ofdm_rate(u8 rate)
989{ 993{
990 switch (rate & ~IEEE80211_BASIC_RATE_MASK) { 994 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
991 case IEEE80211_OFDM_RATE_6MB: 995 case LIBIPW_OFDM_RATE_6MB:
992 case IEEE80211_OFDM_RATE_9MB: 996 case LIBIPW_OFDM_RATE_9MB:
993 case IEEE80211_OFDM_RATE_12MB: 997 case LIBIPW_OFDM_RATE_12MB:
994 case IEEE80211_OFDM_RATE_18MB: 998 case LIBIPW_OFDM_RATE_18MB:
995 case IEEE80211_OFDM_RATE_24MB: 999 case LIBIPW_OFDM_RATE_24MB:
996 case IEEE80211_OFDM_RATE_36MB: 1000 case LIBIPW_OFDM_RATE_36MB:
997 case IEEE80211_OFDM_RATE_48MB: 1001 case LIBIPW_OFDM_RATE_48MB:
998 case IEEE80211_OFDM_RATE_54MB: 1002 case LIBIPW_OFDM_RATE_54MB:
999 return 1; 1003 return 1;
1000 } 1004 }
1001 return 0; 1005 return 0;
1002} 1006}
1003 1007
1004static inline int ieee80211_is_cck_rate(u8 rate) 1008static inline int libipw_is_cck_rate(u8 rate)
1005{ 1009{
1006 switch (rate & ~IEEE80211_BASIC_RATE_MASK) { 1010 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
1007 case IEEE80211_CCK_RATE_1MB: 1011 case LIBIPW_CCK_RATE_1MB:
1008 case IEEE80211_CCK_RATE_2MB: 1012 case LIBIPW_CCK_RATE_2MB:
1009 case IEEE80211_CCK_RATE_5MB: 1013 case LIBIPW_CCK_RATE_5MB:
1010 case IEEE80211_CCK_RATE_11MB: 1014 case LIBIPW_CCK_RATE_11MB:
1011 return 1; 1015 return 1;
1012 } 1016 }
1013 return 0; 1017 return 0;
1014} 1018}
1015 1019
1016/* ieee80211.c */ 1020/* ieee80211.c */
1017extern void free_ieee80211(struct net_device *dev); 1021extern void free_ieee80211(struct net_device *dev, int monitor);
1018extern struct net_device *alloc_ieee80211(int sizeof_priv); 1022extern struct net_device *alloc_ieee80211(int sizeof_priv, int monitor);
1019extern int ieee80211_change_mtu(struct net_device *dev, int new_mtu); 1023extern int libipw_change_mtu(struct net_device *dev, int new_mtu);
1020 1024
1021extern void ieee80211_networks_age(struct ieee80211_device *ieee, 1025extern void libipw_networks_age(struct libipw_device *ieee,
1022 unsigned long age_secs); 1026 unsigned long age_secs);
1023 1027
1024extern int ieee80211_set_encryption(struct ieee80211_device *ieee); 1028extern int libipw_set_encryption(struct libipw_device *ieee);
1025 1029
1026/* ieee80211_tx.c */ 1030/* libipw_tx.c */
1027extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); 1031extern int libipw_xmit(struct sk_buff *skb, struct net_device *dev);
1028extern void ieee80211_txb_free(struct ieee80211_txb *); 1032extern void libipw_txb_free(struct libipw_txb *);
1029 1033
1030/* ieee80211_rx.c */ 1034/* libipw_rx.c */
1031extern void ieee80211_rx_any(struct ieee80211_device *ieee, 1035extern void libipw_rx_any(struct libipw_device *ieee,
1032 struct sk_buff *skb, struct ieee80211_rx_stats *stats); 1036 struct sk_buff *skb, struct libipw_rx_stats *stats);
1033extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, 1037extern int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
1034 struct ieee80211_rx_stats *rx_stats); 1038 struct libipw_rx_stats *rx_stats);
1035/* make sure to set stats->len */ 1039/* make sure to set stats->len */
1036extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, 1040extern void libipw_rx_mgt(struct libipw_device *ieee,
1037 struct ieee80211_hdr_4addr *header, 1041 struct libipw_hdr_4addr *header,
1038 struct ieee80211_rx_stats *stats); 1042 struct libipw_rx_stats *stats);
1039extern void ieee80211_network_reset(struct ieee80211_network *network); 1043extern void libipw_network_reset(struct libipw_network *network);
1040 1044
1041/* ieee80211_geo.c */ 1045/* libipw_geo.c */
1042extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device 1046extern const struct libipw_geo *libipw_get_geo(struct libipw_device
1043 *ieee); 1047 *ieee);
1044extern int ieee80211_set_geo(struct ieee80211_device *ieee, 1048extern int libipw_set_geo(struct libipw_device *ieee,
1045 const struct ieee80211_geo *geo); 1049 const struct libipw_geo *geo);
1046 1050
1047extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee, 1051extern int libipw_is_valid_channel(struct libipw_device *ieee,
1048 u8 channel); 1052 u8 channel);
1049extern int ieee80211_channel_to_index(struct ieee80211_device *ieee, 1053extern int libipw_channel_to_index(struct libipw_device *ieee,
1050 u8 channel); 1054 u8 channel);
1051extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq); 1055extern u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
1052extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee, 1056extern u8 libipw_get_channel_flags(struct libipw_device *ieee,
1053 u8 channel); 1057 u8 channel);
1054extern const struct ieee80211_channel *ieee80211_get_channel(struct 1058extern const struct libipw_channel *libipw_get_channel(struct
1055 ieee80211_device 1059 libipw_device
1056 *ieee, u8 channel); 1060 *ieee, u8 channel);
1057extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee, 1061extern u32 libipw_channel_to_freq(struct libipw_device * ieee,
1058 u8 channel); 1062 u8 channel);
1059 1063
1060/* ieee80211_wx.c */ 1064/* libipw_wx.c */
1061extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, 1065extern int libipw_wx_get_scan(struct libipw_device *ieee,
1062 struct iw_request_info *info, 1066 struct iw_request_info *info,
1063 union iwreq_data *wrqu, char *key); 1067 union iwreq_data *wrqu, char *key);
1064extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, 1068extern int libipw_wx_set_encode(struct libipw_device *ieee,
1065 struct iw_request_info *info, 1069 struct iw_request_info *info,
1066 union iwreq_data *wrqu, char *key); 1070 union iwreq_data *wrqu, char *key);
1067extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, 1071extern int libipw_wx_get_encode(struct libipw_device *ieee,
1068 struct iw_request_info *info, 1072 struct iw_request_info *info,
1069 union iwreq_data *wrqu, char *key); 1073 union iwreq_data *wrqu, char *key);
1070extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee, 1074extern int libipw_wx_set_encodeext(struct libipw_device *ieee,
1071 struct iw_request_info *info, 1075 struct iw_request_info *info,
1072 union iwreq_data *wrqu, char *extra); 1076 union iwreq_data *wrqu, char *extra);
1073extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, 1077extern int libipw_wx_get_encodeext(struct libipw_device *ieee,
1074 struct iw_request_info *info, 1078 struct iw_request_info *info,
1075 union iwreq_data *wrqu, char *extra); 1079 union iwreq_data *wrqu, char *extra);
1076 1080
1077static inline void ieee80211_increment_scans(struct ieee80211_device *ieee) 1081static inline void libipw_increment_scans(struct libipw_device *ieee)
1078{ 1082{
1079 ieee->scans++; 1083 ieee->scans++;
1080} 1084}
1081 1085
1082static inline int ieee80211_get_scans(struct ieee80211_device *ieee) 1086static inline int libipw_get_scans(struct libipw_device *ieee)
1083{ 1087{
1084 return ieee->scans; 1088 return ieee->scans;
1085} 1089}
1086 1090
1087#endif /* IEEE80211_H */ 1091#endif /* LIBIPW_H */
diff --git a/drivers/net/wireless/ipw2x00/libipw_geo.c b/drivers/net/wireless/ipw2x00/libipw_geo.c
index 9dfbb8760f67..65e8c175a4a0 100644
--- a/drivers/net/wireless/ipw2x00/libipw_geo.c
+++ b/drivers/net/wireless/ipw2x00/libipw_geo.c
@@ -19,7 +19,7 @@
19 file called LICENSE. 19 file called LICENSE.
20 20
21 Contact Information: 21 Contact Information:
22 James P. Ketrenos <ipw2100-admin@linux.intel.com> 22 Intel Linux Wireless <ilw@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 24
25******************************************************************************/ 25******************************************************************************/
@@ -41,9 +41,9 @@
41#include <linux/etherdevice.h> 41#include <linux/etherdevice.h>
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43 43
44#include "ieee80211.h" 44#include "libipw.h"
45 45
46int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel) 46int libipw_is_valid_channel(struct libipw_device *ieee, u8 channel)
47{ 47{
48 int i; 48 int i;
49 49
@@ -52,27 +52,27 @@ int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel)
52 if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0) 52 if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
53 return 0; 53 return 0;
54 54
55 if (ieee->freq_band & IEEE80211_24GHZ_BAND) 55 if (ieee->freq_band & LIBIPW_24GHZ_BAND)
56 for (i = 0; i < ieee->geo.bg_channels; i++) 56 for (i = 0; i < ieee->geo.bg_channels; i++)
57 /* NOTE: If G mode is currently supported but 57 /* NOTE: If G mode is currently supported but
58 * this is a B only channel, we don't see it 58 * this is a B only channel, we don't see it
59 * as valid. */ 59 * as valid. */
60 if ((ieee->geo.bg[i].channel == channel) && 60 if ((ieee->geo.bg[i].channel == channel) &&
61 !(ieee->geo.bg[i].flags & IEEE80211_CH_INVALID) && 61 !(ieee->geo.bg[i].flags & LIBIPW_CH_INVALID) &&
62 (!(ieee->mode & IEEE_G) || 62 (!(ieee->mode & IEEE_G) ||
63 !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY))) 63 !(ieee->geo.bg[i].flags & LIBIPW_CH_B_ONLY)))
64 return IEEE80211_24GHZ_BAND; 64 return LIBIPW_24GHZ_BAND;
65 65
66 if (ieee->freq_band & IEEE80211_52GHZ_BAND) 66 if (ieee->freq_band & LIBIPW_52GHZ_BAND)
67 for (i = 0; i < ieee->geo.a_channels; i++) 67 for (i = 0; i < ieee->geo.a_channels; i++)
68 if ((ieee->geo.a[i].channel == channel) && 68 if ((ieee->geo.a[i].channel == channel) &&
69 !(ieee->geo.a[i].flags & IEEE80211_CH_INVALID)) 69 !(ieee->geo.a[i].flags & LIBIPW_CH_INVALID))
70 return IEEE80211_52GHZ_BAND; 70 return LIBIPW_52GHZ_BAND;
71 71
72 return 0; 72 return 0;
73} 73}
74 74
75int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel) 75int libipw_channel_to_index(struct libipw_device *ieee, u8 channel)
76{ 76{
77 int i; 77 int i;
78 78
@@ -81,12 +81,12 @@ int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel)
81 if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0) 81 if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
82 return -1; 82 return -1;
83 83
84 if (ieee->freq_band & IEEE80211_24GHZ_BAND) 84 if (ieee->freq_band & LIBIPW_24GHZ_BAND)
85 for (i = 0; i < ieee->geo.bg_channels; i++) 85 for (i = 0; i < ieee->geo.bg_channels; i++)
86 if (ieee->geo.bg[i].channel == channel) 86 if (ieee->geo.bg[i].channel == channel)
87 return i; 87 return i;
88 88
89 if (ieee->freq_band & IEEE80211_52GHZ_BAND) 89 if (ieee->freq_band & LIBIPW_52GHZ_BAND)
90 for (i = 0; i < ieee->geo.a_channels; i++) 90 for (i = 0; i < ieee->geo.a_channels; i++)
91 if (ieee->geo.a[i].channel == channel) 91 if (ieee->geo.a[i].channel == channel)
92 return i; 92 return i;
@@ -94,22 +94,22 @@ int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel)
94 return -1; 94 return -1;
95} 95}
96 96
97u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee, u8 channel) 97u32 libipw_channel_to_freq(struct libipw_device * ieee, u8 channel)
98{ 98{
99 const struct ieee80211_channel * ch; 99 const struct libipw_channel * ch;
100 100
101 /* Driver needs to initialize the geography map before using 101 /* Driver needs to initialize the geography map before using
102 * these helper functions */ 102 * these helper functions */
103 if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0) 103 if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
104 return 0; 104 return 0;
105 105
106 ch = ieee80211_get_channel(ieee, channel); 106 ch = libipw_get_channel(ieee, channel);
107 if (!ch->channel) 107 if (!ch->channel)
108 return 0; 108 return 0;
109 return ch->freq; 109 return ch->freq;
110} 110}
111 111
112u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq) 112u8 libipw_freq_to_channel(struct libipw_device * ieee, u32 freq)
113{ 113{
114 int i; 114 int i;
115 115
@@ -120,12 +120,12 @@ u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq)
120 120
121 freq /= 100000; 121 freq /= 100000;
122 122
123 if (ieee->freq_band & IEEE80211_24GHZ_BAND) 123 if (ieee->freq_band & LIBIPW_24GHZ_BAND)
124 for (i = 0; i < ieee->geo.bg_channels; i++) 124 for (i = 0; i < ieee->geo.bg_channels; i++)
125 if (ieee->geo.bg[i].freq == freq) 125 if (ieee->geo.bg[i].freq == freq)
126 return ieee->geo.bg[i].channel; 126 return ieee->geo.bg[i].channel;
127 127
128 if (ieee->freq_band & IEEE80211_52GHZ_BAND) 128 if (ieee->freq_band & LIBIPW_52GHZ_BAND)
129 for (i = 0; i < ieee->geo.a_channels; i++) 129 for (i = 0; i < ieee->geo.a_channels; i++)
130 if (ieee->geo.a[i].freq == freq) 130 if (ieee->geo.a[i].freq == freq)
131 return ieee->geo.a[i].channel; 131 return ieee->geo.a[i].channel;
@@ -133,63 +133,63 @@ u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq)
133 return 0; 133 return 0;
134} 134}
135 135
136int ieee80211_set_geo(struct ieee80211_device *ieee, 136int libipw_set_geo(struct libipw_device *ieee,
137 const struct ieee80211_geo *geo) 137 const struct libipw_geo *geo)
138{ 138{
139 memcpy(ieee->geo.name, geo->name, 3); 139 memcpy(ieee->geo.name, geo->name, 3);
140 ieee->geo.name[3] = '\0'; 140 ieee->geo.name[3] = '\0';
141 ieee->geo.bg_channels = geo->bg_channels; 141 ieee->geo.bg_channels = geo->bg_channels;
142 ieee->geo.a_channels = geo->a_channels; 142 ieee->geo.a_channels = geo->a_channels;
143 memcpy(ieee->geo.bg, geo->bg, geo->bg_channels * 143 memcpy(ieee->geo.bg, geo->bg, geo->bg_channels *
144 sizeof(struct ieee80211_channel)); 144 sizeof(struct libipw_channel));
145 memcpy(ieee->geo.a, geo->a, ieee->geo.a_channels * 145 memcpy(ieee->geo.a, geo->a, ieee->geo.a_channels *
146 sizeof(struct ieee80211_channel)); 146 sizeof(struct libipw_channel));
147 return 0; 147 return 0;
148} 148}
149 149
150const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device *ieee) 150const struct libipw_geo *libipw_get_geo(struct libipw_device *ieee)
151{ 151{
152 return &ieee->geo; 152 return &ieee->geo;
153} 153}
154 154
155u8 ieee80211_get_channel_flags(struct ieee80211_device * ieee, u8 channel) 155u8 libipw_get_channel_flags(struct libipw_device * ieee, u8 channel)
156{ 156{
157 int index = ieee80211_channel_to_index(ieee, channel); 157 int index = libipw_channel_to_index(ieee, channel);
158 158
159 if (index == -1) 159 if (index == -1)
160 return IEEE80211_CH_INVALID; 160 return LIBIPW_CH_INVALID;
161 161
162 if (channel <= IEEE80211_24GHZ_CHANNELS) 162 if (channel <= LIBIPW_24GHZ_CHANNELS)
163 return ieee->geo.bg[index].flags; 163 return ieee->geo.bg[index].flags;
164 164
165 return ieee->geo.a[index].flags; 165 return ieee->geo.a[index].flags;
166} 166}
167 167
168static const struct ieee80211_channel bad_channel = { 168static const struct libipw_channel bad_channel = {
169 .channel = 0, 169 .channel = 0,
170 .flags = IEEE80211_CH_INVALID, 170 .flags = LIBIPW_CH_INVALID,
171 .max_power = 0, 171 .max_power = 0,
172}; 172};
173 173
174const struct ieee80211_channel *ieee80211_get_channel(struct ieee80211_device 174const struct libipw_channel *libipw_get_channel(struct libipw_device
175 *ieee, u8 channel) 175 *ieee, u8 channel)
176{ 176{
177 int index = ieee80211_channel_to_index(ieee, channel); 177 int index = libipw_channel_to_index(ieee, channel);
178 178
179 if (index == -1) 179 if (index == -1)
180 return &bad_channel; 180 return &bad_channel;
181 181
182 if (channel <= IEEE80211_24GHZ_CHANNELS) 182 if (channel <= LIBIPW_24GHZ_CHANNELS)
183 return &ieee->geo.bg[index]; 183 return &ieee->geo.bg[index];
184 184
185 return &ieee->geo.a[index]; 185 return &ieee->geo.a[index];
186} 186}
187 187
188EXPORT_SYMBOL(ieee80211_get_channel); 188EXPORT_SYMBOL(libipw_get_channel);
189EXPORT_SYMBOL(ieee80211_get_channel_flags); 189EXPORT_SYMBOL(libipw_get_channel_flags);
190EXPORT_SYMBOL(ieee80211_is_valid_channel); 190EXPORT_SYMBOL(libipw_is_valid_channel);
191EXPORT_SYMBOL(ieee80211_freq_to_channel); 191EXPORT_SYMBOL(libipw_freq_to_channel);
192EXPORT_SYMBOL(ieee80211_channel_to_freq); 192EXPORT_SYMBOL(libipw_channel_to_freq);
193EXPORT_SYMBOL(ieee80211_channel_to_index); 193EXPORT_SYMBOL(libipw_channel_to_index);
194EXPORT_SYMBOL(ieee80211_set_geo); 194EXPORT_SYMBOL(libipw_set_geo);
195EXPORT_SYMBOL(ieee80211_get_geo); 195EXPORT_SYMBOL(libipw_get_geo);
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index 8ce6e961c5da..a0e9f6aed7da 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -25,7 +25,7 @@
25 file called LICENSE. 25 file called LICENSE.
26 26
27 Contact Information: 27 Contact Information:
28 James P. Ketrenos <ipw2100-admin@linux.intel.com> 28 Intel Linux Wireless <ilw@linux.intel.com>
29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 30
31*******************************************************************************/ 31*******************************************************************************/
@@ -50,11 +50,11 @@
50#include <net/net_namespace.h> 50#include <net/net_namespace.h>
51#include <net/arp.h> 51#include <net/arp.h>
52 52
53#include "ieee80211.h" 53#include "libipw.h"
54 54
55#define DRV_DESCRIPTION "802.11 data/management/control stack" 55#define DRV_DESCRIPTION "802.11 data/management/control stack"
56#define DRV_NAME "ieee80211" 56#define DRV_NAME "ieee80211"
57#define DRV_VERSION IEEE80211_VERSION 57#define DRV_VERSION LIBIPW_VERSION
58#define DRV_COPYRIGHT "Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>" 58#define DRV_COPYRIGHT "Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>"
59 59
60MODULE_VERSION(DRV_VERSION); 60MODULE_VERSION(DRV_VERSION);
@@ -62,13 +62,16 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION);
62MODULE_AUTHOR(DRV_COPYRIGHT); 62MODULE_AUTHOR(DRV_COPYRIGHT);
63MODULE_LICENSE("GPL"); 63MODULE_LICENSE("GPL");
64 64
65static int ieee80211_networks_allocate(struct ieee80211_device *ieee) 65struct cfg80211_ops libipw_config_ops = { };
66void *libipw_wiphy_privid = &libipw_wiphy_privid;
67
68static int libipw_networks_allocate(struct libipw_device *ieee)
66{ 69{
67 if (ieee->networks) 70 if (ieee->networks)
68 return 0; 71 return 0;
69 72
70 ieee->networks = 73 ieee->networks =
71 kzalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), 74 kzalloc(MAX_NETWORK_COUNT * sizeof(struct libipw_network),
72 GFP_KERNEL); 75 GFP_KERNEL);
73 if (!ieee->networks) { 76 if (!ieee->networks) {
74 printk(KERN_WARNING "%s: Out of memory allocating beacons\n", 77 printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
@@ -79,7 +82,7 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee)
79 return 0; 82 return 0;
80} 83}
81 84
82void ieee80211_network_reset(struct ieee80211_network *network) 85void libipw_network_reset(struct libipw_network *network)
83{ 86{
84 if (!network) 87 if (!network)
85 return; 88 return;
@@ -90,7 +93,7 @@ void ieee80211_network_reset(struct ieee80211_network *network)
90 } 93 }
91} 94}
92 95
93static inline void ieee80211_networks_free(struct ieee80211_device *ieee) 96static inline void libipw_networks_free(struct libipw_device *ieee)
94{ 97{
95 int i; 98 int i;
96 99
@@ -105,10 +108,10 @@ static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
105 ieee->networks = NULL; 108 ieee->networks = NULL;
106} 109}
107 110
108void ieee80211_networks_age(struct ieee80211_device *ieee, 111void libipw_networks_age(struct libipw_device *ieee,
109 unsigned long age_secs) 112 unsigned long age_secs)
110{ 113{
111 struct ieee80211_network *network = NULL; 114 struct libipw_network *network = NULL;
112 unsigned long flags; 115 unsigned long flags;
113 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); 116 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC);
114 117
@@ -118,9 +121,9 @@ void ieee80211_networks_age(struct ieee80211_device *ieee,
118 } 121 }
119 spin_unlock_irqrestore(&ieee->lock, flags); 122 spin_unlock_irqrestore(&ieee->lock, flags);
120} 123}
121EXPORT_SYMBOL(ieee80211_networks_age); 124EXPORT_SYMBOL(libipw_networks_age);
122 125
123static void ieee80211_networks_initialize(struct ieee80211_device *ieee) 126static void libipw_networks_initialize(struct libipw_device *ieee)
124{ 127{
125 int i; 128 int i;
126 129
@@ -131,38 +134,59 @@ static void ieee80211_networks_initialize(struct ieee80211_device *ieee)
131 &ieee->network_free_list); 134 &ieee->network_free_list);
132} 135}
133 136
134int ieee80211_change_mtu(struct net_device *dev, int new_mtu) 137int libipw_change_mtu(struct net_device *dev, int new_mtu)
135{ 138{
136 if ((new_mtu < 68) || (new_mtu > IEEE80211_DATA_LEN)) 139 if ((new_mtu < 68) || (new_mtu > LIBIPW_DATA_LEN))
137 return -EINVAL; 140 return -EINVAL;
138 dev->mtu = new_mtu; 141 dev->mtu = new_mtu;
139 return 0; 142 return 0;
140} 143}
141EXPORT_SYMBOL(ieee80211_change_mtu); 144EXPORT_SYMBOL(libipw_change_mtu);
142 145
143struct net_device *alloc_ieee80211(int sizeof_priv) 146struct net_device *alloc_ieee80211(int sizeof_priv, int monitor)
144{ 147{
145 struct ieee80211_device *ieee; 148 struct libipw_device *ieee;
146 struct net_device *dev; 149 struct net_device *dev;
147 int err; 150 int err;
148 151
149 IEEE80211_DEBUG_INFO("Initializing...\n"); 152 LIBIPW_DEBUG_INFO("Initializing...\n");
150 153
151 dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv); 154 dev = alloc_etherdev(sizeof(struct libipw_device) + sizeof_priv);
152 if (!dev) { 155 if (!dev) {
153 IEEE80211_ERROR("Unable to allocate network device.\n"); 156 LIBIPW_ERROR("Unable to allocate network device.\n");
154 goto failed; 157 goto failed;
155 } 158 }
156 ieee = netdev_priv(dev); 159 ieee = netdev_priv(dev);
157 160
158 ieee->dev = dev; 161 ieee->dev = dev;
159 162
160 err = ieee80211_networks_allocate(ieee); 163 if (!monitor) {
164 ieee->wdev.wiphy = wiphy_new(&libipw_config_ops, 0);
165 if (!ieee->wdev.wiphy) {
166 LIBIPW_ERROR("Unable to allocate wiphy.\n");
167 goto failed_free_netdev;
168 }
169
170 ieee->dev->ieee80211_ptr = &ieee->wdev;
171 ieee->wdev.iftype = NL80211_IFTYPE_STATION;
172
173 /* Fill-out wiphy structure bits we know... Not enough info
174 here to call set_wiphy_dev or set MAC address or channel info
175 -- have to do that in ->ndo_init... */
176 ieee->wdev.wiphy->privid = libipw_wiphy_privid;
177
178 ieee->wdev.wiphy->max_scan_ssids = 1;
179 ieee->wdev.wiphy->max_scan_ie_len = 0;
180 ieee->wdev.wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
181 | BIT(NL80211_IFTYPE_ADHOC);
182 }
183
184 err = libipw_networks_allocate(ieee);
161 if (err) { 185 if (err) {
162 IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); 186 LIBIPW_ERROR("Unable to allocate beacon storage: %d\n", err);
163 goto failed_free_netdev; 187 goto failed_free_wiphy;
164 } 188 }
165 ieee80211_networks_initialize(ieee); 189 libipw_networks_initialize(ieee);
166 190
167 /* Default fragmentation threshold is maximum payload size */ 191 /* Default fragmentation threshold is maximum payload size */
168 ieee->fts = DEFAULT_FTS; 192 ieee->fts = DEFAULT_FTS;
@@ -193,33 +217,45 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
193 217
194 return dev; 218 return dev;
195 219
220failed_free_wiphy:
221 if (!monitor)
222 wiphy_free(ieee->wdev.wiphy);
196failed_free_netdev: 223failed_free_netdev:
197 free_netdev(dev); 224 free_netdev(dev);
198failed: 225failed:
199 return NULL; 226 return NULL;
200} 227}
201 228
202void free_ieee80211(struct net_device *dev) 229void free_ieee80211(struct net_device *dev, int monitor)
203{ 230{
204 struct ieee80211_device *ieee = netdev_priv(dev); 231 struct libipw_device *ieee = netdev_priv(dev);
205 232
206 lib80211_crypt_info_free(&ieee->crypt_info); 233 lib80211_crypt_info_free(&ieee->crypt_info);
207 234
208 ieee80211_networks_free(ieee); 235 libipw_networks_free(ieee);
236
237 /* free cfg80211 resources */
238 if (!monitor) {
239 wiphy_unregister(ieee->wdev.wiphy);
240 kfree(ieee->a_band.channels);
241 kfree(ieee->bg_band.channels);
242 wiphy_free(ieee->wdev.wiphy);
243 }
244
209 free_netdev(dev); 245 free_netdev(dev);
210} 246}
211 247
212#ifdef CONFIG_LIBIPW_DEBUG 248#ifdef CONFIG_LIBIPW_DEBUG
213 249
214static int debug = 0; 250static int debug = 0;
215u32 ieee80211_debug_level = 0; 251u32 libipw_debug_level = 0;
216EXPORT_SYMBOL_GPL(ieee80211_debug_level); 252EXPORT_SYMBOL_GPL(libipw_debug_level);
217static struct proc_dir_entry *ieee80211_proc = NULL; 253static struct proc_dir_entry *libipw_proc = NULL;
218 254
219static int show_debug_level(char *page, char **start, off_t offset, 255static int show_debug_level(char *page, char **start, off_t offset,
220 int count, int *eof, void *data) 256 int count, int *eof, void *data)
221{ 257{
222 return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); 258 return snprintf(page, count, "0x%08X\n", libipw_debug_level);
223} 259}
224 260
225static int store_debug_level(struct file *file, const char __user * buffer, 261static int store_debug_level(struct file *file, const char __user * buffer,
@@ -236,29 +272,29 @@ static int store_debug_level(struct file *file, const char __user * buffer,
236 printk(KERN_INFO DRV_NAME 272 printk(KERN_INFO DRV_NAME
237 ": %s is not in hex or decimal form.\n", buf); 273 ": %s is not in hex or decimal form.\n", buf);
238 else 274 else
239 ieee80211_debug_level = val; 275 libipw_debug_level = val;
240 276
241 return strnlen(buf, len); 277 return strnlen(buf, len);
242} 278}
243#endif /* CONFIG_LIBIPW_DEBUG */ 279#endif /* CONFIG_LIBIPW_DEBUG */
244 280
245static int __init ieee80211_init(void) 281static int __init libipw_init(void)
246{ 282{
247#ifdef CONFIG_LIBIPW_DEBUG 283#ifdef CONFIG_LIBIPW_DEBUG
248 struct proc_dir_entry *e; 284 struct proc_dir_entry *e;
249 285
250 ieee80211_debug_level = debug; 286 libipw_debug_level = debug;
251 ieee80211_proc = proc_mkdir(DRV_NAME, init_net.proc_net); 287 libipw_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
252 if (ieee80211_proc == NULL) { 288 if (libipw_proc == NULL) {
253 IEEE80211_ERROR("Unable to create " DRV_NAME 289 LIBIPW_ERROR("Unable to create " DRV_NAME
254 " proc directory\n"); 290 " proc directory\n");
255 return -EIO; 291 return -EIO;
256 } 292 }
257 e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, 293 e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
258 ieee80211_proc); 294 libipw_proc);
259 if (!e) { 295 if (!e) {
260 remove_proc_entry(DRV_NAME, init_net.proc_net); 296 remove_proc_entry(DRV_NAME, init_net.proc_net);
261 ieee80211_proc = NULL; 297 libipw_proc = NULL;
262 return -EIO; 298 return -EIO;
263 } 299 }
264 e->read_proc = show_debug_level; 300 e->read_proc = show_debug_level;
@@ -272,13 +308,13 @@ static int __init ieee80211_init(void)
272 return 0; 308 return 0;
273} 309}
274 310
275static void __exit ieee80211_exit(void) 311static void __exit libipw_exit(void)
276{ 312{
277#ifdef CONFIG_LIBIPW_DEBUG 313#ifdef CONFIG_LIBIPW_DEBUG
278 if (ieee80211_proc) { 314 if (libipw_proc) {
279 remove_proc_entry("debug_level", ieee80211_proc); 315 remove_proc_entry("debug_level", libipw_proc);
280 remove_proc_entry(DRV_NAME, init_net.proc_net); 316 remove_proc_entry(DRV_NAME, init_net.proc_net);
281 ieee80211_proc = NULL; 317 libipw_proc = NULL;
282 } 318 }
283#endif /* CONFIG_LIBIPW_DEBUG */ 319#endif /* CONFIG_LIBIPW_DEBUG */
284} 320}
@@ -289,8 +325,8 @@ module_param(debug, int, 0444);
289MODULE_PARM_DESC(debug, "debug output mask"); 325MODULE_PARM_DESC(debug, "debug output mask");
290#endif /* CONFIG_LIBIPW_DEBUG */ 326#endif /* CONFIG_LIBIPW_DEBUG */
291 327
292module_exit(ieee80211_exit); 328module_exit(libipw_exit);
293module_init(ieee80211_init); 329module_init(libipw_init);
294 330
295EXPORT_SYMBOL(alloc_ieee80211); 331EXPORT_SYMBOL(alloc_ieee80211);
296EXPORT_SYMBOL(free_ieee80211); 332EXPORT_SYMBOL(free_ieee80211);
diff --git a/drivers/net/wireless/ipw2x00/libipw_rx.c b/drivers/net/wireless/ipw2x00/libipw_rx.c
index dae4b8e4d8e9..282b1f7ff1e9 100644
--- a/drivers/net/wireless/ipw2x00/libipw_rx.c
+++ b/drivers/net/wireless/ipw2x00/libipw_rx.c
@@ -34,18 +34,18 @@
34 34
35#include <net/lib80211.h> 35#include <net/lib80211.h>
36 36
37#include "ieee80211.h" 37#include "libipw.h"
38 38
39static void ieee80211_monitor_rx(struct ieee80211_device *ieee, 39static void libipw_monitor_rx(struct libipw_device *ieee,
40 struct sk_buff *skb, 40 struct sk_buff *skb,
41 struct ieee80211_rx_stats *rx_stats) 41 struct libipw_rx_stats *rx_stats)
42{ 42{
43 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 43 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
44 u16 fc = le16_to_cpu(hdr->frame_control); 44 u16 fc = le16_to_cpu(hdr->frame_control);
45 45
46 skb->dev = ieee->dev; 46 skb->dev = ieee->dev;
47 skb_reset_mac_header(skb); 47 skb_reset_mac_header(skb);
48 skb_pull(skb, ieee80211_get_hdrlen(fc)); 48 skb_pull(skb, libipw_get_hdrlen(fc));
49 skb->pkt_type = PACKET_OTHERHOST; 49 skb->pkt_type = PACKET_OTHERHOST;
50 skb->protocol = htons(ETH_P_80211_RAW); 50 skb->protocol = htons(ETH_P_80211_RAW);
51 memset(skb->cb, 0, sizeof(skb->cb)); 51 memset(skb->cb, 0, sizeof(skb->cb));
@@ -53,22 +53,22 @@ static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
53} 53}
54 54
55/* Called only as a tasklet (software IRQ) */ 55/* Called only as a tasklet (software IRQ) */
56static struct ieee80211_frag_entry *ieee80211_frag_cache_find(struct 56static struct libipw_frag_entry *libipw_frag_cache_find(struct
57 ieee80211_device 57 libipw_device
58 *ieee, 58 *ieee,
59 unsigned int seq, 59 unsigned int seq,
60 unsigned int frag, 60 unsigned int frag,
61 u8 * src, 61 u8 * src,
62 u8 * dst) 62 u8 * dst)
63{ 63{
64 struct ieee80211_frag_entry *entry; 64 struct libipw_frag_entry *entry;
65 int i; 65 int i;
66 66
67 for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) { 67 for (i = 0; i < LIBIPW_FRAG_CACHE_LEN; i++) {
68 entry = &ieee->frag_cache[i]; 68 entry = &ieee->frag_cache[i];
69 if (entry->skb != NULL && 69 if (entry->skb != NULL &&
70 time_after(jiffies, entry->first_frag_time + 2 * HZ)) { 70 time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
71 IEEE80211_DEBUG_FRAG("expiring fragment cache entry " 71 LIBIPW_DEBUG_FRAG("expiring fragment cache entry "
72 "seq=%u last_frag=%u\n", 72 "seq=%u last_frag=%u\n",
73 entry->seq, entry->last_frag); 73 entry->seq, entry->last_frag);
74 dev_kfree_skb_any(entry->skb); 74 dev_kfree_skb_any(entry->skb);
@@ -86,13 +86,13 @@ static struct ieee80211_frag_entry *ieee80211_frag_cache_find(struct
86} 86}
87 87
88/* Called only as a tasklet (software IRQ) */ 88/* Called only as a tasklet (software IRQ) */
89static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee, 89static struct sk_buff *libipw_frag_cache_get(struct libipw_device *ieee,
90 struct ieee80211_hdr_4addr *hdr) 90 struct libipw_hdr_4addr *hdr)
91{ 91{
92 struct sk_buff *skb = NULL; 92 struct sk_buff *skb = NULL;
93 u16 sc; 93 u16 sc;
94 unsigned int frag, seq; 94 unsigned int frag, seq;
95 struct ieee80211_frag_entry *entry; 95 struct libipw_frag_entry *entry;
96 96
97 sc = le16_to_cpu(hdr->seq_ctl); 97 sc = le16_to_cpu(hdr->seq_ctl);
98 frag = WLAN_GET_SEQ_FRAG(sc); 98 frag = WLAN_GET_SEQ_FRAG(sc);
@@ -101,7 +101,7 @@ static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
101 if (frag == 0) { 101 if (frag == 0) {
102 /* Reserve enough space to fit maximum frame length */ 102 /* Reserve enough space to fit maximum frame length */
103 skb = dev_alloc_skb(ieee->dev->mtu + 103 skb = dev_alloc_skb(ieee->dev->mtu +
104 sizeof(struct ieee80211_hdr_4addr) + 104 sizeof(struct libipw_hdr_4addr) +
105 8 /* LLC */ + 105 8 /* LLC */ +
106 2 /* alignment */ + 106 2 /* alignment */ +
107 8 /* WEP */ + ETH_ALEN /* WDS */ ); 107 8 /* WEP */ + ETH_ALEN /* WDS */ );
@@ -110,7 +110,7 @@ static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
110 110
111 entry = &ieee->frag_cache[ieee->frag_next_idx]; 111 entry = &ieee->frag_cache[ieee->frag_next_idx];
112 ieee->frag_next_idx++; 112 ieee->frag_next_idx++;
113 if (ieee->frag_next_idx >= IEEE80211_FRAG_CACHE_LEN) 113 if (ieee->frag_next_idx >= LIBIPW_FRAG_CACHE_LEN)
114 ieee->frag_next_idx = 0; 114 ieee->frag_next_idx = 0;
115 115
116 if (entry->skb != NULL) 116 if (entry->skb != NULL)
@@ -125,7 +125,7 @@ static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
125 } else { 125 } else {
126 /* received a fragment of a frame for which the head fragment 126 /* received a fragment of a frame for which the head fragment
127 * should have already been received */ 127 * should have already been received */
128 entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2, 128 entry = libipw_frag_cache_find(ieee, seq, frag, hdr->addr2,
129 hdr->addr1); 129 hdr->addr1);
130 if (entry != NULL) { 130 if (entry != NULL) {
131 entry->last_frag = frag; 131 entry->last_frag = frag;
@@ -137,21 +137,21 @@ static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
137} 137}
138 138
139/* Called only as a tasklet (software IRQ) */ 139/* Called only as a tasklet (software IRQ) */
140static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, 140static int libipw_frag_cache_invalidate(struct libipw_device *ieee,
141 struct ieee80211_hdr_4addr *hdr) 141 struct libipw_hdr_4addr *hdr)
142{ 142{
143 u16 sc; 143 u16 sc;
144 unsigned int seq; 144 unsigned int seq;
145 struct ieee80211_frag_entry *entry; 145 struct libipw_frag_entry *entry;
146 146
147 sc = le16_to_cpu(hdr->seq_ctl); 147 sc = le16_to_cpu(hdr->seq_ctl);
148 seq = WLAN_GET_SEQ_SEQ(sc); 148 seq = WLAN_GET_SEQ_SEQ(sc);
149 149
150 entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, 150 entry = libipw_frag_cache_find(ieee, seq, -1, hdr->addr2,
151 hdr->addr1); 151 hdr->addr1);
152 152
153 if (entry == NULL) { 153 if (entry == NULL) {
154 IEEE80211_DEBUG_FRAG("could not invalidate fragment cache " 154 LIBIPW_DEBUG_FRAG("could not invalidate fragment cache "
155 "entry (seq=%u)\n", seq); 155 "entry (seq=%u)\n", seq);
156 return -1; 156 return -1;
157 } 157 }
@@ -161,14 +161,14 @@ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
161} 161}
162 162
163#ifdef NOT_YET 163#ifdef NOT_YET
164/* ieee80211_rx_frame_mgtmt 164/* libipw_rx_frame_mgtmt
165 * 165 *
166 * Responsible for handling management control frames 166 * Responsible for handling management control frames
167 * 167 *
168 * Called by ieee80211_rx */ 168 * Called by libipw_rx */
169static int 169static int
170ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, 170libipw_rx_frame_mgmt(struct libipw_device *ieee, struct sk_buff *skb,
171 struct ieee80211_rx_stats *rx_stats, u16 type, 171 struct libipw_rx_stats *rx_stats, u16 type,
172 u16 stype) 172 u16 stype)
173{ 173{
174 if (ieee->iw_mode == IW_MODE_MASTER) { 174 if (ieee->iw_mode == IW_MODE_MASTER) {
@@ -176,7 +176,7 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
176 ieee->dev->name); 176 ieee->dev->name);
177 return 0; 177 return 0;
178/* 178/*
179 hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *) 179 hostap_update_sta_ps(ieee, (struct hostap_libipw_hdr_4addr *)
180 skb->data);*/ 180 skb->data);*/
181 } 181 }
182 182
@@ -219,26 +219,27 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
219 219
220/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ 220/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
221/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ 221/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
222static unsigned char rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; 222static unsigned char libipw_rfc1042_header[] =
223 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
223 224
224/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ 225/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
225static unsigned char bridge_tunnel_header[] = 226static unsigned char libipw_bridge_tunnel_header[] =
226 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; 227 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
227/* No encapsulation header if EtherType < 0x600 (=length) */ 228/* No encapsulation header if EtherType < 0x600 (=length) */
228 229
229/* Called by ieee80211_rx_frame_decrypt */ 230/* Called by libipw_rx_frame_decrypt */
230static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, 231static int libipw_is_eapol_frame(struct libipw_device *ieee,
231 struct sk_buff *skb) 232 struct sk_buff *skb)
232{ 233{
233 struct net_device *dev = ieee->dev; 234 struct net_device *dev = ieee->dev;
234 u16 fc, ethertype; 235 u16 fc, ethertype;
235 struct ieee80211_hdr_3addr *hdr; 236 struct libipw_hdr_3addr *hdr;
236 u8 *pos; 237 u8 *pos;
237 238
238 if (skb->len < 24) 239 if (skb->len < 24)
239 return 0; 240 return 0;
240 241
241 hdr = (struct ieee80211_hdr_3addr *)skb->data; 242 hdr = (struct libipw_hdr_3addr *)skb->data;
242 fc = le16_to_cpu(hdr->frame_ctl); 243 fc = le16_to_cpu(hdr->frame_ctl);
243 244
244 /* check that the frame is unicast frame to us */ 245 /* check that the frame is unicast frame to us */
@@ -266,28 +267,28 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
266 return 0; 267 return 0;
267} 268}
268 269
269/* Called only as a tasklet (software IRQ), by ieee80211_rx */ 270/* Called only as a tasklet (software IRQ), by libipw_rx */
270static int 271static int
271ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, 272libipw_rx_frame_decrypt(struct libipw_device *ieee, struct sk_buff *skb,
272 struct lib80211_crypt_data *crypt) 273 struct lib80211_crypt_data *crypt)
273{ 274{
274 struct ieee80211_hdr_3addr *hdr; 275 struct libipw_hdr_3addr *hdr;
275 int res, hdrlen; 276 int res, hdrlen;
276 277
277 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) 278 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
278 return 0; 279 return 0;
279 280
280 hdr = (struct ieee80211_hdr_3addr *)skb->data; 281 hdr = (struct libipw_hdr_3addr *)skb->data;
281 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 282 hdrlen = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
282 283
283 atomic_inc(&crypt->refcnt); 284 atomic_inc(&crypt->refcnt);
284 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); 285 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
285 atomic_dec(&crypt->refcnt); 286 atomic_dec(&crypt->refcnt);
286 if (res < 0) { 287 if (res < 0) {
287 IEEE80211_DEBUG_DROP("decryption failed (SA=%pM) res=%d\n", 288 LIBIPW_DEBUG_DROP("decryption failed (SA=%pM) res=%d\n",
288 hdr->addr2, res); 289 hdr->addr2, res);
289 if (res == -2) 290 if (res == -2)
290 IEEE80211_DEBUG_DROP("Decryption failed ICV " 291 LIBIPW_DEBUG_DROP("Decryption failed ICV "
291 "mismatch (key %d)\n", 292 "mismatch (key %d)\n",
292 skb->data[hdrlen + 3] >> 6); 293 skb->data[hdrlen + 3] >> 6);
293 ieee->ieee_stats.rx_discards_undecryptable++; 294 ieee->ieee_stats.rx_discards_undecryptable++;
@@ -297,20 +298,20 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
297 return res; 298 return res;
298} 299}
299 300
300/* Called only as a tasklet (software IRQ), by ieee80211_rx */ 301/* Called only as a tasklet (software IRQ), by libipw_rx */
301static int 302static int
302ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, 303libipw_rx_frame_decrypt_msdu(struct libipw_device *ieee,
303 struct sk_buff *skb, int keyidx, 304 struct sk_buff *skb, int keyidx,
304 struct lib80211_crypt_data *crypt) 305 struct lib80211_crypt_data *crypt)
305{ 306{
306 struct ieee80211_hdr_3addr *hdr; 307 struct libipw_hdr_3addr *hdr;
307 int res, hdrlen; 308 int res, hdrlen;
308 309
309 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) 310 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
310 return 0; 311 return 0;
311 312
312 hdr = (struct ieee80211_hdr_3addr *)skb->data; 313 hdr = (struct libipw_hdr_3addr *)skb->data;
313 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 314 hdrlen = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
314 315
315 atomic_inc(&crypt->refcnt); 316 atomic_inc(&crypt->refcnt);
316 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); 317 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
@@ -328,11 +329,11 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
328/* All received frames are sent to this function. @skb contains the frame in 329/* All received frames are sent to this function. @skb contains the frame in
329 * IEEE 802.11 format, i.e., in the format it was sent over air. 330 * IEEE 802.11 format, i.e., in the format it was sent over air.
330 * This function is called only as a tasklet (software IRQ). */ 331 * This function is called only as a tasklet (software IRQ). */
331int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, 332int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
332 struct ieee80211_rx_stats *rx_stats) 333 struct libipw_rx_stats *rx_stats)
333{ 334{
334 struct net_device *dev = ieee->dev; 335 struct net_device *dev = ieee->dev;
335 struct ieee80211_hdr_4addr *hdr; 336 struct libipw_hdr_4addr *hdr;
336 size_t hdrlen; 337 size_t hdrlen;
337 u16 fc, type, stype, sc; 338 u16 fc, type, stype, sc;
338 unsigned int frag; 339 unsigned int frag;
@@ -352,7 +353,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
352 int keyidx = 0; 353 int keyidx = 0;
353 int can_be_decrypted = 0; 354 int can_be_decrypted = 0;
354 355
355 hdr = (struct ieee80211_hdr_4addr *)skb->data; 356 hdr = (struct libipw_hdr_4addr *)skb->data;
356 if (skb->len < 10) { 357 if (skb->len < 10) {
357 printk(KERN_INFO "%s: SKB length < 10\n", dev->name); 358 printk(KERN_INFO "%s: SKB length < 10\n", dev->name);
358 goto rx_dropped; 359 goto rx_dropped;
@@ -363,7 +364,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
363 stype = WLAN_FC_GET_STYPE(fc); 364 stype = WLAN_FC_GET_STYPE(fc);
364 sc = le16_to_cpu(hdr->seq_ctl); 365 sc = le16_to_cpu(hdr->seq_ctl);
365 frag = WLAN_GET_SEQ_FRAG(sc); 366 frag = WLAN_GET_SEQ_FRAG(sc);
366 hdrlen = ieee80211_get_hdrlen(fc); 367 hdrlen = libipw_get_hdrlen(fc);
367 368
368 if (skb->len < hdrlen) { 369 if (skb->len < hdrlen) {
369 printk(KERN_INFO "%s: invalid SKB length %d\n", 370 printk(KERN_INFO "%s: invalid SKB length %d\n",
@@ -380,19 +381,19 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
380 struct iw_quality wstats; 381 struct iw_quality wstats;
381 382
382 wstats.updated = 0; 383 wstats.updated = 0;
383 if (rx_stats->mask & IEEE80211_STATMASK_RSSI) { 384 if (rx_stats->mask & LIBIPW_STATMASK_RSSI) {
384 wstats.level = rx_stats->signal; 385 wstats.level = rx_stats->signal;
385 wstats.updated |= IW_QUAL_LEVEL_UPDATED; 386 wstats.updated |= IW_QUAL_LEVEL_UPDATED;
386 } else 387 } else
387 wstats.updated |= IW_QUAL_LEVEL_INVALID; 388 wstats.updated |= IW_QUAL_LEVEL_INVALID;
388 389
389 if (rx_stats->mask & IEEE80211_STATMASK_NOISE) { 390 if (rx_stats->mask & LIBIPW_STATMASK_NOISE) {
390 wstats.noise = rx_stats->noise; 391 wstats.noise = rx_stats->noise;
391 wstats.updated |= IW_QUAL_NOISE_UPDATED; 392 wstats.updated |= IW_QUAL_NOISE_UPDATED;
392 } else 393 } else
393 wstats.updated |= IW_QUAL_NOISE_INVALID; 394 wstats.updated |= IW_QUAL_NOISE_INVALID;
394 395
395 if (rx_stats->mask & IEEE80211_STATMASK_SIGNAL) { 396 if (rx_stats->mask & LIBIPW_STATMASK_SIGNAL) {
396 wstats.qual = rx_stats->signal; 397 wstats.qual = rx_stats->signal;
397 wstats.updated |= IW_QUAL_QUAL_UPDATED; 398 wstats.updated |= IW_QUAL_QUAL_UPDATED;
398 } else 399 } else
@@ -411,7 +412,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
411 if (ieee->iw_mode == IW_MODE_MONITOR) { 412 if (ieee->iw_mode == IW_MODE_MONITOR) {
412 dev->stats.rx_packets++; 413 dev->stats.rx_packets++;
413 dev->stats.rx_bytes += skb->len; 414 dev->stats.rx_bytes += skb->len;
414 ieee80211_monitor_rx(ieee, skb, rx_stats); 415 libipw_monitor_rx(ieee, skb, rx_stats);
415 return 1; 416 return 1;
416 } 417 }
417 418
@@ -457,7 +458,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
457 * frames from other than current BSS, so just drop the 458 * frames from other than current BSS, so just drop the
458 * frames silently instead of filling system log with 459 * frames silently instead of filling system log with
459 * these reports. */ 460 * these reports. */
460 IEEE80211_DEBUG_DROP("Decryption failed (not set)" 461 LIBIPW_DEBUG_DROP("Decryption failed (not set)"
461 " (SA=%pM)\n", hdr->addr2); 462 " (SA=%pM)\n", hdr->addr2);
462 ieee->ieee_stats.rx_discards_undecryptable++; 463 ieee->ieee_stats.rx_discards_undecryptable++;
463 goto rx_dropped; 464 goto rx_dropped;
@@ -475,7 +476,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
475 goto rx_dropped; 476 goto rx_dropped;
476 } 477 }
477 478
478 if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype)) 479 if (libipw_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
479 goto rx_dropped; 480 goto rx_dropped;
480 else 481 else
481 goto rx_exit; 482 goto rx_exit;
@@ -488,7 +489,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
488 ieee->prev_seq_ctl = sc; 489 ieee->prev_seq_ctl = sc;
489 490
490 /* Data frame - extract src/dst addresses */ 491 /* Data frame - extract src/dst addresses */
491 if (skb->len < IEEE80211_3ADDR_LEN) 492 if (skb->len < LIBIPW_3ADDR_LEN)
492 goto rx_dropped; 493 goto rx_dropped;
493 494
494 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 495 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
@@ -501,7 +502,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
501 memcpy(src, hdr->addr2, ETH_ALEN); 502 memcpy(src, hdr->addr2, ETH_ALEN);
502 break; 503 break;
503 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 504 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
504 if (skb->len < IEEE80211_4ADDR_LEN) 505 if (skb->len < LIBIPW_4ADDR_LEN)
505 goto rx_dropped; 506 goto rx_dropped;
506 memcpy(dst, hdr->addr3, ETH_ALEN); 507 memcpy(dst, hdr->addr3, ETH_ALEN);
507 memcpy(src, hdr->addr4, ETH_ALEN); 508 memcpy(src, hdr->addr4, ETH_ALEN);
@@ -560,7 +561,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
560 stype != IEEE80211_STYPE_DATA_CFPOLL && 561 stype != IEEE80211_STYPE_DATA_CFPOLL &&
561 stype != IEEE80211_STYPE_DATA_CFACKPOLL) { 562 stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
562 if (stype != IEEE80211_STYPE_NULLFUNC) 563 if (stype != IEEE80211_STYPE_NULLFUNC)
563 IEEE80211_DEBUG_DROP("RX: dropped data frame " 564 LIBIPW_DEBUG_DROP("RX: dropped data frame "
564 "with no data (type=0x%02x, " 565 "with no data (type=0x%02x, "
565 "subtype=0x%02x, len=%d)\n", 566 "subtype=0x%02x, len=%d)\n",
566 type, stype, skb->len); 567 type, stype, skb->len);
@@ -570,21 +571,21 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
570 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */ 571 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
571 572
572 if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted && 573 if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
573 (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) 574 (keyidx = libipw_rx_frame_decrypt(ieee, skb, crypt)) < 0)
574 goto rx_dropped; 575 goto rx_dropped;
575 576
576 hdr = (struct ieee80211_hdr_4addr *)skb->data; 577 hdr = (struct libipw_hdr_4addr *)skb->data;
577 578
578 /* skb: hdr + (possibly fragmented) plaintext payload */ 579 /* skb: hdr + (possibly fragmented) plaintext payload */
579 // PR: FIXME: hostap has additional conditions in the "if" below: 580 // PR: FIXME: hostap has additional conditions in the "if" below:
580 // ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) && 581 // ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
581 if ((frag != 0) || (fc & IEEE80211_FCTL_MOREFRAGS)) { 582 if ((frag != 0) || (fc & IEEE80211_FCTL_MOREFRAGS)) {
582 int flen; 583 int flen;
583 struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr); 584 struct sk_buff *frag_skb = libipw_frag_cache_get(ieee, hdr);
584 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag); 585 LIBIPW_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
585 586
586 if (!frag_skb) { 587 if (!frag_skb) {
587 IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG, 588 LIBIPW_DEBUG(LIBIPW_DL_RX | LIBIPW_DL_FRAG,
588 "Rx cannot get skb from fragment " 589 "Rx cannot get skb from fragment "
589 "cache (morefrag=%d seq=%u frag=%u)\n", 590 "cache (morefrag=%d seq=%u frag=%u)\n",
590 (fc & IEEE80211_FCTL_MOREFRAGS) != 0, 591 (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
@@ -600,7 +601,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
600 printk(KERN_WARNING "%s: host decrypted and " 601 printk(KERN_WARNING "%s: host decrypted and "
601 "reassembled frame did not fit skb\n", 602 "reassembled frame did not fit skb\n",
602 dev->name); 603 dev->name);
603 ieee80211_frag_cache_invalidate(ieee, hdr); 604 libipw_frag_cache_invalidate(ieee, hdr);
604 goto rx_dropped; 605 goto rx_dropped;
605 } 606 }
606 607
@@ -627,24 +628,24 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
627 /* this was the last fragment and the frame will be 628 /* this was the last fragment and the frame will be
628 * delivered, so remove skb from fragment cache */ 629 * delivered, so remove skb from fragment cache */
629 skb = frag_skb; 630 skb = frag_skb;
630 hdr = (struct ieee80211_hdr_4addr *)skb->data; 631 hdr = (struct libipw_hdr_4addr *)skb->data;
631 ieee80211_frag_cache_invalidate(ieee, hdr); 632 libipw_frag_cache_invalidate(ieee, hdr);
632 } 633 }
633 634
634 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still 635 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
635 * encrypted/authenticated */ 636 * encrypted/authenticated */
636 if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted && 637 if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
637 ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) 638 libipw_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
638 goto rx_dropped; 639 goto rx_dropped;
639 640
640 hdr = (struct ieee80211_hdr_4addr *)skb->data; 641 hdr = (struct libipw_hdr_4addr *)skb->data;
641 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) { 642 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
642 if ( /*ieee->ieee802_1x && */ 643 if ( /*ieee->ieee802_1x && */
643 ieee80211_is_eapol_frame(ieee, skb)) { 644 libipw_is_eapol_frame(ieee, skb)) {
644 /* pass unencrypted EAPOL frames even if encryption is 645 /* pass unencrypted EAPOL frames even if encryption is
645 * configured */ 646 * configured */
646 } else { 647 } else {
647 IEEE80211_DEBUG_DROP("encryption configured, but RX " 648 LIBIPW_DEBUG_DROP("encryption configured, but RX "
648 "frame not encrypted (SA=%pM)\n", 649 "frame not encrypted (SA=%pM)\n",
649 hdr->addr2); 650 hdr->addr2);
650 goto rx_dropped; 651 goto rx_dropped;
@@ -652,8 +653,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
652 } 653 }
653 654
654 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep && 655 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
655 !ieee80211_is_eapol_frame(ieee, skb)) { 656 !libipw_is_eapol_frame(ieee, skb)) {
656 IEEE80211_DEBUG_DROP("dropped unencrypted RX data " 657 LIBIPW_DEBUG_DROP("dropped unencrypted RX data "
657 "frame from %pM (drop_unencrypted=1)\n", 658 "frame from %pM (drop_unencrypted=1)\n",
658 hdr->addr2); 659 hdr->addr2);
659 goto rx_dropped; 660 goto rx_dropped;
@@ -736,9 +737,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
736 737
737 /* convert hdr + possible LLC headers into Ethernet header */ 738 /* convert hdr + possible LLC headers into Ethernet header */
738 if (skb->len - hdrlen >= 8 && 739 if (skb->len - hdrlen >= 8 &&
739 ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 && 740 ((memcmp(payload, libipw_rfc1042_header, SNAP_SIZE) == 0 &&
740 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || 741 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
741 memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) { 742 memcmp(payload, libipw_bridge_tunnel_header, SNAP_SIZE) == 0)) {
742 /* remove RFC1042 or Bridge-Tunnel encapsulation and 743 /* remove RFC1042 or Bridge-Tunnel encapsulation and
743 * replace EtherType */ 744 * replace EtherType */
744 skb_pull(skb, hdrlen + SNAP_SIZE); 745 skb_pull(skb, hdrlen + SNAP_SIZE);
@@ -807,7 +808,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
807 /* netif_rx always succeeds, but it might drop 808 /* netif_rx always succeeds, but it might drop
808 * the packet. If it drops the packet, we log that 809 * the packet. If it drops the packet, we log that
809 * in our stats. */ 810 * in our stats. */
810 IEEE80211_DEBUG_DROP 811 LIBIPW_DEBUG_DROP
811 ("RX: netif_rx dropped the packet\n"); 812 ("RX: netif_rx dropped the packet\n");
812 dev->stats.rx_dropped++; 813 dev->stats.rx_dropped++;
813 } 814 }
@@ -829,18 +830,18 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
829 return 0; 830 return 0;
830} 831}
831 832
832/* Filter out unrelated packets, call ieee80211_rx[_mgt] 833/* Filter out unrelated packets, call libipw_rx[_mgt]
833 * This function takes over the skb, it should not be used again after calling 834 * This function takes over the skb, it should not be used again after calling
834 * this function. */ 835 * this function. */
835void ieee80211_rx_any(struct ieee80211_device *ieee, 836void libipw_rx_any(struct libipw_device *ieee,
836 struct sk_buff *skb, struct ieee80211_rx_stats *stats) 837 struct sk_buff *skb, struct libipw_rx_stats *stats)
837{ 838{
838 struct ieee80211_hdr_4addr *hdr; 839 struct libipw_hdr_4addr *hdr;
839 int is_packet_for_us; 840 int is_packet_for_us;
840 u16 fc; 841 u16 fc;
841 842
842 if (ieee->iw_mode == IW_MODE_MONITOR) { 843 if (ieee->iw_mode == IW_MODE_MONITOR) {
843 if (!ieee80211_rx(ieee, skb, stats)) 844 if (!libipw_rx(ieee, skb, stats))
844 dev_kfree_skb_irq(skb); 845 dev_kfree_skb_irq(skb);
845 return; 846 return;
846 } 847 }
@@ -848,7 +849,7 @@ void ieee80211_rx_any(struct ieee80211_device *ieee,
848 if (skb->len < sizeof(struct ieee80211_hdr)) 849 if (skb->len < sizeof(struct ieee80211_hdr))
849 goto drop_free; 850 goto drop_free;
850 851
851 hdr = (struct ieee80211_hdr_4addr *)skb->data; 852 hdr = (struct libipw_hdr_4addr *)skb->data;
852 fc = le16_to_cpu(hdr->frame_ctl); 853 fc = le16_to_cpu(hdr->frame_ctl);
853 854
854 if ((fc & IEEE80211_FCTL_VERS) != 0) 855 if ((fc & IEEE80211_FCTL_VERS) != 0)
@@ -856,9 +857,9 @@ void ieee80211_rx_any(struct ieee80211_device *ieee,
856 857
857 switch (fc & IEEE80211_FCTL_FTYPE) { 858 switch (fc & IEEE80211_FCTL_FTYPE) {
858 case IEEE80211_FTYPE_MGMT: 859 case IEEE80211_FTYPE_MGMT:
859 if (skb->len < sizeof(struct ieee80211_hdr_3addr)) 860 if (skb->len < sizeof(struct libipw_hdr_3addr))
860 goto drop_free; 861 goto drop_free;
861 ieee80211_rx_mgt(ieee, hdr, stats); 862 libipw_rx_mgt(ieee, hdr, stats);
862 dev_kfree_skb_irq(skb); 863 dev_kfree_skb_irq(skb);
863 return; 864 return;
864 case IEEE80211_FTYPE_DATA: 865 case IEEE80211_FTYPE_DATA:
@@ -910,7 +911,7 @@ void ieee80211_rx_any(struct ieee80211_device *ieee,
910 } 911 }
911 912
912 if (is_packet_for_us) 913 if (is_packet_for_us)
913 if (!ieee80211_rx(ieee, skb, stats)) 914 if (!libipw_rx(ieee, skb, stats))
914 dev_kfree_skb_irq(skb); 915 dev_kfree_skb_irq(skb);
915 return; 916 return;
916 917
@@ -928,7 +929,7 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
928* Make ther structure we read from the beacon packet has 929* Make ther structure we read from the beacon packet has
929* the right values 930* the right values
930*/ 931*/
931static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element 932static int libipw_verify_qos_info(struct libipw_qos_information_element
932 *info_element, int sub_type) 933 *info_element, int sub_type)
933{ 934{
934 935
@@ -947,12 +948,12 @@ static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
947/* 948/*
948 * Parse a QoS parameter element 949 * Parse a QoS parameter element
949 */ 950 */
950static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info 951static int libipw_read_qos_param_element(struct libipw_qos_parameter_info
951 *element_param, struct ieee80211_info_element 952 *element_param, struct libipw_info_element
952 *info_element) 953 *info_element)
953{ 954{
954 int ret = 0; 955 int ret = 0;
955 u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; 956 u16 size = sizeof(struct libipw_qos_parameter_info) - 2;
956 957
957 if ((info_element == NULL) || (element_param == NULL)) 958 if ((info_element == NULL) || (element_param == NULL))
958 return -1; 959 return -1;
@@ -965,7 +966,7 @@ static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
965 } else 966 } else
966 ret = -1; 967 ret = -1;
967 if (ret == 0) 968 if (ret == 0)
968 ret = ieee80211_verify_qos_info(&element_param->info_element, 969 ret = libipw_verify_qos_info(&element_param->info_element,
969 QOS_OUI_PARAM_SUB_TYPE); 970 QOS_OUI_PARAM_SUB_TYPE);
970 return ret; 971 return ret;
971} 972}
@@ -973,13 +974,13 @@ static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
973/* 974/*
974 * Parse a QoS information element 975 * Parse a QoS information element
975 */ 976 */
976static int ieee80211_read_qos_info_element(struct 977static int libipw_read_qos_info_element(struct
977 ieee80211_qos_information_element 978 libipw_qos_information_element
978 *element_info, struct ieee80211_info_element 979 *element_info, struct libipw_info_element
979 *info_element) 980 *info_element)
980{ 981{
981 int ret = 0; 982 int ret = 0;
982 u16 size = sizeof(struct ieee80211_qos_information_element) - 2; 983 u16 size = sizeof(struct libipw_qos_information_element) - 2;
983 984
984 if (element_info == NULL) 985 if (element_info == NULL)
985 return -1; 986 return -1;
@@ -995,7 +996,7 @@ static int ieee80211_read_qos_info_element(struct
995 ret = -1; 996 ret = -1;
996 997
997 if (ret == 0) 998 if (ret == 0)
998 ret = ieee80211_verify_qos_info(element_info, 999 ret = libipw_verify_qos_info(element_info,
999 QOS_OUI_INFO_SUB_TYPE); 1000 QOS_OUI_INFO_SUB_TYPE);
1000 return ret; 1001 return ret;
1001} 1002}
@@ -1003,15 +1004,15 @@ static int ieee80211_read_qos_info_element(struct
1003/* 1004/*
1004 * Write QoS parameters from the ac parameters. 1005 * Write QoS parameters from the ac parameters.
1005 */ 1006 */
1006static int ieee80211_qos_convert_ac_to_parameters(struct 1007static int libipw_qos_convert_ac_to_parameters(struct
1007 ieee80211_qos_parameter_info 1008 libipw_qos_parameter_info
1008 *param_elm, struct 1009 *param_elm, struct
1009 ieee80211_qos_parameters 1010 libipw_qos_parameters
1010 *qos_param) 1011 *qos_param)
1011{ 1012{
1012 int rc = 0; 1013 int rc = 0;
1013 int i; 1014 int i;
1014 struct ieee80211_qos_ac_parameter *ac_params; 1015 struct libipw_qos_ac_parameter *ac_params;
1015 u32 txop; 1016 u32 txop;
1016 u8 cw_min; 1017 u8 cw_min;
1017 u8 cw_max; 1018 u8 cw_max;
@@ -1042,27 +1043,27 @@ static int ieee80211_qos_convert_ac_to_parameters(struct
1042 * parameters element. check the information element length to decide 1043 * parameters element. check the information element length to decide
1043 * which type to read 1044 * which type to read
1044 */ 1045 */
1045static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element 1046static int libipw_parse_qos_info_param_IE(struct libipw_info_element
1046 *info_element, 1047 *info_element,
1047 struct ieee80211_network *network) 1048 struct libipw_network *network)
1048{ 1049{
1049 int rc = 0; 1050 int rc = 0;
1050 struct ieee80211_qos_parameters *qos_param = NULL; 1051 struct libipw_qos_parameters *qos_param = NULL;
1051 struct ieee80211_qos_information_element qos_info_element; 1052 struct libipw_qos_information_element qos_info_element;
1052 1053
1053 rc = ieee80211_read_qos_info_element(&qos_info_element, info_element); 1054 rc = libipw_read_qos_info_element(&qos_info_element, info_element);
1054 1055
1055 if (rc == 0) { 1056 if (rc == 0) {
1056 network->qos_data.param_count = qos_info_element.ac_info & 0x0F; 1057 network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
1057 network->flags |= NETWORK_HAS_QOS_INFORMATION; 1058 network->flags |= NETWORK_HAS_QOS_INFORMATION;
1058 } else { 1059 } else {
1059 struct ieee80211_qos_parameter_info param_element; 1060 struct libipw_qos_parameter_info param_element;
1060 1061
1061 rc = ieee80211_read_qos_param_element(&param_element, 1062 rc = libipw_read_qos_param_element(&param_element,
1062 info_element); 1063 info_element);
1063 if (rc == 0) { 1064 if (rc == 0) {
1064 qos_param = &(network->qos_data.parameters); 1065 qos_param = &(network->qos_data.parameters);
1065 ieee80211_qos_convert_ac_to_parameters(&param_element, 1066 libipw_qos_convert_ac_to_parameters(&param_element,
1066 qos_param); 1067 qos_param);
1067 network->flags |= NETWORK_HAS_QOS_PARAMETERS; 1068 network->flags |= NETWORK_HAS_QOS_PARAMETERS;
1068 network->qos_data.param_count = 1069 network->qos_data.param_count =
@@ -1071,7 +1072,7 @@ static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
1071 } 1072 }
1072 1073
1073 if (rc == 0) { 1074 if (rc == 0) {
1074 IEEE80211_DEBUG_QOS("QoS is supported\n"); 1075 LIBIPW_DEBUG_QOS("QoS is supported\n");
1075 network->qos_data.supported = 1; 1076 network->qos_data.supported = 1;
1076 } 1077 }
1077 return rc; 1078 return rc;
@@ -1116,9 +1117,9 @@ static const char *get_info_element_string(u16 id)
1116} 1117}
1117#endif 1118#endif
1118 1119
1119static int ieee80211_parse_info_param(struct ieee80211_info_element 1120static int libipw_parse_info_param(struct libipw_info_element
1120 *info_element, u16 length, 1121 *info_element, u16 length,
1121 struct ieee80211_network *network) 1122 struct libipw_network *network)
1122{ 1123{
1123 DECLARE_SSID_BUF(ssid); 1124 DECLARE_SSID_BUF(ssid);
1124 u8 i; 1125 u8 i;
@@ -1129,7 +1130,7 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1129 1130
1130 while (length >= sizeof(*info_element)) { 1131 while (length >= sizeof(*info_element)) {
1131 if (sizeof(*info_element) + info_element->len > length) { 1132 if (sizeof(*info_element) + info_element->len > length) {
1132 IEEE80211_DEBUG_MGMT("Info elem: parse failed: " 1133 LIBIPW_DEBUG_MGMT("Info elem: parse failed: "
1133 "info_element->len + 2 > left : " 1134 "info_element->len + 2 > left : "
1134 "info_element->len+2=%zd left=%d, id=%d.\n", 1135 "info_element->len+2=%zd left=%d, id=%d.\n",
1135 info_element->len + 1136 info_element->len +
@@ -1151,7 +1152,7 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1151 memset(network->ssid + network->ssid_len, 0, 1152 memset(network->ssid + network->ssid_len, 0,
1152 IW_ESSID_MAX_SIZE - network->ssid_len); 1153 IW_ESSID_MAX_SIZE - network->ssid_len);
1153 1154
1154 IEEE80211_DEBUG_MGMT("WLAN_EID_SSID: '%s' len=%d.\n", 1155 LIBIPW_DEBUG_MGMT("WLAN_EID_SSID: '%s' len=%d.\n",
1155 print_ssid(ssid, network->ssid, 1156 print_ssid(ssid, network->ssid,
1156 network->ssid_len), 1157 network->ssid_len),
1157 network->ssid_len); 1158 network->ssid_len);
@@ -1170,17 +1171,17 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1170 (p - rates_str), "%02X ", 1171 (p - rates_str), "%02X ",
1171 network->rates[i]); 1172 network->rates[i]);
1172#endif 1173#endif
1173 if (ieee80211_is_ofdm_rate 1174 if (libipw_is_ofdm_rate
1174 (info_element->data[i])) { 1175 (info_element->data[i])) {
1175 network->flags |= NETWORK_HAS_OFDM; 1176 network->flags |= NETWORK_HAS_OFDM;
1176 if (info_element->data[i] & 1177 if (info_element->data[i] &
1177 IEEE80211_BASIC_RATE_MASK) 1178 LIBIPW_BASIC_RATE_MASK)
1178 network->flags &= 1179 network->flags &=
1179 ~NETWORK_HAS_CCK; 1180 ~NETWORK_HAS_CCK;
1180 } 1181 }
1181 } 1182 }
1182 1183
1183 IEEE80211_DEBUG_MGMT("WLAN_EID_SUPP_RATES: '%s' (%d)\n", 1184 LIBIPW_DEBUG_MGMT("WLAN_EID_SUPP_RATES: '%s' (%d)\n",
1184 rates_str, network->rates_len); 1185 rates_str, network->rates_len);
1185 break; 1186 break;
1186 1187
@@ -1197,61 +1198,61 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1197 (p - rates_str), "%02X ", 1198 (p - rates_str), "%02X ",
1198 network->rates[i]); 1199 network->rates[i]);
1199#endif 1200#endif
1200 if (ieee80211_is_ofdm_rate 1201 if (libipw_is_ofdm_rate
1201 (info_element->data[i])) { 1202 (info_element->data[i])) {
1202 network->flags |= NETWORK_HAS_OFDM; 1203 network->flags |= NETWORK_HAS_OFDM;
1203 if (info_element->data[i] & 1204 if (info_element->data[i] &
1204 IEEE80211_BASIC_RATE_MASK) 1205 LIBIPW_BASIC_RATE_MASK)
1205 network->flags &= 1206 network->flags &=
1206 ~NETWORK_HAS_CCK; 1207 ~NETWORK_HAS_CCK;
1207 } 1208 }
1208 } 1209 }
1209 1210
1210 IEEE80211_DEBUG_MGMT("WLAN_EID_EXT_SUPP_RATES: '%s' (%d)\n", 1211 LIBIPW_DEBUG_MGMT("WLAN_EID_EXT_SUPP_RATES: '%s' (%d)\n",
1211 rates_str, network->rates_ex_len); 1212 rates_str, network->rates_ex_len);
1212 break; 1213 break;
1213 1214
1214 case WLAN_EID_DS_PARAMS: 1215 case WLAN_EID_DS_PARAMS:
1215 IEEE80211_DEBUG_MGMT("WLAN_EID_DS_PARAMS: %d\n", 1216 LIBIPW_DEBUG_MGMT("WLAN_EID_DS_PARAMS: %d\n",
1216 info_element->data[0]); 1217 info_element->data[0]);
1217 network->channel = info_element->data[0]; 1218 network->channel = info_element->data[0];
1218 break; 1219 break;
1219 1220
1220 case WLAN_EID_FH_PARAMS: 1221 case WLAN_EID_FH_PARAMS:
1221 IEEE80211_DEBUG_MGMT("WLAN_EID_FH_PARAMS: ignored\n"); 1222 LIBIPW_DEBUG_MGMT("WLAN_EID_FH_PARAMS: ignored\n");
1222 break; 1223 break;
1223 1224
1224 case WLAN_EID_CF_PARAMS: 1225 case WLAN_EID_CF_PARAMS:
1225 IEEE80211_DEBUG_MGMT("WLAN_EID_CF_PARAMS: ignored\n"); 1226 LIBIPW_DEBUG_MGMT("WLAN_EID_CF_PARAMS: ignored\n");
1226 break; 1227 break;
1227 1228
1228 case WLAN_EID_TIM: 1229 case WLAN_EID_TIM:
1229 network->tim.tim_count = info_element->data[0]; 1230 network->tim.tim_count = info_element->data[0];
1230 network->tim.tim_period = info_element->data[1]; 1231 network->tim.tim_period = info_element->data[1];
1231 IEEE80211_DEBUG_MGMT("WLAN_EID_TIM: partially ignored\n"); 1232 LIBIPW_DEBUG_MGMT("WLAN_EID_TIM: partially ignored\n");
1232 break; 1233 break;
1233 1234
1234 case WLAN_EID_ERP_INFO: 1235 case WLAN_EID_ERP_INFO:
1235 network->erp_value = info_element->data[0]; 1236 network->erp_value = info_element->data[0];
1236 network->flags |= NETWORK_HAS_ERP_VALUE; 1237 network->flags |= NETWORK_HAS_ERP_VALUE;
1237 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n", 1238 LIBIPW_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1238 network->erp_value); 1239 network->erp_value);
1239 break; 1240 break;
1240 1241
1241 case WLAN_EID_IBSS_PARAMS: 1242 case WLAN_EID_IBSS_PARAMS:
1242 network->atim_window = info_element->data[0]; 1243 network->atim_window = info_element->data[0];
1243 IEEE80211_DEBUG_MGMT("WLAN_EID_IBSS_PARAMS: %d\n", 1244 LIBIPW_DEBUG_MGMT("WLAN_EID_IBSS_PARAMS: %d\n",
1244 network->atim_window); 1245 network->atim_window);
1245 break; 1246 break;
1246 1247
1247 case WLAN_EID_CHALLENGE: 1248 case WLAN_EID_CHALLENGE:
1248 IEEE80211_DEBUG_MGMT("WLAN_EID_CHALLENGE: ignored\n"); 1249 LIBIPW_DEBUG_MGMT("WLAN_EID_CHALLENGE: ignored\n");
1249 break; 1250 break;
1250 1251
1251 case WLAN_EID_GENERIC: 1252 case WLAN_EID_GENERIC:
1252 IEEE80211_DEBUG_MGMT("WLAN_EID_GENERIC: %d bytes\n", 1253 LIBIPW_DEBUG_MGMT("WLAN_EID_GENERIC: %d bytes\n",
1253 info_element->len); 1254 info_element->len);
1254 if (!ieee80211_parse_qos_info_param_IE(info_element, 1255 if (!libipw_parse_qos_info_param_IE(info_element,
1255 network)) 1256 network))
1256 break; 1257 break;
1257 1258
@@ -1268,7 +1269,7 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1268 break; 1269 break;
1269 1270
1270 case WLAN_EID_RSN: 1271 case WLAN_EID_RSN:
1271 IEEE80211_DEBUG_MGMT("WLAN_EID_RSN: %d bytes\n", 1272 LIBIPW_DEBUG_MGMT("WLAN_EID_RSN: %d bytes\n",
1272 info_element->len); 1273 info_element->len);
1273 network->rsn_ie_len = min(info_element->len + 2, 1274 network->rsn_ie_len = min(info_element->len + 2,
1274 MAX_WPA_IE_LEN); 1275 MAX_WPA_IE_LEN);
@@ -1318,7 +1319,7 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1318 break; 1319 break;
1319 1320
1320 default: 1321 default:
1321 IEEE80211_DEBUG_MGMT 1322 LIBIPW_DEBUG_MGMT
1322 ("Unsupported info element: %s (%d)\n", 1323 ("Unsupported info element: %s (%d)\n",
1323 get_info_element_string(info_element->id), 1324 get_info_element_string(info_element->id),
1324 info_element->id); 1325 info_element->id);
@@ -1327,20 +1328,20 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1327 1328
1328 length -= sizeof(*info_element) + info_element->len; 1329 length -= sizeof(*info_element) + info_element->len;
1329 info_element = 1330 info_element =
1330 (struct ieee80211_info_element *)&info_element-> 1331 (struct libipw_info_element *)&info_element->
1331 data[info_element->len]; 1332 data[info_element->len];
1332 } 1333 }
1333 1334
1334 return 0; 1335 return 0;
1335} 1336}
1336 1337
1337static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct ieee80211_assoc_response 1338static int libipw_handle_assoc_resp(struct libipw_device *ieee, struct libipw_assoc_response
1338 *frame, struct ieee80211_rx_stats *stats) 1339 *frame, struct libipw_rx_stats *stats)
1339{ 1340{
1340 struct ieee80211_network network_resp = { 1341 struct libipw_network network_resp = {
1341 .ibss_dfs = NULL, 1342 .ibss_dfs = NULL,
1342 }; 1343 };
1343 struct ieee80211_network *network = &network_resp; 1344 struct libipw_network *network = &network_resp;
1344 struct net_device *dev = ieee->dev; 1345 struct net_device *dev = ieee->dev;
1345 1346
1346 network->flags = 0; 1347 network->flags = 0;
@@ -1361,7 +1362,7 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
1361 network->erp_value = 1362 network->erp_value =
1362 (network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0; 1363 (network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0;
1363 1364
1364 if (stats->freq == IEEE80211_52GHZ_BAND) { 1365 if (stats->freq == LIBIPW_52GHZ_BAND) {
1365 /* for A band (No DS info) */ 1366 /* for A band (No DS info) */
1366 network->channel = stats->received_channel; 1367 network->channel = stats->received_channel;
1367 } else 1368 } else
@@ -1370,12 +1371,12 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
1370 network->wpa_ie_len = 0; 1371 network->wpa_ie_len = 0;
1371 network->rsn_ie_len = 0; 1372 network->rsn_ie_len = 0;
1372 1373
1373 if (ieee80211_parse_info_param 1374 if (libipw_parse_info_param
1374 (frame->info_element, stats->len - sizeof(*frame), network)) 1375 (frame->info_element, stats->len - sizeof(*frame), network))
1375 return 1; 1376 return 1;
1376 1377
1377 network->mode = 0; 1378 network->mode = 0;
1378 if (stats->freq == IEEE80211_52GHZ_BAND) 1379 if (stats->freq == LIBIPW_52GHZ_BAND)
1379 network->mode = IEEE_A; 1380 network->mode = IEEE_A;
1380 else { 1381 else {
1381 if (network->flags & NETWORK_HAS_OFDM) 1382 if (network->flags & NETWORK_HAS_OFDM)
@@ -1394,10 +1395,10 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
1394 1395
1395/***************************************************/ 1396/***************************************************/
1396 1397
1397static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee80211_probe_response 1398static int libipw_network_init(struct libipw_device *ieee, struct libipw_probe_response
1398 *beacon, 1399 *beacon,
1399 struct ieee80211_network *network, 1400 struct libipw_network *network,
1400 struct ieee80211_rx_stats *stats) 1401 struct libipw_rx_stats *stats)
1401{ 1402{
1402 DECLARE_SSID_BUF(ssid); 1403 DECLARE_SSID_BUF(ssid);
1403 1404
@@ -1423,7 +1424,7 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
1423 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? 1424 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
1424 0x3 : 0x0; 1425 0x3 : 0x0;
1425 1426
1426 if (stats->freq == IEEE80211_52GHZ_BAND) { 1427 if (stats->freq == LIBIPW_52GHZ_BAND) {
1427 /* for A band (No DS info) */ 1428 /* for A band (No DS info) */
1428 network->channel = stats->received_channel; 1429 network->channel = stats->received_channel;
1429 } else 1430 } else
@@ -1432,12 +1433,12 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
1432 network->wpa_ie_len = 0; 1433 network->wpa_ie_len = 0;
1433 network->rsn_ie_len = 0; 1434 network->rsn_ie_len = 0;
1434 1435
1435 if (ieee80211_parse_info_param 1436 if (libipw_parse_info_param
1436 (beacon->info_element, stats->len - sizeof(*beacon), network)) 1437 (beacon->info_element, stats->len - sizeof(*beacon), network))
1437 return 1; 1438 return 1;
1438 1439
1439 network->mode = 0; 1440 network->mode = 0;
1440 if (stats->freq == IEEE80211_52GHZ_BAND) 1441 if (stats->freq == LIBIPW_52GHZ_BAND)
1441 network->mode = IEEE_A; 1442 network->mode = IEEE_A;
1442 else { 1443 else {
1443 if (network->flags & NETWORK_HAS_OFDM) 1444 if (network->flags & NETWORK_HAS_OFDM)
@@ -1447,7 +1448,7 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
1447 } 1448 }
1448 1449
1449 if (network->mode == 0) { 1450 if (network->mode == 0) {
1450 IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' " 1451 LIBIPW_DEBUG_SCAN("Filtered out '%s (%pM)' "
1451 "network.\n", 1452 "network.\n",
1452 print_ssid(ssid, network->ssid, 1453 print_ssid(ssid, network->ssid,
1453 network->ssid_len), 1454 network->ssid_len),
@@ -1460,8 +1461,8 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
1460 return 0; 1461 return 0;
1461} 1462}
1462 1463
1463static inline int is_same_network(struct ieee80211_network *src, 1464static inline int is_same_network(struct libipw_network *src,
1464 struct ieee80211_network *dst) 1465 struct libipw_network *dst)
1465{ 1466{
1466 /* A network is only a duplicate if the channel, BSSID, and ESSID 1467 /* A network is only a duplicate if the channel, BSSID, and ESSID
1467 * all match. We treat all <hidden> with the same BSSID and channel 1468 * all match. We treat all <hidden> with the same BSSID and channel
@@ -1472,13 +1473,13 @@ static inline int is_same_network(struct ieee80211_network *src,
1472 !memcmp(src->ssid, dst->ssid, src->ssid_len)); 1473 !memcmp(src->ssid, dst->ssid, src->ssid_len));
1473} 1474}
1474 1475
1475static void update_network(struct ieee80211_network *dst, 1476static void update_network(struct libipw_network *dst,
1476 struct ieee80211_network *src) 1477 struct libipw_network *src)
1477{ 1478{
1478 int qos_active; 1479 int qos_active;
1479 u8 old_param; 1480 u8 old_param;
1480 1481
1481 ieee80211_network_reset(dst); 1482 libipw_network_reset(dst);
1482 dst->ibss_dfs = src->ibss_dfs; 1483 dst->ibss_dfs = src->ibss_dfs;
1483 1484
1484 /* We only update the statistics if they were created by receiving 1485 /* We only update the statistics if they were created by receiving
@@ -1488,9 +1489,9 @@ static void update_network(struct ieee80211_network *dst,
1488 * down the signal level of an AP. */ 1489 * down the signal level of an AP. */
1489 if (dst->channel == src->stats.received_channel) 1490 if (dst->channel == src->stats.received_channel)
1490 memcpy(&dst->stats, &src->stats, 1491 memcpy(&dst->stats, &src->stats,
1491 sizeof(struct ieee80211_rx_stats)); 1492 sizeof(struct libipw_rx_stats));
1492 else 1493 else
1493 IEEE80211_DEBUG_SCAN("Network %pM info received " 1494 LIBIPW_DEBUG_SCAN("Network %pM info received "
1494 "off channel (%d vs. %d)\n", src->bssid, 1495 "off channel (%d vs. %d)\n", src->bssid,
1495 dst->channel, src->stats.received_channel); 1496 dst->channel, src->stats.received_channel);
1496 1497
@@ -1521,7 +1522,7 @@ static void update_network(struct ieee80211_network *dst,
1521 old_param = dst->qos_data.old_param_count; 1522 old_param = dst->qos_data.old_param_count;
1522 if (dst->flags & NETWORK_HAS_QOS_MASK) 1523 if (dst->flags & NETWORK_HAS_QOS_MASK)
1523 memcpy(&dst->qos_data, &src->qos_data, 1524 memcpy(&dst->qos_data, &src->qos_data,
1524 sizeof(struct ieee80211_qos_data)); 1525 sizeof(struct libipw_qos_data));
1525 else { 1526 else {
1526 dst->qos_data.supported = src->qos_data.supported; 1527 dst->qos_data.supported = src->qos_data.supported;
1527 dst->qos_data.param_count = src->qos_data.param_count; 1528 dst->qos_data.param_count = src->qos_data.param_count;
@@ -1529,11 +1530,11 @@ static void update_network(struct ieee80211_network *dst,
1529 1530
1530 if (dst->qos_data.supported == 1) { 1531 if (dst->qos_data.supported == 1) {
1531 if (dst->ssid_len) 1532 if (dst->ssid_len)
1532 IEEE80211_DEBUG_QOS 1533 LIBIPW_DEBUG_QOS
1533 ("QoS the network %s is QoS supported\n", 1534 ("QoS the network %s is QoS supported\n",
1534 dst->ssid); 1535 dst->ssid);
1535 else 1536 else
1536 IEEE80211_DEBUG_QOS 1537 LIBIPW_DEBUG_QOS
1537 ("QoS the network is QoS supported\n"); 1538 ("QoS the network is QoS supported\n");
1538 } 1539 }
1539 dst->qos_data.active = qos_active; 1540 dst->qos_data.active = qos_active;
@@ -1547,25 +1548,25 @@ static inline int is_beacon(__le16 fc)
1547 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON); 1548 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
1548} 1549}
1549 1550
1550static void ieee80211_process_probe_response(struct ieee80211_device 1551static void libipw_process_probe_response(struct libipw_device
1551 *ieee, struct 1552 *ieee, struct
1552 ieee80211_probe_response 1553 libipw_probe_response
1553 *beacon, struct ieee80211_rx_stats 1554 *beacon, struct libipw_rx_stats
1554 *stats) 1555 *stats)
1555{ 1556{
1556 struct net_device *dev = ieee->dev; 1557 struct net_device *dev = ieee->dev;
1557 struct ieee80211_network network = { 1558 struct libipw_network network = {
1558 .ibss_dfs = NULL, 1559 .ibss_dfs = NULL,
1559 }; 1560 };
1560 struct ieee80211_network *target; 1561 struct libipw_network *target;
1561 struct ieee80211_network *oldest = NULL; 1562 struct libipw_network *oldest = NULL;
1562#ifdef CONFIG_LIBIPW_DEBUG 1563#ifdef CONFIG_LIBIPW_DEBUG
1563 struct ieee80211_info_element *info_element = beacon->info_element; 1564 struct libipw_info_element *info_element = beacon->info_element;
1564#endif 1565#endif
1565 unsigned long flags; 1566 unsigned long flags;
1566 DECLARE_SSID_BUF(ssid); 1567 DECLARE_SSID_BUF(ssid);
1567 1568
1568 IEEE80211_DEBUG_SCAN("'%s' (%pM" 1569 LIBIPW_DEBUG_SCAN("'%s' (%pM"
1569 "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", 1570 "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
1570 print_ssid(ssid, info_element->data, info_element->len), 1571 print_ssid(ssid, info_element->data, info_element->len),
1571 beacon->header.addr3, 1572 beacon->header.addr3,
@@ -1586,8 +1587,8 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1586 (beacon->capability & cpu_to_le16(1 << 0x1)) ? '1' : '0', 1587 (beacon->capability & cpu_to_le16(1 << 0x1)) ? '1' : '0',
1587 (beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0'); 1588 (beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0');
1588 1589
1589 if (ieee80211_network_init(ieee, beacon, &network, stats)) { 1590 if (libipw_network_init(ieee, beacon, &network, stats)) {
1590 IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n", 1591 LIBIPW_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n",
1591 print_ssid(ssid, info_element->data, 1592 print_ssid(ssid, info_element->data,
1592 info_element->len), 1593 info_element->len),
1593 beacon->header.addr3, 1594 beacon->header.addr3,
@@ -1624,21 +1625,21 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1624 /* If there are no more slots, expire the oldest */ 1625 /* If there are no more slots, expire the oldest */
1625 list_del(&oldest->list); 1626 list_del(&oldest->list);
1626 target = oldest; 1627 target = oldest;
1627 IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from " 1628 LIBIPW_DEBUG_SCAN("Expired '%s' (%pM) from "
1628 "network list.\n", 1629 "network list.\n",
1629 print_ssid(ssid, target->ssid, 1630 print_ssid(ssid, target->ssid,
1630 target->ssid_len), 1631 target->ssid_len),
1631 target->bssid); 1632 target->bssid);
1632 ieee80211_network_reset(target); 1633 libipw_network_reset(target);
1633 } else { 1634 } else {
1634 /* Otherwise just pull from the free list */ 1635 /* Otherwise just pull from the free list */
1635 target = list_entry(ieee->network_free_list.next, 1636 target = list_entry(ieee->network_free_list.next,
1636 struct ieee80211_network, list); 1637 struct libipw_network, list);
1637 list_del(ieee->network_free_list.next); 1638 list_del(ieee->network_free_list.next);
1638 } 1639 }
1639 1640
1640#ifdef CONFIG_LIBIPW_DEBUG 1641#ifdef CONFIG_LIBIPW_DEBUG
1641 IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n", 1642 LIBIPW_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n",
1642 print_ssid(ssid, network.ssid, 1643 print_ssid(ssid, network.ssid,
1643 network.ssid_len), 1644 network.ssid_len),
1644 network.bssid, 1645 network.bssid,
@@ -1649,7 +1650,7 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1649 network.ibss_dfs = NULL; 1650 network.ibss_dfs = NULL;
1650 list_add_tail(&target->list, &ieee->network_list); 1651 list_add_tail(&target->list, &ieee->network_list);
1651 } else { 1652 } else {
1652 IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n", 1653 LIBIPW_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n",
1653 print_ssid(ssid, target->ssid, 1654 print_ssid(ssid, target->ssid,
1654 target->ssid_len), 1655 target->ssid_len),
1655 target->bssid, 1656 target->bssid,
@@ -1670,121 +1671,121 @@ static void ieee80211_process_probe_response(struct ieee80211_device
1670 } 1671 }
1671} 1672}
1672 1673
1673void ieee80211_rx_mgt(struct ieee80211_device *ieee, 1674void libipw_rx_mgt(struct libipw_device *ieee,
1674 struct ieee80211_hdr_4addr *header, 1675 struct libipw_hdr_4addr *header,
1675 struct ieee80211_rx_stats *stats) 1676 struct libipw_rx_stats *stats)
1676{ 1677{
1677 switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) { 1678 switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
1678 case IEEE80211_STYPE_ASSOC_RESP: 1679 case IEEE80211_STYPE_ASSOC_RESP:
1679 IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n", 1680 LIBIPW_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
1680 WLAN_FC_GET_STYPE(le16_to_cpu 1681 WLAN_FC_GET_STYPE(le16_to_cpu
1681 (header->frame_ctl))); 1682 (header->frame_ctl)));
1682 ieee80211_handle_assoc_resp(ieee, 1683 libipw_handle_assoc_resp(ieee,
1683 (struct ieee80211_assoc_response *) 1684 (struct libipw_assoc_response *)
1684 header, stats); 1685 header, stats);
1685 break; 1686 break;
1686 1687
1687 case IEEE80211_STYPE_REASSOC_RESP: 1688 case IEEE80211_STYPE_REASSOC_RESP:
1688 IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n", 1689 LIBIPW_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
1689 WLAN_FC_GET_STYPE(le16_to_cpu 1690 WLAN_FC_GET_STYPE(le16_to_cpu
1690 (header->frame_ctl))); 1691 (header->frame_ctl)));
1691 break; 1692 break;
1692 1693
1693 case IEEE80211_STYPE_PROBE_REQ: 1694 case IEEE80211_STYPE_PROBE_REQ:
1694 IEEE80211_DEBUG_MGMT("received auth (%d)\n", 1695 LIBIPW_DEBUG_MGMT("received auth (%d)\n",
1695 WLAN_FC_GET_STYPE(le16_to_cpu 1696 WLAN_FC_GET_STYPE(le16_to_cpu
1696 (header->frame_ctl))); 1697 (header->frame_ctl)));
1697 1698
1698 if (ieee->handle_probe_request != NULL) 1699 if (ieee->handle_probe_request != NULL)
1699 ieee->handle_probe_request(ieee->dev, 1700 ieee->handle_probe_request(ieee->dev,
1700 (struct 1701 (struct
1701 ieee80211_probe_request *) 1702 libipw_probe_request *)
1702 header, stats); 1703 header, stats);
1703 break; 1704 break;
1704 1705
1705 case IEEE80211_STYPE_PROBE_RESP: 1706 case IEEE80211_STYPE_PROBE_RESP:
1706 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", 1707 LIBIPW_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
1707 WLAN_FC_GET_STYPE(le16_to_cpu 1708 WLAN_FC_GET_STYPE(le16_to_cpu
1708 (header->frame_ctl))); 1709 (header->frame_ctl)));
1709 IEEE80211_DEBUG_SCAN("Probe response\n"); 1710 LIBIPW_DEBUG_SCAN("Probe response\n");
1710 ieee80211_process_probe_response(ieee, 1711 libipw_process_probe_response(ieee,
1711 (struct 1712 (struct
1712 ieee80211_probe_response *) 1713 libipw_probe_response *)
1713 header, stats); 1714 header, stats);
1714 break; 1715 break;
1715 1716
1716 case IEEE80211_STYPE_BEACON: 1717 case IEEE80211_STYPE_BEACON:
1717 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", 1718 LIBIPW_DEBUG_MGMT("received BEACON (%d)\n",
1718 WLAN_FC_GET_STYPE(le16_to_cpu 1719 WLAN_FC_GET_STYPE(le16_to_cpu
1719 (header->frame_ctl))); 1720 (header->frame_ctl)));
1720 IEEE80211_DEBUG_SCAN("Beacon\n"); 1721 LIBIPW_DEBUG_SCAN("Beacon\n");
1721 ieee80211_process_probe_response(ieee, 1722 libipw_process_probe_response(ieee,
1722 (struct 1723 (struct
1723 ieee80211_probe_response *) 1724 libipw_probe_response *)
1724 header, stats); 1725 header, stats);
1725 break; 1726 break;
1726 case IEEE80211_STYPE_AUTH: 1727 case IEEE80211_STYPE_AUTH:
1727 1728
1728 IEEE80211_DEBUG_MGMT("received auth (%d)\n", 1729 LIBIPW_DEBUG_MGMT("received auth (%d)\n",
1729 WLAN_FC_GET_STYPE(le16_to_cpu 1730 WLAN_FC_GET_STYPE(le16_to_cpu
1730 (header->frame_ctl))); 1731 (header->frame_ctl)));
1731 1732
1732 if (ieee->handle_auth != NULL) 1733 if (ieee->handle_auth != NULL)
1733 ieee->handle_auth(ieee->dev, 1734 ieee->handle_auth(ieee->dev,
1734 (struct ieee80211_auth *)header); 1735 (struct libipw_auth *)header);
1735 break; 1736 break;
1736 1737
1737 case IEEE80211_STYPE_DISASSOC: 1738 case IEEE80211_STYPE_DISASSOC:
1738 if (ieee->handle_disassoc != NULL) 1739 if (ieee->handle_disassoc != NULL)
1739 ieee->handle_disassoc(ieee->dev, 1740 ieee->handle_disassoc(ieee->dev,
1740 (struct ieee80211_disassoc *) 1741 (struct libipw_disassoc *)
1741 header); 1742 header);
1742 break; 1743 break;
1743 1744
1744 case IEEE80211_STYPE_ACTION: 1745 case IEEE80211_STYPE_ACTION:
1745 IEEE80211_DEBUG_MGMT("ACTION\n"); 1746 LIBIPW_DEBUG_MGMT("ACTION\n");
1746 if (ieee->handle_action) 1747 if (ieee->handle_action)
1747 ieee->handle_action(ieee->dev, 1748 ieee->handle_action(ieee->dev,
1748 (struct ieee80211_action *) 1749 (struct libipw_action *)
1749 header, stats); 1750 header, stats);
1750 break; 1751 break;
1751 1752
1752 case IEEE80211_STYPE_REASSOC_REQ: 1753 case IEEE80211_STYPE_REASSOC_REQ:
1753 IEEE80211_DEBUG_MGMT("received reassoc (%d)\n", 1754 LIBIPW_DEBUG_MGMT("received reassoc (%d)\n",
1754 WLAN_FC_GET_STYPE(le16_to_cpu 1755 WLAN_FC_GET_STYPE(le16_to_cpu
1755 (header->frame_ctl))); 1756 (header->frame_ctl)));
1756 1757
1757 IEEE80211_DEBUG_MGMT("%s: IEEE80211_REASSOC_REQ received\n", 1758 LIBIPW_DEBUG_MGMT("%s: LIBIPW_REASSOC_REQ received\n",
1758 ieee->dev->name); 1759 ieee->dev->name);
1759 if (ieee->handle_reassoc_request != NULL) 1760 if (ieee->handle_reassoc_request != NULL)
1760 ieee->handle_reassoc_request(ieee->dev, 1761 ieee->handle_reassoc_request(ieee->dev,
1761 (struct ieee80211_reassoc_request *) 1762 (struct libipw_reassoc_request *)
1762 header); 1763 header);
1763 break; 1764 break;
1764 1765
1765 case IEEE80211_STYPE_ASSOC_REQ: 1766 case IEEE80211_STYPE_ASSOC_REQ:
1766 IEEE80211_DEBUG_MGMT("received assoc (%d)\n", 1767 LIBIPW_DEBUG_MGMT("received assoc (%d)\n",
1767 WLAN_FC_GET_STYPE(le16_to_cpu 1768 WLAN_FC_GET_STYPE(le16_to_cpu
1768 (header->frame_ctl))); 1769 (header->frame_ctl)));
1769 1770
1770 IEEE80211_DEBUG_MGMT("%s: IEEE80211_ASSOC_REQ received\n", 1771 LIBIPW_DEBUG_MGMT("%s: LIBIPW_ASSOC_REQ received\n",
1771 ieee->dev->name); 1772 ieee->dev->name);
1772 if (ieee->handle_assoc_request != NULL) 1773 if (ieee->handle_assoc_request != NULL)
1773 ieee->handle_assoc_request(ieee->dev); 1774 ieee->handle_assoc_request(ieee->dev);
1774 break; 1775 break;
1775 1776
1776 case IEEE80211_STYPE_DEAUTH: 1777 case IEEE80211_STYPE_DEAUTH:
1777 IEEE80211_DEBUG_MGMT("DEAUTH\n"); 1778 LIBIPW_DEBUG_MGMT("DEAUTH\n");
1778 if (ieee->handle_deauth != NULL) 1779 if (ieee->handle_deauth != NULL)
1779 ieee->handle_deauth(ieee->dev, 1780 ieee->handle_deauth(ieee->dev,
1780 (struct ieee80211_deauth *) 1781 (struct libipw_deauth *)
1781 header); 1782 header);
1782 break; 1783 break;
1783 default: 1784 default:
1784 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n", 1785 LIBIPW_DEBUG_MGMT("received UNKNOWN (%d)\n",
1785 WLAN_FC_GET_STYPE(le16_to_cpu 1786 WLAN_FC_GET_STYPE(le16_to_cpu
1786 (header->frame_ctl))); 1787 (header->frame_ctl)));
1787 IEEE80211_DEBUG_MGMT("%s: Unknown management packet: %d\n", 1788 LIBIPW_DEBUG_MGMT("%s: Unknown management packet: %d\n",
1788 ieee->dev->name, 1789 ieee->dev->name,
1789 WLAN_FC_GET_STYPE(le16_to_cpu 1790 WLAN_FC_GET_STYPE(le16_to_cpu
1790 (header->frame_ctl))); 1791 (header->frame_ctl)));
@@ -1792,6 +1793,6 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1792 } 1793 }
1793} 1794}
1794 1795
1795EXPORT_SYMBOL_GPL(ieee80211_rx_any); 1796EXPORT_SYMBOL_GPL(libipw_rx_any);
1796EXPORT_SYMBOL(ieee80211_rx_mgt); 1797EXPORT_SYMBOL(libipw_rx_mgt);
1797EXPORT_SYMBOL(ieee80211_rx); 1798EXPORT_SYMBOL(libipw_rx);
diff --git a/drivers/net/wireless/ipw2x00/libipw_tx.c b/drivers/net/wireless/ipw2x00/libipw_tx.c
index 2e8f84fb29fa..46530ce56ea6 100644
--- a/drivers/net/wireless/ipw2x00/libipw_tx.c
+++ b/drivers/net/wireless/ipw2x00/libipw_tx.c
@@ -19,7 +19,7 @@
19 file called LICENSE. 19 file called LICENSE.
20 20
21 Contact Information: 21 Contact Information:
22 James P. Ketrenos <ipw2100-admin@linux.intel.com> 22 Intel Linux Wireless <ilw@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 24
25******************************************************************************/ 25******************************************************************************/
@@ -41,7 +41,7 @@
41#include <linux/etherdevice.h> 41#include <linux/etherdevice.h>
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43 43
44#include "ieee80211.h" 44#include "libipw.h"
45 45
46/* 46/*
47 47
@@ -126,12 +126,12 @@ payload of each frame is reduced to 492 bytes.
126static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; 126static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
127static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; 127static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
128 128
129static int ieee80211_copy_snap(u8 * data, __be16 h_proto) 129static int libipw_copy_snap(u8 * data, __be16 h_proto)
130{ 130{
131 struct ieee80211_snap_hdr *snap; 131 struct libipw_snap_hdr *snap;
132 u8 *oui; 132 u8 *oui;
133 133
134 snap = (struct ieee80211_snap_hdr *)data; 134 snap = (struct libipw_snap_hdr *)data;
135 snap->dsap = 0xaa; 135 snap->dsap = 0xaa;
136 snap->ssap = 0xaa; 136 snap->ssap = 0xaa;
137 snap->ctrl = 0x03; 137 snap->ctrl = 0x03;
@@ -149,7 +149,7 @@ static int ieee80211_copy_snap(u8 * data, __be16 h_proto)
149 return SNAP_SIZE + sizeof(u16); 149 return SNAP_SIZE + sizeof(u16);
150} 150}
151 151
152static int ieee80211_encrypt_fragment(struct ieee80211_device *ieee, 152static int libipw_encrypt_fragment(struct libipw_device *ieee,
153 struct sk_buff *frag, int hdr_len) 153 struct sk_buff *frag, int hdr_len)
154{ 154{
155 struct lib80211_crypt_data *crypt = 155 struct lib80211_crypt_data *crypt =
@@ -177,7 +177,7 @@ static int ieee80211_encrypt_fragment(struct ieee80211_device *ieee,
177 return 0; 177 return 0;
178} 178}
179 179
180void ieee80211_txb_free(struct ieee80211_txb *txb) 180void libipw_txb_free(struct libipw_txb *txb)
181{ 181{
182 int i; 182 int i;
183 if (unlikely(!txb)) 183 if (unlikely(!txb))
@@ -188,17 +188,17 @@ void ieee80211_txb_free(struct ieee80211_txb *txb)
188 kfree(txb); 188 kfree(txb);
189} 189}
190 190
191static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, 191static struct libipw_txb *libipw_alloc_txb(int nr_frags, int txb_size,
192 int headroom, gfp_t gfp_mask) 192 int headroom, gfp_t gfp_mask)
193{ 193{
194 struct ieee80211_txb *txb; 194 struct libipw_txb *txb;
195 int i; 195 int i;
196 txb = kmalloc(sizeof(struct ieee80211_txb) + (sizeof(u8 *) * nr_frags), 196 txb = kmalloc(sizeof(struct libipw_txb) + (sizeof(u8 *) * nr_frags),
197 gfp_mask); 197 gfp_mask);
198 if (!txb) 198 if (!txb)
199 return NULL; 199 return NULL;
200 200
201 memset(txb, 0, sizeof(struct ieee80211_txb)); 201 memset(txb, 0, sizeof(struct libipw_txb));
202 txb->nr_frags = nr_frags; 202 txb->nr_frags = nr_frags;
203 txb->frag_size = txb_size; 203 txb->frag_size = txb_size;
204 204
@@ -220,7 +220,7 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
220 return txb; 220 return txb;
221} 221}
222 222
223static int ieee80211_classify(struct sk_buff *skb) 223static int libipw_classify(struct sk_buff *skb)
224{ 224{
225 struct ethhdr *eth; 225 struct ethhdr *eth;
226 struct iphdr *ip; 226 struct iphdr *ip;
@@ -252,11 +252,11 @@ static int ieee80211_classify(struct sk_buff *skb)
252 252
253/* Incoming skb is converted to a txb which consists of 253/* Incoming skb is converted to a txb which consists of
254 * a block of 802.11 fragment packets (stored as skbs) */ 254 * a block of 802.11 fragment packets (stored as skbs) */
255int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) 255int libipw_xmit(struct sk_buff *skb, struct net_device *dev)
256{ 256{
257 struct ieee80211_device *ieee = netdev_priv(dev); 257 struct libipw_device *ieee = netdev_priv(dev);
258 struct ieee80211_txb *txb = NULL; 258 struct libipw_txb *txb = NULL;
259 struct ieee80211_hdr_3addrqos *frag_hdr; 259 struct libipw_hdr_3addrqos *frag_hdr;
260 int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size, 260 int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size,
261 rts_required; 261 rts_required;
262 unsigned long flags; 262 unsigned long flags;
@@ -264,7 +264,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
264 __be16 ether_type; 264 __be16 ether_type;
265 int bytes, fc, hdr_len; 265 int bytes, fc, hdr_len;
266 struct sk_buff *skb_frag; 266 struct sk_buff *skb_frag;
267 struct ieee80211_hdr_3addrqos header = {/* Ensure zero initialized */ 267 struct libipw_hdr_3addrqos header = {/* Ensure zero initialized */
268 .duration_id = 0, 268 .duration_id = 0,
269 .seq_ctl = 0, 269 .seq_ctl = 0,
270 .qos_ctl = 0 270 .qos_ctl = 0
@@ -331,14 +331,14 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
331 memcpy(header.addr2, src, ETH_ALEN); 331 memcpy(header.addr2, src, ETH_ALEN);
332 memcpy(header.addr3, ieee->bssid, ETH_ALEN); 332 memcpy(header.addr3, ieee->bssid, ETH_ALEN);
333 } 333 }
334 hdr_len = IEEE80211_3ADDR_LEN; 334 hdr_len = LIBIPW_3ADDR_LEN;
335 335
336 if (ieee->is_qos_active && ieee->is_qos_active(dev, skb)) { 336 if (ieee->is_qos_active && ieee->is_qos_active(dev, skb)) {
337 fc |= IEEE80211_STYPE_QOS_DATA; 337 fc |= IEEE80211_STYPE_QOS_DATA;
338 hdr_len += 2; 338 hdr_len += 2;
339 339
340 skb->priority = ieee80211_classify(skb); 340 skb->priority = libipw_classify(skb);
341 header.qos_ctl |= cpu_to_le16(skb->priority & IEEE80211_QCTL_TID); 341 header.qos_ctl |= cpu_to_le16(skb->priority & LIBIPW_QCTL_TID);
342 } 342 }
343 header.frame_ctl = cpu_to_le16(fc); 343 header.frame_ctl = cpu_to_le16(fc);
344 344
@@ -362,12 +362,12 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
362 skb_reserve(skb_new, crypt->ops->extra_msdu_prefix_len); 362 skb_reserve(skb_new, crypt->ops->extra_msdu_prefix_len);
363 memcpy(skb_put(skb_new, hdr_len), &header, hdr_len); 363 memcpy(skb_put(skb_new, hdr_len), &header, hdr_len);
364 snapped = 1; 364 snapped = 1;
365 ieee80211_copy_snap(skb_put(skb_new, SNAP_SIZE + sizeof(u16)), 365 libipw_copy_snap(skb_put(skb_new, SNAP_SIZE + sizeof(u16)),
366 ether_type); 366 ether_type);
367 skb_copy_from_linear_data(skb, skb_put(skb_new, skb->len), skb->len); 367 skb_copy_from_linear_data(skb, skb_put(skb_new, skb->len), skb->len);
368 res = crypt->ops->encrypt_msdu(skb_new, hdr_len, crypt->priv); 368 res = crypt->ops->encrypt_msdu(skb_new, hdr_len, crypt->priv);
369 if (res < 0) { 369 if (res < 0) {
370 IEEE80211_ERROR("msdu encryption failed\n"); 370 LIBIPW_ERROR("msdu encryption failed\n");
371 dev_kfree_skb_any(skb_new); 371 dev_kfree_skb_any(skb_new);
372 goto failed; 372 goto failed;
373 } 373 }
@@ -393,8 +393,8 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
393 * for it when determining the amount of payload space. */ 393 * for it when determining the amount of payload space. */
394 bytes_per_frag = frag_size - hdr_len; 394 bytes_per_frag = frag_size - hdr_len;
395 if (ieee->config & 395 if (ieee->config &
396 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 396 (CFG_LIBIPW_COMPUTE_FCS | CFG_LIBIPW_RESERVE_FCS))
397 bytes_per_frag -= IEEE80211_FCS_LEN; 397 bytes_per_frag -= LIBIPW_FCS_LEN;
398 398
399 /* Each fragment may need to have room for encryptiong 399 /* Each fragment may need to have room for encryptiong
400 * pre/postfix */ 400 * pre/postfix */
@@ -417,14 +417,14 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
417 } 417 }
418 418
419 rts_required = (frag_size > ieee->rts 419 rts_required = (frag_size > ieee->rts
420 && ieee->config & CFG_IEEE80211_RTS); 420 && ieee->config & CFG_LIBIPW_RTS);
421 if (rts_required) 421 if (rts_required)
422 nr_frags++; 422 nr_frags++;
423 423
424 /* When we allocate the TXB we allocate enough space for the reserve 424 /* When we allocate the TXB we allocate enough space for the reserve
425 * and full fragment bytes (bytes_per_frag doesn't include prefix, 425 * and full fragment bytes (bytes_per_frag doesn't include prefix,
426 * postfix, header, FCS, etc.) */ 426 * postfix, header, FCS, etc.) */
427 txb = ieee80211_alloc_txb(nr_frags, frag_size, 427 txb = libipw_alloc_txb(nr_frags, frag_size,
428 ieee->tx_headroom, GFP_ATOMIC); 428 ieee->tx_headroom, GFP_ATOMIC);
429 if (unlikely(!txb)) { 429 if (unlikely(!txb)) {
430 printk(KERN_WARNING "%s: Could not allocate TXB\n", 430 printk(KERN_WARNING "%s: Could not allocate TXB\n",
@@ -441,7 +441,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
441 if (rts_required) { 441 if (rts_required) {
442 skb_frag = txb->fragments[0]; 442 skb_frag = txb->fragments[0];
443 frag_hdr = 443 frag_hdr =
444 (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); 444 (struct libipw_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
445 445
446 /* 446 /*
447 * Set header frame_ctl to the RTS. 447 * Set header frame_ctl to the RTS.
@@ -456,7 +456,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
456 header.frame_ctl = cpu_to_le16(fc); 456 header.frame_ctl = cpu_to_le16(fc);
457 457
458 if (ieee->config & 458 if (ieee->config &
459 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 459 (CFG_LIBIPW_COMPUTE_FCS | CFG_LIBIPW_RESERVE_FCS))
460 skb_put(skb_frag, 4); 460 skb_put(skb_frag, 4);
461 461
462 txb->rts_included = 1; 462 txb->rts_included = 1;
@@ -472,7 +472,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
472 crypt->ops->extra_mpdu_prefix_len); 472 crypt->ops->extra_mpdu_prefix_len);
473 473
474 frag_hdr = 474 frag_hdr =
475 (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); 475 (struct libipw_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
476 memcpy(frag_hdr, &header, hdr_len); 476 memcpy(frag_hdr, &header, hdr_len);
477 477
478 /* If this is not the last fragment, then add the MOREFRAGS 478 /* If this is not the last fragment, then add the MOREFRAGS
@@ -487,7 +487,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
487 } 487 }
488 488
489 if (i == 0 && !snapped) { 489 if (i == 0 && !snapped) {
490 ieee80211_copy_snap(skb_put 490 libipw_copy_snap(skb_put
491 (skb_frag, SNAP_SIZE + sizeof(u16)), 491 (skb_frag, SNAP_SIZE + sizeof(u16)),
492 ether_type); 492 ether_type);
493 bytes -= SNAP_SIZE + sizeof(u16); 493 bytes -= SNAP_SIZE + sizeof(u16);
@@ -501,7 +501,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
501 /* Encryption routine will move the header forward in order 501 /* Encryption routine will move the header forward in order
502 * to insert the IV between the header and the payload */ 502 * to insert the IV between the header and the payload */
503 if (host_encrypt) 503 if (host_encrypt)
504 ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); 504 libipw_encrypt_fragment(ieee, skb_frag, hdr_len);
505 else if (host_build_iv) { 505 else if (host_build_iv) {
506 atomic_inc(&crypt->refcnt); 506 atomic_inc(&crypt->refcnt);
507 if (crypt->ops->build_iv) 507 if (crypt->ops->build_iv)
@@ -513,7 +513,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
513 } 513 }
514 514
515 if (ieee->config & 515 if (ieee->config &
516 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 516 (CFG_LIBIPW_COMPUTE_FCS | CFG_LIBIPW_RESERVE_FCS))
517 skb_put(skb_frag, 4); 517 skb_put(skb_frag, 4);
518 } 518 }
519 519
@@ -530,7 +530,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
530 return NETDEV_TX_OK; 530 return NETDEV_TX_OK;
531 } 531 }
532 532
533 ieee80211_txb_free(txb); 533 libipw_txb_free(txb);
534 } 534 }
535 535
536 return NETDEV_TX_OK; 536 return NETDEV_TX_OK;
@@ -541,6 +541,6 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
541 dev->stats.tx_errors++; 541 dev->stats.tx_errors++;
542 return NETDEV_TX_BUSY; 542 return NETDEV_TX_BUSY;
543} 543}
544EXPORT_SYMBOL(ieee80211_xmit); 544EXPORT_SYMBOL(libipw_xmit);
545 545
546EXPORT_SYMBOL(ieee80211_txb_free); 546EXPORT_SYMBOL(libipw_txb_free);
diff --git a/drivers/net/wireless/ipw2x00/libipw_wx.c b/drivers/net/wireless/ipw2x00/libipw_wx.c
index 3c0812db030a..4d89f66f53b2 100644
--- a/drivers/net/wireless/ipw2x00/libipw_wx.c
+++ b/drivers/net/wireless/ipw2x00/libipw_wx.c
@@ -25,7 +25,7 @@
25 file called LICENSE. 25 file called LICENSE.
26 26
27 Contact Information: 27 Contact Information:
28 James P. Ketrenos <ipw2100-admin@linux.intel.com> 28 Intel Linux Wireless <ilw@linux.intel.com>
29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 30
31******************************************************************************/ 31******************************************************************************/
@@ -37,9 +37,9 @@
37#include <net/lib80211.h> 37#include <net/lib80211.h>
38#include <linux/wireless.h> 38#include <linux/wireless.h>
39 39
40#include "ieee80211.h" 40#include "libipw.h"
41 41
42static const char *ieee80211_modes[] = { 42static const char *libipw_modes[] = {
43 "?", "a", "b", "ab", "g", "ag", "bg", "abg" 43 "?", "a", "b", "ab", "g", "ag", "bg", "abg"
44}; 44};
45 45
@@ -54,9 +54,9 @@ static inline unsigned int elapsed_jiffies_msecs(unsigned long start)
54} 54}
55 55
56#define MAX_CUSTOM_LEN 64 56#define MAX_CUSTOM_LEN 64
57static char *ieee80211_translate_scan(struct ieee80211_device *ieee, 57static char *libipw_translate_scan(struct libipw_device *ieee,
58 char *start, char *stop, 58 char *start, char *stop,
59 struct ieee80211_network *network, 59 struct libipw_network *network,
60 struct iw_request_info *info) 60 struct iw_request_info *info)
61{ 61{
62 char custom[MAX_CUSTOM_LEN]; 62 char custom[MAX_CUSTOM_LEN];
@@ -84,7 +84,7 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
84 /* Add the protocol name */ 84 /* Add the protocol name */
85 iwe.cmd = SIOCGIWNAME; 85 iwe.cmd = SIOCGIWNAME;
86 snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", 86 snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s",
87 ieee80211_modes[network->mode]); 87 libipw_modes[network->mode]);
88 start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); 88 start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
89 89
90 /* Add mode */ 90 /* Add mode */
@@ -102,7 +102,7 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
102 /* Add channel and frequency */ 102 /* Add channel and frequency */
103 /* Note : userspace automatically computes channel using iwrange */ 103 /* Note : userspace automatically computes channel using iwrange */
104 iwe.cmd = SIOCGIWFREQ; 104 iwe.cmd = SIOCGIWFREQ;
105 iwe.u.freq.m = ieee80211_channel_to_freq(ieee, network->channel); 105 iwe.u.freq.m = libipw_channel_to_freq(ieee, network->channel);
106 iwe.u.freq.e = 6; 106 iwe.u.freq.e = 6;
107 iwe.u.freq.i = 0; 107 iwe.u.freq.i = 0;
108 start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); 108 start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
@@ -155,7 +155,7 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
155 iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | 155 iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
156 IW_QUAL_NOISE_UPDATED; 156 IW_QUAL_NOISE_UPDATED;
157 157
158 if (!(network->stats.mask & IEEE80211_STATMASK_RSSI)) { 158 if (!(network->stats.mask & LIBIPW_STATMASK_RSSI)) {
159 iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID | 159 iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID |
160 IW_QUAL_LEVEL_INVALID; 160 IW_QUAL_LEVEL_INVALID;
161 iwe.u.qual.qual = 0; 161 iwe.u.qual.qual = 0;
@@ -180,14 +180,14 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
180 iwe.u.qual.qual = 0; 180 iwe.u.qual.qual = 0;
181 } 181 }
182 182
183 if (!(network->stats.mask & IEEE80211_STATMASK_NOISE)) { 183 if (!(network->stats.mask & LIBIPW_STATMASK_NOISE)) {
184 iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID; 184 iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
185 iwe.u.qual.noise = 0; 185 iwe.u.qual.noise = 0;
186 } else { 186 } else {
187 iwe.u.qual.noise = network->stats.noise; 187 iwe.u.qual.noise = network->stats.noise;
188 } 188 }
189 189
190 if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL)) { 190 if (!(network->stats.mask & LIBIPW_STATMASK_SIGNAL)) {
191 iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID; 191 iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID;
192 iwe.u.qual.level = 0; 192 iwe.u.qual.level = 0;
193 } else { 193 } else {
@@ -237,14 +237,14 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
237 p = custom; 237 p = custom;
238 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Channel flags: "); 238 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Channel flags: ");
239 239
240 if (ieee80211_get_channel_flags(ieee, network->channel) & 240 if (libipw_get_channel_flags(ieee, network->channel) &
241 IEEE80211_CH_INVALID) { 241 LIBIPW_CH_INVALID) {
242 iwe.cmd = IWEVCUSTOM; 242 iwe.cmd = IWEVCUSTOM;
243 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), "INVALID "); 243 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), "INVALID ");
244 } 244 }
245 245
246 if (ieee80211_get_channel_flags(ieee, network->channel) & 246 if (libipw_get_channel_flags(ieee, network->channel) &
247 IEEE80211_CH_RADAR_DETECT) { 247 LIBIPW_CH_RADAR_DETECT) {
248 iwe.cmd = IWEVCUSTOM; 248 iwe.cmd = IWEVCUSTOM;
249 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), "DFS "); 249 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), "DFS ");
250 } 250 }
@@ -259,11 +259,11 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
259 259
260#define SCAN_ITEM_SIZE 128 260#define SCAN_ITEM_SIZE 128
261 261
262int ieee80211_wx_get_scan(struct ieee80211_device *ieee, 262int libipw_wx_get_scan(struct libipw_device *ieee,
263 struct iw_request_info *info, 263 struct iw_request_info *info,
264 union iwreq_data *wrqu, char *extra) 264 union iwreq_data *wrqu, char *extra)
265{ 265{
266 struct ieee80211_network *network; 266 struct libipw_network *network;
267 unsigned long flags; 267 unsigned long flags;
268 int err = 0; 268 int err = 0;
269 269
@@ -272,7 +272,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
272 int i = 0; 272 int i = 0;
273 DECLARE_SSID_BUF(ssid); 273 DECLARE_SSID_BUF(ssid);
274 274
275 IEEE80211_DEBUG_WX("Getting scan\n"); 275 LIBIPW_DEBUG_WX("Getting scan\n");
276 276
277 spin_lock_irqsave(&ieee->lock, flags); 277 spin_lock_irqsave(&ieee->lock, flags);
278 278
@@ -285,10 +285,10 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
285 285
286 if (ieee->scan_age == 0 || 286 if (ieee->scan_age == 0 ||
287 time_after(network->last_scanned + ieee->scan_age, jiffies)) 287 time_after(network->last_scanned + ieee->scan_age, jiffies))
288 ev = ieee80211_translate_scan(ieee, ev, stop, network, 288 ev = libipw_translate_scan(ieee, ev, stop, network,
289 info); 289 info);
290 else { 290 else {
291 IEEE80211_DEBUG_SCAN("Not showing network '%s (" 291 LIBIPW_DEBUG_SCAN("Not showing network '%s ("
292 "%pM)' due to age (%ums).\n", 292 "%pM)' due to age (%ums).\n",
293 print_ssid(ssid, network->ssid, 293 print_ssid(ssid, network->ssid,
294 network->ssid_len), 294 network->ssid_len),
@@ -303,18 +303,18 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
303 wrqu->data.length = ev - extra; 303 wrqu->data.length = ev - extra;
304 wrqu->data.flags = 0; 304 wrqu->data.flags = 0;
305 305
306 IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i); 306 LIBIPW_DEBUG_WX("exit: %d networks returned.\n", i);
307 307
308 return err; 308 return err;
309} 309}
310 310
311int ieee80211_wx_set_encode(struct ieee80211_device *ieee, 311int libipw_wx_set_encode(struct libipw_device *ieee,
312 struct iw_request_info *info, 312 struct iw_request_info *info,
313 union iwreq_data *wrqu, char *keybuf) 313 union iwreq_data *wrqu, char *keybuf)
314{ 314{
315 struct iw_point *erq = &(wrqu->encoding); 315 struct iw_point *erq = &(wrqu->encoding);
316 struct net_device *dev = ieee->dev; 316 struct net_device *dev = ieee->dev;
317 struct ieee80211_security sec = { 317 struct libipw_security sec = {
318 .flags = 0 318 .flags = 0
319 }; 319 };
320 int i, key, key_provided, len; 320 int i, key, key_provided, len;
@@ -322,7 +322,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
322 int host_crypto = ieee->host_encrypt || ieee->host_decrypt || ieee->host_build_iv; 322 int host_crypto = ieee->host_encrypt || ieee->host_decrypt || ieee->host_build_iv;
323 DECLARE_SSID_BUF(ssid); 323 DECLARE_SSID_BUF(ssid);
324 324
325 IEEE80211_DEBUG_WX("SET_ENCODE\n"); 325 LIBIPW_DEBUG_WX("SET_ENCODE\n");
326 326
327 key = erq->flags & IW_ENCODE_INDEX; 327 key = erq->flags & IW_ENCODE_INDEX;
328 if (key) { 328 if (key) {
@@ -335,18 +335,18 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
335 key = ieee->crypt_info.tx_keyidx; 335 key = ieee->crypt_info.tx_keyidx;
336 } 336 }
337 337
338 IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? 338 LIBIPW_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
339 "provided" : "default"); 339 "provided" : "default");
340 340
341 crypt = &ieee->crypt_info.crypt[key]; 341 crypt = &ieee->crypt_info.crypt[key];
342 342
343 if (erq->flags & IW_ENCODE_DISABLED) { 343 if (erq->flags & IW_ENCODE_DISABLED) {
344 if (key_provided && *crypt) { 344 if (key_provided && *crypt) {
345 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", 345 LIBIPW_DEBUG_WX("Disabling encryption on key %d.\n",
346 key); 346 key);
347 lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt); 347 lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
348 } else 348 } else
349 IEEE80211_DEBUG_WX("Disabling encryption.\n"); 349 LIBIPW_DEBUG_WX("Disabling encryption.\n");
350 350
351 /* Check all the keys to see if any are still configured, 351 /* Check all the keys to see if any are still configured,
352 * and if no key index was provided, de-init them all */ 352 * and if no key index was provided, de-init them all */
@@ -410,7 +410,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
410 410
411 /* If a new key was provided, set it up */ 411 /* If a new key was provided, set it up */
412 if (erq->length > 0) { 412 if (erq->length > 0) {
413#ifdef CONFIG_IEEE80211_DEBUG 413#ifdef CONFIG_LIBIPW_DEBUG
414 DECLARE_SSID_BUF(ssid); 414 DECLARE_SSID_BUF(ssid);
415#endif 415#endif
416 416
@@ -419,7 +419,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
419 if (len > erq->length) 419 if (len > erq->length)
420 memset(sec.keys[key] + erq->length, 0, 420 memset(sec.keys[key] + erq->length, 0,
421 len - erq->length); 421 len - erq->length);
422 IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", 422 LIBIPW_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
423 key, print_ssid(ssid, sec.keys[key], len), 423 key, print_ssid(ssid, sec.keys[key], len),
424 erq->length, len); 424 erq->length, len);
425 sec.key_sizes[key] = len; 425 sec.key_sizes[key] = len;
@@ -438,7 +438,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
438 NULL, (*crypt)->priv); 438 NULL, (*crypt)->priv);
439 if (len == 0) { 439 if (len == 0) {
440 /* Set a default key of all 0 */ 440 /* Set a default key of all 0 */
441 IEEE80211_DEBUG_WX("Setting key %d to all " 441 LIBIPW_DEBUG_WX("Setting key %d to all "
442 "zero.\n", key); 442 "zero.\n", key);
443 memset(sec.keys[key], 0, 13); 443 memset(sec.keys[key], 0, 13);
444 (*crypt)->ops->set_key(sec.keys[key], 13, NULL, 444 (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
@@ -449,7 +449,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
449 } 449 }
450 /* No key data - just set the default TX key index */ 450 /* No key data - just set the default TX key index */
451 if (key_provided) { 451 if (key_provided) {
452 IEEE80211_DEBUG_WX("Setting key %d to default Tx " 452 LIBIPW_DEBUG_WX("Setting key %d to default Tx "
453 "key.\n", key); 453 "key.\n", key);
454 ieee->crypt_info.tx_keyidx = key; 454 ieee->crypt_info.tx_keyidx = key;
455 sec.active_key = key; 455 sec.active_key = key;
@@ -461,7 +461,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
461 sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : 461 sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN :
462 WLAN_AUTH_SHARED_KEY; 462 WLAN_AUTH_SHARED_KEY;
463 sec.flags |= SEC_AUTH_MODE; 463 sec.flags |= SEC_AUTH_MODE;
464 IEEE80211_DEBUG_WX("Auth: %s\n", 464 LIBIPW_DEBUG_WX("Auth: %s\n",
465 sec.auth_mode == WLAN_AUTH_OPEN ? 465 sec.auth_mode == WLAN_AUTH_OPEN ?
466 "OPEN" : "SHARED KEY"); 466 "OPEN" : "SHARED KEY");
467 } 467 }
@@ -490,16 +490,16 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
490 return 0; 490 return 0;
491} 491}
492 492
493int ieee80211_wx_get_encode(struct ieee80211_device *ieee, 493int libipw_wx_get_encode(struct libipw_device *ieee,
494 struct iw_request_info *info, 494 struct iw_request_info *info,
495 union iwreq_data *wrqu, char *keybuf) 495 union iwreq_data *wrqu, char *keybuf)
496{ 496{
497 struct iw_point *erq = &(wrqu->encoding); 497 struct iw_point *erq = &(wrqu->encoding);
498 int len, key; 498 int len, key;
499 struct lib80211_crypt_data *crypt; 499 struct lib80211_crypt_data *crypt;
500 struct ieee80211_security *sec = &ieee->sec; 500 struct libipw_security *sec = &ieee->sec;
501 501
502 IEEE80211_DEBUG_WX("GET_ENCODE\n"); 502 LIBIPW_DEBUG_WX("GET_ENCODE\n");
503 503
504 key = erq->flags & IW_ENCODE_INDEX; 504 key = erq->flags & IW_ENCODE_INDEX;
505 if (key) { 505 if (key) {
@@ -532,7 +532,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
532 return 0; 532 return 0;
533} 533}
534 534
535int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee, 535int libipw_wx_set_encodeext(struct libipw_device *ieee,
536 struct iw_request_info *info, 536 struct iw_request_info *info,
537 union iwreq_data *wrqu, char *extra) 537 union iwreq_data *wrqu, char *extra)
538{ 538{
@@ -545,7 +545,7 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
545 struct lib80211_crypto_ops *ops; 545 struct lib80211_crypto_ops *ops;
546 struct lib80211_crypt_data **crypt; 546 struct lib80211_crypt_data **crypt;
547 547
548 struct ieee80211_security sec = { 548 struct libipw_security sec = {
549 .flags = 0, 549 .flags = 0,
550 }; 550 };
551 551
@@ -611,7 +611,7 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
611 module = "lib80211_crypt_ccmp"; 611 module = "lib80211_crypt_ccmp";
612 break; 612 break;
613 default: 613 default:
614 IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", 614 LIBIPW_DEBUG_WX("%s: unknown crypto alg %d\n",
615 dev->name, ext->alg); 615 dev->name, ext->alg);
616 ret = -EINVAL; 616 ret = -EINVAL;
617 goto done; 617 goto done;
@@ -623,7 +623,7 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
623 ops = lib80211_get_crypto_ops(alg); 623 ops = lib80211_get_crypto_ops(alg);
624 } 624 }
625 if (ops == NULL) { 625 if (ops == NULL) {
626 IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", 626 LIBIPW_DEBUG_WX("%s: unknown crypto alg %d\n",
627 dev->name, ext->alg); 627 dev->name, ext->alg);
628 ret = -EINVAL; 628 ret = -EINVAL;
629 goto done; 629 goto done;
@@ -653,7 +653,7 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
653 if (ext->key_len > 0 && (*crypt)->ops->set_key && 653 if (ext->key_len > 0 && (*crypt)->ops->set_key &&
654 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, 654 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
655 (*crypt)->priv) < 0) { 655 (*crypt)->priv) < 0) {
656 IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name); 656 LIBIPW_DEBUG_WX("%s: key setting failed\n", dev->name);
657 ret = -EINVAL; 657 ret = -EINVAL;
658 goto done; 658 goto done;
659 } 659 }
@@ -700,20 +700,20 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
700 if (ieee->reset_on_keychange && 700 if (ieee->reset_on_keychange &&
701 ieee->iw_mode != IW_MODE_INFRA && 701 ieee->iw_mode != IW_MODE_INFRA &&
702 ieee->reset_port && ieee->reset_port(dev)) { 702 ieee->reset_port && ieee->reset_port(dev)) {
703 IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name); 703 LIBIPW_DEBUG_WX("%s: reset_port failed\n", dev->name);
704 return -EINVAL; 704 return -EINVAL;
705 } 705 }
706 706
707 return ret; 707 return ret;
708} 708}
709 709
710int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, 710int libipw_wx_get_encodeext(struct libipw_device *ieee,
711 struct iw_request_info *info, 711 struct iw_request_info *info,
712 union iwreq_data *wrqu, char *extra) 712 union iwreq_data *wrqu, char *extra)
713{ 713{
714 struct iw_point *encoding = &wrqu->encoding; 714 struct iw_point *encoding = &wrqu->encoding;
715 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 715 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
716 struct ieee80211_security *sec = &ieee->sec; 716 struct libipw_security *sec = &ieee->sec;
717 int idx, max_key_len; 717 int idx, max_key_len;
718 718
719 max_key_len = encoding->length - sizeof(*ext); 719 max_key_len = encoding->length - sizeof(*ext);
@@ -763,9 +763,9 @@ int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
763 return 0; 763 return 0;
764} 764}
765 765
766EXPORT_SYMBOL(ieee80211_wx_set_encodeext); 766EXPORT_SYMBOL(libipw_wx_set_encodeext);
767EXPORT_SYMBOL(ieee80211_wx_get_encodeext); 767EXPORT_SYMBOL(libipw_wx_get_encodeext);
768 768
769EXPORT_SYMBOL(ieee80211_wx_get_scan); 769EXPORT_SYMBOL(libipw_wx_get_scan);
770EXPORT_SYMBOL(ieee80211_wx_set_encode); 770EXPORT_SYMBOL(libipw_wx_set_encode);
771EXPORT_SYMBOL(ieee80211_wx_get_encode); 771EXPORT_SYMBOL(libipw_wx_get_encode);
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 383177db7de7..82b9c93dff54 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -46,8 +46,8 @@
46#include "iwl-5000-hw.h" 46#include "iwl-5000-hw.h"
47 47
48/* Highest firmware API version supported */ 48/* Highest firmware API version supported */
49#define IWL6000_UCODE_API_MAX 3 49#define IWL6000_UCODE_API_MAX 4
50#define IWL6050_UCODE_API_MAX 3 50#define IWL6050_UCODE_API_MAX 4
51 51
52/* Lowest firmware API version supported */ 52/* Lowest firmware API version supported */
53#define IWL6000_UCODE_API_MIN 1 53#define IWL6000_UCODE_API_MIN 1
@@ -126,6 +126,7 @@ static struct iwl_lib_ops iwl6000_lib = {
126 .release_semaphore = iwlcore_eeprom_release_semaphore, 126 .release_semaphore = iwlcore_eeprom_release_semaphore,
127 .calib_version = iwl5000_eeprom_calib_version, 127 .calib_version = iwl5000_eeprom_calib_version,
128 .query_addr = iwl5000_eeprom_query_addr, 128 .query_addr = iwl5000_eeprom_query_addr,
129 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
129 }, 130 },
130 .post_associate = iwl_post_associate, 131 .post_associate = iwl_post_associate,
131 .isr = iwl_isr_ict, 132 .isr = iwl_isr_ict,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index fee110de5c6a..26ec969e265d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -2546,6 +2546,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2546 rate_idx = rate_lowest_index(sband, sta); 2546 rate_idx = rate_lowest_index(sband, sta);
2547 else if (sband->band == IEEE80211_BAND_5GHZ) 2547 else if (sband->band == IEEE80211_BAND_5GHZ)
2548 rate_idx -= IWL_FIRST_OFDM_RATE; 2548 rate_idx -= IWL_FIRST_OFDM_RATE;
2549 info->control.rates[0].flags = 0;
2549 } 2550 }
2550 info->control.rates[0].idx = rate_idx; 2551 info->control.rates[0].idx = rate_idx;
2551 2552
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 2232b1794e76..00457bff1ed1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2155,7 +2155,7 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
2155 2155
2156 priv->is_open = 0; 2156 priv->is_open = 0;
2157 2157
2158 if (iwl_is_ready_rf(priv)) { 2158 if (iwl_is_ready_rf(priv) || test_bit(STATUS_SCAN_HW, &priv->status)) {
2159 /* stop mac, cancel any scan request and clear 2159 /* stop mac, cancel any scan request and clear
2160 * RXON_FILTER_ASSOC_MSK BIT 2160 * RXON_FILTER_ASSOC_MSK BIT
2161 */ 2161 */
@@ -2477,10 +2477,15 @@ static ssize_t store_tx_power(struct device *d,
2477 ret = strict_strtoul(buf, 10, &val); 2477 ret = strict_strtoul(buf, 10, &val);
2478 if (ret) 2478 if (ret)
2479 IWL_INFO(priv, "%s is not in decimal form.\n", buf); 2479 IWL_INFO(priv, "%s is not in decimal form.\n", buf);
2480 else 2480 else {
2481 iwl_set_tx_power(priv, val, false); 2481 ret = iwl_set_tx_power(priv, val, false);
2482 2482 if (ret)
2483 return count; 2483 IWL_ERR(priv, "failed setting tx power (0x%d).\n",
2484 ret);
2485 else
2486 ret = count;
2487 }
2488 return ret;
2484} 2489}
2485 2490
2486static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power); 2491static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index f4303843ff9b..2c5c88fc38f5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -886,7 +886,6 @@ struct iwl_qosparam_cmd {
886 886
887#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2); 887#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2);
888#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8); 888#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8);
889#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8);
890#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17) 889#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
891#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18) 890#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
892#define STA_FLG_MAX_AGG_SIZE_POS (19) 891#define STA_FLG_MAX_AGG_SIZE_POS (19)
@@ -2930,6 +2929,20 @@ struct statistics_rx {
2930 struct statistics_rx_ht_phy ofdm_ht; 2929 struct statistics_rx_ht_phy ofdm_ht;
2931} __attribute__ ((packed)); 2930} __attribute__ ((packed));
2932 2931
2932/**
2933 * struct statistics_tx_power - current tx power
2934 *
2935 * @ant_a: current tx power on chain a in 1/2 dB step
2936 * @ant_b: current tx power on chain b in 1/2 dB step
2937 * @ant_c: current tx power on chain c in 1/2 dB step
2938 */
2939struct statistics_tx_power {
2940 u8 ant_a;
2941 u8 ant_b;
2942 u8 ant_c;
2943 u8 reserved;
2944} __attribute__ ((packed));
2945
2933struct statistics_tx_non_phy_agg { 2946struct statistics_tx_non_phy_agg {
2934 __le32 ba_timeout; 2947 __le32 ba_timeout;
2935 __le32 ba_reschedule_frames; 2948 __le32 ba_reschedule_frames;
@@ -2941,8 +2954,6 @@ struct statistics_tx_non_phy_agg {
2941 __le32 underrun; 2954 __le32 underrun;
2942 __le32 bt_prio_kill; 2955 __le32 bt_prio_kill;
2943 __le32 rx_ba_rsp_cnt; 2956 __le32 rx_ba_rsp_cnt;
2944 __le32 reserved2;
2945 __le32 reserved3;
2946} __attribute__ ((packed)); 2957} __attribute__ ((packed));
2947 2958
2948struct statistics_tx { 2959struct statistics_tx {
@@ -2961,6 +2972,8 @@ struct statistics_tx {
2961 __le32 cts_timeout_collision; 2972 __le32 cts_timeout_collision;
2962 __le32 ack_or_ba_timeout_collision; 2973 __le32 ack_or_ba_timeout_collision;
2963 struct statistics_tx_non_phy_agg agg; 2974 struct statistics_tx_non_phy_agg agg;
2975 struct statistics_tx_power tx_power;
2976 __le32 reserved1;
2964} __attribute__ ((packed)); 2977} __attribute__ ((packed));
2965 2978
2966 2979
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index f1f6dabd8fbd..0bfd4e918139 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -543,8 +543,8 @@ int iwlcore_init_geos(struct iwl_priv *priv)
543 543
544 geo_ch->flags |= ch->ht40_extension_channel; 544 geo_ch->flags |= ch->ht40_extension_channel;
545 545
546 if (ch->max_power_avg > priv->tx_power_channel_lmt) 546 if (ch->max_power_avg > priv->tx_power_device_lmt)
547 priv->tx_power_channel_lmt = ch->max_power_avg; 547 priv->tx_power_device_lmt = ch->max_power_avg;
548 } else { 548 } else {
549 geo_ch->flags |= IEEE80211_CHAN_DISABLED; 549 geo_ch->flags |= IEEE80211_CHAN_DISABLED;
550 } 550 }
@@ -1671,7 +1671,10 @@ int iwl_init_drv(struct iwl_priv *priv)
1671 priv->qos_data.qos_cap.val = 0; 1671 priv->qos_data.qos_cap.val = 0;
1672 1672
1673 priv->rates_mask = IWL_RATES_MASK; 1673 priv->rates_mask = IWL_RATES_MASK;
1674 priv->tx_power_user_lmt = IWL_TX_POWER_TARGET_POWER_MAX; 1674 /* Set the tx_power_user_lmt to the lowest power level
1675 * this value will get overwritten by channel max power avg
1676 * from eeprom */
1677 priv->tx_power_user_lmt = IWL_TX_POWER_TARGET_POWER_MIN;
1675 1678
1676 ret = iwl_init_channel_map(priv); 1679 ret = iwl_init_channel_map(priv);
1677 if (ret) { 1680 if (ret) {
@@ -1698,6 +1701,8 @@ EXPORT_SYMBOL(iwl_init_drv);
1698int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) 1701int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1699{ 1702{
1700 int ret = 0; 1703 int ret = 0;
1704 s8 prev_tx_power = priv->tx_power_user_lmt;
1705
1701 if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) { 1706 if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) {
1702 IWL_WARN(priv, "Requested user TXPOWER %d below lower limit %d.\n", 1707 IWL_WARN(priv, "Requested user TXPOWER %d below lower limit %d.\n",
1703 tx_power, 1708 tx_power,
@@ -1705,25 +1710,37 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1705 return -EINVAL; 1710 return -EINVAL;
1706 } 1711 }
1707 1712
1708 if (tx_power > IWL_TX_POWER_TARGET_POWER_MAX) { 1713 if (tx_power > priv->tx_power_device_lmt) {
1709 IWL_WARN(priv, "Requested user TXPOWER %d above upper limit %d.\n", 1714 IWL_WARN(priv,
1710 tx_power, 1715 "Requested user TXPOWER %d above upper limit %d.\n",
1711 IWL_TX_POWER_TARGET_POWER_MAX); 1716 tx_power, priv->tx_power_device_lmt);
1712 return -EINVAL; 1717 return -EINVAL;
1713 } 1718 }
1714 1719
1715 if (priv->tx_power_user_lmt != tx_power) 1720 if (priv->tx_power_user_lmt != tx_power)
1716 force = true; 1721 force = true;
1717 1722
1718 priv->tx_power_user_lmt = tx_power;
1719
1720 /* if nic is not up don't send command */ 1723 /* if nic is not up don't send command */
1721 if (!iwl_is_ready_rf(priv)) 1724 if (iwl_is_ready_rf(priv)) {
1722 return ret; 1725 priv->tx_power_user_lmt = tx_power;
1723 1726 if (force && priv->cfg->ops->lib->send_tx_power)
1724 if (force && priv->cfg->ops->lib->send_tx_power) 1727 ret = priv->cfg->ops->lib->send_tx_power(priv);
1725 ret = priv->cfg->ops->lib->send_tx_power(priv); 1728 else if (!priv->cfg->ops->lib->send_tx_power)
1729 ret = -EOPNOTSUPP;
1730 /*
1731 * if fail to set tx_power, restore the orig. tx power
1732 */
1733 if (ret)
1734 priv->tx_power_user_lmt = prev_tx_power;
1735 }
1726 1736
1737 /*
1738 * Even this is an async host command, the command
1739 * will always report success from uCode
1740 * So once driver can placing the command into the queue
1741 * successfully, driver can use priv->tx_power_user_lmt
1742 * to reflect the current tx power
1743 */
1727 return ret; 1744 return ret;
1728} 1745}
1729EXPORT_SYMBOL(iwl_set_tx_power); 1746EXPORT_SYMBOL(iwl_set_tx_power);
@@ -1806,7 +1823,7 @@ int iwl_reset_ict(struct iwl_priv *priv)
1806 spin_lock_irqsave(&priv->lock, flags); 1823 spin_lock_irqsave(&priv->lock, flags);
1807 iwl_disable_interrupts(priv); 1824 iwl_disable_interrupts(priv);
1808 1825
1809 memset(&priv->ict_tbl[0],0, sizeof(u32) * ICT_COUNT); 1826 memset(&priv->ict_tbl[0], 0, sizeof(u32) * ICT_COUNT);
1810 1827
1811 val = priv->aligned_ict_tbl_dma >> PAGE_SHIFT; 1828 val = priv->aligned_ict_tbl_dma >> PAGE_SHIFT;
1812 1829
@@ -1884,13 +1901,13 @@ irqreturn_t iwl_isr_ict(int irq, void *data)
1884 /* read all entries that not 0 start with ict_index */ 1901 /* read all entries that not 0 start with ict_index */
1885 while (priv->ict_tbl[priv->ict_index]) { 1902 while (priv->ict_tbl[priv->ict_index]) {
1886 1903
1887 val |= priv->ict_tbl[priv->ict_index]; 1904 val |= le32_to_cpu(priv->ict_tbl[priv->ict_index]);
1888 IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n", 1905 IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n",
1889 priv->ict_index, 1906 priv->ict_index,
1890 priv->ict_tbl[priv->ict_index]); 1907 le32_to_cpu(priv->ict_tbl[priv->ict_index]));
1891 priv->ict_tbl[priv->ict_index] = 0; 1908 priv->ict_tbl[priv->ict_index] = 0;
1892 priv->ict_index = iwl_queue_inc_wrap(priv->ict_index, 1909 priv->ict_index = iwl_queue_inc_wrap(priv->ict_index,
1893 ICT_COUNT); 1910 ICT_COUNT);
1894 1911
1895 } 1912 }
1896 1913
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 723f38a023ce..cbc62904655d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -107,6 +107,7 @@ struct iwl_debugfs {
107 struct dentry *file_ucode_general_stats; 107 struct dentry *file_ucode_general_stats;
108 struct dentry *file_sensitivity; 108 struct dentry *file_sensitivity;
109 struct dentry *file_chain_noise; 109 struct dentry *file_chain_noise;
110 struct dentry *file_tx_power;
110 } dbgfs_debug_files; 111 } dbgfs_debug_files;
111 u32 sram_offset; 112 u32 sram_offset;
112 u32 sram_len; 113 u32 sram_len;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index f68fb4711da2..fb844859a443 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -1563,6 +1563,57 @@ static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1563 return ret; 1563 return ret;
1564} 1564}
1565 1565
1566static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1567 char __user *user_buf,
1568 size_t count, loff_t *ppos) {
1569
1570 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1571 char buf[128];
1572 int pos = 0;
1573 ssize_t ret;
1574 const size_t bufsz = sizeof(buf);
1575 struct statistics_tx *tx;
1576
1577 if (!iwl_is_alive(priv))
1578 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1579 else {
1580 /* make request to uCode to retrieve statistics information */
1581 mutex_lock(&priv->mutex);
1582 ret = iwl_send_statistics_request(priv, 0);
1583 mutex_unlock(&priv->mutex);
1584
1585 if (ret) {
1586 IWL_ERR(priv, "Error sending statistics request: %zd\n",
1587 ret);
1588 return -EAGAIN;
1589 }
1590 tx = &priv->statistics.tx;
1591 if (tx->tx_power.ant_a ||
1592 tx->tx_power.ant_b ||
1593 tx->tx_power.ant_c) {
1594 pos += scnprintf(buf + pos, bufsz - pos,
1595 "tx power: (1/2 dB step)\n");
1596 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1597 tx->tx_power.ant_a)
1598 pos += scnprintf(buf + pos, bufsz - pos,
1599 "\tantenna A: 0x%X\n",
1600 tx->tx_power.ant_a);
1601 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1602 tx->tx_power.ant_b)
1603 pos += scnprintf(buf + pos, bufsz - pos,
1604 "\tantenna B: 0x%X\n",
1605 tx->tx_power.ant_b);
1606 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1607 tx->tx_power.ant_c)
1608 pos += scnprintf(buf + pos, bufsz - pos,
1609 "\tantenna C: 0x%X\n",
1610 tx->tx_power.ant_c);
1611 } else
1612 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1613 }
1614 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1615}
1616
1566DEBUGFS_READ_WRITE_FILE_OPS(rx_statistics); 1617DEBUGFS_READ_WRITE_FILE_OPS(rx_statistics);
1567DEBUGFS_READ_WRITE_FILE_OPS(tx_statistics); 1618DEBUGFS_READ_WRITE_FILE_OPS(tx_statistics);
1568DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 1619DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
@@ -1573,6 +1624,7 @@ DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
1573DEBUGFS_READ_FILE_OPS(ucode_general_stats); 1624DEBUGFS_READ_FILE_OPS(ucode_general_stats);
1574DEBUGFS_READ_FILE_OPS(sensitivity); 1625DEBUGFS_READ_FILE_OPS(sensitivity);
1575DEBUGFS_READ_FILE_OPS(chain_noise); 1626DEBUGFS_READ_FILE_OPS(chain_noise);
1627DEBUGFS_READ_FILE_OPS(tx_power);
1576 1628
1577/* 1629/*
1578 * Create the debugfs files and directories 1630 * Create the debugfs files and directories
@@ -1621,6 +1673,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1621 DEBUGFS_ADD_FILE(traffic_log, debug); 1673 DEBUGFS_ADD_FILE(traffic_log, debug);
1622 DEBUGFS_ADD_FILE(rx_queue, debug); 1674 DEBUGFS_ADD_FILE(rx_queue, debug);
1623 DEBUGFS_ADD_FILE(tx_queue, debug); 1675 DEBUGFS_ADD_FILE(tx_queue, debug);
1676 DEBUGFS_ADD_FILE(tx_power, debug);
1624 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 1677 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
1625 DEBUGFS_ADD_FILE(ucode_rx_stats, debug); 1678 DEBUGFS_ADD_FILE(ucode_rx_stats, debug);
1626 DEBUGFS_ADD_FILE(ucode_tx_stats, debug); 1679 DEBUGFS_ADD_FILE(ucode_tx_stats, debug);
@@ -1674,6 +1727,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
1674 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_traffic_log); 1727 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_traffic_log);
1675 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_queue); 1728 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_queue);
1676 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_queue); 1729 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_queue);
1730 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_power);
1677 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 1731 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
1678 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. 1732 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
1679 file_ucode_rx_stats); 1733 file_ucode_rx_stats);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 0178734499f0..028d50599550 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1170,7 +1170,7 @@ struct iwl_priv {
1170 struct iwl_hw_params hw_params; 1170 struct iwl_hw_params hw_params;
1171 1171
1172 /* INT ICT Table */ 1172 /* INT ICT Table */
1173 u32 *ict_tbl; 1173 __le32 *ict_tbl;
1174 dma_addr_t ict_tbl_dma; 1174 dma_addr_t ict_tbl_dma;
1175 dma_addr_t aligned_ict_tbl_dma; 1175 dma_addr_t aligned_ict_tbl_dma;
1176 int ict_index; 1176 int ict_index;
@@ -1215,7 +1215,7 @@ struct iwl_priv {
1215 1215
1216 /* TX Power */ 1216 /* TX Power */
1217 s8 tx_power_user_lmt; 1217 s8 tx_power_user_lmt;
1218 s8 tx_power_channel_lmt; 1218 s8 tx_power_device_lmt;
1219 1219
1220 1220
1221#ifdef CONFIG_IWLWIFI_DEBUG 1221#ifdef CONFIG_IWLWIFI_DEBUG
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 01b95e89009a..3d2b93a61e62 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -135,6 +135,78 @@ static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */
135 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 135 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
136}; 136};
137 137
138/**
139 * struct iwl_txpwr_section: eeprom section information
140 * @offset: indirect address into eeprom image
141 * @count: number of "struct iwl_eeprom_enhanced_txpwr" in this section
142 * @band: band type for the section
143 * @is_common - true: common section, false: channel section
144 * @is_cck - true: cck section, false: not cck section
145 * @is_ht_40 - true: all channel in the section are HT40 channel,
146 * false: legacy or HT 20 MHz
147 * ignore if it is common section
148 * @iwl_eeprom_section_channel: channel array in the section,
149 * ignore if common section
150 */
151struct iwl_txpwr_section {
152 u32 offset;
153 u8 count;
154 enum ieee80211_band band;
155 bool is_common;
156 bool is_cck;
157 bool is_ht40;
158 u8 iwl_eeprom_section_channel[EEPROM_MAX_TXPOWER_SECTION_ELEMENTS];
159};
160
161/**
162 * section 1 - 3 are regulatory tx power apply to all channels based on
163 * modulation: CCK, OFDM
164 * Band: 2.4GHz, 5.2GHz
165 * section 4 - 10 are regulatory tx power apply to specified channels
166 * For example:
167 * 1L - Channel 1 Legacy
168 * 1HT - Channel 1 HT
169 * (1,+1) - Channel 1 HT40 "_above_"
170 *
171 * Section 1: all CCK channels
172 * Section 2: all 2.4 GHz OFDM (Legacy, HT and HT40) channels
173 * Section 3: all 5.2 GHz OFDM (Legacy, HT and HT40) channels
174 * Section 4: 2.4 GHz 20MHz channels: 1L, 1HT, 2L, 2HT, 10L, 10HT, 11L, 11HT
175 * Section 5: 2.4 GHz 40MHz channels: (1,+1) (2,+1) (6,+1) (7,+1) (9,+1)
176 * Section 6: 5.2 GHz 20MHz channels: 36L, 64L, 100L, 36HT, 64HT, 100HT
177 * Section 7: 5.2 GHz 40MHz channels: (36,+1) (60,+1) (100,+1)
178 * Section 8: 2.4 GHz channel: 13L, 13HT
179 * Section 9: 2.4 GHz channel: 140L, 140HT
180 * Section 10: 2.4 GHz 40MHz channels: (132,+1) (44,+1)
181 *
182 */
183static const struct iwl_txpwr_section enhinfo[] = {
184 { EEPROM_LB_CCK_20_COMMON, 1, IEEE80211_BAND_2GHZ, true, true, false },
185 { EEPROM_LB_OFDM_COMMON, 3, IEEE80211_BAND_2GHZ, true, false, false },
186 { EEPROM_HB_OFDM_COMMON, 3, IEEE80211_BAND_5GHZ, true, false, false },
187 { EEPROM_LB_OFDM_20_BAND, 8, IEEE80211_BAND_2GHZ,
188 false, false, false,
189 {1, 1, 2, 2, 10, 10, 11, 11 } },
190 { EEPROM_LB_OFDM_HT40_BAND, 5, IEEE80211_BAND_2GHZ,
191 false, false, true,
192 { 1, 2, 6, 7, 9 } },
193 { EEPROM_HB_OFDM_20_BAND, 6, IEEE80211_BAND_5GHZ,
194 false, false, false,
195 { 36, 64, 100, 36, 64, 100 } },
196 { EEPROM_HB_OFDM_HT40_BAND, 3, IEEE80211_BAND_5GHZ,
197 false, false, true,
198 { 36, 60, 100 } },
199 { EEPROM_LB_OFDM_20_CHANNEL_13, 2, IEEE80211_BAND_2GHZ,
200 false, false, false,
201 { 13, 13 } },
202 { EEPROM_HB_OFDM_20_CHANNEL_140, 2, IEEE80211_BAND_5GHZ,
203 false, false, false,
204 { 140, 140 } },
205 { EEPROM_HB_OFDM_HT40_BAND_1, 2, IEEE80211_BAND_5GHZ,
206 false, false, true,
207 { 132, 44 } },
208};
209
138/****************************************************************************** 210/******************************************************************************
139 * 211 *
140 * EEPROM related functions 212 * EEPROM related functions
@@ -643,6 +715,178 @@ static int iwl_mod_ht40_chan_info(struct iwl_priv *priv,
643 return 0; 715 return 0;
644} 716}
645 717
718/**
719 * iwl_get_max_txpower_avg - get the highest tx power from all chains.
720 * find the highest tx power from all chains for the channel
721 */
722static s8 iwl_get_max_txpower_avg(struct iwl_priv *priv,
723 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, int element)
724{
725 s8 max_txpower_avg = 0; /* (dBm) */
726
727 IWL_DEBUG_INFO(priv, "%d - "
728 "chain_a: %d dB chain_b: %d dB "
729 "chain_c: %d dB mimo2: %d dB mimo3: %d dB\n",
730 element,
731 enhanced_txpower[element].chain_a_max >> 1,
732 enhanced_txpower[element].chain_b_max >> 1,
733 enhanced_txpower[element].chain_c_max >> 1,
734 enhanced_txpower[element].mimo2_max >> 1,
735 enhanced_txpower[element].mimo3_max >> 1);
736 /* Take the highest tx power from any valid chains */
737 if ((priv->cfg->valid_tx_ant & ANT_A) &&
738 (enhanced_txpower[element].chain_a_max > max_txpower_avg))
739 max_txpower_avg = enhanced_txpower[element].chain_a_max;
740 if ((priv->cfg->valid_tx_ant & ANT_B) &&
741 (enhanced_txpower[element].chain_b_max > max_txpower_avg))
742 max_txpower_avg = enhanced_txpower[element].chain_b_max;
743 if ((priv->cfg->valid_tx_ant & ANT_C) &&
744 (enhanced_txpower[element].chain_c_max > max_txpower_avg))
745 max_txpower_avg = enhanced_txpower[element].chain_c_max;
746 if (((priv->cfg->valid_tx_ant == ANT_AB) |
747 (priv->cfg->valid_tx_ant == ANT_BC) |
748 (priv->cfg->valid_tx_ant == ANT_AC)) &&
749 (enhanced_txpower[element].mimo2_max > max_txpower_avg))
750 max_txpower_avg = enhanced_txpower[element].mimo2_max;
751 if ((priv->cfg->valid_tx_ant == ANT_ABC) &&
752 (enhanced_txpower[element].mimo3_max > max_txpower_avg))
753 max_txpower_avg = enhanced_txpower[element].mimo3_max;
754
755 /* max. tx power in EEPROM is in 1/2 dBm format
756 * convert from 1/2 dBm to dBm
757 */
758 return max_txpower_avg >> 1;
759}
760
761/**
762 * iwl_update_common_txpower: update channel tx power
763 * update tx power per band based on EEPROM enhanced tx power info.
764 */
765static s8 iwl_update_common_txpower(struct iwl_priv *priv,
766 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower,
767 int section, int element)
768{
769 struct iwl_channel_info *ch_info;
770 int ch;
771 bool is_ht40 = false;
772 s8 max_txpower_avg; /* (dBm) */
773
774 /* it is common section, contain all type (Legacy, HT and HT40)
775 * based on the element in the section to determine
776 * is it HT 40 or not
777 */
778 if (element == EEPROM_TXPOWER_COMMON_HT40_INDEX)
779 is_ht40 = true;
780 max_txpower_avg =
781 iwl_get_max_txpower_avg(priv, enhanced_txpower, element);
782 ch_info = priv->channel_info;
783
784 for (ch = 0; ch < priv->channel_count; ch++) {
785 /* find matching band and update tx power if needed */
786 if ((ch_info->band == enhinfo[section].band) &&
787 (ch_info->max_power_avg < max_txpower_avg) && (!is_ht40)) {
788 /* Update regulatory-based run-time data */
789 ch_info->max_power_avg = ch_info->curr_txpow =
790 max_txpower_avg;
791 ch_info->scan_power = max_txpower_avg;
792 }
793 if ((ch_info->band == enhinfo[section].band) && is_ht40 &&
794 ch_info->ht40_max_power_avg &&
795 (ch_info->ht40_max_power_avg < max_txpower_avg)) {
796 /* Update regulatory-based run-time data */
797 ch_info->ht40_max_power_avg = max_txpower_avg;
798 ch_info->ht40_curr_txpow = max_txpower_avg;
799 ch_info->ht40_scan_power = max_txpower_avg;
800 }
801 ch_info++;
802 }
803 return max_txpower_avg;
804}
805
806/**
807 * iwl_update_channel_txpower: update channel tx power
808 * update channel tx power based on EEPROM enhanced tx power info.
809 */
810static s8 iwl_update_channel_txpower(struct iwl_priv *priv,
811 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower,
812 int section, int element)
813{
814 struct iwl_channel_info *ch_info;
815 int ch;
816 u8 channel;
817 s8 max_txpower_avg; /* (dBm) */
818
819 channel = enhinfo[section].iwl_eeprom_section_channel[element];
820 max_txpower_avg =
821 iwl_get_max_txpower_avg(priv, enhanced_txpower, element);
822
823 ch_info = priv->channel_info;
824 for (ch = 0; ch < priv->channel_count; ch++) {
825 /* find matching channel and update tx power if needed */
826 if (ch_info->channel == channel) {
827 if ((ch_info->max_power_avg < max_txpower_avg) &&
828 (!enhinfo[section].is_ht40)) {
829 /* Update regulatory-based run-time data */
830 ch_info->max_power_avg = max_txpower_avg;
831 ch_info->curr_txpow = max_txpower_avg;
832 ch_info->scan_power = max_txpower_avg;
833 }
834 if ((enhinfo[section].is_ht40) &&
835 (ch_info->ht40_max_power_avg) &&
836 (ch_info->ht40_max_power_avg < max_txpower_avg)) {
837 /* Update regulatory-based run-time data */
838 ch_info->ht40_max_power_avg = max_txpower_avg;
839 ch_info->ht40_curr_txpow = max_txpower_avg;
840 ch_info->ht40_scan_power = max_txpower_avg;
841 }
842 break;
843 }
844 ch_info++;
845 }
846 return max_txpower_avg;
847}
848
849/**
850 * iwlcore_eeprom_enhanced_txpower: process enhanced tx power info
851 */
852void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv)
853{
854 int eeprom_section_count = 0;
855 int section, element;
856 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower;
857 u32 offset;
858 s8 max_txpower_avg; /* (dBm) */
859
860 /* Loop through all the sections
861 * adjust bands and channel's max tx power
862 * Set the tx_power_user_lmt to the highest power
863 * supported by any channels and chains
864 */
865 for (section = 0; section < ARRAY_SIZE(enhinfo); section++) {
866 eeprom_section_count = enhinfo[section].count;
867 offset = enhinfo[section].offset;
868 enhanced_txpower = (struct iwl_eeprom_enhanced_txpwr *)
869 iwl_eeprom_query_addr(priv, offset);
870
871 for (element = 0; element < eeprom_section_count; element++) {
872 if (enhinfo[section].is_common)
873 max_txpower_avg =
874 iwl_update_common_txpower(priv,
875 enhanced_txpower, section, element);
876 else
877 max_txpower_avg =
878 iwl_update_channel_txpower(priv,
879 enhanced_txpower, section, element);
880
881 /* Update the tx_power_user_lmt to the highest power
882 * supported by any channel */
883 if (max_txpower_avg > priv->tx_power_user_lmt)
884 priv->tx_power_user_lmt = max_txpower_avg;
885 }
886 }
887}
888EXPORT_SYMBOL(iwlcore_eeprom_enhanced_txpower);
889
646#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ 890#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
647 ? # x " " : "") 891 ? # x " " : "")
648 892
@@ -790,6 +1034,14 @@ int iwl_init_channel_map(struct iwl_priv *priv)
790 } 1034 }
791 } 1035 }
792 1036
1037 /* for newer device (6000 series and up)
1038 * EEPROM contain enhanced tx power information
1039 * driver need to process addition information
1040 * to determine the max channel tx power limits
1041 */
1042 if (priv->cfg->ops->lib->eeprom_ops.update_enhanced_txpower)
1043 priv->cfg->ops->lib->eeprom_ops.update_enhanced_txpower(priv);
1044
793 return 0; 1045 return 0;
794} 1046}
795EXPORT_SYMBOL(iwl_init_channel_map); 1047EXPORT_SYMBOL(iwl_init_channel_map);
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index ca7920a8f52f..6b68db7b1b81 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -118,6 +118,30 @@ struct iwl_eeprom_channel {
118 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ 118 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
119} __attribute__ ((packed)); 119} __attribute__ ((packed));
120 120
121/**
122 * iwl_eeprom_enhanced_txpwr structure
123 * This structure presents the enhanced regulatory tx power limit layout
124 * in eeprom image
125 * Enhanced regulatory tx power portion of eeprom image can be broken down
126 * into individual structures; each one is 8 bytes in size and contain the
127 * following information
128 * @chain_a_max_pwr: chain a max power in 1/2 dBm
129 * @chain_b_max_pwr: chain b max power in 1/2 dBm
130 * @chain_c_max_pwr: chain c max power in 1/2 dBm
131 * @mimo2_max_pwr: mimo2 max power in 1/2 dBm
132 * @mimo3_max_pwr: mimo3 max power in 1/2 dBm
133 *
134 */
135struct iwl_eeprom_enhanced_txpwr {
136 u16 reserved;
137 s8 chain_a_max;
138 s8 chain_b_max;
139 s8 chain_c_max;
140 s8 reserved1;
141 s8 mimo2_max;
142 s8 mimo3_max;
143} __attribute__ ((packed));
144
121/* 3945 Specific */ 145/* 3945 Specific */
122#define EEPROM_3945_EEPROM_VERSION (0x2f) 146#define EEPROM_3945_EEPROM_VERSION (0x2f)
123 147
@@ -175,6 +199,59 @@ struct iwl_eeprom_channel {
175#define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\ 199#define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\
176 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ 200 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */
177 201
202/* 6000 and up regulatory tx power - indirect access */
203/* max. elements per section */
204#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8)
205#define EEPROM_TXPOWER_COMMON_HT40_INDEX (2)
206
207/**
208 * Partition the enhanced tx power portion of eeprom image into
209 * 10 sections based on band, modulation, frequency and channel
210 *
211 * Section 1: all CCK channels
212 * Section 2: all 2.4 GHz OFDM (Legacy, HT and HT40 ) channels
213 * Section 3: all 5.2 GHz OFDM (Legacy, HT and HT40) channels
214 * Section 4: 2.4 GHz 20MHz channels: 1, 2, 10, 11. Both Legacy and HT
215 * Section 5: 2.4 GHz 40MHz channels: 1, 2, 6, 7, 9, (_above_)
216 * Section 6: 5.2 GHz 20MHz channels: 36, 64, 100, both Legacy and HT
217 * Section 7: 5.2 GHz 40MHz channels: 36, 60, 100 (_above_)
218 * Section 8: 2.4 GHz channel 13, Both Legacy and HT
219 * Section 9: 2.4 GHz channel 140, Both Legacy and HT
220 * Section 10: 2.4 GHz 40MHz channels: 132, 44 (_above_)
221 */
222/* 2.4 GHz band: CCK */
223#define EEPROM_LB_CCK_20_COMMON ((0xAA)\
224 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 8 bytes */
225/* 2.4 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */
226#define EEPROM_LB_OFDM_COMMON ((0xB2)\
227 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */
228/* 5.2 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */
229#define EEPROM_HB_OFDM_COMMON ((0xCA)\
230 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */
231/* 2.4GHz band channels:
232 * 1Legacy, 1HT, 2Legacy, 2HT, 10Legacy, 10HT, 11Legacy, 11HT */
233#define EEPROM_LB_OFDM_20_BAND ((0xE2)\
234 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 64 bytes */
235/* 2.4 GHz band HT40 channels: (1,+1) (2,+1) (6,+1) (7,+1) (9,+1) */
236#define EEPROM_LB_OFDM_HT40_BAND ((0x122)\
237 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 40 bytes */
238/* 5.2GHz band channels: 36Legacy, 36HT, 64Legacy, 64HT, 100Legacy, 100HT */
239#define EEPROM_HB_OFDM_20_BAND ((0x14A)\
240 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 48 bytes */
241/* 5.2 GHz band HT40 channels: (36,+1) (60,+1) (100,+1) */
242#define EEPROM_HB_OFDM_HT40_BAND ((0x17A)\
243 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */
244/* 2.4 GHz band, channnel 13: Legacy, HT */
245#define EEPROM_LB_OFDM_20_CHANNEL_13 ((0x192)\
246 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */
247/* 5.2 GHz band, channnel 140: Legacy, HT */
248#define EEPROM_HB_OFDM_20_CHANNEL_140 ((0x1A2)\
249 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */
250/* 5.2 GHz band, HT40 channnels (132,+1) (44,+1) */
251#define EEPROM_HB_OFDM_HT40_BAND_1 ((0x1B2)\
252 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */
253
254
178/* 5050 Specific */ 255/* 5050 Specific */
179#define EEPROM_5050_TX_POWER_VERSION (4) 256#define EEPROM_5050_TX_POWER_VERSION (4)
180#define EEPROM_5050_EEPROM_VERSION (0x21E) 257#define EEPROM_5050_EEPROM_VERSION (0x21E)
@@ -389,6 +466,7 @@ struct iwl_eeprom_ops {
389 void (*release_semaphore) (struct iwl_priv *priv); 466 void (*release_semaphore) (struct iwl_priv *priv);
390 u16 (*calib_version) (struct iwl_priv *priv); 467 u16 (*calib_version) (struct iwl_priv *priv);
391 const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset); 468 const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset);
469 void (*update_enhanced_txpower) (struct iwl_priv *priv);
392}; 470};
393 471
394 472
@@ -403,7 +481,7 @@ int iwlcore_eeprom_verify_signature(struct iwl_priv *priv);
403int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv); 481int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv);
404void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv); 482void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv);
405const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); 483const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset);
406 484void iwlcore_eeprom_enhanced_txpower(struct iwl_priv *priv);
407int iwl_init_channel_map(struct iwl_priv *priv); 485int iwl_init_channel_map(struct iwl_priv *priv);
408void iwl_free_channel_map(struct iwl_priv *priv); 486void iwl_free_channel_map(struct iwl_priv *priv);
409const struct iwl_channel_info *iwl_get_channel_info( 487const struct iwl_channel_info *iwl_get_channel_info(
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 353d9a2ddbca..e34d3fcb6c3d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -915,6 +915,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
915 u32 len; 915 u32 len;
916 u32 ampdu_status; 916 u32 ampdu_status;
917 u16 fc; 917 u16 fc;
918 u32 rate_n_flags;
918 919
919 /** 920 /**
920 * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. 921 * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently.
@@ -1032,6 +1033,15 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1032 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) 1033 if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
1033 rx_status.flag |= RX_FLAG_SHORTPRE; 1034 rx_status.flag |= RX_FLAG_SHORTPRE;
1034 1035
1036 /* Set up the HT phy flags */
1037 rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);
1038 if (rate_n_flags & RATE_MCS_HT_MSK)
1039 rx_status.flag |= RX_FLAG_HT;
1040 if (rate_n_flags & RATE_MCS_HT40_MSK)
1041 rx_status.flag |= RX_FLAG_40MHZ;
1042 if (rate_n_flags & RATE_MCS_SGI_MSK)
1043 rx_status.flag |= RX_FLAG_SHORT_GI;
1044
1035 if (iwl_is_network_packet(priv, header)) { 1045 if (iwl_is_network_packet(priv, header)) {
1036 priv->last_rx_rssi = rx_status.signal; 1046 priv->last_rx_rssi = rx_status.signal;
1037 priv->last_beacon_time = priv->ucode_beacon_time; 1047 priv->last_beacon_time = priv->ucode_beacon_time;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index c4c916df4a43..4f3a108fa990 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -796,7 +796,8 @@ void iwl_bg_abort_scan(struct work_struct *work)
796{ 796{
797 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); 797 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
798 798
799 if (!iwl_is_ready(priv)) 799 if (!test_bit(STATUS_READY, &priv->status) ||
800 !test_bit(STATUS_GEO_CONFIGURED, &priv->status))
800 return; 801 return;
801 802
802 mutex_lock(&priv->mutex); 803 mutex_lock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index c6633fec8216..a2b9ec82b965 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -520,7 +520,7 @@ int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
520 struct iwl_host_cmd cmd = { 520 struct iwl_host_cmd cmd = {
521 .id = REPLY_WEPKEY, 521 .id = REPLY_WEPKEY,
522 .data = wep_cmd, 522 .data = wep_cmd,
523 .flags = CMD_ASYNC, 523 .flags = CMD_SYNC,
524 }; 524 };
525 525
526 memset(wep_cmd, 0, cmd_size + 526 memset(wep_cmd, 0, cmd_size +
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 7686fc72eb89..7bc9c0039f79 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -718,10 +718,9 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
718 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); 718 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
719#endif 719#endif
720 720
721 /* drop all data frame if we are not associated */ 721 /* drop all non-injected data frame if we are not associated */
722 if (ieee80211_is_data(fc) && 722 if (ieee80211_is_data(fc) &&
723 (!iwl_is_monitor_mode(priv) || 723 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
724 !(info->flags & IEEE80211_TX_CTL_INJECTED)) && /* packet injection */
725 (!iwl_is_associated(priv) || 724 (!iwl_is_associated(priv) ||
726 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) || 725 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) ||
727 !priv->assoc_station_added)) { 726 !priv->assoc_station_added)) {
@@ -732,7 +731,10 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
732 hdr_len = ieee80211_hdrlen(fc); 731 hdr_len = ieee80211_hdrlen(fc);
733 732
734 /* Find (or create) index into station table for destination station */ 733 /* Find (or create) index into station table for destination station */
735 sta_id = iwl_get_sta_id(priv, hdr); 734 if (info->flags & IEEE80211_TX_CTL_INJECTED)
735 sta_id = priv->hw_params.bcast_sta_id;
736 else
737 sta_id = iwl_get_sta_id(priv, hdr);
736 if (sta_id == IWL_INVALID_STATION) { 738 if (sta_id == IWL_INVALID_STATION) {
737 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 739 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
738 hdr->addr1); 740 hdr->addr1);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index f339c5bd1fde..34790413eadd 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -518,9 +518,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
518 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); 518 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
519#endif 519#endif
520 520
521 /* drop all data frame if we are not associated */ 521 /* drop all non-injected data frame if we are not associated */
522 if (ieee80211_is_data(fc) && 522 if (ieee80211_is_data(fc) &&
523 (!iwl_is_monitor_mode(priv)) && /* packet injection */ 523 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
524 (!iwl_is_associated(priv) || 524 (!iwl_is_associated(priv) ||
525 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) { 525 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) {
526 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n"); 526 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
@@ -532,7 +532,10 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
532 hdr_len = ieee80211_hdrlen(fc); 532 hdr_len = ieee80211_hdrlen(fc);
533 533
534 /* Find (or create) index into station table for destination station */ 534 /* Find (or create) index into station table for destination station */
535 sta_id = iwl_get_sta_id(priv, hdr); 535 if (info->flags & IEEE80211_TX_CTL_INJECTED)
536 sta_id = priv->hw_params.bcast_sta_id;
537 else
538 sta_id = iwl_get_sta_id(priv, hdr);
536 if (sta_id == IWL_INVALID_STATION) { 539 if (sta_id == IWL_INVALID_STATION) {
537 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 540 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
538 hdr->addr1); 541 hdr->addr1);
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 81f86ef26990..dd8732611ba9 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -34,7 +34,8 @@ static const u8 bssid_off[ETH_ALEN] __attribute__ ((aligned (2))) =
34 * 34 *
35 * @param priv A pointer to struct lbs_private structure 35 * @param priv A pointer to struct lbs_private structure
36 * @param rates the buffer which keeps input and output 36 * @param rates the buffer which keeps input and output
37 * @param rates_size the size of rate1 buffer; new size of buffer on return 37 * @param rates_size the size of rates buffer; new size of buffer on return,
38 * which will be less than or equal to original rates_size
38 * 39 *
39 * @return 0 on success, or -1 on error 40 * @return 0 on success, or -1 on error
40 */ 41 */
@@ -42,48 +43,42 @@ static int get_common_rates(struct lbs_private *priv,
42 u8 *rates, 43 u8 *rates,
43 u16 *rates_size) 44 u16 *rates_size)
44{ 45{
45 u8 *card_rates = lbs_bg_rates; 46 int i, j;
46 size_t num_card_rates = sizeof(lbs_bg_rates); 47 u8 intersection[MAX_RATES];
47 int ret = 0, i, j; 48 u16 intersection_size;
48 u8 *tmp; 49 u16 num_rates = 0;
49 size_t tmp_size = 0; 50
50 51 intersection_size = min_t(u16, *rates_size, ARRAY_SIZE(intersection));
51 tmp = kzalloc((ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1), 52
52 GFP_KERNEL); 53 /* Allow each rate from 'rates' that is supported by the hardware */
53 if (!tmp) 54 for (i = 0; i < ARRAY_SIZE(lbs_bg_rates) && lbs_bg_rates[i]; i++) {
54 return -1; 55 for (j = 0; j < intersection_size && rates[j]; j++) {
55 56 if (rates[j] == lbs_bg_rates[i])
56 /* For each rate in card_rates that exists in rate1, copy to tmp */ 57 intersection[num_rates++] = rates[j];
57 for (i = 0; card_rates[i] && (i < num_card_rates); i++) {
58 for (j = 0; rates[j] && (j < *rates_size); j++) {
59 if (rates[j] == card_rates[i])
60 tmp[tmp_size++] = card_rates[i];
61 } 58 }
62 } 59 }
63 60
64 lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); 61 lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size);
65 lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates); 62 lbs_deb_hex(LBS_DEB_JOIN, "card rates ", lbs_bg_rates,
66 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); 63 ARRAY_SIZE(lbs_bg_rates));
64 lbs_deb_hex(LBS_DEB_JOIN, "common rates", intersection, num_rates);
67 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); 65 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate);
68 66
69 if (!priv->enablehwauto) { 67 if (!priv->enablehwauto) {
70 for (i = 0; i < tmp_size; i++) { 68 for (i = 0; i < num_rates; i++) {
71 if (tmp[i] == priv->cur_rate) 69 if (intersection[i] == priv->cur_rate)
72 goto done; 70 goto done;
73 } 71 }
74 lbs_pr_alert("Previously set fixed data rate %#x isn't " 72 lbs_pr_alert("Previously set fixed data rate %#x isn't "
75 "compatible with the network.\n", priv->cur_rate); 73 "compatible with the network.\n", priv->cur_rate);
76 ret = -1; 74 return -1;
77 goto done;
78 } 75 }
79 ret = 0;
80 76
81done: 77done:
82 memset(rates, 0, *rates_size); 78 memset(rates, 0, *rates_size);
83 *rates_size = min_t(int, tmp_size, *rates_size); 79 *rates_size = num_rates;
84 memcpy(rates, tmp, *rates_size); 80 memcpy(rates, intersection, num_rates);
85 kfree(tmp); 81 return 0;
86 return ret;
87} 82}
88 83
89 84
@@ -325,8 +320,8 @@ static int lbs_associate(struct lbs_private *priv,
325 320
326 rates = (struct mrvl_ie_rates_param_set *) pos; 321 rates = (struct mrvl_ie_rates_param_set *) pos;
327 rates->header.type = cpu_to_le16(TLV_TYPE_RATES); 322 rates->header.type = cpu_to_le16(TLV_TYPE_RATES);
328 memcpy(&rates->rates, &bss->rates, MAX_RATES); 323 tmplen = min_t(u16, ARRAY_SIZE(bss->rates), MAX_RATES);
329 tmplen = MAX_RATES; 324 memcpy(&rates->rates, &bss->rates, tmplen);
330 if (get_common_rates(priv, rates->rates, &tmplen)) { 325 if (get_common_rates(priv, rates->rates, &tmplen)) {
331 ret = -1; 326 ret = -1;
332 goto done; 327 goto done;
@@ -600,7 +595,7 @@ static int lbs_adhoc_join(struct lbs_private *priv,
600 595
601 /* Copy Data rates from the rates recorded in scan response */ 596 /* Copy Data rates from the rates recorded in scan response */
602 memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates)); 597 memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates));
603 ratesize = min_t(u16, sizeof(cmd.bss.rates), MAX_RATES); 598 ratesize = min_t(u16, ARRAY_SIZE(cmd.bss.rates), ARRAY_SIZE (bss->rates));
604 memcpy(cmd.bss.rates, bss->rates, ratesize); 599 memcpy(cmd.bss.rates, bss->rates, ratesize);
605 if (get_common_rates(priv, cmd.bss.rates, &ratesize)) { 600 if (get_common_rates(priv, cmd.bss.rates, &ratesize)) {
606 lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n"); 601 lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n");
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 811ffc3ef414..893a55ca344a 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -45,6 +45,8 @@ static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
45 unsigned long addr = get_zeroed_page(GFP_KERNEL); 45 unsigned long addr = get_zeroed_page(GFP_KERNEL);
46 char *buf = (char *)addr; 46 char *buf = (char *)addr;
47 ssize_t res; 47 ssize_t res;
48 if (!buf)
49 return -ENOMEM;
48 50
49 pos += snprintf(buf+pos, len-pos, "state = %s\n", 51 pos += snprintf(buf+pos, len-pos, "state = %s\n",
50 szStates[priv->connect_status]); 52 szStates[priv->connect_status]);
@@ -68,6 +70,8 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
68 char *buf = (char *)addr; 70 char *buf = (char *)addr;
69 DECLARE_SSID_BUF(ssid); 71 DECLARE_SSID_BUF(ssid);
70 struct bss_descriptor * iter_bss; 72 struct bss_descriptor * iter_bss;
73 if (!buf)
74 return -ENOMEM;
71 75
72 pos += snprintf(buf+pos, len-pos, 76 pos += snprintf(buf+pos, len-pos,
73 "# | ch | rssi | bssid | cap | Qual | SSID \n"); 77 "# | ch | rssi | bssid | cap | Qual | SSID \n");
@@ -110,6 +114,8 @@ static ssize_t lbs_sleepparams_write(struct file *file,
110 int p1, p2, p3, p4, p5, p6; 114 int p1, p2, p3, p4, p5, p6;
111 unsigned long addr = get_zeroed_page(GFP_KERNEL); 115 unsigned long addr = get_zeroed_page(GFP_KERNEL);
112 char *buf = (char *)addr; 116 char *buf = (char *)addr;
117 if (!buf)
118 return -ENOMEM;
113 119
114 buf_size = min(count, len - 1); 120 buf_size = min(count, len - 1);
115 if (copy_from_user(buf, user_buf, buf_size)) { 121 if (copy_from_user(buf, user_buf, buf_size)) {
@@ -148,6 +154,8 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
148 struct sleep_params sp; 154 struct sleep_params sp;
149 unsigned long addr = get_zeroed_page(GFP_KERNEL); 155 unsigned long addr = get_zeroed_page(GFP_KERNEL);
150 char *buf = (char *)addr; 156 char *buf = (char *)addr;
157 if (!buf)
158 return -ENOMEM;
151 159
152 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp); 160 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp);
153 if (ret) 161 if (ret)
@@ -433,6 +441,8 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
433 int ret; 441 int ret;
434 unsigned long addr = get_zeroed_page(GFP_KERNEL); 442 unsigned long addr = get_zeroed_page(GFP_KERNEL);
435 char *buf = (char *)addr; 443 char *buf = (char *)addr;
444 if (!buf)
445 return -ENOMEM;
436 446
437 offval.offset = priv->mac_offset; 447 offval.offset = priv->mac_offset;
438 offval.value = 0; 448 offval.value = 0;
@@ -457,6 +467,8 @@ static ssize_t lbs_rdmac_write(struct file *file,
457 ssize_t res, buf_size; 467 ssize_t res, buf_size;
458 unsigned long addr = get_zeroed_page(GFP_KERNEL); 468 unsigned long addr = get_zeroed_page(GFP_KERNEL);
459 char *buf = (char *)addr; 469 char *buf = (char *)addr;
470 if (!buf)
471 return -ENOMEM;
460 472
461 buf_size = min(count, len - 1); 473 buf_size = min(count, len - 1);
462 if (copy_from_user(buf, userbuf, buf_size)) { 474 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -481,6 +493,8 @@ static ssize_t lbs_wrmac_write(struct file *file,
481 struct lbs_offset_value offval; 493 struct lbs_offset_value offval;
482 unsigned long addr = get_zeroed_page(GFP_KERNEL); 494 unsigned long addr = get_zeroed_page(GFP_KERNEL);
483 char *buf = (char *)addr; 495 char *buf = (char *)addr;
496 if (!buf)
497 return -ENOMEM;
484 498
485 buf_size = min(count, len - 1); 499 buf_size = min(count, len - 1);
486 if (copy_from_user(buf, userbuf, buf_size)) { 500 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -515,6 +529,8 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
515 int ret; 529 int ret;
516 unsigned long addr = get_zeroed_page(GFP_KERNEL); 530 unsigned long addr = get_zeroed_page(GFP_KERNEL);
517 char *buf = (char *)addr; 531 char *buf = (char *)addr;
532 if (!buf)
533 return -ENOMEM;
518 534
519 offval.offset = priv->bbp_offset; 535 offval.offset = priv->bbp_offset;
520 offval.value = 0; 536 offval.value = 0;
@@ -540,6 +556,8 @@ static ssize_t lbs_rdbbp_write(struct file *file,
540 ssize_t res, buf_size; 556 ssize_t res, buf_size;
541 unsigned long addr = get_zeroed_page(GFP_KERNEL); 557 unsigned long addr = get_zeroed_page(GFP_KERNEL);
542 char *buf = (char *)addr; 558 char *buf = (char *)addr;
559 if (!buf)
560 return -ENOMEM;
543 561
544 buf_size = min(count, len - 1); 562 buf_size = min(count, len - 1);
545 if (copy_from_user(buf, userbuf, buf_size)) { 563 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -564,6 +582,8 @@ static ssize_t lbs_wrbbp_write(struct file *file,
564 struct lbs_offset_value offval; 582 struct lbs_offset_value offval;
565 unsigned long addr = get_zeroed_page(GFP_KERNEL); 583 unsigned long addr = get_zeroed_page(GFP_KERNEL);
566 char *buf = (char *)addr; 584 char *buf = (char *)addr;
585 if (!buf)
586 return -ENOMEM;
567 587
568 buf_size = min(count, len - 1); 588 buf_size = min(count, len - 1);
569 if (copy_from_user(buf, userbuf, buf_size)) { 589 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -598,6 +618,8 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
598 int ret; 618 int ret;
599 unsigned long addr = get_zeroed_page(GFP_KERNEL); 619 unsigned long addr = get_zeroed_page(GFP_KERNEL);
600 char *buf = (char *)addr; 620 char *buf = (char *)addr;
621 if (!buf)
622 return -ENOMEM;
601 623
602 offval.offset = priv->rf_offset; 624 offval.offset = priv->rf_offset;
603 offval.value = 0; 625 offval.value = 0;
@@ -623,6 +645,8 @@ static ssize_t lbs_rdrf_write(struct file *file,
623 ssize_t res, buf_size; 645 ssize_t res, buf_size;
624 unsigned long addr = get_zeroed_page(GFP_KERNEL); 646 unsigned long addr = get_zeroed_page(GFP_KERNEL);
625 char *buf = (char *)addr; 647 char *buf = (char *)addr;
648 if (!buf)
649 return -ENOMEM;
626 650
627 buf_size = min(count, len - 1); 651 buf_size = min(count, len - 1);
628 if (copy_from_user(buf, userbuf, buf_size)) { 652 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -647,6 +671,8 @@ static ssize_t lbs_wrrf_write(struct file *file,
647 struct lbs_offset_value offval; 671 struct lbs_offset_value offval;
648 unsigned long addr = get_zeroed_page(GFP_KERNEL); 672 unsigned long addr = get_zeroed_page(GFP_KERNEL);
649 char *buf = (char *)addr; 673 char *buf = (char *)addr;
674 if (!buf)
675 return -ENOMEM;
650 676
651 buf_size = min(count, len - 1); 677 buf_size = min(count, len - 1);
652 if (copy_from_user(buf, userbuf, buf_size)) { 678 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -853,6 +879,8 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
853 struct debug_data *d; 879 struct debug_data *d;
854 unsigned long addr = get_zeroed_page(GFP_KERNEL); 880 unsigned long addr = get_zeroed_page(GFP_KERNEL);
855 char *buf = (char *)addr; 881 char *buf = (char *)addr;
882 if (!buf)
883 return -ENOMEM;
856 884
857 p = buf; 885 p = buf;
858 886
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index f658fd6a2c0c..62381768f2d5 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -59,6 +59,7 @@ struct if_cs_card {
59 struct pcmcia_device *p_dev; 59 struct pcmcia_device *p_dev;
60 struct lbs_private *priv; 60 struct lbs_private *priv;
61 void __iomem *iobase; 61 void __iomem *iobase;
62 bool align_regs;
62}; 63};
63 64
64 65
@@ -274,16 +275,25 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
274#define IF_CS_PRODUCT_ID 0x0000001C 275#define IF_CS_PRODUCT_ID 0x0000001C
275#define IF_CS_CF8385_B1_REV 0x12 276#define IF_CS_CF8385_B1_REV 0x12
276#define IF_CS_CF8381_B3_REV 0x04 277#define IF_CS_CF8381_B3_REV 0x04
278#define IF_CS_CF8305_B1_REV 0x03
277 279
278/* 280/*
279 * Used to detect other cards than CF8385 since their revisions of silicon 281 * Used to detect other cards than CF8385 since their revisions of silicon
280 * doesn't match those from CF8385, eg. CF8381 B3 works with this driver. 282 * doesn't match those from CF8385, eg. CF8381 B3 works with this driver.
281 */ 283 */
284#define CF8305_MANFID 0x02db
285#define CF8305_CARDID 0x8103
282#define CF8381_MANFID 0x02db 286#define CF8381_MANFID 0x02db
283#define CF8381_CARDID 0x6064 287#define CF8381_CARDID 0x6064
284#define CF8385_MANFID 0x02df 288#define CF8385_MANFID 0x02df
285#define CF8385_CARDID 0x8103 289#define CF8385_CARDID 0x8103
286 290
291static inline int if_cs_hw_is_cf8305(struct pcmcia_device *p_dev)
292{
293 return (p_dev->manf_id == CF8305_MANFID &&
294 p_dev->card_id == CF8305_CARDID);
295}
296
287static inline int if_cs_hw_is_cf8381(struct pcmcia_device *p_dev) 297static inline int if_cs_hw_is_cf8381(struct pcmcia_device *p_dev)
288{ 298{
289 return (p_dev->manf_id == CF8381_MANFID && 299 return (p_dev->manf_id == CF8381_MANFID &&
@@ -556,7 +566,15 @@ static int if_cs_prog_helper(struct if_cs_card *card)
556 566
557 lbs_deb_enter(LBS_DEB_CS); 567 lbs_deb_enter(LBS_DEB_CS);
558 568
559 scratch = if_cs_read8(card, IF_CS_SCRATCH); 569 /*
570 * This is the only place where an unaligned register access happens on
571 * the CF8305 card, therefore for the sake of speed of the driver, we do
572 * the alignment correction here.
573 */
574 if (card->align_regs)
575 scratch = if_cs_read16(card, IF_CS_SCRATCH) >> 8;
576 else
577 scratch = if_cs_read8(card, IF_CS_SCRATCH);
560 578
561 /* "If the value is 0x5a, the firmware is already 579 /* "If the value is 0x5a, the firmware is already
562 * downloaded successfully" 580 * downloaded successfully"
@@ -880,8 +898,24 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
880 p_dev->irq.AssignedIRQ, p_dev->io.BasePort1, 898 p_dev->irq.AssignedIRQ, p_dev->io.BasePort1,
881 p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1); 899 p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1);
882 900
901 /*
902 * Most of the libertas cards can do unaligned register access, but some
903 * weird ones can not. That's especially true for the CF8305 card.
904 */
905 card->align_regs = 0;
906
883 /* Check if we have a current silicon */ 907 /* Check if we have a current silicon */
884 prod_id = if_cs_read8(card, IF_CS_PRODUCT_ID); 908 prod_id = if_cs_read8(card, IF_CS_PRODUCT_ID);
909 if (if_cs_hw_is_cf8305(p_dev)) {
910 card->align_regs = 1;
911 if (prod_id < IF_CS_CF8305_B1_REV) {
912 lbs_pr_err("old chips like 8305 rev B3 "
913 "aren't supported\n");
914 ret = -ENODEV;
915 goto out2;
916 }
917 }
918
885 if (if_cs_hw_is_cf8381(p_dev) && prod_id < IF_CS_CF8381_B3_REV) { 919 if (if_cs_hw_is_cf8381(p_dev) && prod_id < IF_CS_CF8381_B3_REV) {
886 lbs_pr_err("old chips like 8381 rev B3 aren't supported\n"); 920 lbs_pr_err("old chips like 8381 rev B3 aren't supported\n");
887 ret = -ENODEV; 921 ret = -ENODEV;
@@ -896,7 +930,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
896 930
897 /* Load the firmware early, before calling into libertas.ko */ 931 /* Load the firmware early, before calling into libertas.ko */
898 ret = if_cs_prog_helper(card); 932 ret = if_cs_prog_helper(card);
899 if (ret == 0) 933 if (ret == 0 && !if_cs_hw_is_cf8305(p_dev))
900 ret = if_cs_prog_real(card); 934 ret = if_cs_prog_real(card);
901 if (ret) 935 if (ret)
902 goto out2; 936 goto out2;
@@ -976,6 +1010,7 @@ static void if_cs_detach(struct pcmcia_device *p_dev)
976/********************************************************************/ 1010/********************************************************************/
977 1011
978static struct pcmcia_device_id if_cs_ids[] = { 1012static struct pcmcia_device_id if_cs_ids[] = {
1013 PCMCIA_DEVICE_MANF_CARD(CF8305_MANFID, CF8305_CARDID),
979 PCMCIA_DEVICE_MANF_CARD(CF8381_MANFID, CF8381_CARDID), 1014 PCMCIA_DEVICE_MANF_CARD(CF8381_MANFID, CF8381_CARDID),
980 PCMCIA_DEVICE_MANF_CARD(CF8385_MANFID, CF8385_CARDID), 1015 PCMCIA_DEVICE_MANF_CARD(CF8385_MANFID, CF8385_CARDID),
981 PCMCIA_DEVICE_NULL, 1016 PCMCIA_DEVICE_NULL,
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 41a708ce8730..746532ebe5a8 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -164,7 +164,7 @@ struct mwl8k_priv {
164 164
165 u16 num_mcaddrs; 165 u16 num_mcaddrs;
166 u8 hw_rev; 166 u8 hw_rev;
167 __le32 fw_rev; 167 u32 fw_rev;
168 168
169 /* 169 /*
170 * Running count of TX packets in flight, to avoid 170 * Running count of TX packets in flight, to avoid
@@ -1439,8 +1439,11 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1439 return -ENOMEM; 1439 return -ENOMEM;
1440 1440
1441 rc = mwl8k_fw_lock(hw); 1441 rc = mwl8k_fw_lock(hw);
1442 if (rc) 1442 if (rc) {
1443 pci_unmap_single(priv->pdev, dma_addr, dma_size,
1444 PCI_DMA_BIDIRECTIONAL);
1443 return rc; 1445 return rc;
1446 }
1444 1447
1445 priv->hostcmd_wait = &cmd_wait; 1448 priv->hostcmd_wait = &cmd_wait;
1446 iowrite32(dma_addr, regs + MWL8K_HIU_GEN_PTR); 1449 iowrite32(dma_addr, regs + MWL8K_HIU_GEN_PTR);
@@ -1471,7 +1474,7 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1471 printk(KERN_ERR "%s: Command %s error 0x%x\n", 1474 printk(KERN_ERR "%s: Command %s error 0x%x\n",
1472 priv->name, 1475 priv->name,
1473 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)), 1476 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1474 cmd->result); 1477 le16_to_cpu(cmd->result));
1475 } 1478 }
1476 1479
1477 return rc; 1480 return rc;
@@ -2617,7 +2620,7 @@ static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
2617 priv->capture_beacon = false; 2620 priv->capture_beacon = false;
2618 2621
2619 rc = mwl8k_fw_lock(hw); 2622 rc = mwl8k_fw_lock(hw);
2620 if (!rc) 2623 if (rc)
2621 return; 2624 return;
2622 2625
2623 if (info->assoc) { 2626 if (info->assoc) {
@@ -2822,11 +2825,16 @@ static void mwl8k_finalize_join_worker(struct work_struct *work)
2822static int __devinit mwl8k_probe(struct pci_dev *pdev, 2825static int __devinit mwl8k_probe(struct pci_dev *pdev,
2823 const struct pci_device_id *id) 2826 const struct pci_device_id *id)
2824{ 2827{
2828 static int printed_version = 0;
2825 struct ieee80211_hw *hw; 2829 struct ieee80211_hw *hw;
2826 struct mwl8k_priv *priv; 2830 struct mwl8k_priv *priv;
2827 int rc; 2831 int rc;
2828 int i; 2832 int i;
2829 u8 *fw; 2833
2834 if (!printed_version) {
2835 printk(KERN_INFO "%s version %s\n", MWL8K_DESC, MWL8K_VERSION);
2836 printed_version = 1;
2837 }
2830 2838
2831 rc = pci_enable_device(pdev); 2839 rc = pci_enable_device(pdev);
2832 if (rc) { 2840 if (rc) {
@@ -3001,13 +3009,11 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
3001 goto err_stop_firmware; 3009 goto err_stop_firmware;
3002 } 3010 }
3003 3011
3004 fw = (u8 *)&priv->fw_rev; 3012 printk(KERN_INFO "%s: 88w%u v%d, %pM, firmware version %u.%u.%u.%u\n",
3005 printk(KERN_INFO "%s: 88W%u %s\n", priv->name, priv->part_num, 3013 wiphy_name(hw->wiphy), priv->part_num, priv->hw_rev,
3006 MWL8K_DESC); 3014 hw->wiphy->perm_addr,
3007 printk(KERN_INFO "%s: Driver Ver:%s Firmware Ver:%u.%u.%u.%u\n", 3015 (priv->fw_rev >> 24) & 0xff, (priv->fw_rev >> 16) & 0xff,
3008 priv->name, MWL8K_VERSION, fw[3], fw[2], fw[1], fw[0]); 3016 (priv->fw_rev >> 8) & 0xff, priv->fw_rev & 0xff);
3009 printk(KERN_INFO "%s: MAC Address: %pM\n", priv->name,
3010 hw->wiphy->perm_addr);
3011 3017
3012 return 0; 3018 return 0;
3013 3019
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index 6fc0b6148c8a..b6dda2b27fb5 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -623,6 +623,9 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
623 if (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE) 623 if (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)
624 *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL; 624 *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
625 625
626 if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
627 *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
628
626 *queue = skb_get_queue_mapping(skb) + P54_QUEUE_DATA; 629 *queue = skb_get_queue_mapping(skb) + P54_QUEUE_DATA;
627 630
628 switch (priv->mode) { 631 switch (priv->mode) {
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index c255d9c6a5f1..9b5ee3419287 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -50,7 +50,7 @@ islpci_eth_cleanup_transmit(islpci_private *priv,
50 50
51 /* check for holes in the arrays caused by multi fragment frames 51 /* check for holes in the arrays caused by multi fragment frames
52 * searching for the last fragment of a frame */ 52 * searching for the last fragment of a frame */
53 if (priv->pci_map_tx_address[index] != (dma_addr_t) NULL) { 53 if (priv->pci_map_tx_address[index]) {
54 /* entry is the last fragment of a frame 54 /* entry is the last fragment of a frame
55 * free the skb structure and unmap pci memory */ 55 * free the skb structure and unmap pci memory */
56 skb = priv->data_low_tx[index]; 56 skb = priv->data_low_tx[index];
@@ -450,7 +450,7 @@ islpci_eth_receive(islpci_private *priv)
450 pci_map_single(priv->pdev, (void *) skb->data, 450 pci_map_single(priv->pdev, (void *) skb->data,
451 MAX_FRAGMENT_SIZE_RX + 2, 451 MAX_FRAGMENT_SIZE_RX + 2,
452 PCI_DMA_FROMDEVICE); 452 PCI_DMA_FROMDEVICE);
453 if (unlikely(priv->pci_map_rx_address[index] == (dma_addr_t) NULL)) { 453 if (unlikely(!priv->pci_map_rx_address[index])) {
454 /* error mapping the buffer to device accessable memory address */ 454 /* error mapping the buffer to device accessable memory address */
455 DEBUG(SHOW_ERROR_MESSAGES, 455 DEBUG(SHOW_ERROR_MESSAGES,
456 "Error mapping DMA address\n"); 456 "Error mapping DMA address\n");
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index d42692dfbc67..402d36757765 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -358,13 +358,6 @@ struct ndis_80211_assoc_info {
358 __le32 offset_resp_ies; 358 __le32 offset_resp_ies;
359} __attribute__((packed)); 359} __attribute__((packed));
360 360
361/* these have to match what is in wpa_supplicant */
362enum wpa_alg { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP };
363enum wpa_cipher { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
364 CIPHER_WEP104 };
365enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
366 KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE };
367
368/* 361/*
369 * private data 362 * private data
370 */ 363 */
@@ -379,6 +372,15 @@ enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
379#define WORK_LINK_DOWN (1<<1) 372#define WORK_LINK_DOWN (1<<1)
380#define WORK_SET_MULTICAST_LIST (1<<2) 373#define WORK_SET_MULTICAST_LIST (1<<2)
381 374
375#define RNDIS_WLAN_ALG_NONE 0
376#define RNDIS_WLAN_ALG_WEP (1<<0)
377#define RNDIS_WLAN_ALG_TKIP (1<<1)
378#define RNDIS_WLAN_ALG_CCMP (1<<2)
379
380#define RNDIS_WLAN_KEY_MGMT_NONE 0
381#define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0)
382#define RNDIS_WLAN_KEY_MGMT_PSK (1<<1)
383
382#define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set)) 384#define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set))
383 385
384static const struct ieee80211_channel rndis_channels[] = { 386static const struct ieee80211_channel rndis_channels[] = {
@@ -413,9 +415,16 @@ static const struct ieee80211_rate rndis_rates[] = {
413 { .bitrate = 540 } 415 { .bitrate = 540 }
414}; 416};
415 417
418static const u32 rndis_cipher_suites[] = {
419 WLAN_CIPHER_SUITE_WEP40,
420 WLAN_CIPHER_SUITE_WEP104,
421 WLAN_CIPHER_SUITE_TKIP,
422 WLAN_CIPHER_SUITE_CCMP,
423};
424
416struct rndis_wlan_encr_key { 425struct rndis_wlan_encr_key {
417 int len; 426 int len;
418 int cipher; 427 u32 cipher;
419 u8 material[32]; 428 u8 material[32];
420 u8 bssid[ETH_ALEN]; 429 u8 bssid[ETH_ALEN];
421 bool pairwise; 430 bool pairwise;
@@ -431,19 +440,17 @@ struct rndis_wlan_private {
431 struct cfg80211_scan_request *scan_request; 440 struct cfg80211_scan_request *scan_request;
432 441
433 struct workqueue_struct *workqueue; 442 struct workqueue_struct *workqueue;
434 struct delayed_work stats_work; 443 struct delayed_work dev_poller_work;
435 struct delayed_work scan_work; 444 struct delayed_work scan_work;
436 struct work_struct work; 445 struct work_struct work;
437 struct mutex command_lock; 446 struct mutex command_lock;
438 spinlock_t stats_lock;
439 unsigned long work_pending; 447 unsigned long work_pending;
448 int last_qual;
440 449
441 struct ieee80211_supported_band band; 450 struct ieee80211_supported_band band;
442 struct ieee80211_channel channels[ARRAY_SIZE(rndis_channels)]; 451 struct ieee80211_channel channels[ARRAY_SIZE(rndis_channels)];
443 struct ieee80211_rate rates[ARRAY_SIZE(rndis_rates)]; 452 struct ieee80211_rate rates[ARRAY_SIZE(rndis_rates)];
444 453 u32 cipher_suites[ARRAY_SIZE(rndis_cipher_suites)];
445 struct iw_statistics iwstats;
446 struct iw_statistics privstats;
447 454
448 int caps; 455 int caps;
449 int multicast_size; 456 int multicast_size;
@@ -461,14 +468,17 @@ struct rndis_wlan_private {
461 /* hardware state */ 468 /* hardware state */
462 int radio_on; 469 int radio_on;
463 int infra_mode; 470 int infra_mode;
471 bool connected;
472 u8 bssid[ETH_ALEN];
464 struct ndis_80211_ssid essid; 473 struct ndis_80211_ssid essid;
474 __le32 current_command_oid;
465 475
466 /* encryption stuff */ 476 /* encryption stuff */
467 int encr_tx_key_index; 477 int encr_tx_key_index;
468 struct rndis_wlan_encr_key encr_keys[4]; 478 struct rndis_wlan_encr_key encr_keys[4];
479 enum nl80211_auth_type wpa_auth_type;
469 int wpa_version; 480 int wpa_version;
470 int wpa_keymgmt; 481 int wpa_keymgmt;
471 int wpa_authalg;
472 int wpa_ie_len; 482 int wpa_ie_len;
473 u8 *wpa_ie; 483 u8 *wpa_ie;
474 int wpa_cipher_pair; 484 int wpa_cipher_pair;
@@ -494,22 +504,57 @@ static int rndis_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type,
494 int dbm); 504 int dbm);
495static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm); 505static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm);
496 506
507static int rndis_connect(struct wiphy *wiphy, struct net_device *dev,
508 struct cfg80211_connect_params *sme);
509
510static int rndis_disconnect(struct wiphy *wiphy, struct net_device *dev,
511 u16 reason_code);
512
513static int rndis_join_ibss(struct wiphy *wiphy, struct net_device *dev,
514 struct cfg80211_ibss_params *params);
515
516static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev);
517
518static int rndis_set_channel(struct wiphy *wiphy,
519 struct ieee80211_channel *chan, enum nl80211_channel_type channel_type);
520
521static int rndis_add_key(struct wiphy *wiphy, struct net_device *netdev,
522 u8 key_index, const u8 *mac_addr,
523 struct key_params *params);
524
525static int rndis_del_key(struct wiphy *wiphy, struct net_device *netdev,
526 u8 key_index, const u8 *mac_addr);
527
528static int rndis_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
529 u8 key_index);
530
531static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
532 u8 *mac, struct station_info *sinfo);
533
534static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
535 int idx, u8 *mac, struct station_info *sinfo);
536
497static struct cfg80211_ops rndis_config_ops = { 537static struct cfg80211_ops rndis_config_ops = {
498 .change_virtual_intf = rndis_change_virtual_intf, 538 .change_virtual_intf = rndis_change_virtual_intf,
499 .scan = rndis_scan, 539 .scan = rndis_scan,
500 .set_wiphy_params = rndis_set_wiphy_params, 540 .set_wiphy_params = rndis_set_wiphy_params,
501 .set_tx_power = rndis_set_tx_power, 541 .set_tx_power = rndis_set_tx_power,
502 .get_tx_power = rndis_get_tx_power, 542 .get_tx_power = rndis_get_tx_power,
543 .connect = rndis_connect,
544 .disconnect = rndis_disconnect,
545 .join_ibss = rndis_join_ibss,
546 .leave_ibss = rndis_leave_ibss,
547 .set_channel = rndis_set_channel,
548 .add_key = rndis_add_key,
549 .del_key = rndis_del_key,
550 .set_default_key = rndis_set_default_key,
551 .get_station = rndis_get_station,
552 .dump_station = rndis_dump_station,
503}; 553};
504 554
505static void *rndis_wiphy_privid = &rndis_wiphy_privid; 555static void *rndis_wiphy_privid = &rndis_wiphy_privid;
506 556
507 557
508static const unsigned char zero_bssid[ETH_ALEN] = {0,};
509static const unsigned char ffff_bssid[ETH_ALEN] = { 0xff, 0xff, 0xff,
510 0xff, 0xff, 0xff };
511
512
513static struct rndis_wlan_private *get_rndis_wlan_priv(struct usbnet *dev) 558static struct rndis_wlan_private *get_rndis_wlan_priv(struct usbnet *dev)
514{ 559{
515 return (struct rndis_wlan_private *)dev->driver_priv; 560 return (struct rndis_wlan_private *)dev->driver_priv;
@@ -541,6 +586,34 @@ static bool is_wpa_key(struct rndis_wlan_private *priv, int idx)
541} 586}
542 587
543 588
589static int rndis_cipher_to_alg(u32 cipher)
590{
591 switch (cipher) {
592 default:
593 return RNDIS_WLAN_ALG_NONE;
594 case WLAN_CIPHER_SUITE_WEP40:
595 case WLAN_CIPHER_SUITE_WEP104:
596 return RNDIS_WLAN_ALG_WEP;
597 case WLAN_CIPHER_SUITE_TKIP:
598 return RNDIS_WLAN_ALG_TKIP;
599 case WLAN_CIPHER_SUITE_CCMP:
600 return RNDIS_WLAN_ALG_CCMP;
601 }
602}
603
604static int rndis_akm_suite_to_key_mgmt(u32 akm_suite)
605{
606 switch (akm_suite) {
607 default:
608 return RNDIS_WLAN_KEY_MGMT_NONE;
609 case WLAN_AKM_SUITE_8021X:
610 return RNDIS_WLAN_KEY_MGMT_802_1X;
611 case WLAN_AKM_SUITE_PSK:
612 return RNDIS_WLAN_KEY_MGMT_PSK;
613 }
614}
615
616
544#ifdef DEBUG 617#ifdef DEBUG
545static const char *oid_to_string(__le32 oid) 618static const char *oid_to_string(__le32 oid)
546{ 619{
@@ -657,7 +730,9 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
657 u.get->msg_len = cpu_to_le32(sizeof *u.get); 730 u.get->msg_len = cpu_to_le32(sizeof *u.get);
658 u.get->oid = oid; 731 u.get->oid = oid;
659 732
733 priv->current_command_oid = oid;
660 ret = rndis_command(dev, u.header, buflen); 734 ret = rndis_command(dev, u.header, buflen);
735 priv->current_command_oid = 0;
661 if (ret < 0) 736 if (ret < 0)
662 devdbg(dev, "rndis_query_oid(%s): rndis_command() failed, %d " 737 devdbg(dev, "rndis_query_oid(%s): rndis_command() failed, %d "
663 "(%08x)", oid_to_string(oid), ret, 738 "(%08x)", oid_to_string(oid), ret,
@@ -665,7 +740,8 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
665 740
666 if (ret == 0) { 741 if (ret == 0) {
667 ret = le32_to_cpu(u.get_c->len); 742 ret = le32_to_cpu(u.get_c->len);
668 *len = (*len > ret) ? ret : *len; 743 if (ret > *len)
744 *len = ret;
669 memcpy(data, u.buf + le32_to_cpu(u.get_c->offset) + 8, *len); 745 memcpy(data, u.buf + le32_to_cpu(u.get_c->offset) + 8, *len);
670 ret = rndis_error_status(u.get_c->status); 746 ret = rndis_error_status(u.get_c->status);
671 747
@@ -717,7 +793,9 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len)
717 u.set->handle = cpu_to_le32(0); 793 u.set->handle = cpu_to_le32(0);
718 memcpy(u.buf + sizeof(*u.set), data, len); 794 memcpy(u.buf + sizeof(*u.set), data, len);
719 795
796 priv->current_command_oid = oid;
720 ret = rndis_command(dev, u.header, buflen); 797 ret = rndis_command(dev, u.header, buflen);
798 priv->current_command_oid = 0;
721 if (ret < 0) 799 if (ret < 0)
722 devdbg(dev, "rndis_set_oid(%s): rndis_command() failed, %d " 800 devdbg(dev, "rndis_set_oid(%s): rndis_command() failed, %d "
723 "(%08x)", oid_to_string(oid), ret, 801 "(%08x)", oid_to_string(oid), ret,
@@ -752,6 +830,7 @@ static int rndis_reset(struct usbnet *usbdev)
752 memset(reset, 0, sizeof(*reset)); 830 memset(reset, 0, sizeof(*reset));
753 reset->msg_type = RNDIS_MSG_RESET; 831 reset->msg_type = RNDIS_MSG_RESET;
754 reset->msg_len = cpu_to_le32(sizeof(*reset)); 832 reset->msg_len = cpu_to_le32(sizeof(*reset));
833 priv->current_command_oid = 0;
755 ret = rndis_command(usbdev, (void *)reset, CONTROL_BUFFER_SIZE); 834 ret = rndis_command(usbdev, (void *)reset, CONTROL_BUFFER_SIZE);
756 835
757 mutex_unlock(&priv->command_lock); 836 mutex_unlock(&priv->command_lock);
@@ -868,73 +947,12 @@ static int level_to_qual(int level)
868} 947}
869 948
870 949
871static void dsconfig_to_freq(unsigned int dsconfig, struct iw_freq *freq)
872{
873 freq->e = 0;
874 freq->i = 0;
875 freq->flags = 0;
876
877 /* see comment in wireless.h above the "struct iw_freq"
878 * definition for an explanation of this if
879 * NOTE: 1000000 is due to the kHz
880 */
881 if (dsconfig > 1000000) {
882 freq->m = dsconfig / 10;
883 freq->e = 1;
884 } else
885 freq->m = dsconfig;
886
887 /* convert from kHz to Hz */
888 freq->e += 3;
889}
890
891
892static int freq_to_dsconfig(struct iw_freq *freq, unsigned int *dsconfig)
893{
894 if (freq->m < 1000 && freq->e == 0) {
895 if (freq->m >= 1 && freq->m <= 14)
896 *dsconfig = ieee80211_dsss_chan_to_freq(freq->m) * 1000;
897 else
898 return -1;
899 } else {
900 int i;
901 *dsconfig = freq->m;
902 for (i = freq->e; i > 0; i--)
903 *dsconfig *= 10;
904 *dsconfig /= 1000;
905 }
906
907 return 0;
908}
909
910
911/* 950/*
912 * common functions 951 * common functions
913 */ 952 */
953static int set_infra_mode(struct usbnet *usbdev, int mode);
914static void restore_keys(struct usbnet *usbdev); 954static void restore_keys(struct usbnet *usbdev);
915 955static int rndis_check_bssid_list(struct usbnet *usbdev);
916static int get_essid(struct usbnet *usbdev, struct ndis_80211_ssid *ssid)
917{
918 int ret, len;
919
920 len = sizeof(*ssid);
921 ret = rndis_query_oid(usbdev, OID_802_11_SSID, ssid, &len);
922
923 if (ret != 0)
924 ssid->length = 0;
925
926#ifdef DEBUG
927 {
928 unsigned char tmp[NDIS_802_11_LENGTH_SSID + 1];
929
930 memcpy(tmp, ssid->essid, le32_to_cpu(ssid->length));
931 tmp[le32_to_cpu(ssid->length)] = 0;
932 devdbg(usbdev, "get_essid: '%s', ret: %d", tmp, ret);
933 }
934#endif
935 return ret;
936}
937
938 956
939static int set_essid(struct usbnet *usbdev, struct ndis_80211_ssid *ssid) 957static int set_essid(struct usbnet *usbdev, struct ndis_80211_ssid *ssid)
940{ 958{
@@ -942,6 +960,10 @@ static int set_essid(struct usbnet *usbdev, struct ndis_80211_ssid *ssid)
942 int ret; 960 int ret;
943 961
944 ret = rndis_set_oid(usbdev, OID_802_11_SSID, ssid, sizeof(*ssid)); 962 ret = rndis_set_oid(usbdev, OID_802_11_SSID, ssid, sizeof(*ssid));
963 if (ret < 0) {
964 devwarn(usbdev, "setting SSID failed (%08X)", ret);
965 return ret;
966 }
945 if (ret == 0) { 967 if (ret == 0) {
946 memcpy(&priv->essid, ssid, sizeof(priv->essid)); 968 memcpy(&priv->essid, ssid, sizeof(priv->essid));
947 priv->radio_on = 1; 969 priv->radio_on = 1;
@@ -951,6 +973,25 @@ static int set_essid(struct usbnet *usbdev, struct ndis_80211_ssid *ssid)
951 return ret; 973 return ret;
952} 974}
953 975
976static int set_bssid(struct usbnet *usbdev, u8 bssid[ETH_ALEN])
977{
978 int ret;
979
980 ret = rndis_set_oid(usbdev, OID_802_11_BSSID, bssid, ETH_ALEN);
981 if (ret < 0) {
982 devwarn(usbdev, "setting BSSID[%pM] failed (%08X)", bssid, ret);
983 return ret;
984 }
985
986 return ret;
987}
988
989static int clear_bssid(struct usbnet *usbdev)
990{
991 u8 broadcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
992
993 return set_bssid(usbdev, broadcast_mac);
994}
954 995
955static int get_bssid(struct usbnet *usbdev, u8 bssid[ETH_ALEN]) 996static int get_bssid(struct usbnet *usbdev, u8 bssid[ETH_ALEN])
956{ 997{
@@ -972,14 +1013,18 @@ static int get_association_info(struct usbnet *usbdev,
972 info, &len); 1013 info, &len);
973} 1014}
974 1015
975static int is_associated(struct usbnet *usbdev) 1016static bool is_associated(struct usbnet *usbdev)
976{ 1017{
1018 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
977 u8 bssid[ETH_ALEN]; 1019 u8 bssid[ETH_ALEN];
978 int ret; 1020 int ret;
979 1021
1022 if (!priv->radio_on)
1023 return false;
1024
980 ret = get_bssid(usbdev, bssid); 1025 ret = get_bssid(usbdev, bssid);
981 1026
982 return(ret == 0 && memcmp(bssid, zero_bssid, ETH_ALEN) != 0); 1027 return (ret == 0 && !is_zero_ether_addr(bssid));
983} 1028}
984 1029
985 1030
@@ -1003,6 +1048,11 @@ static int disassociate(struct usbnet *usbdev, int reset_ssid)
1003 /* disassociate causes radio to be turned off; if reset_ssid 1048 /* disassociate causes radio to be turned off; if reset_ssid
1004 * is given, set random ssid to enable radio */ 1049 * is given, set random ssid to enable radio */
1005 if (reset_ssid) { 1050 if (reset_ssid) {
1051 /* Set device to infrastructure mode so we don't get ad-hoc
1052 * 'media connect' indications with the random ssid.
1053 */
1054 set_infra_mode(usbdev, NDIS_80211_INFRA_INFRA);
1055
1006 ssid.length = cpu_to_le32(sizeof(ssid.essid)); 1056 ssid.length = cpu_to_le32(sizeof(ssid.essid));
1007 get_random_bytes(&ssid.essid[2], sizeof(ssid.essid)-2); 1057 get_random_bytes(&ssid.essid[2], sizeof(ssid.essid)-2);
1008 ssid.essid[0] = 0x1; 1058 ssid.essid[0] = 0x1;
@@ -1015,34 +1065,34 @@ static int disassociate(struct usbnet *usbdev, int reset_ssid)
1015} 1065}
1016 1066
1017 1067
1018static int set_auth_mode(struct usbnet *usbdev, int wpa_version, int authalg) 1068static int set_auth_mode(struct usbnet *usbdev, u32 wpa_version,
1069 enum nl80211_auth_type auth_type, int keymgmt)
1019{ 1070{
1020 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1071 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1021 __le32 tmp; 1072 __le32 tmp;
1022 int auth_mode, ret; 1073 int auth_mode, ret;
1023 1074
1024 devdbg(usbdev, "set_auth_mode: wpa_version=0x%x authalg=0x%x " 1075 devdbg(usbdev, "set_auth_mode: wpa_version=0x%x authalg=0x%x "
1025 "keymgmt=0x%x", wpa_version, authalg, priv->wpa_keymgmt); 1076 "keymgmt=0x%x", wpa_version, auth_type, keymgmt);
1026 1077
1027 if (wpa_version & IW_AUTH_WPA_VERSION_WPA2) { 1078 if (wpa_version & NL80211_WPA_VERSION_2) {
1028 if (priv->wpa_keymgmt & IW_AUTH_KEY_MGMT_802_1X) 1079 if (keymgmt & RNDIS_WLAN_KEY_MGMT_802_1X)
1029 auth_mode = NDIS_80211_AUTH_WPA2; 1080 auth_mode = NDIS_80211_AUTH_WPA2;
1030 else 1081 else
1031 auth_mode = NDIS_80211_AUTH_WPA2_PSK; 1082 auth_mode = NDIS_80211_AUTH_WPA2_PSK;
1032 } else if (wpa_version & IW_AUTH_WPA_VERSION_WPA) { 1083 } else if (wpa_version & NL80211_WPA_VERSION_1) {
1033 if (priv->wpa_keymgmt & IW_AUTH_KEY_MGMT_802_1X) 1084 if (keymgmt & RNDIS_WLAN_KEY_MGMT_802_1X)
1034 auth_mode = NDIS_80211_AUTH_WPA; 1085 auth_mode = NDIS_80211_AUTH_WPA;
1035 else if (priv->wpa_keymgmt & IW_AUTH_KEY_MGMT_PSK) 1086 else if (keymgmt & RNDIS_WLAN_KEY_MGMT_PSK)
1036 auth_mode = NDIS_80211_AUTH_WPA_PSK; 1087 auth_mode = NDIS_80211_AUTH_WPA_PSK;
1037 else 1088 else
1038 auth_mode = NDIS_80211_AUTH_WPA_NONE; 1089 auth_mode = NDIS_80211_AUTH_WPA_NONE;
1039 } else if (authalg & IW_AUTH_ALG_SHARED_KEY) { 1090 } else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
1040 if (authalg & IW_AUTH_ALG_OPEN_SYSTEM) 1091 auth_mode = NDIS_80211_AUTH_SHARED;
1041 auth_mode = NDIS_80211_AUTH_AUTO_SWITCH; 1092 else if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
1042 else
1043 auth_mode = NDIS_80211_AUTH_SHARED;
1044 } else
1045 auth_mode = NDIS_80211_AUTH_OPEN; 1093 auth_mode = NDIS_80211_AUTH_OPEN;
1094 else
1095 return -ENOTSUPP;
1046 1096
1047 tmp = cpu_to_le32(auth_mode); 1097 tmp = cpu_to_le32(auth_mode);
1048 ret = rndis_set_oid(usbdev, OID_802_11_AUTHENTICATION_MODE, &tmp, 1098 ret = rndis_set_oid(usbdev, OID_802_11_AUTHENTICATION_MODE, &tmp,
@@ -1053,7 +1103,9 @@ static int set_auth_mode(struct usbnet *usbdev, int wpa_version, int authalg)
1053 } 1103 }
1054 1104
1055 priv->wpa_version = wpa_version; 1105 priv->wpa_version = wpa_version;
1056 priv->wpa_authalg = authalg; 1106 priv->wpa_auth_type = auth_type;
1107 priv->wpa_keymgmt = keymgmt;
1108
1057 return 0; 1109 return 0;
1058} 1110}
1059 1111
@@ -1065,8 +1117,8 @@ static int set_priv_filter(struct usbnet *usbdev)
1065 1117
1066 devdbg(usbdev, "set_priv_filter: wpa_version=0x%x", priv->wpa_version); 1118 devdbg(usbdev, "set_priv_filter: wpa_version=0x%x", priv->wpa_version);
1067 1119
1068 if (priv->wpa_version & IW_AUTH_WPA_VERSION_WPA2 || 1120 if (priv->wpa_version & NL80211_WPA_VERSION_2 ||
1069 priv->wpa_version & IW_AUTH_WPA_VERSION_WPA) 1121 priv->wpa_version & NL80211_WPA_VERSION_1)
1070 tmp = cpu_to_le32(NDIS_80211_PRIV_8021X_WEP); 1122 tmp = cpu_to_le32(NDIS_80211_PRIV_8021X_WEP);
1071 else 1123 else
1072 tmp = cpu_to_le32(NDIS_80211_PRIV_ACCEPT_ALL); 1124 tmp = cpu_to_le32(NDIS_80211_PRIV_ACCEPT_ALL);
@@ -1083,19 +1135,17 @@ static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
1083 int encr_mode, ret; 1135 int encr_mode, ret;
1084 1136
1085 devdbg(usbdev, "set_encr_mode: cipher_pair=0x%x cipher_group=0x%x", 1137 devdbg(usbdev, "set_encr_mode: cipher_pair=0x%x cipher_group=0x%x",
1086 pairwise, 1138 pairwise, groupwise);
1087 groupwise);
1088 1139
1089 if (pairwise & IW_AUTH_CIPHER_CCMP) 1140 if (pairwise & RNDIS_WLAN_ALG_CCMP)
1090 encr_mode = NDIS_80211_ENCR_CCMP_ENABLED; 1141 encr_mode = NDIS_80211_ENCR_CCMP_ENABLED;
1091 else if (pairwise & IW_AUTH_CIPHER_TKIP) 1142 else if (pairwise & RNDIS_WLAN_ALG_TKIP)
1092 encr_mode = NDIS_80211_ENCR_TKIP_ENABLED; 1143 encr_mode = NDIS_80211_ENCR_TKIP_ENABLED;
1093 else if (pairwise & 1144 else if (pairwise & RNDIS_WLAN_ALG_WEP)
1094 (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104))
1095 encr_mode = NDIS_80211_ENCR_WEP_ENABLED; 1145 encr_mode = NDIS_80211_ENCR_WEP_ENABLED;
1096 else if (groupwise & IW_AUTH_CIPHER_CCMP) 1146 else if (groupwise & RNDIS_WLAN_ALG_CCMP)
1097 encr_mode = NDIS_80211_ENCR_CCMP_ENABLED; 1147 encr_mode = NDIS_80211_ENCR_CCMP_ENABLED;
1098 else if (groupwise & IW_AUTH_CIPHER_TKIP) 1148 else if (groupwise & RNDIS_WLAN_ALG_TKIP)
1099 encr_mode = NDIS_80211_ENCR_TKIP_ENABLED; 1149 encr_mode = NDIS_80211_ENCR_TKIP_ENABLED;
1100 else 1150 else
1101 encr_mode = NDIS_80211_ENCR_DISABLED; 1151 encr_mode = NDIS_80211_ENCR_DISABLED;
@@ -1114,18 +1164,6 @@ static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
1114} 1164}
1115 1165
1116 1166
1117static int set_assoc_params(struct usbnet *usbdev)
1118{
1119 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1120
1121 set_auth_mode(usbdev, priv->wpa_version, priv->wpa_authalg);
1122 set_priv_filter(usbdev);
1123 set_encr_mode(usbdev, priv->wpa_cipher_pair, priv->wpa_cipher_group);
1124
1125 return 0;
1126}
1127
1128
1129static int set_infra_mode(struct usbnet *usbdev, int mode) 1167static int set_infra_mode(struct usbnet *usbdev, int mode)
1130{ 1168{
1131 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1169 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
@@ -1184,16 +1222,11 @@ static int set_frag_threshold(struct usbnet *usbdev, u32 frag_threshold)
1184 1222
1185static void set_default_iw_params(struct usbnet *usbdev) 1223static void set_default_iw_params(struct usbnet *usbdev)
1186{ 1224{
1187 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1188
1189 priv->wpa_keymgmt = 0;
1190 priv->wpa_version = 0;
1191
1192 set_infra_mode(usbdev, NDIS_80211_INFRA_INFRA); 1225 set_infra_mode(usbdev, NDIS_80211_INFRA_INFRA);
1193 set_auth_mode(usbdev, IW_AUTH_WPA_VERSION_DISABLED, 1226 set_auth_mode(usbdev, 0, NL80211_AUTHTYPE_OPEN_SYSTEM,
1194 IW_AUTH_ALG_OPEN_SYSTEM); 1227 RNDIS_WLAN_KEY_MGMT_NONE);
1195 set_priv_filter(usbdev); 1228 set_priv_filter(usbdev);
1196 set_encr_mode(usbdev, IW_AUTH_CIPHER_NONE, IW_AUTH_CIPHER_NONE); 1229 set_encr_mode(usbdev, RNDIS_WLAN_ALG_NONE, RNDIS_WLAN_ALG_NONE);
1197} 1230}
1198 1231
1199 1232
@@ -1207,14 +1240,49 @@ static int deauthenticate(struct usbnet *usbdev)
1207} 1240}
1208 1241
1209 1242
1243static int set_channel(struct usbnet *usbdev, int channel)
1244{
1245 struct ndis_80211_conf config;
1246 unsigned int dsconfig;
1247 int len, ret;
1248
1249 devdbg(usbdev, "set_channel(%d)", channel);
1250
1251 /* this OID is valid only when not associated */
1252 if (is_associated(usbdev))
1253 return 0;
1254
1255 dsconfig = ieee80211_dsss_chan_to_freq(channel) * 1000;
1256
1257 len = sizeof(config);
1258 ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len);
1259 if (ret < 0) {
1260 devdbg(usbdev, "set_channel: querying configuration failed");
1261 return ret;
1262 }
1263
1264 config.ds_config = cpu_to_le32(dsconfig);
1265 ret = rndis_set_oid(usbdev, OID_802_11_CONFIGURATION, &config,
1266 sizeof(config));
1267
1268 devdbg(usbdev, "set_channel: %d -> %d", channel, ret);
1269
1270 return ret;
1271}
1272
1273
1210/* index must be 0 - N, as per NDIS */ 1274/* index must be 0 - N, as per NDIS */
1211static int add_wep_key(struct usbnet *usbdev, char *key, int key_len, int index) 1275static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len,
1276 int index)
1212{ 1277{
1213 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1278 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1214 struct ndis_80211_wep_key ndis_key; 1279 struct ndis_80211_wep_key ndis_key;
1215 int cipher, ret; 1280 u32 cipher;
1281 int ret;
1216 1282
1217 if ((key_len != 5 || key_len != 13) || index < 0 || index > 3) 1283 devdbg(usbdev, "add_wep_key(idx: %d, len: %d)", index, key_len);
1284
1285 if ((key_len != 5 && key_len != 13) || index < 0 || index > 3)
1218 return -EINVAL; 1286 return -EINVAL;
1219 1287
1220 if (key_len == 5) 1288 if (key_len == 5)
@@ -1231,8 +1299,8 @@ static int add_wep_key(struct usbnet *usbdev, char *key, int key_len, int index)
1231 1299
1232 if (index == priv->encr_tx_key_index) { 1300 if (index == priv->encr_tx_key_index) {
1233 ndis_key.index |= NDIS_80211_ADDWEP_TRANSMIT_KEY; 1301 ndis_key.index |= NDIS_80211_ADDWEP_TRANSMIT_KEY;
1234 ret = set_encr_mode(usbdev, IW_AUTH_CIPHER_WEP104, 1302 ret = set_encr_mode(usbdev, RNDIS_WLAN_ALG_WEP,
1235 IW_AUTH_CIPHER_NONE); 1303 RNDIS_WLAN_ALG_NONE);
1236 if (ret) 1304 if (ret)
1237 devwarn(usbdev, "encryption couldn't be enabled (%08X)", 1305 devwarn(usbdev, "encryption couldn't be enabled (%08X)",
1238 ret); 1306 ret);
@@ -1256,8 +1324,8 @@ static int add_wep_key(struct usbnet *usbdev, char *key, int key_len, int index)
1256 1324
1257 1325
1258static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len, 1326static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
1259 int index, const u8 *addr, const u8 *rx_seq, int cipher, 1327 int index, const u8 *addr, const u8 *rx_seq,
1260 int flags) 1328 int seq_len, u32 cipher, int flags)
1261{ 1329{
1262 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1330 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1263 struct ndis_80211_key ndis_key; 1331 struct ndis_80211_key ndis_key;
@@ -1273,12 +1341,20 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
1273 key_len); 1341 key_len);
1274 return -EINVAL; 1342 return -EINVAL;
1275 } 1343 }
1276 if ((flags & NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ) && !rx_seq) { 1344 if (flags & NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ) {
1277 devdbg(usbdev, "add_wpa_key: recv seq flag without buffer"); 1345 if (!rx_seq || seq_len <= 0) {
1278 return -EINVAL; 1346 devdbg(usbdev, "add_wpa_key: recv seq flag without"
1347 "buffer");
1348 return -EINVAL;
1349 }
1350 if (rx_seq && seq_len > sizeof(ndis_key.rsc)) {
1351 devdbg(usbdev, "add_wpa_key: too big recv seq buffer");
1352 return -EINVAL;
1353 }
1279 } 1354 }
1280 is_addr_ok = addr && memcmp(addr, zero_bssid, ETH_ALEN) != 0 && 1355
1281 memcmp(addr, ffff_bssid, ETH_ALEN) != 0; 1356 is_addr_ok = addr && !is_zero_ether_addr(addr) &&
1357 !is_broadcast_ether_addr(addr);
1282 if ((flags & NDIS_80211_ADDKEY_PAIRWISE_KEY) && !is_addr_ok) { 1358 if ((flags & NDIS_80211_ADDKEY_PAIRWISE_KEY) && !is_addr_ok) {
1283 devdbg(usbdev, "add_wpa_key: pairwise but bssid invalid (%pM)", 1359 devdbg(usbdev, "add_wpa_key: pairwise but bssid invalid (%pM)",
1284 addr); 1360 addr);
@@ -1307,7 +1383,7 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len,
1307 memcpy(ndis_key.material, key, key_len); 1383 memcpy(ndis_key.material, key, key_len);
1308 1384
1309 if (flags & NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ) 1385 if (flags & NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ)
1310 memcpy(ndis_key.rsc, rx_seq, 6); 1386 memcpy(ndis_key.rsc, rx_seq, seq_len);
1311 1387
1312 if (flags & NDIS_80211_ADDKEY_PAIRWISE_KEY) { 1388 if (flags & NDIS_80211_ADDKEY_PAIRWISE_KEY) {
1313 /* pairwise key */ 1389 /* pairwise key */
@@ -1346,31 +1422,17 @@ static int restore_key(struct usbnet *usbdev, int key_idx)
1346{ 1422{
1347 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1423 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1348 struct rndis_wlan_encr_key key; 1424 struct rndis_wlan_encr_key key;
1349 int flags; 1425
1426 if (is_wpa_key(priv, key_idx))
1427 return 0;
1350 1428
1351 key = priv->encr_keys[key_idx]; 1429 key = priv->encr_keys[key_idx];
1352 1430
1353 devdbg(usbdev, "restore_key: %i:%s:%i", key_idx, 1431 devdbg(usbdev, "restore_key: %i:%i", key_idx, key.len);
1354 is_wpa_key(priv, key_idx) ? "wpa" : "wep",
1355 key.len);
1356 1432
1357 if (key.len == 0) 1433 if (key.len == 0)
1358 return 0; 1434 return 0;
1359 1435
1360 if (is_wpa_key(priv, key_idx)) {
1361 flags = 0;
1362
1363 /*if (priv->encr_tx_key_index == key_idx)
1364 flags |= NDIS_80211_ADDKEY_TRANSMIT_KEY;*/
1365
1366 if (memcmp(key.bssid, zero_bssid, ETH_ALEN) != 0 &&
1367 memcmp(key.bssid, ffff_bssid, ETH_ALEN) != 0)
1368 flags |= NDIS_80211_ADDKEY_PAIRWISE_KEY;
1369
1370 return add_wpa_key(usbdev, key.material, key.len, key_idx,
1371 key.bssid, NULL, key.cipher, flags);
1372 }
1373
1374 return add_wep_key(usbdev, key.material, key.len, key_idx); 1436 return add_wep_key(usbdev, key.material, key.len, key_idx);
1375} 1437}
1376 1438
@@ -1391,7 +1453,7 @@ static void clear_key(struct rndis_wlan_private *priv, int idx)
1391 1453
1392 1454
1393/* remove_key is for both wep and wpa */ 1455/* remove_key is for both wep and wpa */
1394static int remove_key(struct usbnet *usbdev, int index, u8 bssid[ETH_ALEN]) 1456static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid)
1395{ 1457{
1396 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1458 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1397 struct ndis_80211_remove_key remove_key; 1459 struct ndis_80211_remove_key remove_key;
@@ -1414,7 +1476,7 @@ static int remove_key(struct usbnet *usbdev, int index, u8 bssid[ETH_ALEN])
1414 remove_key.index = cpu_to_le32(index); 1476 remove_key.index = cpu_to_le32(index);
1415 if (bssid) { 1477 if (bssid) {
1416 /* pairwise key */ 1478 /* pairwise key */
1417 if (memcmp(bssid, ffff_bssid, ETH_ALEN) != 0) 1479 if (!is_broadcast_ether_addr(bssid))
1418 remove_key.index |= 1480 remove_key.index |=
1419 NDIS_80211_ADDKEY_PAIRWISE_KEY; 1481 NDIS_80211_ADDKEY_PAIRWISE_KEY;
1420 memcpy(remove_key.bssid, bssid, 1482 memcpy(remove_key.bssid, bssid,
@@ -1441,7 +1503,7 @@ static int remove_key(struct usbnet *usbdev, int index, u8 bssid[ETH_ALEN])
1441 1503
1442 /* if it is transmit key, disable encryption */ 1504 /* if it is transmit key, disable encryption */
1443 if (index == priv->encr_tx_key_index) 1505 if (index == priv->encr_tx_key_index)
1444 set_encr_mode(usbdev, IW_AUTH_CIPHER_NONE, IW_AUTH_CIPHER_NONE); 1506 set_encr_mode(usbdev, RNDIS_WLAN_ALG_NONE, RNDIS_WLAN_ALG_NONE);
1445 1507
1446 return 0; 1508 return 0;
1447} 1509}
@@ -1515,7 +1577,8 @@ static int rndis_change_virtual_intf(struct wiphy *wiphy,
1515 enum nl80211_iftype type, u32 *flags, 1577 enum nl80211_iftype type, u32 *flags,
1516 struct vif_params *params) 1578 struct vif_params *params)
1517{ 1579{
1518 struct usbnet *usbdev = netdev_priv(dev); 1580 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
1581 struct usbnet *usbdev = priv->usbdev;
1519 int mode; 1582 int mode;
1520 1583
1521 switch (type) { 1584 switch (type) {
@@ -1529,6 +1592,8 @@ static int rndis_change_virtual_intf(struct wiphy *wiphy,
1529 return -EINVAL; 1592 return -EINVAL;
1530 } 1593 }
1531 1594
1595 priv->wdev.iftype = type;
1596
1532 return set_infra_mode(usbdev, mode); 1597 return set_infra_mode(usbdev, mode);
1533} 1598}
1534 1599
@@ -1591,7 +1656,7 @@ static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm)
1591} 1656}
1592 1657
1593 1658
1594#define SCAN_DELAY_JIFFIES (HZ) 1659#define SCAN_DELAY_JIFFIES (6 * HZ)
1595static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, 1660static int rndis_scan(struct wiphy *wiphy, struct net_device *dev,
1596 struct cfg80211_scan_request *request) 1661 struct cfg80211_scan_request *request)
1597{ 1662{
@@ -1602,6 +1667,11 @@ static int rndis_scan(struct wiphy *wiphy, struct net_device *dev,
1602 1667
1603 devdbg(usbdev, "cfg80211.scan"); 1668 devdbg(usbdev, "cfg80211.scan");
1604 1669
1670 /* Get current bssid list from device before new scan, as new scan
1671 * clears internal bssid list.
1672 */
1673 rndis_check_bssid_list(usbdev);
1674
1605 if (!request) 1675 if (!request)
1606 return -EINVAL; 1676 return -EINVAL;
1607 1677
@@ -1636,6 +1706,9 @@ static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev,
1636 int ie_len, bssid_len; 1706 int ie_len, bssid_len;
1637 u8 *ie; 1707 u8 *ie;
1638 1708
1709 devdbg(usbdev, " found bssid: '%.32s' [%pM]", bssid->ssid.essid,
1710 bssid->mac);
1711
1639 /* parse bssid structure */ 1712 /* parse bssid structure */
1640 bssid_len = le32_to_cpu(bssid->length); 1713 bssid_len = le32_to_cpu(bssid->length);
1641 1714
@@ -1675,10 +1748,12 @@ static int rndis_check_bssid_list(struct usbnet *usbdev)
1675 struct ndis_80211_bssid_list_ex *bssid_list; 1748 struct ndis_80211_bssid_list_ex *bssid_list;
1676 struct ndis_80211_bssid_ex *bssid; 1749 struct ndis_80211_bssid_ex *bssid;
1677 int ret = -EINVAL, len, count, bssid_len; 1750 int ret = -EINVAL, len, count, bssid_len;
1751 bool resized = false;
1678 1752
1679 devdbg(usbdev, "check_bssid_list"); 1753 devdbg(usbdev, "check_bssid_list");
1680 1754
1681 len = CONTROL_BUFFER_SIZE; 1755 len = CONTROL_BUFFER_SIZE;
1756resize_buf:
1682 buf = kmalloc(len, GFP_KERNEL); 1757 buf = kmalloc(len, GFP_KERNEL);
1683 if (!buf) { 1758 if (!buf) {
1684 ret = -ENOMEM; 1759 ret = -ENOMEM;
@@ -1689,11 +1764,18 @@ static int rndis_check_bssid_list(struct usbnet *usbdev)
1689 if (ret != 0) 1764 if (ret != 0)
1690 goto out; 1765 goto out;
1691 1766
1767 if (!resized && len > CONTROL_BUFFER_SIZE) {
1768 resized = true;
1769 kfree(buf);
1770 goto resize_buf;
1771 }
1772
1692 bssid_list = buf; 1773 bssid_list = buf;
1693 bssid = bssid_list->bssid; 1774 bssid = bssid_list->bssid;
1694 bssid_len = le32_to_cpu(bssid->length); 1775 bssid_len = le32_to_cpu(bssid->length);
1695 count = le32_to_cpu(bssid_list->num_items); 1776 count = le32_to_cpu(bssid_list->num_items);
1696 devdbg(usbdev, "check_bssid_list: %d BSSIDs found", count); 1777 devdbg(usbdev, "check_bssid_list: %d BSSIDs found (buflen: %d)", count,
1778 len);
1697 1779
1698 while (count && ((void *)bssid + bssid_len) <= (buf + len)) { 1780 while (count && ((void *)bssid + bssid_len) <= (buf + len)) {
1699 rndis_bss_info_update(usbdev, bssid); 1781 rndis_bss_info_update(usbdev, bssid);
@@ -1728,625 +1810,472 @@ static void rndis_get_scan_results(struct work_struct *work)
1728 priv->scan_request = NULL; 1810 priv->scan_request = NULL;
1729} 1811}
1730 1812
1731 1813static int rndis_connect(struct wiphy *wiphy, struct net_device *dev,
1732/* 1814 struct cfg80211_connect_params *sme)
1733 * wireless extension handlers
1734 */
1735
1736static int rndis_iw_commit(struct net_device *dev,
1737 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1738{
1739 /* dummy op */
1740 return 0;
1741}
1742
1743
1744static int rndis_iw_set_essid(struct net_device *dev,
1745 struct iw_request_info *info, union iwreq_data *wrqu, char *essid)
1746{ 1815{
1816 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
1817 struct usbnet *usbdev = priv->usbdev;
1818 struct ieee80211_channel *channel = sme->channel;
1747 struct ndis_80211_ssid ssid; 1819 struct ndis_80211_ssid ssid;
1748 int length = wrqu->essid.length; 1820 int pairwise = RNDIS_WLAN_ALG_NONE;
1749 struct usbnet *usbdev = netdev_priv(dev); 1821 int groupwise = RNDIS_WLAN_ALG_NONE;
1822 int keymgmt = RNDIS_WLAN_KEY_MGMT_NONE;
1823 int length, i, ret, chan = -1;
1750 1824
1751 devdbg(usbdev, "SIOCSIWESSID: [flags:%d,len:%d] '%.32s'", 1825 if (channel)
1752 wrqu->essid.flags, wrqu->essid.length, essid); 1826 chan = ieee80211_frequency_to_channel(channel->center_freq);
1753 1827
1754 if (length > NDIS_802_11_LENGTH_SSID) 1828 groupwise = rndis_cipher_to_alg(sme->crypto.cipher_group);
1755 length = NDIS_802_11_LENGTH_SSID; 1829 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
1756 1830 pairwise |=
1757 ssid.length = cpu_to_le32(length); 1831 rndis_cipher_to_alg(sme->crypto.ciphers_pairwise[i]);
1758 if (length > 0)
1759 memcpy(ssid.essid, essid, length);
1760 else
1761 memset(ssid.essid, 0, NDIS_802_11_LENGTH_SSID);
1762 1832
1763 set_assoc_params(usbdev); 1833 if (sme->crypto.n_ciphers_pairwise > 0 &&
1834 pairwise == RNDIS_WLAN_ALG_NONE) {
1835 deverr(usbdev, "Unsupported pairwise cipher");
1836 return -ENOTSUPP;
1837 }
1764 1838
1765 if (!wrqu->essid.flags || length == 0) 1839 for (i = 0; i < sme->crypto.n_akm_suites; i++)
1766 return disassociate(usbdev, 1); 1840 keymgmt |=
1767 else { 1841 rndis_akm_suite_to_key_mgmt(sme->crypto.akm_suites[i]);
1768 /* Pause and purge rx queue, so we don't pass packets before
1769 * 'media connect'-indication.
1770 */
1771 usbnet_pause_rx(usbdev);
1772 usbnet_purge_paused_rxq(usbdev);
1773 1842
1774 return set_essid(usbdev, &ssid); 1843 if (sme->crypto.n_akm_suites > 0 &&
1844 keymgmt == RNDIS_WLAN_KEY_MGMT_NONE) {
1845 deverr(usbdev, "Invalid keymgmt");
1846 return -ENOTSUPP;
1775 } 1847 }
1776}
1777 1848
1849 devdbg(usbdev, "cfg80211.connect('%.32s':[%pM]:%d:[%d,0x%x:0x%x]:[0x%x:"
1850 "0x%x]:0x%x)", sme->ssid, sme->bssid, chan,
1851 sme->privacy, sme->crypto.wpa_versions, sme->auth_type,
1852 groupwise, pairwise, keymgmt);
1778 1853
1779static int rndis_iw_get_essid(struct net_device *dev, 1854 if (is_associated(usbdev))
1780 struct iw_request_info *info, union iwreq_data *wrqu, char *essid) 1855 disassociate(usbdev, false);
1781{
1782 struct ndis_80211_ssid ssid;
1783 struct usbnet *usbdev = netdev_priv(dev);
1784 int ret;
1785
1786 ret = get_essid(usbdev, &ssid);
1787 1856
1788 if (ret == 0 && le32_to_cpu(ssid.length) > 0) { 1857 ret = set_infra_mode(usbdev, NDIS_80211_INFRA_INFRA);
1789 wrqu->essid.flags = 1; 1858 if (ret < 0) {
1790 wrqu->essid.length = le32_to_cpu(ssid.length); 1859 devdbg(usbdev, "connect: set_infra_mode failed, %d", ret);
1791 memcpy(essid, ssid.essid, wrqu->essid.length); 1860 goto err_turn_radio_on;
1792 essid[wrqu->essid.length] = 0;
1793 } else {
1794 memset(essid, 0, sizeof(NDIS_802_11_LENGTH_SSID));
1795 wrqu->essid.flags = 0;
1796 wrqu->essid.length = 0;
1797 } 1861 }
1798 devdbg(usbdev, "SIOCGIWESSID: %s", essid);
1799 return ret;
1800}
1801 1862
1863 ret = set_auth_mode(usbdev, sme->crypto.wpa_versions, sme->auth_type,
1864 keymgmt);
1865 if (ret < 0) {
1866 devdbg(usbdev, "connect: set_auth_mode failed, %d", ret);
1867 goto err_turn_radio_on;
1868 }
1802 1869
1803static int rndis_iw_get_bssid(struct net_device *dev, 1870 set_priv_filter(usbdev);
1804 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1805{
1806 struct usbnet *usbdev = netdev_priv(dev);
1807 unsigned char bssid[ETH_ALEN];
1808 int ret;
1809 1871
1810 ret = get_bssid(usbdev, bssid); 1872 ret = set_encr_mode(usbdev, pairwise, groupwise);
1873 if (ret < 0) {
1874 devdbg(usbdev, "connect: set_encr_mode failed, %d", ret);
1875 goto err_turn_radio_on;
1876 }
1811 1877
1812 if (ret == 0) 1878 if (channel) {
1813 devdbg(usbdev, "SIOCGIWAP: %pM", bssid); 1879 ret = set_channel(usbdev, chan);
1814 else 1880 if (ret < 0) {
1815 devdbg(usbdev, "SIOCGIWAP: <not associated>"); 1881 devdbg(usbdev, "connect: set_channel failed, %d", ret);
1882 goto err_turn_radio_on;
1883 }
1884 }
1816 1885
1817 wrqu->ap_addr.sa_family = ARPHRD_ETHER; 1886 if (sme->key && ((groupwise | pairwise) & RNDIS_WLAN_ALG_WEP)) {
1818 memcpy(wrqu->ap_addr.sa_data, bssid, ETH_ALEN); 1887 priv->encr_tx_key_index = sme->key_idx;
1888 ret = add_wep_key(usbdev, sme->key, sme->key_len, sme->key_idx);
1889 if (ret < 0) {
1890 devdbg(usbdev, "connect: add_wep_key failed, %d "
1891 "(%d, %d)", ret, sme->key_len, sme->key_idx);
1892 goto err_turn_radio_on;
1893 }
1894 }
1819 1895
1820 return ret; 1896 if (sme->bssid && !is_zero_ether_addr(sme->bssid) &&
1821} 1897 !is_broadcast_ether_addr(sme->bssid)) {
1898 ret = set_bssid(usbdev, sme->bssid);
1899 if (ret < 0) {
1900 devdbg(usbdev, "connect: set_bssid failed, %d", ret);
1901 goto err_turn_radio_on;
1902 }
1903 } else
1904 clear_bssid(usbdev);
1822 1905
1906 length = sme->ssid_len;
1907 if (length > NDIS_802_11_LENGTH_SSID)
1908 length = NDIS_802_11_LENGTH_SSID;
1823 1909
1824static int rndis_iw_set_bssid(struct net_device *dev, 1910 memset(&ssid, 0, sizeof(ssid));
1825 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1911 ssid.length = cpu_to_le32(length);
1826{ 1912 memcpy(ssid.essid, sme->ssid, length);
1827 struct usbnet *usbdev = netdev_priv(dev);
1828 u8 *bssid = (u8 *)wrqu->ap_addr.sa_data;
1829 int ret;
1830 1913
1831 devdbg(usbdev, "SIOCSIWAP: %pM", bssid); 1914 /* Pause and purge rx queue, so we don't pass packets before
1915 * 'media connect'-indication.
1916 */
1917 usbnet_pause_rx(usbdev);
1918 usbnet_purge_paused_rxq(usbdev);
1832 1919
1833 ret = rndis_set_oid(usbdev, OID_802_11_BSSID, bssid, ETH_ALEN); 1920 ret = set_essid(usbdev, &ssid);
1921 if (ret < 0)
1922 devdbg(usbdev, "connect: set_essid failed, %d", ret);
1923 return ret;
1834 1924
1835 /* user apps may set ap's mac address, which is not required; 1925err_turn_radio_on:
1836 * they may fail to work if this function fails, so return 1926 disassociate(usbdev, 1);
1837 * success */
1838 if (ret)
1839 devwarn(usbdev, "setting AP mac address failed (%08X)", ret);
1840 1927
1841 return 0; 1928 return ret;
1842} 1929}
1843 1930
1844 1931static int rndis_disconnect(struct wiphy *wiphy, struct net_device *dev,
1845static int rndis_iw_set_auth(struct net_device *dev, 1932 u16 reason_code)
1846 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1847{ 1933{
1848 struct iw_param *p = &wrqu->param; 1934 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
1849 struct usbnet *usbdev = netdev_priv(dev); 1935 struct usbnet *usbdev = priv->usbdev;
1850 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1851 int ret = -ENOTSUPP;
1852
1853 switch (p->flags & IW_AUTH_INDEX) {
1854 case IW_AUTH_WPA_VERSION:
1855 devdbg(usbdev, "SIOCSIWAUTH: WPA_VERSION, %08x", p->value);
1856 priv->wpa_version = p->value;
1857 ret = 0;
1858 break;
1859
1860 case IW_AUTH_CIPHER_PAIRWISE:
1861 devdbg(usbdev, "SIOCSIWAUTH: CIPHER_PAIRWISE, %08x", p->value);
1862 priv->wpa_cipher_pair = p->value;
1863 ret = 0;
1864 break;
1865
1866 case IW_AUTH_CIPHER_GROUP:
1867 devdbg(usbdev, "SIOCSIWAUTH: CIPHER_GROUP, %08x", p->value);
1868 priv->wpa_cipher_group = p->value;
1869 ret = 0;
1870 break;
1871
1872 case IW_AUTH_KEY_MGMT:
1873 devdbg(usbdev, "SIOCSIWAUTH: KEY_MGMT, %08x", p->value);
1874 priv->wpa_keymgmt = p->value;
1875 ret = 0;
1876 break;
1877
1878 case IW_AUTH_TKIP_COUNTERMEASURES:
1879 devdbg(usbdev, "SIOCSIWAUTH: TKIP_COUNTERMEASURES, %08x",
1880 p->value);
1881 ret = 0;
1882 break;
1883
1884 case IW_AUTH_DROP_UNENCRYPTED:
1885 devdbg(usbdev, "SIOCSIWAUTH: DROP_UNENCRYPTED, %08x", p->value);
1886 ret = 0;
1887 break;
1888
1889 case IW_AUTH_80211_AUTH_ALG:
1890 devdbg(usbdev, "SIOCSIWAUTH: 80211_AUTH_ALG, %08x", p->value);
1891 priv->wpa_authalg = p->value;
1892 ret = 0;
1893 break;
1894
1895 case IW_AUTH_WPA_ENABLED:
1896 devdbg(usbdev, "SIOCSIWAUTH: WPA_ENABLED, %08x", p->value);
1897 if (wrqu->param.value)
1898 deauthenticate(usbdev);
1899 ret = 0;
1900 break;
1901
1902 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1903 devdbg(usbdev, "SIOCSIWAUTH: RX_UNENCRYPTED_EAPOL, %08x",
1904 p->value);
1905 ret = 0;
1906 break;
1907 1936
1908 case IW_AUTH_ROAMING_CONTROL: 1937 devdbg(usbdev, "cfg80211.disconnect(%d)", reason_code);
1909 devdbg(usbdev, "SIOCSIWAUTH: ROAMING_CONTROL, %08x", p->value);
1910 ret = 0;
1911 break;
1912 1938
1913 case IW_AUTH_PRIVACY_INVOKED: 1939 priv->connected = false;
1914 devdbg(usbdev, "SIOCSIWAUTH: invalid cmd %d", 1940 memset(priv->bssid, 0, ETH_ALEN);
1915 wrqu->param.flags & IW_AUTH_INDEX);
1916 return -EOPNOTSUPP;
1917 1941
1918 default: 1942 return deauthenticate(usbdev);
1919 devdbg(usbdev, "SIOCSIWAUTH: UNKNOWN %08x, %08x",
1920 p->flags & IW_AUTH_INDEX, p->value);
1921 }
1922 return ret;
1923} 1943}
1924 1944
1925 1945static int rndis_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1926static int rndis_iw_get_auth(struct net_device *dev, 1946 struct cfg80211_ibss_params *params)
1927 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1928{ 1947{
1929 struct iw_param *p = &wrqu->param; 1948 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
1930 struct usbnet *usbdev = netdev_priv(dev); 1949 struct usbnet *usbdev = priv->usbdev;
1931 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1950 struct ieee80211_channel *channel = params->channel;
1932 1951 struct ndis_80211_ssid ssid;
1933 switch (p->flags & IW_AUTH_INDEX) { 1952 enum nl80211_auth_type auth_type;
1934 case IW_AUTH_WPA_VERSION: 1953 int ret, alg, length, chan = -1;
1935 p->value = priv->wpa_version;
1936 break;
1937 case IW_AUTH_CIPHER_PAIRWISE:
1938 p->value = priv->wpa_cipher_pair;
1939 break;
1940 case IW_AUTH_CIPHER_GROUP:
1941 p->value = priv->wpa_cipher_group;
1942 break;
1943 case IW_AUTH_KEY_MGMT:
1944 p->value = priv->wpa_keymgmt;
1945 break;
1946 case IW_AUTH_80211_AUTH_ALG:
1947 p->value = priv->wpa_authalg;
1948 break;
1949 default:
1950 devdbg(usbdev, "SIOCGIWAUTH: invalid cmd %d",
1951 wrqu->param.flags & IW_AUTH_INDEX);
1952 return -EOPNOTSUPP;
1953 }
1954 return 0;
1955}
1956 1954
1955 if (channel)
1956 chan = ieee80211_frequency_to_channel(channel->center_freq);
1957 1957
1958static int rndis_iw_set_encode(struct net_device *dev, 1958 /* TODO: How to handle ad-hoc encryption?
1959 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1959 * connect() has *key, join_ibss() doesn't. RNDIS requires key to be
1960{ 1960 * pre-shared for encryption (open/shared/wpa), is key set before
1961 struct usbnet *usbdev = netdev_priv(dev); 1961 * join_ibss? Which auth_type to use (not in params)? What about WPA?
1962 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1962 */
1963 struct rndis_wlan_encr_key key; 1963 if (params->privacy) {
1964 int ret, index, key_len; 1964 auth_type = NL80211_AUTHTYPE_SHARED_KEY;
1965 u8 *keybuf; 1965 alg = RNDIS_WLAN_ALG_WEP;
1966 } else {
1967 auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
1968 alg = RNDIS_WLAN_ALG_NONE;
1969 }
1966 1970
1967 index = (wrqu->encoding.flags & IW_ENCODE_INDEX); 1971 devdbg(usbdev, "cfg80211.join_ibss('%.32s':[%pM]:%d:%d)", params->ssid,
1972 params->bssid, chan, params->privacy);
1968 1973
1969 /* iwconfig gives index as 1 - N */ 1974 if (is_associated(usbdev))
1970 if (index > 0) 1975 disassociate(usbdev, false);
1971 index--;
1972 else
1973 index = priv->encr_tx_key_index;
1974 1976
1975 if (index < 0 || index >= 4) { 1977 ret = set_infra_mode(usbdev, NDIS_80211_INFRA_ADHOC);
1976 devwarn(usbdev, "encryption index out of range (%u)", index); 1978 if (ret < 0) {
1977 return -EINVAL; 1979 devdbg(usbdev, "join_ibss: set_infra_mode failed, %d", ret);
1980 goto err_turn_radio_on;
1978 } 1981 }
1979 1982
1980 /* remove key if disabled */ 1983 ret = set_auth_mode(usbdev, 0, auth_type, RNDIS_WLAN_KEY_MGMT_NONE);
1981 if (wrqu->data.flags & IW_ENCODE_DISABLED) { 1984 if (ret < 0) {
1982 if (remove_key(usbdev, index, NULL)) 1985 devdbg(usbdev, "join_ibss: set_auth_mode failed, %d", ret);
1983 return -EINVAL; 1986 goto err_turn_radio_on;
1984 else
1985 return 0;
1986 } 1987 }
1987 1988
1988 /* global encryption state (for all keys) */ 1989 set_priv_filter(usbdev);
1989 if (wrqu->data.flags & IW_ENCODE_OPEN)
1990 ret = set_auth_mode(usbdev, IW_AUTH_WPA_VERSION_DISABLED,
1991 IW_AUTH_ALG_OPEN_SYSTEM);
1992 else /*if (wrqu->data.flags & IW_ENCODE_RESTRICTED)*/
1993 ret = set_auth_mode(usbdev, IW_AUTH_WPA_VERSION_DISABLED,
1994 IW_AUTH_ALG_SHARED_KEY);
1995 if (ret != 0)
1996 return ret;
1997 1990
1998 if (wrqu->data.length > 0) { 1991 ret = set_encr_mode(usbdev, alg, RNDIS_WLAN_ALG_NONE);
1999 key_len = wrqu->data.length; 1992 if (ret < 0) {
2000 keybuf = extra; 1993 devdbg(usbdev, "join_ibss: set_encr_mode failed, %d", ret);
2001 } else { 1994 goto err_turn_radio_on;
2002 /* must be set as tx key */
2003 if (priv->encr_keys[index].len == 0)
2004 return -EINVAL;
2005 key = priv->encr_keys[index];
2006 key_len = key.len;
2007 keybuf = key.material;
2008 priv->encr_tx_key_index = index;
2009 } 1995 }
2010 1996
2011 if (add_wep_key(usbdev, keybuf, key_len, index) != 0) 1997 if (channel) {
2012 return -EINVAL; 1998 ret = set_channel(usbdev, chan);
2013 1999 if (ret < 0) {
2014 if (index == priv->encr_tx_key_index) 2000 devdbg(usbdev, "join_ibss: set_channel failed, %d",
2015 /* ndis drivers want essid to be set after setting encr */ 2001 ret);
2016 set_essid(usbdev, &priv->essid); 2002 goto err_turn_radio_on;
2017 2003 }
2018 return 0; 2004 }
2019}
2020 2005
2006 if (params->bssid && !is_zero_ether_addr(params->bssid) &&
2007 !is_broadcast_ether_addr(params->bssid)) {
2008 ret = set_bssid(usbdev, params->bssid);
2009 if (ret < 0) {
2010 devdbg(usbdev, "join_ibss: set_bssid failed, %d", ret);
2011 goto err_turn_radio_on;
2012 }
2013 } else
2014 clear_bssid(usbdev);
2021 2015
2022static int rndis_iw_set_encode_ext(struct net_device *dev, 2016 length = params->ssid_len;
2023 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2017 if (length > NDIS_802_11_LENGTH_SSID)
2024{ 2018 length = NDIS_802_11_LENGTH_SSID;
2025 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2026 struct usbnet *usbdev = netdev_priv(dev);
2027 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
2028 int keyidx, flags, cipher;
2029 2019
2030 keyidx = wrqu->encoding.flags & IW_ENCODE_INDEX; 2020 memset(&ssid, 0, sizeof(ssid));
2021 ssid.length = cpu_to_le32(length);
2022 memcpy(ssid.essid, params->ssid, length);
2031 2023
2032 /* iwconfig gives index as 1 - N */ 2024 /* Don't need to pause rx queue for ad-hoc. */
2033 if (keyidx) 2025 usbnet_purge_paused_rxq(usbdev);
2034 keyidx--; 2026 usbnet_resume_rx(usbdev);
2035 else
2036 keyidx = priv->encr_tx_key_index;
2037 2027
2038 if (keyidx < 0 || keyidx >= 4) { 2028 ret = set_essid(usbdev, &ssid);
2039 devwarn(usbdev, "encryption index out of range (%u)", keyidx); 2029 if (ret < 0)
2040 return -EINVAL; 2030 devdbg(usbdev, "join_ibss: set_essid failed, %d", ret);
2041 } 2031 return ret;
2042 2032
2043 if (ext->alg == WPA_ALG_WEP) { 2033err_turn_radio_on:
2044 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2034 disassociate(usbdev, 1);
2045 priv->encr_tx_key_index = keyidx;
2046 return add_wep_key(usbdev, ext->key, ext->key_len, keyidx);
2047 }
2048 2035
2049 cipher = -1; 2036 return ret;
2050 if (ext->alg == IW_ENCODE_ALG_TKIP) 2037}
2051 cipher = WLAN_CIPHER_SUITE_TKIP;
2052 else if (ext->alg == IW_ENCODE_ALG_CCMP)
2053 cipher = WLAN_CIPHER_SUITE_CCMP;
2054 2038
2055 if ((wrqu->encoding.flags & IW_ENCODE_DISABLED) || 2039static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2056 ext->alg == IW_ENCODE_ALG_NONE || ext->key_len == 0) 2040{
2057 return remove_key(usbdev, keyidx, NULL); 2041 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2042 struct usbnet *usbdev = priv->usbdev;
2058 2043
2059 if (cipher == -1) 2044 devdbg(usbdev, "cfg80211.leave_ibss()");
2060 return -EOPNOTSUPP;
2061 2045
2062 flags = 0; 2046 priv->connected = false;
2063 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) 2047 memset(priv->bssid, 0, ETH_ALEN);
2064 flags |= NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ;
2065 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY))
2066 flags |= NDIS_80211_ADDKEY_PAIRWISE_KEY;
2067 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2068 flags |= NDIS_80211_ADDKEY_TRANSMIT_KEY;
2069 2048
2070 return add_wpa_key(usbdev, ext->key, ext->key_len, keyidx, 2049 return deauthenticate(usbdev);
2071 (u8 *)&ext->addr.sa_data, ext->rx_seq, cipher,
2072 flags);
2073} 2050}
2074 2051
2075 2052static int rndis_set_channel(struct wiphy *wiphy,
2076static int rndis_iw_set_genie(struct net_device *dev, 2053 struct ieee80211_channel *chan, enum nl80211_channel_type channel_type)
2077 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2078{ 2054{
2079 struct usbnet *usbdev = netdev_priv(dev); 2055 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2080 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 2056 struct usbnet *usbdev = priv->usbdev;
2081 int ret = 0;
2082
2083#ifdef DEBUG
2084 int j;
2085 u8 *gie = extra;
2086 for (j = 0; j < wrqu->data.length; j += 8)
2087 devdbg(usbdev,
2088 "SIOCSIWGENIE %04x - "
2089 "%02x %02x %02x %02x %02x %02x %02x %02x", j,
2090 gie[j + 0], gie[j + 1], gie[j + 2], gie[j + 3],
2091 gie[j + 4], gie[j + 5], gie[j + 6], gie[j + 7]);
2092#endif
2093 /* clear existing IEs */
2094 if (priv->wpa_ie_len) {
2095 kfree(priv->wpa_ie);
2096 priv->wpa_ie_len = 0;
2097 }
2098 2057
2099 /* set new IEs */ 2058 return set_channel(usbdev,
2100 priv->wpa_ie = kmalloc(wrqu->data.length, GFP_KERNEL); 2059 ieee80211_frequency_to_channel(chan->center_freq));
2101 if (priv->wpa_ie) {
2102 priv->wpa_ie_len = wrqu->data.length;
2103 memcpy(priv->wpa_ie, extra, priv->wpa_ie_len);
2104 } else
2105 ret = -ENOMEM;
2106 return ret;
2107} 2060}
2108 2061
2109 2062static int rndis_add_key(struct wiphy *wiphy, struct net_device *netdev,
2110static int rndis_iw_get_genie(struct net_device *dev, 2063 u8 key_index, const u8 *mac_addr,
2111 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2064 struct key_params *params)
2112{ 2065{
2113 struct usbnet *usbdev = netdev_priv(dev); 2066 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2114 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 2067 struct usbnet *usbdev = priv->usbdev;
2068 int flags;
2115 2069
2116 devdbg(usbdev, "SIOCGIWGENIE"); 2070 devdbg(usbdev, "rndis_add_key(%i, %pM, %08x)", key_index, mac_addr,
2071 params->cipher);
2117 2072
2118 if (priv->wpa_ie_len == 0 || priv->wpa_ie == NULL) { 2073 switch (params->cipher) {
2119 wrqu->data.length = 0; 2074 case WLAN_CIPHER_SUITE_WEP40:
2120 return 0; 2075 case WLAN_CIPHER_SUITE_WEP104:
2121 } 2076 return add_wep_key(usbdev, params->key, params->key_len,
2122 2077 key_index);
2123 if (wrqu->data.length < priv->wpa_ie_len) 2078 case WLAN_CIPHER_SUITE_TKIP:
2124 return -E2BIG; 2079 case WLAN_CIPHER_SUITE_CCMP:
2080 flags = 0;
2125 2081
2126 wrqu->data.length = priv->wpa_ie_len; 2082 if (params->seq && params->seq_len > 0)
2127 memcpy(extra, priv->wpa_ie, priv->wpa_ie_len); 2083 flags |= NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ;
2084 if (mac_addr)
2085 flags |= NDIS_80211_ADDKEY_PAIRWISE_KEY |
2086 NDIS_80211_ADDKEY_TRANSMIT_KEY;
2128 2087
2129 return 0; 2088 return add_wpa_key(usbdev, params->key, params->key_len,
2089 key_index, mac_addr, params->seq,
2090 params->seq_len, params->cipher, flags);
2091 default:
2092 devdbg(usbdev, "rndis_add_key: unsupported cipher %08x",
2093 params->cipher);
2094 return -ENOTSUPP;
2095 }
2130} 2096}
2131 2097
2132 2098static int rndis_del_key(struct wiphy *wiphy, struct net_device *netdev,
2133static int rndis_iw_set_freq(struct net_device *dev, 2099 u8 key_index, const u8 *mac_addr)
2134 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2135{ 2100{
2136 struct usbnet *usbdev = netdev_priv(dev); 2101 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2137 struct ndis_80211_conf config; 2102 struct usbnet *usbdev = priv->usbdev;
2138 unsigned int dsconfig;
2139 int len, ret;
2140
2141 /* this OID is valid only when not associated */
2142 if (is_associated(usbdev))
2143 return 0;
2144
2145 dsconfig = 0;
2146 if (freq_to_dsconfig(&wrqu->freq, &dsconfig))
2147 return -EINVAL;
2148
2149 len = sizeof(config);
2150 ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len);
2151 if (ret != 0) {
2152 devdbg(usbdev, "SIOCSIWFREQ: querying configuration failed");
2153 return 0;
2154 }
2155 2103
2156 config.ds_config = cpu_to_le32(dsconfig); 2104 devdbg(usbdev, "rndis_del_key(%i, %pM)", key_index, mac_addr);
2157 2105
2158 devdbg(usbdev, "SIOCSIWFREQ: %d * 10^%d", wrqu->freq.m, wrqu->freq.e); 2106 return remove_key(usbdev, key_index, mac_addr);
2159 return rndis_set_oid(usbdev, OID_802_11_CONFIGURATION, &config,
2160 sizeof(config));
2161} 2107}
2162 2108
2163 2109static int rndis_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
2164static int rndis_iw_get_freq(struct net_device *dev, 2110 u8 key_index)
2165 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
2166{ 2111{
2167 struct usbnet *usbdev = netdev_priv(dev); 2112 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2168 struct ndis_80211_conf config; 2113 struct usbnet *usbdev = priv->usbdev;
2169 int len, ret; 2114 struct rndis_wlan_encr_key key;
2170 2115
2171 len = sizeof(config); 2116 devdbg(usbdev, "rndis_set_default_key(%i)", key_index);
2172 ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len);
2173 if (ret == 0)
2174 dsconfig_to_freq(le32_to_cpu(config.ds_config), &wrqu->freq);
2175 2117
2176 devdbg(usbdev, "SIOCGIWFREQ: %d", wrqu->freq.m); 2118 priv->encr_tx_key_index = key_index;
2177 return ret; 2119
2178} 2120 key = priv->encr_keys[key_index];
2179 2121
2122 return add_wep_key(usbdev, key.material, key.len, key_index);
2123}
2180 2124
2181static int rndis_iw_get_rate(struct net_device *dev, 2125static void rndis_fill_station_info(struct usbnet *usbdev,
2182 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2126 struct station_info *sinfo)
2183{ 2127{
2184 struct usbnet *usbdev = netdev_priv(dev); 2128 __le32 linkspeed, rssi;
2185 __le32 tmp;
2186 int ret, len; 2129 int ret, len;
2187 2130
2188 len = sizeof(tmp); 2131 memset(sinfo, 0, sizeof(*sinfo));
2189 ret = rndis_query_oid(usbdev, OID_GEN_LINK_SPEED, &tmp, &len); 2132
2133 len = sizeof(linkspeed);
2134 ret = rndis_query_oid(usbdev, OID_GEN_LINK_SPEED, &linkspeed, &len);
2190 if (ret == 0) { 2135 if (ret == 0) {
2191 wrqu->bitrate.value = le32_to_cpu(tmp) * 100; 2136 sinfo->txrate.legacy = le32_to_cpu(linkspeed) / 1000;
2192 wrqu->bitrate.disabled = 0; 2137 sinfo->filled |= STATION_INFO_TX_BITRATE;
2193 wrqu->bitrate.flags = 1;
2194 } 2138 }
2195 return ret;
2196}
2197 2139
2140 len = sizeof(rssi);
2141 ret = rndis_query_oid(usbdev, OID_802_11_RSSI, &rssi, &len);
2142 if (ret == 0) {
2143 sinfo->signal = level_to_qual(le32_to_cpu(rssi));
2144 sinfo->filled |= STATION_INFO_SIGNAL;
2145 }
2146}
2198 2147
2199static int rndis_iw_set_mlme(struct net_device *dev, 2148static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
2200 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 2149 u8 *mac, struct station_info *sinfo)
2201{ 2150{
2202 struct usbnet *usbdev = netdev_priv(dev); 2151 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2203 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 2152 struct usbnet *usbdev = priv->usbdev;
2204 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2205 unsigned char bssid[ETH_ALEN];
2206 2153
2207 get_bssid(usbdev, bssid); 2154 if (compare_ether_addr(priv->bssid, mac))
2155 return -ENOENT;
2208 2156
2209 if (memcmp(bssid, mlme->addr.sa_data, ETH_ALEN)) 2157 rndis_fill_station_info(usbdev, sinfo);
2210 return -EINVAL;
2211
2212 switch (mlme->cmd) {
2213 case IW_MLME_DEAUTH:
2214 return deauthenticate(usbdev);
2215 case IW_MLME_DISASSOC:
2216 return disassociate(usbdev, priv->radio_on);
2217 default:
2218 return -EOPNOTSUPP;
2219 }
2220 2158
2221 return 0; 2159 return 0;
2222} 2160}
2223 2161
2224 2162static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
2225static struct iw_statistics *rndis_get_wireless_stats(struct net_device *dev) 2163 int idx, u8 *mac, struct station_info *sinfo)
2226{ 2164{
2227 struct usbnet *usbdev = netdev_priv(dev); 2165 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2228 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 2166 struct usbnet *usbdev = priv->usbdev;
2229 unsigned long flags;
2230
2231 spin_lock_irqsave(&priv->stats_lock, flags);
2232 memcpy(&priv->iwstats, &priv->privstats, sizeof(priv->iwstats));
2233 spin_unlock_irqrestore(&priv->stats_lock, flags);
2234
2235 return &priv->iwstats;
2236}
2237
2238
2239#define IW_IOCTL(x) [(x) - SIOCSIWCOMMIT]
2240static const iw_handler rndis_iw_handler[] =
2241{
2242 IW_IOCTL(SIOCSIWCOMMIT) = rndis_iw_commit,
2243 IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname,
2244 IW_IOCTL(SIOCSIWFREQ) = rndis_iw_set_freq,
2245 IW_IOCTL(SIOCGIWFREQ) = rndis_iw_get_freq,
2246 IW_IOCTL(SIOCSIWMODE) = (iw_handler) cfg80211_wext_siwmode,
2247 IW_IOCTL(SIOCGIWMODE) = (iw_handler) cfg80211_wext_giwmode,
2248 IW_IOCTL(SIOCGIWRANGE) = (iw_handler) cfg80211_wext_giwrange,
2249 IW_IOCTL(SIOCSIWAP) = rndis_iw_set_bssid,
2250 IW_IOCTL(SIOCGIWAP) = rndis_iw_get_bssid,
2251 IW_IOCTL(SIOCSIWSCAN) = (iw_handler) cfg80211_wext_siwscan,
2252 IW_IOCTL(SIOCGIWSCAN) = (iw_handler) cfg80211_wext_giwscan,
2253 IW_IOCTL(SIOCSIWESSID) = rndis_iw_set_essid,
2254 IW_IOCTL(SIOCGIWESSID) = rndis_iw_get_essid,
2255 IW_IOCTL(SIOCGIWRATE) = rndis_iw_get_rate,
2256 IW_IOCTL(SIOCSIWRTS) = (iw_handler) cfg80211_wext_siwrts,
2257 IW_IOCTL(SIOCGIWRTS) = (iw_handler) cfg80211_wext_giwrts,
2258 IW_IOCTL(SIOCSIWFRAG) = (iw_handler) cfg80211_wext_siwfrag,
2259 IW_IOCTL(SIOCGIWFRAG) = (iw_handler) cfg80211_wext_giwfrag,
2260 IW_IOCTL(SIOCSIWTXPOW) = (iw_handler) cfg80211_wext_siwtxpower,
2261 IW_IOCTL(SIOCGIWTXPOW) = (iw_handler) cfg80211_wext_giwtxpower,
2262 IW_IOCTL(SIOCSIWENCODE) = rndis_iw_set_encode,
2263 IW_IOCTL(SIOCSIWENCODEEXT) = rndis_iw_set_encode_ext,
2264 IW_IOCTL(SIOCSIWAUTH) = rndis_iw_set_auth,
2265 IW_IOCTL(SIOCGIWAUTH) = rndis_iw_get_auth,
2266 IW_IOCTL(SIOCSIWGENIE) = rndis_iw_set_genie,
2267 IW_IOCTL(SIOCGIWGENIE) = rndis_iw_get_genie,
2268 IW_IOCTL(SIOCSIWMLME) = rndis_iw_set_mlme,
2269};
2270 2167
2271static const iw_handler rndis_wlan_private_handler[] = { 2168 if (idx != 0)
2272}; 2169 return -ENOENT;
2273 2170
2274static const struct iw_priv_args rndis_wlan_private_args[] = { 2171 memcpy(mac, priv->bssid, ETH_ALEN);
2275};
2276 2172
2173 rndis_fill_station_info(usbdev, sinfo);
2277 2174
2278static const struct iw_handler_def rndis_iw_handlers = { 2175 return 0;
2279 .num_standard = ARRAY_SIZE(rndis_iw_handler), 2176}
2280 .num_private = ARRAY_SIZE(rndis_wlan_private_handler),
2281 .num_private_args = ARRAY_SIZE(rndis_wlan_private_args),
2282 .standard = (iw_handler *)rndis_iw_handler,
2283 .private = (iw_handler *)rndis_wlan_private_handler,
2284 .private_args = (struct iw_priv_args *)rndis_wlan_private_args,
2285 .get_wireless_stats = rndis_get_wireless_stats,
2286};
2287 2177
2288 2178
2289static void rndis_wlan_worker(struct work_struct *work) 2179static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
2290{ 2180{
2291 struct rndis_wlan_private *priv = 2181 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
2292 container_of(work, struct rndis_wlan_private, work);
2293 struct usbnet *usbdev = priv->usbdev;
2294 union iwreq_data evt;
2295 unsigned char bssid[ETH_ALEN];
2296 struct ndis_80211_assoc_info *info; 2182 struct ndis_80211_assoc_info *info;
2297 int assoc_size = sizeof(*info) + IW_CUSTOM_MAX + 32; 2183 u8 assoc_buf[sizeof(*info) + IW_CUSTOM_MAX + 32];
2184 u8 bssid[ETH_ALEN];
2185 int resp_ie_len, req_ie_len;
2186 u8 *req_ie, *resp_ie;
2298 int ret, offset; 2187 int ret, offset;
2188 bool roamed = false;
2299 2189
2300 if (test_and_clear_bit(WORK_LINK_UP, &priv->work_pending)) { 2190 if (priv->infra_mode == NDIS_80211_INFRA_INFRA && priv->connected) {
2301 netif_carrier_on(usbdev->net); 2191 /* received media connect indication while connected, either
2192 * device reassociated with same AP or roamed to new. */
2193 roamed = true;
2194 }
2195
2196 req_ie_len = 0;
2197 resp_ie_len = 0;
2198 req_ie = NULL;
2199 resp_ie = NULL;
2302 2200
2303 info = kzalloc(assoc_size, GFP_KERNEL); 2201 if (priv->infra_mode == NDIS_80211_INFRA_INFRA) {
2304 if (!info) 2202 memset(assoc_buf, 0, sizeof(assoc_buf));
2305 goto get_bssid; 2203 info = (void *)assoc_buf;
2306 2204
2307 /* Get association info IEs from device and send them back to 2205 /* Get association info IEs from device and send them back to
2308 * userspace. */ 2206 * userspace. */
2309 ret = get_association_info(usbdev, info, assoc_size); 2207 ret = get_association_info(usbdev, info, sizeof(assoc_buf));
2310 if (!ret) { 2208 if (!ret) {
2311 evt.data.length = le32_to_cpu(info->req_ie_length); 2209 req_ie_len = le32_to_cpu(info->req_ie_length);
2312 if (evt.data.length > 0) { 2210 if (req_ie_len > 0) {
2313 offset = le32_to_cpu(info->offset_req_ies); 2211 offset = le32_to_cpu(info->offset_req_ies);
2314 wireless_send_event(usbdev->net, 2212 req_ie = (u8 *)info + offset;
2315 IWEVASSOCREQIE, &evt,
2316 (char *)info + offset);
2317 } 2213 }
2318 2214
2319 evt.data.length = le32_to_cpu(info->resp_ie_length); 2215 resp_ie_len = le32_to_cpu(info->resp_ie_length);
2320 if (evt.data.length > 0) { 2216 if (resp_ie_len > 0) {
2321 offset = le32_to_cpu(info->offset_resp_ies); 2217 offset = le32_to_cpu(info->offset_resp_ies);
2322 wireless_send_event(usbdev->net, 2218 resp_ie = (u8 *)info + offset;
2323 IWEVASSOCRESPIE, &evt,
2324 (char *)info + offset);
2325 } 2219 }
2326 } 2220 }
2221 } else if (WARN_ON(priv->infra_mode != NDIS_80211_INFRA_ADHOC))
2222 return;
2327 2223
2328 kfree(info); 2224 ret = get_bssid(usbdev, bssid);
2225 if (ret < 0)
2226 memset(bssid, 0, sizeof(bssid));
2329 2227
2330get_bssid: 2228 devdbg(usbdev, "link up work: [%pM] %s", bssid, roamed ? "roamed" : "");
2331 ret = get_bssid(usbdev, bssid);
2332 if (!ret) {
2333 evt.data.flags = 0;
2334 evt.data.length = 0;
2335 memcpy(evt.ap_addr.sa_data, bssid, ETH_ALEN);
2336 wireless_send_event(usbdev->net, SIOCGIWAP, &evt, NULL);
2337 }
2338 2229
2339 usbnet_resume_rx(usbdev); 2230 /* Internal bss list in device always contains at least the currently
2340 } 2231 * connected bss and we can get it to cfg80211 with
2232 * rndis_check_bssid_list().
2233 * NOTE: This is true for Broadcom chip, but not mentioned in RNDIS
2234 * spec.
2235 */
2236 rndis_check_bssid_list(usbdev);
2341 2237
2342 if (test_and_clear_bit(WORK_LINK_DOWN, &priv->work_pending)) { 2238 if (priv->infra_mode == NDIS_80211_INFRA_INFRA) {
2343 netif_carrier_off(usbdev->net); 2239 if (!roamed)
2240 cfg80211_connect_result(usbdev->net, bssid, req_ie,
2241 req_ie_len, resp_ie,
2242 resp_ie_len, 0, GFP_KERNEL);
2243 else
2244 cfg80211_roamed(usbdev->net, bssid, req_ie, req_ie_len,
2245 resp_ie, resp_ie_len, GFP_KERNEL);
2246 } else if (priv->infra_mode == NDIS_80211_INFRA_ADHOC)
2247 cfg80211_ibss_joined(usbdev->net, bssid, GFP_KERNEL);
2344 2248
2345 evt.data.flags = 0; 2249 priv->connected = true;
2346 evt.data.length = 0; 2250 memcpy(priv->bssid, bssid, ETH_ALEN);
2347 memset(evt.ap_addr.sa_data, 0, ETH_ALEN); 2251
2348 wireless_send_event(usbdev->net, SIOCGIWAP, &evt, NULL); 2252 usbnet_resume_rx(usbdev);
2349 } 2253 netif_carrier_on(usbdev->net);
2254}
2255
2256static void rndis_wlan_do_link_down_work(struct usbnet *usbdev)
2257{
2258 union iwreq_data evt;
2259
2260 netif_carrier_off(usbdev->net);
2261
2262 evt.data.flags = 0;
2263 evt.data.length = 0;
2264 memset(evt.ap_addr.sa_data, 0, ETH_ALEN);
2265 wireless_send_event(usbdev->net, SIOCGIWAP, &evt, NULL);
2266}
2267
2268static void rndis_wlan_worker(struct work_struct *work)
2269{
2270 struct rndis_wlan_private *priv =
2271 container_of(work, struct rndis_wlan_private, work);
2272 struct usbnet *usbdev = priv->usbdev;
2273
2274 if (test_and_clear_bit(WORK_LINK_UP, &priv->work_pending))
2275 rndis_wlan_do_link_up_work(usbdev);
2276
2277 if (test_and_clear_bit(WORK_LINK_DOWN, &priv->work_pending))
2278 rndis_wlan_do_link_down_work(usbdev);
2350 2279
2351 if (test_and_clear_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending)) 2280 if (test_and_clear_bit(WORK_SET_MULTICAST_LIST, &priv->work_pending))
2352 set_multicast_list(usbdev); 2281 set_multicast_list(usbdev);
@@ -2371,9 +2300,10 @@ static void rndis_wlan_auth_indication(struct usbnet *usbdev,
2371{ 2300{
2372 u8 *buf; 2301 u8 *buf;
2373 const char *type; 2302 const char *type;
2374 int flags, buflen; 2303 int flags, buflen, key_id;
2375 bool pairwise_error, group_error; 2304 bool pairwise_error, group_error;
2376 struct ndis_80211_auth_request *auth_req; 2305 struct ndis_80211_auth_request *auth_req;
2306 enum nl80211_key_type key_type;
2377 2307
2378 /* must have at least one array entry */ 2308 /* must have at least one array entry */
2379 if (len < offsetof(struct ndis_80211_status_indication, u) + 2309 if (len < offsetof(struct ndis_80211_status_indication, u) +
@@ -2409,23 +2339,24 @@ static void rndis_wlan_auth_indication(struct usbnet *usbdev,
2409 devinfo(usbdev, "authentication indication: %s (0x%08x)", type, 2339 devinfo(usbdev, "authentication indication: %s (0x%08x)", type,
2410 le32_to_cpu(auth_req->flags)); 2340 le32_to_cpu(auth_req->flags));
2411 2341
2412 if (pairwise_error || group_error) { 2342 if (pairwise_error) {
2413 union iwreq_data wrqu; 2343 key_type = NL80211_KEYTYPE_PAIRWISE;
2414 struct iw_michaelmicfailure micfailure; 2344 key_id = -1;
2415 2345
2416 memset(&micfailure, 0, sizeof(micfailure)); 2346 cfg80211_michael_mic_failure(usbdev->net,
2417 if (pairwise_error) 2347 auth_req->bssid,
2418 micfailure.flags |= IW_MICFAILURE_PAIRWISE; 2348 key_type, key_id, NULL,
2419 if (group_error) 2349 GFP_KERNEL);
2420 micfailure.flags |= IW_MICFAILURE_GROUP; 2350 }
2421 2351
2422 memcpy(micfailure.src_addr.sa_data, auth_req->bssid, 2352 if (group_error) {
2423 ETH_ALEN); 2353 key_type = NL80211_KEYTYPE_GROUP;
2354 key_id = -1;
2424 2355
2425 memset(&wrqu, 0, sizeof(wrqu)); 2356 cfg80211_michael_mic_failure(usbdev->net,
2426 wrqu.data.length = sizeof(micfailure); 2357 auth_req->bssid,
2427 wireless_send_event(usbdev->net, IWEVMICHAELMICFAILURE, 2358 key_type, key_id, NULL,
2428 &wrqu, (u8 *)&micfailure); 2359 GFP_KERNEL);
2429 } 2360 }
2430 2361
2431 buflen -= le32_to_cpu(auth_req->length); 2362 buflen -= le32_to_cpu(auth_req->length);
@@ -2470,14 +2401,16 @@ static void rndis_wlan_pmkid_cand_list_indication(struct usbnet *usbdev,
2470 return; 2401 return;
2471 2402
2472 for (i = 0; i < le32_to_cpu(cand_list->num_candidates); i++) { 2403 for (i = 0; i < le32_to_cpu(cand_list->num_candidates); i++) {
2473 struct iw_pmkid_cand pcand;
2474 union iwreq_data wrqu;
2475 struct ndis_80211_pmkid_candidate *cand = 2404 struct ndis_80211_pmkid_candidate *cand =
2476 &cand_list->candidate_list[i]; 2405 &cand_list->candidate_list[i];
2477 2406
2478 devdbg(usbdev, "cand[%i]: flags: 0x%08x, bssid: %pM", 2407 devdbg(usbdev, "cand[%i]: flags: 0x%08x, bssid: %pM",
2479 i, le32_to_cpu(cand->flags), cand->bssid); 2408 i, le32_to_cpu(cand->flags), cand->bssid);
2480 2409
2410#if 0
2411 struct iw_pmkid_cand pcand;
2412 union iwreq_data wrqu;
2413
2481 memset(&pcand, 0, sizeof(pcand)); 2414 memset(&pcand, 0, sizeof(pcand));
2482 if (le32_to_cpu(cand->flags) & 0x01) 2415 if (le32_to_cpu(cand->flags) & 0x01)
2483 pcand.flags |= IW_PMKID_CAND_PREAUTH; 2416 pcand.flags |= IW_PMKID_CAND_PREAUTH;
@@ -2488,6 +2421,7 @@ static void rndis_wlan_pmkid_cand_list_indication(struct usbnet *usbdev,
2488 wrqu.data.length = sizeof(pcand); 2421 wrqu.data.length = sizeof(pcand);
2489 wireless_send_event(usbdev->net, IWEVPMKIDCAND, &wrqu, 2422 wireless_send_event(usbdev->net, IWEVPMKIDCAND, &wrqu,
2490 (u8 *)&pcand); 2423 (u8 *)&pcand);
2424#endif
2491 } 2425 }
2492} 2426}
2493 2427
@@ -2550,6 +2484,17 @@ static void rndis_wlan_indication(struct usbnet *usbdev, void *ind, int buflen)
2550 2484
2551 switch (msg->status) { 2485 switch (msg->status) {
2552 case RNDIS_STATUS_MEDIA_CONNECT: 2486 case RNDIS_STATUS_MEDIA_CONNECT:
2487 if (priv->current_command_oid == OID_802_11_ADD_KEY) {
2488 /* OID_802_11_ADD_KEY causes sometimes extra
2489 * "media connect" indications which confuses driver
2490 * and userspace to think that device is
2491 * roaming/reassociating when it isn't.
2492 */
2493 devdbg(usbdev, "ignored OID_802_11_ADD_KEY triggered "
2494 "'media connect'");
2495 return;
2496 }
2497
2553 usbnet_pause_rx(usbdev); 2498 usbnet_pause_rx(usbdev);
2554 2499
2555 devinfo(usbdev, "media connect"); 2500 devinfo(usbdev, "media connect");
@@ -2616,77 +2561,44 @@ static int rndis_wlan_get_caps(struct usbnet *usbdev)
2616} 2561}
2617 2562
2618 2563
2619#define STATS_UPDATE_JIFFIES (HZ) 2564#define DEVICE_POLLER_JIFFIES (HZ)
2620static void rndis_update_wireless_stats(struct work_struct *work) 2565static void rndis_device_poller(struct work_struct *work)
2621{ 2566{
2622 struct rndis_wlan_private *priv = 2567 struct rndis_wlan_private *priv =
2623 container_of(work, struct rndis_wlan_private, stats_work.work); 2568 container_of(work, struct rndis_wlan_private,
2569 dev_poller_work.work);
2624 struct usbnet *usbdev = priv->usbdev; 2570 struct usbnet *usbdev = priv->usbdev;
2625 struct iw_statistics iwstats;
2626 __le32 rssi, tmp; 2571 __le32 rssi, tmp;
2627 int len, ret, j; 2572 int len, ret, j;
2628 unsigned long flags; 2573 int update_jiffies = DEVICE_POLLER_JIFFIES;
2629 int update_jiffies = STATS_UPDATE_JIFFIES;
2630 void *buf; 2574 void *buf;
2631 2575
2632 spin_lock_irqsave(&priv->stats_lock, flags); 2576 /* Only check/do workaround when connected. Calling is_associated()
2633 memcpy(&iwstats, &priv->privstats, sizeof(iwstats)); 2577 * also polls device with rndis_command() and catches for media link
2634 spin_unlock_irqrestore(&priv->stats_lock, flags); 2578 * indications.
2635 2579 */
2636 /* only update stats when connected */ 2580 if (!is_associated(usbdev))
2637 if (!is_associated(usbdev)) {
2638 iwstats.qual.qual = 0;
2639 iwstats.qual.level = 0;
2640 iwstats.qual.updated = IW_QUAL_QUAL_UPDATED
2641 | IW_QUAL_LEVEL_UPDATED
2642 | IW_QUAL_NOISE_INVALID
2643 | IW_QUAL_QUAL_INVALID
2644 | IW_QUAL_LEVEL_INVALID;
2645 goto end; 2581 goto end;
2646 }
2647 2582
2648 len = sizeof(rssi); 2583 len = sizeof(rssi);
2649 ret = rndis_query_oid(usbdev, OID_802_11_RSSI, &rssi, &len); 2584 ret = rndis_query_oid(usbdev, OID_802_11_RSSI, &rssi, &len);
2650
2651 devdbg(usbdev, "stats: OID_802_11_RSSI -> %d, rssi:%d", ret,
2652 le32_to_cpu(rssi));
2653 if (ret == 0) {
2654 memset(&iwstats.qual, 0, sizeof(iwstats.qual));
2655 iwstats.qual.qual = level_to_qual(le32_to_cpu(rssi));
2656 iwstats.qual.level = level_to_qual(le32_to_cpu(rssi));
2657 iwstats.qual.updated = IW_QUAL_QUAL_UPDATED
2658 | IW_QUAL_LEVEL_UPDATED
2659 | IW_QUAL_NOISE_INVALID;
2660 }
2661
2662 memset(&iwstats.discard, 0, sizeof(iwstats.discard));
2663
2664 len = sizeof(tmp);
2665 ret = rndis_query_oid(usbdev, OID_GEN_XMIT_ERROR, &tmp, &len);
2666 if (ret == 0)
2667 iwstats.discard.misc += le32_to_cpu(tmp);
2668
2669 len = sizeof(tmp);
2670 ret = rndis_query_oid(usbdev, OID_GEN_RCV_ERROR, &tmp, &len);
2671 if (ret == 0) 2585 if (ret == 0)
2672 iwstats.discard.misc += le32_to_cpu(tmp); 2586 priv->last_qual = level_to_qual(le32_to_cpu(rssi));
2673 2587
2674 len = sizeof(tmp); 2588 devdbg(usbdev, "dev-poller: OID_802_11_RSSI -> %d, rssi:%d, qual: %d",
2675 ret = rndis_query_oid(usbdev, OID_GEN_RCV_NO_BUFFER, &tmp, &len); 2589 ret, le32_to_cpu(rssi), level_to_qual(le32_to_cpu(rssi)));
2676 if (ret == 0)
2677 iwstats.discard.misc += le32_to_cpu(tmp);
2678 2590
2679 /* Workaround transfer stalls on poor quality links. 2591 /* Workaround transfer stalls on poor quality links.
2680 * TODO: find right way to fix these stalls (as stalls do not happen 2592 * TODO: find right way to fix these stalls (as stalls do not happen
2681 * with ndiswrapper/windows driver). */ 2593 * with ndiswrapper/windows driver). */
2682 if (iwstats.qual.qual <= 25) { 2594 if (priv->last_qual <= 25) {
2683 /* Decrease stats worker interval to catch stalls. 2595 /* Decrease stats worker interval to catch stalls.
2684 * faster. Faster than 400-500ms causes packet loss, 2596 * faster. Faster than 400-500ms causes packet loss,
2685 * Slower doesn't catch stalls fast enough. 2597 * Slower doesn't catch stalls fast enough.
2686 */ 2598 */
2687 j = msecs_to_jiffies(priv->param_workaround_interval); 2599 j = msecs_to_jiffies(priv->param_workaround_interval);
2688 if (j > STATS_UPDATE_JIFFIES) 2600 if (j > DEVICE_POLLER_JIFFIES)
2689 j = STATS_UPDATE_JIFFIES; 2601 j = DEVICE_POLLER_JIFFIES;
2690 else if (j <= 0) 2602 else if (j <= 0)
2691 j = 1; 2603 j = 1;
2692 update_jiffies = j; 2604 update_jiffies = j;
@@ -2706,11 +2618,8 @@ static void rndis_update_wireless_stats(struct work_struct *work)
2706 rndis_query_oid(usbdev, OID_802_11_BSSID_LIST, buf, &len); 2618 rndis_query_oid(usbdev, OID_802_11_BSSID_LIST, buf, &len);
2707 kfree(buf); 2619 kfree(buf);
2708 } 2620 }
2709end:
2710 spin_lock_irqsave(&priv->stats_lock, flags);
2711 memcpy(&priv->privstats, &iwstats, sizeof(iwstats));
2712 spin_unlock_irqrestore(&priv->stats_lock, flags);
2713 2621
2622end:
2714 if (update_jiffies >= HZ) 2623 if (update_jiffies >= HZ)
2715 update_jiffies = round_jiffies_relative(update_jiffies); 2624 update_jiffies = round_jiffies_relative(update_jiffies);
2716 else { 2625 else {
@@ -2719,7 +2628,8 @@ end:
2719 update_jiffies = j; 2628 update_jiffies = j;
2720 } 2629 }
2721 2630
2722 queue_delayed_work(priv->workqueue, &priv->stats_work, update_jiffies); 2631 queue_delayed_work(priv->workqueue, &priv->dev_poller_work,
2632 update_jiffies);
2723} 2633}
2724 2634
2725 2635
@@ -2836,16 +2746,14 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
2836 * Otherwise we'll be in big trouble in rndis_wlan_early_init(). 2746 * Otherwise we'll be in big trouble in rndis_wlan_early_init().
2837 */ 2747 */
2838 usbdev->driver_priv = priv; 2748 usbdev->driver_priv = priv;
2839 usbdev->net->wireless_handlers = &rndis_iw_handlers;
2840 priv->usbdev = usbdev; 2749 priv->usbdev = usbdev;
2841 2750
2842 mutex_init(&priv->command_lock); 2751 mutex_init(&priv->command_lock);
2843 spin_lock_init(&priv->stats_lock);
2844 2752
2845 /* because rndis_command() sleeps we need to use workqueue */ 2753 /* because rndis_command() sleeps we need to use workqueue */
2846 priv->workqueue = create_singlethread_workqueue("rndis_wlan"); 2754 priv->workqueue = create_singlethread_workqueue("rndis_wlan");
2847 INIT_WORK(&priv->work, rndis_wlan_worker); 2755 INIT_WORK(&priv->work, rndis_wlan_worker);
2848 INIT_DELAYED_WORK(&priv->stats_work, rndis_update_wireless_stats); 2756 INIT_DELAYED_WORK(&priv->dev_poller_work, rndis_device_poller);
2849 INIT_DELAYED_WORK(&priv->scan_work, rndis_get_scan_results); 2757 INIT_DELAYED_WORK(&priv->scan_work, rndis_get_scan_results);
2850 2758
2851 /* try bind rndis_host */ 2759 /* try bind rndis_host */
@@ -2877,14 +2785,6 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
2877 else 2785 else
2878 usbdev->net->flags &= ~IFF_MULTICAST; 2786 usbdev->net->flags &= ~IFF_MULTICAST;
2879 2787
2880 priv->iwstats.qual.qual = 0;
2881 priv->iwstats.qual.level = 0;
2882 priv->iwstats.qual.updated = IW_QUAL_QUAL_UPDATED
2883 | IW_QUAL_LEVEL_UPDATED
2884 | IW_QUAL_NOISE_INVALID
2885 | IW_QUAL_QUAL_INVALID
2886 | IW_QUAL_LEVEL_INVALID;
2887
2888 /* fill-out wiphy structure and register w/ cfg80211 */ 2788 /* fill-out wiphy structure and register w/ cfg80211 */
2889 memcpy(wiphy->perm_addr, usbdev->net->dev_addr, ETH_ALEN); 2789 memcpy(wiphy->perm_addr, usbdev->net->dev_addr, ETH_ALEN);
2890 wiphy->privid = rndis_wiphy_privid; 2790 wiphy->privid = rndis_wiphy_privid;
@@ -2892,7 +2792,7 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
2892 | BIT(NL80211_IFTYPE_ADHOC); 2792 | BIT(NL80211_IFTYPE_ADHOC);
2893 wiphy->max_scan_ssids = 1; 2793 wiphy->max_scan_ssids = 1;
2894 2794
2895 /* TODO: fill-out band information based on priv->caps */ 2795 /* TODO: fill-out band/encr information based on priv->caps */
2896 rndis_wlan_get_caps(usbdev); 2796 rndis_wlan_get_caps(usbdev);
2897 2797
2898 memcpy(priv->channels, rndis_channels, sizeof(rndis_channels)); 2798 memcpy(priv->channels, rndis_channels, sizeof(rndis_channels));
@@ -2904,6 +2804,11 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
2904 wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; 2804 wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
2905 wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; 2805 wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
2906 2806
2807 memcpy(priv->cipher_suites, rndis_cipher_suites,
2808 sizeof(rndis_cipher_suites));
2809 wiphy->cipher_suites = priv->cipher_suites;
2810 wiphy->n_cipher_suites = ARRAY_SIZE(rndis_cipher_suites);
2811
2907 set_wiphy_dev(wiphy, &usbdev->udev->dev); 2812 set_wiphy_dev(wiphy, &usbdev->udev->dev);
2908 2813
2909 if (wiphy_register(wiphy)) { 2814 if (wiphy_register(wiphy)) {
@@ -2925,7 +2830,7 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
2925 return 0; 2830 return 0;
2926 2831
2927fail: 2832fail:
2928 cancel_delayed_work_sync(&priv->stats_work); 2833 cancel_delayed_work_sync(&priv->dev_poller_work);
2929 cancel_delayed_work_sync(&priv->scan_work); 2834 cancel_delayed_work_sync(&priv->scan_work);
2930 cancel_work_sync(&priv->work); 2835 cancel_work_sync(&priv->work);
2931 flush_workqueue(priv->workqueue); 2836 flush_workqueue(priv->workqueue);
@@ -2943,7 +2848,7 @@ static void rndis_wlan_unbind(struct usbnet *usbdev, struct usb_interface *intf)
2943 /* turn radio off */ 2848 /* turn radio off */
2944 disassociate(usbdev, 0); 2849 disassociate(usbdev, 0);
2945 2850
2946 cancel_delayed_work_sync(&priv->stats_work); 2851 cancel_delayed_work_sync(&priv->dev_poller_work);
2947 cancel_delayed_work_sync(&priv->scan_work); 2852 cancel_delayed_work_sync(&priv->scan_work);
2948 cancel_work_sync(&priv->work); 2853 cancel_work_sync(&priv->work);
2949 flush_workqueue(priv->workqueue); 2854 flush_workqueue(priv->workqueue);
@@ -2974,8 +2879,8 @@ static int rndis_wlan_reset(struct usbnet *usbdev)
2974 (set_multicast_list() also turns on current packet filter) */ 2879 (set_multicast_list() also turns on current packet filter) */
2975 set_multicast_list(usbdev); 2880 set_multicast_list(usbdev);
2976 2881
2977 queue_delayed_work(priv->workqueue, &priv->stats_work, 2882 queue_delayed_work(priv->workqueue, &priv->dev_poller_work,
2978 round_jiffies_relative(STATS_UPDATE_JIFFIES)); 2883 round_jiffies_relative(DEVICE_POLLER_JIFFIES));
2979 2884
2980 return deauthenticate(usbdev); 2885 return deauthenticate(usbdev);
2981} 2886}
@@ -2992,7 +2897,7 @@ static int rndis_wlan_stop(struct usbnet *usbdev)
2992 retval = disassociate(usbdev, 0); 2897 retval = disassociate(usbdev, 0);
2993 2898
2994 priv->work_pending = 0; 2899 priv->work_pending = 0;
2995 cancel_delayed_work_sync(&priv->stats_work); 2900 cancel_delayed_work_sync(&priv->dev_poller_work);
2996 cancel_delayed_work_sync(&priv->scan_work); 2901 cancel_delayed_work_sync(&priv->scan_work);
2997 cancel_work_sync(&priv->work); 2902 cancel_work_sync(&priv->work);
2998 flush_workqueue(priv->workqueue); 2903 flush_workqueue(priv->workqueue);
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index a91f316cd452..929b85f34f38 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -582,7 +582,6 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
582{ 582{
583 struct rt2x00_dev *rt2x00dev = hw->priv; 583 struct rt2x00_dev *rt2x00dev = hw->priv;
584 struct rt2x00_intf *intf = vif_to_intf(vif); 584 struct rt2x00_intf *intf = vif_to_intf(vif);
585 unsigned int delayed = 0;
586 int update_bssid = 0; 585 int update_bssid = 0;
587 586
588 /* 587 /*
@@ -645,13 +644,6 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
645 */ 644 */
646 if (changes & ~(BSS_CHANGED_ASSOC | BSS_CHANGED_HT)) 645 if (changes & ~(BSS_CHANGED_ASSOC | BSS_CHANGED_HT))
647 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf); 646 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf);
648
649 spin_lock(&intf->lock);
650 if (delayed) {
651 intf->delayed_flags |= delayed;
652 schedule_work(&rt2x00dev->intf_work);
653 }
654 spin_unlock(&intf->lock);
655} 647}
656EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed); 648EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed);
657 649
diff --git a/drivers/net/wireless/rtl818x/Makefile b/drivers/net/wireless/rtl818x/Makefile
index 37e3d4db0c40..93cbfbedb46d 100644
--- a/drivers/net/wireless/rtl818x/Makefile
+++ b/drivers/net/wireless/rtl818x/Makefile
@@ -1,5 +1,5 @@
1rtl8180-objs := rtl8180_dev.o rtl8180_rtl8225.o rtl8180_sa2400.o rtl8180_max2820.o rtl8180_grf5101.o 1rtl8180-objs := rtl8180_dev.o rtl8180_rtl8225.o rtl8180_sa2400.o rtl8180_max2820.o rtl8180_grf5101.o
2rtl8187-objs := rtl8187_dev.o rtl8187_rtl8225.o rtl8187_leds.o 2rtl8187-objs := rtl8187_dev.o rtl8187_rtl8225.o rtl8187_leds.o rtl8187_rfkill.o
3 3
4obj-$(CONFIG_RTL8180) += rtl8180.o 4obj-$(CONFIG_RTL8180) += rtl8180.o
5obj-$(CONFIG_RTL8187) += rtl8187.o 5obj-$(CONFIG_RTL8187) += rtl8187.o
diff --git a/drivers/net/wireless/rtl818x/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187.h
index c09bfefc70f3..bf9175a8c1f4 100644
--- a/drivers/net/wireless/rtl818x/rtl8187.h
+++ b/drivers/net/wireless/rtl818x/rtl8187.h
@@ -133,6 +133,7 @@ struct rtl8187_priv {
133 __le16 bits16; 133 __le16 bits16;
134 __le32 bits32; 134 __le32 bits32;
135 } *io_dmabuf; 135 } *io_dmabuf;
136 bool rfkill_off;
136}; 137};
137 138
138void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data); 139void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 90f38357393c..9679b29e1c49 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -32,6 +32,7 @@
32#ifdef CONFIG_RTL8187_LEDS 32#ifdef CONFIG_RTL8187_LEDS
33#include "rtl8187_leds.h" 33#include "rtl8187_leds.h"
34#endif 34#endif
35#include "rtl8187_rfkill.h"
35 36
36MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); 37MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
37MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); 38MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>");
@@ -648,10 +649,10 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
648 649
649 /* setup card */ 650 /* setup card */
650 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0); 651 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0);
651 rtl818x_iowrite8(priv, &priv->map->GPIO, 0); 652 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0);
652 653
653 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, (4 << 8)); 654 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, (4 << 8));
654 rtl818x_iowrite8(priv, &priv->map->GPIO, 1); 655 rtl818x_iowrite8(priv, &priv->map->GPIO0, 1);
655 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0); 656 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0);
656 657
657 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); 658 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
@@ -674,11 +675,11 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
674 675
675 /* host_usb_init */ 676 /* host_usb_init */
676 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0); 677 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0);
677 rtl818x_iowrite8(priv, &priv->map->GPIO, 0); 678 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0);
678 reg = rtl818x_ioread8(priv, (u8 *)0xFE53); 679 reg = rtl818x_ioread8(priv, (u8 *)0xFE53);
679 rtl818x_iowrite8(priv, (u8 *)0xFE53, reg | (1 << 7)); 680 rtl818x_iowrite8(priv, (u8 *)0xFE53, reg | (1 << 7));
680 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, (4 << 8)); 681 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, (4 << 8));
681 rtl818x_iowrite8(priv, &priv->map->GPIO, 0x20); 682 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x20);
682 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0); 683 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0);
683 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x80); 684 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x80);
684 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x80); 685 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x80);
@@ -907,12 +908,12 @@ static int rtl8187_start(struct ieee80211_hw *dev)
907 u32 reg; 908 u32 reg;
908 int ret; 909 int ret;
909 910
911 mutex_lock(&priv->conf_mutex);
912
910 ret = (!priv->is_rtl8187b) ? rtl8187_init_hw(dev) : 913 ret = (!priv->is_rtl8187b) ? rtl8187_init_hw(dev) :
911 rtl8187b_init_hw(dev); 914 rtl8187b_init_hw(dev);
912 if (ret) 915 if (ret)
913 return ret; 916 goto rtl8187_start_exit;
914
915 mutex_lock(&priv->conf_mutex);
916 917
917 init_usb_anchor(&priv->anchored); 918 init_usb_anchor(&priv->anchored);
918 priv->dev = dev; 919 priv->dev = dev;
@@ -939,8 +940,7 @@ static int rtl8187_start(struct ieee80211_hw *dev)
939 (7 << 21 /* MAX TX DMA */)); 940 (7 << 21 /* MAX TX DMA */));
940 rtl8187_init_urbs(dev); 941 rtl8187_init_urbs(dev);
941 rtl8187b_init_status_urb(dev); 942 rtl8187b_init_status_urb(dev);
942 mutex_unlock(&priv->conf_mutex); 943 goto rtl8187_start_exit;
943 return 0;
944 } 944 }
945 945
946 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); 946 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF);
@@ -984,9 +984,10 @@ static int rtl8187_start(struct ieee80211_hw *dev)
984 reg |= RTL818X_CMD_RX_ENABLE; 984 reg |= RTL818X_CMD_RX_ENABLE;
985 rtl818x_iowrite8(priv, &priv->map->CMD, reg); 985 rtl818x_iowrite8(priv, &priv->map->CMD, reg);
986 INIT_DELAYED_WORK(&priv->work, rtl8187_work); 986 INIT_DELAYED_WORK(&priv->work, rtl8187_work);
987 mutex_unlock(&priv->conf_mutex);
988 987
989 return 0; 988rtl8187_start_exit:
989 mutex_unlock(&priv->conf_mutex);
990 return ret;
990} 991}
991 992
992static void rtl8187_stop(struct ieee80211_hw *dev) 993static void rtl8187_stop(struct ieee80211_hw *dev)
@@ -1014,9 +1015,10 @@ static void rtl8187_stop(struct ieee80211_hw *dev)
1014 dev_kfree_skb_any(skb); 1015 dev_kfree_skb_any(skb);
1015 1016
1016 usb_kill_anchored_urbs(&priv->anchored); 1017 usb_kill_anchored_urbs(&priv->anchored);
1018 mutex_unlock(&priv->conf_mutex);
1019
1017 if (!priv->is_rtl8187b) 1020 if (!priv->is_rtl8187b)
1018 cancel_delayed_work_sync(&priv->work); 1021 cancel_delayed_work_sync(&priv->work);
1019 mutex_unlock(&priv->conf_mutex);
1020} 1022}
1021 1023
1022static int rtl8187_add_interface(struct ieee80211_hw *dev, 1024static int rtl8187_add_interface(struct ieee80211_hw *dev,
@@ -1276,7 +1278,8 @@ static const struct ieee80211_ops rtl8187_ops = {
1276 .bss_info_changed = rtl8187_bss_info_changed, 1278 .bss_info_changed = rtl8187_bss_info_changed,
1277 .prepare_multicast = rtl8187_prepare_multicast, 1279 .prepare_multicast = rtl8187_prepare_multicast,
1278 .configure_filter = rtl8187_configure_filter, 1280 .configure_filter = rtl8187_configure_filter,
1279 .conf_tx = rtl8187_conf_tx 1281 .conf_tx = rtl8187_conf_tx,
1282 .rfkill_poll = rtl8187_rfkill_poll
1280}; 1283};
1281 1284
1282static void rtl8187_eeprom_register_read(struct eeprom_93cx6 *eeprom) 1285static void rtl8187_eeprom_register_read(struct eeprom_93cx6 *eeprom)
@@ -1516,6 +1519,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1516 reg &= 0xFF; 1519 reg &= 0xFF;
1517 rtl8187_leds_init(dev, reg); 1520 rtl8187_leds_init(dev, reg);
1518#endif 1521#endif
1522 rtl8187_rfkill_init(dev);
1519 1523
1520 return 0; 1524 return 0;
1521 1525
@@ -1539,6 +1543,7 @@ static void __devexit rtl8187_disconnect(struct usb_interface *intf)
1539#ifdef CONFIG_RTL8187_LEDS 1543#ifdef CONFIG_RTL8187_LEDS
1540 rtl8187_leds_exit(dev); 1544 rtl8187_leds_exit(dev);
1541#endif 1545#endif
1546 rtl8187_rfkill_exit(dev);
1542 ieee80211_unregister_hw(dev); 1547 ieee80211_unregister_hw(dev);
1543 1548
1544 priv = dev->priv; 1549 priv = dev->priv;
diff --git a/drivers/net/wireless/rtl818x/rtl8187_leds.c b/drivers/net/wireless/rtl818x/rtl8187_leds.c
index a6cfb7e77994..a1c670fc1552 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_leds.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_leds.c
@@ -42,7 +42,7 @@ static void led_turn_on(struct work_struct *work)
42 mutex_lock(&priv->conf_mutex); 42 mutex_lock(&priv->conf_mutex);
43 switch (led->ledpin) { 43 switch (led->ledpin) {
44 case LED_PIN_GPIO0: 44 case LED_PIN_GPIO0:
45 rtl818x_iowrite8(priv, &priv->map->GPIO, 0x01); 45 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x01);
46 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x00); 46 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x00);
47 break; 47 break;
48 case LED_PIN_LED0: 48 case LED_PIN_LED0:
@@ -80,7 +80,7 @@ static void led_turn_off(struct work_struct *work)
80 mutex_lock(&priv->conf_mutex); 80 mutex_lock(&priv->conf_mutex);
81 switch (led->ledpin) { 81 switch (led->ledpin) {
82 case LED_PIN_GPIO0: 82 case LED_PIN_GPIO0:
83 rtl818x_iowrite8(priv, &priv->map->GPIO, 0x01); 83 rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x01);
84 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x01); 84 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x01);
85 break; 85 break;
86 case LED_PIN_LED0: 86 case LED_PIN_LED0:
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rfkill.c b/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
new file mode 100644
index 000000000000..9fab13e4004e
--- /dev/null
+++ b/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
@@ -0,0 +1,63 @@
1/*
2 * Linux RFKILL support for RTL8187
3 *
4 * Copyright (c) 2009 Herton Ronaldo Krzesinski <herton@mandriva.com.br>
5 *
6 * Based on the RFKILL handling in the r8187 driver, which is:
7 * Copyright (c) Realtek Semiconductor Corp. All rights reserved.
8 *
9 * Thanks to Realtek for their support!
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/types.h>
17#include <linux/usb.h>
18#include <net/mac80211.h>
19
20#include "rtl8187.h"
21
22static bool rtl8187_is_radio_enabled(struct rtl8187_priv *priv)
23{
24 u8 gpio;
25
26 gpio = rtl818x_ioread8(priv, &priv->map->GPIO0);
27 rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~0x02);
28 gpio = rtl818x_ioread8(priv, &priv->map->GPIO1);
29
30 return gpio & 0x02;
31}
32
33void rtl8187_rfkill_init(struct ieee80211_hw *hw)
34{
35 struct rtl8187_priv *priv = hw->priv;
36
37 priv->rfkill_off = rtl8187_is_radio_enabled(priv);
38 printk(KERN_INFO "rtl8187: wireless switch is %s\n",
39 priv->rfkill_off ? "on" : "off");
40 wiphy_rfkill_set_hw_state(hw->wiphy, !priv->rfkill_off);
41 wiphy_rfkill_start_polling(hw->wiphy);
42}
43
44void rtl8187_rfkill_poll(struct ieee80211_hw *hw)
45{
46 bool enabled;
47 struct rtl8187_priv *priv = hw->priv;
48
49 mutex_lock(&priv->conf_mutex);
50 enabled = rtl8187_is_radio_enabled(priv);
51 if (unlikely(enabled != priv->rfkill_off)) {
52 priv->rfkill_off = enabled;
53 printk(KERN_INFO "rtl8187: wireless radio switch turned %s\n",
54 enabled ? "on" : "off");
55 wiphy_rfkill_set_hw_state(hw->wiphy, !enabled);
56 }
57 mutex_unlock(&priv->conf_mutex);
58}
59
60void rtl8187_rfkill_exit(struct ieee80211_hw *hw)
61{
62 wiphy_rfkill_stop_polling(hw->wiphy);
63}
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rfkill.h b/drivers/net/wireless/rtl818x/rtl8187_rfkill.h
new file mode 100644
index 000000000000..e12575e96d11
--- /dev/null
+++ b/drivers/net/wireless/rtl818x/rtl8187_rfkill.h
@@ -0,0 +1,8 @@
1#ifndef RTL8187_RFKILL_H
2#define RTL8187_RFKILL_H
3
4void rtl8187_rfkill_init(struct ieee80211_hw *hw);
5void rtl8187_rfkill_poll(struct ieee80211_hw *hw);
6void rtl8187_rfkill_exit(struct ieee80211_hw *hw);
7
8#endif /* RTL8187_RFKILL_H */
diff --git a/drivers/net/wireless/rtl818x/rtl818x.h b/drivers/net/wireless/rtl818x/rtl818x.h
index 562222e6cf1f..8522490d2e29 100644
--- a/drivers/net/wireless/rtl818x/rtl818x.h
+++ b/drivers/net/wireless/rtl818x/rtl818x.h
@@ -138,8 +138,9 @@ struct rtl818x_csr {
138 __le32 RF_PARA; 138 __le32 RF_PARA;
139 __le32 RF_TIMING; 139 __le32 RF_TIMING;
140 u8 GP_ENABLE; 140 u8 GP_ENABLE;
141 u8 GPIO; 141 u8 GPIO0;
142 u8 reserved_12[2]; 142 u8 GPIO1;
143 u8 reserved_12;
143 __le32 HSSI_PARA; 144 __le32 HSSI_PARA;
144 u8 reserved_13[4]; 145 u8 reserved_13[4];
145 u8 TX_AGC_CTL; 146 u8 TX_AGC_CTL;
diff --git a/drivers/ssb/driver_chipcommon_pmu.c b/drivers/ssb/driver_chipcommon_pmu.c
index 4aaddeec55a2..64abd11f6fbb 100644
--- a/drivers/ssb/driver_chipcommon_pmu.c
+++ b/drivers/ssb/driver_chipcommon_pmu.c
@@ -28,6 +28,21 @@ static void ssb_chipco_pll_write(struct ssb_chipcommon *cc,
28 chipco_write32(cc, SSB_CHIPCO_PLLCTL_DATA, value); 28 chipco_write32(cc, SSB_CHIPCO_PLLCTL_DATA, value);
29} 29}
30 30
31static void ssb_chipco_regctl_maskset(struct ssb_chipcommon *cc,
32 u32 offset, u32 mask, u32 set)
33{
34 u32 value;
35
36 chipco_read32(cc, SSB_CHIPCO_REGCTL_ADDR);
37 chipco_write32(cc, SSB_CHIPCO_REGCTL_ADDR, offset);
38 chipco_read32(cc, SSB_CHIPCO_REGCTL_ADDR);
39 value = chipco_read32(cc, SSB_CHIPCO_REGCTL_DATA);
40 value &= mask;
41 value |= set;
42 chipco_write32(cc, SSB_CHIPCO_REGCTL_DATA, value);
43 chipco_read32(cc, SSB_CHIPCO_REGCTL_DATA);
44}
45
31struct pmu0_plltab_entry { 46struct pmu0_plltab_entry {
32 u16 freq; /* Crystal frequency in kHz.*/ 47 u16 freq; /* Crystal frequency in kHz.*/
33 u8 xf; /* Crystal frequency value for PMU control */ 48 u8 xf; /* Crystal frequency value for PMU control */
@@ -506,3 +521,82 @@ void ssb_pmu_init(struct ssb_chipcommon *cc)
506 ssb_pmu_pll_init(cc); 521 ssb_pmu_pll_init(cc);
507 ssb_pmu_resources_init(cc); 522 ssb_pmu_resources_init(cc);
508} 523}
524
525void ssb_pmu_set_ldo_voltage(struct ssb_chipcommon *cc,
526 enum ssb_pmu_ldo_volt_id id, u32 voltage)
527{
528 struct ssb_bus *bus = cc->dev->bus;
529 u32 addr, shift, mask;
530
531 switch (bus->chip_id) {
532 case 0x4328:
533 case 0x5354:
534 switch (id) {
535 case LDO_VOLT1:
536 addr = 2;
537 shift = 25;
538 mask = 0xF;
539 break;
540 case LDO_VOLT2:
541 addr = 3;
542 shift = 1;
543 mask = 0xF;
544 break;
545 case LDO_VOLT3:
546 addr = 3;
547 shift = 9;
548 mask = 0xF;
549 break;
550 case LDO_PAREF:
551 addr = 3;
552 shift = 17;
553 mask = 0x3F;
554 break;
555 default:
556 SSB_WARN_ON(1);
557 return;
558 }
559 break;
560 case 0x4312:
561 if (SSB_WARN_ON(id != LDO_PAREF))
562 return;
563 addr = 0;
564 shift = 21;
565 mask = 0x3F;
566 break;
567 default:
568 return;
569 }
570
571 ssb_chipco_regctl_maskset(cc, addr, ~(mask << shift),
572 (voltage & mask) << shift);
573}
574
575void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on)
576{
577 struct ssb_bus *bus = cc->dev->bus;
578 int ldo;
579
580 switch (bus->chip_id) {
581 case 0x4312:
582 ldo = SSB_PMURES_4312_PA_REF_LDO;
583 break;
584 case 0x4328:
585 ldo = SSB_PMURES_4328_PA_REF_LDO;
586 break;
587 case 0x5354:
588 ldo = SSB_PMURES_5354_PA_REF_LDO;
589 break;
590 default:
591 return;
592 }
593
594 if (on)
595 chipco_set32(cc, SSB_CHIPCO_PMU_MINRES_MSK, 1 << ldo);
596 else
597 chipco_mask32(cc, SSB_CHIPCO_PMU_MINRES_MSK, ~(1 << ldo));
598 chipco_read32(cc, SSB_CHIPCO_PMU_MINRES_MSK); //SPEC FIXME found via mmiotrace - dummy read?
599}
600
601EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage);
602EXPORT_SYMBOL(ssb_pmu_set_ldo_paref);
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 21556a2d9e7e..52e15e079c61 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -115,7 +115,7 @@
115#define IEEE80211_MAX_SSID_LEN 32 115#define IEEE80211_MAX_SSID_LEN 32
116 116
117#define IEEE80211_MAX_MESH_ID_LEN 32 117#define IEEE80211_MAX_MESH_ID_LEN 32
118#define IEEE80211_MESH_CONFIG_LEN 19 118#define IEEE80211_MESH_CONFIG_LEN 24
119 119
120#define IEEE80211_QOS_CTL_LEN 2 120#define IEEE80211_QOS_CTL_LEN 2
121#define IEEE80211_QOS_CTL_TID_MASK 0x000F 121#define IEEE80211_QOS_CTL_TID_MASK 0x000F
diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h
index d3b1d18922f2..4e27acf0a92f 100644
--- a/include/linux/ssb/ssb_driver_chipcommon.h
+++ b/include/linux/ssb/ssb_driver_chipcommon.h
@@ -629,5 +629,15 @@ extern int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
629/* PMU support */ 629/* PMU support */
630extern void ssb_pmu_init(struct ssb_chipcommon *cc); 630extern void ssb_pmu_init(struct ssb_chipcommon *cc);
631 631
632enum ssb_pmu_ldo_volt_id {
633 LDO_PAREF = 0,
634 LDO_VOLT1,
635 LDO_VOLT2,
636 LDO_VOLT3,
637};
638
639void ssb_pmu_set_ldo_voltage(struct ssb_chipcommon *cc,
640 enum ssb_pmu_ldo_volt_id id, u32 voltage);
641void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on);
632 642
633#endif /* LINUX_SSB_CHIPCO_H_ */ 643#endif /* LINUX_SSB_CHIPCO_H_ */
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index 2b3fbbb8669e..e9054a283fde 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -416,13 +416,13 @@ struct iw_spy_data
416 * data (i.e. valid as long as struct net_device exist, same locking rules). 416 * data (i.e. valid as long as struct net_device exist, same locking rules).
417 */ 417 */
418/* Forward declaration */ 418/* Forward declaration */
419struct ieee80211_device; 419struct libipw_device;
420/* The struct */ 420/* The struct */
421struct iw_public_data { 421struct iw_public_data {
422 /* Driver enhanced spy support */ 422 /* Driver enhanced spy support */
423 struct iw_spy_data * spy_data; 423 struct iw_spy_data * spy_data;
424 /* Structure managed by the in-kernel IEEE 802.11 layer */ 424 /* Legacy structure managed by the ipw2x00-specific IEEE 802.11 layer */
425 struct ieee80211_device * ieee80211; 425 struct libipw_device * libipw;
426}; 426};
427 427
428/**************************** PROTOTYPES ****************************/ 428/**************************** PROTOTYPES ****************************/
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index aac84d7bd46e..466859b285e1 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1657,12 +1657,6 @@ void ieee80211_free_hw(struct ieee80211_hw *hw);
1657 */ 1657 */
1658void ieee80211_restart_hw(struct ieee80211_hw *hw); 1658void ieee80211_restart_hw(struct ieee80211_hw *hw);
1659 1659
1660/*
1661 * trick to avoid symbol clashes with the ieee80211 subsystem,
1662 * use the inline below instead
1663 */
1664void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb);
1665
1666/** 1660/**
1667 * ieee80211_rx - receive frame 1661 * ieee80211_rx - receive frame
1668 * 1662 *
@@ -1678,10 +1672,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb);
1678 * @hw: the hardware this frame came in on 1672 * @hw: the hardware this frame came in on
1679 * @skb: the buffer to receive, owned by mac80211 after this call 1673 * @skb: the buffer to receive, owned by mac80211 after this call
1680 */ 1674 */
1681static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) 1675void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb);
1682{
1683 __ieee80211_rx(hw, skb);
1684}
1685 1676
1686/** 1677/**
1687 * ieee80211_rx_irqsafe - receive frame 1678 * ieee80211_rx_irqsafe - receive frame
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index d231c9323ad1..020a94a31106 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -12,7 +12,11 @@ static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
12 12
13static inline int drv_start(struct ieee80211_local *local) 13static inline int drv_start(struct ieee80211_local *local)
14{ 14{
15 int ret = local->ops->start(&local->hw); 15 int ret;
16
17 local->started = true;
18 smp_mb();
19 ret = local->ops->start(&local->hw);
16 trace_drv_start(local, ret); 20 trace_drv_start(local, ret);
17 return ret; 21 return ret;
18} 22}
@@ -21,6 +25,14 @@ static inline void drv_stop(struct ieee80211_local *local)
21{ 25{
22 local->ops->stop(&local->hw); 26 local->ops->stop(&local->hw);
23 trace_drv_stop(local); 27 trace_drv_stop(local);
28
29 /* sync away all work on the tasklet before clearing started */
30 tasklet_disable(&local->tasklet);
31 tasklet_enable(&local->tasklet);
32
33 barrier();
34
35 local->started = false;
24} 36}
25 37
26static inline int drv_add_interface(struct ieee80211_local *local, 38static inline int drv_add_interface(struct ieee80211_local *local,
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 93e618a980d1..dbd8411cc1bd 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -367,6 +367,10 @@ struct ieee80211_if_mesh {
367 u8 mesh_pm_id[4]; 367 u8 mesh_pm_id[4];
368 /* Congestion Control Mode Identifier */ 368 /* Congestion Control Mode Identifier */
369 u8 mesh_cc_id[4]; 369 u8 mesh_cc_id[4];
370 /* Synchronization Protocol Identifier */
371 u8 mesh_sp_id[4];
372 /* Authentication Protocol Identifier */
373 u8 mesh_auth_id[4];
370 /* Local mesh Destination Sequence Number */ 374 /* Local mesh Destination Sequence Number */
371 u32 dsn; 375 u32 dsn;
372 /* Last used PREQ ID */ 376 /* Last used PREQ ID */
@@ -663,6 +667,9 @@ struct ieee80211_local {
663 */ 667 */
664 bool quiescing; 668 bool quiescing;
665 669
670 /* device is started */
671 bool started;
672
666 int tx_headroom; /* required headroom for hardware/radiotap */ 673 int tx_headroom; /* required headroom for hardware/radiotap */
667 674
668 /* Tasklet and skb queue to process calls from IRQ mode. All frames 675 /* Tasklet and skb queue to process calls from IRQ mode. All frames
@@ -1082,6 +1089,7 @@ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1082 1089
1083/* Suspend/resume and hw reconfiguration */ 1090/* Suspend/resume and hw reconfiguration */
1084int ieee80211_reconfig(struct ieee80211_local *local); 1091int ieee80211_reconfig(struct ieee80211_local *local);
1092void ieee80211_stop_device(struct ieee80211_local *local);
1085 1093
1086#ifdef CONFIG_PM 1094#ifdef CONFIG_PM
1087int __ieee80211_suspend(struct ieee80211_hw *hw); 1095int __ieee80211_suspend(struct ieee80211_hw *hw);
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index b161301056df..f6005adcbf90 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -277,11 +277,6 @@ static int ieee80211_open(struct net_device *dev)
277 } 277 }
278 } 278 }
279 279
280 if (local->open_count == 0) {
281 tasklet_enable(&local->tx_pending_tasklet);
282 tasklet_enable(&local->tasklet);
283 }
284
285 /* 280 /*
286 * set_multicast_list will be invoked by the networking core 281 * set_multicast_list will be invoked by the networking core
287 * which will check whether any increments here were done in 282 * which will check whether any increments here were done in
@@ -502,30 +497,8 @@ static int ieee80211_stop(struct net_device *dev)
502 } 497 }
503 /* fall through */ 498 /* fall through */
504 default: 499 default:
505 if (local->scan_sdata == sdata) { 500 if (local->scan_sdata == sdata)
506 if (!local->ops->hw_scan) 501 ieee80211_scan_cancel(local);
507 cancel_delayed_work_sync(&local->scan_work);
508 /*
509 * The software scan can no longer run now, so we can
510 * clear out the scan_sdata reference. However, the
511 * hardware scan may still be running. The complete
512 * function must be prepared to handle a NULL value.
513 */
514 local->scan_sdata = NULL;
515 /*
516 * The memory barrier guarantees that another CPU
517 * that is hardware-scanning will now see the fact
518 * that this interface is gone.
519 */
520 smp_mb();
521 /*
522 * If software scanning, complete the scan but since
523 * the scan_sdata is NULL already don't send out a
524 * scan event to userspace -- the scan is incomplete.
525 */
526 if (test_bit(SCAN_SW_SCANNING, &local->scanning))
527 ieee80211_scan_completed(&local->hw, true);
528 }
529 502
530 /* 503 /*
531 * Disable beaconing for AP and mesh, IBSS can't 504 * Disable beaconing for AP and mesh, IBSS can't
@@ -552,14 +525,8 @@ static int ieee80211_stop(struct net_device *dev)
552 ieee80211_recalc_ps(local, -1); 525 ieee80211_recalc_ps(local, -1);
553 526
554 if (local->open_count == 0) { 527 if (local->open_count == 0) {
555 drv_stop(local); 528 ieee80211_clear_tx_pending(local);
556 529 ieee80211_stop_device(local);
557 ieee80211_led_radio(local, false);
558
559 flush_workqueue(local->workqueue);
560
561 tasklet_disable(&local->tx_pending_tasklet);
562 tasklet_disable(&local->tasklet);
563 530
564 /* no reconfiguring after stop! */ 531 /* no reconfiguring after stop! */
565 hw_reconf_flags = 0; 532 hw_reconf_flags = 0;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index dd3b0816614d..797f53942e5f 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -715,12 +715,10 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
715 skb_queue_head_init(&local->pending[i]); 715 skb_queue_head_init(&local->pending[i]);
716 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, 716 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
717 (unsigned long)local); 717 (unsigned long)local);
718 tasklet_disable(&local->tx_pending_tasklet);
719 718
720 tasklet_init(&local->tasklet, 719 tasklet_init(&local->tasklet,
721 ieee80211_tasklet_handler, 720 ieee80211_tasklet_handler,
722 (unsigned long) local); 721 (unsigned long) local);
723 tasklet_disable(&local->tasklet);
724 722
725 skb_queue_head_init(&local->skb_queue); 723 skb_queue_head_init(&local->skb_queue);
726 skb_queue_head_init(&local->skb_queue_unreliable); 724 skb_queue_head_init(&local->skb_queue_unreliable);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 3185e18c8214..f7364e56f1ee 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -18,8 +18,11 @@
18#define PP_OFFSET 1 /* Path Selection Protocol */ 18#define PP_OFFSET 1 /* Path Selection Protocol */
19#define PM_OFFSET 5 /* Path Selection Metric */ 19#define PM_OFFSET 5 /* Path Selection Metric */
20#define CC_OFFSET 9 /* Congestion Control Mode */ 20#define CC_OFFSET 9 /* Congestion Control Mode */
21#define CAPAB_OFFSET 17 21#define SP_OFFSET 13 /* Synchronization Protocol */
22#define ACCEPT_PLINKS 0x80 22#define AUTH_OFFSET 17 /* Authentication Protocol */
23#define CAPAB_OFFSET 22
24#define CAPAB_ACCEPT_PLINKS 0x80
25#define CAPAB_FORWARDING 0x10
23 26
24#define TMR_RUNNING_HK 0 27#define TMR_RUNNING_HK 0
25#define TMR_RUNNING_MP 1 28#define TMR_RUNNING_MP 1
@@ -84,7 +87,9 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat
84 memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && 87 memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
85 memcmp(ifmsh->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 && 88 memcmp(ifmsh->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 &&
86 memcmp(ifmsh->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 && 89 memcmp(ifmsh->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 &&
87 memcmp(ifmsh->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0) 90 memcmp(ifmsh->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0 &&
91 memcmp(ifmsh->mesh_sp_id, ie->mesh_config + SP_OFFSET, 4) == 0 &&
92 memcmp(ifmsh->mesh_auth_id, ie->mesh_config + AUTH_OFFSET, 4) == 0)
88 return true; 93 return true;
89 94
90 return false; 95 return false;
@@ -97,7 +102,7 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat
97 */ 102 */
98bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie) 103bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
99{ 104{
100 return (*(ie->mesh_config + CAPAB_OFFSET) & ACCEPT_PLINKS) != 0; 105 return (*(ie->mesh_config + CAPAB_OFFSET) & CAPAB_ACCEPT_PLINKS) != 0;
101} 106}
102 107
103/** 108/**
@@ -123,11 +128,18 @@ void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
123 128
124void mesh_ids_set_default(struct ieee80211_if_mesh *sta) 129void mesh_ids_set_default(struct ieee80211_if_mesh *sta)
125{ 130{
126 u8 def_id[4] = {0x00, 0x0F, 0xAC, 0xff}; 131 u8 oui[3] = {0x00, 0x0F, 0xAC};
127 132
128 memcpy(sta->mesh_pp_id, def_id, 4); 133 memcpy(sta->mesh_pp_id, oui, sizeof(oui));
129 memcpy(sta->mesh_pm_id, def_id, 4); 134 memcpy(sta->mesh_pm_id, oui, sizeof(oui));
130 memcpy(sta->mesh_cc_id, def_id, 4); 135 memcpy(sta->mesh_cc_id, oui, sizeof(oui));
136 memcpy(sta->mesh_sp_id, oui, sizeof(oui));
137 memcpy(sta->mesh_auth_id, oui, sizeof(oui));
138 sta->mesh_pp_id[sizeof(oui)] = 0;
139 sta->mesh_pm_id[sizeof(oui)] = 0;
140 sta->mesh_cc_id[sizeof(oui)] = 0xff;
141 sta->mesh_sp_id[sizeof(oui)] = 0xff;
142 sta->mesh_auth_id[sizeof(oui)] = 0x0;
131} 143}
132 144
133int mesh_rmc_init(struct ieee80211_sub_if_data *sdata) 145int mesh_rmc_init(struct ieee80211_sub_if_data *sdata)
@@ -245,7 +257,7 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
245 if (sdata->u.mesh.mesh_id_len) 257 if (sdata->u.mesh.mesh_id_len)
246 memcpy(pos, sdata->u.mesh.mesh_id, sdata->u.mesh.mesh_id_len); 258 memcpy(pos, sdata->u.mesh.mesh_id, sdata->u.mesh.mesh_id_len);
247 259
248 pos = skb_put(skb, 21); 260 pos = skb_put(skb, 2 + IEEE80211_MESH_CONFIG_LEN);
249 *pos++ = WLAN_EID_MESH_CONFIG; 261 *pos++ = WLAN_EID_MESH_CONFIG;
250 *pos++ = IEEE80211_MESH_CONFIG_LEN; 262 *pos++ = IEEE80211_MESH_CONFIG_LEN;
251 /* Version */ 263 /* Version */
@@ -263,15 +275,22 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
263 memcpy(pos, sdata->u.mesh.mesh_cc_id, 4); 275 memcpy(pos, sdata->u.mesh.mesh_cc_id, 4);
264 pos += 4; 276 pos += 4;
265 277
266 /* Channel precedence: 278 /* Synchronization protocol identifier */
267 * Not running simple channel unification protocol 279 memcpy(pos, sdata->u.mesh.mesh_sp_id, 4);
268 */
269 memset(pos, 0x00, 4);
270 pos += 4; 280 pos += 4;
271 281
282 /* Authentication Protocol identifier */
283 memcpy(pos, sdata->u.mesh.mesh_auth_id, 4);
284 pos += 4;
285
286 /* Mesh Formation Info */
287 memset(pos, 0x00, 1);
288 pos += 1;
289
272 /* Mesh capability */ 290 /* Mesh capability */
273 sdata->u.mesh.accepting_plinks = mesh_plink_availables(sdata); 291 sdata->u.mesh.accepting_plinks = mesh_plink_availables(sdata);
274 *pos++ = sdata->u.mesh.accepting_plinks ? ACCEPT_PLINKS : 0x00; 292 *pos = CAPAB_FORWARDING;
293 *pos++ |= sdata->u.mesh.accepting_plinks ? CAPAB_ACCEPT_PLINKS : 0x00;
275 *pos++ = 0x00; 294 *pos++ = 0x00;
276 295
277 return; 296 return;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index c374d2d73fa4..97a278a2f48e 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2123,25 +2123,9 @@ static void ieee80211_sta_work(struct work_struct *work)
2123 } 2123 }
2124 } 2124 }
2125 2125
2126 list_for_each_entry(wk, &ifmgd->work_list, list) {
2127 if (wk->state != IEEE80211_MGD_STATE_IDLE) {
2128 anybusy = true;
2129 break;
2130 }
2131 }
2132 2126
2133 ieee80211_recalc_idle(local); 2127 ieee80211_recalc_idle(local);
2134 2128
2135 if (!anybusy) {
2136 mutex_unlock(&ifmgd->mtx);
2137
2138 if (test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request))
2139 ieee80211_queue_delayed_work(&local->hw,
2140 &local->scan_work,
2141 round_jiffies_relative(0));
2142 return;
2143 }
2144
2145 list_for_each_entry_safe(wk, tmp, &ifmgd->work_list, list) { 2129 list_for_each_entry_safe(wk, tmp, &ifmgd->work_list, list) {
2146 if (time_is_after_jiffies(wk->timeout)) { 2130 if (time_is_after_jiffies(wk->timeout)) {
2147 /* 2131 /*
@@ -2187,6 +2171,18 @@ static void ieee80211_sta_work(struct work_struct *work)
2187 } 2171 }
2188 } 2172 }
2189 2173
2174 list_for_each_entry(wk, &ifmgd->work_list, list) {
2175 if (wk->state != IEEE80211_MGD_STATE_IDLE) {
2176 anybusy = true;
2177 break;
2178 }
2179 }
2180 if (!anybusy &&
2181 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request))
2182 ieee80211_queue_delayed_work(&local->hw,
2183 &local->scan_work,
2184 round_jiffies_relative(0));
2185
2190 mutex_unlock(&ifmgd->mtx); 2186 mutex_unlock(&ifmgd->mtx);
2191 2187
2192 list_for_each_entry_safe(wk, tmp, &free_work, list) { 2188 list_for_each_entry_safe(wk, tmp, &free_work, list) {
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
index a5d2f1fb4417..e535f1c988fe 100644
--- a/net/mac80211/pm.c
+++ b/net/mac80211/pm.c
@@ -107,17 +107,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
107 } 107 }
108 108
109 /* stop hardware - this must stop RX */ 109 /* stop hardware - this must stop RX */
110 if (local->open_count) { 110 if (local->open_count)
111 ieee80211_led_radio(local, false); 111 ieee80211_stop_device(local);
112 drv_stop(local);
113 }
114
115 /*
116 * flush again, in case driver queued work -- it
117 * shouldn't be doing (or cancel everything in the
118 * stop callback) that but better safe than sorry.
119 */
120 flush_workqueue(local->workqueue);
121 112
122 local->suspended = true; 113 local->suspended = true;
123 /* need suspended to be visible before quiescing is false */ 114 /* need suspended to be visible before quiescing is false */
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 869fe0ef951d..38bf4168fc3a 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -33,7 +33,6 @@ struct minstrel_rate {
33 33
34 /* per-rate throughput */ 34 /* per-rate throughput */
35 u32 cur_tp; 35 u32 cur_tp;
36 u32 throughput;
37 36
38 u64 succ_hist; 37 u64 succ_hist;
39 u64 att_hist; 38 u64 att_hist;
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index 98f480708050..3d72ec5730d4 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -83,7 +83,7 @@ minstrel_stats_open(struct inode *inode, struct file *file)
83 p += sprintf(p, "%3u%s", mr->bitrate / 2, 83 p += sprintf(p, "%3u%s", mr->bitrate / 2,
84 (mr->bitrate & 1 ? ".5" : " ")); 84 (mr->bitrate & 1 ? ".5" : " "));
85 85
86 tp = ((mr->cur_tp * 96) / 18000) >> 10; 86 tp = mr->cur_tp / ((18000 << 10) / 96);
87 prob = mr->cur_prob / 18; 87 prob = mr->cur_prob / 18;
88 eprob = mr->probability / 18; 88 eprob = mr->probability / 18;
89 89
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 7065fd7e7ba2..c01588f9d453 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2440,24 +2440,20 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2440 * This is the receive path handler. It is called by a low level driver when an 2440 * This is the receive path handler. It is called by a low level driver when an
2441 * 802.11 MPDU is received from the hardware. 2441 * 802.11 MPDU is received from the hardware.
2442 */ 2442 */
2443void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) 2443void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
2444{ 2444{
2445 struct ieee80211_local *local = hw_to_local(hw); 2445 struct ieee80211_local *local = hw_to_local(hw);
2446 struct ieee80211_rate *rate = NULL; 2446 struct ieee80211_rate *rate = NULL;
2447 struct ieee80211_supported_band *sband; 2447 struct ieee80211_supported_band *sband;
2448 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 2448 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2449 2449
2450 if (status->band < 0 || 2450 if (WARN_ON(status->band < 0 ||
2451 status->band >= IEEE80211_NUM_BANDS) { 2451 status->band >= IEEE80211_NUM_BANDS))
2452 WARN_ON(1); 2452 goto drop;
2453 return;
2454 }
2455 2453
2456 sband = local->hw.wiphy->bands[status->band]; 2454 sband = local->hw.wiphy->bands[status->band];
2457 if (!sband) { 2455 if (WARN_ON(!sband))
2458 WARN_ON(1); 2456 goto drop;
2459 return;
2460 }
2461 2457
2462 /* 2458 /*
2463 * If we're suspending, it is possible although not too likely 2459 * If we're suspending, it is possible although not too likely
@@ -2466,16 +2462,21 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
2466 * that might, for example, cause stations to be added or other 2462 * that might, for example, cause stations to be added or other
2467 * driver callbacks be invoked. 2463 * driver callbacks be invoked.
2468 */ 2464 */
2469 if (unlikely(local->quiescing || local->suspended)) { 2465 if (unlikely(local->quiescing || local->suspended))
2470 kfree_skb(skb); 2466 goto drop;
2471 return; 2467
2472 } 2468 /*
2469 * The same happens when we're not even started,
2470 * but that's worth a warning.
2471 */
2472 if (WARN_ON(!local->started))
2473 goto drop;
2473 2474
2474 if (status->flag & RX_FLAG_HT) { 2475 if (status->flag & RX_FLAG_HT) {
2475 /* rate_idx is MCS index */ 2476 /* rate_idx is MCS index */
2476 if (WARN_ON(status->rate_idx < 0 || 2477 if (WARN_ON(status->rate_idx < 0 ||
2477 status->rate_idx >= 76)) 2478 status->rate_idx >= 76))
2478 return; 2479 goto drop;
2479 /* HT rates are not in the table - use the highest legacy rate 2480 /* HT rates are not in the table - use the highest legacy rate
2480 * for now since other parts of mac80211 may not yet be fully 2481 * for now since other parts of mac80211 may not yet be fully
2481 * MCS aware. */ 2482 * MCS aware. */
@@ -2483,7 +2484,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
2483 } else { 2484 } else {
2484 if (WARN_ON(status->rate_idx < 0 || 2485 if (WARN_ON(status->rate_idx < 0 ||
2485 status->rate_idx >= sband->n_bitrates)) 2486 status->rate_idx >= sband->n_bitrates))
2486 return; 2487 goto drop;
2487 rate = &sband->bitrates[status->rate_idx]; 2488 rate = &sband->bitrates[status->rate_idx];
2488 } 2489 }
2489 2490
@@ -2522,8 +2523,12 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
2522 __ieee80211_rx_handle_packet(hw, skb, rate); 2523 __ieee80211_rx_handle_packet(hw, skb, rate);
2523 2524
2524 rcu_read_unlock(); 2525 rcu_read_unlock();
2526
2527 return;
2528 drop:
2529 kfree_skb(skb);
2525} 2530}
2526EXPORT_SYMBOL(__ieee80211_rx); 2531EXPORT_SYMBOL(ieee80211_rx);
2527 2532
2528/* This is a version of the rx handler that can be called from hard irq 2533/* This is a version of the rx handler that can be called from hard irq
2529 * context. Post the skb on the queue and schedule the tasklet */ 2534 * context. Post the skb on the queue and schedule the tasklet */
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 1e04be6b9129..039901109fa1 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -280,6 +280,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
280 if (local->scan_req != local->int_scan_req) 280 if (local->scan_req != local->int_scan_req)
281 cfg80211_scan_done(local->scan_req, aborted); 281 cfg80211_scan_done(local->scan_req, aborted);
282 local->scan_req = NULL; 282 local->scan_req = NULL;
283 local->scan_sdata = NULL;
283 284
284 was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning); 285 was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
285 local->scanning = 0; 286 local->scanning = 0;
@@ -660,6 +661,7 @@ void ieee80211_scan_work(struct work_struct *work)
660 int rc; 661 int rc;
661 662
662 local->scan_req = NULL; 663 local->scan_req = NULL;
664 local->scan_sdata = NULL;
663 665
664 rc = __ieee80211_start_scan(sdata, req); 666 rc = __ieee80211_start_scan(sdata, req);
665 mutex_unlock(&local->scan_mtx); 667 mutex_unlock(&local->scan_mtx);
@@ -742,7 +744,7 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
742 744
743void ieee80211_scan_cancel(struct ieee80211_local *local) 745void ieee80211_scan_cancel(struct ieee80211_local *local)
744{ 746{
745 bool swscan; 747 bool abortscan;
746 748
747 cancel_delayed_work_sync(&local->scan_work); 749 cancel_delayed_work_sync(&local->scan_work);
748 750
@@ -751,9 +753,10 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
751 * queued -- mostly at suspend under RTNL. 753 * queued -- mostly at suspend under RTNL.
752 */ 754 */
753 mutex_lock(&local->scan_mtx); 755 mutex_lock(&local->scan_mtx);
754 swscan = test_bit(SCAN_SW_SCANNING, &local->scanning); 756 abortscan = test_bit(SCAN_SW_SCANNING, &local->scanning) ||
757 (!local->scanning && local->scan_req);
755 mutex_unlock(&local->scan_mtx); 758 mutex_unlock(&local->scan_mtx);
756 759
757 if (swscan) 760 if (abortscan)
758 ieee80211_scan_completed(&local->hw, true); 761 ieee80211_scan_completed(&local->hw, true);
759} 762}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 5eb306377c63..dd6564321369 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1007,6 +1007,16 @@ u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
1007 return supp_rates; 1007 return supp_rates;
1008} 1008}
1009 1009
1010void ieee80211_stop_device(struct ieee80211_local *local)
1011{
1012 ieee80211_led_radio(local, false);
1013
1014 cancel_work_sync(&local->reconfig_filter);
1015 drv_stop(local);
1016
1017 flush_workqueue(local->workqueue);
1018}
1019
1010int ieee80211_reconfig(struct ieee80211_local *local) 1020int ieee80211_reconfig(struct ieee80211_local *local)
1011{ 1021{
1012 struct ieee80211_hw *hw = &local->hw; 1022 struct ieee80211_hw *hw = &local->hw;
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index c6031d5b135f..aea7e6824af9 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -17,6 +17,23 @@ config NL80211_TESTMODE
17 17
18 Say N. 18 Say N.
19 19
20config CFG80211_DEVELOPER_WARNINGS
21 bool "enable developer warnings"
22 depends on CFG80211
23 default n
24 help
25 This option enables some additional warnings that help
26 cfg80211 developers and driver developers, but that can
27 trigger due to races with userspace.
28
29 For example, when a driver reports that it was disconnected
30 from the AP, but the user disconnects manually at the same
31 time, the warning might trigger spuriously due to races.
32
33 Say Y only if you are developing cfg80211 or a driver based
34 on it (or mac80211).
35
36
20config CFG80211_REG_DEBUG 37config CFG80211_REG_DEBUG
21 bool "cfg80211 regulatory debugging" 38 bool "cfg80211 regulatory debugging"
22 depends on CFG80211 39 depends on CFG80211
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 154e1e294cb9..45b2be3274db 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -294,69 +294,17 @@ static void cfg80211_rfkill_sync_work(struct work_struct *work)
294 cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill)); 294 cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
295} 295}
296 296
297static void cfg80211_process_events(struct wireless_dev *wdev)
298{
299 struct cfg80211_event *ev;
300 unsigned long flags;
301
302 spin_lock_irqsave(&wdev->event_lock, flags);
303 while (!list_empty(&wdev->event_list)) {
304 ev = list_first_entry(&wdev->event_list,
305 struct cfg80211_event, list);
306 list_del(&ev->list);
307 spin_unlock_irqrestore(&wdev->event_lock, flags);
308
309 wdev_lock(wdev);
310 switch (ev->type) {
311 case EVENT_CONNECT_RESULT:
312 __cfg80211_connect_result(
313 wdev->netdev, is_zero_ether_addr(ev->cr.bssid) ?
314 NULL : ev->cr.bssid,
315 ev->cr.req_ie, ev->cr.req_ie_len,
316 ev->cr.resp_ie, ev->cr.resp_ie_len,
317 ev->cr.status,
318 ev->cr.status == WLAN_STATUS_SUCCESS,
319 NULL);
320 break;
321 case EVENT_ROAMED:
322 __cfg80211_roamed(wdev, ev->rm.bssid,
323 ev->rm.req_ie, ev->rm.req_ie_len,
324 ev->rm.resp_ie, ev->rm.resp_ie_len);
325 break;
326 case EVENT_DISCONNECTED:
327 __cfg80211_disconnected(wdev->netdev,
328 ev->dc.ie, ev->dc.ie_len,
329 ev->dc.reason, true);
330 break;
331 case EVENT_IBSS_JOINED:
332 __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
333 break;
334 }
335 wdev_unlock(wdev);
336
337 kfree(ev);
338
339 spin_lock_irqsave(&wdev->event_lock, flags);
340 }
341 spin_unlock_irqrestore(&wdev->event_lock, flags);
342}
343
344static void cfg80211_event_work(struct work_struct *work) 297static void cfg80211_event_work(struct work_struct *work)
345{ 298{
346 struct cfg80211_registered_device *rdev; 299 struct cfg80211_registered_device *rdev;
347 struct wireless_dev *wdev;
348 300
349 rdev = container_of(work, struct cfg80211_registered_device, 301 rdev = container_of(work, struct cfg80211_registered_device,
350 event_work); 302 event_work);
351 303
352 rtnl_lock(); 304 rtnl_lock();
353 cfg80211_lock_rdev(rdev); 305 cfg80211_lock_rdev(rdev);
354 mutex_lock(&rdev->devlist_mtx);
355
356 list_for_each_entry(wdev, &rdev->netdev_list, list)
357 cfg80211_process_events(wdev);
358 306
359 mutex_unlock(&rdev->devlist_mtx); 307 cfg80211_process_rdev_events(rdev);
360 cfg80211_unlock_rdev(rdev); 308 cfg80211_unlock_rdev(rdev);
361 rtnl_unlock(); 309 rtnl_unlock();
362} 310}
@@ -664,7 +612,7 @@ static void wdev_cleanup_work(struct work_struct *work)
664 612
665 if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) { 613 if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) {
666 rdev->scan_req->aborted = true; 614 rdev->scan_req->aborted = true;
667 ___cfg80211_scan_done(rdev); 615 ___cfg80211_scan_done(rdev, true);
668 } 616 }
669 617
670 cfg80211_unlock_rdev(rdev); 618 cfg80211_unlock_rdev(rdev);
@@ -755,6 +703,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
755 default: 703 default:
756 break; 704 break;
757 } 705 }
706 break;
707 case NETDEV_DOWN:
758 dev_hold(dev); 708 dev_hold(dev);
759 schedule_work(&wdev->cleanup_work); 709 schedule_work(&wdev->cleanup_work);
760 break; 710 break;
diff --git a/net/wireless/core.h b/net/wireless/core.h
index f565432ae22f..2a33d8bc886b 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -370,8 +370,12 @@ void cfg80211_sme_scan_done(struct net_device *dev);
370void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len); 370void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len);
371void cfg80211_sme_disassoc(struct net_device *dev, int idx); 371void cfg80211_sme_disassoc(struct net_device *dev, int idx);
372void __cfg80211_scan_done(struct work_struct *wk); 372void __cfg80211_scan_done(struct work_struct *wk);
373void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev); 373void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak);
374void cfg80211_upload_connect_keys(struct wireless_dev *wdev); 374void cfg80211_upload_connect_keys(struct wireless_dev *wdev);
375int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
376 struct net_device *dev, enum nl80211_iftype ntype,
377 u32 *flags, struct vif_params *params);
378void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev);
375 379
376struct ieee80211_channel * 380struct ieee80211_channel *
377rdev_fixed_channel(struct cfg80211_registered_device *rdev, 381rdev_fixed_channel(struct cfg80211_registered_device *rdev,
@@ -380,4 +384,15 @@ int rdev_set_freq(struct cfg80211_registered_device *rdev,
380 struct wireless_dev *for_wdev, 384 struct wireless_dev *for_wdev,
381 int freq, enum nl80211_channel_type channel_type); 385 int freq, enum nl80211_channel_type channel_type);
382 386
387#ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
388#define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond)
389#else
390/*
391 * Trick to enable using it as a condition,
392 * and also not give a warning when it's
393 * not used that way.
394 */
395#define CFG80211_DEV_WARN_ON(cond) ({bool __r = (cond); __r; })
396#endif
397
383#endif /* __NET_WIRELESS_CORE_H */ 398#endif /* __NET_WIRELESS_CORE_H */
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 42840a01be74..c88338911979 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -22,7 +22,7 @@ void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid)
22 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) 22 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
23 return; 23 return;
24 24
25 if (WARN_ON(!wdev->ssid_len)) 25 if (!wdev->ssid_len)
26 return; 26 return;
27 27
28 bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid, 28 bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
@@ -58,6 +58,8 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
58 struct cfg80211_event *ev; 58 struct cfg80211_event *ev;
59 unsigned long flags; 59 unsigned long flags;
60 60
61 CFG80211_DEV_WARN_ON(!wdev->ssid_len);
62
61 ev = kzalloc(sizeof(*ev), gfp); 63 ev = kzalloc(sizeof(*ev), gfp);
62 if (!ev) 64 if (!ev)
63 return; 65 return;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a8aaadeb6773..eddab097435c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -977,12 +977,6 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
977 } 977 }
978 } 978 }
979 979
980 if (!rdev->ops->change_virtual_intf ||
981 !(rdev->wiphy.interface_modes & (1 << ntype))) {
982 err = -EOPNOTSUPP;
983 goto unlock;
984 }
985
986 if (info->attrs[NL80211_ATTR_MESH_ID]) { 980 if (info->attrs[NL80211_ATTR_MESH_ID]) {
987 if (ntype != NL80211_IFTYPE_MESH_POINT) { 981 if (ntype != NL80211_IFTYPE_MESH_POINT) {
988 err = -EINVAL; 982 err = -EINVAL;
@@ -1008,18 +1002,10 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
1008 } 1002 }
1009 1003
1010 if (change) 1004 if (change)
1011 err = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, 1005 err = cfg80211_change_iface(rdev, dev, ntype, flags, &params);
1012 ntype, flags, &params);
1013 else 1006 else
1014 err = 0; 1007 err = 0;
1015 1008
1016 WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype);
1017
1018 if (!err && (ntype != otype)) {
1019 if (otype == NL80211_IFTYPE_ADHOC)
1020 cfg80211_clear_ibss(dev, false);
1021 }
1022
1023 unlock: 1009 unlock:
1024 dev_put(dev); 1010 dev_put(dev);
1025 cfg80211_unlock_rdev(rdev); 1011 cfg80211_unlock_rdev(rdev);
@@ -2195,7 +2181,7 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
2195 2181
2196 if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) { 2182 if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
2197 err = -EOPNOTSUPP; 2183 err = -EOPNOTSUPP;
2198 goto out; 2184 goto out_err;
2199 } 2185 }
2200 2186
2201 while (1) { 2187 while (1) {
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index fe575a24c95c..7043de6221ab 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -18,7 +18,7 @@
18 18
19#define IEEE80211_SCAN_RESULT_EXPIRE (15 * HZ) 19#define IEEE80211_SCAN_RESULT_EXPIRE (15 * HZ)
20 20
21void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev) 21void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
22{ 22{
23 struct cfg80211_scan_request *request; 23 struct cfg80211_scan_request *request;
24 struct net_device *dev; 24 struct net_device *dev;
@@ -26,8 +26,13 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev)
26 union iwreq_data wrqu; 26 union iwreq_data wrqu;
27#endif 27#endif
28 28
29 ASSERT_RDEV_LOCK(rdev);
30
29 request = rdev->scan_req; 31 request = rdev->scan_req;
30 32
33 if (!request)
34 return;
35
31 dev = request->dev; 36 dev = request->dev;
32 37
33 /* 38 /*
@@ -53,7 +58,17 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev)
53 dev_put(dev); 58 dev_put(dev);
54 59
55 rdev->scan_req = NULL; 60 rdev->scan_req = NULL;
56 kfree(request); 61
62 /*
63 * OK. If this is invoked with "leak" then we can't
64 * free this ... but we've cleaned it up anyway. The
65 * driver failed to call the scan_done callback, so
66 * all bets are off, it might still be trying to use
67 * the scan request or not ... if it accesses the dev
68 * in there (it shouldn't anyway) then it may crash.
69 */
70 if (!leak)
71 kfree(request);
57} 72}
58 73
59void __cfg80211_scan_done(struct work_struct *wk) 74void __cfg80211_scan_done(struct work_struct *wk)
@@ -64,7 +79,7 @@ void __cfg80211_scan_done(struct work_struct *wk)
64 scan_done_wk); 79 scan_done_wk);
65 80
66 cfg80211_lock_rdev(rdev); 81 cfg80211_lock_rdev(rdev);
67 ___cfg80211_scan_done(rdev); 82 ___cfg80211_scan_done(rdev, false);
68 cfg80211_unlock_rdev(rdev); 83 cfg80211_unlock_rdev(rdev);
69} 84}
70 85
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 4a8289f9b4f0..68307883ec87 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -351,7 +351,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
351 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) 351 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
352 return; 352 return;
353 353
354 if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING)) 354 if (wdev->sme_state != CFG80211_SME_CONNECTING)
355 return; 355 return;
356 356
357 nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev, 357 nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev,
@@ -445,6 +445,8 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
445 struct cfg80211_event *ev; 445 struct cfg80211_event *ev;
446 unsigned long flags; 446 unsigned long flags;
447 447
448 CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING);
449
448 ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp); 450 ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp);
449 if (!ev) 451 if (!ev)
450 return; 452 return;
@@ -481,7 +483,7 @@ void __cfg80211_roamed(struct wireless_dev *wdev, const u8 *bssid,
481 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) 483 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
482 return; 484 return;
483 485
484 if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED)) 486 if (wdev->sme_state != CFG80211_SME_CONNECTED)
485 return; 487 return;
486 488
487 /* internal error -- how did we get to CONNECTED w/o BSS? */ 489 /* internal error -- how did we get to CONNECTED w/o BSS? */
@@ -540,6 +542,8 @@ void cfg80211_roamed(struct net_device *dev, const u8 *bssid,
540 struct cfg80211_event *ev; 542 struct cfg80211_event *ev;
541 unsigned long flags; 543 unsigned long flags;
542 544
545 CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED);
546
543 ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp); 547 ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp);
544 if (!ev) 548 if (!ev)
545 return; 549 return;
@@ -575,7 +579,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
575 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) 579 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
576 return; 580 return;
577 581
578 if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED)) 582 if (wdev->sme_state != CFG80211_SME_CONNECTED)
579 return; 583 return;
580 584
581 if (wdev->current_bss) { 585 if (wdev->current_bss) {
@@ -639,6 +643,8 @@ void cfg80211_disconnected(struct net_device *dev, u16 reason,
639 struct cfg80211_event *ev; 643 struct cfg80211_event *ev;
640 unsigned long flags; 644 unsigned long flags;
641 645
646 CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED);
647
642 ev = kzalloc(sizeof(*ev) + ie_len, gfp); 648 ev = kzalloc(sizeof(*ev) + ie_len, gfp);
643 if (!ev) 649 if (!ev)
644 return; 650 return;
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 693275a16a26..3fc2df86278f 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -574,3 +574,111 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
574 kfree(wdev->connect_keys); 574 kfree(wdev->connect_keys);
575 wdev->connect_keys = NULL; 575 wdev->connect_keys = NULL;
576} 576}
577
578static void cfg80211_process_wdev_events(struct wireless_dev *wdev)
579{
580 struct cfg80211_event *ev;
581 unsigned long flags;
582 const u8 *bssid = NULL;
583
584 spin_lock_irqsave(&wdev->event_lock, flags);
585 while (!list_empty(&wdev->event_list)) {
586 ev = list_first_entry(&wdev->event_list,
587 struct cfg80211_event, list);
588 list_del(&ev->list);
589 spin_unlock_irqrestore(&wdev->event_lock, flags);
590
591 wdev_lock(wdev);
592 switch (ev->type) {
593 case EVENT_CONNECT_RESULT:
594 if (!is_zero_ether_addr(ev->cr.bssid))
595 bssid = ev->cr.bssid;
596 __cfg80211_connect_result(
597 wdev->netdev, bssid,
598 ev->cr.req_ie, ev->cr.req_ie_len,
599 ev->cr.resp_ie, ev->cr.resp_ie_len,
600 ev->cr.status,
601 ev->cr.status == WLAN_STATUS_SUCCESS,
602 NULL);
603 break;
604 case EVENT_ROAMED:
605 __cfg80211_roamed(wdev, ev->rm.bssid,
606 ev->rm.req_ie, ev->rm.req_ie_len,
607 ev->rm.resp_ie, ev->rm.resp_ie_len);
608 break;
609 case EVENT_DISCONNECTED:
610 __cfg80211_disconnected(wdev->netdev,
611 ev->dc.ie, ev->dc.ie_len,
612 ev->dc.reason, true);
613 break;
614 case EVENT_IBSS_JOINED:
615 __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
616 break;
617 }
618 wdev_unlock(wdev);
619
620 kfree(ev);
621
622 spin_lock_irqsave(&wdev->event_lock, flags);
623 }
624 spin_unlock_irqrestore(&wdev->event_lock, flags);
625}
626
627void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev)
628{
629 struct wireless_dev *wdev;
630
631 ASSERT_RTNL();
632 ASSERT_RDEV_LOCK(rdev);
633
634 mutex_lock(&rdev->devlist_mtx);
635
636 list_for_each_entry(wdev, &rdev->netdev_list, list)
637 cfg80211_process_wdev_events(wdev);
638
639 mutex_unlock(&rdev->devlist_mtx);
640}
641
642int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
643 struct net_device *dev, enum nl80211_iftype ntype,
644 u32 *flags, struct vif_params *params)
645{
646 int err;
647 enum nl80211_iftype otype = dev->ieee80211_ptr->iftype;
648
649 ASSERT_RDEV_LOCK(rdev);
650
651 /* don't support changing VLANs, you just re-create them */
652 if (otype == NL80211_IFTYPE_AP_VLAN)
653 return -EOPNOTSUPP;
654
655 if (!rdev->ops->change_virtual_intf ||
656 !(rdev->wiphy.interface_modes & (1 << ntype)))
657 return -EOPNOTSUPP;
658
659 if (ntype != otype) {
660 switch (otype) {
661 case NL80211_IFTYPE_ADHOC:
662 cfg80211_leave_ibss(rdev, dev, false);
663 break;
664 case NL80211_IFTYPE_STATION:
665 cfg80211_disconnect(rdev, dev,
666 WLAN_REASON_DEAUTH_LEAVING, true);
667 break;
668 case NL80211_IFTYPE_MESH_POINT:
669 /* mesh should be handled? */
670 break;
671 default:
672 break;
673 }
674
675 cfg80211_process_rdev_events(rdev);
676 }
677
678 err = rdev->ops->change_virtual_intf(&rdev->wiphy, dev,
679 ntype, flags, params);
680
681 WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype);
682
683 return err;
684}
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index c12029b1def0..429dd06a4ecc 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -70,18 +70,8 @@ int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
70 enum nl80211_iftype type; 70 enum nl80211_iftype type;
71 int ret; 71 int ret;
72 72
73 if (!wdev)
74 return -EOPNOTSUPP;
75
76 rdev = wiphy_to_dev(wdev->wiphy); 73 rdev = wiphy_to_dev(wdev->wiphy);
77 74
78 if (!rdev->ops->change_virtual_intf)
79 return -EOPNOTSUPP;
80
81 /* don't support changing VLANs, you just re-create them */
82 if (wdev->iftype == NL80211_IFTYPE_AP_VLAN)
83 return -EOPNOTSUPP;
84
85 switch (*mode) { 75 switch (*mode) {
86 case IW_MODE_INFRA: 76 case IW_MODE_INFRA:
87 type = NL80211_IFTYPE_STATION; 77 type = NL80211_IFTYPE_STATION;
@@ -104,9 +94,9 @@ int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
104 94
105 memset(&vifparams, 0, sizeof(vifparams)); 95 memset(&vifparams, 0, sizeof(vifparams));
106 96
107 ret = rdev->ops->change_virtual_intf(wdev->wiphy, dev, type, 97 cfg80211_lock_rdev(rdev);
108 NULL, &vifparams); 98 ret = cfg80211_change_iface(rdev, dev, type, NULL, &vifparams);
109 WARN_ON(!ret && wdev->iftype != type); 99 cfg80211_unlock_rdev(rdev);
110 100
111 return ret; 101 return ret;
112} 102}