aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-12-08 16:44:44 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-08 16:44:44 -0500
commite61444d9209821469ed0d5a9128dcf2e494533ea (patch)
tree17b406ce83e925da011d2b463ddf278b821c365d
parenta252e749f1ae17e43ccc5824f7b1b5854417c98b (diff)
parent6a213afd058436dbbd01098d7422c6a0073c39b5 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c2
-rw-r--r--drivers/net/wireless/mwl8k.c327
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.c2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187.h5
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c12
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_rfkill.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c36
-rw-r--r--net/mac80211/ieee80211_i.h1
-rw-r--r--net/mac80211/mlme.c10
-rw-r--r--net/mac80211/scan.c20
-rw-r--r--net/mac80211/util.c2
-rw-r--r--net/rfkill/core.c4
14 files changed, 228 insertions, 201 deletions
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index d495890355d9..60f547503d75 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -79,6 +79,8 @@ static const struct pci_device_id ath5k_led_devices[] = {
79 { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) }, 79 { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) },
80 /* IBM-specific AR5212 (all others) */ 80 /* IBM-specific AR5212 (all others) */
81 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) }, 81 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) },
82 /* Dell Vostro A860 (shahar@shahar-or.co.il) */
83 { ATH_SDEVICE(PCI_VENDOR_ID_QMI, 0x0112), ATH_LED(3, 0) },
82 { } 84 { }
83}; 85};
84 86
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 564c6cb1c2b4..2a11cc57ceea 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2078,7 +2078,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
2078 &txq->axq_q, lastbf->list.prev); 2078 &txq->axq_q, lastbf->list.prev);
2079 2079
2080 txq->axq_depth--; 2080 txq->axq_depth--;
2081 txok = (ds->ds_txstat.ts_status == 0); 2081 txok = !(ds->ds_txstat.ts_status & ATH9K_TXERR_FILT);
2082 txq->axq_tx_inprogress = false; 2082 txq->axq_tx_inprogress = false;
2083 spin_unlock_bh(&txq->axq_lock); 2083 spin_unlock_bh(&txq->axq_lock);
2084 2084
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 58b132f9cf28..00da5e152d46 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -1353,7 +1353,7 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1353 if (priv->stations[sta_id].tid[tid].agg.state == 1353 if (priv->stations[sta_id].tid[tid].agg.state ==
1354 IWL_EMPTYING_HW_QUEUE_ADDBA) { 1354 IWL_EMPTYING_HW_QUEUE_ADDBA) {
1355 IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); 1355 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
1356 ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); 1356 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid);
1357 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1357 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1358 return 0; 1358 return 0;
1359 } 1359 }
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 0cb5ecc822a8..59d49159cf2a 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -84,7 +84,8 @@ struct rxd_ops {
84 int rxd_size; 84 int rxd_size;
85 void (*rxd_init)(void *rxd, dma_addr_t next_dma_addr); 85 void (*rxd_init)(void *rxd, dma_addr_t next_dma_addr);
86 void (*rxd_refill)(void *rxd, dma_addr_t addr, int len); 86 void (*rxd_refill)(void *rxd, dma_addr_t addr, int len);
87 int (*rxd_process)(void *rxd, struct ieee80211_rx_status *status); 87 int (*rxd_process)(void *rxd, struct ieee80211_rx_status *status,
88 __le16 *qos);
88}; 89};
89 90
90struct mwl8k_device_info { 91struct mwl8k_device_info {
@@ -184,7 +185,7 @@ struct mwl8k_priv {
184 /* PHY parameters */ 185 /* PHY parameters */
185 struct ieee80211_supported_band band; 186 struct ieee80211_supported_band band;
186 struct ieee80211_channel channels[14]; 187 struct ieee80211_channel channels[14];
187 struct ieee80211_rate rates[13]; 188 struct ieee80211_rate rates[14];
188 189
189 bool radio_on; 190 bool radio_on;
190 bool radio_short_preamble; 191 bool radio_short_preamble;
@@ -220,15 +221,6 @@ struct mwl8k_vif {
220 u8 bssid[ETH_ALEN]; 221 u8 bssid[ETH_ALEN];
221 u8 mac_addr[ETH_ALEN]; 222 u8 mac_addr[ETH_ALEN];
222 223
223 /*
224 * Subset of supported legacy rates.
225 * Intersection of AP and STA supported rates.
226 */
227 struct ieee80211_rate legacy_rates[13];
228
229 /* number of supported legacy rates */
230 u8 legacy_nrates;
231
232 /* Index into station database.Returned by update_sta_db call */ 224 /* Index into station database.Returned by update_sta_db call */
233 u8 peer_id; 225 u8 peer_id;
234 226
@@ -266,6 +258,11 @@ static const struct ieee80211_rate mwl8k_rates[] = {
266 { .bitrate = 360, .hw_value = 72, }, 258 { .bitrate = 360, .hw_value = 72, },
267 { .bitrate = 480, .hw_value = 96, }, 259 { .bitrate = 480, .hw_value = 96, },
268 { .bitrate = 540, .hw_value = 108, }, 260 { .bitrate = 540, .hw_value = 108, },
261 { .bitrate = 720, .hw_value = 144, },
262};
263
264static const u8 mwl8k_rateids[12] = {
265 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108,
269}; 266};
270 267
271/* Set or get info from Firmware */ 268/* Set or get info from Firmware */
@@ -574,7 +571,7 @@ static int mwl8k_load_firmware(struct ieee80211_hw *hw)
574 "helper image\n", pci_name(priv->pdev)); 571 "helper image\n", pci_name(priv->pdev));
575 return rc; 572 return rc;
576 } 573 }
577 msleep(1); 574 msleep(5);
578 575
579 rc = mwl8k_feed_fw_image(priv, fw->data, fw->size); 576 rc = mwl8k_feed_fw_image(priv, fw->data, fw->size);
580 } else { 577 } else {
@@ -591,9 +588,8 @@ static int mwl8k_load_firmware(struct ieee80211_hw *hw)
591 iowrite32(MWL8K_MODE_AP, priv->regs + MWL8K_HIU_GEN_PTR); 588 iowrite32(MWL8K_MODE_AP, priv->regs + MWL8K_HIU_GEN_PTR);
592 else 589 else
593 iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR); 590 iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR);
594 msleep(1);
595 591
596 loops = 200000; 592 loops = 500000;
597 do { 593 do {
598 u32 ready_code; 594 u32 ready_code;
599 595
@@ -633,9 +629,6 @@ struct ewc_ht_info {
633/* Peer Entry flags - used to define the type of the peer node */ 629/* Peer Entry flags - used to define the type of the peer node */
634#define MWL8K_PEER_TYPE_ACCESSPOINT 2 630#define MWL8K_PEER_TYPE_ACCESSPOINT 2
635 631
636#define MWL8K_IEEE_LEGACY_DATA_RATES 13
637#define MWL8K_MCS_BITMAP_SIZE 16
638
639struct peer_capability_info { 632struct peer_capability_info {
640 /* Peer type - AP vs. STA. */ 633 /* Peer type - AP vs. STA. */
641 __u8 peer_type; 634 __u8 peer_type;
@@ -652,10 +645,10 @@ struct peer_capability_info {
652 struct ewc_ht_info ewc_info; 645 struct ewc_ht_info ewc_info;
653 646
654 /* Legacy rate table. Intersection of our rates and peer rates. */ 647 /* Legacy rate table. Intersection of our rates and peer rates. */
655 __u8 legacy_rates[MWL8K_IEEE_LEGACY_DATA_RATES]; 648 __u8 legacy_rates[12];
656 649
657 /* HT rate table. Intersection of our rates and peer rates. */ 650 /* HT rate table. Intersection of our rates and peer rates. */
658 __u8 ht_rates[MWL8K_MCS_BITMAP_SIZE]; 651 __u8 ht_rates[16];
659 __u8 pad[16]; 652 __u8 pad[16];
660 653
661 /* If set, interoperability mode, no proprietary extensions. */ 654 /* If set, interoperability mode, no proprietary extensions. */
@@ -706,55 +699,64 @@ static inline u16 mwl8k_qos_setbit_qlen(u16 qos, u8 len)
706struct mwl8k_dma_data { 699struct mwl8k_dma_data {
707 __le16 fwlen; 700 __le16 fwlen;
708 struct ieee80211_hdr wh; 701 struct ieee80211_hdr wh;
702 char data[0];
709} __attribute__((packed)); 703} __attribute__((packed));
710 704
711/* Routines to add/remove DMA header from skb. */ 705/* Routines to add/remove DMA header from skb. */
712static inline void mwl8k_remove_dma_header(struct sk_buff *skb) 706static inline void mwl8k_remove_dma_header(struct sk_buff *skb, __le16 qos)
713{ 707{
714 struct mwl8k_dma_data *tr = (struct mwl8k_dma_data *)skb->data; 708 struct mwl8k_dma_data *tr;
715 void *dst, *src = &tr->wh; 709 int hdrlen;
716 int hdrlen = ieee80211_hdrlen(tr->wh.frame_control);
717 u16 space = sizeof(struct mwl8k_dma_data) - hdrlen;
718 710
719 dst = (void *)tr + space; 711 tr = (struct mwl8k_dma_data *)skb->data;
720 if (dst != src) { 712 hdrlen = ieee80211_hdrlen(tr->wh.frame_control);
721 memmove(dst, src, hdrlen); 713
722 skb_pull(skb, space); 714 if (hdrlen != sizeof(tr->wh)) {
715 if (ieee80211_is_data_qos(tr->wh.frame_control)) {
716 memmove(tr->data - hdrlen, &tr->wh, hdrlen - 2);
717 *((__le16 *)(tr->data - 2)) = qos;
718 } else {
719 memmove(tr->data - hdrlen, &tr->wh, hdrlen);
720 }
723 } 721 }
722
723 if (hdrlen != sizeof(*tr))
724 skb_pull(skb, sizeof(*tr) - hdrlen);
724} 725}
725 726
726static inline void mwl8k_add_dma_header(struct sk_buff *skb) 727static inline void mwl8k_add_dma_header(struct sk_buff *skb)
727{ 728{
728 struct ieee80211_hdr *wh; 729 struct ieee80211_hdr *wh;
729 u32 hdrlen, pktlen; 730 int hdrlen;
730 struct mwl8k_dma_data *tr; 731 struct mwl8k_dma_data *tr;
731 732
733 /*
734 * Add a firmware DMA header; the firmware requires that we
735 * present a 2-byte payload length followed by a 4-address
736 * header (without QoS field), followed (optionally) by any
737 * WEP/ExtIV header (but only filled in for CCMP).
738 */
732 wh = (struct ieee80211_hdr *)skb->data; 739 wh = (struct ieee80211_hdr *)skb->data;
740
733 hdrlen = ieee80211_hdrlen(wh->frame_control); 741 hdrlen = ieee80211_hdrlen(wh->frame_control);
734 pktlen = skb->len; 742 if (hdrlen != sizeof(*tr))
743 skb_push(skb, sizeof(*tr) - hdrlen);
735 744
736 /* 745 if (ieee80211_is_data_qos(wh->frame_control))
737 * Copy up/down the 802.11 header; the firmware requires 746 hdrlen -= 2;
738 * we present a 2-byte payload length followed by a
739 * 4-address header (w/o QoS), followed (optionally) by
740 * any WEP/ExtIV header (but only filled in for CCMP).
741 */
742 if (hdrlen != sizeof(struct mwl8k_dma_data))
743 skb_push(skb, sizeof(struct mwl8k_dma_data) - hdrlen);
744 747
745 tr = (struct mwl8k_dma_data *)skb->data; 748 tr = (struct mwl8k_dma_data *)skb->data;
746 if (wh != &tr->wh) 749 if (wh != &tr->wh)
747 memmove(&tr->wh, wh, hdrlen); 750 memmove(&tr->wh, wh, hdrlen);
748 751 if (hdrlen != sizeof(tr->wh))
749 /* Clear addr4 */ 752 memset(((void *)&tr->wh) + hdrlen, 0, sizeof(tr->wh) - hdrlen);
750 memset(tr->wh.addr4, 0, ETH_ALEN);
751 753
752 /* 754 /*
753 * Firmware length is the length of the fully formed "802.11 755 * Firmware length is the length of the fully formed "802.11
754 * payload". That is, everything except for the 802.11 header. 756 * payload". That is, everything except for the 802.11 header.
755 * This includes all crypto material including the MIC. 757 * This includes all crypto material including the MIC.
756 */ 758 */
757 tr->fwlen = cpu_to_le16(pktlen - hdrlen); 759 tr->fwlen = cpu_to_le16(skb->len - sizeof(*tr));
758} 760}
759 761
760 762
@@ -779,6 +781,10 @@ struct mwl8k_rxd_8366 {
779 __u8 rx_ctrl; 781 __u8 rx_ctrl;
780} __attribute__((packed)); 782} __attribute__((packed));
781 783
784#define MWL8K_8366_RATE_INFO_MCS_FORMAT 0x80
785#define MWL8K_8366_RATE_INFO_40MHZ 0x40
786#define MWL8K_8366_RATE_INFO_RATEID(x) ((x) & 0x3f)
787
782#define MWL8K_8366_RX_CTRL_OWNED_BY_HOST 0x80 788#define MWL8K_8366_RX_CTRL_OWNED_BY_HOST 0x80
783 789
784static void mwl8k_rxd_8366_init(void *_rxd, dma_addr_t next_dma_addr) 790static void mwl8k_rxd_8366_init(void *_rxd, dma_addr_t next_dma_addr)
@@ -800,7 +806,8 @@ static void mwl8k_rxd_8366_refill(void *_rxd, dma_addr_t addr, int len)
800} 806}
801 807
802static int 808static int
803mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status) 809mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status,
810 __le16 *qos)
804{ 811{
805 struct mwl8k_rxd_8366 *rxd = _rxd; 812 struct mwl8k_rxd_8366 *rxd = _rxd;
806 813
@@ -813,9 +820,11 @@ mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status)
813 status->signal = -rxd->rssi; 820 status->signal = -rxd->rssi;
814 status->noise = -rxd->noise_floor; 821 status->noise = -rxd->noise_floor;
815 822
816 if (rxd->rate & 0x80) { 823 if (rxd->rate & MWL8K_8366_RATE_INFO_MCS_FORMAT) {
817 status->flag |= RX_FLAG_HT; 824 status->flag |= RX_FLAG_HT;
818 status->rate_idx = rxd->rate & 0x7f; 825 if (rxd->rate & MWL8K_8366_RATE_INFO_40MHZ)
826 status->flag |= RX_FLAG_40MHZ;
827 status->rate_idx = MWL8K_8366_RATE_INFO_RATEID(rxd->rate);
819 } else { 828 } else {
820 int i; 829 int i;
821 830
@@ -830,6 +839,8 @@ mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status)
830 status->band = IEEE80211_BAND_2GHZ; 839 status->band = IEEE80211_BAND_2GHZ;
831 status->freq = ieee80211_channel_to_frequency(rxd->channel); 840 status->freq = ieee80211_channel_to_frequency(rxd->channel);
832 841
842 *qos = rxd->qos_control;
843
833 return le16_to_cpu(rxd->pkt_len); 844 return le16_to_cpu(rxd->pkt_len);
834} 845}
835 846
@@ -888,7 +899,8 @@ static void mwl8k_rxd_8687_refill(void *_rxd, dma_addr_t addr, int len)
888} 899}
889 900
890static int 901static int
891mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status) 902mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status,
903 __le16 *qos)
892{ 904{
893 struct mwl8k_rxd_8687 *rxd = _rxd; 905 struct mwl8k_rxd_8687 *rxd = _rxd;
894 u16 rate_info; 906 u16 rate_info;
@@ -903,7 +915,6 @@ mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status)
903 915
904 status->signal = -rxd->rssi; 916 status->signal = -rxd->rssi;
905 status->noise = -rxd->noise_level; 917 status->noise = -rxd->noise_level;
906 status->qual = rxd->link_quality;
907 status->antenna = MWL8K_8687_RATE_INFO_ANTSELECT(rate_info); 918 status->antenna = MWL8K_8687_RATE_INFO_ANTSELECT(rate_info);
908 status->rate_idx = MWL8K_8687_RATE_INFO_RATEID(rate_info); 919 status->rate_idx = MWL8K_8687_RATE_INFO_RATEID(rate_info);
909 920
@@ -919,6 +930,8 @@ mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status)
919 status->band = IEEE80211_BAND_2GHZ; 930 status->band = IEEE80211_BAND_2GHZ;
920 status->freq = ieee80211_channel_to_frequency(rxd->channel); 931 status->freq = ieee80211_channel_to_frequency(rxd->channel);
921 932
933 *qos = rxd->qos_control;
934
922 return le16_to_cpu(rxd->pkt_len); 935 return le16_to_cpu(rxd->pkt_len);
923} 936}
924 937
@@ -1090,6 +1103,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1090 void *rxd; 1103 void *rxd;
1091 int pkt_len; 1104 int pkt_len;
1092 struct ieee80211_rx_status status; 1105 struct ieee80211_rx_status status;
1106 __le16 qos;
1093 1107
1094 skb = rxq->buf[rxq->head].skb; 1108 skb = rxq->buf[rxq->head].skb;
1095 if (skb == NULL) 1109 if (skb == NULL)
@@ -1097,7 +1111,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1097 1111
1098 rxd = rxq->rxd + (rxq->head * priv->rxd_ops->rxd_size); 1112 rxd = rxq->rxd + (rxq->head * priv->rxd_ops->rxd_size);
1099 1113
1100 pkt_len = priv->rxd_ops->rxd_process(rxd, &status); 1114 pkt_len = priv->rxd_ops->rxd_process(rxd, &status, &qos);
1101 if (pkt_len < 0) 1115 if (pkt_len < 0)
1102 break; 1116 break;
1103 1117
@@ -1115,7 +1129,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1115 rxq->rxd_count--; 1129 rxq->rxd_count--;
1116 1130
1117 skb_put(skb, pkt_len); 1131 skb_put(skb, pkt_len);
1118 mwl8k_remove_dma_header(skb); 1132 mwl8k_remove_dma_header(skb, qos);
1119 1133
1120 /* 1134 /*
1121 * Check for a pending join operation. Save a 1135 * Check for a pending join operation. Save a
@@ -1221,99 +1235,106 @@ static inline void mwl8k_tx_start(struct mwl8k_priv *priv)
1221 ioread32(priv->regs + MWL8K_HIU_INT_CODE); 1235 ioread32(priv->regs + MWL8K_HIU_INT_CODE);
1222} 1236}
1223 1237
1224struct mwl8k_txq_info { 1238static void mwl8k_dump_tx_rings(struct ieee80211_hw *hw)
1225 u32 fw_owned;
1226 u32 drv_owned;
1227 u32 unused;
1228 u32 len;
1229 u32 head;
1230 u32 tail;
1231};
1232
1233static int mwl8k_scan_tx_ring(struct mwl8k_priv *priv,
1234 struct mwl8k_txq_info *txinfo)
1235{ 1239{
1236 int count, desc, status; 1240 struct mwl8k_priv *priv = hw->priv;
1237 struct mwl8k_tx_queue *txq; 1241 int i;
1238 struct mwl8k_tx_desc *tx_desc;
1239 int ndescs = 0;
1240 1242
1241 memset(txinfo, 0, MWL8K_TX_QUEUES * sizeof(struct mwl8k_txq_info)); 1243 for (i = 0; i < MWL8K_TX_QUEUES; i++) {
1244 struct mwl8k_tx_queue *txq = priv->txq + i;
1245 int fw_owned = 0;
1246 int drv_owned = 0;
1247 int unused = 0;
1248 int desc;
1242 1249
1243 for (count = 0; count < MWL8K_TX_QUEUES; count++) {
1244 txq = priv->txq + count;
1245 txinfo[count].len = txq->stats.len;
1246 txinfo[count].head = txq->head;
1247 txinfo[count].tail = txq->tail;
1248 for (desc = 0; desc < MWL8K_TX_DESCS; desc++) { 1250 for (desc = 0; desc < MWL8K_TX_DESCS; desc++) {
1249 tx_desc = txq->txd + desc; 1251 struct mwl8k_tx_desc *tx_desc = txq->txd + desc;
1250 status = le32_to_cpu(tx_desc->status); 1252 u32 status;
1251 1253
1254 status = le32_to_cpu(tx_desc->status);
1252 if (status & MWL8K_TXD_STATUS_FW_OWNED) 1255 if (status & MWL8K_TXD_STATUS_FW_OWNED)
1253 txinfo[count].fw_owned++; 1256 fw_owned++;
1254 else 1257 else
1255 txinfo[count].drv_owned++; 1258 drv_owned++;
1256 1259
1257 if (tx_desc->pkt_len == 0) 1260 if (tx_desc->pkt_len == 0)
1258 txinfo[count].unused++; 1261 unused++;
1259 } 1262 }
1260 }
1261 1263
1262 return ndescs; 1264 printk(KERN_ERR "%s: txq[%d] len=%d head=%d tail=%d "
1265 "fw_owned=%d drv_owned=%d unused=%d\n",
1266 wiphy_name(hw->wiphy), i,
1267 txq->stats.len, txq->head, txq->tail,
1268 fw_owned, drv_owned, unused);
1269 }
1263} 1270}
1264 1271
1265/* 1272/*
1266 * Must be called with priv->fw_mutex held and tx queues stopped. 1273 * Must be called with priv->fw_mutex held and tx queues stopped.
1267 */ 1274 */
1275#define MWL8K_TX_WAIT_TIMEOUT_MS 1000
1276
1268static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw) 1277static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw)
1269{ 1278{
1270 struct mwl8k_priv *priv = hw->priv; 1279 struct mwl8k_priv *priv = hw->priv;
1271 DECLARE_COMPLETION_ONSTACK(tx_wait); 1280 DECLARE_COMPLETION_ONSTACK(tx_wait);
1272 u32 count; 1281 int retry;
1273 unsigned long timeout; 1282 int rc;
1274 1283
1275 might_sleep(); 1284 might_sleep();
1276 1285
1286 /*
1287 * The TX queues are stopped at this point, so this test
1288 * doesn't need to take ->tx_lock.
1289 */
1290 if (!priv->pending_tx_pkts)
1291 return 0;
1292
1293 retry = 0;
1294 rc = 0;
1295
1277 spin_lock_bh(&priv->tx_lock); 1296 spin_lock_bh(&priv->tx_lock);
1278 count = priv->pending_tx_pkts; 1297 priv->tx_wait = &tx_wait;
1279 if (count) 1298 while (!rc) {
1280 priv->tx_wait = &tx_wait; 1299 int oldcount;
1281 spin_unlock_bh(&priv->tx_lock); 1300 unsigned long timeout;
1282 1301
1283 if (count) { 1302 oldcount = priv->pending_tx_pkts;
1284 struct mwl8k_txq_info txinfo[MWL8K_TX_QUEUES];
1285 int index;
1286 int newcount;
1287 1303
1304 spin_unlock_bh(&priv->tx_lock);
1288 timeout = wait_for_completion_timeout(&tx_wait, 1305 timeout = wait_for_completion_timeout(&tx_wait,
1289 msecs_to_jiffies(5000)); 1306 msecs_to_jiffies(MWL8K_TX_WAIT_TIMEOUT_MS));
1290 if (timeout)
1291 return 0;
1292
1293 spin_lock_bh(&priv->tx_lock); 1307 spin_lock_bh(&priv->tx_lock);
1294 priv->tx_wait = NULL;
1295 newcount = priv->pending_tx_pkts;
1296 mwl8k_scan_tx_ring(priv, txinfo);
1297 spin_unlock_bh(&priv->tx_lock);
1298 1308
1299 printk(KERN_ERR "%s(%u) TIMEDOUT:5000ms Pend:%u-->%u\n", 1309 if (timeout) {
1300 __func__, __LINE__, count, newcount); 1310 WARN_ON(priv->pending_tx_pkts);
1311 if (retry) {
1312 printk(KERN_NOTICE "%s: tx rings drained\n",
1313 wiphy_name(hw->wiphy));
1314 }
1315 break;
1316 }
1301 1317
1302 for (index = 0; index < MWL8K_TX_QUEUES; index++) 1318 if (priv->pending_tx_pkts < oldcount) {
1303 printk(KERN_ERR "TXQ:%u L:%u H:%u T:%u FW:%u " 1319 printk(KERN_NOTICE "%s: timeout waiting for tx "
1304 "DRV:%u U:%u\n", 1320 "rings to drain (%d -> %d pkts), retrying\n",
1305 index, 1321 wiphy_name(hw->wiphy), oldcount,
1306 txinfo[index].len, 1322 priv->pending_tx_pkts);
1307 txinfo[index].head, 1323 retry = 1;
1308 txinfo[index].tail, 1324 continue;
1309 txinfo[index].fw_owned, 1325 }
1310 txinfo[index].drv_owned,
1311 txinfo[index].unused);
1312 1326
1313 return -ETIMEDOUT; 1327 priv->tx_wait = NULL;
1328
1329 printk(KERN_ERR "%s: tx rings stuck for %d ms\n",
1330 wiphy_name(hw->wiphy), MWL8K_TX_WAIT_TIMEOUT_MS);
1331 mwl8k_dump_tx_rings(hw);
1332
1333 rc = -ETIMEDOUT;
1314 } 1334 }
1335 spin_unlock_bh(&priv->tx_lock);
1315 1336
1316 return 0; 1337 return rc;
1317} 1338}
1318 1339
1319#define MWL8K_TXD_SUCCESS(status) \ 1340#define MWL8K_TXD_SUCCESS(status) \
@@ -1361,7 +1382,7 @@ static void mwl8k_txq_reclaim(struct ieee80211_hw *hw, int index, int force)
1361 BUG_ON(skb == NULL); 1382 BUG_ON(skb == NULL);
1362 pci_unmap_single(priv->pdev, addr, size, PCI_DMA_TODEVICE); 1383 pci_unmap_single(priv->pdev, addr, size, PCI_DMA_TODEVICE);
1363 1384
1364 mwl8k_remove_dma_header(skb); 1385 mwl8k_remove_dma_header(skb, tx_desc->qos_control);
1365 1386
1366 /* Mark descriptor as unused */ 1387 /* Mark descriptor as unused */
1367 tx_desc->pkt_phys_addr = 0; 1388 tx_desc->pkt_phys_addr = 0;
@@ -1563,8 +1584,8 @@ static void mwl8k_fw_unlock(struct ieee80211_hw *hw)
1563 * Command processing. 1584 * Command processing.
1564 */ 1585 */
1565 1586
1566/* Timeout firmware commands after 2000ms */ 1587/* Timeout firmware commands after 10s */
1567#define MWL8K_CMD_TIMEOUT_MS 2000 1588#define MWL8K_CMD_TIMEOUT_MS 10000
1568 1589
1569static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd) 1590static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1570{ 1591{
@@ -1615,12 +1636,21 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1615 MWL8K_CMD_TIMEOUT_MS); 1636 MWL8K_CMD_TIMEOUT_MS);
1616 rc = -ETIMEDOUT; 1637 rc = -ETIMEDOUT;
1617 } else { 1638 } else {
1639 int ms;
1640
1641 ms = MWL8K_CMD_TIMEOUT_MS - jiffies_to_msecs(timeout);
1642
1618 rc = cmd->result ? -EINVAL : 0; 1643 rc = cmd->result ? -EINVAL : 0;
1619 if (rc) 1644 if (rc)
1620 printk(KERN_ERR "%s: Command %s error 0x%x\n", 1645 printk(KERN_ERR "%s: Command %s error 0x%x\n",
1621 wiphy_name(hw->wiphy), 1646 wiphy_name(hw->wiphy),
1622 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)), 1647 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1623 le16_to_cpu(cmd->result)); 1648 le16_to_cpu(cmd->result));
1649 else if (ms > 2000)
1650 printk(KERN_NOTICE "%s: Command %s took %d ms\n",
1651 wiphy_name(hw->wiphy),
1652 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1653 ms);
1624 } 1654 }
1625 1655
1626 return rc; 1656 return rc;
@@ -2439,8 +2469,6 @@ mwl8k_set_edca_params(struct ieee80211_hw *hw, __u8 qnum,
2439/* 2469/*
2440 * CMD_FINALIZE_JOIN. 2470 * CMD_FINALIZE_JOIN.
2441 */ 2471 */
2442
2443/* FJ beacon buffer size is compiled into the firmware. */
2444#define MWL8K_FJ_BEACON_MAXLEN 128 2472#define MWL8K_FJ_BEACON_MAXLEN 128
2445 2473
2446struct mwl8k_cmd_finalize_join { 2474struct mwl8k_cmd_finalize_join {
@@ -2450,17 +2478,13 @@ struct mwl8k_cmd_finalize_join {
2450} __attribute__((packed)); 2478} __attribute__((packed));
2451 2479
2452static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame, 2480static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame,
2453 __u16 framelen, __u16 dtim) 2481 int framelen, int dtim)
2454{ 2482{
2455 struct mwl8k_cmd_finalize_join *cmd; 2483 struct mwl8k_cmd_finalize_join *cmd;
2456 struct ieee80211_mgmt *payload = frame; 2484 struct ieee80211_mgmt *payload = frame;
2457 u16 hdrlen; 2485 int payload_len;
2458 u32 payload_len;
2459 int rc; 2486 int rc;
2460 2487
2461 if (frame == NULL)
2462 return -EINVAL;
2463
2464 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 2488 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2465 if (cmd == NULL) 2489 if (cmd == NULL)
2466 return -ENOMEM; 2490 return -ENOMEM;
@@ -2469,24 +2493,17 @@ static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame,
2469 cmd->header.length = cpu_to_le16(sizeof(*cmd)); 2493 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2470 cmd->sleep_interval = cpu_to_le32(dtim ? dtim : 1); 2494 cmd->sleep_interval = cpu_to_le32(dtim ? dtim : 1);
2471 2495
2472 hdrlen = ieee80211_hdrlen(payload->frame_control); 2496 payload_len = framelen - ieee80211_hdrlen(payload->frame_control);
2473 2497 if (payload_len < 0)
2474 payload_len = framelen > hdrlen ? framelen - hdrlen : 0; 2498 payload_len = 0;
2475 2499 else if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2476 /* XXX TBD Might just have to abort and return an error */
2477 if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2478 printk(KERN_ERR "%s(): WARNING: Incomplete beacon "
2479 "sent to firmware. Sz=%u MAX=%u\n", __func__,
2480 payload_len, MWL8K_FJ_BEACON_MAXLEN);
2481
2482 if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2483 payload_len = MWL8K_FJ_BEACON_MAXLEN; 2500 payload_len = MWL8K_FJ_BEACON_MAXLEN;
2484 2501
2485 if (payload && payload_len) 2502 memcpy(cmd->beacon_data, &payload->u.beacon, payload_len);
2486 memcpy(cmd->beacon_data, &payload->u.beacon, payload_len);
2487 2503
2488 rc = mwl8k_post_cmd(hw, &cmd->header); 2504 rc = mwl8k_post_cmd(hw, &cmd->header);
2489 kfree(cmd); 2505 kfree(cmd);
2506
2490 return rc; 2507 return rc;
2491} 2508}
2492 2509
@@ -2515,9 +2532,7 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2515 struct ieee80211_bss_conf *info = &mv_vif->bss_info; 2532 struct ieee80211_bss_conf *info = &mv_vif->bss_info;
2516 struct mwl8k_cmd_update_sta_db *cmd; 2533 struct mwl8k_cmd_update_sta_db *cmd;
2517 struct peer_capability_info *peer_info; 2534 struct peer_capability_info *peer_info;
2518 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2519 int rc; 2535 int rc;
2520 __u8 count, *rates;
2521 2536
2522 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 2537 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2523 if (cmd == NULL) 2538 if (cmd == NULL)
@@ -2536,13 +2551,11 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2536 /* Build peer_info block */ 2551 /* Build peer_info block */
2537 peer_info->peer_type = MWL8K_PEER_TYPE_ACCESSPOINT; 2552 peer_info->peer_type = MWL8K_PEER_TYPE_ACCESSPOINT;
2538 peer_info->basic_caps = cpu_to_le16(info->assoc_capability); 2553 peer_info->basic_caps = cpu_to_le16(info->assoc_capability);
2554 memcpy(peer_info->legacy_rates, mwl8k_rateids,
2555 sizeof(mwl8k_rateids));
2539 peer_info->interop = 1; 2556 peer_info->interop = 1;
2540 peer_info->amsdu_enabled = 0; 2557 peer_info->amsdu_enabled = 0;
2541 2558
2542 rates = peer_info->legacy_rates;
2543 for (count = 0; count < mv_vif->legacy_nrates; count++)
2544 rates[count] = bitrates[count].hw_value;
2545
2546 rc = mwl8k_post_cmd(hw, &cmd->header); 2559 rc = mwl8k_post_cmd(hw, &cmd->header);
2547 if (rc == 0) 2560 if (rc == 0)
2548 mv_vif->peer_id = peer_info->station_id; 2561 mv_vif->peer_id = peer_info->station_id;
@@ -2565,8 +2578,6 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2565/* 2578/*
2566 * CMD_SET_AID. 2579 * CMD_SET_AID.
2567 */ 2580 */
2568#define MWL8K_RATE_INDEX_MAX_ARRAY 14
2569
2570#define MWL8K_FRAME_PROT_DISABLED 0x00 2581#define MWL8K_FRAME_PROT_DISABLED 0x00
2571#define MWL8K_FRAME_PROT_11G 0x07 2582#define MWL8K_FRAME_PROT_11G 0x07
2572#define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02 2583#define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02
@@ -2579,7 +2590,7 @@ struct mwl8k_cmd_update_set_aid {
2579 /* AP's MAC address (BSSID) */ 2590 /* AP's MAC address (BSSID) */
2580 __u8 bssid[ETH_ALEN]; 2591 __u8 bssid[ETH_ALEN];
2581 __le16 protection_mode; 2592 __le16 protection_mode;
2582 __u8 supp_rates[MWL8K_RATE_INDEX_MAX_ARRAY]; 2593 __u8 supp_rates[14];
2583} __attribute__((packed)); 2594} __attribute__((packed));
2584 2595
2585static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw, 2596static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
@@ -2588,8 +2599,6 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2588 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif); 2599 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2589 struct ieee80211_bss_conf *info = &mv_vif->bss_info; 2600 struct ieee80211_bss_conf *info = &mv_vif->bss_info;
2590 struct mwl8k_cmd_update_set_aid *cmd; 2601 struct mwl8k_cmd_update_set_aid *cmd;
2591 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2592 int count;
2593 u16 prot_mode; 2602 u16 prot_mode;
2594 int rc; 2603 int rc;
2595 2604
@@ -2621,8 +2630,7 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2621 } 2630 }
2622 cmd->protection_mode = cpu_to_le16(prot_mode); 2631 cmd->protection_mode = cpu_to_le16(prot_mode);
2623 2632
2624 for (count = 0; count < mv_vif->legacy_nrates; count++) 2633 memcpy(cmd->supp_rates, mwl8k_rateids, sizeof(mwl8k_rateids));
2625 cmd->supp_rates[count] = bitrates[count].hw_value;
2626 2634
2627 rc = mwl8k_post_cmd(hw, &cmd->header); 2635 rc = mwl8k_post_cmd(hw, &cmd->header);
2628 kfree(cmd); 2636 kfree(cmd);
@@ -2635,20 +2643,17 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2635 */ 2643 */
2636struct mwl8k_cmd_update_rateset { 2644struct mwl8k_cmd_update_rateset {
2637 struct mwl8k_cmd_pkt header; 2645 struct mwl8k_cmd_pkt header;
2638 __u8 legacy_rates[MWL8K_RATE_INDEX_MAX_ARRAY]; 2646 __u8 legacy_rates[14];
2639 2647
2640 /* Bitmap for supported MCS codes. */ 2648 /* Bitmap for supported MCS codes. */
2641 __u8 mcs_set[MWL8K_IEEE_LEGACY_DATA_RATES]; 2649 __u8 mcs_set[16];
2642 __u8 reserved[MWL8K_IEEE_LEGACY_DATA_RATES]; 2650 __u8 reserved[16];
2643} __attribute__((packed)); 2651} __attribute__((packed));
2644 2652
2645static int mwl8k_update_rateset(struct ieee80211_hw *hw, 2653static int mwl8k_update_rateset(struct ieee80211_hw *hw,
2646 struct ieee80211_vif *vif) 2654 struct ieee80211_vif *vif)
2647{ 2655{
2648 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2649 struct mwl8k_cmd_update_rateset *cmd; 2656 struct mwl8k_cmd_update_rateset *cmd;
2650 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2651 int count;
2652 int rc; 2657 int rc;
2653 2658
2654 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 2659 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
@@ -2657,9 +2662,7 @@ static int mwl8k_update_rateset(struct ieee80211_hw *hw,
2657 2662
2658 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RATE); 2663 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RATE);
2659 cmd->header.length = cpu_to_le16(sizeof(*cmd)); 2664 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2660 2665 memcpy(cmd->legacy_rates, mwl8k_rateids, sizeof(mwl8k_rateids));
2661 for (count = 0; count < mv_vif->legacy_nrates; count++)
2662 cmd->legacy_rates[count] = bitrates[count].hw_value;
2663 2666
2664 rc = mwl8k_post_cmd(hw, &cmd->header); 2667 rc = mwl8k_post_cmd(hw, &cmd->header);
2665 kfree(cmd); 2668 kfree(cmd);
@@ -2932,11 +2935,6 @@ static int mwl8k_add_interface(struct ieee80211_hw *hw,
2932 /* Back pointer to parent config block */ 2935 /* Back pointer to parent config block */
2933 mwl8k_vif->priv = priv; 2936 mwl8k_vif->priv = priv;
2934 2937
2935 /* Setup initial PHY parameters */
2936 memcpy(mwl8k_vif->legacy_rates,
2937 priv->rates, sizeof(mwl8k_vif->legacy_rates));
2938 mwl8k_vif->legacy_nrates = ARRAY_SIZE(priv->rates);
2939
2940 /* Set Initial sequence number to zero */ 2938 /* Set Initial sequence number to zero */
2941 mwl8k_vif->seqno = 0; 2939 mwl8k_vif->seqno = 0;
2942 2940
@@ -3014,9 +3012,6 @@ static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
3014 struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif); 3012 struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif);
3015 int rc; 3013 int rc;
3016 3014
3017 if (changed & BSS_CHANGED_BSSID)
3018 memcpy(mwl8k_vif->bssid, info->bssid, ETH_ALEN);
3019
3020 if ((changed & BSS_CHANGED_ASSOC) == 0) 3015 if ((changed & BSS_CHANGED_ASSOC) == 0)
3021 return; 3016 return;
3022 3017
@@ -3030,6 +3025,8 @@ static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
3030 memcpy(&mwl8k_vif->bss_info, info, 3025 memcpy(&mwl8k_vif->bss_info, info,
3031 sizeof(struct ieee80211_bss_conf)); 3026 sizeof(struct ieee80211_bss_conf));
3032 3027
3028 memcpy(mwl8k_vif->bssid, info->bssid, ETH_ALEN);
3029
3033 /* Install rates */ 3030 /* Install rates */
3034 rc = mwl8k_update_rateset(hw, vif); 3031 rc = mwl8k_update_rateset(hw, vif);
3035 if (rc) 3032 if (rc)
@@ -3366,7 +3363,7 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
3366 if (rc) { 3363 if (rc) {
3367 printk(KERN_ERR "%s: Cannot obtain PCI resources\n", 3364 printk(KERN_ERR "%s: Cannot obtain PCI resources\n",
3368 MWL8K_NAME); 3365 MWL8K_NAME);
3369 return rc; 3366 goto err_disable_device;
3370 } 3367 }
3371 3368
3372 pci_set_master(pdev); 3369 pci_set_master(pdev);
@@ -3597,6 +3594,8 @@ err_iounmap:
3597 3594
3598err_free_reg: 3595err_free_reg:
3599 pci_release_regions(pdev); 3596 pci_release_regions(pdev);
3597
3598err_disable_device:
3600 pci_disable_device(pdev); 3599 pci_disable_device(pdev);
3601 3600
3602 return rc; 3601 return rc;
diff --git a/drivers/net/wireless/orinoco/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c
index a3eefe109df4..6d5660defd87 100644
--- a/drivers/net/wireless/orinoco/hermes_dld.c
+++ b/drivers/net/wireless/orinoco/hermes_dld.c
@@ -427,7 +427,7 @@ int hermesi_program_init(hermes_t *hw, u32 offset)
427 if (err) 427 if (err)
428 return err; 428 return err;
429 429
430 pr_debug(KERN_DEBUG PFX "Enabling volatile, EP 0x%08x\n", offset); 430 pr_debug(PFX "Enabling volatile, EP 0x%08x\n", offset);
431 err = hermes_doicmd_wait(hw, 431 err = hermes_doicmd_wait(hw,
432 HERMES_PROGRAM_ENABLE_VOLATILE, 432 HERMES_PROGRAM_ENABLE_VOLATILE,
433 offset & 0xFFFFu, 433 offset & 0xFFFFu,
diff --git a/drivers/net/wireless/rtl818x/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187.h
index abb4907cf296..b1a24de0b7b0 100644
--- a/drivers/net/wireless/rtl818x/rtl8187.h
+++ b/drivers/net/wireless/rtl818x/rtl8187.h
@@ -23,6 +23,7 @@
23#define RTL8187_EEPROM_TXPWR_CHAN_1 0x16 /* 3 channels */ 23#define RTL8187_EEPROM_TXPWR_CHAN_1 0x16 /* 3 channels */
24#define RTL8187_EEPROM_TXPWR_CHAN_6 0x1B /* 2 channels */ 24#define RTL8187_EEPROM_TXPWR_CHAN_6 0x1B /* 2 channels */
25#define RTL8187_EEPROM_TXPWR_CHAN_4 0x3D /* 2 channels */ 25#define RTL8187_EEPROM_TXPWR_CHAN_4 0x3D /* 2 channels */
26#define RTL8187_EEPROM_SELECT_GPIO 0x3B
26 27
27#define RTL8187_REQT_READ 0xC0 28#define RTL8187_REQT_READ 0xC0
28#define RTL8187_REQT_WRITE 0x40 29#define RTL8187_REQT_WRITE 0x40
@@ -31,6 +32,9 @@
31 32
32#define RTL8187_MAX_RX 0x9C4 33#define RTL8187_MAX_RX 0x9C4
33 34
35#define RFKILL_MASK_8187_89_97 0x2
36#define RFKILL_MASK_8198 0x4
37
34struct rtl8187_rx_info { 38struct rtl8187_rx_info {
35 struct urb *urb; 39 struct urb *urb;
36 struct ieee80211_hw *dev; 40 struct ieee80211_hw *dev;
@@ -122,6 +126,7 @@ struct rtl8187_priv {
122 u8 noise; 126 u8 noise;
123 u8 slot_time; 127 u8 slot_time;
124 u8 aifsn[4]; 128 u8 aifsn[4];
129 u8 rfkill_mask;
125 struct { 130 struct {
126 __le64 buf; 131 __le64 buf;
127 struct sk_buff_head queue; 132 struct sk_buff_head queue;
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 76973b8c7099..bc5726dd5fe4 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -1322,6 +1322,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1322 struct ieee80211_channel *channel; 1322 struct ieee80211_channel *channel;
1323 const char *chip_name; 1323 const char *chip_name;
1324 u16 txpwr, reg; 1324 u16 txpwr, reg;
1325 u16 product_id = le16_to_cpu(udev->descriptor.idProduct);
1325 int err, i; 1326 int err, i;
1326 1327
1327 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops); 1328 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops);
@@ -1481,6 +1482,13 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1481 (*channel++).hw_value = txpwr & 0xFF; 1482 (*channel++).hw_value = txpwr & 0xFF;
1482 (*channel++).hw_value = txpwr >> 8; 1483 (*channel++).hw_value = txpwr >> 8;
1483 } 1484 }
1485 /* Handle the differing rfkill GPIO bit in different models */
1486 priv->rfkill_mask = RFKILL_MASK_8187_89_97;
1487 if (product_id == 0x8197 || product_id == 0x8198) {
1488 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_SELECT_GPIO, &reg);
1489 if (reg & 0xFF00)
1490 priv->rfkill_mask = RFKILL_MASK_8198;
1491 }
1484 1492
1485 /* 1493 /*
1486 * XXX: Once this driver supports anything that requires 1494 * XXX: Once this driver supports anything that requires
@@ -1509,9 +1517,9 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1509 mutex_init(&priv->conf_mutex); 1517 mutex_init(&priv->conf_mutex);
1510 skb_queue_head_init(&priv->b_tx_status.queue); 1518 skb_queue_head_init(&priv->b_tx_status.queue);
1511 1519
1512 printk(KERN_INFO "%s: hwaddr %pM, %s V%d + %s\n", 1520 printk(KERN_INFO "%s: hwaddr %pM, %s V%d + %s, rfkill mask %d\n",
1513 wiphy_name(dev->wiphy), dev->wiphy->perm_addr, 1521 wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
1514 chip_name, priv->asic_rev, priv->rf->name); 1522 chip_name, priv->asic_rev, priv->rf->name, priv->rfkill_mask);
1515 1523
1516#ifdef CONFIG_RTL8187_LEDS 1524#ifdef CONFIG_RTL8187_LEDS
1517 eeprom_93cx6_read(&eeprom, 0x3F, &reg); 1525 eeprom_93cx6_read(&eeprom, 0x3F, &reg);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rfkill.c b/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
index cad8037ab2af..03555e1e0cab 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
@@ -25,10 +25,10 @@ static bool rtl8187_is_radio_enabled(struct rtl8187_priv *priv)
25 u8 gpio; 25 u8 gpio;
26 26
27 gpio = rtl818x_ioread8(priv, &priv->map->GPIO0); 27 gpio = rtl818x_ioread8(priv, &priv->map->GPIO0);
28 rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~0x02); 28 rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~priv->rfkill_mask);
29 gpio = rtl818x_ioread8(priv, &priv->map->GPIO1); 29 gpio = rtl818x_ioread8(priv, &priv->map->GPIO1);
30 30
31 return gpio & 0x02; 31 return gpio & priv->rfkill_mask;
32} 32}
33 33
34void rtl8187_rfkill_init(struct ieee80211_hw *hw) 34void rtl8187_rfkill_init(struct ieee80211_hw *hw)
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index ff4be7bf5d36..2f50a256efa5 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -629,10 +629,6 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
629 goto out_sleep; 629 goto out_sleep;
630 } 630 }
631 631
632 ret = wl1251_build_null_data(wl);
633 if (ret < 0)
634 goto out_sleep;
635
636 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { 632 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
637 wl1251_debug(DEBUG_PSM, "psm enabled"); 633 wl1251_debug(DEBUG_PSM, "psm enabled");
638 634
@@ -1110,6 +1106,21 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
1110 if (ret < 0) 1106 if (ret < 0)
1111 goto out; 1107 goto out;
1112 1108
1109 if (changed & BSS_CHANGED_BSSID) {
1110 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1111
1112 ret = wl1251_build_null_data(wl);
1113 if (ret < 0)
1114 goto out;
1115
1116 if (wl->bss_type != BSS_TYPE_IBSS) {
1117 ret = wl1251_join(wl, wl->bss_type, wl->channel,
1118 wl->beacon_int, wl->dtim_period);
1119 if (ret < 0)
1120 goto out_sleep;
1121 }
1122 }
1123
1113 if (changed & BSS_CHANGED_ASSOC) { 1124 if (changed & BSS_CHANGED_ASSOC) {
1114 if (bss_conf->assoc) { 1125 if (bss_conf->assoc) {
1115 wl->beacon_int = bss_conf->beacon_int; 1126 wl->beacon_int = bss_conf->beacon_int;
@@ -1169,23 +1180,6 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
1169 } 1180 }
1170 } 1181 }
1171 1182
1172 if (changed & BSS_CHANGED_BSSID) {
1173 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1174
1175 ret = wl1251_build_null_data(wl);
1176 if (ret < 0)
1177 goto out;
1178
1179 if (wl->bss_type != BSS_TYPE_IBSS) {
1180 ret = wl1251_join(wl, wl->bss_type, wl->channel,
1181 wl->beacon_int, wl->dtim_period);
1182 if (ret < 0)
1183 goto out_sleep;
1184 wl1251_warning("Set ctsprotect failed %d", ret);
1185 goto out_sleep;
1186 }
1187 }
1188
1189 if (changed & BSS_CHANGED_BEACON) { 1183 if (changed & BSS_CHANGED_BEACON) {
1190 beacon = ieee80211_beacon_get(hw, vif); 1184 beacon = ieee80211_beacon_get(hw, vif);
1191 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data, 1185 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data,
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 419f186cfcf0..91dc8636d644 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -746,6 +746,7 @@ struct ieee80211_local {
746 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 746 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
747 747
748 bool pspolling; 748 bool pspolling;
749 bool scan_ps_enabled;
749 /* 750 /*
750 * PS can only be enabled when we have exactly one managed 751 * PS can only be enabled when we have exactly one managed
751 * interface (and monitors) in PS, this then points there. 752 * interface (and monitors) in PS, this then points there.
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 6dc7b5ad9a41..d8d50fb5e823 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1083,8 +1083,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1083 1083
1084 ieee80211_set_wmm_default(sdata); 1084 ieee80211_set_wmm_default(sdata);
1085 1085
1086 ieee80211_recalc_idle(local);
1087
1088 /* channel(_type) changes are handled by ieee80211_hw_config */ 1086 /* channel(_type) changes are handled by ieee80211_hw_config */
1089 local->oper_channel_type = NL80211_CHAN_NO_HT; 1087 local->oper_channel_type = NL80211_CHAN_NO_HT;
1090 1088
@@ -1370,6 +1368,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1370 1368
1371 if (!wk) { 1369 if (!wk) {
1372 ieee80211_set_disassoc(sdata, true); 1370 ieee80211_set_disassoc(sdata, true);
1371 ieee80211_recalc_idle(sdata->local);
1373 } else { 1372 } else {
1374 list_del(&wk->list); 1373 list_del(&wk->list);
1375 kfree(wk); 1374 kfree(wk);
@@ -1403,6 +1402,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1403 sdata->dev->name, mgmt->sa, reason_code); 1402 sdata->dev->name, mgmt->sa, reason_code);
1404 1403
1405 ieee80211_set_disassoc(sdata, false); 1404 ieee80211_set_disassoc(sdata, false);
1405 ieee80211_recalc_idle(sdata->local);
1406 return RX_MGMT_CFG80211_DISASSOC; 1406 return RX_MGMT_CFG80211_DISASSOC;
1407} 1407}
1408 1408
@@ -2117,6 +2117,7 @@ static void ieee80211_sta_work(struct work_struct *work)
2117 " after %dms, disconnecting.\n", 2117 " after %dms, disconnecting.\n",
2118 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); 2118 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
2119 ieee80211_set_disassoc(sdata, true); 2119 ieee80211_set_disassoc(sdata, true);
2120 ieee80211_recalc_idle(local);
2120 mutex_unlock(&ifmgd->mtx); 2121 mutex_unlock(&ifmgd->mtx);
2121 /* 2122 /*
2122 * must be outside lock due to cfg80211, 2123 * must be outside lock due to cfg80211,
@@ -2560,6 +2561,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
2560 IEEE80211_STYPE_DEAUTH, req->reason_code, 2561 IEEE80211_STYPE_DEAUTH, req->reason_code,
2561 cookie); 2562 cookie);
2562 2563
2564 ieee80211_recalc_idle(sdata->local);
2565
2563 return 0; 2566 return 0;
2564} 2567}
2565 2568
@@ -2592,5 +2595,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
2592 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, 2595 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid,
2593 IEEE80211_STYPE_DISASSOC, req->reason_code, 2596 IEEE80211_STYPE_DISASSOC, req->reason_code,
2594 cookie); 2597 cookie);
2598
2599 ieee80211_recalc_idle(sdata->local);
2600
2595 return 0; 2601 return 0;
2596} 2602}
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4cf387c944bf..f1a4c7160300 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -227,7 +227,8 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
227static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata) 227static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
228{ 228{
229 struct ieee80211_local *local = sdata->local; 229 struct ieee80211_local *local = sdata->local;
230 bool ps = false; 230
231 local->scan_ps_enabled = false;
231 232
232 /* FIXME: what to do when local->pspolling is true? */ 233 /* FIXME: what to do when local->pspolling is true? */
233 234
@@ -235,12 +236,13 @@ static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
235 cancel_work_sync(&local->dynamic_ps_enable_work); 236 cancel_work_sync(&local->dynamic_ps_enable_work);
236 237
237 if (local->hw.conf.flags & IEEE80211_CONF_PS) { 238 if (local->hw.conf.flags & IEEE80211_CONF_PS) {
238 ps = true; 239 local->scan_ps_enabled = true;
239 local->hw.conf.flags &= ~IEEE80211_CONF_PS; 240 local->hw.conf.flags &= ~IEEE80211_CONF_PS;
240 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 241 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
241 } 242 }
242 243
243 if (!ps || !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) 244 if (!(local->scan_ps_enabled) ||
245 !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
244 /* 246 /*
245 * If power save was enabled, no need to send a nullfunc 247 * If power save was enabled, no need to send a nullfunc
246 * frame because AP knows that we are sleeping. But if the 248 * frame because AP knows that we are sleeping. But if the
@@ -261,7 +263,7 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
261 263
262 if (!local->ps_sdata) 264 if (!local->ps_sdata)
263 ieee80211_send_nullfunc(local, sdata, 0); 265 ieee80211_send_nullfunc(local, sdata, 0);
264 else { 266 else if (local->scan_ps_enabled) {
265 /* 267 /*
266 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware 268 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
267 * will send a nullfunc frame with the powersave bit set 269 * will send a nullfunc frame with the powersave bit set
@@ -277,6 +279,16 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
277 */ 279 */
278 local->hw.conf.flags |= IEEE80211_CONF_PS; 280 local->hw.conf.flags |= IEEE80211_CONF_PS;
279 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 281 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
282 } else if (local->hw.conf.dynamic_ps_timeout > 0) {
283 /*
284 * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer
285 * had been running before leaving the operating channel,
286 * restart the timer now and send a nullfunc frame to inform
287 * the AP that we are awake.
288 */
289 ieee80211_send_nullfunc(local, sdata, 0);
290 mod_timer(&local->dynamic_ps_timer, jiffies +
291 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
280 } 292 }
281} 293}
282 294
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index d09f78bb2442..78a6e924c7e1 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -579,7 +579,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
579 if (elen > left) 579 if (elen > left)
580 break; 580 break;
581 581
582 if (calc_crc && id < 64 && (filter & BIT(id))) 582 if (calc_crc && id < 64 && (filter & (1ULL << id)))
583 crc = crc32_be(crc, pos - 2, elen + 2); 583 crc = crc32_be(crc, pos - 2, elen + 2);
584 584
585 switch (id) { 585 switch (id) {
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 448e5a0fcc2e..c218e07e5caf 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -579,6 +579,8 @@ static ssize_t rfkill_name_show(struct device *dev,
579 579
580static const char *rfkill_get_type_str(enum rfkill_type type) 580static const char *rfkill_get_type_str(enum rfkill_type type)
581{ 581{
582 BUILD_BUG_ON(NUM_RFKILL_TYPES != RFKILL_TYPE_FM + 1);
583
582 switch (type) { 584 switch (type) {
583 case RFKILL_TYPE_WLAN: 585 case RFKILL_TYPE_WLAN:
584 return "wlan"; 586 return "wlan";
@@ -597,8 +599,6 @@ static const char *rfkill_get_type_str(enum rfkill_type type)
597 default: 599 default:
598 BUG(); 600 BUG();
599 } 601 }
600
601 BUILD_BUG_ON(NUM_RFKILL_TYPES != RFKILL_TYPE_FM + 1);
602} 602}
603 603
604static ssize_t rfkill_type_show(struct device *dev, 604static ssize_t rfkill_type_show(struct device *dev,