aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-09-19 19:17:12 -0400
committerDavid S. Miller <davem@davemloft.net>2008-09-19 19:17:12 -0400
commitd950f264ff7260d8c1e124158d758db13e1ad2d0 (patch)
tree8a8758af70d72b94e51609a5088a5739d00d8793 /drivers
parent04da2cf9bb133355b7073be25ef3ce88c8edc135 (diff)
parent375da53b8e5e3ff2330b66b377e07a6151a93fe5 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/adm8211.c22
-rw-r--r--drivers/net/wireless/ath5k/ath5k.h4
-rw-r--r--drivers/net/wireless/ath5k/attach.c2
-rw-r--r--drivers/net/wireless/ath5k/base.c50
-rw-r--r--drivers/net/wireless/ath5k/base.h2
-rw-r--r--drivers/net/wireless/ath5k/pcu.c12
-rw-r--r--drivers/net/wireless/ath5k/reset.c2
-rw-r--r--drivers/net/wireless/ath9k/ath9k.h7
-rw-r--r--drivers/net/wireless/ath9k/core.h16
-rw-r--r--drivers/net/wireless/ath9k/hw.c70
-rw-r--r--drivers/net/wireless/ath9k/main.c1262
-rw-r--r--drivers/net/wireless/ath9k/rc.c3
-rw-r--r--drivers/net/wireless/b43/b43.h2
-rw-r--r--drivers/net/wireless/b43/main.c43
-rw-r--r--drivers/net/wireless/b43/phy_common.c4
-rw-r--r--drivers/net/wireless/b43legacy/main.c32
-rw-r--r--drivers/net/wireless/b43legacy/phy.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c30
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c66
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c81
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c86
-rw-r--r--drivers/net/wireless/libertas/assoc.c6
-rw-r--r--drivers/net/wireless/libertas/cmd.c198
-rw-r--r--drivers/net/wireless/libertas/cmd.h4
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c47
-rw-r--r--drivers/net/wireless/libertas/defs.h27
-rw-r--r--drivers/net/wireless/libertas/dev.h3
-rw-r--r--drivers/net/wireless/libertas/host.h24
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h10
-rw-r--r--drivers/net/wireless/libertas/if_usb.c5
-rw-r--r--drivers/net/wireless/libertas/wext.c156
-rw-r--r--drivers/net/wireless/libertas_tf/main.c18
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c192
-rw-r--r--drivers/net/wireless/orinoco.c14
-rw-r--r--drivers/net/wireless/p54/p54common.c14
-rw-r--r--drivers/net/wireless/p54/p54pci.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c18
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c21
-rw-r--r--drivers/net/wireless/rtl8180_dev.c10
-rw-r--r--drivers/net/wireless/rtl8187_dev.c8
-rw-r--r--drivers/net/wireless/zd1211rw/Makefile2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c100
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h95
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c60
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h65
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.c2
62 files changed, 1588 insertions, 1396 deletions
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index c6a55cd12db9..b2c050b68890 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -765,11 +765,11 @@ static void adm8211_update_mode(struct ieee80211_hw *dev)
765 765
766 priv->soft_rx_crc = 0; 766 priv->soft_rx_crc = 0;
767 switch (priv->mode) { 767 switch (priv->mode) {
768 case IEEE80211_IF_TYPE_STA: 768 case NL80211_IFTYPE_STATION:
769 priv->nar &= ~(ADM8211_NAR_PR | ADM8211_NAR_EA); 769 priv->nar &= ~(ADM8211_NAR_PR | ADM8211_NAR_EA);
770 priv->nar |= ADM8211_NAR_ST | ADM8211_NAR_SR; 770 priv->nar |= ADM8211_NAR_ST | ADM8211_NAR_SR;
771 break; 771 break;
772 case IEEE80211_IF_TYPE_IBSS: 772 case NL80211_IFTYPE_ADHOC:
773 priv->nar &= ~ADM8211_NAR_PR; 773 priv->nar &= ~ADM8211_NAR_PR;
774 priv->nar |= ADM8211_NAR_EA | ADM8211_NAR_ST | ADM8211_NAR_SR; 774 priv->nar |= ADM8211_NAR_EA | ADM8211_NAR_ST | ADM8211_NAR_SR;
775 775
@@ -777,7 +777,7 @@ static void adm8211_update_mode(struct ieee80211_hw *dev)
777 if (priv->pdev->revision >= ADM8211_REV_BA) 777 if (priv->pdev->revision >= ADM8211_REV_BA)
778 priv->soft_rx_crc = 1; 778 priv->soft_rx_crc = 1;
779 break; 779 break;
780 case IEEE80211_IF_TYPE_MNTR: 780 case NL80211_IFTYPE_MONITOR:
781 priv->nar &= ~(ADM8211_NAR_EA | ADM8211_NAR_ST); 781 priv->nar &= ~(ADM8211_NAR_EA | ADM8211_NAR_ST);
782 priv->nar |= ADM8211_NAR_PR | ADM8211_NAR_SR; 782 priv->nar |= ADM8211_NAR_PR | ADM8211_NAR_SR;
783 break; 783 break;
@@ -1410,11 +1410,11 @@ static int adm8211_add_interface(struct ieee80211_hw *dev,
1410 struct ieee80211_if_init_conf *conf) 1410 struct ieee80211_if_init_conf *conf)
1411{ 1411{
1412 struct adm8211_priv *priv = dev->priv; 1412 struct adm8211_priv *priv = dev->priv;
1413 if (priv->mode != IEEE80211_IF_TYPE_MNTR) 1413 if (priv->mode != NL80211_IFTYPE_MONITOR)
1414 return -EOPNOTSUPP; 1414 return -EOPNOTSUPP;
1415 1415
1416 switch (conf->type) { 1416 switch (conf->type) {
1417 case IEEE80211_IF_TYPE_STA: 1417 case NL80211_IFTYPE_STATION:
1418 priv->mode = conf->type; 1418 priv->mode = conf->type;
1419 break; 1419 break;
1420 default: 1420 default:
@@ -1437,7 +1437,7 @@ static void adm8211_remove_interface(struct ieee80211_hw *dev,
1437 struct ieee80211_if_init_conf *conf) 1437 struct ieee80211_if_init_conf *conf)
1438{ 1438{
1439 struct adm8211_priv *priv = dev->priv; 1439 struct adm8211_priv *priv = dev->priv;
1440 priv->mode = IEEE80211_IF_TYPE_MNTR; 1440 priv->mode = NL80211_IFTYPE_MONITOR;
1441} 1441}
1442 1442
1443static int adm8211_init_rings(struct ieee80211_hw *dev) 1443static int adm8211_init_rings(struct ieee80211_hw *dev)
@@ -1556,7 +1556,7 @@ static int adm8211_start(struct ieee80211_hw *dev)
1556 ADM8211_CSR_WRITE(IER, ADM8211_IER_NIE | ADM8211_IER_AIE | 1556 ADM8211_CSR_WRITE(IER, ADM8211_IER_NIE | ADM8211_IER_AIE |
1557 ADM8211_IER_RCIE | ADM8211_IER_TCIE | 1557 ADM8211_IER_RCIE | ADM8211_IER_TCIE |
1558 ADM8211_IER_TDUIE | ADM8211_IER_GPTIE); 1558 ADM8211_IER_TDUIE | ADM8211_IER_GPTIE);
1559 priv->mode = IEEE80211_IF_TYPE_MNTR; 1559 priv->mode = NL80211_IFTYPE_MONITOR;
1560 adm8211_update_mode(dev); 1560 adm8211_update_mode(dev);
1561 ADM8211_CSR_WRITE(RDR, 0); 1561 ADM8211_CSR_WRITE(RDR, 0);
1562 1562
@@ -1571,7 +1571,7 @@ static void adm8211_stop(struct ieee80211_hw *dev)
1571{ 1571{
1572 struct adm8211_priv *priv = dev->priv; 1572 struct adm8211_priv *priv = dev->priv;
1573 1573
1574 priv->mode = IEEE80211_IF_TYPE_INVALID; 1574 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1575 priv->nar = 0; 1575 priv->nar = 0;
1576 ADM8211_CSR_WRITE(NAR, 0); 1576 ADM8211_CSR_WRITE(NAR, 0);
1577 ADM8211_CSR_WRITE(IER, 0); 1577 ADM8211_CSR_WRITE(IER, 0);
@@ -1896,7 +1896,7 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
1896 priv->tx_power = 0x40; 1896 priv->tx_power = 0x40;
1897 priv->lpf_cutoff = 0xFF; 1897 priv->lpf_cutoff = 0xFF;
1898 priv->lnags_threshold = 0xFF; 1898 priv->lnags_threshold = 0xFF;
1899 priv->mode = IEEE80211_IF_TYPE_INVALID; 1899 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1900 1900
1901 /* Power-on issue. EEPROM won't read correctly without */ 1901 /* Power-on issue. EEPROM won't read correctly without */
1902 if (pdev->revision >= ADM8211_REV_BA) { 1902 if (pdev->revision >= ADM8211_REV_BA) {
@@ -1986,7 +1986,7 @@ static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
1986 struct ieee80211_hw *dev = pci_get_drvdata(pdev); 1986 struct ieee80211_hw *dev = pci_get_drvdata(pdev);
1987 struct adm8211_priv *priv = dev->priv; 1987 struct adm8211_priv *priv = dev->priv;
1988 1988
1989 if (priv->mode != IEEE80211_IF_TYPE_INVALID) { 1989 if (priv->mode != NL80211_IFTYPE_UNSPECIFIED) {
1990 ieee80211_stop_queues(dev); 1990 ieee80211_stop_queues(dev);
1991 adm8211_stop(dev); 1991 adm8211_stop(dev);
1992 } 1992 }
@@ -2004,7 +2004,7 @@ static int adm8211_resume(struct pci_dev *pdev)
2004 pci_set_power_state(pdev, PCI_D0); 2004 pci_set_power_state(pdev, PCI_D0);
2005 pci_restore_state(pdev); 2005 pci_restore_state(pdev);
2006 2006
2007 if (priv->mode != IEEE80211_IF_TYPE_INVALID) { 2007 if (priv->mode != NL80211_IFTYPE_UNSPECIFIED) {
2008 adm8211_start(dev); 2008 adm8211_start(dev);
2009 ieee80211_wake_queues(dev); 2009 ieee80211_wake_queues(dev);
2010 } 2010 }
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h
index 4c0211798a7a..20018869051d 100644
--- a/drivers/net/wireless/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath5k/ath5k.h
@@ -1008,7 +1008,7 @@ struct ath5k_hw {
1008 1008
1009 enum ath5k_int ah_imr; 1009 enum ath5k_int ah_imr;
1010 1010
1011 enum ieee80211_if_types ah_op_mode; 1011 enum nl80211_iftype ah_op_mode;
1012 enum ath5k_power_mode ah_power_mode; 1012 enum ath5k_power_mode ah_power_mode;
1013 struct ieee80211_channel ah_current_channel; 1013 struct ieee80211_channel ah_current_channel;
1014 bool ah_turbo; 1014 bool ah_turbo;
@@ -1117,7 +1117,7 @@ extern void ath5k_hw_detach(struct ath5k_hw *ah);
1117 1117
1118/* Reset Functions */ 1118/* Reset Functions */
1119extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); 1119extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial);
1120extern int ath5k_hw_reset(struct ath5k_hw *ah, enum ieee80211_if_types op_mode, struct ieee80211_channel *channel, bool change_channel); 1120extern int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, struct ieee80211_channel *channel, bool change_channel);
1121/* Power management functions */ 1121/* Power management functions */
1122extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration); 1122extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration);
1123 1123
diff --git a/drivers/net/wireless/ath5k/attach.c b/drivers/net/wireless/ath5k/attach.c
index 0eb2511fe147..153c4111fabe 100644
--- a/drivers/net/wireless/ath5k/attach.c
+++ b/drivers/net/wireless/ath5k/attach.c
@@ -124,7 +124,7 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
124 /* 124 /*
125 * HW information 125 * HW information
126 */ 126 */
127 ah->ah_op_mode = IEEE80211_IF_TYPE_STA; 127 ah->ah_op_mode = NL80211_IFTYPE_STATION;
128 ah->ah_radar.r_enabled = AR5K_TUNE_RADAR_ALERT; 128 ah->ah_radar.r_enabled = AR5K_TUNE_RADAR_ALERT;
129 ah->ah_turbo = false; 129 ah->ah_turbo = false;
130 ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER; 130 ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER;
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index 85260c39aa2b..e09ed2ce6753 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -507,7 +507,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
507 507
508 sc->iobase = mem; /* So we can unmap it on detach */ 508 sc->iobase = mem; /* So we can unmap it on detach */
509 sc->cachelsz = csz * sizeof(u32); /* convert to bytes */ 509 sc->cachelsz = csz * sizeof(u32); /* convert to bytes */
510 sc->opmode = IEEE80211_IF_TYPE_STA; 510 sc->opmode = NL80211_IFTYPE_STATION;
511 mutex_init(&sc->lock); 511 mutex_init(&sc->lock);
512 spin_lock_init(&sc->rxbuflock); 512 spin_lock_init(&sc->rxbuflock);
513 spin_lock_init(&sc->txbuflock); 513 spin_lock_init(&sc->txbuflock);
@@ -1377,8 +1377,8 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
1377 ret = ath5k_hw_get_tx_queueprops(ah, sc->bhalq, &qi); 1377 ret = ath5k_hw_get_tx_queueprops(ah, sc->bhalq, &qi);
1378 if (ret) 1378 if (ret)
1379 return ret; 1379 return ret;
1380 if (sc->opmode == IEEE80211_IF_TYPE_AP || 1380 if (sc->opmode == NL80211_IFTYPE_AP ||
1381 sc->opmode == IEEE80211_IF_TYPE_MESH_POINT) { 1381 sc->opmode == NL80211_IFTYPE_MESH_POINT) {
1382 /* 1382 /*
1383 * Always burst out beacon and CAB traffic 1383 * Always burst out beacon and CAB traffic
1384 * (aifs = cwmin = cwmax = 0) 1384 * (aifs = cwmin = cwmax = 0)
@@ -1386,7 +1386,7 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
1386 qi.tqi_aifs = 0; 1386 qi.tqi_aifs = 0;
1387 qi.tqi_cw_min = 0; 1387 qi.tqi_cw_min = 0;
1388 qi.tqi_cw_max = 0; 1388 qi.tqi_cw_max = 0;
1389 } else if (sc->opmode == IEEE80211_IF_TYPE_IBSS) { 1389 } else if (sc->opmode == NL80211_IFTYPE_ADHOC) {
1390 /* 1390 /*
1391 * Adhoc mode; backoff between 0 and (2 * cw_min). 1391 * Adhoc mode; backoff between 0 and (2 * cw_min).
1392 */ 1392 */
@@ -1714,7 +1714,7 @@ ath5k_tasklet_rx(unsigned long data)
1714 /* let crypto-error packets fall through in MNTR */ 1714 /* let crypto-error packets fall through in MNTR */
1715 if ((rs.rs_status & 1715 if ((rs.rs_status &
1716 ~(AR5K_RXERR_DECRYPT|AR5K_RXERR_MIC)) || 1716 ~(AR5K_RXERR_DECRYPT|AR5K_RXERR_MIC)) ||
1717 sc->opmode != IEEE80211_IF_TYPE_MNTR) 1717 sc->opmode != NL80211_IFTYPE_MONITOR)
1718 goto next; 1718 goto next;
1719 } 1719 }
1720accept: 1720accept:
@@ -1777,7 +1777,7 @@ accept:
1777 ath5k_debug_dump_skb(sc, skb, "RX ", 0); 1777 ath5k_debug_dump_skb(sc, skb, "RX ", 0);
1778 1778
1779 /* check beacons in IBSS mode */ 1779 /* check beacons in IBSS mode */
1780 if (sc->opmode == IEEE80211_IF_TYPE_IBSS) 1780 if (sc->opmode == NL80211_IFTYPE_ADHOC)
1781 ath5k_check_ibss_tsf(sc, skb, &rxs); 1781 ath5k_check_ibss_tsf(sc, skb, &rxs);
1782 1782
1783 __ieee80211_rx(sc->hw, skb, &rxs); 1783 __ieee80211_rx(sc->hw, skb, &rxs);
@@ -1892,7 +1892,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1892 ds = bf->desc; 1892 ds = bf->desc;
1893 1893
1894 flags = AR5K_TXDESC_NOACK; 1894 flags = AR5K_TXDESC_NOACK;
1895 if (sc->opmode == IEEE80211_IF_TYPE_IBSS && ath5k_hw_hasveol(ah)) { 1895 if (sc->opmode == NL80211_IFTYPE_ADHOC && ath5k_hw_hasveol(ah)) {
1896 ds->ds_link = bf->daddr; /* self-linked */ 1896 ds->ds_link = bf->daddr; /* self-linked */
1897 flags |= AR5K_TXDESC_VEOL; 1897 flags |= AR5K_TXDESC_VEOL;
1898 /* 1898 /*
@@ -1941,8 +1941,8 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1941 1941
1942 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "in beacon_send\n"); 1942 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "in beacon_send\n");
1943 1943
1944 if (unlikely(bf->skb == NULL || sc->opmode == IEEE80211_IF_TYPE_STA || 1944 if (unlikely(bf->skb == NULL || sc->opmode == NL80211_IFTYPE_STATION ||
1945 sc->opmode == IEEE80211_IF_TYPE_MNTR)) { 1945 sc->opmode == NL80211_IFTYPE_MONITOR)) {
1946 ATH5K_WARN(sc, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL); 1946 ATH5K_WARN(sc, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL);
1947 return; 1947 return;
1948 } 1948 }
@@ -2116,9 +2116,9 @@ ath5k_beacon_config(struct ath5k_softc *sc)
2116 sc->bmisscount = 0; 2116 sc->bmisscount = 0;
2117 sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA); 2117 sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA);
2118 2118
2119 if (sc->opmode == IEEE80211_IF_TYPE_STA) { 2119 if (sc->opmode == NL80211_IFTYPE_STATION) {
2120 sc->imask |= AR5K_INT_BMISS; 2120 sc->imask |= AR5K_INT_BMISS;
2121 } else if (sc->opmode == IEEE80211_IF_TYPE_IBSS) { 2121 } else if (sc->opmode == NL80211_IFTYPE_ADHOC) {
2122 /* 2122 /*
2123 * In IBSS mode we use a self-linked tx descriptor and let the 2123 * In IBSS mode we use a self-linked tx descriptor and let the
2124 * hardware send the beacons automatically. We have to load it 2124 * hardware send the beacons automatically. We have to load it
@@ -2323,7 +2323,7 @@ ath5k_intr(int irq, void *dev_id)
2323 * transmission time) in order to detect wether 2323 * transmission time) in order to detect wether
2324 * automatic TSF updates happened. 2324 * automatic TSF updates happened.
2325 */ 2325 */
2326 if (sc->opmode == IEEE80211_IF_TYPE_IBSS) { 2326 if (sc->opmode == NL80211_IFTYPE_ADHOC) {
2327 /* XXX: only if VEOL suppported */ 2327 /* XXX: only if VEOL suppported */
2328 u64 tsf = ath5k_hw_get_tsf64(ah); 2328 u64 tsf = ath5k_hw_get_tsf64(ah);
2329 sc->nexttbtt += sc->bintval; 2329 sc->nexttbtt += sc->bintval;
@@ -2553,7 +2553,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2553 2553
2554 ath5k_debug_dump_skb(sc, skb, "TX ", 1); 2554 ath5k_debug_dump_skb(sc, skb, "TX ", 1);
2555 2555
2556 if (sc->opmode == IEEE80211_IF_TYPE_MNTR) 2556 if (sc->opmode == NL80211_IFTYPE_MONITOR)
2557 ATH5K_DBG(sc, ATH5K_DEBUG_XMIT, "tx in monitor (scan?)\n"); 2557 ATH5K_DBG(sc, ATH5K_DEBUG_XMIT, "tx in monitor (scan?)\n");
2558 2558
2559 /* 2559 /*
@@ -2688,9 +2688,9 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
2688 sc->vif = conf->vif; 2688 sc->vif = conf->vif;
2689 2689
2690 switch (conf->type) { 2690 switch (conf->type) {
2691 case IEEE80211_IF_TYPE_STA: 2691 case NL80211_IFTYPE_STATION:
2692 case IEEE80211_IF_TYPE_IBSS: 2692 case NL80211_IFTYPE_ADHOC:
2693 case IEEE80211_IF_TYPE_MNTR: 2693 case NL80211_IFTYPE_MONITOR:
2694 sc->opmode = conf->type; 2694 sc->opmode = conf->type;
2695 break; 2695 break;
2696 default: 2696 default:
@@ -2761,7 +2761,7 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2761 } 2761 }
2762 2762
2763 if (conf->changed & IEEE80211_IFCC_BEACON && 2763 if (conf->changed & IEEE80211_IFCC_BEACON &&
2764 vif->type == IEEE80211_IF_TYPE_IBSS) { 2764 vif->type == NL80211_IFTYPE_ADHOC) {
2765 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 2765 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2766 if (!beacon) { 2766 if (!beacon) {
2767 ret = -ENOMEM; 2767 ret = -ENOMEM;
@@ -2880,17 +2880,17 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
2880 2880
2881 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */ 2881 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */
2882 2882
2883 if (sc->opmode == IEEE80211_IF_TYPE_MNTR) 2883 if (sc->opmode == NL80211_IFTYPE_MONITOR)
2884 rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON | 2884 rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON |
2885 AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM; 2885 AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM;
2886 if (sc->opmode != IEEE80211_IF_TYPE_STA) 2886 if (sc->opmode != NL80211_IFTYPE_STATION)
2887 rfilt |= AR5K_RX_FILTER_PROBEREQ; 2887 rfilt |= AR5K_RX_FILTER_PROBEREQ;
2888 if (sc->opmode != IEEE80211_IF_TYPE_AP && 2888 if (sc->opmode != NL80211_IFTYPE_AP &&
2889 sc->opmode != IEEE80211_IF_TYPE_MESH_POINT && 2889 sc->opmode != NL80211_IFTYPE_MESH_POINT &&
2890 test_bit(ATH_STAT_PROMISC, sc->status)) 2890 test_bit(ATH_STAT_PROMISC, sc->status))
2891 rfilt |= AR5K_RX_FILTER_PROM; 2891 rfilt |= AR5K_RX_FILTER_PROM;
2892 if (sc->opmode == IEEE80211_IF_TYPE_STA || 2892 if (sc->opmode == NL80211_IFTYPE_STATION ||
2893 sc->opmode == IEEE80211_IF_TYPE_IBSS) { 2893 sc->opmode == NL80211_IFTYPE_ADHOC) {
2894 rfilt |= AR5K_RX_FILTER_BEACON; 2894 rfilt |= AR5K_RX_FILTER_BEACON;
2895 } 2895 }
2896 2896
@@ -2995,7 +2995,7 @@ ath5k_reset_tsf(struct ieee80211_hw *hw)
2995 * in IBSS mode we need to update the beacon timers too. 2995 * in IBSS mode we need to update the beacon timers too.
2996 * this will also reset the TSF if we call it with 0 2996 * this will also reset the TSF if we call it with 0
2997 */ 2997 */
2998 if (sc->opmode == IEEE80211_IF_TYPE_IBSS) 2998 if (sc->opmode == NL80211_IFTYPE_ADHOC)
2999 ath5k_beacon_update_timers(sc, 0); 2999 ath5k_beacon_update_timers(sc, 0);
3000 else 3000 else
3001 ath5k_hw_reset_tsf(sc->ah); 3001 ath5k_hw_reset_tsf(sc->ah);
@@ -3010,7 +3010,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
3010 3010
3011 ath5k_debug_dump_skb(sc, skb, "BC ", 1); 3011 ath5k_debug_dump_skb(sc, skb, "BC ", 1);
3012 3012
3013 if (sc->opmode != IEEE80211_IF_TYPE_IBSS) { 3013 if (sc->opmode != NL80211_IFTYPE_ADHOC) {
3014 ret = -EIO; 3014 ret = -EIO;
3015 goto end; 3015 goto end;
3016 } 3016 }
diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath5k/base.h
index 1549b63d6138..9d0b728928e3 100644
--- a/drivers/net/wireless/ath5k/base.h
+++ b/drivers/net/wireless/ath5k/base.h
@@ -113,7 +113,7 @@ struct ath5k_softc {
113 struct ieee80211_channel channels[ATH_CHAN_MAX]; 113 struct ieee80211_channel channels[ATH_CHAN_MAX];
114 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES]; 114 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
115 u8 rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES]; 115 u8 rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
116 enum ieee80211_if_types opmode; 116 enum nl80211_iftype opmode;
117 struct ath5k_hw *ah; /* Atheros HW */ 117 struct ath5k_hw *ah; /* Atheros HW */
118 118
119 struct ieee80211_supported_band *curband; 119 struct ieee80211_supported_band *curband;
diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath5k/pcu.c
index 5a896d1e2a2b..c77cee2a5582 100644
--- a/drivers/net/wireless/ath5k/pcu.c
+++ b/drivers/net/wireless/ath5k/pcu.c
@@ -52,26 +52,26 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
52 ATH5K_TRACE(ah->ah_sc); 52 ATH5K_TRACE(ah->ah_sc);
53 53
54 switch (ah->ah_op_mode) { 54 switch (ah->ah_op_mode) {
55 case IEEE80211_IF_TYPE_IBSS: 55 case NL80211_IFTYPE_ADHOC:
56 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_DESC_ANTENNA | 56 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_DESC_ANTENNA |
57 (ah->ah_version == AR5K_AR5210 ? 57 (ah->ah_version == AR5K_AR5210 ?
58 AR5K_STA_ID1_NO_PSPOLL : 0); 58 AR5K_STA_ID1_NO_PSPOLL : 0);
59 beacon_reg |= AR5K_BCR_ADHOC; 59 beacon_reg |= AR5K_BCR_ADHOC;
60 break; 60 break;
61 61
62 case IEEE80211_IF_TYPE_AP: 62 case NL80211_IFTYPE_AP:
63 case IEEE80211_IF_TYPE_MESH_POINT: 63 case NL80211_IFTYPE_MESH_POINT:
64 pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_RTS_DEF_ANTENNA | 64 pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_RTS_DEF_ANTENNA |
65 (ah->ah_version == AR5K_AR5210 ? 65 (ah->ah_version == AR5K_AR5210 ?
66 AR5K_STA_ID1_NO_PSPOLL : 0); 66 AR5K_STA_ID1_NO_PSPOLL : 0);
67 beacon_reg |= AR5K_BCR_AP; 67 beacon_reg |= AR5K_BCR_AP;
68 break; 68 break;
69 69
70 case IEEE80211_IF_TYPE_STA: 70 case NL80211_IFTYPE_STATION:
71 pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA | 71 pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA |
72 (ah->ah_version == AR5K_AR5210 ? 72 (ah->ah_version == AR5K_AR5210 ?
73 AR5K_STA_ID1_PWR_SV : 0); 73 AR5K_STA_ID1_PWR_SV : 0);
74 case IEEE80211_IF_TYPE_MNTR: 74 case NL80211_IFTYPE_MONITOR:
75 pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA | 75 pcu_reg |= AR5K_STA_ID1_DEFAULT_ANTENNA |
76 (ah->ah_version == AR5K_AR5210 ? 76 (ah->ah_version == AR5K_AR5210 ?
77 AR5K_STA_ID1_NO_PSPOLL : 0); 77 AR5K_STA_ID1_NO_PSPOLL : 0);
@@ -649,7 +649,7 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
649 * Set the additional timers by mode 649 * Set the additional timers by mode
650 */ 650 */
651 switch (ah->ah_op_mode) { 651 switch (ah->ah_op_mode) {
652 case IEEE80211_IF_TYPE_STA: 652 case NL80211_IFTYPE_STATION:
653 if (ah->ah_version == AR5K_AR5210) { 653 if (ah->ah_version == AR5K_AR5210) {
654 timer1 = 0xffffffff; 654 timer1 = 0xffffffff;
655 timer2 = 0xffffffff; 655 timer2 = 0xffffffff;
diff --git a/drivers/net/wireless/ath5k/reset.c b/drivers/net/wireless/ath5k/reset.c
index d260fba0180f..f5c3de890cdb 100644
--- a/drivers/net/wireless/ath5k/reset.c
+++ b/drivers/net/wireless/ath5k/reset.c
@@ -399,7 +399,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
399/* 399/*
400 * Main reset function 400 * Main reset function
401 */ 401 */
402int ath5k_hw_reset(struct ath5k_hw *ah, enum ieee80211_if_types op_mode, 402int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
403 struct ieee80211_channel *channel, bool change_channel) 403 struct ieee80211_channel *channel, bool change_channel)
404{ 404{
405 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 405 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h
index 28b8d84f49b4..0e897c276858 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath9k/ath9k.h
@@ -798,10 +798,11 @@ struct ath_hal {
798 struct ath9k_channel *ah_curchan; 798 struct ath9k_channel *ah_curchan;
799 u32 ah_nchan; 799 u32 ah_nchan;
800 800
801 u16 ah_rfsilent;
802 bool ah_rfkillEnabled;
803 bool ah_isPciExpress; 801 bool ah_isPciExpress;
804 u16 ah_txTrigLevel; 802 u16 ah_txTrigLevel;
803 u16 ah_rfsilent;
804 u32 ah_rfkill_gpio;
805 u32 ah_rfkill_polarity;
805 806
806#ifndef ATH_NF_PER_CHAN 807#ifndef ATH_NF_PER_CHAN
807 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 808 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
@@ -1003,4 +1004,6 @@ bool ath9k_get_channel_edges(struct ath_hal *ah,
1003void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio, 1004void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio,
1004 u32 ah_signal_type); 1005 u32 ah_signal_type);
1005void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 value); 1006void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 value);
1007u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio);
1008void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio);
1006#endif 1009#endif
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 1faa1effa02c..b66de29cf662 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -40,6 +40,7 @@
40#include <asm/page.h> 40#include <asm/page.h>
41#include <net/mac80211.h> 41#include <net/mac80211.h>
42#include <linux/leds.h> 42#include <linux/leds.h>
43#include <linux/rfkill.h>
43 44
44#include "ath9k.h" 45#include "ath9k.h"
45#include "rc.h" 46#include "rc.h"
@@ -823,6 +824,15 @@ struct ath_led {
823 bool registered; 824 bool registered;
824}; 825};
825 826
827/* Rfkill */
828#define ATH_RFKILL_POLL_INTERVAL 2000 /* msecs */
829
830struct ath_rfkill {
831 struct rfkill *rfkill;
832 struct delayed_work rfkill_poll;
833 char rfkill_name[32];
834};
835
826/********************/ 836/********************/
827/* Main driver core */ 837/* Main driver core */
828/********************/ 838/********************/
@@ -906,6 +916,9 @@ struct ath_ht_info {
906#define SC_OP_PROTECT_ENABLE BIT(8) 916#define SC_OP_PROTECT_ENABLE BIT(8)
907#define SC_OP_RXFLUSH BIT(9) 917#define SC_OP_RXFLUSH BIT(9)
908#define SC_OP_LED_ASSOCIATED BIT(10) 918#define SC_OP_LED_ASSOCIATED BIT(10)
919#define SC_OP_RFKILL_REGISTERED BIT(11)
920#define SC_OP_RFKILL_SW_BLOCKED BIT(12)
921#define SC_OP_RFKILL_HW_BLOCKED BIT(13)
909 922
910struct ath_softc { 923struct ath_softc {
911 struct ieee80211_hw *hw; 924 struct ieee80211_hw *hw;
@@ -1015,6 +1028,9 @@ struct ath_softc {
1015 struct ath_led assoc_led; 1028 struct ath_led assoc_led;
1016 struct ath_led tx_led; 1029 struct ath_led tx_led;
1017 struct ath_led rx_led; 1030 struct ath_led rx_led;
1031
1032 /* Rfkill */
1033 struct ath_rfkill rf_kill;
1018}; 1034};
1019 1035
1020int ath_init(u16 devid, struct ath_softc *sc); 1036int ath_init(u16 devid, struct ath_softc *sc);
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index 4ccbbc07cf1e..0251e59f2f84 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -2821,7 +2821,38 @@ void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 val)
2821 AR_GPIO_BIT(gpio)); 2821 AR_GPIO_BIT(gpio));
2822} 2822}
2823 2823
2824static u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio) 2824/*
2825 * Configure GPIO Input lines
2826 */
2827void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio)
2828{
2829 u32 gpio_shift;
2830
2831 ASSERT(gpio < ah->ah_caps.num_gpio_pins);
2832
2833 gpio_shift = gpio << 1;
2834
2835 REG_RMW(ah,
2836 AR_GPIO_OE_OUT,
2837 (AR_GPIO_OE_OUT_DRV_NO << gpio_shift),
2838 (AR_GPIO_OE_OUT_DRV << gpio_shift));
2839}
2840
2841#ifdef CONFIG_RFKILL
2842static void ath9k_enable_rfkill(struct ath_hal *ah)
2843{
2844 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
2845 AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
2846
2847 REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2,
2848 AR_GPIO_INPUT_MUX2_RFSILENT);
2849
2850 ath9k_hw_cfg_gpio_input(ah, ah->ah_rfkill_gpio);
2851 REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
2852}
2853#endif
2854
2855u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio)
2825{ 2856{
2826 if (gpio >= ah->ah_caps.num_gpio_pins) 2857 if (gpio >= ah->ah_caps.num_gpio_pins)
2827 return 0xffffffff; 2858 return 0xffffffff;
@@ -3034,17 +3065,17 @@ static bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
3034 3065
3035 pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM; 3066 pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM;
3036 3067
3068#ifdef CONFIG_RFKILL
3037 ah->ah_rfsilent = ath9k_hw_get_eeprom(ahp, EEP_RF_SILENT); 3069 ah->ah_rfsilent = ath9k_hw_get_eeprom(ahp, EEP_RF_SILENT);
3038 if (ah->ah_rfsilent & EEP_RFSILENT_ENABLED) { 3070 if (ah->ah_rfsilent & EEP_RFSILENT_ENABLED) {
3039 ahp->ah_gpioSelect = 3071 ah->ah_rfkill_gpio =
3040 MS(ah->ah_rfsilent, EEP_RFSILENT_GPIO_SEL); 3072 MS(ah->ah_rfsilent, EEP_RFSILENT_GPIO_SEL);
3041 ahp->ah_polarity = 3073 ah->ah_rfkill_polarity =
3042 MS(ah->ah_rfsilent, EEP_RFSILENT_POLARITY); 3074 MS(ah->ah_rfsilent, EEP_RFSILENT_POLARITY);
3043 3075
3044 ath9k_hw_setcapability(ah, ATH9K_CAP_RFSILENT, 1, true,
3045 NULL);
3046 pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT; 3076 pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT;
3047 } 3077 }
3078#endif
3048 3079
3049 if ((ah->ah_macVersion == AR_SREV_VERSION_5416_PCI) || 3080 if ((ah->ah_macVersion == AR_SREV_VERSION_5416_PCI) ||
3050 (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE) || 3081 (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE) ||
@@ -5961,6 +5992,10 @@ bool ath9k_hw_reset(struct ath_hal *ah,
5961 ath9k_hw_init_interrupt_masks(ah, ah->ah_opmode); 5992 ath9k_hw_init_interrupt_masks(ah, ah->ah_opmode);
5962 ath9k_hw_init_qos(ah); 5993 ath9k_hw_init_qos(ah);
5963 5994
5995#ifdef CONFIG_RFKILL
5996 if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
5997 ath9k_enable_rfkill(ah);
5998#endif
5964 ath9k_hw_init_user_settings(ah); 5999 ath9k_hw_init_user_settings(ah);
5965 6000
5966 REG_WRITE(ah, AR_STA_ID1, 6001 REG_WRITE(ah, AR_STA_ID1,
@@ -6490,31 +6525,6 @@ ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask)
6490 return true; 6525 return true;
6491} 6526}
6492 6527
6493#ifdef CONFIG_ATH9K_RFKILL
6494static void ath9k_enable_rfkill(struct ath_hal *ah)
6495{
6496 struct ath_hal_5416 *ahp = AH5416(ah);
6497
6498 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
6499 AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
6500
6501 REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2,
6502 AR_GPIO_INPUT_MUX2_RFSILENT);
6503
6504 ath9k_hw_cfg_gpio_input(ah, ahp->ah_gpioSelect);
6505 REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
6506
6507 if (ahp->ah_gpioBit == ath9k_hw_gpio_get(ah, ahp->ah_gpioSelect)) {
6508
6509 ath9k_hw_set_gpio_intr(ah, ahp->ah_gpioSelect,
6510 !ahp->ah_gpioBit);
6511 } else {
6512 ath9k_hw_set_gpio_intr(ah, ahp->ah_gpioSelect,
6513 ahp->ah_gpioBit);
6514 }
6515}
6516#endif
6517
6518void 6528void
6519ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid, 6529ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid,
6520 u16 assocId) 6530 u16 assocId)
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 57d7cc87cb0f..1ba18006f475 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -140,7 +140,7 @@ static int ath_key_config(struct ath_softc *sc,
140 struct ath9k_keyval hk; 140 struct ath9k_keyval hk;
141 const u8 *mac = NULL; 141 const u8 *mac = NULL;
142 int ret = 0; 142 int ret = 0;
143 enum ieee80211_if_types opmode; 143 enum nl80211_iftype opmode;
144 144
145 memset(&hk, 0, sizeof(hk)); 145 memset(&hk, 0, sizeof(hk));
146 146
@@ -179,14 +179,14 @@ static int ath_key_config(struct ath_softc *sc,
179 */ 179 */
180 if (is_broadcast_ether_addr(addr)) { 180 if (is_broadcast_ether_addr(addr)) {
181 switch (opmode) { 181 switch (opmode) {
182 case IEEE80211_IF_TYPE_STA: 182 case NL80211_IFTYPE_STATION:
183 /* default key: could be group WPA key 183 /* default key: could be group WPA key
184 * or could be static WEP key */ 184 * or could be static WEP key */
185 mac = NULL; 185 mac = NULL;
186 break; 186 break;
187 case IEEE80211_IF_TYPE_IBSS: 187 case NL80211_IFTYPE_ADHOC:
188 break; 188 break;
189 case IEEE80211_IF_TYPE_AP: 189 case NL80211_IFTYPE_AP:
190 break; 190 break;
191 default: 191 default:
192 ASSERT(0); 192 ASSERT(0);
@@ -325,6 +325,693 @@ static u8 parse_mpdudensity(u8 mpdudensity)
325 } 325 }
326} 326}
327 327
328static void ath9k_ht_conf(struct ath_softc *sc,
329 struct ieee80211_bss_conf *bss_conf)
330{
331#define IEEE80211_HT_CAP_40MHZ_INTOLERANT BIT(14)
332 struct ath_ht_info *ht_info = &sc->sc_ht_info;
333
334 if (bss_conf->assoc_ht) {
335 ht_info->ext_chan_offset =
336 bss_conf->ht_bss_conf->bss_cap &
337 IEEE80211_HT_IE_CHA_SEC_OFFSET;
338
339 if (!(bss_conf->ht_conf->cap &
340 IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
341 (bss_conf->ht_bss_conf->bss_cap &
342 IEEE80211_HT_IE_CHA_WIDTH))
343 ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040;
344 else
345 ht_info->tx_chan_width = ATH9K_HT_MACMODE_20;
346
347 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width);
348 ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
349 bss_conf->ht_conf->ampdu_factor);
350 ht_info->mpdudensity =
351 parse_mpdudensity(bss_conf->ht_conf->ampdu_density);
352
353 }
354
355#undef IEEE80211_HT_CAP_40MHZ_INTOLERANT
356}
357
358static void ath9k_bss_assoc_info(struct ath_softc *sc,
359 struct ieee80211_bss_conf *bss_conf)
360{
361 struct ieee80211_hw *hw = sc->hw;
362 struct ieee80211_channel *curchan = hw->conf.channel;
363 struct ath_vap *avp;
364 int pos;
365 DECLARE_MAC_BUF(mac);
366
367 if (bss_conf->assoc) {
368 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Bss Info ASSOC %d\n",
369 __func__,
370 bss_conf->aid);
371
372 avp = sc->sc_vaps[0];
373 if (avp == NULL) {
374 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
375 __func__);
376 return;
377 }
378
379 /* New association, store aid */
380 if (avp->av_opmode == ATH9K_M_STA) {
381 sc->sc_curaid = bss_conf->aid;
382 ath9k_hw_write_associd(sc->sc_ah, sc->sc_curbssid,
383 sc->sc_curaid);
384 }
385
386 /* Configure the beacon */
387 ath_beacon_config(sc, 0);
388 sc->sc_flags |= SC_OP_BEACONS;
389
390 /* Reset rssi stats */
391 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER;
392 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER;
393 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
394 sc->sc_halstats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER;
395
396 /* Update chainmask */
397 ath_update_chainmask(sc, bss_conf->assoc_ht);
398
399 DPRINTF(sc, ATH_DBG_CONFIG,
400 "%s: bssid %s aid 0x%x\n",
401 __func__,
402 print_mac(mac, sc->sc_curbssid), sc->sc_curaid);
403
404 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
405 __func__,
406 curchan->center_freq);
407
408 pos = ath_get_channel(sc, curchan);
409 if (pos == -1) {
410 DPRINTF(sc, ATH_DBG_FATAL,
411 "%s: Invalid channel\n", __func__);
412 return;
413 }
414
415 if (hw->conf.ht_conf.ht_supported)
416 sc->sc_ah->ah_channels[pos].chanmode =
417 ath_get_extchanmode(sc, curchan);
418 else
419 sc->sc_ah->ah_channels[pos].chanmode =
420 (curchan->band == IEEE80211_BAND_2GHZ) ?
421 CHANNEL_G : CHANNEL_A;
422
423 /* set h/w channel */
424 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0)
425 DPRINTF(sc, ATH_DBG_FATAL,
426 "%s: Unable to set channel\n",
427 __func__);
428
429 ath_rate_newstate(sc, avp);
430 /* Update ratectrl about the new state */
431 ath_rc_node_update(hw, avp->rc_node);
432 } else {
433 DPRINTF(sc, ATH_DBG_CONFIG,
434 "%s: Bss Info DISSOC\n", __func__);
435 sc->sc_curaid = 0;
436 }
437}
438
439void ath_get_beaconconfig(struct ath_softc *sc,
440 int if_id,
441 struct ath_beacon_config *conf)
442{
443 struct ieee80211_hw *hw = sc->hw;
444
445 /* fill in beacon config data */
446
447 conf->beacon_interval = hw->conf.beacon_int;
448 conf->listen_interval = 100;
449 conf->dtim_count = 1;
450 conf->bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf->listen_interval;
451}
452
453void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
454 struct ath_xmit_status *tx_status, struct ath_node *an)
455{
456 struct ieee80211_hw *hw = sc->hw;
457 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
458
459 DPRINTF(sc, ATH_DBG_XMIT,
460 "%s: TX complete: skb: %p\n", __func__, skb);
461
462 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
463 tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
464 /* free driver's private data area of tx_info */
465 if (tx_info->driver_data[0] != NULL)
466 kfree(tx_info->driver_data[0]);
467 tx_info->driver_data[0] = NULL;
468 }
469
470 if (tx_status->flags & ATH_TX_BAR) {
471 tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
472 tx_status->flags &= ~ATH_TX_BAR;
473 }
474
475 if (tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY)) {
476 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
477 /* Frame was not ACKed, but an ACK was expected */
478 tx_info->status.excessive_retries = 1;
479 }
480 } else {
481 /* Frame was ACKed */
482 tx_info->flags |= IEEE80211_TX_STAT_ACK;
483 }
484
485 tx_info->status.retry_count = tx_status->retries;
486
487 ieee80211_tx_status(hw, skb);
488 if (an)
489 ath_node_put(sc, an, ATH9K_BH_STATUS_CHANGE);
490}
491
492int _ath_rx_indicate(struct ath_softc *sc,
493 struct sk_buff *skb,
494 struct ath_recv_status *status,
495 u16 keyix)
496{
497 struct ieee80211_hw *hw = sc->hw;
498 struct ath_node *an = NULL;
499 struct ieee80211_rx_status rx_status;
500 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
501 int hdrlen = ieee80211_get_hdrlen_from_skb(skb);
502 int padsize;
503 enum ATH_RX_TYPE st;
504
505 /* see if any padding is done by the hw and remove it */
506 if (hdrlen & 3) {
507 padsize = hdrlen % 4;
508 memmove(skb->data + padsize, skb->data, hdrlen);
509 skb_pull(skb, padsize);
510 }
511
512 /* Prepare rx status */
513 ath9k_rx_prepare(sc, skb, status, &rx_status);
514
515 if (!(keyix == ATH9K_RXKEYIX_INVALID) &&
516 !(status->flags & ATH_RX_DECRYPT_ERROR)) {
517 rx_status.flag |= RX_FLAG_DECRYPTED;
518 } else if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_PROTECTED)
519 && !(status->flags & ATH_RX_DECRYPT_ERROR)
520 && skb->len >= hdrlen + 4) {
521 keyix = skb->data[hdrlen + 3] >> 6;
522
523 if (test_bit(keyix, sc->sc_keymap))
524 rx_status.flag |= RX_FLAG_DECRYPTED;
525 }
526
527 spin_lock_bh(&sc->node_lock);
528 an = ath_node_find(sc, hdr->addr2);
529 spin_unlock_bh(&sc->node_lock);
530
531 if (an) {
532 ath_rx_input(sc, an,
533 hw->conf.ht_conf.ht_supported,
534 skb, status, &st);
535 }
536 if (!an || (st != ATH_RX_CONSUMED))
537 __ieee80211_rx(hw, skb, &rx_status);
538
539 return 0;
540}
541
542int ath_rx_subframe(struct ath_node *an,
543 struct sk_buff *skb,
544 struct ath_recv_status *status)
545{
546 struct ath_softc *sc = an->an_sc;
547 struct ieee80211_hw *hw = sc->hw;
548 struct ieee80211_rx_status rx_status;
549
550 /* Prepare rx status */
551 ath9k_rx_prepare(sc, skb, status, &rx_status);
552 if (!(status->flags & ATH_RX_DECRYPT_ERROR))
553 rx_status.flag |= RX_FLAG_DECRYPTED;
554
555 __ieee80211_rx(hw, skb, &rx_status);
556
557 return 0;
558}
559
560/********************************/
561/* LED functions */
562/********************************/
563
564static void ath_led_brightness(struct led_classdev *led_cdev,
565 enum led_brightness brightness)
566{
567 struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev);
568 struct ath_softc *sc = led->sc;
569
570 switch (brightness) {
571 case LED_OFF:
572 if (led->led_type == ATH_LED_ASSOC ||
573 led->led_type == ATH_LED_RADIO)
574 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
575 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
576 (led->led_type == ATH_LED_RADIO) ? 1 :
577 !!(sc->sc_flags & SC_OP_LED_ASSOCIATED));
578 break;
579 case LED_FULL:
580 if (led->led_type == ATH_LED_ASSOC)
581 sc->sc_flags |= SC_OP_LED_ASSOCIATED;
582 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0);
583 break;
584 default:
585 break;
586 }
587}
588
589static int ath_register_led(struct ath_softc *sc, struct ath_led *led,
590 char *trigger)
591{
592 int ret;
593
594 led->sc = sc;
595 led->led_cdev.name = led->name;
596 led->led_cdev.default_trigger = trigger;
597 led->led_cdev.brightness_set = ath_led_brightness;
598
599 ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev);
600 if (ret)
601 DPRINTF(sc, ATH_DBG_FATAL,
602 "Failed to register led:%s", led->name);
603 else
604 led->registered = 1;
605 return ret;
606}
607
608static void ath_unregister_led(struct ath_led *led)
609{
610 if (led->registered) {
611 led_classdev_unregister(&led->led_cdev);
612 led->registered = 0;
613 }
614}
615
616static void ath_deinit_leds(struct ath_softc *sc)
617{
618 ath_unregister_led(&sc->assoc_led);
619 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
620 ath_unregister_led(&sc->tx_led);
621 ath_unregister_led(&sc->rx_led);
622 ath_unregister_led(&sc->radio_led);
623 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
624}
625
626static void ath_init_leds(struct ath_softc *sc)
627{
628 char *trigger;
629 int ret;
630
631 /* Configure gpio 1 for output */
632 ath9k_hw_cfg_output(sc->sc_ah, ATH_LED_PIN,
633 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
634 /* LED off, active low */
635 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
636
637 trigger = ieee80211_get_radio_led_name(sc->hw);
638 snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
639 "ath9k-%s:radio", wiphy_name(sc->hw->wiphy));
640 ret = ath_register_led(sc, &sc->radio_led, trigger);
641 sc->radio_led.led_type = ATH_LED_RADIO;
642 if (ret)
643 goto fail;
644
645 trigger = ieee80211_get_assoc_led_name(sc->hw);
646 snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name),
647 "ath9k-%s:assoc", wiphy_name(sc->hw->wiphy));
648 ret = ath_register_led(sc, &sc->assoc_led, trigger);
649 sc->assoc_led.led_type = ATH_LED_ASSOC;
650 if (ret)
651 goto fail;
652
653 trigger = ieee80211_get_tx_led_name(sc->hw);
654 snprintf(sc->tx_led.name, sizeof(sc->tx_led.name),
655 "ath9k-%s:tx", wiphy_name(sc->hw->wiphy));
656 ret = ath_register_led(sc, &sc->tx_led, trigger);
657 sc->tx_led.led_type = ATH_LED_TX;
658 if (ret)
659 goto fail;
660
661 trigger = ieee80211_get_rx_led_name(sc->hw);
662 snprintf(sc->rx_led.name, sizeof(sc->rx_led.name),
663 "ath9k-%s:rx", wiphy_name(sc->hw->wiphy));
664 ret = ath_register_led(sc, &sc->rx_led, trigger);
665 sc->rx_led.led_type = ATH_LED_RX;
666 if (ret)
667 goto fail;
668
669 return;
670
671fail:
672 ath_deinit_leds(sc);
673}
674
675#ifdef CONFIG_RFKILL
676/*******************/
677/* Rfkill */
678/*******************/
679
680static void ath_radio_enable(struct ath_softc *sc)
681{
682 struct ath_hal *ah = sc->sc_ah;
683 int status;
684
685 spin_lock_bh(&sc->sc_resetlock);
686 if (!ath9k_hw_reset(ah, ah->ah_curchan,
687 sc->sc_ht_info.tx_chan_width,
688 sc->sc_tx_chainmask,
689 sc->sc_rx_chainmask,
690 sc->sc_ht_extprotspacing,
691 false, &status)) {
692 DPRINTF(sc, ATH_DBG_FATAL,
693 "%s: unable to reset channel %u (%uMhz) "
694 "flags 0x%x hal status %u\n", __func__,
695 ath9k_hw_mhz2ieee(ah,
696 ah->ah_curchan->channel,
697 ah->ah_curchan->channelFlags),
698 ah->ah_curchan->channel,
699 ah->ah_curchan->channelFlags, status);
700 }
701 spin_unlock_bh(&sc->sc_resetlock);
702
703 ath_update_txpow(sc);
704 if (ath_startrecv(sc) != 0) {
705 DPRINTF(sc, ATH_DBG_FATAL,
706 "%s: unable to restart recv logic\n", __func__);
707 return;
708 }
709
710 if (sc->sc_flags & SC_OP_BEACONS)
711 ath_beacon_config(sc, ATH_IF_ID_ANY); /* restart beacons */
712
713 /* Re-Enable interrupts */
714 ath9k_hw_set_interrupts(ah, sc->sc_imask);
715
716 /* Enable LED */
717 ath9k_hw_cfg_output(ah, ATH_LED_PIN,
718 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
719 ath9k_hw_set_gpio(ah, ATH_LED_PIN, 0);
720
721 ieee80211_wake_queues(sc->hw);
722}
723
724static void ath_radio_disable(struct ath_softc *sc)
725{
726 struct ath_hal *ah = sc->sc_ah;
727 int status;
728
729
730 ieee80211_stop_queues(sc->hw);
731
732 /* Disable LED */
733 ath9k_hw_set_gpio(ah, ATH_LED_PIN, 1);
734 ath9k_hw_cfg_gpio_input(ah, ATH_LED_PIN);
735
736 /* Disable interrupts */
737 ath9k_hw_set_interrupts(ah, 0);
738
739 ath_draintxq(sc, false); /* clear pending tx frames */
740 ath_stoprecv(sc); /* turn off frame recv */
741 ath_flushrecv(sc); /* flush recv queue */
742
743 spin_lock_bh(&sc->sc_resetlock);
744 if (!ath9k_hw_reset(ah, ah->ah_curchan,
745 sc->sc_ht_info.tx_chan_width,
746 sc->sc_tx_chainmask,
747 sc->sc_rx_chainmask,
748 sc->sc_ht_extprotspacing,
749 false, &status)) {
750 DPRINTF(sc, ATH_DBG_FATAL,
751 "%s: unable to reset channel %u (%uMhz) "
752 "flags 0x%x hal status %u\n", __func__,
753 ath9k_hw_mhz2ieee(ah,
754 ah->ah_curchan->channel,
755 ah->ah_curchan->channelFlags),
756 ah->ah_curchan->channel,
757 ah->ah_curchan->channelFlags, status);
758 }
759 spin_unlock_bh(&sc->sc_resetlock);
760
761 ath9k_hw_phy_disable(ah);
762 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
763}
764
765static bool ath_is_rfkill_set(struct ath_softc *sc)
766{
767 struct ath_hal *ah = sc->sc_ah;
768
769 return ath9k_hw_gpio_get(ah, ah->ah_rfkill_gpio) ==
770 ah->ah_rfkill_polarity;
771}
772
773/* h/w rfkill poll function */
774static void ath_rfkill_poll(struct work_struct *work)
775{
776 struct ath_softc *sc = container_of(work, struct ath_softc,
777 rf_kill.rfkill_poll.work);
778 bool radio_on;
779
780 if (sc->sc_flags & SC_OP_INVALID)
781 return;
782
783 radio_on = !ath_is_rfkill_set(sc);
784
785 /*
786 * enable/disable radio only when there is a
787 * state change in RF switch
788 */
789 if (radio_on == !!(sc->sc_flags & SC_OP_RFKILL_HW_BLOCKED)) {
790 enum rfkill_state state;
791
792 if (sc->sc_flags & SC_OP_RFKILL_SW_BLOCKED) {
793 state = radio_on ? RFKILL_STATE_SOFT_BLOCKED
794 : RFKILL_STATE_HARD_BLOCKED;
795 } else if (radio_on) {
796 ath_radio_enable(sc);
797 state = RFKILL_STATE_UNBLOCKED;
798 } else {
799 ath_radio_disable(sc);
800 state = RFKILL_STATE_HARD_BLOCKED;
801 }
802
803 if (state == RFKILL_STATE_HARD_BLOCKED)
804 sc->sc_flags |= SC_OP_RFKILL_HW_BLOCKED;
805 else
806 sc->sc_flags &= ~SC_OP_RFKILL_HW_BLOCKED;
807
808 rfkill_force_state(sc->rf_kill.rfkill, state);
809 }
810
811 queue_delayed_work(sc->hw->workqueue, &sc->rf_kill.rfkill_poll,
812 msecs_to_jiffies(ATH_RFKILL_POLL_INTERVAL));
813}
814
815/* s/w rfkill handler */
816static int ath_sw_toggle_radio(void *data, enum rfkill_state state)
817{
818 struct ath_softc *sc = data;
819
820 switch (state) {
821 case RFKILL_STATE_SOFT_BLOCKED:
822 if (!(sc->sc_flags & (SC_OP_RFKILL_HW_BLOCKED |
823 SC_OP_RFKILL_SW_BLOCKED)))
824 ath_radio_disable(sc);
825 sc->sc_flags |= SC_OP_RFKILL_SW_BLOCKED;
826 return 0;
827 case RFKILL_STATE_UNBLOCKED:
828 if ((sc->sc_flags & SC_OP_RFKILL_SW_BLOCKED)) {
829 sc->sc_flags &= ~SC_OP_RFKILL_SW_BLOCKED;
830 if (sc->sc_flags & SC_OP_RFKILL_HW_BLOCKED) {
831 DPRINTF(sc, ATH_DBG_FATAL, "Can't turn on the"
832 "radio as it is disabled by h/w \n");
833 return -EPERM;
834 }
835 ath_radio_enable(sc);
836 }
837 return 0;
838 default:
839 return -EINVAL;
840 }
841}
842
843/* Init s/w rfkill */
844static int ath_init_sw_rfkill(struct ath_softc *sc)
845{
846 sc->rf_kill.rfkill = rfkill_allocate(wiphy_dev(sc->hw->wiphy),
847 RFKILL_TYPE_WLAN);
848 if (!sc->rf_kill.rfkill) {
849 DPRINTF(sc, ATH_DBG_FATAL, "Failed to allocate rfkill\n");
850 return -ENOMEM;
851 }
852
853 snprintf(sc->rf_kill.rfkill_name, sizeof(sc->rf_kill.rfkill_name),
854 "ath9k-%s:rfkill", wiphy_name(sc->hw->wiphy));
855 sc->rf_kill.rfkill->name = sc->rf_kill.rfkill_name;
856 sc->rf_kill.rfkill->data = sc;
857 sc->rf_kill.rfkill->toggle_radio = ath_sw_toggle_radio;
858 sc->rf_kill.rfkill->state = RFKILL_STATE_UNBLOCKED;
859 sc->rf_kill.rfkill->user_claim_unsupported = 1;
860
861 return 0;
862}
863
864/* Deinitialize rfkill */
865static void ath_deinit_rfkill(struct ath_softc *sc)
866{
867 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
868 cancel_delayed_work_sync(&sc->rf_kill.rfkill_poll);
869
870 if (sc->sc_flags & SC_OP_RFKILL_REGISTERED) {
871 rfkill_unregister(sc->rf_kill.rfkill);
872 sc->sc_flags &= ~SC_OP_RFKILL_REGISTERED;
873 sc->rf_kill.rfkill = NULL;
874 }
875}
876#endif /* CONFIG_RFKILL */
877
878static int ath_detach(struct ath_softc *sc)
879{
880 struct ieee80211_hw *hw = sc->hw;
881
882 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach ATH hw\n", __func__);
883
884 /* Deinit LED control */
885 ath_deinit_leds(sc);
886
887#ifdef CONFIG_RFKILL
888 /* deinit rfkill */
889 ath_deinit_rfkill(sc);
890#endif
891
892 /* Unregister hw */
893
894 ieee80211_unregister_hw(hw);
895
896 /* unregister Rate control */
897 ath_rate_control_unregister();
898
899 /* tx/rx cleanup */
900
901 ath_rx_cleanup(sc);
902 ath_tx_cleanup(sc);
903
904 /* Deinit */
905
906 ath_deinit(sc);
907
908 return 0;
909}
910
911static int ath_attach(u16 devid,
912 struct ath_softc *sc)
913{
914 struct ieee80211_hw *hw = sc->hw;
915 int error = 0;
916
917 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach ATH hw\n", __func__);
918
919 error = ath_init(devid, sc);
920 if (error != 0)
921 return error;
922
923 /* Init nodes */
924
925 INIT_LIST_HEAD(&sc->node_list);
926 spin_lock_init(&sc->node_lock);
927
928 /* get mac address from hardware and set in mac80211 */
929
930 SET_IEEE80211_PERM_ADDR(hw, sc->sc_myaddr);
931
932 /* setup channels and rates */
933
934 sc->sbands[IEEE80211_BAND_2GHZ].channels =
935 sc->channels[IEEE80211_BAND_2GHZ];
936 sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
937 sc->rates[IEEE80211_BAND_2GHZ];
938 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
939
940 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
941 /* Setup HT capabilities for 2.4Ghz*/
942 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_info);
943
944 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
945 &sc->sbands[IEEE80211_BAND_2GHZ];
946
947 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes)) {
948 sc->sbands[IEEE80211_BAND_5GHZ].channels =
949 sc->channels[IEEE80211_BAND_5GHZ];
950 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
951 sc->rates[IEEE80211_BAND_5GHZ];
952 sc->sbands[IEEE80211_BAND_5GHZ].band =
953 IEEE80211_BAND_5GHZ;
954
955 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
956 /* Setup HT capabilities for 5Ghz*/
957 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_info);
958
959 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
960 &sc->sbands[IEEE80211_BAND_5GHZ];
961 }
962
963 /* FIXME: Have to figure out proper hw init values later */
964
965 hw->queues = 4;
966 hw->ampdu_queues = 1;
967
968 /* Register rate control */
969 hw->rate_control_algorithm = "ath9k_rate_control";
970 error = ath_rate_control_register();
971 if (error != 0) {
972 DPRINTF(sc, ATH_DBG_FATAL,
973 "%s: Unable to register rate control "
974 "algorithm:%d\n", __func__, error);
975 ath_rate_control_unregister();
976 goto bad;
977 }
978
979 error = ieee80211_register_hw(hw);
980 if (error != 0) {
981 ath_rate_control_unregister();
982 goto bad;
983 }
984
985 /* Initialize LED control */
986 ath_init_leds(sc);
987
988#ifdef CONFIG_RFKILL
989 /* Initialze h/w Rfkill */
990 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
991 INIT_DELAYED_WORK(&sc->rf_kill.rfkill_poll, ath_rfkill_poll);
992
993 /* Initialize s/w rfkill */
994 if (ath_init_sw_rfkill(sc))
995 goto detach;
996#endif
997
998 /* initialize tx/rx engine */
999
1000 error = ath_tx_init(sc, ATH_TXBUF);
1001 if (error != 0)
1002 goto detach;
1003
1004 error = ath_rx_init(sc, ATH_RXBUF);
1005 if (error != 0)
1006 goto detach;
1007
1008 return 0;
1009detach:
1010 ath_detach(sc);
1011bad:
1012 return error;
1013}
1014
328static int ath9k_start(struct ieee80211_hw *hw) 1015static int ath9k_start(struct ieee80211_hw *hw)
329{ 1016{
330 struct ath_softc *sc = hw->priv; 1017 struct ath_softc *sc = hw->priv;
@@ -353,6 +1040,33 @@ static int ath9k_start(struct ieee80211_hw *hw)
353 return error; 1040 return error;
354 } 1041 }
355 1042
1043#ifdef CONFIG_RFKILL
1044 /* Start rfkill polling */
1045 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1046 queue_delayed_work(sc->hw->workqueue,
1047 &sc->rf_kill.rfkill_poll, 0);
1048
1049 if (!(sc->sc_flags & SC_OP_RFKILL_REGISTERED)) {
1050 if (rfkill_register(sc->rf_kill.rfkill)) {
1051 DPRINTF(sc, ATH_DBG_FATAL,
1052 "Unable to register rfkill\n");
1053 rfkill_free(sc->rf_kill.rfkill);
1054
1055 /* Deinitialize the device */
1056 if (sc->pdev->irq)
1057 free_irq(sc->pdev->irq, sc);
1058 ath_detach(sc);
1059 pci_iounmap(sc->pdev, sc->mem);
1060 pci_release_region(sc->pdev, 0);
1061 pci_disable_device(sc->pdev);
1062 ieee80211_free_hw(hw);
1063 return -EIO;
1064 } else {
1065 sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
1066 }
1067 }
1068#endif
1069
356 ieee80211_wake_queues(hw); 1070 ieee80211_wake_queues(hw);
357 return 0; 1071 return 0;
358} 1072}
@@ -414,6 +1128,11 @@ static void ath9k_stop(struct ieee80211_hw *hw)
414 "%s: Device is no longer present\n", __func__); 1128 "%s: Device is no longer present\n", __func__);
415 1129
416 ieee80211_stop_queues(hw); 1130 ieee80211_stop_queues(hw);
1131
1132#ifdef CONFIG_RFKILL
1133 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1134 cancel_delayed_work_sync(&sc->rf_kill.rfkill_poll);
1135#endif
417} 1136}
418 1137
419static int ath9k_add_interface(struct ieee80211_hw *hw, 1138static int ath9k_add_interface(struct ieee80211_hw *hw,
@@ -428,13 +1147,13 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
428 return -ENOBUFS; 1147 return -ENOBUFS;
429 1148
430 switch (conf->type) { 1149 switch (conf->type) {
431 case IEEE80211_IF_TYPE_STA: 1150 case NL80211_IFTYPE_STATION:
432 ic_opmode = ATH9K_M_STA; 1151 ic_opmode = ATH9K_M_STA;
433 break; 1152 break;
434 case IEEE80211_IF_TYPE_IBSS: 1153 case NL80211_IFTYPE_ADHOC:
435 ic_opmode = ATH9K_M_IBSS; 1154 ic_opmode = ATH9K_M_IBSS;
436 break; 1155 break;
437 case IEEE80211_IF_TYPE_AP: 1156 case NL80211_IFTYPE_AP:
438 ic_opmode = ATH9K_M_HOSTAP; 1157 ic_opmode = ATH9K_M_HOSTAP;
439 break; 1158 break;
440 default: 1159 default:
@@ -556,7 +1275,7 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
556 1275
557 /* TODO: Need to decide which hw opmode to use for multi-interface 1276 /* TODO: Need to decide which hw opmode to use for multi-interface
558 * cases */ 1277 * cases */
559 if (vif->type == IEEE80211_IF_TYPE_AP && 1278 if (vif->type == NL80211_IFTYPE_AP &&
560 ah->ah_opmode != ATH9K_M_HOSTAP) { 1279 ah->ah_opmode != ATH9K_M_HOSTAP) {
561 ah->ah_opmode = ATH9K_M_HOSTAP; 1280 ah->ah_opmode = ATH9K_M_HOSTAP;
562 ath9k_hw_setopmode(ah); 1281 ath9k_hw_setopmode(ah);
@@ -568,8 +1287,8 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
568 if ((conf->changed & IEEE80211_IFCC_BSSID) && 1287 if ((conf->changed & IEEE80211_IFCC_BSSID) &&
569 !is_zero_ether_addr(conf->bssid)) { 1288 !is_zero_ether_addr(conf->bssid)) {
570 switch (vif->type) { 1289 switch (vif->type) {
571 case IEEE80211_IF_TYPE_STA: 1290 case NL80211_IFTYPE_STATION:
572 case IEEE80211_IF_TYPE_IBSS: 1291 case NL80211_IFTYPE_ADHOC:
573 /* Update ratectrl about the new state */ 1292 /* Update ratectrl about the new state */
574 ath_rate_newstate(sc, avp); 1293 ath_rate_newstate(sc, avp);
575 1294
@@ -614,8 +1333,8 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
614 } 1333 }
615 1334
616 if ((conf->changed & IEEE80211_IFCC_BEACON) && 1335 if ((conf->changed & IEEE80211_IFCC_BEACON) &&
617 ((vif->type == IEEE80211_IF_TYPE_IBSS) || 1336 ((vif->type == NL80211_IFTYPE_ADHOC) ||
618 (vif->type == IEEE80211_IF_TYPE_AP))) { 1337 (vif->type == NL80211_IFTYPE_AP))) {
619 /* 1338 /*
620 * Allocate and setup the beacon frame. 1339 * Allocate and setup the beacon frame.
621 * 1340 *
@@ -634,7 +1353,7 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
634 } 1353 }
635 1354
636 /* Check for WLAN_CAPABILITY_PRIVACY ? */ 1355 /* Check for WLAN_CAPABILITY_PRIVACY ? */
637 if ((avp->av_opmode != IEEE80211_IF_TYPE_STA)) { 1356 if ((avp->av_opmode != NL80211_IFTYPE_STATION)) {
638 for (i = 0; i < IEEE80211_WEP_NKID; i++) 1357 for (i = 0; i < IEEE80211_WEP_NKID; i++)
639 if (ath9k_hw_keyisvalid(sc->sc_ah, (u16)i)) 1358 if (ath9k_hw_keyisvalid(sc->sc_ah, (u16)i))
640 ath9k_hw_keysetmac(sc->sc_ah, 1359 ath9k_hw_keysetmac(sc->sc_ah,
@@ -643,7 +1362,7 @@ static int ath9k_config_interface(struct ieee80211_hw *hw,
643 } 1362 }
644 1363
645 /* Only legacy IBSS for now */ 1364 /* Only legacy IBSS for now */
646 if (vif->type == IEEE80211_IF_TYPE_IBSS) 1365 if (vif->type == NL80211_IFTYPE_ADHOC)
647 ath_update_chainmask(sc, 0); 1366 ath_update_chainmask(sc, 0);
648 1367
649 return 0; 1368 return 0;
@@ -686,7 +1405,7 @@ static void ath9k_configure_filter(struct ieee80211_hw *hw,
686static void ath9k_sta_notify(struct ieee80211_hw *hw, 1405static void ath9k_sta_notify(struct ieee80211_hw *hw,
687 struct ieee80211_vif *vif, 1406 struct ieee80211_vif *vif,
688 enum sta_notify_cmd cmd, 1407 enum sta_notify_cmd cmd,
689 const u8 *addr) 1408 struct ieee80211_sta *sta)
690{ 1409{
691 struct ath_softc *sc = hw->priv; 1410 struct ath_softc *sc = hw->priv;
692 struct ath_node *an; 1411 struct ath_node *an;
@@ -694,19 +1413,18 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
694 DECLARE_MAC_BUF(mac); 1413 DECLARE_MAC_BUF(mac);
695 1414
696 spin_lock_irqsave(&sc->node_lock, flags); 1415 spin_lock_irqsave(&sc->node_lock, flags);
697 an = ath_node_find(sc, (u8 *) addr); 1416 an = ath_node_find(sc, sta->addr);
698 spin_unlock_irqrestore(&sc->node_lock, flags); 1417 spin_unlock_irqrestore(&sc->node_lock, flags);
699 1418
700 switch (cmd) { 1419 switch (cmd) {
701 case STA_NOTIFY_ADD: 1420 case STA_NOTIFY_ADD:
702 spin_lock_irqsave(&sc->node_lock, flags); 1421 spin_lock_irqsave(&sc->node_lock, flags);
703 if (!an) { 1422 if (!an) {
704 ath_node_attach(sc, (u8 *)addr, 0); 1423 ath_node_attach(sc, sta->addr, 0);
705 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach a node: %s\n", 1424 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach a node: %s\n",
706 __func__, 1425 __func__, print_mac(mac, sta->addr));
707 print_mac(mac, addr));
708 } else { 1426 } else {
709 ath_node_get(sc, (u8 *)addr); 1427 ath_node_get(sc, sta->addr);
710 } 1428 }
711 spin_unlock_irqrestore(&sc->node_lock, flags); 1429 spin_unlock_irqrestore(&sc->node_lock, flags);
712 break; 1430 break;
@@ -719,7 +1437,7 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
719 ath_node_put(sc, an, ATH9K_BH_STATUS_INTACT); 1437 ath_node_put(sc, an, ATH9K_BH_STATUS_INTACT);
720 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Put a node: %s\n", 1438 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Put a node: %s\n",
721 __func__, 1439 __func__,
722 print_mac(mac, addr)); 1440 print_mac(mac, sta->addr));
723 } 1441 }
724 break; 1442 break;
725 default: 1443 default:
@@ -798,117 +1516,6 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
798 return ret; 1516 return ret;
799} 1517}
800 1518
801static void ath9k_ht_conf(struct ath_softc *sc,
802 struct ieee80211_bss_conf *bss_conf)
803{
804#define IEEE80211_HT_CAP_40MHZ_INTOLERANT BIT(14)
805 struct ath_ht_info *ht_info = &sc->sc_ht_info;
806
807 if (bss_conf->assoc_ht) {
808 ht_info->ext_chan_offset =
809 bss_conf->ht_bss_conf->bss_cap &
810 IEEE80211_HT_IE_CHA_SEC_OFFSET;
811
812 if (!(bss_conf->ht_conf->cap &
813 IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
814 (bss_conf->ht_bss_conf->bss_cap &
815 IEEE80211_HT_IE_CHA_WIDTH))
816 ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040;
817 else
818 ht_info->tx_chan_width = ATH9K_HT_MACMODE_20;
819
820 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width);
821 ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
822 bss_conf->ht_conf->ampdu_factor);
823 ht_info->mpdudensity =
824 parse_mpdudensity(bss_conf->ht_conf->ampdu_density);
825
826 }
827
828#undef IEEE80211_HT_CAP_40MHZ_INTOLERANT
829}
830
831static void ath9k_bss_assoc_info(struct ath_softc *sc,
832 struct ieee80211_bss_conf *bss_conf)
833{
834 struct ieee80211_hw *hw = sc->hw;
835 struct ieee80211_channel *curchan = hw->conf.channel;
836 struct ath_vap *avp;
837 int pos;
838 DECLARE_MAC_BUF(mac);
839
840 if (bss_conf->assoc) {
841 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Bss Info ASSOC %d\n",
842 __func__,
843 bss_conf->aid);
844
845 avp = sc->sc_vaps[0];
846 if (avp == NULL) {
847 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
848 __func__);
849 return;
850 }
851
852 /* New association, store aid */
853 if (avp->av_opmode == ATH9K_M_STA) {
854 sc->sc_curaid = bss_conf->aid;
855 ath9k_hw_write_associd(sc->sc_ah, sc->sc_curbssid,
856 sc->sc_curaid);
857 }
858
859 /* Configure the beacon */
860 ath_beacon_config(sc, 0);
861 sc->sc_flags |= SC_OP_BEACONS;
862
863 /* Reset rssi stats */
864 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER;
865 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER;
866 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
867 sc->sc_halstats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER;
868
869 /* Update chainmask */
870 ath_update_chainmask(sc, bss_conf->assoc_ht);
871
872 DPRINTF(sc, ATH_DBG_CONFIG,
873 "%s: bssid %s aid 0x%x\n",
874 __func__,
875 print_mac(mac, sc->sc_curbssid), sc->sc_curaid);
876
877 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
878 __func__,
879 curchan->center_freq);
880
881 pos = ath_get_channel(sc, curchan);
882 if (pos == -1) {
883 DPRINTF(sc, ATH_DBG_FATAL,
884 "%s: Invalid channel\n", __func__);
885 return;
886 }
887
888 if (hw->conf.ht_conf.ht_supported)
889 sc->sc_ah->ah_channels[pos].chanmode =
890 ath_get_extchanmode(sc, curchan);
891 else
892 sc->sc_ah->ah_channels[pos].chanmode =
893 (curchan->band == IEEE80211_BAND_2GHZ) ?
894 CHANNEL_G : CHANNEL_A;
895
896 /* set h/w channel */
897 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0)
898 DPRINTF(sc, ATH_DBG_FATAL,
899 "%s: Unable to set channel\n",
900 __func__);
901
902 ath_rate_newstate(sc, avp);
903 /* Update ratectrl about the new state */
904 ath_rc_node_update(hw, avp->rc_node);
905 } else {
906 DPRINTF(sc, ATH_DBG_CONFIG,
907 "%s: Bss Info DISSOC\n", __func__);
908 sc->sc_curaid = 0;
909 }
910}
911
912static void ath9k_bss_info_changed(struct ieee80211_hw *hw, 1519static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
913 struct ieee80211_vif *vif, 1520 struct ieee80211_vif *vif,
914 struct ieee80211_bss_conf *bss_conf, 1521 struct ieee80211_bss_conf *bss_conf,
@@ -973,45 +1580,44 @@ static void ath9k_reset_tsf(struct ieee80211_hw *hw)
973 1580
974static int ath9k_ampdu_action(struct ieee80211_hw *hw, 1581static int ath9k_ampdu_action(struct ieee80211_hw *hw,
975 enum ieee80211_ampdu_mlme_action action, 1582 enum ieee80211_ampdu_mlme_action action,
976 const u8 *addr, 1583 struct ieee80211_sta *sta,
977 u16 tid, 1584 u16 tid, u16 *ssn)
978 u16 *ssn)
979{ 1585{
980 struct ath_softc *sc = hw->priv; 1586 struct ath_softc *sc = hw->priv;
981 int ret = 0; 1587 int ret = 0;
982 1588
983 switch (action) { 1589 switch (action) {
984 case IEEE80211_AMPDU_RX_START: 1590 case IEEE80211_AMPDU_RX_START:
985 ret = ath_rx_aggr_start(sc, addr, tid, ssn); 1591 ret = ath_rx_aggr_start(sc, sta->addr, tid, ssn);
986 if (ret < 0) 1592 if (ret < 0)
987 DPRINTF(sc, ATH_DBG_FATAL, 1593 DPRINTF(sc, ATH_DBG_FATAL,
988 "%s: Unable to start RX aggregation\n", 1594 "%s: Unable to start RX aggregation\n",
989 __func__); 1595 __func__);
990 break; 1596 break;
991 case IEEE80211_AMPDU_RX_STOP: 1597 case IEEE80211_AMPDU_RX_STOP:
992 ret = ath_rx_aggr_stop(sc, addr, tid); 1598 ret = ath_rx_aggr_stop(sc, sta->addr, tid);
993 if (ret < 0) 1599 if (ret < 0)
994 DPRINTF(sc, ATH_DBG_FATAL, 1600 DPRINTF(sc, ATH_DBG_FATAL,
995 "%s: Unable to stop RX aggregation\n", 1601 "%s: Unable to stop RX aggregation\n",
996 __func__); 1602 __func__);
997 break; 1603 break;
998 case IEEE80211_AMPDU_TX_START: 1604 case IEEE80211_AMPDU_TX_START:
999 ret = ath_tx_aggr_start(sc, addr, tid, ssn); 1605 ret = ath_tx_aggr_start(sc, sta->addr, tid, ssn);
1000 if (ret < 0) 1606 if (ret < 0)
1001 DPRINTF(sc, ATH_DBG_FATAL, 1607 DPRINTF(sc, ATH_DBG_FATAL,
1002 "%s: Unable to start TX aggregation\n", 1608 "%s: Unable to start TX aggregation\n",
1003 __func__); 1609 __func__);
1004 else 1610 else
1005 ieee80211_start_tx_ba_cb_irqsafe(hw, (u8 *)addr, tid); 1611 ieee80211_start_tx_ba_cb_irqsafe(hw, sta->addr, tid);
1006 break; 1612 break;
1007 case IEEE80211_AMPDU_TX_STOP: 1613 case IEEE80211_AMPDU_TX_STOP:
1008 ret = ath_tx_aggr_stop(sc, addr, tid); 1614 ret = ath_tx_aggr_stop(sc, sta->addr, tid);
1009 if (ret < 0) 1615 if (ret < 0)
1010 DPRINTF(sc, ATH_DBG_FATAL, 1616 DPRINTF(sc, ATH_DBG_FATAL,
1011 "%s: Unable to stop TX aggregation\n", 1617 "%s: Unable to stop TX aggregation\n",
1012 __func__); 1618 __func__);
1013 1619
1014 ieee80211_stop_tx_ba_cb_irqsafe(hw, (u8 *)addr, tid); 1620 ieee80211_stop_tx_ba_cb_irqsafe(hw, sta->addr, tid);
1015 break; 1621 break;
1016 default: 1622 default:
1017 DPRINTF(sc, ATH_DBG_FATAL, 1623 DPRINTF(sc, ATH_DBG_FATAL,
@@ -1048,364 +1654,6 @@ static struct ieee80211_ops ath9k_ops = {
1048 .ampdu_action = ath9k_ampdu_action 1654 .ampdu_action = ath9k_ampdu_action
1049}; 1655};
1050 1656
1051void ath_get_beaconconfig(struct ath_softc *sc,
1052 int if_id,
1053 struct ath_beacon_config *conf)
1054{
1055 struct ieee80211_hw *hw = sc->hw;
1056
1057 /* fill in beacon config data */
1058
1059 conf->beacon_interval = hw->conf.beacon_int;
1060 conf->listen_interval = 100;
1061 conf->dtim_count = 1;
1062 conf->bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf->listen_interval;
1063}
1064
1065void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
1066 struct ath_xmit_status *tx_status, struct ath_node *an)
1067{
1068 struct ieee80211_hw *hw = sc->hw;
1069 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1070
1071 DPRINTF(sc, ATH_DBG_XMIT,
1072 "%s: TX complete: skb: %p\n", __func__, skb);
1073
1074 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
1075 tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
1076 /* free driver's private data area of tx_info */
1077 if (tx_info->driver_data[0] != NULL)
1078 kfree(tx_info->driver_data[0]);
1079 tx_info->driver_data[0] = NULL;
1080 }
1081
1082 if (tx_status->flags & ATH_TX_BAR) {
1083 tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
1084 tx_status->flags &= ~ATH_TX_BAR;
1085 }
1086
1087 if (tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY)) {
1088 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
1089 /* Frame was not ACKed, but an ACK was expected */
1090 tx_info->status.excessive_retries = 1;
1091 }
1092 } else {
1093 /* Frame was ACKed */
1094 tx_info->flags |= IEEE80211_TX_STAT_ACK;
1095 }
1096
1097 tx_info->status.retry_count = tx_status->retries;
1098
1099 ieee80211_tx_status(hw, skb);
1100 if (an)
1101 ath_node_put(sc, an, ATH9K_BH_STATUS_CHANGE);
1102}
1103
1104int _ath_rx_indicate(struct ath_softc *sc,
1105 struct sk_buff *skb,
1106 struct ath_recv_status *status,
1107 u16 keyix)
1108{
1109 struct ieee80211_hw *hw = sc->hw;
1110 struct ath_node *an = NULL;
1111 struct ieee80211_rx_status rx_status;
1112 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1113 int hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1114 int padsize;
1115 enum ATH_RX_TYPE st;
1116
1117 /* see if any padding is done by the hw and remove it */
1118 if (hdrlen & 3) {
1119 padsize = hdrlen % 4;
1120 memmove(skb->data + padsize, skb->data, hdrlen);
1121 skb_pull(skb, padsize);
1122 }
1123
1124 /* Prepare rx status */
1125 ath9k_rx_prepare(sc, skb, status, &rx_status);
1126
1127 if (!(keyix == ATH9K_RXKEYIX_INVALID) &&
1128 !(status->flags & ATH_RX_DECRYPT_ERROR)) {
1129 rx_status.flag |= RX_FLAG_DECRYPTED;
1130 } else if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_PROTECTED)
1131 && !(status->flags & ATH_RX_DECRYPT_ERROR)
1132 && skb->len >= hdrlen + 4) {
1133 keyix = skb->data[hdrlen + 3] >> 6;
1134
1135 if (test_bit(keyix, sc->sc_keymap))
1136 rx_status.flag |= RX_FLAG_DECRYPTED;
1137 }
1138
1139 spin_lock_bh(&sc->node_lock);
1140 an = ath_node_find(sc, hdr->addr2);
1141 spin_unlock_bh(&sc->node_lock);
1142
1143 if (an) {
1144 ath_rx_input(sc, an,
1145 hw->conf.ht_conf.ht_supported,
1146 skb, status, &st);
1147 }
1148 if (!an || (st != ATH_RX_CONSUMED))
1149 __ieee80211_rx(hw, skb, &rx_status);
1150
1151 return 0;
1152}
1153
1154int ath_rx_subframe(struct ath_node *an,
1155 struct sk_buff *skb,
1156 struct ath_recv_status *status)
1157{
1158 struct ath_softc *sc = an->an_sc;
1159 struct ieee80211_hw *hw = sc->hw;
1160 struct ieee80211_rx_status rx_status;
1161
1162 /* Prepare rx status */
1163 ath9k_rx_prepare(sc, skb, status, &rx_status);
1164 if (!(status->flags & ATH_RX_DECRYPT_ERROR))
1165 rx_status.flag |= RX_FLAG_DECRYPTED;
1166
1167 __ieee80211_rx(hw, skb, &rx_status);
1168
1169 return 0;
1170}
1171
1172/********************************/
1173/* LED functions */
1174/********************************/
1175
1176static void ath_led_brightness(struct led_classdev *led_cdev,
1177 enum led_brightness brightness)
1178{
1179 struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev);
1180 struct ath_softc *sc = led->sc;
1181
1182 switch (brightness) {
1183 case LED_OFF:
1184 if (led->led_type == ATH_LED_ASSOC ||
1185 led->led_type == ATH_LED_RADIO)
1186 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
1187 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
1188 (led->led_type == ATH_LED_RADIO) ? 1 :
1189 !!(sc->sc_flags & SC_OP_LED_ASSOCIATED));
1190 break;
1191 case LED_FULL:
1192 if (led->led_type == ATH_LED_ASSOC)
1193 sc->sc_flags |= SC_OP_LED_ASSOCIATED;
1194 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0);
1195 break;
1196 default:
1197 break;
1198 }
1199}
1200
1201static int ath_register_led(struct ath_softc *sc, struct ath_led *led,
1202 char *trigger)
1203{
1204 int ret;
1205
1206 led->sc = sc;
1207 led->led_cdev.name = led->name;
1208 led->led_cdev.default_trigger = trigger;
1209 led->led_cdev.brightness_set = ath_led_brightness;
1210
1211 ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev);
1212 if (ret)
1213 DPRINTF(sc, ATH_DBG_FATAL,
1214 "Failed to register led:%s", led->name);
1215 else
1216 led->registered = 1;
1217 return ret;
1218}
1219
1220static void ath_unregister_led(struct ath_led *led)
1221{
1222 if (led->registered) {
1223 led_classdev_unregister(&led->led_cdev);
1224 led->registered = 0;
1225 }
1226}
1227
1228static void ath_deinit_leds(struct ath_softc *sc)
1229{
1230 ath_unregister_led(&sc->assoc_led);
1231 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
1232 ath_unregister_led(&sc->tx_led);
1233 ath_unregister_led(&sc->rx_led);
1234 ath_unregister_led(&sc->radio_led);
1235 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
1236}
1237
1238static void ath_init_leds(struct ath_softc *sc)
1239{
1240 char *trigger;
1241 int ret;
1242
1243 /* Configure gpio 1 for output */
1244 ath9k_hw_cfg_output(sc->sc_ah, ATH_LED_PIN,
1245 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
1246 /* LED off, active low */
1247 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
1248
1249 trigger = ieee80211_get_radio_led_name(sc->hw);
1250 snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
1251 "ath9k-%s:radio", wiphy_name(sc->hw->wiphy));
1252 ret = ath_register_led(sc, &sc->radio_led, trigger);
1253 sc->radio_led.led_type = ATH_LED_RADIO;
1254 if (ret)
1255 goto fail;
1256
1257 trigger = ieee80211_get_assoc_led_name(sc->hw);
1258 snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name),
1259 "ath9k-%s:assoc", wiphy_name(sc->hw->wiphy));
1260 ret = ath_register_led(sc, &sc->assoc_led, trigger);
1261 sc->assoc_led.led_type = ATH_LED_ASSOC;
1262 if (ret)
1263 goto fail;
1264
1265 trigger = ieee80211_get_tx_led_name(sc->hw);
1266 snprintf(sc->tx_led.name, sizeof(sc->tx_led.name),
1267 "ath9k-%s:tx", wiphy_name(sc->hw->wiphy));
1268 ret = ath_register_led(sc, &sc->tx_led, trigger);
1269 sc->tx_led.led_type = ATH_LED_TX;
1270 if (ret)
1271 goto fail;
1272
1273 trigger = ieee80211_get_rx_led_name(sc->hw);
1274 snprintf(sc->rx_led.name, sizeof(sc->rx_led.name),
1275 "ath9k-%s:rx", wiphy_name(sc->hw->wiphy));
1276 ret = ath_register_led(sc, &sc->rx_led, trigger);
1277 sc->rx_led.led_type = ATH_LED_RX;
1278 if (ret)
1279 goto fail;
1280
1281 return;
1282
1283fail:
1284 ath_deinit_leds(sc);
1285}
1286
1287static int ath_detach(struct ath_softc *sc)
1288{
1289 struct ieee80211_hw *hw = sc->hw;
1290
1291 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach ATH hw\n", __func__);
1292
1293 /* Deinit LED control */
1294 ath_deinit_leds(sc);
1295
1296 /* Unregister hw */
1297
1298 ieee80211_unregister_hw(hw);
1299
1300 /* unregister Rate control */
1301 ath_rate_control_unregister();
1302
1303 /* tx/rx cleanup */
1304
1305 ath_rx_cleanup(sc);
1306 ath_tx_cleanup(sc);
1307
1308 /* Deinit */
1309
1310 ath_deinit(sc);
1311
1312 return 0;
1313}
1314
1315static int ath_attach(u16 devid,
1316 struct ath_softc *sc)
1317{
1318 struct ieee80211_hw *hw = sc->hw;
1319 int error = 0;
1320
1321 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach ATH hw\n", __func__);
1322
1323 error = ath_init(devid, sc);
1324 if (error != 0)
1325 return error;
1326
1327 /* Init nodes */
1328
1329 INIT_LIST_HEAD(&sc->node_list);
1330 spin_lock_init(&sc->node_lock);
1331
1332 /* get mac address from hardware and set in mac80211 */
1333
1334 SET_IEEE80211_PERM_ADDR(hw, sc->sc_myaddr);
1335
1336 /* setup channels and rates */
1337
1338 sc->sbands[IEEE80211_BAND_2GHZ].channels =
1339 sc->channels[IEEE80211_BAND_2GHZ];
1340 sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
1341 sc->rates[IEEE80211_BAND_2GHZ];
1342 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
1343
1344 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
1345 /* Setup HT capabilities for 2.4Ghz*/
1346 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_info);
1347
1348 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
1349 &sc->sbands[IEEE80211_BAND_2GHZ];
1350
1351 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes)) {
1352 sc->sbands[IEEE80211_BAND_5GHZ].channels =
1353 sc->channels[IEEE80211_BAND_5GHZ];
1354 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
1355 sc->rates[IEEE80211_BAND_5GHZ];
1356 sc->sbands[IEEE80211_BAND_5GHZ].band =
1357 IEEE80211_BAND_5GHZ;
1358
1359 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
1360 /* Setup HT capabilities for 5Ghz*/
1361 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_info);
1362
1363 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
1364 &sc->sbands[IEEE80211_BAND_5GHZ];
1365 }
1366
1367 /* FIXME: Have to figure out proper hw init values later */
1368
1369 hw->queues = 4;
1370 hw->ampdu_queues = 1;
1371
1372 /* Register rate control */
1373 hw->rate_control_algorithm = "ath9k_rate_control";
1374 error = ath_rate_control_register();
1375 if (error != 0) {
1376 DPRINTF(sc, ATH_DBG_FATAL,
1377 "%s: Unable to register rate control "
1378 "algorithm:%d\n", __func__, error);
1379 ath_rate_control_unregister();
1380 goto bad;
1381 }
1382
1383 error = ieee80211_register_hw(hw);
1384 if (error != 0) {
1385 ath_rate_control_unregister();
1386 goto bad;
1387 }
1388
1389 /* Initialize LED control */
1390 ath_init_leds(sc);
1391
1392 /* initialize tx/rx engine */
1393
1394 error = ath_tx_init(sc, ATH_TXBUF);
1395 if (error != 0)
1396 goto detach;
1397
1398 error = ath_rx_init(sc, ATH_RXBUF);
1399 if (error != 0)
1400 goto detach;
1401
1402 return 0;
1403detach:
1404 ath_detach(sc);
1405bad:
1406 return error;
1407}
1408
1409static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1657static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1410{ 1658{
1411 void __iomem *mem; 1659 void __iomem *mem;
@@ -1554,6 +1802,12 @@ static int ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1554 struct ath_softc *sc = hw->priv; 1802 struct ath_softc *sc = hw->priv;
1555 1803
1556 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1); 1804 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
1805
1806#ifdef CONFIG_RFKILL
1807 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1808 cancel_delayed_work_sync(&sc->rf_kill.rfkill_poll);
1809#endif
1810
1557 pci_save_state(pdev); 1811 pci_save_state(pdev);
1558 pci_disable_device(pdev); 1812 pci_disable_device(pdev);
1559 pci_set_power_state(pdev, 3); 1813 pci_set_power_state(pdev, 3);
@@ -1586,6 +1840,16 @@ static int ath_pci_resume(struct pci_dev *pdev)
1586 AR_GPIO_OUTPUT_MUX_AS_OUTPUT); 1840 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
1587 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1); 1841 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
1588 1842
1843#ifdef CONFIG_RFKILL
1844 /*
1845 * check the h/w rfkill state on resume
1846 * and start the rfkill poll timer
1847 */
1848 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1849 queue_delayed_work(sc->hw->workqueue,
1850 &sc->rf_kill.rfkill_poll, 0);
1851#endif
1852
1589 return 0; 1853 return 0;
1590} 1854}
1591 1855
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index 390019ed398e..1cc9daf44550 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -1825,7 +1825,7 @@ static void ath_setup_rates(struct ieee80211_local *local, struct sta_info *sta)
1825 1825
1826 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1826 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1827 for (i = 0; i < sband->n_bitrates; i++) { 1827 for (i = 0; i < sband->n_bitrates; i++) {
1828 if (sta->supp_rates[local->hw.conf.channel->band] & BIT(i)) { 1828 if (sta->sta.supp_rates[local->hw.conf.channel->band] & BIT(i)) {
1829 rc_priv->neg_rates.rs_rates[j] 1829 rc_priv->neg_rates.rs_rates[j]
1830 = (sband->bitrates[i].bitrate * 2) / 10; 1830 = (sband->bitrates[i].bitrate * 2) / 10;
1831 j++; 1831 j++;
@@ -2039,7 +2039,6 @@ static void ath_rate_init(void *priv, void *priv_sta,
2039 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 2039 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2040 2040
2041 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2041 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
2042 sta->txrate_idx = rate_lowest_index(local, sband, sta);
2043 2042
2044 ath_setup_rates(local, sta); 2043 ath_setup_rates(local, sta);
2045 if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) { 2044 if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 07d2825458ab..427b8203e3f9 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -569,7 +569,7 @@ struct b43_key {
569#define B43_QOS_VOICE B43_QOS_PARAMS(3) 569#define B43_QOS_VOICE B43_QOS_PARAMS(3)
570 570
571/* QOS parameter hardware data structure offsets. */ 571/* QOS parameter hardware data structure offsets. */
572#define B43_NR_QOSPARAMS 22 572#define B43_NR_QOSPARAMS 16
573enum { 573enum {
574 B43_QOSPARAM_TXOP = 0, 574 B43_QOSPARAM_TXOP = 0,
575 B43_QOSPARAM_CWMIN, 575 B43_QOSPARAM_CWMIN,
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index d4a356b11636..0f628a29d833 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1244,13 +1244,13 @@ generate_new:
1244 1244
1245static void handle_irq_tbtt_indication(struct b43_wldev *dev) 1245static void handle_irq_tbtt_indication(struct b43_wldev *dev)
1246{ 1246{
1247 if (b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) { 1247 if (b43_is_mode(dev->wl, NL80211_IFTYPE_AP)) {
1248 ///TODO: PS TBTT 1248 ///TODO: PS TBTT
1249 } else { 1249 } else {
1250 if (1 /*FIXME: the last PSpoll frame was sent successfully */ ) 1250 if (1 /*FIXME: the last PSpoll frame was sent successfully */ )
1251 b43_power_saving_ctl_bits(dev, 0); 1251 b43_power_saving_ctl_bits(dev, 0);
1252 } 1252 }
1253 if (b43_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS)) 1253 if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC))
1254 dev->dfq_valid = 1; 1254 dev->dfq_valid = 1;
1255} 1255}
1256 1256
@@ -1599,8 +1599,8 @@ static void handle_irq_beacon(struct b43_wldev *dev)
1599 struct b43_wl *wl = dev->wl; 1599 struct b43_wl *wl = dev->wl;
1600 u32 cmd, beacon0_valid, beacon1_valid; 1600 u32 cmd, beacon0_valid, beacon1_valid;
1601 1601
1602 if (!b43_is_mode(wl, IEEE80211_IF_TYPE_AP) && 1602 if (!b43_is_mode(wl, NL80211_IFTYPE_AP) &&
1603 !b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) 1603 !b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT))
1604 return; 1604 return;
1605 1605
1606 /* This is the bottom half of the asynchronous beacon update. */ 1606 /* This is the bottom half of the asynchronous beacon update. */
@@ -2568,10 +2568,10 @@ static void b43_adjust_opmode(struct b43_wldev *dev)
2568 ctl &= ~B43_MACCTL_BEACPROMISC; 2568 ctl &= ~B43_MACCTL_BEACPROMISC;
2569 ctl |= B43_MACCTL_INFRA; 2569 ctl |= B43_MACCTL_INFRA;
2570 2570
2571 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || 2571 if (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
2572 b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) 2572 b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT))
2573 ctl |= B43_MACCTL_AP; 2573 ctl |= B43_MACCTL_AP;
2574 else if (b43_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) 2574 else if (b43_is_mode(wl, NL80211_IFTYPE_ADHOC))
2575 ctl &= ~B43_MACCTL_INFRA; 2575 ctl &= ~B43_MACCTL_INFRA;
2576 2576
2577 if (wl->filter_flags & FIF_CONTROL) 2577 if (wl->filter_flags & FIF_CONTROL)
@@ -3406,8 +3406,8 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
3406 phy->ops->set_rx_antenna(dev, antenna); 3406 phy->ops->set_rx_antenna(dev, antenna);
3407 3407
3408 /* Update templates for AP/mesh mode. */ 3408 /* Update templates for AP/mesh mode. */
3409 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || 3409 if (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
3410 b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) 3410 b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT))
3411 b43_set_beacon_int(dev, conf->beacon_int); 3411 b43_set_beacon_int(dev, conf->beacon_int);
3412 3412
3413 if (!!conf->radio_enabled != phy->radio_on) { 3413 if (!!conf->radio_enabled != phy->radio_on) {
@@ -3595,14 +3595,14 @@ static int b43_op_config_interface(struct ieee80211_hw *hw,
3595 else 3595 else
3596 memset(wl->bssid, 0, ETH_ALEN); 3596 memset(wl->bssid, 0, ETH_ALEN);
3597 if (b43_status(dev) >= B43_STAT_INITIALIZED) { 3597 if (b43_status(dev) >= B43_STAT_INITIALIZED) {
3598 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || 3598 if (b43_is_mode(wl, NL80211_IFTYPE_AP) ||
3599 b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) { 3599 b43_is_mode(wl, NL80211_IFTYPE_MESH_POINT)) {
3600 B43_WARN_ON(vif->type != wl->if_type); 3600 B43_WARN_ON(vif->type != wl->if_type);
3601 if (conf->changed & IEEE80211_IFCC_SSID) 3601 if (conf->changed & IEEE80211_IFCC_SSID)
3602 b43_set_ssid(dev, conf->ssid, conf->ssid_len); 3602 b43_set_ssid(dev, conf->ssid, conf->ssid_len);
3603 if (conf->changed & IEEE80211_IFCC_BEACON) 3603 if (conf->changed & IEEE80211_IFCC_BEACON)
3604 b43_update_templates(wl); 3604 b43_update_templates(wl);
3605 } else if (b43_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) { 3605 } else if (b43_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
3606 if (conf->changed & IEEE80211_IFCC_BEACON) 3606 if (conf->changed & IEEE80211_IFCC_BEACON)
3607 b43_update_templates(wl); 3607 b43_update_templates(wl);
3608 } 3608 }
@@ -3903,7 +3903,7 @@ static void b43_set_synth_pu_delay(struct b43_wldev *dev, bool idle)
3903 pu_delay = 3700; 3903 pu_delay = 3700;
3904 else 3904 else
3905 pu_delay = 1050; 3905 pu_delay = 1050;
3906 if (b43_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS) || idle) 3906 if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC) || idle)
3907 pu_delay = 500; 3907 pu_delay = 500;
3908 if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8)) 3908 if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8))
3909 pu_delay = max(pu_delay, (u16)2400); 3909 pu_delay = max(pu_delay, (u16)2400);
@@ -3917,7 +3917,7 @@ static void b43_set_pretbtt(struct b43_wldev *dev)
3917 u16 pretbtt; 3917 u16 pretbtt;
3918 3918
3919 /* The time value is in microseconds. */ 3919 /* The time value is in microseconds. */
3920 if (b43_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS)) { 3920 if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC)) {
3921 pretbtt = 2; 3921 pretbtt = 2;
3922 } else { 3922 } else {
3923 if (dev->phy.type == B43_PHYTYPE_A) 3923 if (dev->phy.type == B43_PHYTYPE_A)
@@ -4084,11 +4084,11 @@ static int b43_op_add_interface(struct ieee80211_hw *hw,
4084 4084
4085 /* TODO: allow WDS/AP devices to coexist */ 4085 /* TODO: allow WDS/AP devices to coexist */
4086 4086
4087 if (conf->type != IEEE80211_IF_TYPE_AP && 4087 if (conf->type != NL80211_IFTYPE_AP &&
4088 conf->type != IEEE80211_IF_TYPE_MESH_POINT && 4088 conf->type != NL80211_IFTYPE_MESH_POINT &&
4089 conf->type != IEEE80211_IF_TYPE_STA && 4089 conf->type != NL80211_IFTYPE_STATION &&
4090 conf->type != IEEE80211_IF_TYPE_WDS && 4090 conf->type != NL80211_IFTYPE_WDS &&
4091 conf->type != IEEE80211_IF_TYPE_IBSS) 4091 conf->type != NL80211_IFTYPE_ADHOC)
4092 return -EOPNOTSUPP; 4092 return -EOPNOTSUPP;
4093 4093
4094 mutex_lock(&wl->mutex); 4094 mutex_lock(&wl->mutex);
@@ -4234,7 +4234,8 @@ out_unlock:
4234 return err; 4234 return err;
4235} 4235}
4236 4236
4237static int b43_op_beacon_set_tim(struct ieee80211_hw *hw, int aid, int set) 4237static int b43_op_beacon_set_tim(struct ieee80211_hw *hw,
4238 struct ieee80211_sta *sta, bool set)
4238{ 4239{
4239 struct b43_wl *wl = hw_to_b43_wl(hw); 4240 struct b43_wl *wl = hw_to_b43_wl(hw);
4240 unsigned long flags; 4241 unsigned long flags;
@@ -4249,7 +4250,7 @@ static int b43_op_beacon_set_tim(struct ieee80211_hw *hw, int aid, int set)
4249static void b43_op_sta_notify(struct ieee80211_hw *hw, 4250static void b43_op_sta_notify(struct ieee80211_hw *hw,
4250 struct ieee80211_vif *vif, 4251 struct ieee80211_vif *vif,
4251 enum sta_notify_cmd notify_cmd, 4252 enum sta_notify_cmd notify_cmd,
4252 const u8 *addr) 4253 struct ieee80211_sta *sta)
4253{ 4254{
4254 struct b43_wl *wl = hw_to_b43_wl(hw); 4255 struct b43_wl *wl = hw_to_b43_wl(hw);
4255 4256
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 4d4345d76abf..af37abccccb3 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -162,7 +162,7 @@ void b43_phy_lock(struct b43_wldev *dev)
162#endif 162#endif
163 B43_WARN_ON(dev->dev->id.revision < 3); 163 B43_WARN_ON(dev->dev->id.revision < 3);
164 164
165 if (!b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) 165 if (!b43_is_mode(dev->wl, NL80211_IFTYPE_AP))
166 b43_power_saving_ctl_bits(dev, B43_PS_AWAKE); 166 b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
167} 167}
168 168
@@ -174,7 +174,7 @@ void b43_phy_unlock(struct b43_wldev *dev)
174#endif 174#endif
175 B43_WARN_ON(dev->dev->id.revision < 3); 175 B43_WARN_ON(dev->dev->id.revision < 3);
176 176
177 if (!b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) 177 if (!b43_is_mode(dev->wl, NL80211_IFTYPE_AP))
178 b43_power_saving_ctl_bits(dev, 0); 178 b43_power_saving_ctl_bits(dev, 0);
179} 179}
180 180
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 68f63f5093af..9fb1421cbec2 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -888,13 +888,13 @@ generate_new:
888 888
889static void handle_irq_tbtt_indication(struct b43legacy_wldev *dev) 889static void handle_irq_tbtt_indication(struct b43legacy_wldev *dev)
890{ 890{
891 if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) { 891 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP)) {
892 /* TODO: PS TBTT */ 892 /* TODO: PS TBTT */
893 } else { 893 } else {
894 if (1/*FIXME: the last PSpoll frame was sent successfully */) 894 if (1/*FIXME: the last PSpoll frame was sent successfully */)
895 b43legacy_power_saving_ctl_bits(dev, -1, -1); 895 b43legacy_power_saving_ctl_bits(dev, -1, -1);
896 } 896 }
897 if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS)) 897 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC))
898 dev->dfq_valid = 1; 898 dev->dfq_valid = 1;
899} 899}
900 900
@@ -1201,7 +1201,7 @@ static void handle_irq_beacon(struct b43legacy_wldev *dev)
1201 struct b43legacy_wl *wl = dev->wl; 1201 struct b43legacy_wl *wl = dev->wl;
1202 u32 cmd; 1202 u32 cmd;
1203 1203
1204 if (!b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) 1204 if (!b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
1205 return; 1205 return;
1206 1206
1207 /* This is the bottom half of the asynchronous beacon update. */ 1207 /* This is the bottom half of the asynchronous beacon update. */
@@ -1936,9 +1936,9 @@ static void b43legacy_adjust_opmode(struct b43legacy_wldev *dev)
1936 ctl &= ~B43legacy_MACCTL_BEACPROMISC; 1936 ctl &= ~B43legacy_MACCTL_BEACPROMISC;
1937 ctl |= B43legacy_MACCTL_INFRA; 1937 ctl |= B43legacy_MACCTL_INFRA;
1938 1938
1939 if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) 1939 if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
1940 ctl |= B43legacy_MACCTL_AP; 1940 ctl |= B43legacy_MACCTL_AP;
1941 else if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) 1941 else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC))
1942 ctl &= ~B43legacy_MACCTL_INFRA; 1942 ctl &= ~B43legacy_MACCTL_INFRA;
1943 1943
1944 if (wl->filter_flags & FIF_CONTROL) 1944 if (wl->filter_flags & FIF_CONTROL)
@@ -2646,7 +2646,7 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
2646 b43legacy_mgmtframe_txantenna(dev, antenna_tx); 2646 b43legacy_mgmtframe_txantenna(dev, antenna_tx);
2647 2647
2648 /* Update templates for AP mode. */ 2648 /* Update templates for AP mode. */
2649 if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) 2649 if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
2650 b43legacy_set_beacon_int(dev, conf->beacon_int); 2650 b43legacy_set_beacon_int(dev, conf->beacon_int);
2651 2651
2652 2652
@@ -2733,12 +2733,12 @@ static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
2733 else 2733 else
2734 memset(wl->bssid, 0, ETH_ALEN); 2734 memset(wl->bssid, 0, ETH_ALEN);
2735 if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) { 2735 if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) {
2736 if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) { 2736 if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP)) {
2737 B43legacy_WARN_ON(vif->type != IEEE80211_IF_TYPE_AP); 2737 B43legacy_WARN_ON(vif->type != NL80211_IFTYPE_AP);
2738 b43legacy_set_ssid(dev, conf->ssid, conf->ssid_len); 2738 b43legacy_set_ssid(dev, conf->ssid, conf->ssid_len);
2739 if (conf->changed & IEEE80211_IFCC_BEACON) 2739 if (conf->changed & IEEE80211_IFCC_BEACON)
2740 b43legacy_update_templates(wl); 2740 b43legacy_update_templates(wl);
2741 } else if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) { 2741 } else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
2742 if (conf->changed & IEEE80211_IFCC_BEACON) 2742 if (conf->changed & IEEE80211_IFCC_BEACON)
2743 b43legacy_update_templates(wl); 2743 b43legacy_update_templates(wl);
2744 } 2744 }
@@ -3020,7 +3020,7 @@ static void b43legacy_set_synth_pu_delay(struct b43legacy_wldev *dev,
3020 bool idle) { 3020 bool idle) {
3021 u16 pu_delay = 1050; 3021 u16 pu_delay = 1050;
3022 3022
3023 if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS) || idle) 3023 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC) || idle)
3024 pu_delay = 500; 3024 pu_delay = 500;
3025 if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8)) 3025 if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8))
3026 pu_delay = max(pu_delay, (u16)2400); 3026 pu_delay = max(pu_delay, (u16)2400);
@@ -3035,7 +3035,7 @@ static void b43legacy_set_pretbtt(struct b43legacy_wldev *dev)
3035 u16 pretbtt; 3035 u16 pretbtt;
3036 3036
3037 /* The time value is in microseconds. */ 3037 /* The time value is in microseconds. */
3038 if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS)) 3038 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC))
3039 pretbtt = 2; 3039 pretbtt = 2;
3040 else 3040 else
3041 pretbtt = 250; 3041 pretbtt = 250;
@@ -3259,10 +3259,10 @@ static int b43legacy_op_add_interface(struct ieee80211_hw *hw,
3259 3259
3260 /* TODO: allow WDS/AP devices to coexist */ 3260 /* TODO: allow WDS/AP devices to coexist */
3261 3261
3262 if (conf->type != IEEE80211_IF_TYPE_AP && 3262 if (conf->type != NL80211_IFTYPE_AP &&
3263 conf->type != IEEE80211_IF_TYPE_STA && 3263 conf->type != NL80211_IFTYPE_STATION &&
3264 conf->type != IEEE80211_IF_TYPE_WDS && 3264 conf->type != NL80211_IFTYPE_WDS &&
3265 conf->type != IEEE80211_IF_TYPE_IBSS) 3265 conf->type != NL80211_IFTYPE_ADHOC)
3266 return -EOPNOTSUPP; 3266 return -EOPNOTSUPP;
3267 3267
3268 mutex_lock(&wl->mutex); 3268 mutex_lock(&wl->mutex);
@@ -3403,7 +3403,7 @@ out_unlock:
3403} 3403}
3404 3404
3405static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw, 3405static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw,
3406 int aid, int set) 3406 struct ieee80211_sta *sta, bool set)
3407{ 3407{
3408 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 3408 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3409 unsigned long flags; 3409 unsigned long flags;
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c
index bed67a54250c..4c9442b16f3f 100644
--- a/drivers/net/wireless/b43legacy/phy.c
+++ b/drivers/net/wireless/b43legacy/phy.c
@@ -103,7 +103,7 @@ void b43legacy_phy_lock(struct b43legacy_wldev *dev)
103 if (dev->dev->id.revision < 3) { 103 if (dev->dev->id.revision < 3) {
104 b43legacy_mac_suspend(dev); 104 b43legacy_mac_suspend(dev);
105 } else { 105 } else {
106 if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) 106 if (!b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP))
107 b43legacy_power_saving_ctl_bits(dev, -1, 1); 107 b43legacy_power_saving_ctl_bits(dev, -1, 1);
108 } 108 }
109} 109}
@@ -118,7 +118,7 @@ void b43legacy_phy_unlock(struct b43legacy_wldev *dev)
118 if (dev->dev->id.revision < 3) { 118 if (dev->dev->id.revision < 3) {
119 b43legacy_mac_enable(dev); 119 b43legacy_mac_enable(dev);
120 } else { 120 } else {
121 if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) 121 if (!b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP))
122 b43legacy_power_saving_ctl_bits(dev, -1, -1); 122 b43legacy_power_saving_ctl_bits(dev, -1, -1);
123 } 123 }
124} 124}
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 10c64bdb314c..a279bf1dc9b0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -65,6 +65,9 @@ struct iwl3945_rs_sta {
65 u8 ibss_sta_added; 65 u8 ibss_sta_added;
66 struct timer_list rate_scale_flush; 66 struct timer_list rate_scale_flush;
67 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT]; 67 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT];
68
69 /* used to be in sta_info */
70 int last_txrate_idx;
68}; 71};
69 72
70static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT] = { 73static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT] = {
@@ -319,6 +322,7 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
319static void rs_rate_init(void *priv_rate, void *priv_sta, 322static void rs_rate_init(void *priv_rate, void *priv_sta,
320 struct ieee80211_local *local, struct sta_info *sta) 323 struct ieee80211_local *local, struct sta_info *sta)
321{ 324{
325 struct iwl3945_rs_sta *rs_sta = (void *)sta->rate_ctrl_priv;
322 int i; 326 int i;
323 327
324 IWL_DEBUG_RATE("enter\n"); 328 IWL_DEBUG_RATE("enter\n");
@@ -329,17 +333,15 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
329 * after assoc.. */ 333 * after assoc.. */
330 334
331 for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { 335 for (i = IWL_RATE_COUNT - 1; i >= 0; i--) {
332 if (sta->supp_rates[local->hw.conf.channel->band] & (1 << i)) { 336 if (sta->sta.supp_rates[local->hw.conf.channel->band] & (1 << i)) {
333 sta->txrate_idx = i; 337 rs_sta->last_txrate_idx = i;
334 break; 338 break;
335 } 339 }
336 } 340 }
337 341
338 sta->last_txrate_idx = sta->txrate_idx;
339
340 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ 342 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */
341 if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 343 if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ)
342 sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 344 rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
343 345
344 IWL_DEBUG_RATE("leave\n"); 346 IWL_DEBUG_RATE("leave\n");
345} 347}
@@ -674,15 +676,15 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
674 return; 676 return;
675 } 677 }
676 678
677 rate_mask = sta->supp_rates[sband->band]; 679 rs_sta = (void *)sta->rate_ctrl_priv;
678 index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); 680
681 rate_mask = sta->sta.supp_rates[sband->band];
682 index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1);
679 683
680 if (sband->band == IEEE80211_BAND_5GHZ) 684 if (sband->band == IEEE80211_BAND_5GHZ)
681 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; 685 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE;
682 686
683 rs_sta = (void *)sta->rate_ctrl_priv; 687 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
684
685 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) &&
686 !rs_sta->ibss_sta_added) { 688 !rs_sta->ibss_sta_added) {
687 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1); 689 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
688 690
@@ -803,17 +805,15 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
803 805
804 out: 806 out:
805 807
806 sta->last_txrate_idx = index; 808 rs_sta->last_txrate_idx = index;
807 if (sband->band == IEEE80211_BAND_5GHZ) 809 if (sband->band == IEEE80211_BAND_5GHZ)
808 sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; 810 sel->rate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE;
809 else 811 else
810 sta->txrate_idx = sta->last_txrate_idx; 812 sel->rate_idx = rs_sta->last_txrate_idx;
811 813
812 rcu_read_unlock(); 814 rcu_read_unlock();
813 815
814 IWL_DEBUG_RATE("leave: %d\n", index); 816 IWL_DEBUG_RATE("leave: %d\n", index);
815
816 sel->rate_idx = sta->txrate_idx;
817} 817}
818 818
819static struct rate_control_ops rs_ops = { 819static struct rate_control_ops rs_ops = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 3d100e898249..7ca5627cc078 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -520,10 +520,10 @@ static int iwl3945_is_network_packet(struct iwl3945_priv *priv,
520 /* Filter incoming packets to determine if they are targeted toward 520 /* Filter incoming packets to determine if they are targeted toward
521 * this network, discarding packets coming from ourselves */ 521 * this network, discarding packets coming from ourselves */
522 switch (priv->iw_mode) { 522 switch (priv->iw_mode) {
523 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */ 523 case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */
524 /* packets to our IBSS update information */ 524 /* packets to our IBSS update information */
525 return !compare_ether_addr(header->addr3, priv->bssid); 525 return !compare_ether_addr(header->addr3, priv->bssid);
526 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */ 526 case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */
527 /* packets to our IBSS update information */ 527 /* packets to our IBSS update information */
528 return !compare_ether_addr(header->addr2, priv->bssid); 528 return !compare_ether_addr(header->addr2, priv->bssid);
529 default: 529 default:
@@ -807,7 +807,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv,
807 807
808 priv->stations[sta_id].current_rate.rate_n_flags = rate; 808 priv->stations[sta_id].current_rate.rate_n_flags = rate;
809 809
810 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && 810 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
811 (sta_id != priv->hw_setting.bcast_sta_id) && 811 (sta_id != priv->hw_setting.bcast_sta_id) &&
812 (sta_id != IWL_MULTICAST_ID)) 812 (sta_id != IWL_MULTICAST_ID))
813 priv->stations[IWL_STA_ID].current_rate.rate_n_flags = rate; 813 priv->stations[IWL_STA_ID].current_rate.rate_n_flags = rate;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 9bbbc9d7c0e8..2a4933b5fb64 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -851,7 +851,7 @@ struct iwl3945_priv {
851 /* eeprom */ 851 /* eeprom */
852 struct iwl3945_eeprom eeprom; 852 struct iwl3945_eeprom eeprom;
853 853
854 enum ieee80211_if_types iw_mode; 854 enum nl80211_iftype iw_mode;
855 855
856 struct sk_buff *ibss_beacon; 856 struct sk_buff *ibss_beacon;
857 857
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index cccd84c2f8ea..f6003e7996af 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -1569,6 +1569,8 @@ struct iwl_cfg iwl5350_agn_cfg = {
1569 .mod_params = &iwl50_mod_params, 1569 .mod_params = &iwl50_mod_params,
1570}; 1570};
1571 1571
1572MODULE_FIRMWARE("iwlwifi-5000" IWL5000_UCODE_API ".ucode");
1573
1572module_param_named(disable50, iwl50_mod_params.disable, int, 0444); 1574module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
1573MODULE_PARM_DESC(disable50, 1575MODULE_PARM_DESC(disable50,
1574 "manually disable the 50XX radio (default 0 [radio on])"); 1576 "manually disable the 50XX radio (default 0 [radio on])");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index c293e5b6cbb5..8b57b390c8ba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -163,6 +163,9 @@ struct iwl_lq_sta {
163 u32 dbg_fixed_rate; 163 u32 dbg_fixed_rate;
164#endif 164#endif
165 struct iwl_priv *drv; 165 struct iwl_priv *drv;
166
167 /* used to be in sta_info */
168 int last_txrate_idx;
166}; 169};
167 170
168static void rs_rate_scale_perform(struct iwl_priv *priv, 171static void rs_rate_scale_perform(struct iwl_priv *priv,
@@ -356,18 +359,12 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
356 struct iwl_lq_sta *lq_data, u8 tid, 359 struct iwl_lq_sta *lq_data, u8 tid,
357 struct sta_info *sta) 360 struct sta_info *sta)
358{ 361{
359 unsigned long state;
360 DECLARE_MAC_BUF(mac); 362 DECLARE_MAC_BUF(mac);
361 363
362 spin_lock_bh(&sta->lock); 364 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) {
363 state = sta->ampdu_mlme.tid_state_tx[tid];
364 spin_unlock_bh(&sta->lock);
365
366 if (state == HT_AGG_STATE_IDLE &&
367 rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) {
368 IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n", 365 IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n",
369 print_mac(mac, sta->addr), tid); 366 print_mac(mac, sta->sta.addr), tid);
370 ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); 367 ieee80211_start_tx_ba_session(priv->hw, sta->sta.addr, tid);
371 } 368 }
372} 369}
373 370
@@ -821,7 +818,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
821 818
822 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; 819 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv;
823 820
824 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && 821 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
825 !lq_sta->ibss_sta_added) 822 !lq_sta->ibss_sta_added)
826 goto out; 823 goto out;
827 824
@@ -1151,10 +1148,10 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1151 s8 is_green = lq_sta->is_green; 1148 s8 is_green = lq_sta->is_green;
1152 1149
1153 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || 1150 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) ||
1154 !sta->ht_info.ht_supported) 1151 !sta->sta.ht_info.ht_supported)
1155 return -1; 1152 return -1;
1156 1153
1157 if (((sta->ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2) 1154 if (((sta->sta.ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
1158 == WLAN_HT_CAP_SM_PS_STATIC) 1155 == WLAN_HT_CAP_SM_PS_STATIC)
1159 return -1; 1156 return -1;
1160 1157
@@ -1219,7 +1216,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1219 s32 rate; 1216 s32 rate;
1220 1217
1221 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || 1218 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) ||
1222 !sta->ht_info.ht_supported) 1219 !sta->sta.ht_info.ht_supported)
1223 return -1; 1220 return -1;
1224 1221
1225 IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); 1222 IWL_DEBUG_RATE("LQ: try to switch to SISO\n");
@@ -1728,7 +1725,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1728 return; 1725 return;
1729 1726
1730 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; 1727 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv;
1731 lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; 1728 lq_sta->supp_rates = sta->sta.supp_rates[lq_sta->band];
1732 1729
1733 tid = rs_tl_add_packet(lq_sta, hdr); 1730 tid = rs_tl_add_packet(lq_sta, hdr);
1734 1731
@@ -1746,7 +1743,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1746 is_green = lq_sta->is_green; 1743 is_green = lq_sta->is_green;
1747 1744
1748 /* current tx rate */ 1745 /* current tx rate */
1749 index = sta->last_txrate_idx; 1746 index = lq_sta->last_txrate_idx;
1750 1747
1751 IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, 1748 IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index,
1752 tbl->lq_type); 1749 tbl->lq_type);
@@ -2059,15 +2056,7 @@ lq_update:
2059out: 2056out:
2060 tbl->current_rate = rate_n_flags_from_tbl(tbl, index, is_green); 2057 tbl->current_rate = rate_n_flags_from_tbl(tbl, index, is_green);
2061 i = index; 2058 i = index;
2062 sta->last_txrate_idx = i; 2059 lq_sta->last_txrate_idx = i;
2063
2064 /* sta->txrate_idx is an index to A mode rates which start
2065 * at IWL_FIRST_OFDM_RATE
2066 */
2067 if (lq_sta->band == IEEE80211_BAND_5GHZ)
2068 sta->txrate_idx = i - IWL_FIRST_OFDM_RATE;
2069 else
2070 sta->txrate_idx = i;
2071 2060
2072 return; 2061 return;
2073} 2062}
@@ -2090,10 +2079,10 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2090 goto out; 2079 goto out;
2091 2080
2092 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; 2081 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv;
2093 i = sta->last_txrate_idx; 2082 i = lq_sta->last_txrate_idx;
2094 2083
2095 if ((lq_sta->lq.sta_id == 0xff) && 2084 if ((lq_sta->lq.sta_id == 0xff) &&
2096 (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) 2085 (priv->iw_mode == NL80211_IFTYPE_ADHOC))
2097 goto out; 2086 goto out;
2098 2087
2099 valid_tx_ant = priv->hw_params.valid_tx_ant; 2088 valid_tx_ant = priv->hw_params.valid_tx_ant;
@@ -2161,9 +2150,9 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
2161 } 2150 }
2162 2151
2163 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; 2152 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv;
2164 i = sta->last_txrate_idx; 2153 i = lq_sta->last_txrate_idx;
2165 2154
2166 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && 2155 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
2167 !lq_sta->ibss_sta_added) { 2156 !lq_sta->ibss_sta_added) {
2168 u8 sta_id = iwl_find_station(priv, hdr->addr1); 2157 u8 sta_id = iwl_find_station(priv, hdr->addr1);
2169 DECLARE_MAC_BUF(mac); 2158 DECLARE_MAC_BUF(mac);
@@ -2230,8 +2219,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2230 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2219 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
2231 2220
2232 lq_sta->flush_timer = 0; 2221 lq_sta->flush_timer = 0;
2233 lq_sta->supp_rates = sta->supp_rates[sband->band]; 2222 lq_sta->supp_rates = sta->sta.supp_rates[sband->band];
2234 sta->txrate_idx = 3;
2235 for (j = 0; j < LQ_SIZE; j++) 2223 for (j = 0; j < LQ_SIZE; j++)
2236 for (i = 0; i < IWL_RATE_COUNT; i++) 2224 for (i = 0; i < IWL_RATE_COUNT; i++)
2237 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); 2225 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]);
@@ -2243,18 +2231,18 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2243 * after assoc.. */ 2231 * after assoc.. */
2244 2232
2245 lq_sta->ibss_sta_added = 0; 2233 lq_sta->ibss_sta_added = 0;
2246 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 2234 if (priv->iw_mode == NL80211_IFTYPE_AP) {
2247 u8 sta_id = iwl_find_station(priv, sta->addr); 2235 u8 sta_id = iwl_find_station(priv, sta->sta.addr);
2248 DECLARE_MAC_BUF(mac); 2236 DECLARE_MAC_BUF(mac);
2249 2237
2250 /* for IBSS the call are from tasklet */ 2238 /* for IBSS the call are from tasklet */
2251 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2239 IWL_DEBUG_RATE("LQ: ADD station %s\n",
2252 print_mac(mac, sta->addr)); 2240 print_mac(mac, sta->sta.addr));
2253 2241
2254 if (sta_id == IWL_INVALID_STATION) { 2242 if (sta_id == IWL_INVALID_STATION) {
2255 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2243 IWL_DEBUG_RATE("LQ: ADD station %s\n",
2256 print_mac(mac, sta->addr)); 2244 print_mac(mac, sta->sta.addr));
2257 sta_id = iwl_add_station_flags(priv, sta->addr, 2245 sta_id = iwl_add_station_flags(priv, sta->sta.addr,
2258 0, CMD_ASYNC, NULL); 2246 0, CMD_ASYNC, NULL);
2259 } 2247 }
2260 if ((sta_id != IWL_INVALID_STATION)) { 2248 if ((sta_id != IWL_INVALID_STATION)) {
@@ -2266,14 +2254,14 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2266 } 2254 }
2267 2255
2268 /* Find highest tx rate supported by hardware and destination station */ 2256 /* Find highest tx rate supported by hardware and destination station */
2257 lq_sta->last_txrate_idx = 3;
2269 for (i = 0; i < sband->n_bitrates; i++) 2258 for (i = 0; i < sband->n_bitrates; i++)
2270 if (sta->supp_rates[sband->band] & BIT(i)) 2259 if (sta->sta.supp_rates[sband->band] & BIT(i))
2271 sta->txrate_idx = i; 2260 lq_sta->last_txrate_idx = i;
2272 2261
2273 sta->last_txrate_idx = sta->txrate_idx;
2274 /* For MODE_IEEE80211A, skip over cck rates in global rate table */ 2262 /* For MODE_IEEE80211A, skip over cck rates in global rate table */
2275 if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 2263 if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ)
2276 sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2264 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
2277 2265
2278 lq_sta->is_dup = 0; 2266 lq_sta->is_dup = 0;
2279 lq_sta->is_green = rs_use_green(priv, conf); 2267 lq_sta->is_green = rs_use_green(priv, conf);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 31ea28858896..273762769767 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -337,7 +337,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
337 /* If we have set the ASSOC_MSK and we are in BSS mode then 337 /* If we have set the ASSOC_MSK and we are in BSS mode then
338 * add the IWL_AP_ID to the station rate table */ 338 * add the IWL_AP_ID to the station rate table */
339 if (new_assoc) { 339 if (new_assoc) {
340 if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { 340 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
341 ret = iwl_rxon_add_station(priv, 341 ret = iwl_rxon_add_station(priv,
342 priv->active_rxon.bssid_addr, 1); 342 priv->active_rxon.bssid_addr, 1);
343 if (ret == IWL_INVALID_STATION) { 343 if (ret == IWL_INVALID_STATION) {
@@ -448,8 +448,8 @@ static unsigned int iwl_fill_beacon_frame(struct iwl_priv *priv,
448 const u8 *dest, int left) 448 const u8 *dest, int left)
449{ 449{
450 if (!iwl_is_associated(priv) || !priv->ibss_beacon || 450 if (!iwl_is_associated(priv) || !priv->ibss_beacon ||
451 ((priv->iw_mode != IEEE80211_IF_TYPE_IBSS) && 451 ((priv->iw_mode != NL80211_IFTYPE_ADHOC) &&
452 (priv->iw_mode != IEEE80211_IF_TYPE_AP))) 452 (priv->iw_mode != NL80211_IFTYPE_AP)))
453 return 0; 453 return 0;
454 454
455 if (priv->ibss_beacon->len > left) 455 if (priv->ibss_beacon->len > left)
@@ -672,7 +672,7 @@ static void iwl4965_setup_rxon_timing(struct iwl_priv *priv)
672 beacon_int = priv->beacon_int; 672 beacon_int = priv->beacon_int;
673 spin_unlock_irqrestore(&priv->lock, flags); 673 spin_unlock_irqrestore(&priv->lock, flags);
674 674
675 if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { 675 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
676 if (beacon_int == 0) { 676 if (beacon_int == 0) {
677 priv->rxon_timing.beacon_interval = cpu_to_le16(100); 677 priv->rxon_timing.beacon_interval = cpu_to_le16(100);
678 priv->rxon_timing.beacon_init_val = cpu_to_le32(102400); 678 priv->rxon_timing.beacon_init_val = cpu_to_le32(102400);
@@ -721,7 +721,7 @@ static void iwl_set_flags_for_band(struct iwl_priv *priv,
721 else 721 else
722 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 722 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
723 723
724 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 724 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
725 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 725 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
726 726
727 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 727 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
@@ -740,23 +740,23 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
740 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 740 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
741 741
742 switch (priv->iw_mode) { 742 switch (priv->iw_mode) {
743 case IEEE80211_IF_TYPE_AP: 743 case NL80211_IFTYPE_AP:
744 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP; 744 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
745 break; 745 break;
746 746
747 case IEEE80211_IF_TYPE_STA: 747 case NL80211_IFTYPE_STATION:
748 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS; 748 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS;
749 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; 749 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
750 break; 750 break;
751 751
752 case IEEE80211_IF_TYPE_IBSS: 752 case NL80211_IFTYPE_ADHOC:
753 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS; 753 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS;
754 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK; 754 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
755 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK | 755 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
756 RXON_FILTER_ACCEPT_GRP_MSK; 756 RXON_FILTER_ACCEPT_GRP_MSK;
757 break; 757 break;
758 758
759 case IEEE80211_IF_TYPE_MNTR: 759 case NL80211_IFTYPE_MONITOR:
760 priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER; 760 priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER;
761 priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK | 761 priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK |
762 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK; 762 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
@@ -785,7 +785,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
785 * in some case A channels are all non IBSS 785 * in some case A channels are all non IBSS
786 * in this case force B/G channel 786 * in this case force B/G channel
787 */ 787 */
788 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && 788 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
789 !(is_channel_ibss(ch_info))) 789 !(is_channel_ibss(ch_info)))
790 ch_info = &priv->channel_info[0]; 790 ch_info = &priv->channel_info[0];
791 791
@@ -1182,7 +1182,7 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv,
1182 le32_to_cpu(beacon->low_tsf), rate); 1182 le32_to_cpu(beacon->low_tsf), rate);
1183#endif 1183#endif
1184 1184
1185 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 1185 if ((priv->iw_mode == NL80211_IFTYPE_AP) &&
1186 (!test_bit(STATUS_EXIT_PENDING, &priv->status))) 1186 (!test_bit(STATUS_EXIT_PENDING, &priv->status)))
1187 queue_work(priv->workqueue, &priv->beacon_update); 1187 queue_work(priv->workqueue, &priv->beacon_update);
1188} 1188}
@@ -2388,7 +2388,7 @@ static void iwl4965_bg_set_monitor(struct work_struct *work)
2388 2388
2389 mutex_lock(&priv->mutex); 2389 mutex_lock(&priv->mutex);
2390 2390
2391 ret = iwl4965_set_mode(priv, IEEE80211_IF_TYPE_MNTR); 2391 ret = iwl4965_set_mode(priv, NL80211_IFTYPE_MONITOR);
2392 2392
2393 if (ret) { 2393 if (ret) {
2394 if (ret == -EAGAIN) 2394 if (ret == -EAGAIN)
@@ -2469,7 +2469,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2469 DECLARE_MAC_BUF(mac); 2469 DECLARE_MAC_BUF(mac);
2470 unsigned long flags; 2470 unsigned long flags;
2471 2471
2472 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 2472 if (priv->iw_mode == NL80211_IFTYPE_AP) {
2473 IWL_ERROR("%s Should not be called in AP mode\n", __func__); 2473 IWL_ERROR("%s Should not be called in AP mode\n", __func__);
2474 return; 2474 return;
2475 } 2475 }
@@ -2524,7 +2524,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2524 else 2524 else
2525 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2525 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2526 2526
2527 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 2527 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
2528 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2528 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2529 2529
2530 } 2530 }
@@ -2532,10 +2532,10 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2532 iwl4965_commit_rxon(priv); 2532 iwl4965_commit_rxon(priv);
2533 2533
2534 switch (priv->iw_mode) { 2534 switch (priv->iw_mode) {
2535 case IEEE80211_IF_TYPE_STA: 2535 case NL80211_IFTYPE_STATION:
2536 break; 2536 break;
2537 2537
2538 case IEEE80211_IF_TYPE_IBSS: 2538 case NL80211_IFTYPE_ADHOC:
2539 2539
2540 /* assume default assoc id */ 2540 /* assume default assoc id */
2541 priv->assoc_id = 1; 2541 priv->assoc_id = 1;
@@ -2551,7 +2551,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2551 break; 2551 break;
2552 } 2552 }
2553 2553
2554 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 2554 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
2555 priv->assoc_station_added = 1; 2555 priv->assoc_station_added = 1;
2556 2556
2557 spin_lock_irqsave(&priv->lock, flags); 2557 spin_lock_irqsave(&priv->lock, flags);
@@ -2828,7 +2828,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
2828 goto out; 2828 goto out;
2829 } 2829 }
2830 2830
2831 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS && 2831 if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
2832 !is_channel_ibss(ch_info)) { 2832 !is_channel_ibss(ch_info)) {
2833 IWL_ERROR("channel %d in band %d not IBSS channel\n", 2833 IWL_ERROR("channel %d in band %d not IBSS channel\n",
2834 conf->channel->hw_value, conf->channel->band); 2834 conf->channel->hw_value, conf->channel->band);
@@ -2943,7 +2943,7 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
2943 priv->staging_rxon.flags &= 2943 priv->staging_rxon.flags &=
2944 ~RXON_FLG_SHORT_SLOT_MSK; 2944 ~RXON_FLG_SHORT_SLOT_MSK;
2945 2945
2946 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 2946 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
2947 priv->staging_rxon.flags &= 2947 priv->staging_rxon.flags &=
2948 ~RXON_FLG_SHORT_SLOT_MSK; 2948 ~RXON_FLG_SHORT_SLOT_MSK;
2949 } 2949 }
@@ -2982,7 +2982,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2982 return 0; 2982 return 0;
2983 } 2983 }
2984 2984
2985 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS && 2985 if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
2986 conf->changed & IEEE80211_IFCC_BEACON) { 2986 conf->changed & IEEE80211_IFCC_BEACON) {
2987 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 2987 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2988 if (!beacon) 2988 if (!beacon)
@@ -2992,7 +2992,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2992 return rc; 2992 return rc;
2993 } 2993 }
2994 2994
2995 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 2995 if ((priv->iw_mode == NL80211_IFTYPE_AP) &&
2996 (!conf->ssid_len)) { 2996 (!conf->ssid_len)) {
2997 IWL_DEBUG_MAC80211 2997 IWL_DEBUG_MAC80211
2998 ("Leaving in AP mode because HostAPD is not ready.\n"); 2998 ("Leaving in AP mode because HostAPD is not ready.\n");
@@ -3015,7 +3015,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
3015 !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) { 3015 !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
3016 */ 3016 */
3017 3017
3018 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 3018 if (priv->iw_mode == NL80211_IFTYPE_AP) {
3019 if (!conf->bssid) { 3019 if (!conf->bssid) {
3020 conf->bssid = priv->mac_addr; 3020 conf->bssid = priv->mac_addr;
3021 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN); 3021 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
@@ -3050,11 +3050,11 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
3050 * to verify) - jpk */ 3050 * to verify) - jpk */
3051 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 3051 memcpy(priv->bssid, conf->bssid, ETH_ALEN);
3052 3052
3053 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) 3053 if (priv->iw_mode == NL80211_IFTYPE_AP)
3054 iwl4965_config_ap(priv); 3054 iwl4965_config_ap(priv);
3055 else { 3055 else {
3056 rc = iwl4965_commit_rxon(priv); 3056 rc = iwl4965_commit_rxon(priv);
3057 if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) 3057 if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
3058 iwl_rxon_add_station( 3058 iwl_rxon_add_station(
3059 priv, priv->active_rxon.bssid_addr, 1); 3059 priv, priv->active_rxon.bssid_addr, 1);
3060 } 3060 }
@@ -3090,7 +3090,7 @@ static void iwl4965_configure_filter(struct ieee80211_hw *hw,
3090 3090
3091 if (changed_flags & (*total_flags) & FIF_OTHER_BSS) { 3091 if (changed_flags & (*total_flags) & FIF_OTHER_BSS) {
3092 IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n", 3092 IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n",
3093 IEEE80211_IF_TYPE_MNTR, 3093 NL80211_IFTYPE_MONITOR,
3094 changed_flags, *total_flags); 3094 changed_flags, *total_flags);
3095 /* queue work 'cuz mac80211 is holding a lock which 3095 /* queue work 'cuz mac80211 is holding a lock which
3096 * prevents us from issuing (synchronous) f/w cmds */ 3096 * prevents us from issuing (synchronous) f/w cmds */
@@ -3204,7 +3204,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3204 goto out_unlock; 3204 goto out_unlock;
3205 } 3205 }
3206 3206
3207 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { /* APs don't scan */ 3207 if (priv->iw_mode == NL80211_IFTYPE_AP) { /* APs don't scan */
3208 ret = -EIO; 3208 ret = -EIO;
3209 IWL_ERROR("ERROR: APs don't scan\n"); 3209 IWL_ERROR("ERROR: APs don't scan\n");
3210 goto out_unlock; 3210 goto out_unlock;
@@ -3329,7 +3329,7 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3329 * in 1X mode. 3329 * in 1X mode.
3330 * In legacy wep mode, we use another host command to the uCode */ 3330 * In legacy wep mode, we use another host command to the uCode */
3331 if (key->alg == ALG_WEP && sta_id == priv->hw_params.bcast_sta_id && 3331 if (key->alg == ALG_WEP && sta_id == priv->hw_params.bcast_sta_id &&
3332 priv->iw_mode != IEEE80211_IF_TYPE_AP) { 3332 priv->iw_mode != NL80211_IFTYPE_AP) {
3333 if (cmd == SET_KEY) 3333 if (cmd == SET_KEY)
3334 is_default_wep_key = !priv->key_mapping_key; 3334 is_default_wep_key = !priv->key_mapping_key;
3335 else 3335 else
@@ -3400,7 +3400,7 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3400 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0; 3400 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
3401 priv->qos_data.qos_active = 1; 3401 priv->qos_data.qos_active = 1;
3402 3402
3403 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) 3403 if (priv->iw_mode == NL80211_IFTYPE_AP)
3404 iwl_activate_qos(priv, 1); 3404 iwl_activate_qos(priv, 1);
3405 else if (priv->assoc_id && iwl_is_associated(priv)) 3405 else if (priv->assoc_id && iwl_is_associated(priv))
3406 iwl_activate_qos(priv, 0); 3406 iwl_activate_qos(priv, 0);
@@ -3413,13 +3413,13 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3413 3413
3414static int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, 3414static int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
3415 enum ieee80211_ampdu_mlme_action action, 3415 enum ieee80211_ampdu_mlme_action action,
3416 const u8 *addr, u16 tid, u16 *ssn) 3416 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
3417{ 3417{
3418 struct iwl_priv *priv = hw->priv; 3418 struct iwl_priv *priv = hw->priv;
3419 DECLARE_MAC_BUF(mac); 3419 DECLARE_MAC_BUF(mac);
3420 3420
3421 IWL_DEBUG_HT("A-MPDU action on addr %s tid %d\n", 3421 IWL_DEBUG_HT("A-MPDU action on addr %s tid %d\n",
3422 print_mac(mac, addr), tid); 3422 print_mac(mac, sta->addr), tid);
3423 3423
3424 if (!(priv->cfg->sku & IWL_SKU_N)) 3424 if (!(priv->cfg->sku & IWL_SKU_N))
3425 return -EACCES; 3425 return -EACCES;
@@ -3427,16 +3427,16 @@ static int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
3427 switch (action) { 3427 switch (action) {
3428 case IEEE80211_AMPDU_RX_START: 3428 case IEEE80211_AMPDU_RX_START:
3429 IWL_DEBUG_HT("start Rx\n"); 3429 IWL_DEBUG_HT("start Rx\n");
3430 return iwl_rx_agg_start(priv, addr, tid, *ssn); 3430 return iwl_rx_agg_start(priv, sta->addr, tid, *ssn);
3431 case IEEE80211_AMPDU_RX_STOP: 3431 case IEEE80211_AMPDU_RX_STOP:
3432 IWL_DEBUG_HT("stop Rx\n"); 3432 IWL_DEBUG_HT("stop Rx\n");
3433 return iwl_rx_agg_stop(priv, addr, tid); 3433 return iwl_rx_agg_stop(priv, sta->addr, tid);
3434 case IEEE80211_AMPDU_TX_START: 3434 case IEEE80211_AMPDU_TX_START:
3435 IWL_DEBUG_HT("start Tx\n"); 3435 IWL_DEBUG_HT("start Tx\n");
3436 return iwl_tx_agg_start(priv, addr, tid, ssn); 3436 return iwl_tx_agg_start(priv, sta->addr, tid, ssn);
3437 case IEEE80211_AMPDU_TX_STOP: 3437 case IEEE80211_AMPDU_TX_STOP:
3438 IWL_DEBUG_HT("stop Tx\n"); 3438 IWL_DEBUG_HT("stop Tx\n");
3439 return iwl_tx_agg_stop(priv, addr, tid); 3439 return iwl_tx_agg_stop(priv, sta->addr, tid);
3440 default: 3440 default:
3441 IWL_DEBUG_HT("unknown\n"); 3441 IWL_DEBUG_HT("unknown\n");
3442 return -EINVAL; 3442 return -EINVAL;
@@ -3518,7 +3518,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
3518 3518
3519 priv->beacon_int = priv->hw->conf.beacon_int; 3519 priv->beacon_int = priv->hw->conf.beacon_int;
3520 priv->timestamp = 0; 3520 priv->timestamp = 0;
3521 if ((priv->iw_mode == IEEE80211_IF_TYPE_STA)) 3521 if ((priv->iw_mode == NL80211_IFTYPE_STATION))
3522 priv->beacon_int = 0; 3522 priv->beacon_int = 0;
3523 3523
3524 spin_unlock_irqrestore(&priv->lock, flags); 3524 spin_unlock_irqrestore(&priv->lock, flags);
@@ -3532,7 +3532,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
3532 /* we are restarting association process 3532 /* we are restarting association process
3533 * clear RXON_FILTER_ASSOC_MSK bit 3533 * clear RXON_FILTER_ASSOC_MSK bit
3534 */ 3534 */
3535 if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 3535 if (priv->iw_mode != NL80211_IFTYPE_AP) {
3536 iwl_scan_cancel_timeout(priv, 100); 3536 iwl_scan_cancel_timeout(priv, 100);
3537 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3537 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3538 iwl4965_commit_rxon(priv); 3538 iwl4965_commit_rxon(priv);
@@ -3541,7 +3541,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
3541 iwl_power_update_mode(priv, 0); 3541 iwl_power_update_mode(priv, 0);
3542 3542
3543 /* Per mac80211.h: This is only used in IBSS mode... */ 3543 /* Per mac80211.h: This is only used in IBSS mode... */
3544 if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { 3544 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
3545 3545
3546 /* switch to CAM during association period. 3546 /* switch to CAM during association period.
3547 * the ucode will block any association/authentication 3547 * the ucode will block any association/authentication
@@ -3580,7 +3580,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
3580 return -EIO; 3580 return -EIO;
3581 } 3581 }
3582 3582
3583 if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { 3583 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
3584 IWL_DEBUG_MAC80211("leave - not IBSS\n"); 3584 IWL_DEBUG_MAC80211("leave - not IBSS\n");
3585 mutex_unlock(&priv->mutex); 3585 mutex_unlock(&priv->mutex);
3586 return -EIO; 3586 return -EIO;
@@ -4506,7 +4506,10 @@ static struct pci_device_id iwl_hw_card_ids[] = {
4506 {IWL_PCI_DEVICE(0x4235, PCI_ANY_ID, iwl5300_agn_cfg)}, 4506 {IWL_PCI_DEVICE(0x4235, PCI_ANY_ID, iwl5300_agn_cfg)},
4507 {IWL_PCI_DEVICE(0x4236, PCI_ANY_ID, iwl5300_agn_cfg)}, 4507 {IWL_PCI_DEVICE(0x4236, PCI_ANY_ID, iwl5300_agn_cfg)},
4508 {IWL_PCI_DEVICE(0x4237, PCI_ANY_ID, iwl5100_agn_cfg)}, 4508 {IWL_PCI_DEVICE(0x4237, PCI_ANY_ID, iwl5100_agn_cfg)},
4509 {IWL_PCI_DEVICE(0x423A, PCI_ANY_ID, iwl5350_agn_cfg)}, 4509/* 5350 WiFi/WiMax */
4510 {IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)},
4511 {IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)},
4512 {IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)},
4510#endif /* CONFIG_IWL5000 */ 4513#endif /* CONFIG_IWL5000 */
4511 {0} 4514 {0}
4512}; 4515};
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 36d08b0eec43..d80184ee911c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -306,14 +306,14 @@ void iwl_reset_qos(struct iwl_priv *priv)
306 spin_lock_irqsave(&priv->lock, flags); 306 spin_lock_irqsave(&priv->lock, flags);
307 priv->qos_data.qos_active = 0; 307 priv->qos_data.qos_active = 0;
308 308
309 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) { 309 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) {
310 if (priv->qos_data.qos_enable) 310 if (priv->qos_data.qos_enable)
311 priv->qos_data.qos_active = 1; 311 priv->qos_data.qos_active = 1;
312 if (!(priv->active_rate & 0xfff0)) { 312 if (!(priv->active_rate & 0xfff0)) {
313 cw_min = 31; 313 cw_min = 31;
314 is_legacy = 1; 314 is_legacy = 1;
315 } 315 }
316 } else if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 316 } else if (priv->iw_mode == NL80211_IFTYPE_AP) {
317 if (priv->qos_data.qos_enable) 317 if (priv->qos_data.qos_enable)
318 priv->qos_data.qos_active = 1; 318 priv->qos_data.qos_active = 1;
319 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) { 319 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) {
@@ -932,7 +932,7 @@ int iwl_init_drv(struct iwl_priv *priv)
932 priv->ieee_rates = NULL; 932 priv->ieee_rates = NULL;
933 priv->band = IEEE80211_BAND_2GHZ; 933 priv->band = IEEE80211_BAND_2GHZ;
934 934
935 priv->iw_mode = IEEE80211_IF_TYPE_STA; 935 priv->iw_mode = NL80211_IFTYPE_STATION;
936 936
937 priv->use_ant_b_for_management_frame = 1; /* start with ant B */ 937 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
938 priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED; 938 priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED;
@@ -1396,7 +1396,7 @@ void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv)
1396 1396
1397 iwl_scan_cancel(priv); 1397 iwl_scan_cancel(priv);
1398 /* FIXME: This is a workaround for AP */ 1398 /* FIXME: This is a workaround for AP */
1399 if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 1399 if (priv->iw_mode != NL80211_IFTYPE_AP) {
1400 spin_lock_irqsave(&priv->lock, flags); 1400 spin_lock_irqsave(&priv->lock, flags);
1401 iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, 1401 iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
1402 CSR_UCODE_SW_BIT_RFKILL); 1402 CSR_UCODE_SW_BIT_RFKILL);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 1823687e5820..c018121085e9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -954,7 +954,7 @@ struct iwl_priv {
954 u8 *eeprom; 954 u8 *eeprom;
955 struct iwl_eeprom_calib_info *calib_info; 955 struct iwl_eeprom_calib_info *calib_info;
956 956
957 enum ieee80211_if_types iw_mode; 957 enum nl80211_iftype iw_mode;
958 958
959 struct sk_buff *ibss_beacon; 959 struct sk_buff *ibss_beacon;
960 960
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 55ec31ec9e15..60a03d2d2d0e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -290,7 +290,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
290 final_mode = setting->critical_power_setting; 290 final_mode = setting->critical_power_setting;
291 291
292 /* driver only support CAM for non STA network */ 292 /* driver only support CAM for non STA network */
293 if (priv->iw_mode != IEEE80211_IF_TYPE_STA) 293 if (priv->iw_mode != NL80211_IFTYPE_STATION)
294 final_mode = IWL_POWER_MODE_CAM; 294 final_mode = IWL_POWER_MODE_CAM;
295 295
296 if (!iwl_is_rfkill(priv) && !setting->power_disabled && 296 if (!iwl_is_rfkill(priv) && !setting->power_disabled &&
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index faad4d3f56e1..38b2946b1d81 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -1026,10 +1026,10 @@ static int iwl_is_network_packet(struct iwl_priv *priv,
1026 /* Filter incoming packets to determine if they are targeted toward 1026 /* Filter incoming packets to determine if they are targeted toward
1027 * this network, discarding packets coming from ourselves */ 1027 * this network, discarding packets coming from ourselves */
1028 switch (priv->iw_mode) { 1028 switch (priv->iw_mode) {
1029 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */ 1029 case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */
1030 /* packets to our IBSS update information */ 1030 /* packets to our IBSS update information */
1031 return !compare_ether_addr(header->addr3, priv->bssid); 1031 return !compare_ether_addr(header->addr3, priv->bssid);
1032 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */ 1032 case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */
1033 /* packets to our IBSS update information */ 1033 /* packets to our IBSS update information */
1034 return !compare_ether_addr(header->addr2, priv->bssid); 1034 return !compare_ether_addr(header->addr2, priv->bssid);
1035 default: 1035 default:
@@ -1169,7 +1169,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1169 rx_status.flag |= RX_FLAG_SHORTPRE; 1169 rx_status.flag |= RX_FLAG_SHORTPRE;
1170 1170
1171 /* Take shortcut when only in monitor mode */ 1171 /* Take shortcut when only in monitor mode */
1172 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { 1172 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
1173 iwl_pass_packet_to_mac80211(priv, include_phy, 1173 iwl_pass_packet_to_mac80211(priv, include_phy,
1174 rxb, &rx_status); 1174 rxb, &rx_status);
1175 return; 1175 return;
@@ -1186,7 +1186,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1186 switch (fc & IEEE80211_FCTL_FTYPE) { 1186 switch (fc & IEEE80211_FCTL_FTYPE) {
1187 case IEEE80211_FTYPE_MGMT: 1187 case IEEE80211_FTYPE_MGMT:
1188 case IEEE80211_FTYPE_DATA: 1188 case IEEE80211_FTYPE_DATA:
1189 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) 1189 if (priv->iw_mode == NL80211_IFTYPE_AP)
1190 iwl_update_ps_mode(priv, fc & IEEE80211_FCTL_PM, 1190 iwl_update_ps_mode(priv, fc & IEEE80211_FCTL_PM,
1191 header->addr2); 1191 header->addr2);
1192 /* fall through */ 1192 /* fall through */
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index d026aaf62335..09c264be0496 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -463,7 +463,7 @@ void iwl_init_scan_params(struct iwl_priv *priv)
463 463
464int iwl_scan_initiate(struct iwl_priv *priv) 464int iwl_scan_initiate(struct iwl_priv *priv)
465{ 465{
466 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 466 if (priv->iw_mode == NL80211_IFTYPE_AP) {
467 IWL_ERROR("APs don't scan.\n"); 467 IWL_ERROR("APs don't scan.\n");
468 return 0; 468 return 0;
469 } 469 }
@@ -868,7 +868,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
868 868
869 scan->tx_cmd.len = cpu_to_le16(cmd_len); 869 scan->tx_cmd.len = cpu_to_le16(cmd_len);
870 870
871 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) 871 if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
872 scan->filter_flags = RXON_FILTER_PROMISC_MSK; 872 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
873 873
874 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | 874 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index a72569f1acb5..61797f3f8d5c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -47,8 +47,8 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
47 unsigned long flags; 47 unsigned long flags;
48 DECLARE_MAC_BUF(mac); 48 DECLARE_MAC_BUF(mac);
49 49
50 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) || 50 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
51 (priv->iw_mode == IEEE80211_IF_TYPE_AP)) 51 (priv->iw_mode == NL80211_IFTYPE_AP))
52 start = IWL_STA_ID; 52 start = IWL_STA_ID;
53 53
54 if (is_broadcast_ether_addr(addr)) 54 if (is_broadcast_ether_addr(addr))
@@ -74,7 +74,7 @@ EXPORT_SYMBOL(iwl_find_station);
74 74
75int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) 75int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
76{ 76{
77 if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { 77 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
78 return IWL_AP_ID; 78 return IWL_AP_ID;
79 } else { 79 } else {
80 u8 *da = ieee80211_get_DA(hdr); 80 u8 *da = ieee80211_get_DA(hdr);
@@ -286,7 +286,7 @@ u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
286 286
287 /* BCAST station and IBSS stations do not work in HT mode */ 287 /* BCAST station and IBSS stations do not work in HT mode */
288 if (sta_id != priv->hw_params.bcast_sta_id && 288 if (sta_id != priv->hw_params.bcast_sta_id &&
289 priv->iw_mode != IEEE80211_IF_TYPE_IBSS) 289 priv->iw_mode != NL80211_IFTYPE_ADHOC)
290 iwl_set_ht_add_station(priv, sta_id, ht_info); 290 iwl_set_ht_add_station(priv, sta_id, ht_info);
291 291
292 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 292 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
@@ -817,7 +817,7 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
817 }; 817 };
818 818
819 if ((lq->sta_id == 0xFF) && 819 if ((lq->sta_id == 0xFF) &&
820 (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) 820 (priv->iw_mode == NL80211_IFTYPE_ADHOC))
821 return -EINVAL; 821 return -EINVAL;
822 822
823 if (lq->sta_id == 0xFF) 823 if (lq->sta_id == 0xFF)
@@ -904,7 +904,7 @@ int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
904 904
905 if ((is_ap) && 905 if ((is_ap) &&
906 (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) && 906 (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) &&
907 (priv->iw_mode == IEEE80211_IF_TYPE_STA)) 907 (priv->iw_mode == NL80211_IFTYPE_STATION))
908 sta_id = iwl_add_station_flags(priv, addr, is_ap, 908 sta_id = iwl_add_station_flags(priv, addr, is_ap,
909 0, cur_ht_config); 909 0, cur_ht_config);
910 else 910 else
@@ -938,11 +938,11 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
938 938
939 /* If we are a client station in a BSS network, use the special 939 /* If we are a client station in a BSS network, use the special
940 * AP station entry (that's the only station we communicate with) */ 940 * AP station entry (that's the only station we communicate with) */
941 case IEEE80211_IF_TYPE_STA: 941 case NL80211_IFTYPE_STATION:
942 return IWL_AP_ID; 942 return IWL_AP_ID;
943 943
944 /* If we are an AP, then find the station, or use BCAST */ 944 /* If we are an AP, then find the station, or use BCAST */
945 case IEEE80211_IF_TYPE_AP: 945 case NL80211_IFTYPE_AP:
946 sta_id = iwl_find_station(priv, hdr->addr1); 946 sta_id = iwl_find_station(priv, hdr->addr1);
947 if (sta_id != IWL_INVALID_STATION) 947 if (sta_id != IWL_INVALID_STATION)
948 return sta_id; 948 return sta_id;
@@ -950,7 +950,7 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
950 950
951 /* If this frame is going out to an IBSS network, find the station, 951 /* If this frame is going out to an IBSS network, find the station,
952 * or create a new station table entry */ 952 * or create a new station table entry */
953 case IEEE80211_IF_TYPE_IBSS: 953 case NL80211_IFTYPE_ADHOC:
954 sta_id = iwl_find_station(priv, hdr->addr1); 954 sta_id = iwl_find_station(priv, hdr->addr1);
955 if (sta_id != IWL_INVALID_STATION) 955 if (sta_id != IWL_INVALID_STATION)
956 return sta_id; 956 return sta_id;
@@ -970,7 +970,7 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
970 970
971 /* If we are in monitor mode, use BCAST. This is required for 971 /* If we are in monitor mode, use BCAST. This is required for
972 * packet injection. */ 972 * packet injection. */
973 case IEEE80211_IF_TYPE_MNTR: 973 case NL80211_IFTYPE_MONITOR:
974 return priv->hw_params.bcast_sta_id; 974 return priv->hw_params.bcast_sta_id;
975 975
976 default: 976 default:
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 9d5bcf46cbe9..e9feca4033f9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -814,10 +814,10 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
814 814
815 /* drop all data frame if we are not associated */ 815 /* drop all data frame if we are not associated */
816 if (ieee80211_is_data(fc) && 816 if (ieee80211_is_data(fc) &&
817 (priv->iw_mode != IEEE80211_IF_TYPE_MNTR || 817 (priv->iw_mode != NL80211_IFTYPE_MONITOR ||
818 !(info->flags & IEEE80211_TX_CTL_INJECTED)) && /* packet injection */ 818 !(info->flags & IEEE80211_TX_CTL_INJECTED)) && /* packet injection */
819 (!iwl_is_associated(priv) || 819 (!iwl_is_associated(priv) ||
820 ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) || 820 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) ||
821 !priv->assoc_station_added)) { 821 !priv->assoc_station_added)) {
822 IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n"); 822 IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n");
823 goto drop_unlock; 823 goto drop_unlock;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index cbbe73a12887..62b26befddc5 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1160,7 +1160,7 @@ static int iwl3945_commit_rxon(struct iwl3945_priv *priv)
1160 /* If we have set the ASSOC_MSK and we are in BSS mode then 1160 /* If we have set the ASSOC_MSK and we are in BSS mode then
1161 * add the IWL_AP_ID to the station rate table */ 1161 * add the IWL_AP_ID to the station rate table */
1162 if (iwl3945_is_associated(priv) && 1162 if (iwl3945_is_associated(priv) &&
1163 (priv->iw_mode == IEEE80211_IF_TYPE_STA)) 1163 (priv->iw_mode == NL80211_IFTYPE_STATION))
1164 if (iwl3945_add_station(priv, priv->active_rxon.bssid_addr, 1, 0) 1164 if (iwl3945_add_station(priv, priv->active_rxon.bssid_addr, 1, 0)
1165 == IWL_INVALID_STATION) { 1165 == IWL_INVALID_STATION) {
1166 IWL_ERROR("Error adding AP address for transmit.\n"); 1166 IWL_ERROR("Error adding AP address for transmit.\n");
@@ -1447,8 +1447,8 @@ unsigned int iwl3945_fill_beacon_frame(struct iwl3945_priv *priv,
1447{ 1447{
1448 1448
1449 if (!iwl3945_is_associated(priv) || !priv->ibss_beacon || 1449 if (!iwl3945_is_associated(priv) || !priv->ibss_beacon ||
1450 ((priv->iw_mode != IEEE80211_IF_TYPE_IBSS) && 1450 ((priv->iw_mode != NL80211_IFTYPE_ADHOC) &&
1451 (priv->iw_mode != IEEE80211_IF_TYPE_AP))) 1451 (priv->iw_mode != NL80211_IFTYPE_AP)))
1452 return 0; 1452 return 0;
1453 1453
1454 if (priv->ibss_beacon->len > left) 1454 if (priv->ibss_beacon->len > left)
@@ -1746,14 +1746,14 @@ static void iwl3945_reset_qos(struct iwl3945_priv *priv)
1746 spin_lock_irqsave(&priv->lock, flags); 1746 spin_lock_irqsave(&priv->lock, flags);
1747 priv->qos_data.qos_active = 0; 1747 priv->qos_data.qos_active = 0;
1748 1748
1749 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) { 1749 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) {
1750 if (priv->qos_data.qos_enable) 1750 if (priv->qos_data.qos_enable)
1751 priv->qos_data.qos_active = 1; 1751 priv->qos_data.qos_active = 1;
1752 if (!(priv->active_rate & 0xfff0)) { 1752 if (!(priv->active_rate & 0xfff0)) {
1753 cw_min = 31; 1753 cw_min = 31;
1754 is_legacy = 1; 1754 is_legacy = 1;
1755 } 1755 }
1756 } else if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 1756 } else if (priv->iw_mode == NL80211_IFTYPE_AP) {
1757 if (priv->qos_data.qos_enable) 1757 if (priv->qos_data.qos_enable)
1758 priv->qos_data.qos_active = 1; 1758 priv->qos_data.qos_active = 1;
1759 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) { 1759 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) {
@@ -2120,7 +2120,7 @@ static void iwl3945_setup_rxon_timing(struct iwl3945_priv *priv)
2120 beacon_int = priv->beacon_int; 2120 beacon_int = priv->beacon_int;
2121 spin_unlock_irqrestore(&priv->lock, flags); 2121 spin_unlock_irqrestore(&priv->lock, flags);
2122 2122
2123 if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { 2123 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
2124 if (beacon_int == 0) { 2124 if (beacon_int == 0) {
2125 priv->rxon_timing.beacon_interval = cpu_to_le16(100); 2125 priv->rxon_timing.beacon_interval = cpu_to_le16(100);
2126 priv->rxon_timing.beacon_init_val = cpu_to_le32(102400); 2126 priv->rxon_timing.beacon_init_val = cpu_to_le32(102400);
@@ -2156,7 +2156,7 @@ static void iwl3945_setup_rxon_timing(struct iwl3945_priv *priv)
2156 2156
2157static int iwl3945_scan_initiate(struct iwl3945_priv *priv) 2157static int iwl3945_scan_initiate(struct iwl3945_priv *priv)
2158{ 2158{
2159 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 2159 if (priv->iw_mode == NL80211_IFTYPE_AP) {
2160 IWL_ERROR("APs don't scan.\n"); 2160 IWL_ERROR("APs don't scan.\n");
2161 return 0; 2161 return 0;
2162 } 2162 }
@@ -2218,7 +2218,7 @@ static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv,
2218 else 2218 else
2219 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2219 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2220 2220
2221 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 2221 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
2222 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2222 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2223 2223
2224 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 2224 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
@@ -2237,23 +2237,23 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv)
2237 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 2237 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
2238 2238
2239 switch (priv->iw_mode) { 2239 switch (priv->iw_mode) {
2240 case IEEE80211_IF_TYPE_AP: 2240 case NL80211_IFTYPE_AP:
2241 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP; 2241 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
2242 break; 2242 break;
2243 2243
2244 case IEEE80211_IF_TYPE_STA: 2244 case NL80211_IFTYPE_STATION:
2245 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS; 2245 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS;
2246 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; 2246 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
2247 break; 2247 break;
2248 2248
2249 case IEEE80211_IF_TYPE_IBSS: 2249 case NL80211_IFTYPE_ADHOC:
2250 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS; 2250 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS;
2251 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK; 2251 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
2252 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK | 2252 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
2253 RXON_FILTER_ACCEPT_GRP_MSK; 2253 RXON_FILTER_ACCEPT_GRP_MSK;
2254 break; 2254 break;
2255 2255
2256 case IEEE80211_IF_TYPE_MNTR: 2256 case NL80211_IFTYPE_MONITOR:
2257 priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER; 2257 priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER;
2258 priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK | 2258 priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK |
2259 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK; 2259 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
@@ -2282,7 +2282,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv)
2282 * in some case A channels are all non IBSS 2282 * in some case A channels are all non IBSS
2283 * in this case force B/G channel 2283 * in this case force B/G channel
2284 */ 2284 */
2285 if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && 2285 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
2286 !(is_channel_ibss(ch_info))) 2286 !(is_channel_ibss(ch_info)))
2287 ch_info = &priv->channel_info[0]; 2287 ch_info = &priv->channel_info[0];
2288 2288
@@ -2302,7 +2302,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv)
2302 2302
2303static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode) 2303static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode)
2304{ 2304{
2305 if (mode == IEEE80211_IF_TYPE_IBSS) { 2305 if (mode == NL80211_IFTYPE_ADHOC) {
2306 const struct iwl3945_channel_info *ch_info; 2306 const struct iwl3945_channel_info *ch_info;
2307 2307
2308 ch_info = iwl3945_get_channel_info(priv, 2308 ch_info = iwl3945_get_channel_info(priv,
@@ -2469,11 +2469,11 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h
2469 2469
2470 /* If we are a client station in a BSS network, use the special 2470 /* If we are a client station in a BSS network, use the special
2471 * AP station entry (that's the only station we communicate with) */ 2471 * AP station entry (that's the only station we communicate with) */
2472 case IEEE80211_IF_TYPE_STA: 2472 case NL80211_IFTYPE_STATION:
2473 return IWL_AP_ID; 2473 return IWL_AP_ID;
2474 2474
2475 /* If we are an AP, then find the station, or use BCAST */ 2475 /* If we are an AP, then find the station, or use BCAST */
2476 case IEEE80211_IF_TYPE_AP: 2476 case NL80211_IFTYPE_AP:
2477 sta_id = iwl3945_hw_find_station(priv, hdr->addr1); 2477 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
2478 if (sta_id != IWL_INVALID_STATION) 2478 if (sta_id != IWL_INVALID_STATION)
2479 return sta_id; 2479 return sta_id;
@@ -2481,7 +2481,7 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h
2481 2481
2482 /* If this frame is going out to an IBSS network, find the station, 2482 /* If this frame is going out to an IBSS network, find the station,
2483 * or create a new station table entry */ 2483 * or create a new station table entry */
2484 case IEEE80211_IF_TYPE_IBSS: { 2484 case NL80211_IFTYPE_ADHOC: {
2485 DECLARE_MAC_BUF(mac); 2485 DECLARE_MAC_BUF(mac);
2486 2486
2487 /* Create new station table entry */ 2487 /* Create new station table entry */
@@ -2502,7 +2502,7 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h
2502 } 2502 }
2503 /* If we are in monitor mode, use BCAST. This is required for 2503 /* If we are in monitor mode, use BCAST. This is required for
2504 * packet injection. */ 2504 * packet injection. */
2505 case IEEE80211_IF_TYPE_MNTR: 2505 case NL80211_IFTYPE_MONITOR:
2506 return priv->hw_setting.bcast_sta_id; 2506 return priv->hw_setting.bcast_sta_id;
2507 2507
2508 default: 2508 default:
@@ -2565,9 +2565,9 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
2565 2565
2566 /* drop all data frame if we are not associated */ 2566 /* drop all data frame if we are not associated */
2567 if (ieee80211_is_data(fc) && 2567 if (ieee80211_is_data(fc) &&
2568 (priv->iw_mode != IEEE80211_IF_TYPE_MNTR) && /* packet injection */ 2568 (priv->iw_mode != NL80211_IFTYPE_MONITOR) && /* packet injection */
2569 (!iwl3945_is_associated(priv) || 2569 (!iwl3945_is_associated(priv) ||
2570 ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id))) { 2570 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) {
2571 IWL_DEBUG_DROP("Dropping - !iwl3945_is_associated\n"); 2571 IWL_DEBUG_DROP("Dropping - !iwl3945_is_associated\n");
2572 goto drop_unlock; 2572 goto drop_unlock;
2573 } 2573 }
@@ -2806,7 +2806,7 @@ static void iwl3945_radio_kill_sw(struct iwl3945_priv *priv, int disable_radio)
2806 if (disable_radio) { 2806 if (disable_radio) {
2807 iwl3945_scan_cancel(priv); 2807 iwl3945_scan_cancel(priv);
2808 /* FIXME: This is a workaround for AP */ 2808 /* FIXME: This is a workaround for AP */
2809 if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 2809 if (priv->iw_mode != NL80211_IFTYPE_AP) {
2810 spin_lock_irqsave(&priv->lock, flags); 2810 spin_lock_irqsave(&priv->lock, flags);
2811 iwl3945_write32(priv, CSR_UCODE_DRV_GP1_SET, 2811 iwl3945_write32(priv, CSR_UCODE_DRV_GP1_SET,
2812 CSR_UCODE_SW_BIT_RFKILL); 2812 CSR_UCODE_SW_BIT_RFKILL);
@@ -3161,7 +3161,7 @@ static void iwl3945_rx_beacon_notif(struct iwl3945_priv *priv,
3161 le32_to_cpu(beacon->low_tsf), rate); 3161 le32_to_cpu(beacon->low_tsf), rate);
3162#endif 3162#endif
3163 3163
3164 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 3164 if ((priv->iw_mode == NL80211_IFTYPE_AP) &&
3165 (!test_bit(STATUS_EXIT_PENDING, &priv->status))) 3165 (!test_bit(STATUS_EXIT_PENDING, &priv->status)))
3166 queue_work(priv->workqueue, &priv->beacon_update); 3166 queue_work(priv->workqueue, &priv->beacon_update);
3167} 3167}
@@ -6059,7 +6059,7 @@ static void iwl3945_bg_set_monitor(struct work_struct *work)
6059 if (!iwl3945_is_ready(priv)) 6059 if (!iwl3945_is_ready(priv))
6060 IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n"); 6060 IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n");
6061 else 6061 else
6062 if (iwl3945_set_mode(priv, IEEE80211_IF_TYPE_MNTR) != 0) 6062 if (iwl3945_set_mode(priv, NL80211_IFTYPE_MONITOR) != 0)
6063 IWL_ERROR("iwl3945_set_mode() failed\n"); 6063 IWL_ERROR("iwl3945_set_mode() failed\n");
6064 6064
6065 mutex_unlock(&priv->mutex); 6065 mutex_unlock(&priv->mutex);
@@ -6248,7 +6248,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
6248 /* select Rx antennas */ 6248 /* select Rx antennas */
6249 scan->flags |= iwl3945_get_antenna_flags(priv); 6249 scan->flags |= iwl3945_get_antenna_flags(priv);
6250 6250
6251 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) 6251 if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
6252 scan->filter_flags = RXON_FILTER_PROMISC_MSK; 6252 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
6253 6253
6254 scan->channel_count = 6254 scan->channel_count =
@@ -6323,7 +6323,7 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
6323 struct ieee80211_conf *conf = NULL; 6323 struct ieee80211_conf *conf = NULL;
6324 DECLARE_MAC_BUF(mac); 6324 DECLARE_MAC_BUF(mac);
6325 6325
6326 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 6326 if (priv->iw_mode == NL80211_IFTYPE_AP) {
6327 IWL_ERROR("%s Should not be called in AP mode\n", __func__); 6327 IWL_ERROR("%s Should not be called in AP mode\n", __func__);
6328 return; 6328 return;
6329 } 6329 }
@@ -6372,7 +6372,7 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
6372 else 6372 else
6373 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 6373 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
6374 6374
6375 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 6375 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
6376 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 6376 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
6377 6377
6378 } 6378 }
@@ -6380,11 +6380,11 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
6380 iwl3945_commit_rxon(priv); 6380 iwl3945_commit_rxon(priv);
6381 6381
6382 switch (priv->iw_mode) { 6382 switch (priv->iw_mode) {
6383 case IEEE80211_IF_TYPE_STA: 6383 case NL80211_IFTYPE_STATION:
6384 iwl3945_rate_scale_init(priv->hw, IWL_AP_ID); 6384 iwl3945_rate_scale_init(priv->hw, IWL_AP_ID);
6385 break; 6385 break;
6386 6386
6387 case IEEE80211_IF_TYPE_IBSS: 6387 case NL80211_IFTYPE_ADHOC:
6388 6388
6389 /* clear out the station table */ 6389 /* clear out the station table */
6390 iwl3945_clear_stations_table(priv); 6390 iwl3945_clear_stations_table(priv);
@@ -6754,7 +6754,7 @@ static void iwl3945_config_ap(struct iwl3945_priv *priv)
6754 priv->staging_rxon.flags &= 6754 priv->staging_rxon.flags &=
6755 ~RXON_FLG_SHORT_SLOT_MSK; 6755 ~RXON_FLG_SHORT_SLOT_MSK;
6756 6756
6757 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 6757 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
6758 priv->staging_rxon.flags &= 6758 priv->staging_rxon.flags &=
6759 ~RXON_FLG_SHORT_SLOT_MSK; 6759 ~RXON_FLG_SHORT_SLOT_MSK;
6760 } 6760 }
@@ -6791,7 +6791,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6791 } 6791 }
6792 6792
6793 /* handle this temporarily here */ 6793 /* handle this temporarily here */
6794 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS && 6794 if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
6795 conf->changed & IEEE80211_IFCC_BEACON) { 6795 conf->changed & IEEE80211_IFCC_BEACON) {
6796 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 6796 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
6797 if (!beacon) 6797 if (!beacon)
@@ -6803,7 +6803,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6803 6803
6804 /* XXX: this MUST use conf->mac_addr */ 6804 /* XXX: this MUST use conf->mac_addr */
6805 6805
6806 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 6806 if ((priv->iw_mode == NL80211_IFTYPE_AP) &&
6807 (!conf->ssid_len)) { 6807 (!conf->ssid_len)) {
6808 IWL_DEBUG_MAC80211 6808 IWL_DEBUG_MAC80211
6809 ("Leaving in AP mode because HostAPD is not ready.\n"); 6809 ("Leaving in AP mode because HostAPD is not ready.\n");
@@ -6826,7 +6826,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6826 !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) { 6826 !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
6827 */ 6827 */
6828 6828
6829 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 6829 if (priv->iw_mode == NL80211_IFTYPE_AP) {
6830 if (!conf->bssid) { 6830 if (!conf->bssid) {
6831 conf->bssid = priv->mac_addr; 6831 conf->bssid = priv->mac_addr;
6832 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN); 6832 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
@@ -6861,11 +6861,11 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6861 * to verify) - jpk */ 6861 * to verify) - jpk */
6862 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 6862 memcpy(priv->bssid, conf->bssid, ETH_ALEN);
6863 6863
6864 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) 6864 if (priv->iw_mode == NL80211_IFTYPE_AP)
6865 iwl3945_config_ap(priv); 6865 iwl3945_config_ap(priv);
6866 else { 6866 else {
6867 rc = iwl3945_commit_rxon(priv); 6867 rc = iwl3945_commit_rxon(priv);
6868 if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) 6868 if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
6869 iwl3945_add_station(priv, 6869 iwl3945_add_station(priv,
6870 priv->active_rxon.bssid_addr, 1, 0); 6870 priv->active_rxon.bssid_addr, 1, 0);
6871 } 6871 }
@@ -6901,7 +6901,7 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw,
6901 6901
6902 if (changed_flags & (*total_flags) & FIF_OTHER_BSS) { 6902 if (changed_flags & (*total_flags) & FIF_OTHER_BSS) {
6903 IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n", 6903 IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n",
6904 IEEE80211_IF_TYPE_MNTR, 6904 NL80211_IFTYPE_MONITOR,
6905 changed_flags, *total_flags); 6905 changed_flags, *total_flags);
6906 /* queue work 'cuz mac80211 is holding a lock which 6906 /* queue work 'cuz mac80211 is holding a lock which
6907 * prevents us from issuing (synchronous) f/w cmds */ 6907 * prevents us from issuing (synchronous) f/w cmds */
@@ -7010,7 +7010,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
7010 goto out_unlock; 7010 goto out_unlock;
7011 } 7011 }
7012 7012
7013 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { /* APs don't scan */ 7013 if (priv->iw_mode == NL80211_IFTYPE_AP) { /* APs don't scan */
7014 rc = -EIO; 7014 rc = -EIO;
7015 IWL_ERROR("ERROR: APs don't scan\n"); 7015 IWL_ERROR("ERROR: APs don't scan\n");
7016 goto out_unlock; 7016 goto out_unlock;
@@ -7152,7 +7152,7 @@ static int iwl3945_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
7152 spin_unlock_irqrestore(&priv->lock, flags); 7152 spin_unlock_irqrestore(&priv->lock, flags);
7153 7153
7154 mutex_lock(&priv->mutex); 7154 mutex_lock(&priv->mutex);
7155 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) 7155 if (priv->iw_mode == NL80211_IFTYPE_AP)
7156 iwl3945_activate_qos(priv, 1); 7156 iwl3945_activate_qos(priv, 1);
7157 else if (priv->assoc_id && iwl3945_is_associated(priv)) 7157 else if (priv->assoc_id && iwl3945_is_associated(priv))
7158 iwl3945_activate_qos(priv, 0); 7158 iwl3945_activate_qos(priv, 0);
@@ -7239,7 +7239,7 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
7239 priv->beacon_int = priv->hw->conf.beacon_int; 7239 priv->beacon_int = priv->hw->conf.beacon_int;
7240 priv->timestamp1 = 0; 7240 priv->timestamp1 = 0;
7241 priv->timestamp0 = 0; 7241 priv->timestamp0 = 0;
7242 if ((priv->iw_mode == IEEE80211_IF_TYPE_STA)) 7242 if ((priv->iw_mode == NL80211_IFTYPE_STATION))
7243 priv->beacon_int = 0; 7243 priv->beacon_int = 0;
7244 7244
7245 spin_unlock_irqrestore(&priv->lock, flags); 7245 spin_unlock_irqrestore(&priv->lock, flags);
@@ -7253,14 +7253,14 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
7253 /* we are restarting association process 7253 /* we are restarting association process
7254 * clear RXON_FILTER_ASSOC_MSK bit 7254 * clear RXON_FILTER_ASSOC_MSK bit
7255 */ 7255 */
7256 if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { 7256 if (priv->iw_mode != NL80211_IFTYPE_AP) {
7257 iwl3945_scan_cancel_timeout(priv, 100); 7257 iwl3945_scan_cancel_timeout(priv, 100);
7258 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 7258 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
7259 iwl3945_commit_rxon(priv); 7259 iwl3945_commit_rxon(priv);
7260 } 7260 }
7261 7261
7262 /* Per mac80211.h: This is only used in IBSS mode... */ 7262 /* Per mac80211.h: This is only used in IBSS mode... */
7263 if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { 7263 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
7264 7264
7265 IWL_DEBUG_MAC80211("leave - not in IBSS\n"); 7265 IWL_DEBUG_MAC80211("leave - not in IBSS\n");
7266 mutex_unlock(&priv->mutex); 7266 mutex_unlock(&priv->mutex);
@@ -7289,7 +7289,7 @@ static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
7289 return -EIO; 7289 return -EIO;
7290 } 7290 }
7291 7291
7292 if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { 7292 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
7293 IWL_DEBUG_MAC80211("leave - not IBSS\n"); 7293 IWL_DEBUG_MAC80211("leave - not IBSS\n");
7294 mutex_unlock(&priv->mutex); 7294 mutex_unlock(&priv->mutex);
7295 return -EIO; 7295 return -EIO;
@@ -7996,7 +7996,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7996 IWL_DEBUG_INFO("Radio disabled.\n"); 7996 IWL_DEBUG_INFO("Radio disabled.\n");
7997 } 7997 }
7998 7998
7999 priv->iw_mode = IEEE80211_IF_TYPE_STA; 7999 priv->iw_mode = NL80211_IFTYPE_STATION;
8000 8000
8001 printk(KERN_INFO DRV_NAME 8001 printk(KERN_INFO DRV_NAME
8002 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); 8002 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name);
@@ -8376,6 +8376,8 @@ static void __exit iwl3945_exit(void)
8376 iwl3945_rate_control_unregister(); 8376 iwl3945_rate_control_unregister();
8377} 8377}
8378 8378
8379MODULE_FIRMWARE("iwlwifi-3945" IWL3945_UCODE_API ".ucode");
8380
8379module_param_named(antenna, iwl3945_param_antenna, int, 0444); 8381module_param_named(antenna, iwl3945_param_antenna, int, 0444);
8380MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); 8382MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
8381module_param_named(disable, iwl3945_param_disable, int, 0444); 8383module_param_named(disable, iwl3945_param_disable, int, 0444);
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 4ddf44b2758b..92be60415d04 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -823,11 +823,7 @@ static int assoc_helper_mode(struct lbs_private *priv,
823 } 823 }
824 824
825 priv->mode = assoc_req->mode; 825 priv->mode = assoc_req->mode;
826 ret = lbs_prepare_and_send_command(priv, 826 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, assoc_req->mode);
827 CMD_802_11_SNMP_MIB,
828 0, CMD_OPTION_WAITFORRSP,
829 OID_802_11_INFRASTRUCTURE_MODE,
830 /* Shoot me now */ (void *) (size_t) assoc_req->mode);
831 827
832done: 828done:
833 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 829 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 5fef05f3cd00..aee19fa844e4 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -480,138 +480,103 @@ int lbs_cmd_802_11_key_material(struct lbs_private *priv, uint16_t cmd_action,
480 return ret; 480 return ret;
481} 481}
482 482
483static int lbs_cmd_802_11_reset(struct cmd_ds_command *cmd, int cmd_action) 483/**
484{ 484 * @brief Set an SNMP MIB value
485 struct cmd_ds_802_11_reset *reset = &cmd->params.reset; 485 *
486 486 * @param priv A pointer to struct lbs_private structure
487 lbs_deb_enter(LBS_DEB_CMD); 487 * @param oid The OID to set in the firmware
488 488 * @param val Value to set the OID to
489 cmd->command = cpu_to_le16(CMD_802_11_RESET); 489 *
490 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN); 490 * @return 0 on success, error on failure
491 reset->action = cpu_to_le16(cmd_action); 491 */
492 492int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val)
493 lbs_deb_leave(LBS_DEB_CMD);
494 return 0;
495}
496
497static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
498 struct cmd_ds_command *cmd,
499 int cmd_action,
500 int cmd_oid, void *pdata_buf)
501{ 493{
502 struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib; 494 struct cmd_ds_802_11_snmp_mib cmd;
503 u8 ucTemp; 495 int ret;
504 496
505 lbs_deb_enter(LBS_DEB_CMD); 497 lbs_deb_enter(LBS_DEB_CMD);
506 498
507 lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); 499 memset(&cmd, 0, sizeof (cmd));
508 500 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
509 cmd->command = cpu_to_le16(CMD_802_11_SNMP_MIB); 501 cmd.action = cpu_to_le16(CMD_ACT_SET);
510 cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN); 502 cmd.oid = cpu_to_le16((u16) oid);
511
512 switch (cmd_oid) {
513 case OID_802_11_INFRASTRUCTURE_MODE:
514 {
515 u8 mode = (u8) (size_t) pdata_buf;
516 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
517 pSNMPMIB->oid = cpu_to_le16((u16) DESIRED_BSSTYPE_I);
518 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u8));
519 if (mode == IW_MODE_ADHOC) {
520 ucTemp = SNMP_MIB_VALUE_ADHOC;
521 } else {
522 /* Infra and Auto modes */
523 ucTemp = SNMP_MIB_VALUE_INFRA;
524 }
525
526 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8));
527 503
504 switch (oid) {
505 case SNMP_MIB_OID_BSS_TYPE:
506 cmd.bufsize = cpu_to_le16(sizeof(u8));
507 cmd.value[0] = (val == IW_MODE_ADHOC) ? 2 : 1;
508 break;
509 case SNMP_MIB_OID_11D_ENABLE:
510 case SNMP_MIB_OID_FRAG_THRESHOLD:
511 case SNMP_MIB_OID_RTS_THRESHOLD:
512 case SNMP_MIB_OID_SHORT_RETRY_LIMIT:
513 case SNMP_MIB_OID_LONG_RETRY_LIMIT:
514 cmd.bufsize = cpu_to_le16(sizeof(u16));
515 *((__le16 *)(&cmd.value)) = cpu_to_le16(val);
528 break; 516 break;
517 default:
518 lbs_deb_cmd("SNMP_CMD: (set) unhandled OID 0x%x\n", oid);
519 ret = -EINVAL;
520 goto out;
529 } 521 }
530 522
531 case OID_802_11D_ENABLE: 523 lbs_deb_cmd("SNMP_CMD: (set) oid 0x%x, oid size 0x%x, value 0x%x\n",
532 { 524 le16_to_cpu(cmd.oid), le16_to_cpu(cmd.bufsize), val);
533 u32 ulTemp;
534
535 pSNMPMIB->oid = cpu_to_le16((u16) DOT11D_I);
536
537 if (cmd_action == CMD_ACT_SET) {
538 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
539 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
540 ulTemp = *(u32 *)pdata_buf;
541 *((__le16 *)(pSNMPMIB->value)) =
542 cpu_to_le16((u16) ulTemp);
543 }
544 break;
545 }
546
547 case OID_802_11_FRAGMENTATION_THRESHOLD:
548 {
549 u32 ulTemp;
550
551 pSNMPMIB->oid = cpu_to_le16((u16) FRAGTHRESH_I);
552 525
553 if (cmd_action == CMD_ACT_GET) { 526 ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd);
554 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
555 } else if (cmd_action == CMD_ACT_SET) {
556 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
557 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
558 ulTemp = *((u32 *) pdata_buf);
559 *((__le16 *)(pSNMPMIB->value)) =
560 cpu_to_le16((u16) ulTemp);
561 527
562 } 528out:
563 529 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
564 break; 530 return ret;
565 } 531}
566 532
567 case OID_802_11_RTS_THRESHOLD: 533/**
568 { 534 * @brief Get an SNMP MIB value
535 *
536 * @param priv A pointer to struct lbs_private structure
537 * @param oid The OID to retrieve from the firmware
538 * @param out_val Location for the returned value
539 *
540 * @return 0 on success, error on failure
541 */
542int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val)
543{
544 struct cmd_ds_802_11_snmp_mib cmd;
545 int ret;
569 546
570 u32 ulTemp; 547 lbs_deb_enter(LBS_DEB_CMD);
571 pSNMPMIB->oid = cpu_to_le16(RTSTHRESH_I);
572 548
573 if (cmd_action == CMD_ACT_GET) { 549 memset(&cmd, 0, sizeof (cmd));
574 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET); 550 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
575 } else if (cmd_action == CMD_ACT_SET) { 551 cmd.action = cpu_to_le16(CMD_ACT_GET);
576 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); 552 cmd.oid = cpu_to_le16(oid);
577 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
578 ulTemp = *((u32 *)pdata_buf);
579 *(__le16 *)(pSNMPMIB->value) =
580 cpu_to_le16((u16) ulTemp);
581 553
582 } 554 ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd);
583 break; 555 if (ret)
584 } 556 goto out;
585 case OID_802_11_TX_RETRYCOUNT:
586 pSNMPMIB->oid = cpu_to_le16((u16) SHORT_RETRYLIM_I);
587
588 if (cmd_action == CMD_ACT_GET) {
589 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
590 } else if (cmd_action == CMD_ACT_SET) {
591 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
592 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
593 *((__le16 *)(pSNMPMIB->value)) =
594 cpu_to_le16((u16) priv->txretrycount);
595 }
596 557
558 switch (le16_to_cpu(cmd.bufsize)) {
559 case sizeof(u8):
560 if (oid == SNMP_MIB_OID_BSS_TYPE) {
561 if (cmd.value[0] == 2)
562 *out_val = IW_MODE_ADHOC;
563 else
564 *out_val = IW_MODE_INFRA;
565 } else
566 *out_val = cmd.value[0];
567 break;
568 case sizeof(u16):
569 *out_val = le16_to_cpu(*((__le16 *)(&cmd.value)));
597 break; 570 break;
598 default: 571 default:
572 lbs_deb_cmd("SNMP_CMD: (get) unhandled OID 0x%x size %d\n",
573 oid, le16_to_cpu(cmd.bufsize));
599 break; 574 break;
600 } 575 }
601 576
602 lbs_deb_cmd( 577out:
603 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n", 578 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
604 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size), 579 return ret;
605 le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result));
606
607 lbs_deb_cmd(
608 "SNMP_CMD: action 0x%x, oid 0x%x, oidsize 0x%x, value 0x%x\n",
609 le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid),
610 le16_to_cpu(pSNMPMIB->bufsize),
611 le16_to_cpu(*(__le16 *) pSNMPMIB->value));
612
613 lbs_deb_leave(LBS_DEB_CMD);
614 return 0;
615} 580}
616 581
617/** 582/**
@@ -1419,19 +1384,10 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1419 ret = lbs_cmd_80211_associate(priv, cmdptr, pdata_buf); 1384 ret = lbs_cmd_80211_associate(priv, cmdptr, pdata_buf);
1420 break; 1385 break;
1421 1386
1422 case CMD_802_11_RESET:
1423 ret = lbs_cmd_802_11_reset(cmdptr, cmd_action);
1424 break;
1425
1426 case CMD_802_11_AUTHENTICATE: 1387 case CMD_802_11_AUTHENTICATE:
1427 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf); 1388 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf);
1428 break; 1389 break;
1429 1390
1430 case CMD_802_11_SNMP_MIB:
1431 ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr,
1432 cmd_action, cmd_oid, pdata_buf);
1433 break;
1434
1435 case CMD_MAC_REG_ACCESS: 1391 case CMD_MAC_REG_ACCESS:
1436 case CMD_BBP_REG_ACCESS: 1392 case CMD_BBP_REG_ACCESS:
1437 case CMD_RF_REG_ACCESS: 1393 case CMD_RF_REG_ACCESS:
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 336a181d857a..d002160f597d 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -73,4 +73,8 @@ int lbs_set_tx_power(struct lbs_private *priv, s16 dbm);
73 73
74int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on); 74int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on);
75 75
76int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val);
77
78int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val);
79
76#endif /* _LBS_CMD_H */ 80#endif /* _LBS_CMD_H */
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 0371c83f5661..bcf2a9756fb6 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -146,48 +146,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
146 return ret; 146 return ret;
147} 147}
148 148
149static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv,
150 struct cmd_ds_command *resp)
151{
152 struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
153 u16 oid = le16_to_cpu(smib->oid);
154 u16 querytype = le16_to_cpu(smib->querytype);
155
156 lbs_deb_enter(LBS_DEB_CMD);
157
158 lbs_deb_cmd("SNMP_RESP: oid 0x%x, querytype 0x%x\n", oid,
159 querytype);
160 lbs_deb_cmd("SNMP_RESP: Buf size %d\n", le16_to_cpu(smib->bufsize));
161
162 if (querytype == CMD_ACT_GET) {
163 switch (oid) {
164 case FRAGTHRESH_I:
165 priv->fragthsd =
166 le16_to_cpu(*((__le16 *)(smib->value)));
167 lbs_deb_cmd("SNMP_RESP: frag threshold %u\n",
168 priv->fragthsd);
169 break;
170 case RTSTHRESH_I:
171 priv->rtsthsd =
172 le16_to_cpu(*((__le16 *)(smib->value)));
173 lbs_deb_cmd("SNMP_RESP: rts threshold %u\n",
174 priv->rtsthsd);
175 break;
176 case SHORT_RETRYLIM_I:
177 priv->txretrycount =
178 le16_to_cpu(*((__le16 *)(smib->value)));
179 lbs_deb_cmd("SNMP_RESP: tx retry count %u\n",
180 priv->rtsthsd);
181 break;
182 default:
183 break;
184 }
185 }
186
187 lbs_deb_enter(LBS_DEB_CMD);
188 return 0;
189}
190
191static int lbs_ret_802_11_rssi(struct lbs_private *priv, 149static int lbs_ret_802_11_rssi(struct lbs_private *priv,
192 struct cmd_ds_command *resp) 150 struct cmd_ds_command *resp)
193{ 151{
@@ -258,10 +216,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
258 ret = lbs_ret_80211_associate(priv, resp); 216 ret = lbs_ret_80211_associate(priv, resp);
259 break; 217 break;
260 218
261 case CMD_RET(CMD_802_11_SNMP_MIB):
262 ret = lbs_ret_802_11_snmp_mib(priv, resp);
263 break;
264
265 case CMD_RET(CMD_802_11_SET_AFC): 219 case CMD_RET(CMD_802_11_SET_AFC):
266 case CMD_RET(CMD_802_11_GET_AFC): 220 case CMD_RET(CMD_802_11_GET_AFC):
267 spin_lock_irqsave(&priv->driver_lock, flags); 221 spin_lock_irqsave(&priv->driver_lock, flags);
@@ -271,7 +225,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
271 225
272 break; 226 break;
273 227
274 case CMD_RET(CMD_802_11_RESET):
275 case CMD_RET(CMD_802_11_AUTHENTICATE): 228 case CMD_RET(CMD_802_11_AUTHENTICATE):
276 case CMD_RET(CMD_802_11_BEACON_STOP): 229 case CMD_RET(CMD_802_11_BEACON_STOP):
277 break; 230 break;
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index c89d7a1041a8..58d11a35e61b 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -352,27 +352,6 @@ enum mv_ms_type {
352 MVMS_EVENT 352 MVMS_EVENT
353}; 353};
354 354
355/** SNMP_MIB_INDEX_e */
356enum SNMP_MIB_INDEX_e {
357 DESIRED_BSSTYPE_I = 0,
358 OP_RATESET_I,
359 BCNPERIOD_I,
360 DTIMPERIOD_I,
361 ASSOCRSP_TIMEOUT_I,
362 RTSTHRESH_I,
363 SHORT_RETRYLIM_I,
364 LONG_RETRYLIM_I,
365 FRAGTHRESH_I,
366 DOT11D_I,
367 DOT11H_I,
368 MANUFID_I,
369 PRODID_I,
370 MANUF_OUI_I,
371 MANUF_NAME_I,
372 MANUF_PRODNAME_I,
373 MANUF_PRODVER_I,
374};
375
376/** KEY_TYPE_ID */ 355/** KEY_TYPE_ID */
377enum KEY_TYPE_ID { 356enum KEY_TYPE_ID {
378 KEY_TYPE_ID_WEP = 0, 357 KEY_TYPE_ID_WEP = 0,
@@ -387,12 +366,6 @@ enum KEY_INFO_WPA {
387 KEY_INFO_WPA_ENABLED = 0x04 366 KEY_INFO_WPA_ENABLED = 0x04
388}; 367};
389 368
390/** SNMP_MIB_VALUE_e */
391enum SNMP_MIB_VALUE_e {
392 SNMP_MIB_VALUE_INFRA = 1,
393 SNMP_MIB_VALUE_ADHOC
394};
395
396/* Default values for fwt commands. */ 369/* Default values for fwt commands. */
397#define FWT_DEFAULT_METRIC 0 370#define FWT_DEFAULT_METRIC 0
398#define FWT_DEFAULT_DIR 1 371#define FWT_DEFAULT_DIR 1
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index fd59e1816460..acb889e25900 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -240,9 +240,6 @@ struct lbs_private {
240 uint16_t enablehwauto; 240 uint16_t enablehwauto;
241 uint16_t ratebitmap; 241 uint16_t ratebitmap;
242 242
243 u32 fragthsd;
244 u32 rtsthsd;
245
246 u8 txretrycount; 243 u8 txretrycount;
247 244
248 /** Tx-related variables (for single packet tx) */ 245 /** Tx-related variables (for single packet tx) */
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index a916bb9bd5da..5004d7679c02 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -9,17 +9,6 @@
9#define DEFAULT_AD_HOC_CHANNEL 6 9#define DEFAULT_AD_HOC_CHANNEL 6
10#define DEFAULT_AD_HOC_CHANNEL_A 36 10#define DEFAULT_AD_HOC_CHANNEL_A 36
11 11
12/** IEEE 802.11 oids */
13#define OID_802_11_SSID 0x00008002
14#define OID_802_11_INFRASTRUCTURE_MODE 0x00008008
15#define OID_802_11_FRAGMENTATION_THRESHOLD 0x00008009
16#define OID_802_11_RTS_THRESHOLD 0x0000800A
17#define OID_802_11_TX_ANTENNA_SELECTED 0x0000800D
18#define OID_802_11_SUPPORTED_RATES 0x0000800E
19#define OID_802_11_STATISTICS 0x00008012
20#define OID_802_11_TX_RETRYCOUNT 0x0000801D
21#define OID_802_11D_ENABLE 0x00008020
22
23#define CMD_OPTION_WAITFORRSP 0x0002 12#define CMD_OPTION_WAITFORRSP 0x0002
24 13
25/** Host command IDs */ 14/** Host command IDs */
@@ -191,6 +180,19 @@
191#define CMD_WAKE_METHOD_COMMAND_INT 0x0001 180#define CMD_WAKE_METHOD_COMMAND_INT 0x0001
192#define CMD_WAKE_METHOD_GPIO 0x0002 181#define CMD_WAKE_METHOD_GPIO 0x0002
193 182
183/* Object IDs for CMD_802_11_SNMP_MIB */
184#define SNMP_MIB_OID_BSS_TYPE 0x0000
185#define SNMP_MIB_OID_OP_RATE_SET 0x0001
186#define SNMP_MIB_OID_BEACON_PERIOD 0x0002 /* Reserved on v9+ */
187#define SNMP_MIB_OID_DTIM_PERIOD 0x0003 /* Reserved on v9+ */
188#define SNMP_MIB_OID_ASSOC_TIMEOUT 0x0004 /* Reserved on v9+ */
189#define SNMP_MIB_OID_RTS_THRESHOLD 0x0005
190#define SNMP_MIB_OID_SHORT_RETRY_LIMIT 0x0006
191#define SNMP_MIB_OID_LONG_RETRY_LIMIT 0x0007
192#define SNMP_MIB_OID_FRAG_THRESHOLD 0x0008
193#define SNMP_MIB_OID_11D_ENABLE 0x0009
194#define SNMP_MIB_OID_11H_ENABLE 0x000A
195
194/* Define action or option for CMD_BT_ACCESS */ 196/* Define action or option for CMD_BT_ACCESS */
195enum cmd_bt_access_opts { 197enum cmd_bt_access_opts {
196 /* The bt commands start at 5 instead of 1 because the old dft commands 198 /* The bt commands start at 5 instead of 1 because the old dft commands
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index 630b79967560..d9f9a12a739e 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -151,10 +151,6 @@ struct cmd_ds_get_hw_spec {
151 __le32 fwcapinfo; 151 __le32 fwcapinfo;
152} __attribute__ ((packed)); 152} __attribute__ ((packed));
153 153
154struct cmd_ds_802_11_reset {
155 __le16 action;
156};
157
158struct cmd_ds_802_11_subscribe_event { 154struct cmd_ds_802_11_subscribe_event {
159 struct cmd_header hdr; 155 struct cmd_header hdr;
160 156
@@ -301,7 +297,9 @@ struct cmd_ds_802_11_get_stat {
301}; 297};
302 298
303struct cmd_ds_802_11_snmp_mib { 299struct cmd_ds_802_11_snmp_mib {
304 __le16 querytype; 300 struct cmd_header hdr;
301
302 __le16 action;
305 __le16 oid; 303 __le16 oid;
306 __le16 bufsize; 304 __le16 bufsize;
307 u8 value[128]; 305 u8 value[128];
@@ -717,11 +715,9 @@ struct cmd_ds_command {
717 union { 715 union {
718 struct cmd_ds_802_11_ps_mode psmode; 716 struct cmd_ds_802_11_ps_mode psmode;
719 struct cmd_ds_802_11_associate associate; 717 struct cmd_ds_802_11_associate associate;
720 struct cmd_ds_802_11_reset reset;
721 struct cmd_ds_802_11_authenticate auth; 718 struct cmd_ds_802_11_authenticate auth;
722 struct cmd_ds_802_11_get_stat gstat; 719 struct cmd_ds_802_11_get_stat gstat;
723 struct cmd_ds_802_3_get_stat gstat_8023; 720 struct cmd_ds_802_3_get_stat gstat_8023;
724 struct cmd_ds_802_11_snmp_mib smib;
725 struct cmd_ds_802_11_rf_antenna rant; 721 struct cmd_ds_802_11_rf_antenna rant;
726 struct cmd_ds_802_11_monitor_mode monitor; 722 struct cmd_ds_802_11_monitor_mode monitor;
727 struct cmd_ds_802_11_rssi rssi; 723 struct cmd_ds_802_11_rssi rssi;
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 7b02d612b076..cafbccb74143 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -439,11 +439,10 @@ static int if_usb_reset_device(struct if_usb_card *cardp)
439 *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); 439 *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST);
440 440
441 cmd->command = cpu_to_le16(CMD_802_11_RESET); 441 cmd->command = cpu_to_le16(CMD_802_11_RESET);
442 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN); 442 cmd->size = cpu_to_le16(sizeof(struct cmd_header));
443 cmd->result = cpu_to_le16(0); 443 cmd->result = cpu_to_le16(0);
444 cmd->seqnum = cpu_to_le16(0x5a5a); 444 cmd->seqnum = cpu_to_le16(0x5a5a);
445 cmd->params.reset.action = cpu_to_le16(CMD_ACT_HALT); 445 usb_tx_block(cardp, cardp->ep_out_buf, 4 + sizeof(struct cmd_header));
446 usb_tx_block(cardp, cardp->ep_out_buf, 4 + S_DS_GEN + sizeof(struct cmd_ds_802_11_reset));
447 446
448 msleep(100); 447 msleep(100);
449 ret = usb_reset_device(cardp->udev); 448 ret = usb_reset_device(cardp->udev);
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index e8cadad2c863..11297dcf9fc3 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -30,6 +30,14 @@ static inline void lbs_postpone_association_work(struct lbs_private *priv)
30 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2); 30 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
31} 31}
32 32
33static inline void lbs_do_association_work(struct lbs_private *priv)
34{
35 if (priv->surpriseremoved)
36 return;
37 cancel_delayed_work(&priv->assoc_work);
38 queue_delayed_work(priv->work_thread, &priv->assoc_work, 0);
39}
40
33static inline void lbs_cancel_association_work(struct lbs_private *priv) 41static inline void lbs_cancel_association_work(struct lbs_private *priv)
34{ 42{
35 cancel_delayed_work(&priv->assoc_work); 43 cancel_delayed_work(&priv->assoc_work);
@@ -266,21 +274,17 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
266{ 274{
267 int ret = 0; 275 int ret = 0;
268 struct lbs_private *priv = dev->priv; 276 struct lbs_private *priv = dev->priv;
269 u32 rthr = vwrq->value; 277 u32 val = vwrq->value;
270 278
271 lbs_deb_enter(LBS_DEB_WEXT); 279 lbs_deb_enter(LBS_DEB_WEXT);
272 280
273 if (vwrq->disabled) { 281 if (vwrq->disabled)
274 priv->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE; 282 val = MRVDRV_RTS_MAX_VALUE;
275 } else {
276 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE)
277 return -EINVAL;
278 priv->rtsthsd = rthr;
279 }
280 283
281 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 284 if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
282 CMD_ACT_SET, CMD_OPTION_WAITFORRSP, 285 return -EINVAL;
283 OID_802_11_RTS_THRESHOLD, &rthr); 286
287 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
284 288
285 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 289 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
286 return ret; 290 return ret;
@@ -289,21 +293,18 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
289static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info, 293static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
290 struct iw_param *vwrq, char *extra) 294 struct iw_param *vwrq, char *extra)
291{ 295{
292 int ret = 0;
293 struct lbs_private *priv = dev->priv; 296 struct lbs_private *priv = dev->priv;
297 int ret = 0;
298 u16 val = 0;
294 299
295 lbs_deb_enter(LBS_DEB_WEXT); 300 lbs_deb_enter(LBS_DEB_WEXT);
296 301
297 priv->rtsthsd = 0; 302 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
298 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
299 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
300 OID_802_11_RTS_THRESHOLD, NULL);
301 if (ret) 303 if (ret)
302 goto out; 304 goto out;
303 305
304 vwrq->value = priv->rtsthsd; 306 vwrq->value = val;
305 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE) 307 vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
306 || (vwrq->value > MRVDRV_RTS_MAX_VALUE));
307 vwrq->fixed = 1; 308 vwrq->fixed = 1;
308 309
309out: 310out:
@@ -314,24 +315,19 @@ out:
314static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info, 315static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
315 struct iw_param *vwrq, char *extra) 316 struct iw_param *vwrq, char *extra)
316{ 317{
317 int ret = 0;
318 u32 fthr = vwrq->value;
319 struct lbs_private *priv = dev->priv; 318 struct lbs_private *priv = dev->priv;
319 int ret = 0;
320 u32 val = vwrq->value;
320 321
321 lbs_deb_enter(LBS_DEB_WEXT); 322 lbs_deb_enter(LBS_DEB_WEXT);
322 323
323 if (vwrq->disabled) { 324 if (vwrq->disabled)
324 priv->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE; 325 val = MRVDRV_FRAG_MAX_VALUE;
325 } else { 326
326 if (fthr < MRVDRV_FRAG_MIN_VALUE 327 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
327 || fthr > MRVDRV_FRAG_MAX_VALUE) 328 return -EINVAL;
328 return -EINVAL;
329 priv->fragthsd = fthr;
330 }
331 329
332 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 330 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
333 CMD_ACT_SET, CMD_OPTION_WAITFORRSP,
334 OID_802_11_FRAGMENTATION_THRESHOLD, &fthr);
335 331
336 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 332 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
337 return ret; 333 return ret;
@@ -340,22 +336,19 @@ static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
340static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info, 336static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
341 struct iw_param *vwrq, char *extra) 337 struct iw_param *vwrq, char *extra)
342{ 338{
343 int ret = 0;
344 struct lbs_private *priv = dev->priv; 339 struct lbs_private *priv = dev->priv;
340 int ret = 0;
341 u16 val = 0;
345 342
346 lbs_deb_enter(LBS_DEB_WEXT); 343 lbs_deb_enter(LBS_DEB_WEXT);
347 344
348 priv->fragthsd = 0; 345 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
349 ret = lbs_prepare_and_send_command(priv,
350 CMD_802_11_SNMP_MIB,
351 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
352 OID_802_11_FRAGMENTATION_THRESHOLD, NULL);
353 if (ret) 346 if (ret)
354 goto out; 347 goto out;
355 348
356 vwrq->value = priv->fragthsd; 349 vwrq->value = val;
357 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE) 350 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
358 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE)); 351 || (val > MRVDRV_FRAG_MAX_VALUE));
359 vwrq->fixed = 1; 352 vwrq->fixed = 1;
360 353
361out: 354out:
@@ -382,7 +375,7 @@ static int mesh_wlan_get_mode(struct net_device *dev,
382{ 375{
383 lbs_deb_enter(LBS_DEB_WEXT); 376 lbs_deb_enter(LBS_DEB_WEXT);
384 377
385 *uwrq = IW_MODE_REPEAT ; 378 *uwrq = IW_MODE_REPEAT;
386 379
387 lbs_deb_leave(LBS_DEB_WEXT); 380 lbs_deb_leave(LBS_DEB_WEXT);
388 return 0; 381 return 0;
@@ -425,31 +418,44 @@ out:
425static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info, 418static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
426 struct iw_param *vwrq, char *extra) 419 struct iw_param *vwrq, char *extra)
427{ 420{
428 int ret = 0;
429 struct lbs_private *priv = dev->priv; 421 struct lbs_private *priv = dev->priv;
422 int ret = 0;
423 u16 slimit = 0, llimit = 0;
430 424
431 lbs_deb_enter(LBS_DEB_WEXT); 425 lbs_deb_enter(LBS_DEB_WEXT);
432 426
433 if (vwrq->flags == IW_RETRY_LIMIT) { 427 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
434 /* The MAC has a 4-bit Total_Tx_Count register 428 return -EOPNOTSUPP;
435 Total_Tx_Count = 1 + Tx_Retry_Count */ 429
430 /* The MAC has a 4-bit Total_Tx_Count register
431 Total_Tx_Count = 1 + Tx_Retry_Count */
436#define TX_RETRY_MIN 0 432#define TX_RETRY_MIN 0
437#define TX_RETRY_MAX 14 433#define TX_RETRY_MAX 14
438 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX) 434 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
439 return -EINVAL; 435 return -EINVAL;
440 436
441 /* Adding 1 to convert retry count to try count */ 437 /* Add 1 to convert retry count to try count */
442 priv->txretrycount = vwrq->value + 1; 438 if (vwrq->flags & IW_RETRY_SHORT)
439 slimit = (u16) (vwrq->value + 1);
440 else if (vwrq->flags & IW_RETRY_LONG)
441 llimit = (u16) (vwrq->value + 1);
442 else
443 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
443 444
444 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 445 if (llimit) {
445 CMD_ACT_SET, 446 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
446 CMD_OPTION_WAITFORRSP, 447 llimit);
447 OID_802_11_TX_RETRYCOUNT, NULL); 448 if (ret)
449 goto out;
450 }
448 451
452 if (slimit) {
453 /* txretrycount follows the short retry limit */
454 priv->txretrycount = slimit;
455 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
456 slimit);
449 if (ret) 457 if (ret)
450 goto out; 458 goto out;
451 } else {
452 return -EOPNOTSUPP;
453 } 459 }
454 460
455out: 461out:
@@ -462,22 +468,30 @@ static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
462{ 468{
463 struct lbs_private *priv = dev->priv; 469 struct lbs_private *priv = dev->priv;
464 int ret = 0; 470 int ret = 0;
471 u16 val = 0;
465 472
466 lbs_deb_enter(LBS_DEB_WEXT); 473 lbs_deb_enter(LBS_DEB_WEXT);
467 474
468 priv->txretrycount = 0;
469 ret = lbs_prepare_and_send_command(priv,
470 CMD_802_11_SNMP_MIB,
471 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
472 OID_802_11_TX_RETRYCOUNT, NULL);
473 if (ret)
474 goto out;
475
476 vwrq->disabled = 0; 475 vwrq->disabled = 0;
477 if (!vwrq->flags) { 476
478 vwrq->flags = IW_RETRY_LIMIT; 477 if (vwrq->flags & IW_RETRY_LONG) {
478 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
479 if (ret)
480 goto out;
481
482 /* Subtract 1 to convert try count to retry count */
483 vwrq->value = val - 1;
484 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
485 } else {
486 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
487 if (ret)
488 goto out;
489
490 /* txretry count follows the short retry limit */
491 priv->txretrycount = val;
479 /* Subtract 1 to convert try count to retry count */ 492 /* Subtract 1 to convert try count to retry count */
480 vwrq->value = priv->txretrycount - 1; 493 vwrq->value = val - 1;
494 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
481 } 495 }
482 496
483out: 497out:
@@ -1578,12 +1592,14 @@ static int lbs_set_encodeext(struct net_device *dev,
1578 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); 1592 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1579 } 1593 }
1580 1594
1581 disable_wep (assoc_req); 1595 /* Only disable wep if necessary: can't waste time here. */
1596 if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
1597 disable_wep(assoc_req);
1582 } 1598 }
1583 1599
1584out: 1600out:
1585 if (ret == 0) { 1601 if (ret == 0) { /* key installation is time critical: postpone not! */
1586 lbs_postpone_association_work(priv); 1602 lbs_do_association_work(priv);
1587 } else { 1603 } else {
1588 lbs_cancel_association_work(priv); 1604 lbs_cancel_association_work(priv);
1589 } 1605 }
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index c948021bff6a..feff945ad856 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -219,7 +219,7 @@ static void lbtf_tx_work(struct work_struct *work)
219 struct sk_buff *skb = NULL; 219 struct sk_buff *skb = NULL;
220 int err; 220 int err;
221 221
222 if ((priv->vif->type == IEEE80211_IF_TYPE_AP) && 222 if ((priv->vif->type == NL80211_IFTYPE_AP) &&
223 (!skb_queue_empty(&priv->bc_ps_buf))) 223 (!skb_queue_empty(&priv->bc_ps_buf)))
224 skb = skb_dequeue(&priv->bc_ps_buf); 224 skb = skb_dequeue(&priv->bc_ps_buf);
225 else if (priv->skb_to_tx) { 225 else if (priv->skb_to_tx) {
@@ -326,11 +326,11 @@ static int lbtf_op_add_interface(struct ieee80211_hw *hw,
326 326
327 priv->vif = conf->vif; 327 priv->vif = conf->vif;
328 switch (conf->type) { 328 switch (conf->type) {
329 case IEEE80211_IF_TYPE_MESH_POINT: 329 case NL80211_IFTYPE_MESH_POINT:
330 case IEEE80211_IF_TYPE_AP: 330 case NL80211_IFTYPE_AP:
331 lbtf_set_mode(priv, LBTF_AP_MODE); 331 lbtf_set_mode(priv, LBTF_AP_MODE);
332 break; 332 break;
333 case IEEE80211_IF_TYPE_STA: 333 case NL80211_IFTYPE_STATION:
334 lbtf_set_mode(priv, LBTF_STA_MODE); 334 lbtf_set_mode(priv, LBTF_STA_MODE);
335 break; 335 break;
336 default: 336 default:
@@ -346,8 +346,8 @@ static void lbtf_op_remove_interface(struct ieee80211_hw *hw,
346{ 346{
347 struct lbtf_private *priv = hw->priv; 347 struct lbtf_private *priv = hw->priv;
348 348
349 if (priv->vif->type == IEEE80211_IF_TYPE_AP || 349 if (priv->vif->type == NL80211_IFTYPE_AP ||
350 priv->vif->type == IEEE80211_IF_TYPE_MESH_POINT) 350 priv->vif->type == NL80211_IFTYPE_MESH_POINT)
351 lbtf_beacon_ctrl(priv, 0, 0); 351 lbtf_beacon_ctrl(priv, 0, 0);
352 lbtf_set_mode(priv, LBTF_PASSIVE_MODE); 352 lbtf_set_mode(priv, LBTF_PASSIVE_MODE);
353 lbtf_set_bssid(priv, 0, NULL); 353 lbtf_set_bssid(priv, 0, NULL);
@@ -372,8 +372,8 @@ static int lbtf_op_config_interface(struct ieee80211_hw *hw,
372 struct sk_buff *beacon; 372 struct sk_buff *beacon;
373 373
374 switch (priv->vif->type) { 374 switch (priv->vif->type) {
375 case IEEE80211_IF_TYPE_AP: 375 case NL80211_IFTYPE_AP:
376 case IEEE80211_IF_TYPE_MESH_POINT: 376 case NL80211_IFTYPE_MESH_POINT:
377 beacon = ieee80211_beacon_get(hw, vif); 377 beacon = ieee80211_beacon_get(hw, vif);
378 if (beacon) { 378 if (beacon) {
379 lbtf_beacon_set(priv, beacon); 379 lbtf_beacon_set(priv, beacon);
@@ -614,7 +614,7 @@ void lbtf_bcn_sent(struct lbtf_private *priv)
614{ 614{
615 struct sk_buff *skb = NULL; 615 struct sk_buff *skb = NULL;
616 616
617 if (priv->vif->type != IEEE80211_IF_TYPE_AP) 617 if (priv->vif->type != NL80211_IFTYPE_AP)
618 return; 618 return;
619 619
620 if (skb_queue_empty(&priv->bc_ps_buf)) { 620 if (skb_queue_empty(&priv->bc_ps_buf)) {
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 6ba50f087f7b..c9e4a435b2fc 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -14,6 +14,8 @@
14 * - RX filtering based on filter configuration (data->rx_filter) 14 * - RX filtering based on filter configuration (data->rx_filter)
15 */ 15 */
16 16
17#include <linux/list.h>
18#include <linux/spinlock.h>
17#include <net/mac80211.h> 19#include <net/mac80211.h>
18#include <net/ieee80211_radiotap.h> 20#include <net/ieee80211_radiotap.h>
19#include <linux/if_arp.h> 21#include <linux/if_arp.h>
@@ -28,11 +30,56 @@ static int radios = 2;
28module_param(radios, int, 0444); 30module_param(radios, int, 0444);
29MODULE_PARM_DESC(radios, "Number of simulated radios"); 31MODULE_PARM_DESC(radios, "Number of simulated radios");
30 32
33struct hwsim_vif_priv {
34 u32 magic;
35};
36
37#define HWSIM_VIF_MAGIC 0x69537748
38
39static inline void hwsim_check_magic(struct ieee80211_vif *vif)
40{
41 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
42 WARN_ON(vp->magic != HWSIM_VIF_MAGIC);
43}
44
45static inline void hwsim_set_magic(struct ieee80211_vif *vif)
46{
47 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
48 vp->magic = HWSIM_VIF_MAGIC;
49}
50
51static inline void hwsim_clear_magic(struct ieee80211_vif *vif)
52{
53 struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
54 vp->magic = 0;
55}
56
57struct hwsim_sta_priv {
58 u32 magic;
59};
60
61#define HWSIM_STA_MAGIC 0x6d537748
62
63static inline void hwsim_check_sta_magic(struct ieee80211_sta *sta)
64{
65 struct hwsim_sta_priv *sp = (void *)sta->drv_priv;
66 WARN_ON(sp->magic != HWSIM_VIF_MAGIC);
67}
68
69static inline void hwsim_set_sta_magic(struct ieee80211_sta *sta)
70{
71 struct hwsim_sta_priv *sp = (void *)sta->drv_priv;
72 sp->magic = HWSIM_VIF_MAGIC;
73}
74
75static inline void hwsim_clear_sta_magic(struct ieee80211_sta *sta)
76{
77 struct hwsim_sta_priv *sp = (void *)sta->drv_priv;
78 sp->magic = 0;
79}
31 80
32static struct class *hwsim_class; 81static struct class *hwsim_class;
33 82
34static struct ieee80211_hw **hwsim_radios;
35static int hwsim_radio_count;
36static struct net_device *hwsim_mon; /* global monitor netdev */ 83static struct net_device *hwsim_mon; /* global monitor netdev */
37 84
38 85
@@ -68,7 +115,12 @@ static const struct ieee80211_rate hwsim_rates[] = {
68 { .bitrate = 540 } 115 { .bitrate = 540 }
69}; 116};
70 117
118static spinlock_t hwsim_radio_lock;
119static struct list_head hwsim_radios;
120
71struct mac80211_hwsim_data { 121struct mac80211_hwsim_data {
122 struct list_head list;
123 struct ieee80211_hw *hw;
72 struct device *dev; 124 struct device *dev;
73 struct ieee80211_supported_band band; 125 struct ieee80211_supported_band band;
74 struct ieee80211_channel channels[ARRAY_SIZE(hwsim_channels)]; 126 struct ieee80211_channel channels[ARRAY_SIZE(hwsim_channels)];
@@ -144,11 +196,11 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
144} 196}
145 197
146 198
147static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, 199static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
148 struct sk_buff *skb) 200 struct sk_buff *skb)
149{ 201{
150 struct mac80211_hwsim_data *data = hw->priv; 202 struct mac80211_hwsim_data *data = hw->priv, *data2;
151 int i, ack = 0; 203 bool ack = false;
152 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 204 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
153 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 205 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
154 struct ieee80211_rx_status rx_status; 206 struct ieee80211_rx_status rx_status;
@@ -161,13 +213,13 @@ static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
161 /* TODO: simulate signal strength (and optional packet drop) */ 213 /* TODO: simulate signal strength (and optional packet drop) */
162 214
163 /* Copy skb to all enabled radios that are on the current frequency */ 215 /* Copy skb to all enabled radios that are on the current frequency */
164 for (i = 0; i < hwsim_radio_count; i++) { 216 spin_lock(&hwsim_radio_lock);
165 struct mac80211_hwsim_data *data2; 217 list_for_each_entry(data2, &hwsim_radios, list) {
166 struct sk_buff *nskb; 218 struct sk_buff *nskb;
167 219
168 if (hwsim_radios[i] == NULL || hwsim_radios[i] == hw) 220 if (data == data2)
169 continue; 221 continue;
170 data2 = hwsim_radios[i]->priv; 222
171 if (!data2->started || !data2->radio_enabled || 223 if (!data2->started || !data2->radio_enabled ||
172 data->channel->center_freq != data2->channel->center_freq) 224 data->channel->center_freq != data2->channel->center_freq)
173 continue; 225 continue;
@@ -176,11 +228,12 @@ static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
176 if (nskb == NULL) 228 if (nskb == NULL)
177 continue; 229 continue;
178 230
179 if (memcmp(hdr->addr1, hwsim_radios[i]->wiphy->perm_addr, 231 if (memcmp(hdr->addr1, data2->hw->wiphy->perm_addr,
180 ETH_ALEN) == 0) 232 ETH_ALEN) == 0)
181 ack = 1; 233 ack = true;
182 ieee80211_rx_irqsafe(hwsim_radios[i], nskb, &rx_status); 234 ieee80211_rx_irqsafe(data2->hw, nskb, &rx_status);
183 } 235 }
236 spin_unlock(&hwsim_radio_lock);
184 237
185 return ack; 238 return ack;
186} 239}
@@ -189,7 +242,7 @@ static int mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
189static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 242static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
190{ 243{
191 struct mac80211_hwsim_data *data = hw->priv; 244 struct mac80211_hwsim_data *data = hw->priv;
192 int ack; 245 bool ack;
193 struct ieee80211_tx_info *txi; 246 struct ieee80211_tx_info *txi;
194 247
195 mac80211_hwsim_monitor_rx(hw, skb); 248 mac80211_hwsim_monitor_rx(hw, skb);
@@ -210,6 +263,12 @@ static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
210 ack = mac80211_hwsim_tx_frame(hw, skb); 263 ack = mac80211_hwsim_tx_frame(hw, skb);
211 264
212 txi = IEEE80211_SKB_CB(skb); 265 txi = IEEE80211_SKB_CB(skb);
266
267 if (txi->control.vif)
268 hwsim_check_magic(txi->control.vif);
269 if (txi->control.sta)
270 hwsim_check_sta_magic(txi->control.sta);
271
213 memset(&txi->status, 0, sizeof(txi->status)); 272 memset(&txi->status, 0, sizeof(txi->status));
214 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { 273 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
215 if (ack) 274 if (ack)
@@ -246,6 +305,7 @@ static int mac80211_hwsim_add_interface(struct ieee80211_hw *hw,
246 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n", 305 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
247 wiphy_name(hw->wiphy), __func__, conf->type, 306 wiphy_name(hw->wiphy), __func__, conf->type,
248 print_mac(mac, conf->mac_addr)); 307 print_mac(mac, conf->mac_addr));
308 hwsim_set_magic(conf->vif);
249 return 0; 309 return 0;
250} 310}
251 311
@@ -257,6 +317,8 @@ static void mac80211_hwsim_remove_interface(
257 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n", 317 printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
258 wiphy_name(hw->wiphy), __func__, conf->type, 318 wiphy_name(hw->wiphy), __func__, conf->type,
259 print_mac(mac, conf->mac_addr)); 319 print_mac(mac, conf->mac_addr));
320 hwsim_check_magic(conf->vif);
321 hwsim_clear_magic(conf->vif);
260} 322}
261 323
262 324
@@ -267,7 +329,9 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
267 struct sk_buff *skb; 329 struct sk_buff *skb;
268 struct ieee80211_tx_info *info; 330 struct ieee80211_tx_info *info;
269 331
270 if (vif->type != IEEE80211_IF_TYPE_AP) 332 hwsim_check_magic(vif);
333
334 if (vif->type != NL80211_IFTYPE_AP)
271 return; 335 return;
272 336
273 skb = ieee80211_beacon_get(hw, vif); 337 skb = ieee80211_beacon_get(hw, vif);
@@ -341,7 +405,45 @@ static void mac80211_hwsim_configure_filter(struct ieee80211_hw *hw,
341 *total_flags = data->rx_filter; 405 *total_flags = data->rx_filter;
342} 406}
343 407
408static int mac80211_hwsim_config_interface(struct ieee80211_hw *hw,
409 struct ieee80211_vif *vif,
410 struct ieee80211_if_conf *conf)
411{
412 hwsim_check_magic(vif);
413 return 0;
414}
415
416static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
417 struct ieee80211_vif *vif,
418 struct ieee80211_bss_conf *info,
419 u32 changed)
420{
421 hwsim_check_magic(vif);
422}
423
424static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw,
425 struct ieee80211_vif *vif,
426 enum sta_notify_cmd cmd,
427 struct ieee80211_sta *sta)
428{
429 hwsim_check_magic(vif);
430 switch (cmd) {
431 case STA_NOTIFY_ADD:
432 hwsim_set_sta_magic(sta);
433 break;
434 case STA_NOTIFY_REMOVE:
435 hwsim_clear_sta_magic(sta);
436 break;
437 }
438}
344 439
440static int mac80211_hwsim_set_tim(struct ieee80211_hw *hw,
441 struct ieee80211_sta *sta,
442 bool set)
443{
444 hwsim_check_sta_magic(sta);
445 return 0;
446}
345 447
346static const struct ieee80211_ops mac80211_hwsim_ops = 448static const struct ieee80211_ops mac80211_hwsim_ops =
347{ 449{
@@ -352,23 +454,30 @@ static const struct ieee80211_ops mac80211_hwsim_ops =
352 .remove_interface = mac80211_hwsim_remove_interface, 454 .remove_interface = mac80211_hwsim_remove_interface,
353 .config = mac80211_hwsim_config, 455 .config = mac80211_hwsim_config,
354 .configure_filter = mac80211_hwsim_configure_filter, 456 .configure_filter = mac80211_hwsim_configure_filter,
457 .config_interface = mac80211_hwsim_config_interface,
458 .bss_info_changed = mac80211_hwsim_bss_info_changed,
459 .sta_notify = mac80211_hwsim_sta_notify,
460 .set_tim = mac80211_hwsim_set_tim,
355}; 461};
356 462
357 463
358static void mac80211_hwsim_free(void) 464static void mac80211_hwsim_free(void)
359{ 465{
360 int i; 466 struct list_head tmplist, *i, *tmp;
361 467 struct mac80211_hwsim_data *data;
362 for (i = 0; i < hwsim_radio_count; i++) { 468
363 if (hwsim_radios[i]) { 469 INIT_LIST_HEAD(&tmplist);
364 struct mac80211_hwsim_data *data; 470
365 data = hwsim_radios[i]->priv; 471 spin_lock_bh(&hwsim_radio_lock);
366 ieee80211_unregister_hw(hwsim_radios[i]); 472 list_for_each_safe(i, tmp, &hwsim_radios)
367 device_unregister(data->dev); 473 list_move(i, &tmplist);
368 ieee80211_free_hw(hwsim_radios[i]); 474 spin_unlock_bh(&hwsim_radio_lock);
369 } 475
476 list_for_each_entry(data, &tmplist, list) {
477 ieee80211_unregister_hw(data->hw);
478 device_unregister(data->dev);
479 ieee80211_free_hw(data->hw);
370 } 480 }
371 kfree(hwsim_radios);
372 class_destroy(hwsim_class); 481 class_destroy(hwsim_class);
373} 482}
374 483
@@ -398,37 +507,32 @@ static int __init init_mac80211_hwsim(void)
398 struct ieee80211_hw *hw; 507 struct ieee80211_hw *hw;
399 DECLARE_MAC_BUF(mac); 508 DECLARE_MAC_BUF(mac);
400 509
401 if (radios < 1 || radios > 65535) 510 if (radios < 1 || radios > 100)
402 return -EINVAL; 511 return -EINVAL;
403 512
404 hwsim_radio_count = radios; 513 spin_lock_init(&hwsim_radio_lock);
405 hwsim_radios = kcalloc(hwsim_radio_count, 514 INIT_LIST_HEAD(&hwsim_radios);
406 sizeof(struct ieee80211_hw *), GFP_KERNEL);
407 if (hwsim_radios == NULL)
408 return -ENOMEM;
409 515
410 hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim"); 516 hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim");
411 if (IS_ERR(hwsim_class)) { 517 if (IS_ERR(hwsim_class))
412 kfree(hwsim_radios);
413 return PTR_ERR(hwsim_class); 518 return PTR_ERR(hwsim_class);
414 }
415 519
416 memset(addr, 0, ETH_ALEN); 520 memset(addr, 0, ETH_ALEN);
417 addr[0] = 0x02; 521 addr[0] = 0x02;
418 522
419 for (i = 0; i < hwsim_radio_count; i++) { 523 for (i = 0; i < radios; i++) {
420 printk(KERN_DEBUG "mac80211_hwsim: Initializing radio %d\n", 524 printk(KERN_DEBUG "mac80211_hwsim: Initializing radio %d\n",
421 i); 525 i);
422 hw = ieee80211_alloc_hw(sizeof(*data), &mac80211_hwsim_ops); 526 hw = ieee80211_alloc_hw(sizeof(*data), &mac80211_hwsim_ops);
423 if (hw == NULL) { 527 if (!hw) {
424 printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw " 528 printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw "
425 "failed\n"); 529 "failed\n");
426 err = -ENOMEM; 530 err = -ENOMEM;
427 goto failed; 531 goto failed;
428 } 532 }
429 hwsim_radios[i] = hw;
430
431 data = hw->priv; 533 data = hw->priv;
534 data->hw = hw;
535
432 data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw, 536 data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw,
433 "hwsim%d", i); 537 "hwsim%d", i);
434 if (IS_ERR(data->dev)) { 538 if (IS_ERR(data->dev)) {
@@ -452,6 +556,10 @@ static int __init init_mac80211_hwsim(void)
452 BIT(NL80211_IFTYPE_AP); 556 BIT(NL80211_IFTYPE_AP);
453 hw->ampdu_queues = 1; 557 hw->ampdu_queues = 1;
454 558
559 /* ask mac80211 to reserve space for magic */
560 hw->vif_data_size = sizeof(struct hwsim_vif_priv);
561 hw->sta_data_size = sizeof(struct hwsim_sta_priv);
562
455 memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels)); 563 memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels));
456 memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); 564 memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));
457 data->band.channels = data->channels; 565 data->band.channels = data->channels;
@@ -486,6 +594,8 @@ static int __init init_mac80211_hwsim(void)
486 594
487 setup_timer(&data->beacon_timer, mac80211_hwsim_beacon, 595 setup_timer(&data->beacon_timer, mac80211_hwsim_beacon,
488 (unsigned long) hw); 596 (unsigned long) hw);
597
598 list_add_tail(&data->list, &hwsim_radios);
489 } 599 }
490 600
491 hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup); 601 hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup);
@@ -517,7 +627,6 @@ failed_hw:
517 device_unregister(data->dev); 627 device_unregister(data->dev);
518failed_drvdata: 628failed_drvdata:
519 ieee80211_free_hw(hw); 629 ieee80211_free_hw(hw);
520 hwsim_radios[i] = NULL;
521failed: 630failed:
522 mac80211_hwsim_free(); 631 mac80211_hwsim_free();
523 return err; 632 return err;
@@ -526,8 +635,7 @@ failed:
526 635
527static void __exit exit_mac80211_hwsim(void) 636static void __exit exit_mac80211_hwsim(void)
528{ 637{
529 printk(KERN_DEBUG "mac80211_hwsim: unregister %d radios\n", 638 printk(KERN_DEBUG "mac80211_hwsim: unregister radios\n");
530 hwsim_radio_count);
531 639
532 unregister_netdev(hwsim_mon); 640 unregister_netdev(hwsim_mon);
533 mac80211_hwsim_free(); 641 mac80211_hwsim_free();
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index ec0451cbb8e1..9a2fcc0163d6 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -4777,14 +4777,14 @@ static int orinoco_ioctl_get_encodeext(struct net_device *dev,
4777 encoding->flags |= IW_ENCODE_DISABLED; 4777 encoding->flags |= IW_ENCODE_DISABLED;
4778 break; 4778 break;
4779 case IW_ENCODE_ALG_WEP: 4779 case IW_ENCODE_ALG_WEP:
4780 ext->key_len = min(le16_to_cpu(priv->keys[idx].len), 4780 ext->key_len = min_t(u16, le16_to_cpu(priv->keys[idx].len),
4781 (u16) max_key_len); 4781 max_key_len);
4782 memcpy(ext->key, priv->keys[idx].data, ext->key_len); 4782 memcpy(ext->key, priv->keys[idx].data, ext->key_len);
4783 encoding->flags |= IW_ENCODE_ENABLED; 4783 encoding->flags |= IW_ENCODE_ENABLED;
4784 break; 4784 break;
4785 case IW_ENCODE_ALG_TKIP: 4785 case IW_ENCODE_ALG_TKIP:
4786 ext->key_len = min((u16) sizeof(struct orinoco_tkip_key), 4786 ext->key_len = min_t(u16, sizeof(struct orinoco_tkip_key),
4787 (u16) max_key_len); 4787 max_key_len);
4788 memcpy(ext->key, &priv->tkip_key[idx], ext->key_len); 4788 memcpy(ext->key, &priv->tkip_key[idx], ext->key_len);
4789 encoding->flags |= IW_ENCODE_ENABLED; 4789 encoding->flags |= IW_ENCODE_ENABLED;
4790 break; 4790 break;
@@ -5686,9 +5686,9 @@ static inline char *orinoco_translate_ext_scan(struct net_device *dev,
5686 5686
5687 /* Timestamp */ 5687 /* Timestamp */
5688 iwe.cmd = IWEVCUSTOM; 5688 iwe.cmd = IWEVCUSTOM;
5689 iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, 5689 iwe.u.data.length =
5690 "tsf=%016llx", 5690 snprintf(custom, MAX_CUSTOM_LEN, "tsf=%016llx",
5691 le64_to_cpu(bss->timestamp)); 5691 (unsigned long long) le64_to_cpu(bss->timestamp));
5692 if (iwe.u.data.length) 5692 if (iwe.u.data.length)
5693 current_ev = iwe_stream_add_point(info, current_ev, end_buf, 5693 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
5694 &iwe, custom); 5694 &iwe, custom);
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index da51786254dc..bac58ed03e5c 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -1139,7 +1139,7 @@ static int p54_start(struct ieee80211_hw *dev)
1139 1139
1140 err = priv->open(dev); 1140 err = priv->open(dev);
1141 if (!err) 1141 if (!err)
1142 priv->mode = IEEE80211_IF_TYPE_MNTR; 1142 priv->mode = NL80211_IFTYPE_MONITOR;
1143 1143
1144 p54_init_vdcf(dev); 1144 p54_init_vdcf(dev);
1145 1145
@@ -1157,7 +1157,7 @@ static void p54_stop(struct ieee80211_hw *dev)
1157 kfree_skb(skb); 1157 kfree_skb(skb);
1158 priv->stop(dev); 1158 priv->stop(dev);
1159 priv->tsf_high32 = priv->tsf_low32 = 0; 1159 priv->tsf_high32 = priv->tsf_low32 = 0;
1160 priv->mode = IEEE80211_IF_TYPE_INVALID; 1160 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1161} 1161}
1162 1162
1163static int p54_add_interface(struct ieee80211_hw *dev, 1163static int p54_add_interface(struct ieee80211_hw *dev,
@@ -1165,11 +1165,11 @@ static int p54_add_interface(struct ieee80211_hw *dev,
1165{ 1165{
1166 struct p54_common *priv = dev->priv; 1166 struct p54_common *priv = dev->priv;
1167 1167
1168 if (priv->mode != IEEE80211_IF_TYPE_MNTR) 1168 if (priv->mode != NL80211_IFTYPE_MONITOR)
1169 return -EOPNOTSUPP; 1169 return -EOPNOTSUPP;
1170 1170
1171 switch (conf->type) { 1171 switch (conf->type) {
1172 case IEEE80211_IF_TYPE_STA: 1172 case NL80211_IFTYPE_STATION:
1173 priv->mode = conf->type; 1173 priv->mode = conf->type;
1174 break; 1174 break;
1175 default: 1175 default:
@@ -1181,7 +1181,7 @@ static int p54_add_interface(struct ieee80211_hw *dev,
1181 p54_set_filter(dev, 0, NULL); 1181 p54_set_filter(dev, 0, NULL);
1182 1182
1183 switch (conf->type) { 1183 switch (conf->type) {
1184 case IEEE80211_IF_TYPE_STA: 1184 case NL80211_IFTYPE_STATION:
1185 p54_set_filter(dev, 1, NULL); 1185 p54_set_filter(dev, 1, NULL);
1186 break; 1186 break;
1187 default: 1187 default:
@@ -1198,7 +1198,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
1198 struct ieee80211_if_init_conf *conf) 1198 struct ieee80211_if_init_conf *conf)
1199{ 1199{
1200 struct p54_common *priv = dev->priv; 1200 struct p54_common *priv = dev->priv;
1201 priv->mode = IEEE80211_IF_TYPE_MNTR; 1201 priv->mode = NL80211_IFTYPE_MONITOR;
1202 memset(priv->mac_addr, 0, ETH_ALEN); 1202 memset(priv->mac_addr, 0, ETH_ALEN);
1203 p54_set_filter(dev, 0, NULL); 1203 p54_set_filter(dev, 0, NULL);
1204} 1204}
@@ -1380,7 +1380,7 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
1380 return NULL; 1380 return NULL;
1381 1381
1382 priv = dev->priv; 1382 priv = dev->priv;
1383 priv->mode = IEEE80211_IF_TYPE_INVALID; 1383 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1384 skb_queue_head_init(&priv->tx_queue); 1384 skb_queue_head_init(&priv->tx_queue);
1385 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */ 1385 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */
1386 IEEE80211_HW_RX_INCLUDES_FCS | 1386 IEEE80211_HW_RX_INCLUDES_FCS |
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 1594786205f8..1c2a02a741af 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -616,7 +616,7 @@ static int p54p_suspend(struct pci_dev *pdev, pm_message_t state)
616 struct ieee80211_hw *dev = pci_get_drvdata(pdev); 616 struct ieee80211_hw *dev = pci_get_drvdata(pdev);
617 struct p54p_priv *priv = dev->priv; 617 struct p54p_priv *priv = dev->priv;
618 618
619 if (priv->common.mode != IEEE80211_IF_TYPE_INVALID) { 619 if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
620 ieee80211_stop_queues(dev); 620 ieee80211_stop_queues(dev);
621 p54p_stop(dev); 621 p54p_stop(dev);
622 } 622 }
@@ -634,7 +634,7 @@ static int p54p_resume(struct pci_dev *pdev)
634 pci_set_power_state(pdev, PCI_D0); 634 pci_set_power_state(pdev, PCI_D0);
635 pci_restore_state(pdev); 635 pci_restore_state(pdev);
636 636
637 if (priv->common.mode != IEEE80211_IF_TYPE_INVALID) { 637 if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
638 p54p_open(dev); 638 p54p_open(dev);
639 ieee80211_wake_queues(dev); 639 ieee80211_wake_queues(dev);
640 } 640 }
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index cb5f2d01a9c3..d3bf7bba611a 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -384,7 +384,7 @@ static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
384 rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg); 384 rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg);
385 rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET, bcn_preload >> 6); 385 rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET, bcn_preload >> 6);
386 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 386 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW,
387 2 * (conf->type != IEEE80211_IF_TYPE_STA)); 387 2 * (conf->type != NL80211_IFTYPE_STATION));
388 rt2500usb_register_write(rt2x00dev, TXRX_CSR20, reg); 388 rt2500usb_register_write(rt2x00dev, TXRX_CSR20, reg);
389 389
390 /* 390 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 6f296cef76ad..1359a3768404 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -483,7 +483,7 @@ struct rt2x00intf_conf {
483 /* 483 /*
484 * Interface type 484 * Interface type
485 */ 485 */
486 enum ieee80211_if_types type; 486 enum nl80211_iftype type;
487 487
488 /* 488 /*
489 * TSF sync value, this is dependant on the operation type. 489 * TSF sync value, this is dependant on the operation type.
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index ca051f50ef10..4d5e87b015a0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -31,7 +31,7 @@
31 31
32void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev, 32void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
33 struct rt2x00_intf *intf, 33 struct rt2x00_intf *intf,
34 enum ieee80211_if_types type, 34 enum nl80211_iftype type,
35 u8 *mac, u8 *bssid) 35 u8 *mac, u8 *bssid)
36{ 36{
37 struct rt2x00intf_conf conf; 37 struct rt2x00intf_conf conf;
@@ -40,11 +40,11 @@ void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
40 conf.type = type; 40 conf.type = type;
41 41
42 switch (type) { 42 switch (type) {
43 case IEEE80211_IF_TYPE_IBSS: 43 case NL80211_IFTYPE_ADHOC:
44 case IEEE80211_IF_TYPE_AP: 44 case NL80211_IFTYPE_AP:
45 conf.sync = TSF_SYNC_BEACON; 45 conf.sync = TSF_SYNC_BEACON;
46 break; 46 break;
47 case IEEE80211_IF_TYPE_STA: 47 case NL80211_IFTYPE_STATION:
48 conf.sync = TSF_SYNC_INFRA; 48 conf.sync = TSF_SYNC_INFRA;
49 break; 49 break;
50 default: 50 default:
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 2f3bfc606880..86840e3585e8 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -467,8 +467,8 @@ static void rt2x00lib_beacondone_iter(void *data, u8 *mac,
467 struct rt2x00_dev *rt2x00dev = data; 467 struct rt2x00_dev *rt2x00dev = data;
468 struct rt2x00_intf *intf = vif_to_intf(vif); 468 struct rt2x00_intf *intf = vif_to_intf(vif);
469 469
470 if (vif->type != IEEE80211_IF_TYPE_AP && 470 if (vif->type != NL80211_IFTYPE_AP &&
471 vif->type != IEEE80211_IF_TYPE_IBSS) 471 vif->type != NL80211_IFTYPE_ADHOC)
472 return; 472 return;
473 473
474 /* 474 /*
@@ -1212,8 +1212,8 @@ static void rt2x00lib_resume_intf(void *data, u8 *mac,
1212 /* 1212 /*
1213 * Master or Ad-hoc mode require a new beacon update. 1213 * Master or Ad-hoc mode require a new beacon update.
1214 */ 1214 */
1215 if (vif->type == IEEE80211_IF_TYPE_AP || 1215 if (vif->type == NL80211_IFTYPE_AP ||
1216 vif->type == IEEE80211_IF_TYPE_IBSS) 1216 vif->type == NL80211_IFTYPE_ADHOC)
1217 intf->delayed_flags |= DELAYED_UPDATE_BEACON; 1217 intf->delayed_flags |= DELAYED_UPDATE_BEACON;
1218 1218
1219 spin_unlock(&intf->lock); 1219 spin_unlock(&intf->lock);
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 7bbc16b1b6c6..797eb619aa0a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -88,7 +88,7 @@ void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev);
88 */ 88 */
89void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev, 89void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
90 struct rt2x00_intf *intf, 90 struct rt2x00_intf *intf,
91 enum ieee80211_if_types type, 91 enum nl80211_iftype type,
92 u8 *mac, u8 *bssid); 92 u8 *mac, u8 *bssid);
93void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev, 93void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
94 struct rt2x00_intf *intf, 94 struct rt2x00_intf *intf,
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 56829fad3471..485c40de5cc0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -211,7 +211,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
211 return -ENODEV; 211 return -ENODEV;
212 212
213 switch (conf->type) { 213 switch (conf->type) {
214 case IEEE80211_IF_TYPE_AP: 214 case NL80211_IFTYPE_AP:
215 /* 215 /*
216 * We don't support mixed combinations of 216 * We don't support mixed combinations of
217 * sta and ap interfaces. 217 * sta and ap interfaces.
@@ -227,8 +227,8 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
227 return -ENOBUFS; 227 return -ENOBUFS;
228 228
229 break; 229 break;
230 case IEEE80211_IF_TYPE_STA: 230 case NL80211_IFTYPE_STATION:
231 case IEEE80211_IF_TYPE_IBSS: 231 case NL80211_IFTYPE_ADHOC:
232 /* 232 /*
233 * We don't support mixed combinations of 233 * We don't support mixed combinations of
234 * sta and ap interfaces. 234 * sta and ap interfaces.
@@ -268,7 +268,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
268 * increase interface count and start initialization. 268 * increase interface count and start initialization.
269 */ 269 */
270 270
271 if (conf->type == IEEE80211_IF_TYPE_AP) 271 if (conf->type == NL80211_IFTYPE_AP)
272 rt2x00dev->intf_ap_count++; 272 rt2x00dev->intf_ap_count++;
273 else 273 else
274 rt2x00dev->intf_sta_count++; 274 rt2x00dev->intf_sta_count++;
@@ -277,7 +277,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
277 spin_lock_init(&intf->seqlock); 277 spin_lock_init(&intf->seqlock);
278 intf->beacon = entry; 278 intf->beacon = entry;
279 279
280 if (conf->type == IEEE80211_IF_TYPE_AP) 280 if (conf->type == NL80211_IFTYPE_AP)
281 memcpy(&intf->bssid, conf->mac_addr, ETH_ALEN); 281 memcpy(&intf->bssid, conf->mac_addr, ETH_ALEN);
282 memcpy(&intf->mac, conf->mac_addr, ETH_ALEN); 282 memcpy(&intf->mac, conf->mac_addr, ETH_ALEN);
283 283
@@ -311,11 +311,11 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
311 * no interface is present. 311 * no interface is present.
312 */ 312 */
313 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) || 313 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
314 (conf->type == IEEE80211_IF_TYPE_AP && !rt2x00dev->intf_ap_count) || 314 (conf->type == NL80211_IFTYPE_AP && !rt2x00dev->intf_ap_count) ||
315 (conf->type != IEEE80211_IF_TYPE_AP && !rt2x00dev->intf_sta_count)) 315 (conf->type != NL80211_IFTYPE_AP && !rt2x00dev->intf_sta_count))
316 return; 316 return;
317 317
318 if (conf->type == IEEE80211_IF_TYPE_AP) 318 if (conf->type == NL80211_IFTYPE_AP)
319 rt2x00dev->intf_ap_count--; 319 rt2x00dev->intf_ap_count--;
320 else 320 else
321 rt2x00dev->intf_sta_count--; 321 rt2x00dev->intf_sta_count--;
@@ -331,7 +331,7 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
331 * are cleared to prevent false ACKing of frames. 331 * are cleared to prevent false ACKing of frames.
332 */ 332 */
333 rt2x00lib_config_intf(rt2x00dev, intf, 333 rt2x00lib_config_intf(rt2x00dev, intf,
334 IEEE80211_IF_TYPE_INVALID, NULL, NULL); 334 NL80211_IFTYPE_UNSPECIFIED, NULL, NULL);
335} 335}
336EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface); 336EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface);
337 337
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index a5e965068c83..b7f4fe8fba6e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -155,7 +155,6 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
155{ 155{
156 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 156 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
157 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); 157 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
158 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
159 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; 158 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data;
160 struct ieee80211_rate *rate = 159 struct ieee80211_rate *rate =
161 ieee80211_get_tx_rate(rt2x00dev->hw, tx_info); 160 ieee80211_get_tx_rate(rt2x00dev->hw, tx_info);
@@ -278,16 +277,22 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
278 * sequence counter given by mac80211. 277 * sequence counter given by mac80211.
279 */ 278 */
280 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 279 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
281 spin_lock_irqsave(&intf->seqlock, irqflags); 280 if (likely(tx_info->control.vif)) {
281 struct rt2x00_intf *intf;
282 282
283 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) 283 intf = vif_to_intf(tx_info->control.vif);
284 intf->seqno += 0x10;
285 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
286 hdr->seq_ctrl |= cpu_to_le16(intf->seqno);
287 284
288 spin_unlock_irqrestore(&intf->seqlock, irqflags); 285 spin_lock_irqsave(&intf->seqlock, irqflags);
289 286
290 __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags); 287 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
288 intf->seqno += 0x10;
289 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
290 hdr->seq_ctrl |= cpu_to_le16(intf->seqno);
291
292 spin_unlock_irqrestore(&intf->seqlock, irqflags);
293
294 __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);
295 }
291 } 296 }
292 297
293 /* 298 /*
diff --git a/drivers/net/wireless/rtl8180_dev.c b/drivers/net/wireless/rtl8180_dev.c
index 861c76a65d6a..abcd641c54be 100644
--- a/drivers/net/wireless/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl8180_dev.c
@@ -615,7 +615,7 @@ static int rtl8180_start(struct ieee80211_hw *dev)
615 reg |= RTL818X_CMD_TX_ENABLE; 615 reg |= RTL818X_CMD_TX_ENABLE;
616 rtl818x_iowrite8(priv, &priv->map->CMD, reg); 616 rtl818x_iowrite8(priv, &priv->map->CMD, reg);
617 617
618 priv->mode = IEEE80211_IF_TYPE_MNTR; 618 priv->mode = NL80211_IFTYPE_MONITOR;
619 return 0; 619 return 0;
620 620
621 err_free_rings: 621 err_free_rings:
@@ -633,7 +633,7 @@ static void rtl8180_stop(struct ieee80211_hw *dev)
633 u8 reg; 633 u8 reg;
634 int i; 634 int i;
635 635
636 priv->mode = IEEE80211_IF_TYPE_INVALID; 636 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
637 637
638 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0); 638 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0);
639 639
@@ -661,11 +661,11 @@ static int rtl8180_add_interface(struct ieee80211_hw *dev,
661{ 661{
662 struct rtl8180_priv *priv = dev->priv; 662 struct rtl8180_priv *priv = dev->priv;
663 663
664 if (priv->mode != IEEE80211_IF_TYPE_MNTR) 664 if (priv->mode != NL80211_IFTYPE_MONITOR)
665 return -EOPNOTSUPP; 665 return -EOPNOTSUPP;
666 666
667 switch (conf->type) { 667 switch (conf->type) {
668 case IEEE80211_IF_TYPE_STA: 668 case NL80211_IFTYPE_STATION:
669 priv->mode = conf->type; 669 priv->mode = conf->type;
670 break; 670 break;
671 default: 671 default:
@@ -688,7 +688,7 @@ static void rtl8180_remove_interface(struct ieee80211_hw *dev,
688 struct ieee80211_if_init_conf *conf) 688 struct ieee80211_if_init_conf *conf)
689{ 689{
690 struct rtl8180_priv *priv = dev->priv; 690 struct rtl8180_priv *priv = dev->priv;
691 priv->mode = IEEE80211_IF_TYPE_MNTR; 691 priv->mode = NL80211_IFTYPE_MONITOR;
692 priv->vif = NULL; 692 priv->vif = NULL;
693} 693}
694 694
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index 8a42bfa6d4f0..e9902613e2ee 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -836,11 +836,11 @@ static int rtl8187_add_interface(struct ieee80211_hw *dev,
836 struct rtl8187_priv *priv = dev->priv; 836 struct rtl8187_priv *priv = dev->priv;
837 int i; 837 int i;
838 838
839 if (priv->mode != IEEE80211_IF_TYPE_MNTR) 839 if (priv->mode != NL80211_IFTYPE_MONITOR)
840 return -EOPNOTSUPP; 840 return -EOPNOTSUPP;
841 841
842 switch (conf->type) { 842 switch (conf->type) {
843 case IEEE80211_IF_TYPE_STA: 843 case NL80211_IFTYPE_STATION:
844 priv->mode = conf->type; 844 priv->mode = conf->type;
845 break; 845 break;
846 default: 846 default:
@@ -865,7 +865,7 @@ static void rtl8187_remove_interface(struct ieee80211_hw *dev,
865{ 865{
866 struct rtl8187_priv *priv = dev->priv; 866 struct rtl8187_priv *priv = dev->priv;
867 mutex_lock(&priv->conf_mutex); 867 mutex_lock(&priv->conf_mutex);
868 priv->mode = IEEE80211_IF_TYPE_MNTR; 868 priv->mode = NL80211_IFTYPE_MONITOR;
869 priv->vif = NULL; 869 priv->vif = NULL;
870 mutex_unlock(&priv->conf_mutex); 870 mutex_unlock(&priv->conf_mutex);
871} 871}
@@ -1057,7 +1057,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1057 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; 1057 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
1058 1058
1059 1059
1060 priv->mode = IEEE80211_IF_TYPE_MNTR; 1060 priv->mode = NL80211_IFTYPE_MONITOR;
1061 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1061 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1062 IEEE80211_HW_RX_INCLUDES_FCS; 1062 IEEE80211_HW_RX_INCLUDES_FCS;
1063 1063
diff --git a/drivers/net/wireless/zd1211rw/Makefile b/drivers/net/wireless/zd1211rw/Makefile
index cc36126cee88..1907eafb9b16 100644
--- a/drivers/net/wireless/zd1211rw/Makefile
+++ b/drivers/net/wireless/zd1211rw/Makefile
@@ -1,6 +1,6 @@
1obj-$(CONFIG_ZD1211RW) += zd1211rw.o 1obj-$(CONFIG_ZD1211RW) += zd1211rw.o
2 2
3zd1211rw-objs := zd_chip.o zd_ieee80211.o zd_mac.o \ 3zd1211rw-objs := zd_chip.o zd_mac.o \
4 zd_rf_al2230.o zd_rf_rf2959.o \ 4 zd_rf_al2230.o zd_rf_rf2959.o \
5 zd_rf_al7230b.o zd_rf_uw2453.o \ 5 zd_rf_al7230b.o zd_rf_uw2453.o \
6 zd_rf.o zd_usb.o 6 zd_rf.o zd_usb.o
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 0acb5c345734..e0ac58b8ff1f 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -28,7 +28,6 @@
28 28
29#include "zd_def.h" 29#include "zd_def.h"
30#include "zd_chip.h" 30#include "zd_chip.h"
31#include "zd_ieee80211.h"
32#include "zd_mac.h" 31#include "zd_mac.h"
33#include "zd_rf.h" 32#include "zd_rf.h"
34 33
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
deleted file mode 100644
index d8dc41ec0e5d..000000000000
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/* ZD1211 USB-WLAN driver for Linux
2 *
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * In the long term, we'll probably find a better way of handling regulatory
23 * requirements outside of the driver.
24 */
25
26#include <linux/kernel.h>
27#include <net/mac80211.h>
28
29#include "zd_ieee80211.h"
30#include "zd_mac.h"
31
32struct channel_range {
33 u8 regdomain;
34 u8 start;
35 u8 end; /* exclusive (channel must be less than end) */
36};
37
38static const struct channel_range channel_ranges[] = {
39 { ZD_REGDOMAIN_FCC, 1, 12 },
40 { ZD_REGDOMAIN_IC, 1, 12 },
41 { ZD_REGDOMAIN_ETSI, 1, 14 },
42 { ZD_REGDOMAIN_JAPAN, 1, 14 },
43 { ZD_REGDOMAIN_SPAIN, 1, 14 },
44 { ZD_REGDOMAIN_FRANCE, 1, 14 },
45
46 /* Japan originally only had channel 14 available (see CHNL_ID 0x40 in
47 * 802.11). However, in 2001 the range was extended to include channels
48 * 1-13. The ZyDAS devices still use the old region code but are
49 * designed to allow the extra channel access in Japan. */
50 { ZD_REGDOMAIN_JAPAN_ADD, 1, 15 },
51};
52
53static const struct channel_range *zd_channel_range(u8 regdomain)
54{
55 int i;
56 for (i = 0; i < ARRAY_SIZE(channel_ranges); i++) {
57 const struct channel_range *range = &channel_ranges[i];
58 if (range->regdomain == regdomain)
59 return range;
60 }
61 return NULL;
62}
63
64#define CHAN_TO_IDX(chan) ((chan) - 1)
65
66static void unmask_bg_channels(struct ieee80211_hw *hw,
67 const struct channel_range *range,
68 struct ieee80211_supported_band *sband)
69{
70 u8 channel;
71
72 for (channel = range->start; channel < range->end; channel++) {
73 struct ieee80211_channel *chan =
74 &sband->channels[CHAN_TO_IDX(channel)];
75 chan->flags = 0;
76 }
77}
78
79void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain)
80{
81 struct zd_mac *mac = zd_hw_mac(hw);
82 const struct channel_range *range;
83
84 dev_dbg(zd_mac_dev(mac), "regdomain %#02x\n", regdomain);
85
86 range = zd_channel_range(regdomain);
87 if (!range) {
88 /* The vendor driver overrides the regulatory domain and
89 * allowed channel registers and unconditionally restricts
90 * available channels to 1-11 everywhere. Match their
91 * questionable behaviour only for regdomains which we don't
92 * recognise. */
93 dev_warn(zd_mac_dev(mac), "Unrecognised regulatory domain: "
94 "%#02x. Defaulting to FCC.\n", regdomain);
95 range = zd_channel_range(ZD_REGDOMAIN_FCC);
96 }
97
98 unmask_bg_channels(hw, range, &mac->band);
99}
100
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
deleted file mode 100644
index 26b79f197587..000000000000
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/* ZD1211 USB-WLAN driver for Linux
2 *
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _ZD_IEEE80211_H
22#define _ZD_IEEE80211_H
23
24#include <net/mac80211.h>
25
26/* Additional definitions from the standards.
27 */
28
29#define ZD_REGDOMAIN_FCC 0x10
30#define ZD_REGDOMAIN_IC 0x20
31#define ZD_REGDOMAIN_ETSI 0x30
32#define ZD_REGDOMAIN_SPAIN 0x31
33#define ZD_REGDOMAIN_FRANCE 0x32
34#define ZD_REGDOMAIN_JAPAN_ADD 0x40
35#define ZD_REGDOMAIN_JAPAN 0x41
36
37enum {
38 MIN_CHANNEL24 = 1,
39 MAX_CHANNEL24 = 14,
40};
41
42void zd_geo_init(struct ieee80211_hw *hw, u8 regdomain);
43
44#define ZD_PLCP_SERVICE_LENGTH_EXTENSION 0x80
45
46struct ofdm_plcp_header {
47 u8 prefix[3];
48 __le16 service;
49} __attribute__((packed));
50
51static inline u8 zd_ofdm_plcp_header_rate(const struct ofdm_plcp_header *header)
52{
53 return header->prefix[0] & 0xf;
54}
55
56/* The following defines give the encoding of the 4-bit rate field in the
57 * OFDM (802.11a/802.11g) PLCP header. Notify that these values are used to
58 * define the zd-rate values for OFDM.
59 *
60 * See the struct zd_ctrlset definition in zd_mac.h.
61 */
62#define ZD_OFDM_PLCP_RATE_6M 0xb
63#define ZD_OFDM_PLCP_RATE_9M 0xf
64#define ZD_OFDM_PLCP_RATE_12M 0xa
65#define ZD_OFDM_PLCP_RATE_18M 0xe
66#define ZD_OFDM_PLCP_RATE_24M 0x9
67#define ZD_OFDM_PLCP_RATE_36M 0xd
68#define ZD_OFDM_PLCP_RATE_48M 0x8
69#define ZD_OFDM_PLCP_RATE_54M 0xc
70
71struct cck_plcp_header {
72 u8 signal;
73 u8 service;
74 __le16 length;
75 __le16 crc16;
76} __attribute__((packed));
77
78static inline u8 zd_cck_plcp_header_signal(const struct cck_plcp_header *header)
79{
80 return header->signal;
81}
82
83/* These defines give the encodings of the signal field in the 802.11b PLCP
84 * header. The signal field gives the bit rate of the following packet. Even
85 * if technically wrong we use CCK here also for the 1 MBit/s and 2 MBit/s
86 * rate to stay consistent with Zydas and our use of the term.
87 *
88 * Notify that these values are *not* used in the zd-rates.
89 */
90#define ZD_CCK_PLCP_SIGNAL_1M 0x0a
91#define ZD_CCK_PLCP_SIGNAL_2M 0x14
92#define ZD_CCK_PLCP_SIGNAL_5M5 0x37
93#define ZD_CCK_PLCP_SIGNAL_11M 0x6e
94
95#endif /* _ZD_IEEE80211_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index e019102b2285..a3da014f928d 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -3,7 +3,7 @@
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> 3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> 4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
5 * Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net> 5 * Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net>
6 * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu> 6 * Copyright (C) 2007-2008 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -29,9 +29,23 @@
29#include "zd_def.h" 29#include "zd_def.h"
30#include "zd_chip.h" 30#include "zd_chip.h"
31#include "zd_mac.h" 31#include "zd_mac.h"
32#include "zd_ieee80211.h"
33#include "zd_rf.h" 32#include "zd_rf.h"
34 33
34struct zd_reg_alpha2_map {
35 u32 reg;
36 char alpha2[2];
37};
38
39static struct zd_reg_alpha2_map reg_alpha2_map[] = {
40 { ZD_REGDOMAIN_FCC, "US" },
41 { ZD_REGDOMAIN_IC, "CA" },
42 { ZD_REGDOMAIN_ETSI, "DE" }, /* Generic ETSI, use most restrictive */
43 { ZD_REGDOMAIN_JAPAN, "JP" },
44 { ZD_REGDOMAIN_JAPAN_ADD, "JP" },
45 { ZD_REGDOMAIN_SPAIN, "ES" },
46 { ZD_REGDOMAIN_FRANCE, "FR" },
47};
48
35/* This table contains the hardware specific values for the modulation rates. */ 49/* This table contains the hardware specific values for the modulation rates. */
36static const struct ieee80211_rate zd_rates[] = { 50static const struct ieee80211_rate zd_rates[] = {
37 { .bitrate = 10, 51 { .bitrate = 10,
@@ -95,6 +109,21 @@ static void housekeeping_init(struct zd_mac *mac);
95static void housekeeping_enable(struct zd_mac *mac); 109static void housekeeping_enable(struct zd_mac *mac);
96static void housekeeping_disable(struct zd_mac *mac); 110static void housekeeping_disable(struct zd_mac *mac);
97 111
112static int zd_reg2alpha2(u8 regdomain, char *alpha2)
113{
114 unsigned int i;
115 struct zd_reg_alpha2_map *reg_map;
116 for (i = 0; i < ARRAY_SIZE(reg_alpha2_map); i++) {
117 reg_map = &reg_alpha2_map[i];
118 if (regdomain == reg_map->reg) {
119 alpha2[0] = reg_map->alpha2[0];
120 alpha2[1] = reg_map->alpha2[1];
121 return 0;
122 }
123 }
124 return 1;
125}
126
98int zd_mac_preinit_hw(struct ieee80211_hw *hw) 127int zd_mac_preinit_hw(struct ieee80211_hw *hw)
99{ 128{
100 int r; 129 int r;
@@ -115,6 +144,7 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
115 int r; 144 int r;
116 struct zd_mac *mac = zd_hw_mac(hw); 145 struct zd_mac *mac = zd_hw_mac(hw);
117 struct zd_chip *chip = &mac->chip; 146 struct zd_chip *chip = &mac->chip;
147 char alpha2[2];
118 u8 default_regdomain; 148 u8 default_regdomain;
119 149
120 r = zd_chip_enable_int(chip); 150 r = zd_chip_enable_int(chip);
@@ -139,7 +169,9 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
139 if (r) 169 if (r)
140 goto disable_int; 170 goto disable_int;
141 171
142 zd_geo_init(hw, mac->regdomain); 172 r = zd_reg2alpha2(mac->regdomain, alpha2);
173 if (!r)
174 regulatory_hint(hw->wiphy, alpha2, NULL);
143 175
144 r = 0; 176 r = 0;
145disable_int: 177disable_int:
@@ -684,15 +716,15 @@ static int zd_op_add_interface(struct ieee80211_hw *hw,
684{ 716{
685 struct zd_mac *mac = zd_hw_mac(hw); 717 struct zd_mac *mac = zd_hw_mac(hw);
686 718
687 /* using IEEE80211_IF_TYPE_INVALID to indicate no mode selected */ 719 /* using NL80211_IFTYPE_UNSPECIFIED to indicate no mode selected */
688 if (mac->type != IEEE80211_IF_TYPE_INVALID) 720 if (mac->type != NL80211_IFTYPE_UNSPECIFIED)
689 return -EOPNOTSUPP; 721 return -EOPNOTSUPP;
690 722
691 switch (conf->type) { 723 switch (conf->type) {
692 case IEEE80211_IF_TYPE_MNTR: 724 case NL80211_IFTYPE_MONITOR:
693 case IEEE80211_IF_TYPE_MESH_POINT: 725 case NL80211_IFTYPE_MESH_POINT:
694 case IEEE80211_IF_TYPE_STA: 726 case NL80211_IFTYPE_STATION:
695 case IEEE80211_IF_TYPE_IBSS: 727 case NL80211_IFTYPE_ADHOC:
696 mac->type = conf->type; 728 mac->type = conf->type;
697 break; 729 break;
698 default: 730 default:
@@ -706,7 +738,7 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw,
706 struct ieee80211_if_init_conf *conf) 738 struct ieee80211_if_init_conf *conf)
707{ 739{
708 struct zd_mac *mac = zd_hw_mac(hw); 740 struct zd_mac *mac = zd_hw_mac(hw);
709 mac->type = IEEE80211_IF_TYPE_INVALID; 741 mac->type = NL80211_IFTYPE_UNSPECIFIED;
710 zd_set_beacon_interval(&mac->chip, 0); 742 zd_set_beacon_interval(&mac->chip, 0);
711 zd_write_mac_addr(&mac->chip, NULL); 743 zd_write_mac_addr(&mac->chip, NULL);
712} 744}
@@ -725,8 +757,8 @@ static int zd_op_config_interface(struct ieee80211_hw *hw,
725 int associated; 757 int associated;
726 int r; 758 int r;
727 759
728 if (mac->type == IEEE80211_IF_TYPE_MESH_POINT || 760 if (mac->type == NL80211_IFTYPE_MESH_POINT ||
729 mac->type == IEEE80211_IF_TYPE_IBSS) { 761 mac->type == NL80211_IFTYPE_ADHOC) {
730 associated = true; 762 associated = true;
731 if (conf->changed & IEEE80211_IFCC_BEACON) { 763 if (conf->changed & IEEE80211_IFCC_BEACON) {
732 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 764 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
@@ -753,7 +785,7 @@ static int zd_op_config_interface(struct ieee80211_hw *hw,
753 return 0; 785 return 0;
754} 786}
755 787
756void zd_process_intr(struct work_struct *work) 788static void zd_process_intr(struct work_struct *work)
757{ 789{
758 u16 int_status; 790 u16 int_status;
759 struct zd_mac *mac = container_of(work, struct zd_mac, process_intr); 791 struct zd_mac *mac = container_of(work, struct zd_mac, process_intr);
@@ -923,7 +955,7 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
923 spin_lock_init(&mac->lock); 955 spin_lock_init(&mac->lock);
924 mac->hw = hw; 956 mac->hw = hw;
925 957
926 mac->type = IEEE80211_IF_TYPE_INVALID; 958 mac->type = NL80211_IFTYPE_UNSPECIFIED;
927 959
928 memcpy(mac->channels, zd_channels, sizeof(zd_channels)); 960 memcpy(mac->channels, zd_channels, sizeof(zd_channels));
929 memcpy(mac->rates, zd_rates, sizeof(zd_rates)); 961 memcpy(mac->rates, zd_rates, sizeof(zd_rates));
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 18c1d56d3dd7..4c05d3ee4c37 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -25,7 +25,6 @@
25#include <net/mac80211.h> 25#include <net/mac80211.h>
26 26
27#include "zd_chip.h" 27#include "zd_chip.h"
28#include "zd_ieee80211.h"
29 28
30struct zd_ctrlset { 29struct zd_ctrlset {
31 u8 modulation; 30 u8 modulation;
@@ -187,6 +186,70 @@ struct zd_mac {
187 unsigned int pass_ctrl:1; 186 unsigned int pass_ctrl:1;
188}; 187};
189 188
189#define ZD_REGDOMAIN_FCC 0x10
190#define ZD_REGDOMAIN_IC 0x20
191#define ZD_REGDOMAIN_ETSI 0x30
192#define ZD_REGDOMAIN_SPAIN 0x31
193#define ZD_REGDOMAIN_FRANCE 0x32
194#define ZD_REGDOMAIN_JAPAN_ADD 0x40
195#define ZD_REGDOMAIN_JAPAN 0x41
196
197enum {
198 MIN_CHANNEL24 = 1,
199 MAX_CHANNEL24 = 14,
200};
201
202#define ZD_PLCP_SERVICE_LENGTH_EXTENSION 0x80
203
204struct ofdm_plcp_header {
205 u8 prefix[3];
206 __le16 service;
207} __attribute__((packed));
208
209static inline u8 zd_ofdm_plcp_header_rate(const struct ofdm_plcp_header *header)
210{
211 return header->prefix[0] & 0xf;
212}
213
214/* The following defines give the encoding of the 4-bit rate field in the
215 * OFDM (802.11a/802.11g) PLCP header. Notify that these values are used to
216 * define the zd-rate values for OFDM.
217 *
218 * See the struct zd_ctrlset definition in zd_mac.h.
219 */
220#define ZD_OFDM_PLCP_RATE_6M 0xb
221#define ZD_OFDM_PLCP_RATE_9M 0xf
222#define ZD_OFDM_PLCP_RATE_12M 0xa
223#define ZD_OFDM_PLCP_RATE_18M 0xe
224#define ZD_OFDM_PLCP_RATE_24M 0x9
225#define ZD_OFDM_PLCP_RATE_36M 0xd
226#define ZD_OFDM_PLCP_RATE_48M 0x8
227#define ZD_OFDM_PLCP_RATE_54M 0xc
228
229struct cck_plcp_header {
230 u8 signal;
231 u8 service;
232 __le16 length;
233 __le16 crc16;
234} __attribute__((packed));
235
236static inline u8 zd_cck_plcp_header_signal(const struct cck_plcp_header *header)
237{
238 return header->signal;
239}
240
241/* These defines give the encodings of the signal field in the 802.11b PLCP
242 * header. The signal field gives the bit rate of the following packet. Even
243 * if technically wrong we use CCK here also for the 1 MBit/s and 2 MBit/s
244 * rate to stay consistent with Zydas and our use of the term.
245 *
246 * Notify that these values are *not* used in the zd-rates.
247 */
248#define ZD_CCK_PLCP_SIGNAL_1M 0x0a
249#define ZD_CCK_PLCP_SIGNAL_2M 0x14
250#define ZD_CCK_PLCP_SIGNAL_5M5 0x37
251#define ZD_CCK_PLCP_SIGNAL_11M 0x6e
252
190static inline struct zd_mac *zd_hw_mac(struct ieee80211_hw *hw) 253static inline struct zd_mac *zd_hw_mac(struct ieee80211_hw *hw)
191{ 254{
192 return hw->priv; 255 return hw->priv;
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.c b/drivers/net/wireless/zd1211rw/zd_rf.c
index ec4129312813..7207bfd2e6cd 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf.c
@@ -23,7 +23,7 @@
23 23
24#include "zd_def.h" 24#include "zd_def.h"
25#include "zd_rf.h" 25#include "zd_rf.h"
26#include "zd_ieee80211.h" 26#include "zd_mac.h"
27#include "zd_chip.h" 27#include "zd_chip.h"
28 28
29static const char * const rfs[] = { 29static const char * const rfs[] = {