aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c174
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.h10
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_initvals.h268
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c236
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h8
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c58
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.c51
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.h15
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_rx.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c147
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c100
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c51
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c31
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c29
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c109
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c556
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c199
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h60
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c66
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h89
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c456
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h60
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c163
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c26
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c26
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c55
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c14
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.c21
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dump.h3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c15
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c35
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c71
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c5
-rw-r--r--include/net/mac80211.h39
-rw-r--r--net/mac80211/driver-ops.h11
-rw-r--r--net/mac80211/driver-trace.h49
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/mlme.c59
-rw-r--r--net/mac80211/rx.c6
-rw-r--r--net/mac80211/work.c27
60 files changed, 2152 insertions, 1442 deletions
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index 8663660ea4c6..abd083a357f5 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -110,6 +110,8 @@ static struct usb_device_id ar9170_usb_ids[] = {
110 { USB_DEVICE(0x0409, 0x0249) }, 110 { USB_DEVICE(0x0409, 0x0249) },
111 /* AVM FRITZ!WLAN USB Stick N 2.4 */ 111 /* AVM FRITZ!WLAN USB Stick N 2.4 */
112 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY }, 112 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY },
113 /* Qwest/Actiontec 802AIN Wireless N USB Network Adapter */
114 { USB_DEVICE(0x1668, 0x1200) },
113 115
114 /* terminate */ 116 /* terminate */
115 {} 117 {}
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 7f5953fac434..5f04cf38a5bc 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1932,12 +1932,6 @@ ath5k_tasklet_rx(unsigned long data)
1932 1932
1933 sc->stats.rx_all_count++; 1933 sc->stats.rx_all_count++;
1934 1934
1935 if (unlikely(rs.rs_more)) {
1936 ATH5K_WARN(sc, "unsupported jumbo\n");
1937 sc->stats.rxerr_jumbo++;
1938 goto next;
1939 }
1940
1941 if (unlikely(rs.rs_status)) { 1935 if (unlikely(rs.rs_status)) {
1942 if (rs.rs_status & AR5K_RXERR_CRC) 1936 if (rs.rs_status & AR5K_RXERR_CRC)
1943 sc->stats.rxerr_crc++; 1937 sc->stats.rxerr_crc++;
@@ -1977,6 +1971,12 @@ ath5k_tasklet_rx(unsigned long data)
1977 sc->opmode != NL80211_IFTYPE_MONITOR) 1971 sc->opmode != NL80211_IFTYPE_MONITOR)
1978 goto next; 1972 goto next;
1979 } 1973 }
1974
1975 if (unlikely(rs.rs_more)) {
1976 sc->stats.rxerr_jumbo++;
1977 goto next;
1978
1979 }
1980accept: 1980accept:
1981 next_skb = ath5k_rx_skb_alloc(sc, &next_skb_addr); 1981 next_skb = ath5k_rx_skb_alloc(sc, &next_skb_addr);
1982 1982
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 8a79550dff71..23eb60ea5455 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -38,6 +38,9 @@
38#define AR_SWITCH_TABLE_ALL (0xfff) 38#define AR_SWITCH_TABLE_ALL (0xfff)
39#define AR_SWITCH_TABLE_ALL_S (0) 39#define AR_SWITCH_TABLE_ALL_S (0)
40 40
41#define LE16(x) __constant_cpu_to_le16(x)
42#define LE32(x) __constant_cpu_to_le32(x)
43
41static const struct ar9300_eeprom ar9300_default = { 44static const struct ar9300_eeprom ar9300_default = {
42 .eepromVersion = 2, 45 .eepromVersion = 2,
43 .templateVersion = 2, 46 .templateVersion = 2,
@@ -45,7 +48,7 @@ static const struct ar9300_eeprom ar9300_default = {
45 .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48 .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
47 .baseEepHeader = { 50 .baseEepHeader = {
48 .regDmn = {0, 0x1f}, 51 .regDmn = { LE16(0), LE16(0x1f) },
49 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ 52 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
50 .opCapFlags = { 53 .opCapFlags = {
51 .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A, 54 .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
@@ -76,15 +79,15 @@ static const struct ar9300_eeprom ar9300_default = {
76 .modalHeader2G = { 79 .modalHeader2G = {
77 /* ar9300_modal_eep_header 2g */ 80 /* ar9300_modal_eep_header 2g */
78 /* 4 idle,t1,t2,b(4 bits per setting) */ 81 /* 4 idle,t1,t2,b(4 bits per setting) */
79 .antCtrlCommon = 0x110, 82 .antCtrlCommon = LE32(0x110),
80 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ 83 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
81 .antCtrlCommon2 = 0x22222, 84 .antCtrlCommon2 = LE32(0x22222),
82 85
83 /* 86 /*
84 * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r, 87 * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
85 * rx1, rx12, b (2 bits each) 88 * rx1, rx12, b (2 bits each)
86 */ 89 */
87 .antCtrlChain = {0x150, 0x150, 0x150}, 90 .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
88 91
89 /* 92 /*
90 * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db 93 * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
@@ -287,12 +290,12 @@ static const struct ar9300_eeprom ar9300_default = {
287 }, 290 },
288 .modalHeader5G = { 291 .modalHeader5G = {
289 /* 4 idle,t1,t2,b (4 bits per setting) */ 292 /* 4 idle,t1,t2,b (4 bits per setting) */
290 .antCtrlCommon = 0x110, 293 .antCtrlCommon = LE32(0x110),
291 /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ 294 /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
292 .antCtrlCommon2 = 0x22222, 295 .antCtrlCommon2 = LE32(0x22222),
293 /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ 296 /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
294 .antCtrlChain = { 297 .antCtrlChain = {
295 0x000, 0x000, 0x000, 298 LE16(0x000), LE16(0x000), LE16(0x000),
296 }, 299 },
297 /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ 300 /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
298 .xatten1DB = {0, 0, 0}, 301 .xatten1DB = {0, 0, 0},
@@ -620,9 +623,9 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
620 case EEP_MAC_MSW: 623 case EEP_MAC_MSW:
621 return eep->macAddr[4] << 8 | eep->macAddr[5]; 624 return eep->macAddr[4] << 8 | eep->macAddr[5];
622 case EEP_REG_0: 625 case EEP_REG_0:
623 return pBase->regDmn[0]; 626 return le16_to_cpu(pBase->regDmn[0]);
624 case EEP_REG_1: 627 case EEP_REG_1:
625 return pBase->regDmn[1]; 628 return le16_to_cpu(pBase->regDmn[1]);
626 case EEP_OP_CAP: 629 case EEP_OP_CAP:
627 return pBase->deviceCap; 630 return pBase->deviceCap;
628 case EEP_OP_MODE: 631 case EEP_OP_MODE:
@@ -640,93 +643,80 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
640 /* Bit 4 is internal regulator flag */ 643 /* Bit 4 is internal regulator flag */
641 return (pBase->featureEnable & 0x10) >> 4; 644 return (pBase->featureEnable & 0x10) >> 4;
642 case EEP_SWREG: 645 case EEP_SWREG:
643 return pBase->swreg; 646 return le32_to_cpu(pBase->swreg);
644 default: 647 default:
645 return 0; 648 return 0;
646 } 649 }
647} 650}
648 651
649#ifdef __BIG_ENDIAN 652static bool ar9300_eeprom_read_byte(struct ath_common *common, int address,
650static void ar9300_swap_eeprom(struct ar9300_eeprom *eep) 653 u8 *buffer)
651{ 654{
652 u32 dword; 655 u16 val;
653 u16 word;
654 int i;
655
656 word = swab16(eep->baseEepHeader.regDmn[0]);
657 eep->baseEepHeader.regDmn[0] = word;
658
659 word = swab16(eep->baseEepHeader.regDmn[1]);
660 eep->baseEepHeader.regDmn[1] = word;
661
662 dword = swab32(eep->baseEepHeader.swreg);
663 eep->baseEepHeader.swreg = dword;
664 656
665 dword = swab32(eep->modalHeader2G.antCtrlCommon); 657 if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
666 eep->modalHeader2G.antCtrlCommon = dword; 658 return false;
667 659
668 dword = swab32(eep->modalHeader2G.antCtrlCommon2); 660 *buffer = (val >> (8 * (address % 2))) & 0xff;
669 eep->modalHeader2G.antCtrlCommon2 = dword; 661 return true;
662}
670 663
671 dword = swab32(eep->modalHeader5G.antCtrlCommon); 664static bool ar9300_eeprom_read_word(struct ath_common *common, int address,
672 eep->modalHeader5G.antCtrlCommon = dword; 665 u8 *buffer)
666{
667 u16 val;
673 668
674 dword = swab32(eep->modalHeader5G.antCtrlCommon2); 669 if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
675 eep->modalHeader5G.antCtrlCommon2 = dword; 670 return false;
676 671
677 for (i = 0; i < AR9300_MAX_CHAINS; i++) { 672 buffer[0] = val >> 8;
678 word = swab16(eep->modalHeader2G.antCtrlChain[i]); 673 buffer[1] = val & 0xff;
679 eep->modalHeader2G.antCtrlChain[i] = word;
680 674
681 word = swab16(eep->modalHeader5G.antCtrlChain[i]); 675 return true;
682 eep->modalHeader5G.antCtrlChain[i] = word;
683 }
684} 676}
685#endif
686 677
687static bool ar9300_hw_read_eeprom(struct ath_hw *ah, 678static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
688 long address, u8 *buffer, int many) 679 int count)
689{ 680{
690 int i;
691 u8 value[2];
692 unsigned long eepAddr;
693 unsigned long byteAddr;
694 u16 *svalue;
695 struct ath_common *common = ath9k_hw_common(ah); 681 struct ath_common *common = ath9k_hw_common(ah);
682 int i;
696 683
697 if ((address < 0) || ((address + many) > AR9300_EEPROM_SIZE - 1)) { 684 if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
698 ath_print(common, ATH_DBG_EEPROM, 685 ath_print(common, ATH_DBG_EEPROM,
699 "eeprom address not in range\n"); 686 "eeprom address not in range\n");
700 return false; 687 return false;
701 } 688 }
702 689
703 for (i = 0; i < many; i++) { 690 /*
704 eepAddr = (u16) (address + i) / 2; 691 * Since we're reading the bytes in reverse order from a little-endian
705 byteAddr = (u16) (address + i) % 2; 692 * word stream, an even address means we only use the lower half of
706 svalue = (u16 *) value; 693 * the 16-bit word at that address
707 if (!ath9k_hw_nvram_read(common, eepAddr, svalue)) { 694 */
708 ath_print(common, ATH_DBG_EEPROM, 695 if (address % 2 == 0) {
709 "unable to read eeprom region\n"); 696 if (!ar9300_eeprom_read_byte(common, address--, buffer++))
710 return false; 697 goto error;
711 } 698
712 *svalue = le16_to_cpu(*svalue); 699 count--;
713 buffer[i] = value[byteAddr];
714 } 700 }
715 701
716 return true; 702 for (i = 0; i < count / 2; i++) {
717} 703 if (!ar9300_eeprom_read_word(common, address, buffer))
704 goto error;
718 705
719static bool ar9300_read_eeprom(struct ath_hw *ah, 706 address -= 2;
720 int address, u8 *buffer, int many) 707 buffer += 2;
721{ 708 }
722 int it; 709
710 if (count % 2)
711 if (!ar9300_eeprom_read_byte(common, address, buffer))
712 goto error;
723 713
724 for (it = 0; it < many; it++)
725 if (!ar9300_hw_read_eeprom(ah,
726 (address - it),
727 (buffer + it), 1))
728 return false;
729 return true; 714 return true;
715
716error:
717 ath_print(common, ATH_DBG_EEPROM,
718 "unable to read eeprom region at offset %d\n", address);
719 return false;
730} 720}
731 721
732static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference, 722static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
@@ -927,30 +917,13 @@ fail:
927 */ 917 */
928static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah) 918static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
929{ 919{
930 u8 *mptr = NULL; 920 u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
931 int mdata_size;
932 921
933 mptr = (u8 *) &ah->eeprom.ar9300_eep; 922 if (ar9300_eeprom_restore_internal(ah, mptr,
934 mdata_size = sizeof(struct ar9300_eeprom); 923 sizeof(struct ar9300_eeprom)) < 0)
924 return false;
935 925
936 if (mptr && mdata_size > 0) { 926 return true;
937 /* At this point, mptr points to the eeprom data structure
938 * in it's "default" state. If this is big endian, swap the
939 * data structures back to "little endian"
940 */
941 /* First swap, default to Little Endian */
942#ifdef __BIG_ENDIAN
943 ar9300_swap_eeprom((struct ar9300_eeprom *)mptr);
944#endif
945 if (ar9300_eeprom_restore_internal(ah, mptr, mdata_size) >= 0)
946 return true;
947
948 /* Second Swap, back to Big Endian */
949#ifdef __BIG_ENDIAN
950 ar9300_swap_eeprom((struct ar9300_eeprom *)mptr);
951#endif
952 }
953 return false;
954} 927}
955 928
956/* XXX: review hardware docs */ 929/* XXX: review hardware docs */
@@ -998,21 +971,25 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
998static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) 971static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
999{ 972{
1000 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 973 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
974 __le32 val;
1001 975
1002 if (is2ghz) 976 if (is2ghz)
1003 return eep->modalHeader2G.antCtrlCommon; 977 val = eep->modalHeader2G.antCtrlCommon;
1004 else 978 else
1005 return eep->modalHeader5G.antCtrlCommon; 979 val = eep->modalHeader5G.antCtrlCommon;
980 return le32_to_cpu(val);
1006} 981}
1007 982
1008static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz) 983static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
1009{ 984{
1010 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 985 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
986 __le32 val;
1011 987
1012 if (is2ghz) 988 if (is2ghz)
1013 return eep->modalHeader2G.antCtrlCommon2; 989 val = eep->modalHeader2G.antCtrlCommon2;
1014 else 990 else
1015 return eep->modalHeader5G.antCtrlCommon2; 991 val = eep->modalHeader5G.antCtrlCommon2;
992 return le32_to_cpu(val);
1016} 993}
1017 994
1018static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, 995static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
@@ -1020,15 +997,16 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
1020 bool is2ghz) 997 bool is2ghz)
1021{ 998{
1022 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 999 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
1000 __le16 val = 0;
1023 1001
1024 if (chain >= 0 && chain < AR9300_MAX_CHAINS) { 1002 if (chain >= 0 && chain < AR9300_MAX_CHAINS) {
1025 if (is2ghz) 1003 if (is2ghz)
1026 return eep->modalHeader2G.antCtrlChain[chain]; 1004 val = eep->modalHeader2G.antCtrlChain[chain];
1027 else 1005 else
1028 return eep->modalHeader5G.antCtrlChain[chain]; 1006 val = eep->modalHeader5G.antCtrlChain[chain];
1029 } 1007 }
1030 1008
1031 return 0; 1009 return le16_to_cpu(val);
1032} 1010}
1033 1011
1034static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) 1012static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index d8c0318f416f..23fb353c3bba 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -169,7 +169,7 @@ enum CompressAlgorithm {
169}; 169};
170 170
171struct ar9300_base_eep_hdr { 171struct ar9300_base_eep_hdr {
172 u16 regDmn[2]; 172 __le16 regDmn[2];
173 /* 4 bits tx and 4 bits rx */ 173 /* 4 bits tx and 4 bits rx */
174 u8 txrxMask; 174 u8 txrxMask;
175 struct eepFlags opCapFlags; 175 struct eepFlags opCapFlags;
@@ -199,16 +199,16 @@ struct ar9300_base_eep_hdr {
199 u8 rxBandSelectGpio; 199 u8 rxBandSelectGpio;
200 u8 txrxgain; 200 u8 txrxgain;
201 /* SW controlled internal regulator fields */ 201 /* SW controlled internal regulator fields */
202 u32 swreg; 202 __le32 swreg;
203} __packed; 203} __packed;
204 204
205struct ar9300_modal_eep_header { 205struct ar9300_modal_eep_header {
206 /* 4 idle, t1, t2, b (4 bits per setting) */ 206 /* 4 idle, t1, t2, b (4 bits per setting) */
207 u32 antCtrlCommon; 207 __le32 antCtrlCommon;
208 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ 208 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
209 u32 antCtrlCommon2; 209 __le32 antCtrlCommon2;
210 /* 6 idle, t, r, rx1, rx12, b (2 bits each) */ 210 /* 6 idle, t, r, rx1, rx12, b (2 bits each) */
211 u16 antCtrlChain[AR9300_MAX_CHAINS]; 211 __le16 antCtrlChain[AR9300_MAX_CHAINS];
212 /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ 212 /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
213 u8 xatten1DB[AR9300_MAX_CHAINS]; 213 u8 xatten1DB[AR9300_MAX_CHAINS];
214 /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */ 214 /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
index ef6116e13033..db019dd220b7 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
@@ -25,8 +25,11 @@ static const u32 ar9300_2p0_radio_postamble[][5] = {
25 {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800}, 25 {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800},
26 {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20}, 26 {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20},
27 {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000}, 27 {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
28 {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
28 {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000}, 29 {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
30 {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
29 {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000}, 31 {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
32 {0x00016940, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
30}; 33};
31 34
32static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = { 35static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = {
@@ -97,13 +100,13 @@ static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = {
97 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 100 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
98 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 101 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
99 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 102 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
100 {0x00016048, 0x60001a61, 0x60001a61, 0x60001a61, 0x60001a61}, 103 {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
101 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 104 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
102 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 105 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
103 {0x00016448, 0x60001a61, 0x60001a61, 0x60001a61, 0x60001a61}, 106 {0x00016448, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
104 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 107 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
105 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 108 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
106 {0x00016848, 0x60001a61, 0x60001a61, 0x60001a61, 0x60001a61}, 109 {0x00016848, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
107 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 110 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
108}; 111};
109 112
@@ -129,7 +132,7 @@ static const u32 ar9300_2p0_radio_core[][2] = {
129 {0x00016040, 0x7f80fff8}, 132 {0x00016040, 0x7f80fff8},
130 {0x0001604c, 0x76d005b5}, 133 {0x0001604c, 0x76d005b5},
131 {0x00016050, 0x556cf031}, 134 {0x00016050, 0x556cf031},
132 {0x00016054, 0x43449440}, 135 {0x00016054, 0x13449440},
133 {0x00016058, 0x0c51c92c}, 136 {0x00016058, 0x0c51c92c},
134 {0x0001605c, 0x3db7fffc}, 137 {0x0001605c, 0x3db7fffc},
135 {0x00016060, 0xfffffffc}, 138 {0x00016060, 0xfffffffc},
@@ -152,12 +155,11 @@ static const u32 ar9300_2p0_radio_core[][2] = {
152 {0x00016100, 0x3fffbe01}, 155 {0x00016100, 0x3fffbe01},
153 {0x00016104, 0xfff80000}, 156 {0x00016104, 0xfff80000},
154 {0x00016108, 0x00080010}, 157 {0x00016108, 0x00080010},
155 {0x00016140, 0x10804008},
156 {0x00016144, 0x02084080}, 158 {0x00016144, 0x02084080},
157 {0x00016148, 0x00000000}, 159 {0x00016148, 0x00000000},
158 {0x00016280, 0x058a0001}, 160 {0x00016280, 0x058a0001},
159 {0x00016284, 0x3d840208}, 161 {0x00016284, 0x3d840208},
160 {0x00016288, 0x01a20408}, 162 {0x00016288, 0x05a20408},
161 {0x0001628c, 0x00038c07}, 163 {0x0001628c, 0x00038c07},
162 {0x00016290, 0x40000004}, 164 {0x00016290, 0x40000004},
163 {0x00016294, 0x458aa14f}, 165 {0x00016294, 0x458aa14f},
@@ -190,7 +192,7 @@ static const u32 ar9300_2p0_radio_core[][2] = {
190 {0x00016440, 0x7f80fff8}, 192 {0x00016440, 0x7f80fff8},
191 {0x0001644c, 0x76d005b5}, 193 {0x0001644c, 0x76d005b5},
192 {0x00016450, 0x556cf031}, 194 {0x00016450, 0x556cf031},
193 {0x00016454, 0x43449440}, 195 {0x00016454, 0x13449440},
194 {0x00016458, 0x0c51c92c}, 196 {0x00016458, 0x0c51c92c},
195 {0x0001645c, 0x3db7fffc}, 197 {0x0001645c, 0x3db7fffc},
196 {0x00016460, 0xfffffffc}, 198 {0x00016460, 0xfffffffc},
@@ -199,7 +201,6 @@ static const u32 ar9300_2p0_radio_core[][2] = {
199 {0x00016500, 0x3fffbe01}, 201 {0x00016500, 0x3fffbe01},
200 {0x00016504, 0xfff80000}, 202 {0x00016504, 0xfff80000},
201 {0x00016508, 0x00080010}, 203 {0x00016508, 0x00080010},
202 {0x00016540, 0x10804008},
203 {0x00016544, 0x02084080}, 204 {0x00016544, 0x02084080},
204 {0x00016548, 0x00000000}, 205 {0x00016548, 0x00000000},
205 {0x00016780, 0x00000000}, 206 {0x00016780, 0x00000000},
@@ -231,7 +232,7 @@ static const u32 ar9300_2p0_radio_core[][2] = {
231 {0x00016840, 0x7f80fff8}, 232 {0x00016840, 0x7f80fff8},
232 {0x0001684c, 0x76d005b5}, 233 {0x0001684c, 0x76d005b5},
233 {0x00016850, 0x556cf031}, 234 {0x00016850, 0x556cf031},
234 {0x00016854, 0x43449440}, 235 {0x00016854, 0x13449440},
235 {0x00016858, 0x0c51c92c}, 236 {0x00016858, 0x0c51c92c},
236 {0x0001685c, 0x3db7fffc}, 237 {0x0001685c, 0x3db7fffc},
237 {0x00016860, 0xfffffffc}, 238 {0x00016860, 0xfffffffc},
@@ -240,7 +241,6 @@ static const u32 ar9300_2p0_radio_core[][2] = {
240 {0x00016900, 0x3fffbe01}, 241 {0x00016900, 0x3fffbe01},
241 {0x00016904, 0xfff80000}, 242 {0x00016904, 0xfff80000},
242 {0x00016908, 0x00080010}, 243 {0x00016908, 0x00080010},
243 {0x00016940, 0x10804008},
244 {0x00016944, 0x02084080}, 244 {0x00016944, 0x02084080},
245 {0x00016948, 0x00000000}, 245 {0x00016948, 0x00000000},
246 {0x00016b80, 0x00000000}, 246 {0x00016b80, 0x00000000},
@@ -588,12 +588,12 @@ static const u32 ar9200_merlin_2p0_radio_core[][2] = {
588 588
589static const u32 ar9300_2p0_baseband_postamble[][5] = { 589static const u32 ar9300_2p0_baseband_postamble[][5] = {
590 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 590 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
591 {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a800b}, 591 {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011},
592 {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, 592 {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e},
593 {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, 593 {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0},
594 {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, 594 {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881},
595 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, 595 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
596 {0x00009830, 0x0000059c, 0x0000059c, 0x0000059c, 0x00000b9c}, 596 {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
597 {0x00009c00, 0x00000044, 0x000000c4, 0x000000c4, 0x00000044}, 597 {0x00009c00, 0x00000044, 0x000000c4, 0x000000c4, 0x00000044},
598 {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0}, 598 {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0},
599 {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020}, 599 {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020},
@@ -604,8 +604,8 @@ static const u32 ar9300_2p0_baseband_postamble[][5] = {
604 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 604 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
605 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, 605 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
606 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021}, 606 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
607 {0x00009e44, 0x02321e27, 0x02321e27, 0x02282324, 0x02282324}, 607 {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27},
608 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302010, 0x50302010}, 608 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
609 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, 609 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
610 {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0}, 610 {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0},
611 {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004}, 611 {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004},
@@ -674,7 +674,7 @@ static const u32 ar9300_2p0_baseband_core[][2] = {
674 {0x00009d10, 0x01834061}, 674 {0x00009d10, 0x01834061},
675 {0x00009d14, 0x00c0040b}, 675 {0x00009d14, 0x00c0040b},
676 {0x00009d18, 0x00000000}, 676 {0x00009d18, 0x00000000},
677 {0x00009e08, 0x0038233c}, 677 {0x00009e08, 0x0038230c},
678 {0x00009e24, 0x990bb515}, 678 {0x00009e24, 0x990bb515},
679 {0x00009e28, 0x0c6f0000}, 679 {0x00009e28, 0x0c6f0000},
680 {0x00009e30, 0x06336f77}, 680 {0x00009e30, 0x06336f77},
@@ -901,13 +901,13 @@ static const u32 ar9300Modes_high_power_tx_gain_table_2p0[][5] = {
901 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 901 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
902 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 902 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
903 {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 903 {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
904 {0x00016048, 0xae481a61, 0xae481a61, 0xae481a61, 0xae481a61}, 904 {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
905 {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 905 {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
906 {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 906 {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
907 {0x00016448, 0xae481a61, 0xae481a61, 0xae481a61, 0xae481a61}, 907 {0x00016448, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
908 {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 908 {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
909 {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 909 {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
910 {0x00016848, 0xae481a61, 0xae481a61, 0xae481a61, 0xae481a61}, 910 {0x00016848, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
911 {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 911 {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
912}; 912};
913 913
@@ -979,13 +979,13 @@ static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p0[][5] = {
979 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 979 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
980 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 980 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
981 {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 981 {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
982 {0x00016048, 0x8e481a61, 0x8e481a61, 0x8e481a61, 0x8e481a61}, 982 {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
983 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 983 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
984 {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 984 {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
985 {0x00016448, 0x8e481a61, 0x8e481a61, 0x8e481a61, 0x8e481a61}, 985 {0x00016448, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
986 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 986 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
987 {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 987 {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
988 {0x00016848, 0x8e481a61, 0x8e481a61, 0x8e481a61, 0x8e481a61}, 988 {0x00016848, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
989 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 989 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
990}; 990};
991 991
@@ -995,22 +995,22 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
995 {0x0000a004, 0x00030002}, 995 {0x0000a004, 0x00030002},
996 {0x0000a008, 0x00050004}, 996 {0x0000a008, 0x00050004},
997 {0x0000a00c, 0x00810080}, 997 {0x0000a00c, 0x00810080},
998 {0x0000a010, 0x01800082}, 998 {0x0000a010, 0x00830082},
999 {0x0000a014, 0x01820181}, 999 {0x0000a014, 0x01810180},
1000 {0x0000a018, 0x01840183}, 1000 {0x0000a018, 0x01830182},
1001 {0x0000a01c, 0x01880185}, 1001 {0x0000a01c, 0x01850184},
1002 {0x0000a020, 0x018a0189}, 1002 {0x0000a020, 0x01890188},
1003 {0x0000a024, 0x02850284}, 1003 {0x0000a024, 0x018b018a},
1004 {0x0000a028, 0x02890288}, 1004 {0x0000a028, 0x018d018c},
1005 {0x0000a02c, 0x028b028a}, 1005 {0x0000a02c, 0x01910190},
1006 {0x0000a030, 0x028d028c}, 1006 {0x0000a030, 0x01930192},
1007 {0x0000a034, 0x02910290}, 1007 {0x0000a034, 0x01950194},
1008 {0x0000a038, 0x02930292}, 1008 {0x0000a038, 0x038a0196},
1009 {0x0000a03c, 0x03910390}, 1009 {0x0000a03c, 0x038c038b},
1010 {0x0000a040, 0x03930392}, 1010 {0x0000a040, 0x0390038d},
1011 {0x0000a044, 0x03950394}, 1011 {0x0000a044, 0x03920391},
1012 {0x0000a048, 0x00000396}, 1012 {0x0000a048, 0x03940393},
1013 {0x0000a04c, 0x00000000}, 1013 {0x0000a04c, 0x03960395},
1014 {0x0000a050, 0x00000000}, 1014 {0x0000a050, 0x00000000},
1015 {0x0000a054, 0x00000000}, 1015 {0x0000a054, 0x00000000},
1016 {0x0000a058, 0x00000000}, 1016 {0x0000a058, 0x00000000},
@@ -1023,14 +1023,14 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1023 {0x0000a074, 0x00000000}, 1023 {0x0000a074, 0x00000000},
1024 {0x0000a078, 0x00000000}, 1024 {0x0000a078, 0x00000000},
1025 {0x0000a07c, 0x00000000}, 1025 {0x0000a07c, 0x00000000},
1026 {0x0000a080, 0x28282828}, 1026 {0x0000a080, 0x22222229},
1027 {0x0000a084, 0x21212128}, 1027 {0x0000a084, 0x1d1d1d1d},
1028 {0x0000a088, 0x21212121}, 1028 {0x0000a088, 0x1d1d1d1d},
1029 {0x0000a08c, 0x1c1c1c21}, 1029 {0x0000a08c, 0x1d1d1d1d},
1030 {0x0000a090, 0x1c1c1c1c}, 1030 {0x0000a090, 0x171d1d1d},
1031 {0x0000a094, 0x17171c1c}, 1031 {0x0000a094, 0x11111717},
1032 {0x0000a098, 0x02020212}, 1032 {0x0000a098, 0x00030311},
1033 {0x0000a09c, 0x02020202}, 1033 {0x0000a09c, 0x00000000},
1034 {0x0000a0a0, 0x00000000}, 1034 {0x0000a0a0, 0x00000000},
1035 {0x0000a0a4, 0x00000000}, 1035 {0x0000a0a4, 0x00000000},
1036 {0x0000a0a8, 0x00000000}, 1036 {0x0000a0a8, 0x00000000},
@@ -1040,26 +1040,26 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1040 {0x0000a0b8, 0x00000000}, 1040 {0x0000a0b8, 0x00000000},
1041 {0x0000a0bc, 0x00000000}, 1041 {0x0000a0bc, 0x00000000},
1042 {0x0000a0c0, 0x001f0000}, 1042 {0x0000a0c0, 0x001f0000},
1043 {0x0000a0c4, 0x011f0100}, 1043 {0x0000a0c4, 0x01000101},
1044 {0x0000a0c8, 0x011d011e}, 1044 {0x0000a0c8, 0x011e011f},
1045 {0x0000a0cc, 0x011b011c}, 1045 {0x0000a0cc, 0x011c011d},
1046 {0x0000a0d0, 0x02030204}, 1046 {0x0000a0d0, 0x02030204},
1047 {0x0000a0d4, 0x02010202}, 1047 {0x0000a0d4, 0x02010202},
1048 {0x0000a0d8, 0x021f0200}, 1048 {0x0000a0d8, 0x021f0200},
1049 {0x0000a0dc, 0x021d021e}, 1049 {0x0000a0dc, 0x0302021e},
1050 {0x0000a0e0, 0x03010302}, 1050 {0x0000a0e0, 0x03000301},
1051 {0x0000a0e4, 0x031f0300}, 1051 {0x0000a0e4, 0x031e031f},
1052 {0x0000a0e8, 0x0402031e}, 1052 {0x0000a0e8, 0x0402031d},
1053 {0x0000a0ec, 0x04000401}, 1053 {0x0000a0ec, 0x04000401},
1054 {0x0000a0f0, 0x041e041f}, 1054 {0x0000a0f0, 0x041e041f},
1055 {0x0000a0f4, 0x05010502}, 1055 {0x0000a0f4, 0x0502041d},
1056 {0x0000a0f8, 0x051f0500}, 1056 {0x0000a0f8, 0x05000501},
1057 {0x0000a0fc, 0x0602051e}, 1057 {0x0000a0fc, 0x051e051f},
1058 {0x0000a100, 0x06000601}, 1058 {0x0000a100, 0x06010602},
1059 {0x0000a104, 0x061e061f}, 1059 {0x0000a104, 0x061f0600},
1060 {0x0000a108, 0x0703061d}, 1060 {0x0000a108, 0x061d061e},
1061 {0x0000a10c, 0x07010702}, 1061 {0x0000a10c, 0x07020703},
1062 {0x0000a110, 0x00000700}, 1062 {0x0000a110, 0x07000701},
1063 {0x0000a114, 0x00000000}, 1063 {0x0000a114, 0x00000000},
1064 {0x0000a118, 0x00000000}, 1064 {0x0000a118, 0x00000000},
1065 {0x0000a11c, 0x00000000}, 1065 {0x0000a11c, 0x00000000},
@@ -1072,26 +1072,26 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1072 {0x0000a138, 0x00000000}, 1072 {0x0000a138, 0x00000000},
1073 {0x0000a13c, 0x00000000}, 1073 {0x0000a13c, 0x00000000},
1074 {0x0000a140, 0x001f0000}, 1074 {0x0000a140, 0x001f0000},
1075 {0x0000a144, 0x011f0100}, 1075 {0x0000a144, 0x01000101},
1076 {0x0000a148, 0x011d011e}, 1076 {0x0000a148, 0x011e011f},
1077 {0x0000a14c, 0x011b011c}, 1077 {0x0000a14c, 0x011c011d},
1078 {0x0000a150, 0x02030204}, 1078 {0x0000a150, 0x02030204},
1079 {0x0000a154, 0x02010202}, 1079 {0x0000a154, 0x02010202},
1080 {0x0000a158, 0x021f0200}, 1080 {0x0000a158, 0x021f0200},
1081 {0x0000a15c, 0x021d021e}, 1081 {0x0000a15c, 0x0302021e},
1082 {0x0000a160, 0x03010302}, 1082 {0x0000a160, 0x03000301},
1083 {0x0000a164, 0x031f0300}, 1083 {0x0000a164, 0x031e031f},
1084 {0x0000a168, 0x0402031e}, 1084 {0x0000a168, 0x0402031d},
1085 {0x0000a16c, 0x04000401}, 1085 {0x0000a16c, 0x04000401},
1086 {0x0000a170, 0x041e041f}, 1086 {0x0000a170, 0x041e041f},
1087 {0x0000a174, 0x05010502}, 1087 {0x0000a174, 0x0502041d},
1088 {0x0000a178, 0x051f0500}, 1088 {0x0000a178, 0x05000501},
1089 {0x0000a17c, 0x0602051e}, 1089 {0x0000a17c, 0x051e051f},
1090 {0x0000a180, 0x06000601}, 1090 {0x0000a180, 0x06010602},
1091 {0x0000a184, 0x061e061f}, 1091 {0x0000a184, 0x061f0600},
1092 {0x0000a188, 0x0703061d}, 1092 {0x0000a188, 0x061d061e},
1093 {0x0000a18c, 0x07010702}, 1093 {0x0000a18c, 0x07020703},
1094 {0x0000a190, 0x00000700}, 1094 {0x0000a190, 0x07000701},
1095 {0x0000a194, 0x00000000}, 1095 {0x0000a194, 0x00000000},
1096 {0x0000a198, 0x00000000}, 1096 {0x0000a198, 0x00000000},
1097 {0x0000a19c, 0x00000000}, 1097 {0x0000a19c, 0x00000000},
@@ -1317,13 +1317,13 @@ static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p0[][5] = {
1317 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 1317 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1318 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 1318 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1319 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1319 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1320 {0x00016048, 0x64001a61, 0x64001a61, 0x64001a61, 0x64001a61}, 1320 {0x00016048, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1321 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1321 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1322 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1322 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1323 {0x00016448, 0x64001a61, 0x64001a61, 0x64001a61, 0x64001a61}, 1323 {0x00016448, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1324 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1324 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1325 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1325 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1326 {0x00016848, 0x64001a61, 0x64001a61, 0x64001a61, 0x64001a61}, 1326 {0x00016848, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1327 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1327 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1328}; 1328};
1329 1329
@@ -1497,22 +1497,22 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1497 {0x0000a004, 0x00030002}, 1497 {0x0000a004, 0x00030002},
1498 {0x0000a008, 0x00050004}, 1498 {0x0000a008, 0x00050004},
1499 {0x0000a00c, 0x00810080}, 1499 {0x0000a00c, 0x00810080},
1500 {0x0000a010, 0x01800082}, 1500 {0x0000a010, 0x00830082},
1501 {0x0000a014, 0x01820181}, 1501 {0x0000a014, 0x01810180},
1502 {0x0000a018, 0x01840183}, 1502 {0x0000a018, 0x01830182},
1503 {0x0000a01c, 0x01880185}, 1503 {0x0000a01c, 0x01850184},
1504 {0x0000a020, 0x018a0189}, 1504 {0x0000a020, 0x01890188},
1505 {0x0000a024, 0x02850284}, 1505 {0x0000a024, 0x018b018a},
1506 {0x0000a028, 0x02890288}, 1506 {0x0000a028, 0x018d018c},
1507 {0x0000a02c, 0x03850384}, 1507 {0x0000a02c, 0x03820190},
1508 {0x0000a030, 0x03890388}, 1508 {0x0000a030, 0x03840383},
1509 {0x0000a034, 0x038b038a}, 1509 {0x0000a034, 0x03880385},
1510 {0x0000a038, 0x038d038c}, 1510 {0x0000a038, 0x038a0389},
1511 {0x0000a03c, 0x03910390}, 1511 {0x0000a03c, 0x038c038b},
1512 {0x0000a040, 0x03930392}, 1512 {0x0000a040, 0x0390038d},
1513 {0x0000a044, 0x03950394}, 1513 {0x0000a044, 0x03920391},
1514 {0x0000a048, 0x00000396}, 1514 {0x0000a048, 0x03940393},
1515 {0x0000a04c, 0x00000000}, 1515 {0x0000a04c, 0x03960395},
1516 {0x0000a050, 0x00000000}, 1516 {0x0000a050, 0x00000000},
1517 {0x0000a054, 0x00000000}, 1517 {0x0000a054, 0x00000000},
1518 {0x0000a058, 0x00000000}, 1518 {0x0000a058, 0x00000000},
@@ -1525,15 +1525,15 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1525 {0x0000a074, 0x00000000}, 1525 {0x0000a074, 0x00000000},
1526 {0x0000a078, 0x00000000}, 1526 {0x0000a078, 0x00000000},
1527 {0x0000a07c, 0x00000000}, 1527 {0x0000a07c, 0x00000000},
1528 {0x0000a080, 0x28282828}, 1528 {0x0000a080, 0x29292929},
1529 {0x0000a084, 0x28282828}, 1529 {0x0000a084, 0x29292929},
1530 {0x0000a088, 0x28282828}, 1530 {0x0000a088, 0x29292929},
1531 {0x0000a08c, 0x28282828}, 1531 {0x0000a08c, 0x29292929},
1532 {0x0000a090, 0x28282828}, 1532 {0x0000a090, 0x22292929},
1533 {0x0000a094, 0x21212128}, 1533 {0x0000a094, 0x1d1d2222},
1534 {0x0000a098, 0x171c1c1c}, 1534 {0x0000a098, 0x0c111117},
1535 {0x0000a09c, 0x02020212}, 1535 {0x0000a09c, 0x00030303},
1536 {0x0000a0a0, 0x00000202}, 1536 {0x0000a0a0, 0x00000000},
1537 {0x0000a0a4, 0x00000000}, 1537 {0x0000a0a4, 0x00000000},
1538 {0x0000a0a8, 0x00000000}, 1538 {0x0000a0a8, 0x00000000},
1539 {0x0000a0ac, 0x00000000}, 1539 {0x0000a0ac, 0x00000000},
@@ -1542,26 +1542,26 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1542 {0x0000a0b8, 0x00000000}, 1542 {0x0000a0b8, 0x00000000},
1543 {0x0000a0bc, 0x00000000}, 1543 {0x0000a0bc, 0x00000000},
1544 {0x0000a0c0, 0x001f0000}, 1544 {0x0000a0c0, 0x001f0000},
1545 {0x0000a0c4, 0x011f0100}, 1545 {0x0000a0c4, 0x01000101},
1546 {0x0000a0c8, 0x011d011e}, 1546 {0x0000a0c8, 0x011e011f},
1547 {0x0000a0cc, 0x011b011c}, 1547 {0x0000a0cc, 0x011c011d},
1548 {0x0000a0d0, 0x02030204}, 1548 {0x0000a0d0, 0x02030204},
1549 {0x0000a0d4, 0x02010202}, 1549 {0x0000a0d4, 0x02010202},
1550 {0x0000a0d8, 0x021f0200}, 1550 {0x0000a0d8, 0x021f0200},
1551 {0x0000a0dc, 0x021d021e}, 1551 {0x0000a0dc, 0x0302021e},
1552 {0x0000a0e0, 0x03010302}, 1552 {0x0000a0e0, 0x03000301},
1553 {0x0000a0e4, 0x031f0300}, 1553 {0x0000a0e4, 0x031e031f},
1554 {0x0000a0e8, 0x0402031e}, 1554 {0x0000a0e8, 0x0402031d},
1555 {0x0000a0ec, 0x04000401}, 1555 {0x0000a0ec, 0x04000401},
1556 {0x0000a0f0, 0x041e041f}, 1556 {0x0000a0f0, 0x041e041f},
1557 {0x0000a0f4, 0x05010502}, 1557 {0x0000a0f4, 0x0502041d},
1558 {0x0000a0f8, 0x051f0500}, 1558 {0x0000a0f8, 0x05000501},
1559 {0x0000a0fc, 0x0602051e}, 1559 {0x0000a0fc, 0x051e051f},
1560 {0x0000a100, 0x06000601}, 1560 {0x0000a100, 0x06010602},
1561 {0x0000a104, 0x061e061f}, 1561 {0x0000a104, 0x061f0600},
1562 {0x0000a108, 0x0703061d}, 1562 {0x0000a108, 0x061d061e},
1563 {0x0000a10c, 0x07010702}, 1563 {0x0000a10c, 0x07020703},
1564 {0x0000a110, 0x00000700}, 1564 {0x0000a110, 0x07000701},
1565 {0x0000a114, 0x00000000}, 1565 {0x0000a114, 0x00000000},
1566 {0x0000a118, 0x00000000}, 1566 {0x0000a118, 0x00000000},
1567 {0x0000a11c, 0x00000000}, 1567 {0x0000a11c, 0x00000000},
@@ -1574,26 +1574,26 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1574 {0x0000a138, 0x00000000}, 1574 {0x0000a138, 0x00000000},
1575 {0x0000a13c, 0x00000000}, 1575 {0x0000a13c, 0x00000000},
1576 {0x0000a140, 0x001f0000}, 1576 {0x0000a140, 0x001f0000},
1577 {0x0000a144, 0x011f0100}, 1577 {0x0000a144, 0x01000101},
1578 {0x0000a148, 0x011d011e}, 1578 {0x0000a148, 0x011e011f},
1579 {0x0000a14c, 0x011b011c}, 1579 {0x0000a14c, 0x011c011d},
1580 {0x0000a150, 0x02030204}, 1580 {0x0000a150, 0x02030204},
1581 {0x0000a154, 0x02010202}, 1581 {0x0000a154, 0x02010202},
1582 {0x0000a158, 0x021f0200}, 1582 {0x0000a158, 0x021f0200},
1583 {0x0000a15c, 0x021d021e}, 1583 {0x0000a15c, 0x0302021e},
1584 {0x0000a160, 0x03010302}, 1584 {0x0000a160, 0x03000301},
1585 {0x0000a164, 0x031f0300}, 1585 {0x0000a164, 0x031e031f},
1586 {0x0000a168, 0x0402031e}, 1586 {0x0000a168, 0x0402031d},
1587 {0x0000a16c, 0x04000401}, 1587 {0x0000a16c, 0x04000401},
1588 {0x0000a170, 0x041e041f}, 1588 {0x0000a170, 0x041e041f},
1589 {0x0000a174, 0x05010502}, 1589 {0x0000a174, 0x0502041d},
1590 {0x0000a178, 0x051f0500}, 1590 {0x0000a178, 0x05000501},
1591 {0x0000a17c, 0x0602051e}, 1591 {0x0000a17c, 0x051e051f},
1592 {0x0000a180, 0x06000601}, 1592 {0x0000a180, 0x06010602},
1593 {0x0000a184, 0x061e061f}, 1593 {0x0000a184, 0x061f0600},
1594 {0x0000a188, 0x0703061d}, 1594 {0x0000a188, 0x061d061e},
1595 {0x0000a18c, 0x07010702}, 1595 {0x0000a18c, 0x07020703},
1596 {0x0000a190, 0x00000700}, 1596 {0x0000a190, 0x07000701},
1597 {0x0000a194, 0x00000000}, 1597 {0x0000a194, 0x00000000},
1598 {0x0000a198, 0x00000000}, 1598 {0x0000a198, 0x00000000},
1599 {0x0000a19c, 0x00000000}, 1599 {0x0000a19c, 0x00000000},
@@ -1620,7 +1620,7 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1620 {0x0000a1f0, 0x00000396}, 1620 {0x0000a1f0, 0x00000396},
1621 {0x0000a1f4, 0x00000396}, 1621 {0x0000a1f4, 0x00000396},
1622 {0x0000a1f8, 0x00000396}, 1622 {0x0000a1f8, 0x00000396},
1623 {0x0000a1fc, 0x00000296}, 1623 {0x0000a1fc, 0x00000196},
1624 {0x0000b000, 0x00010000}, 1624 {0x0000b000, 0x00010000},
1625 {0x0000b004, 0x00030002}, 1625 {0x0000b004, 0x00030002},
1626 {0x0000b008, 0x00050004}, 1626 {0x0000b008, 0x00050004},
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 64e30cd45d05..29898f8d1893 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -78,6 +78,90 @@ static const struct file_operations fops_debug = {
78 78
79#define DMA_BUF_LEN 1024 79#define DMA_BUF_LEN 1024
80 80
81static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
82 size_t count, loff_t *ppos)
83{
84 struct ath_softc *sc = file->private_data;
85 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
86 char buf[32];
87 unsigned int len;
88
89 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->tx_chainmask);
90 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
91}
92
93static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
94 size_t count, loff_t *ppos)
95{
96 struct ath_softc *sc = file->private_data;
97 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
98 unsigned long mask;
99 char buf[32];
100 ssize_t len;
101
102 len = min(count, sizeof(buf) - 1);
103 if (copy_from_user(buf, user_buf, len))
104 return -EINVAL;
105
106 buf[len] = '\0';
107 if (strict_strtoul(buf, 0, &mask))
108 return -EINVAL;
109
110 common->tx_chainmask = mask;
111 sc->sc_ah->caps.tx_chainmask = mask;
112 return count;
113}
114
115static const struct file_operations fops_tx_chainmask = {
116 .read = read_file_tx_chainmask,
117 .write = write_file_tx_chainmask,
118 .open = ath9k_debugfs_open,
119 .owner = THIS_MODULE
120};
121
122
123static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
124 size_t count, loff_t *ppos)
125{
126 struct ath_softc *sc = file->private_data;
127 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
128 char buf[32];
129 unsigned int len;
130
131 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->rx_chainmask);
132 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
133}
134
135static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
136 size_t count, loff_t *ppos)
137{
138 struct ath_softc *sc = file->private_data;
139 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
140 unsigned long mask;
141 char buf[32];
142 ssize_t len;
143
144 len = min(count, sizeof(buf) - 1);
145 if (copy_from_user(buf, user_buf, len))
146 return -EINVAL;
147
148 buf[len] = '\0';
149 if (strict_strtoul(buf, 0, &mask))
150 return -EINVAL;
151
152 common->rx_chainmask = mask;
153 sc->sc_ah->caps.rx_chainmask = mask;
154 return count;
155}
156
157static const struct file_operations fops_rx_chainmask = {
158 .read = read_file_rx_chainmask,
159 .write = write_file_rx_chainmask,
160 .open = ath9k_debugfs_open,
161 .owner = THIS_MODULE
162};
163
164
81static ssize_t read_file_dma(struct file *file, char __user *user_buf, 165static ssize_t read_file_dma(struct file *file, char __user *user_buf,
82 size_t count, loff_t *ppos) 166 size_t count, loff_t *ppos)
83{ 167{
@@ -711,6 +795,86 @@ static const struct file_operations fops_recv = {
711 .owner = THIS_MODULE 795 .owner = THIS_MODULE
712}; 796};
713 797
798static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
799 size_t count, loff_t *ppos)
800{
801 struct ath_softc *sc = file->private_data;
802 char buf[32];
803 unsigned int len;
804
805 len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.regidx);
806 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
807}
808
809static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
810 size_t count, loff_t *ppos)
811{
812 struct ath_softc *sc = file->private_data;
813 unsigned long regidx;
814 char buf[32];
815 ssize_t len;
816
817 len = min(count, sizeof(buf) - 1);
818 if (copy_from_user(buf, user_buf, len))
819 return -EINVAL;
820
821 buf[len] = '\0';
822 if (strict_strtoul(buf, 0, &regidx))
823 return -EINVAL;
824
825 sc->debug.regidx = regidx;
826 return count;
827}
828
829static const struct file_operations fops_regidx = {
830 .read = read_file_regidx,
831 .write = write_file_regidx,
832 .open = ath9k_debugfs_open,
833 .owner = THIS_MODULE
834};
835
836static ssize_t read_file_regval(struct file *file, char __user *user_buf,
837 size_t count, loff_t *ppos)
838{
839 struct ath_softc *sc = file->private_data;
840 struct ath_hw *ah = sc->sc_ah;
841 char buf[32];
842 unsigned int len;
843 u32 regval;
844
845 regval = REG_READ_D(ah, sc->debug.regidx);
846 len = snprintf(buf, sizeof(buf), "0x%08x\n", regval);
847 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
848}
849
850static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
851 size_t count, loff_t *ppos)
852{
853 struct ath_softc *sc = file->private_data;
854 struct ath_hw *ah = sc->sc_ah;
855 unsigned long regval;
856 char buf[32];
857 ssize_t len;
858
859 len = min(count, sizeof(buf) - 1);
860 if (copy_from_user(buf, user_buf, len))
861 return -EINVAL;
862
863 buf[len] = '\0';
864 if (strict_strtoul(buf, 0, &regval))
865 return -EINVAL;
866
867 REG_WRITE_D(ah, sc->debug.regidx, regval);
868 return count;
869}
870
871static const struct file_operations fops_regval = {
872 .read = read_file_regval,
873 .write = write_file_regval,
874 .open = ath9k_debugfs_open,
875 .owner = THIS_MODULE
876};
877
714int ath9k_init_debug(struct ath_hw *ah) 878int ath9k_init_debug(struct ath_hw *ah)
715{ 879{
716 struct ath_common *common = ath9k_hw_common(ah); 880 struct ath_common *common = ath9k_hw_common(ah);
@@ -722,54 +886,55 @@ int ath9k_init_debug(struct ath_hw *ah)
722 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), 886 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
723 ath9k_debugfs_root); 887 ath9k_debugfs_root);
724 if (!sc->debug.debugfs_phy) 888 if (!sc->debug.debugfs_phy)
725 goto err; 889 return -ENOMEM;
726 890
727#ifdef CONFIG_ATH_DEBUG 891#ifdef CONFIG_ATH_DEBUG
728 sc->debug.debugfs_debug = debugfs_create_file("debug", 892 if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR,
729 S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug); 893 sc->debug.debugfs_phy, sc, &fops_debug))
730 if (!sc->debug.debugfs_debug)
731 goto err; 894 goto err;
732#endif 895#endif
733 896
734 sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR, 897 if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy,
735 sc->debug.debugfs_phy, sc, &fops_dma); 898 sc, &fops_dma))
736 if (!sc->debug.debugfs_dma) 899 goto err;
900
901 if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy,
902 sc, &fops_interrupt))
903 goto err;
904
905 if (!debugfs_create_file("rcstat", S_IRUSR, sc->debug.debugfs_phy,
906 sc, &fops_rcstat))
907 goto err;
908
909 if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR,
910 sc->debug.debugfs_phy, sc, &fops_wiphy))
911 goto err;
912
913 if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy,
914 sc, &fops_xmit))
737 goto err; 915 goto err;
738 916
739 sc->debug.debugfs_interrupt = debugfs_create_file("interrupt", 917 if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy,
740 S_IRUSR, 918 sc, &fops_recv))
741 sc->debug.debugfs_phy,
742 sc, &fops_interrupt);
743 if (!sc->debug.debugfs_interrupt)
744 goto err; 919 goto err;
745 920
746 sc->debug.debugfs_rcstat = debugfs_create_file("rcstat", 921 if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
747 S_IRUSR, 922 sc->debug.debugfs_phy, sc, &fops_rx_chainmask))
748 sc->debug.debugfs_phy,
749 sc, &fops_rcstat);
750 if (!sc->debug.debugfs_rcstat)
751 goto err; 923 goto err;
752 924
753 sc->debug.debugfs_wiphy = debugfs_create_file( 925 if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
754 "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, 926 sc->debug.debugfs_phy, sc, &fops_tx_chainmask))
755 &fops_wiphy);
756 if (!sc->debug.debugfs_wiphy)
757 goto err; 927 goto err;
758 928
759 sc->debug.debugfs_xmit = debugfs_create_file("xmit", 929 if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR,
760 S_IRUSR, 930 sc->debug.debugfs_phy, sc, &fops_regidx))
761 sc->debug.debugfs_phy,
762 sc, &fops_xmit);
763 if (!sc->debug.debugfs_xmit)
764 goto err; 931 goto err;
765 932
766 sc->debug.debugfs_recv = debugfs_create_file("recv", 933 if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR,
767 S_IRUSR, 934 sc->debug.debugfs_phy, sc, &fops_regval))
768 sc->debug.debugfs_phy,
769 sc, &fops_recv);
770 if (!sc->debug.debugfs_recv)
771 goto err; 935 goto err;
772 936
937 sc->debug.regidx = 0;
773 return 0; 938 return 0;
774err: 939err:
775 ath9k_exit_debug(ah); 940 ath9k_exit_debug(ah);
@@ -781,14 +946,7 @@ void ath9k_exit_debug(struct ath_hw *ah)
781 struct ath_common *common = ath9k_hw_common(ah); 946 struct ath_common *common = ath9k_hw_common(ah);
782 struct ath_softc *sc = (struct ath_softc *) common->priv; 947 struct ath_softc *sc = (struct ath_softc *) common->priv;
783 948
784 debugfs_remove(sc->debug.debugfs_recv); 949 debugfs_remove_recursive(sc->debug.debugfs_phy);
785 debugfs_remove(sc->debug.debugfs_xmit);
786 debugfs_remove(sc->debug.debugfs_wiphy);
787 debugfs_remove(sc->debug.debugfs_rcstat);
788 debugfs_remove(sc->debug.debugfs_interrupt);
789 debugfs_remove(sc->debug.debugfs_dma);
790 debugfs_remove(sc->debug.debugfs_debug);
791 debugfs_remove(sc->debug.debugfs_phy);
792} 950}
793 951
794int ath9k_debug_create_root(void) 952int ath9k_debug_create_root(void)
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index c545960e7ec5..5147b8709e10 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -153,13 +153,7 @@ struct ath_stats {
153 153
154struct ath9k_debug { 154struct ath9k_debug {
155 struct dentry *debugfs_phy; 155 struct dentry *debugfs_phy;
156 struct dentry *debugfs_debug; 156 u32 regidx;
157 struct dentry *debugfs_dma;
158 struct dentry *debugfs_interrupt;
159 struct dentry *debugfs_rcstat;
160 struct dentry *debugfs_wiphy;
161 struct dentry *debugfs_xmit;
162 struct dentry *debugfs_recv;
163 struct ath_stats stats; 157 struct ath_stats stats;
164}; 158};
165 159
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 74872ca76f9a..46dc41a16faa 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -735,6 +735,14 @@ err:
735 return -ENOMEM; 735 return -ENOMEM;
736} 736}
737 737
738static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
739{
740 usb_kill_anchored_urbs(&hif_dev->regout_submitted);
741 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
742 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
743 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
744}
745
738static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) 746static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
739{ 747{
740 int transfer, err; 748 int transfer, err;
@@ -794,14 +802,6 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
794 goto err_fw_req; 802 goto err_fw_req;
795 } 803 }
796 804
797 /* Download firmware */
798 ret = ath9k_hif_usb_download_fw(hif_dev);
799 if (ret) {
800 dev_err(&hif_dev->udev->dev,
801 "ath9k_htc: Firmware - %s download failed\n", fw_name);
802 goto err_fw_download;
803 }
804
805 /* Alloc URBs */ 805 /* Alloc URBs */
806 ret = ath9k_hif_usb_alloc_urbs(hif_dev); 806 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
807 if (ret) { 807 if (ret) {
@@ -810,25 +810,25 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
810 goto err_urb; 810 goto err_urb;
811 } 811 }
812 812
813 /* Download firmware */
814 ret = ath9k_hif_usb_download_fw(hif_dev);
815 if (ret) {
816 dev_err(&hif_dev->udev->dev,
817 "ath9k_htc: Firmware - %s download failed\n", fw_name);
818 goto err_fw_download;
819 }
820
813 return 0; 821 return 0;
814 822
815err_urb:
816 /* Nothing */
817err_fw_download: 823err_fw_download:
824 ath9k_hif_usb_dealloc_urbs(hif_dev);
825err_urb:
818 release_firmware(hif_dev->firmware); 826 release_firmware(hif_dev->firmware);
819err_fw_req: 827err_fw_req:
820 hif_dev->firmware = NULL; 828 hif_dev->firmware = NULL;
821 return ret; 829 return ret;
822} 830}
823 831
824static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
825{
826 usb_kill_anchored_urbs(&hif_dev->regout_submitted);
827 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
828 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
829 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
830}
831
832static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev) 832static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
833{ 833{
834 ath9k_hif_usb_dealloc_urbs(hif_dev); 834 ath9k_hif_usb_dealloc_urbs(hif_dev);
@@ -859,21 +859,21 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
859#endif 859#endif
860 usb_set_intfdata(interface, hif_dev); 860 usb_set_intfdata(interface, hif_dev);
861 861
862 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb,
863 &hif_dev->udev->dev);
864 if (hif_dev->htc_handle == NULL) {
865 ret = -ENOMEM;
866 goto err_htc_hw_alloc;
867 }
868
862 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name); 869 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name);
863 if (ret) { 870 if (ret) {
864 ret = -EINVAL; 871 ret = -EINVAL;
865 goto err_hif_init_usb; 872 goto err_hif_init_usb;
866 } 873 }
867 874
868 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev); 875 ret = ath9k_htc_hw_init(hif_dev->htc_handle,
869 if (hif_dev->htc_handle == NULL) { 876 &hif_dev->udev->dev, hif_dev->device_id);
870 ret = -ENOMEM;
871 goto err_htc_hw_alloc;
872 }
873
874 ret = ath9k_htc_hw_init(&hif_usb, hif_dev->htc_handle, hif_dev,
875 &hif_dev->udev->dev, hif_dev->device_id,
876 ATH9K_HIF_USB);
877 if (ret) { 877 if (ret) {
878 ret = -EINVAL; 878 ret = -EINVAL;
879 goto err_htc_hw_init; 879 goto err_htc_hw_init;
@@ -884,10 +884,10 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
884 return 0; 884 return 0;
885 885
886err_htc_hw_init: 886err_htc_hw_init:
887 ath9k_htc_hw_free(hif_dev->htc_handle);
888err_htc_hw_alloc:
889 ath9k_hif_usb_dev_deinit(hif_dev); 887 ath9k_hif_usb_dev_deinit(hif_dev);
890err_hif_init_usb: 888err_hif_init_usb:
889 ath9k_htc_hw_free(hif_dev->htc_handle);
890err_htc_hw_alloc:
891 usb_set_intfdata(interface, NULL); 891 usb_set_intfdata(interface, NULL);
892 kfree(hif_dev); 892 kfree(hif_dev);
893 usb_put_dev(udev); 893 usb_put_dev(udev);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 17111fc1d2cc..dc015077a8d9 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -81,6 +81,11 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
81{ 81{
82 int time_left; 82 int time_left;
83 83
84 if (atomic_read(&priv->htc->tgt_ready) > 0) {
85 atomic_dec(&priv->htc->tgt_ready);
86 return 0;
87 }
88
84 /* Firmware can take up to 50ms to get ready, to be safe use 1 second */ 89 /* Firmware can take up to 50ms to get ready, to be safe use 1 second */
85 time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ); 90 time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ);
86 if (!time_left) { 91 if (!time_left) {
@@ -88,6 +93,8 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
88 return -ETIMEDOUT; 93 return -ETIMEDOUT;
89 } 94 }
90 95
96 atomic_dec(&priv->htc->tgt_ready);
97
91 return 0; 98 return 0;
92} 99}
93 100
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 6c386dad1d40..9d371c18eb41 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1452,6 +1452,8 @@ static void ath9k_htc_sta_notify(struct ieee80211_hw *hw,
1452 struct ath9k_htc_priv *priv = hw->priv; 1452 struct ath9k_htc_priv *priv = hw->priv;
1453 int ret; 1453 int ret;
1454 1454
1455 mutex_lock(&priv->mutex);
1456
1455 switch (cmd) { 1457 switch (cmd) {
1456 case STA_NOTIFY_ADD: 1458 case STA_NOTIFY_ADD:
1457 ret = ath9k_htc_add_station(priv, vif, sta); 1459 ret = ath9k_htc_add_station(priv, vif, sta);
@@ -1464,6 +1466,8 @@ static void ath9k_htc_sta_notify(struct ieee80211_hw *hw,
1464 default: 1466 default:
1465 break; 1467 break;
1466 } 1468 }
1469
1470 mutex_unlock(&priv->mutex);
1467} 1471}
1468 1472
1469static int ath9k_htc_conf_tx(struct ieee80211_hw *hw, u16 queue, 1473static int ath9k_htc_conf_tx(struct ieee80211_hw *hw, u16 queue,
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 7bf6ce1e7e2e..064397fd738e 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -39,7 +39,7 @@ static struct htc_endpoint *get_next_avail_ep(struct htc_endpoint *endpoint)
39{ 39{
40 enum htc_endpoint_id avail_epid; 40 enum htc_endpoint_id avail_epid;
41 41
42 for (avail_epid = ENDPOINT_MAX; avail_epid > ENDPOINT0; avail_epid--) 42 for (avail_epid = (ENDPOINT_MAX - 1); avail_epid > ENDPOINT0; avail_epid--)
43 if (endpoint[avail_epid].service_id == 0) 43 if (endpoint[avail_epid].service_id == 0)
44 return &endpoint[avail_epid]; 44 return &endpoint[avail_epid];
45 return NULL; 45 return NULL;
@@ -95,6 +95,7 @@ static void htc_process_target_rdy(struct htc_target *target,
95 endpoint = &target->endpoint[ENDPOINT0]; 95 endpoint = &target->endpoint[ENDPOINT0];
96 endpoint->service_id = HTC_CTRL_RSVD_SVC; 96 endpoint->service_id = HTC_CTRL_RSVD_SVC;
97 endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH; 97 endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH;
98 atomic_inc(&target->tgt_ready);
98 complete(&target->target_wait); 99 complete(&target->target_wait);
99} 100}
100 101
@@ -116,7 +117,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
116 max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len); 117 max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len);
117 endpoint = &target->endpoint[epid]; 118 endpoint = &target->endpoint[epid];
118 119
119 for (tepid = ENDPOINT_MAX; tepid > ENDPOINT0; tepid--) { 120 for (tepid = (ENDPOINT_MAX - 1); tepid > ENDPOINT0; tepid--) {
120 tmp_endpoint = &target->endpoint[tepid]; 121 tmp_endpoint = &target->endpoint[tepid];
121 if (tmp_endpoint->service_id == service_id) { 122 if (tmp_endpoint->service_id == service_id) {
122 tmp_endpoint->service_id = 0; 123 tmp_endpoint->service_id = 0;
@@ -124,7 +125,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
124 } 125 }
125 } 126 }
126 127
127 if (!tmp_endpoint) 128 if (tepid == ENDPOINT0)
128 return; 129 return;
129 130
130 endpoint->service_id = service_id; 131 endpoint->service_id = service_id;
@@ -297,7 +298,7 @@ void htc_stop(struct htc_target *target)
297 enum htc_endpoint_id epid; 298 enum htc_endpoint_id epid;
298 struct htc_endpoint *endpoint; 299 struct htc_endpoint *endpoint;
299 300
300 for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) { 301 for (epid = ENDPOINT0; epid < ENDPOINT_MAX; epid++) {
301 endpoint = &target->endpoint[epid]; 302 endpoint = &target->endpoint[epid];
302 if (endpoint->service_id != 0) 303 if (endpoint->service_id != 0)
303 target->hif->stop(target->hif_dev, endpoint->ul_pipeid); 304 target->hif->stop(target->hif_dev, endpoint->ul_pipeid);
@@ -309,7 +310,7 @@ void htc_start(struct htc_target *target)
309 enum htc_endpoint_id epid; 310 enum htc_endpoint_id epid;
310 struct htc_endpoint *endpoint; 311 struct htc_endpoint *endpoint;
311 312
312 for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) { 313 for (epid = ENDPOINT0; epid < ENDPOINT_MAX; epid++) {
313 endpoint = &target->endpoint[epid]; 314 endpoint = &target->endpoint[epid];
314 if (endpoint->service_id != 0) 315 if (endpoint->service_id != 0)
315 target->hif->start(target->hif_dev, 316 target->hif->start(target->hif_dev,
@@ -425,29 +426,19 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle,
425 } 426 }
426} 427}
427 428
428struct htc_target *ath9k_htc_hw_alloc(void *hif_handle) 429struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
430 struct ath9k_htc_hif *hif,
431 struct device *dev)
429{ 432{
433 struct htc_endpoint *endpoint;
430 struct htc_target *target; 434 struct htc_target *target;
431 435
432 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); 436 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL);
433 if (!target) 437 if (!target) {
434 printk(KERN_ERR "Unable to allocate memory for" 438 printk(KERN_ERR "Unable to allocate memory for"
435 "target device\n"); 439 "target device\n");
436 440 return NULL;
437 return target; 441 }
438}
439
440void ath9k_htc_hw_free(struct htc_target *htc)
441{
442 kfree(htc);
443}
444
445int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target,
446 void *hif_handle, struct device *dev, u16 devid,
447 enum ath9k_hif_transports transport)
448{
449 struct htc_endpoint *endpoint;
450 int err = 0;
451 442
452 init_completion(&target->target_wait); 443 init_completion(&target->target_wait);
453 init_completion(&target->cmd_wait); 444 init_completion(&target->cmd_wait);
@@ -461,8 +452,20 @@ int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target,
461 endpoint->ul_pipeid = hif->control_ul_pipe; 452 endpoint->ul_pipeid = hif->control_ul_pipe;
462 endpoint->dl_pipeid = hif->control_dl_pipe; 453 endpoint->dl_pipeid = hif->control_dl_pipe;
463 454
464 err = ath9k_htc_probe_device(target, dev, devid); 455 atomic_set(&target->tgt_ready, 0);
465 if (err) { 456
457 return target;
458}
459
460void ath9k_htc_hw_free(struct htc_target *htc)
461{
462 kfree(htc);
463}
464
465int ath9k_htc_hw_init(struct htc_target *target,
466 struct device *dev, u16 devid)
467{
468 if (ath9k_htc_probe_device(target, dev, devid)) {
466 printk(KERN_ERR "Failed to initialize the device\n"); 469 printk(KERN_ERR "Failed to initialize the device\n");
467 return -ENODEV; 470 return -ENODEV;
468 } 471 }
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.h b/drivers/net/wireless/ath/ath9k/htc_hst.h
index ea50ab032d20..faba6790328b 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.h
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.h
@@ -123,9 +123,6 @@ struct htc_endpoint {
123#define HTC_CONTROL_BUFFER_SIZE \ 123#define HTC_CONTROL_BUFFER_SIZE \
124 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr)) 124 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
125 125
126#define NUM_CONTROL_BUFFERS 8
127#define HST_ENDPOINT_MAX 8
128
129struct htc_control_buf { 126struct htc_control_buf {
130 struct htc_packet htc_pkt; 127 struct htc_packet htc_pkt;
131 u8 buf[HTC_CONTROL_BUFFER_SIZE]; 128 u8 buf[HTC_CONTROL_BUFFER_SIZE];
@@ -139,7 +136,7 @@ struct htc_target {
139 struct ath9k_htc_priv *drv_priv; 136 struct ath9k_htc_priv *drv_priv;
140 struct device *dev; 137 struct device *dev;
141 struct ath9k_htc_hif *hif; 138 struct ath9k_htc_hif *hif;
142 struct htc_endpoint endpoint[HST_ENDPOINT_MAX]; 139 struct htc_endpoint endpoint[ENDPOINT_MAX];
143 struct completion target_wait; 140 struct completion target_wait;
144 struct completion cmd_wait; 141 struct completion cmd_wait;
145 struct list_head list; 142 struct list_head list;
@@ -147,6 +144,7 @@ struct htc_target {
147 u16 credits; 144 u16 credits;
148 u16 credit_size; 145 u16 credit_size;
149 u8 htc_flags; 146 u8 htc_flags;
147 atomic_t tgt_ready;
150}; 148};
151 149
152enum htc_msg_id { 150enum htc_msg_id {
@@ -236,11 +234,12 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle,
236void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle, 234void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
237 struct sk_buff *skb, bool txok); 235 struct sk_buff *skb, bool txok);
238 236
239struct htc_target *ath9k_htc_hw_alloc(void *hif_handle); 237struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
238 struct ath9k_htc_hif *hif,
239 struct device *dev);
240void ath9k_htc_hw_free(struct htc_target *htc); 240void ath9k_htc_hw_free(struct htc_target *htc);
241int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target, 241int ath9k_htc_hw_init(struct htc_target *target,
242 void *hif_handle, struct device *dev, u16 devid, 242 struct device *dev, u16 devid);
243 enum ath9k_hif_transports transport);
244void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug); 243void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
245 244
246#endif /* HTC_HST_H */ 245#endif /* HTC_HST_H */
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index ac60c4ee62d3..ba139132c85f 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -150,11 +150,9 @@ static bool ath_rx_edma_buf_link(struct ath_softc *sc,
150static void ath_rx_addbuffer_edma(struct ath_softc *sc, 150static void ath_rx_addbuffer_edma(struct ath_softc *sc,
151 enum ath9k_rx_qtype qtype, int size) 151 enum ath9k_rx_qtype qtype, int size)
152{ 152{
153 struct ath_rx_edma *rx_edma;
154 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 153 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
155 u32 nbuf = 0; 154 u32 nbuf = 0;
156 155
157 rx_edma = &sc->rx.rx_edma[qtype];
158 if (list_empty(&sc->rx.rxbuf)) { 156 if (list_empty(&sc->rx.rxbuf)) {
159 ath_print(common, ATH_DBG_QUEUE, "No free rx buf available\n"); 157 ath_print(common, ATH_DBG_QUEUE, "No free rx buf available\n");
160 return; 158 return;
@@ -718,6 +716,7 @@ static bool ath_edma_get_buffers(struct ath_softc *sc,
718 __skb_unlink(skb, &rx_edma->rx_fifo); 716 __skb_unlink(skb, &rx_edma->rx_fifo);
719 list_add_tail(&bf->list, &sc->rx.rxbuf); 717 list_add_tail(&bf->list, &sc->rx.rxbuf);
720 ath_rx_edma_buf_link(sc, qtype); 718 ath_rx_edma_buf_link(sc, qtype);
719 return true;
721 } 720 }
722 skb_queue_tail(&rx_edma->rx_buffers, skb); 721 skb_queue_tail(&rx_edma->rx_buffers, skb);
723 722
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index f4c56121d387..e0b3e8d406b3 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -355,8 +355,7 @@ static struct hostap_bss_info *__hostap_add_bss(local_info_t *local, u8 *bssid,
355 list_del(&bss->list); 355 list_del(&bss->list);
356 local->num_bss_info--; 356 local->num_bss_info--;
357 } else { 357 } else {
358 bss = (struct hostap_bss_info *) 358 bss = kmalloc(sizeof(*bss), GFP_ATOMIC);
359 kmalloc(sizeof(*bss), GFP_ATOMIC);
360 if (bss == NULL) 359 if (bss == NULL)
361 return NULL; 360 return NULL;
362 } 361 }
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 9a082308a9d4..a85e43a8d758 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -3039,8 +3039,7 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
3039 p->length > 1024 || !p->pointer) 3039 p->length > 1024 || !p->pointer)
3040 return -EINVAL; 3040 return -EINVAL;
3041 3041
3042 param = (struct prism2_download_param *) 3042 param = kmalloc(p->length, GFP_KERNEL);
3043 kmalloc(p->length, GFP_KERNEL);
3044 if (param == NULL) 3043 if (param == NULL)
3045 return -ENOMEM; 3044 return -ENOMEM;
3046 3045
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index fb59af2d41c6..6be2992f8f21 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -212,7 +212,7 @@ static struct iwl_lib_ops iwl1000_lib = {
212 .temperature = iwlagn_temperature, 212 .temperature = iwlagn_temperature,
213 .set_ct_kill = iwl1000_set_ct_threshold, 213 .set_ct_kill = iwl1000_set_ct_threshold,
214 }, 214 },
215 .add_bcast_station = iwl_add_bcast_station, 215 .manage_ibss_station = iwlagn_manage_ibss_station,
216 .debugfs_ops = { 216 .debugfs_ops = {
217 .rx_stats_read = iwl_ucode_rx_stats_read, 217 .rx_stats_read = iwl_ucode_rx_stats_read,
218 .tx_stats_read = iwl_ucode_tx_stats_read, 218 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -224,7 +224,6 @@ static struct iwl_lib_ops iwl1000_lib = {
224}; 224};
225 225
226static const struct iwl_ops iwl1000_ops = { 226static const struct iwl_ops iwl1000_ops = {
227 .ucode = &iwlagn_ucode,
228 .lib = &iwl1000_lib, 227 .lib = &iwl1000_lib,
229 .hcmd = &iwlagn_hcmd, 228 .hcmd = &iwlagn_hcmd,
230 .utils = &iwlagn_hcmd_utils, 229 .utils = &iwlagn_hcmd_utils,
@@ -260,6 +259,9 @@ struct iwl_cfg iwl1000_bgn_cfg = {
260 .chain_noise_scale = 1000, 259 .chain_noise_scale = 1000,
261 .monitor_recover_period = IWL_MONITORING_PERIOD, 260 .monitor_recover_period = IWL_MONITORING_PERIOD,
262 .max_event_log_size = 128, 261 .max_event_log_size = 128,
262 .ucode_tracing = true,
263 .sensitivity_calib_by_driver = true,
264 .chain_noise_calib_by_driver = true,
263}; 265};
264 266
265struct iwl_cfg iwl1000_bg_cfg = { 267struct iwl_cfg iwl1000_bg_cfg = {
@@ -289,6 +291,9 @@ struct iwl_cfg iwl1000_bg_cfg = {
289 .chain_noise_scale = 1000, 291 .chain_noise_scale = 1000,
290 .monitor_recover_period = IWL_MONITORING_PERIOD, 292 .monitor_recover_period = IWL_MONITORING_PERIOD,
291 .max_event_log_size = 128, 293 .max_event_log_size = 128,
294 .ucode_tracing = true,
295 .sensitivity_calib_by_driver = true,
296 .chain_noise_calib_by_driver = true,
292}; 297};
293 298
294MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX)); 299MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 99b876a2feb9..068f7f8435c5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -391,6 +391,67 @@ static void iwl3945_accumulative_statistics(struct iwl_priv *priv,
391} 391}
392#endif 392#endif
393 393
394/**
395 * iwl3945_good_plcp_health - checks for plcp error.
396 *
397 * When the plcp error is exceeding the thresholds, reset the radio
398 * to improve the throughput.
399 */
400static bool iwl3945_good_plcp_health(struct iwl_priv *priv,
401 struct iwl_rx_packet *pkt)
402{
403 bool rc = true;
404 struct iwl3945_notif_statistics current_stat;
405 int combined_plcp_delta;
406 unsigned int plcp_msec;
407 unsigned long plcp_received_jiffies;
408
409 memcpy(&current_stat, pkt->u.raw, sizeof(struct
410 iwl3945_notif_statistics));
411 /*
412 * check for plcp_err and trigger radio reset if it exceeds
413 * the plcp error threshold plcp_delta.
414 */
415 plcp_received_jiffies = jiffies;
416 plcp_msec = jiffies_to_msecs((long) plcp_received_jiffies -
417 (long) priv->plcp_jiffies);
418 priv->plcp_jiffies = plcp_received_jiffies;
419 /*
420 * check to make sure plcp_msec is not 0 to prevent division
421 * by zero.
422 */
423 if (plcp_msec) {
424 combined_plcp_delta =
425 (le32_to_cpu(current_stat.rx.ofdm.plcp_err) -
426 le32_to_cpu(priv->_3945.statistics.rx.ofdm.plcp_err));
427
428 if ((combined_plcp_delta > 0) &&
429 ((combined_plcp_delta * 100) / plcp_msec) >
430 priv->cfg->plcp_delta_threshold) {
431 /*
432 * if plcp_err exceed the threshold, the following
433 * data is printed in csv format:
434 * Text: plcp_err exceeded %d,
435 * Received ofdm.plcp_err,
436 * Current ofdm.plcp_err,
437 * combined_plcp_delta,
438 * plcp_msec
439 */
440 IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, "
441 "%u, %d, %u mSecs\n",
442 priv->cfg->plcp_delta_threshold,
443 le32_to_cpu(current_stat.rx.ofdm.plcp_err),
444 combined_plcp_delta, plcp_msec);
445 /*
446 * Reset the RF radio due to the high plcp
447 * error rate
448 */
449 rc = false;
450 }
451 }
452 return rc;
453}
454
394void iwl3945_hw_rx_statistics(struct iwl_priv *priv, 455void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
395 struct iwl_rx_mem_buffer *rxb) 456 struct iwl_rx_mem_buffer *rxb)
396{ 457{
@@ -402,6 +463,7 @@ void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
402#ifdef CONFIG_IWLWIFI_DEBUG 463#ifdef CONFIG_IWLWIFI_DEBUG
403 iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); 464 iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw);
404#endif 465#endif
466 iwl_recover_from_statistics(priv, pkt);
405 467
406 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); 468 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics));
407} 469}
@@ -885,7 +947,8 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
885 tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); 947 tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]);
886} 948}
887 949
888u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate, u8 flags) 950static u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id,
951 u16 tx_rate, u8 flags)
889{ 952{
890 unsigned long flags_spin; 953 unsigned long flags_spin;
891 struct iwl_station_entry *station; 954 struct iwl_station_entry *station;
@@ -1715,6 +1778,11 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv)
1715 int ref_temp; 1778 int ref_temp;
1716 int temperature = priv->temperature; 1779 int temperature = priv->temperature;
1717 1780
1781 if (priv->disable_tx_power_cal ||
1782 test_bit(STATUS_SCANNING, &priv->status)) {
1783 /* do not perform tx power calibration */
1784 return 0;
1785 }
1718 /* set up new Tx power info for each and every channel, 2.4 and 5.x */ 1786 /* set up new Tx power info for each and every channel, 2.4 and 5.x */
1719 for (i = 0; i < priv->channel_count; i++) { 1787 for (i = 0; i < priv->channel_count; i++) {
1720 ch_info = &priv->channel_info[i]; 1788 ch_info = &priv->channel_info[i];
@@ -1925,7 +1993,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1925 "configuration (%d).\n", rc); 1993 "configuration (%d).\n", rc);
1926 return rc; 1994 return rc;
1927 } 1995 }
1928 iwl_clear_ucode_stations(priv, false); 1996 iwl_clear_ucode_stations(priv);
1929 iwl_restore_stations(priv); 1997 iwl_restore_stations(priv);
1930 } 1998 }
1931 1999
@@ -1958,7 +2026,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1958 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); 2026 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
1959 2027
1960 if (!new_assoc) { 2028 if (!new_assoc) {
1961 iwl_clear_ucode_stations(priv, false); 2029 iwl_clear_ucode_stations(priv);
1962 iwl_restore_stations(priv); 2030 iwl_restore_stations(priv);
1963 } 2031 }
1964 2032
@@ -2391,6 +2459,30 @@ static u16 iwl3945_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
2391 return (u16)sizeof(struct iwl3945_addsta_cmd); 2459 return (u16)sizeof(struct iwl3945_addsta_cmd);
2392} 2460}
2393 2461
2462static int iwl3945_manage_ibss_station(struct iwl_priv *priv,
2463 struct ieee80211_vif *vif, bool add)
2464{
2465 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
2466 int ret;
2467
2468 if (add) {
2469 ret = iwl_add_bssid_station(priv, vif->bss_conf.bssid, false,
2470 &vif_priv->ibss_bssid_sta_id);
2471 if (ret)
2472 return ret;
2473
2474 iwl3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id,
2475 (priv->band == IEEE80211_BAND_5GHZ) ?
2476 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP,
2477 CMD_ASYNC);
2478 iwl3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id);
2479
2480 return 0;
2481 }
2482
2483 return iwl_remove_station(priv, vif_priv->ibss_bssid_sta_id,
2484 vif->bss_conf.bssid);
2485}
2394 2486
2395/** 2487/**
2396 * iwl3945_init_hw_rate_table - Initialize the hardware rate fallback table 2488 * iwl3945_init_hw_rate_table - Initialize the hardware rate fallback table
@@ -2720,51 +2812,12 @@ static int iwl3945_load_bsm(struct iwl_priv *priv)
2720 return 0; 2812 return 0;
2721} 2813}
2722 2814
2723#define IWL3945_UCODE_GET(item) \
2724static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode,\
2725 u32 api_ver) \
2726{ \
2727 return le32_to_cpu(ucode->u.v1.item); \
2728}
2729
2730static u32 iwl3945_ucode_get_header_size(u32 api_ver)
2731{
2732 return UCODE_HEADER_SIZE(1);
2733}
2734static u32 iwl3945_ucode_get_build(const struct iwl_ucode_header *ucode,
2735 u32 api_ver)
2736{
2737 return 0;
2738}
2739static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode,
2740 u32 api_ver)
2741{
2742 return (u8 *) ucode->u.v1.data;
2743}
2744
2745IWL3945_UCODE_GET(inst_size);
2746IWL3945_UCODE_GET(data_size);
2747IWL3945_UCODE_GET(init_size);
2748IWL3945_UCODE_GET(init_data_size);
2749IWL3945_UCODE_GET(boot_size);
2750
2751static struct iwl_hcmd_ops iwl3945_hcmd = { 2815static struct iwl_hcmd_ops iwl3945_hcmd = {
2752 .rxon_assoc = iwl3945_send_rxon_assoc, 2816 .rxon_assoc = iwl3945_send_rxon_assoc,
2753 .commit_rxon = iwl3945_commit_rxon, 2817 .commit_rxon = iwl3945_commit_rxon,
2754 .send_bt_config = iwl_send_bt_config, 2818 .send_bt_config = iwl_send_bt_config,
2755}; 2819};
2756 2820
2757static struct iwl_ucode_ops iwl3945_ucode = {
2758 .get_header_size = iwl3945_ucode_get_header_size,
2759 .get_build = iwl3945_ucode_get_build,
2760 .get_inst_size = iwl3945_ucode_get_inst_size,
2761 .get_data_size = iwl3945_ucode_get_data_size,
2762 .get_init_size = iwl3945_ucode_get_init_size,
2763 .get_init_data_size = iwl3945_ucode_get_init_data_size,
2764 .get_boot_size = iwl3945_ucode_get_boot_size,
2765 .get_data = iwl3945_ucode_get_data,
2766};
2767
2768static struct iwl_lib_ops iwl3945_lib = { 2821static struct iwl_lib_ops iwl3945_lib = {
2769 .txq_attach_buf_to_tfd = iwl3945_hw_txq_attach_buf_to_tfd, 2822 .txq_attach_buf_to_tfd = iwl3945_hw_txq_attach_buf_to_tfd,
2770 .txq_free_tfd = iwl3945_hw_txq_free_tfd, 2823 .txq_free_tfd = iwl3945_hw_txq_free_tfd,
@@ -2798,7 +2851,8 @@ static struct iwl_lib_ops iwl3945_lib = {
2798 .post_associate = iwl3945_post_associate, 2851 .post_associate = iwl3945_post_associate,
2799 .isr = iwl_isr_legacy, 2852 .isr = iwl_isr_legacy,
2800 .config_ap = iwl3945_config_ap, 2853 .config_ap = iwl3945_config_ap,
2801 .add_bcast_station = iwl3945_add_bcast_station, 2854 .manage_ibss_station = iwl3945_manage_ibss_station,
2855 .check_plcp_health = iwl3945_good_plcp_health,
2802 2856
2803 .debugfs_ops = { 2857 .debugfs_ops = {
2804 .rx_stats_read = iwl3945_ucode_rx_stats_read, 2858 .rx_stats_read = iwl3945_ucode_rx_stats_read,
@@ -2815,7 +2869,6 @@ static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
2815}; 2869};
2816 2870
2817static const struct iwl_ops iwl3945_ops = { 2871static const struct iwl_ops iwl3945_ops = {
2818 .ucode = &iwl3945_ucode,
2819 .lib = &iwl3945_lib, 2872 .lib = &iwl3945_lib,
2820 .hcmd = &iwl3945_hcmd, 2873 .hcmd = &iwl3945_hcmd,
2821 .utils = &iwl3945_hcmd_utils, 2874 .utils = &iwl3945_hcmd_utils,
@@ -2840,9 +2893,10 @@ static struct iwl_cfg iwl3945_bg_cfg = {
2840 .ht_greenfield_support = false, 2893 .ht_greenfield_support = false,
2841 .led_compensation = 64, 2894 .led_compensation = 64,
2842 .broken_powersave = true, 2895 .broken_powersave = true,
2843 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 2896 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
2844 .monitor_recover_period = IWL_MONITORING_PERIOD, 2897 .monitor_recover_period = IWL_MONITORING_PERIOD,
2845 .max_event_log_size = 512, 2898 .max_event_log_size = 512,
2899 .tx_power_by_driver = true,
2846}; 2900};
2847 2901
2848static struct iwl_cfg iwl3945_abg_cfg = { 2902static struct iwl_cfg iwl3945_abg_cfg = {
@@ -2860,9 +2914,10 @@ static struct iwl_cfg iwl3945_abg_cfg = {
2860 .ht_greenfield_support = false, 2914 .ht_greenfield_support = false,
2861 .led_compensation = 64, 2915 .led_compensation = 64,
2862 .broken_powersave = true, 2916 .broken_powersave = true,
2863 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 2917 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
2864 .monitor_recover_period = IWL_MONITORING_PERIOD, 2918 .monitor_recover_period = IWL_MONITORING_PERIOD,
2865 .max_event_log_size = 512, 2919 .max_event_log_size = 512,
2920 .tx_power_by_driver = true,
2866}; 2921};
2867 2922
2868DEFINE_PCI_DEVICE_TABLE(iwl3945_hw_card_ids) = { 2923DEFINE_PCI_DEVICE_TABLE(iwl3945_hw_card_ids) = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 643adb644bb8..bb2aeebf3652 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -106,7 +106,12 @@ struct iwl3945_rs_sta {
106}; 106};
107 107
108 108
109/*
110 * The common struct MUST be first because it is shared between
111 * 3945 and agn!
112 */
109struct iwl3945_sta_priv { 113struct iwl3945_sta_priv {
114 struct iwl_station_priv_common common;
110 struct iwl3945_rs_sta rs_sta; 115 struct iwl3945_rs_sta rs_sta;
111}; 116};
112 117
@@ -211,13 +216,6 @@ extern int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
211 char **buf, bool display); 216 char **buf, bool display);
212extern void iwl3945_dump_nic_error_log(struct iwl_priv *priv); 217extern void iwl3945_dump_nic_error_log(struct iwl_priv *priv);
213 218
214/*
215 * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
216 * call this... todo... fix that.
217*/
218extern u8 iwl3945_sync_station(struct iwl_priv *priv, int sta_id,
219 u16 tx_rate, u8 flags);
220
221/****************************************************************************** 219/******************************************************************************
222 * 220 *
223 * Functions implemented in iwl-[34]*.c which are forward declared here 221 * Functions implemented in iwl-[34]*.c which are forward declared here
@@ -268,8 +266,10 @@ void iwl3945_reply_statistics(struct iwl_priv *priv,
268 struct iwl_rx_mem_buffer *rxb); 266 struct iwl_rx_mem_buffer *rxb);
269extern void iwl3945_disable_events(struct iwl_priv *priv); 267extern void iwl3945_disable_events(struct iwl_priv *priv);
270extern int iwl4965_get_temperature(const struct iwl_priv *priv); 268extern int iwl4965_get_temperature(const struct iwl_priv *priv);
271extern void iwl3945_post_associate(struct iwl_priv *priv); 269extern void iwl3945_post_associate(struct iwl_priv *priv,
272extern void iwl3945_config_ap(struct iwl_priv *priv); 270 struct ieee80211_vif *vif);
271extern void iwl3945_config_ap(struct iwl_priv *priv,
272 struct ieee80211_vif *vif);
273 273
274/** 274/**
275 * iwl3945_hw_find_station - Find station id for a given BSSID 275 * iwl3945_hw_find_station - Find station id for a given BSSID
@@ -288,8 +288,6 @@ extern __le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv);
288extern int iwl3945_init_hw_rate_table(struct iwl_priv *priv); 288extern int iwl3945_init_hw_rate_table(struct iwl_priv *priv);
289extern void iwl3945_reg_txpower_periodic(struct iwl_priv *priv); 289extern void iwl3945_reg_txpower_periodic(struct iwl_priv *priv);
290extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv); 290extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv);
291extern u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id,
292 u16 tx_rate, u8 flags);
293 291
294extern const struct iwl_channel_info *iwl3945_get_channel_info( 292extern const struct iwl_channel_info *iwl3945_get_channel_info(
295 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel); 293 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
@@ -297,7 +295,7 @@ extern const struct iwl_channel_info *iwl3945_get_channel_info(
297extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate); 295extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate);
298 296
299/* scanning */ 297/* scanning */
300void iwl3945_request_scan(struct iwl_priv *priv); 298void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
301 299
302/* Requires full declaration of iwl_priv before including */ 300/* Requires full declaration of iwl_priv before including */
303#include "iwl-io.h" 301#include "iwl-io.h"
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 136c29067489..d3afddae8d9f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1953,6 +1953,60 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
1953 return 0; 1953 return 0;
1954} 1954}
1955 1955
1956static u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
1957{
1958 int i;
1959 int start = 0;
1960 int ret = IWL_INVALID_STATION;
1961 unsigned long flags;
1962
1963 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
1964 (priv->iw_mode == NL80211_IFTYPE_AP))
1965 start = IWL_STA_ID;
1966
1967 if (is_broadcast_ether_addr(addr))
1968 return priv->hw_params.bcast_sta_id;
1969
1970 spin_lock_irqsave(&priv->sta_lock, flags);
1971 for (i = start; i < priv->hw_params.max_stations; i++)
1972 if (priv->stations[i].used &&
1973 (!compare_ether_addr(priv->stations[i].sta.sta.addr,
1974 addr))) {
1975 ret = i;
1976 goto out;
1977 }
1978
1979 IWL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n",
1980 addr, priv->num_stations);
1981
1982 out:
1983 /*
1984 * It may be possible that more commands interacting with stations
1985 * arrive before we completed processing the adding of
1986 * station
1987 */
1988 if (ret != IWL_INVALID_STATION &&
1989 (!(priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) ||
1990 ((priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) &&
1991 (priv->stations[ret].used & IWL_STA_UCODE_INPROGRESS)))) {
1992 IWL_ERR(priv, "Requested station info for sta %d before ready.\n",
1993 ret);
1994 ret = IWL_INVALID_STATION;
1995 }
1996 spin_unlock_irqrestore(&priv->sta_lock, flags);
1997 return ret;
1998}
1999
2000static int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
2001{
2002 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
2003 return IWL_AP_ID;
2004 } else {
2005 u8 *da = ieee80211_get_DA(hdr);
2006 return iwl_find_station(priv, da);
2007 }
2008}
2009
1956/** 2010/**
1957 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response 2011 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response
1958 */ 2012 */
@@ -2112,34 +2166,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
2112 cancel_work_sync(&priv->txpower_work); 2166 cancel_work_sync(&priv->txpower_work);
2113} 2167}
2114 2168
2115#define IWL4965_UCODE_GET(item) \
2116static u32 iwl4965_ucode_get_##item(const struct iwl_ucode_header *ucode,\
2117 u32 api_ver) \
2118{ \
2119 return le32_to_cpu(ucode->u.v1.item); \
2120}
2121
2122static u32 iwl4965_ucode_get_header_size(u32 api_ver)
2123{
2124 return UCODE_HEADER_SIZE(1);
2125}
2126static u32 iwl4965_ucode_get_build(const struct iwl_ucode_header *ucode,
2127 u32 api_ver)
2128{
2129 return 0;
2130}
2131static u8 *iwl4965_ucode_get_data(const struct iwl_ucode_header *ucode,
2132 u32 api_ver)
2133{
2134 return (u8 *) ucode->u.v1.data;
2135}
2136
2137IWL4965_UCODE_GET(inst_size);
2138IWL4965_UCODE_GET(data_size);
2139IWL4965_UCODE_GET(init_size);
2140IWL4965_UCODE_GET(init_data_size);
2141IWL4965_UCODE_GET(boot_size);
2142
2143static struct iwl_hcmd_ops iwl4965_hcmd = { 2169static struct iwl_hcmd_ops iwl4965_hcmd = {
2144 .rxon_assoc = iwl4965_send_rxon_assoc, 2170 .rxon_assoc = iwl4965_send_rxon_assoc,
2145 .commit_rxon = iwl_commit_rxon, 2171 .commit_rxon = iwl_commit_rxon,
@@ -2147,16 +2173,6 @@ static struct iwl_hcmd_ops iwl4965_hcmd = {
2147 .send_bt_config = iwl_send_bt_config, 2173 .send_bt_config = iwl_send_bt_config,
2148}; 2174};
2149 2175
2150static struct iwl_ucode_ops iwl4965_ucode = {
2151 .get_header_size = iwl4965_ucode_get_header_size,
2152 .get_build = iwl4965_ucode_get_build,
2153 .get_inst_size = iwl4965_ucode_get_inst_size,
2154 .get_data_size = iwl4965_ucode_get_data_size,
2155 .get_init_size = iwl4965_ucode_get_init_size,
2156 .get_init_data_size = iwl4965_ucode_get_init_data_size,
2157 .get_boot_size = iwl4965_ucode_get_boot_size,
2158 .get_data = iwl4965_ucode_get_data,
2159};
2160static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { 2176static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
2161 .get_hcmd_size = iwl4965_get_hcmd_size, 2177 .get_hcmd_size = iwl4965_get_hcmd_size,
2162 .build_addsta_hcmd = iwl4965_build_addsta_hcmd, 2178 .build_addsta_hcmd = iwl4965_build_addsta_hcmd,
@@ -2218,7 +2234,7 @@ static struct iwl_lib_ops iwl4965_lib = {
2218 .temperature = iwl4965_temperature_calib, 2234 .temperature = iwl4965_temperature_calib,
2219 .set_ct_kill = iwl4965_set_ct_threshold, 2235 .set_ct_kill = iwl4965_set_ct_threshold,
2220 }, 2236 },
2221 .add_bcast_station = iwl_add_bcast_station, 2237 .manage_ibss_station = iwlagn_manage_ibss_station,
2222 .debugfs_ops = { 2238 .debugfs_ops = {
2223 .rx_stats_read = iwl_ucode_rx_stats_read, 2239 .rx_stats_read = iwl_ucode_rx_stats_read,
2224 .tx_stats_read = iwl_ucode_tx_stats_read, 2240 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -2228,7 +2244,6 @@ static struct iwl_lib_ops iwl4965_lib = {
2228}; 2244};
2229 2245
2230static const struct iwl_ops iwl4965_ops = { 2246static const struct iwl_ops iwl4965_ops = {
2231 .ucode = &iwl4965_ucode,
2232 .lib = &iwl4965_lib, 2247 .lib = &iwl4965_lib,
2233 .hcmd = &iwl4965_hcmd, 2248 .hcmd = &iwl4965_hcmd,
2234 .utils = &iwl4965_hcmd_utils, 2249 .utils = &iwl4965_hcmd_utils,
@@ -2262,7 +2277,10 @@ struct iwl_cfg iwl4965_agn_cfg = {
2262 .monitor_recover_period = IWL_MONITORING_PERIOD, 2277 .monitor_recover_period = IWL_MONITORING_PERIOD,
2263 .temperature_kelvin = true, 2278 .temperature_kelvin = true,
2264 .max_event_log_size = 512, 2279 .max_event_log_size = 512,
2265 2280 .tx_power_by_driver = true,
2281 .ucode_tracing = true,
2282 .sensitivity_calib_by_driver = true,
2283 .chain_noise_calib_by_driver = true,
2266 /* 2284 /*
2267 * Force use of chains B and C for scan RX on 5 GHz band 2285 * Force use of chains B and C for scan RX on 5 GHz band
2268 * because the device has off-channel reception on chain A. 2286 * because the device has off-channel reception on chain A.
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 115d3ea1142f..a28af7eb67eb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -351,7 +351,7 @@ static struct iwl_lib_ops iwl5000_lib = {
351 .temperature = iwlagn_temperature, 351 .temperature = iwlagn_temperature,
352 .set_ct_kill = iwl5000_set_ct_threshold, 352 .set_ct_kill = iwl5000_set_ct_threshold,
353 }, 353 },
354 .add_bcast_station = iwl_add_bcast_station, 354 .manage_ibss_station = iwlagn_manage_ibss_station,
355 .debugfs_ops = { 355 .debugfs_ops = {
356 .rx_stats_read = iwl_ucode_rx_stats_read, 356 .rx_stats_read = iwl_ucode_rx_stats_read,
357 .tx_stats_read = iwl_ucode_tx_stats_read, 357 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -413,7 +413,7 @@ static struct iwl_lib_ops iwl5150_lib = {
413 .temperature = iwl5150_temperature, 413 .temperature = iwl5150_temperature,
414 .set_ct_kill = iwl5150_set_ct_threshold, 414 .set_ct_kill = iwl5150_set_ct_threshold,
415 }, 415 },
416 .add_bcast_station = iwl_add_bcast_station, 416 .manage_ibss_station = iwlagn_manage_ibss_station,
417 .debugfs_ops = { 417 .debugfs_ops = {
418 .rx_stats_read = iwl_ucode_rx_stats_read, 418 .rx_stats_read = iwl_ucode_rx_stats_read,
419 .tx_stats_read = iwl_ucode_tx_stats_read, 419 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -425,7 +425,6 @@ static struct iwl_lib_ops iwl5150_lib = {
425}; 425};
426 426
427static const struct iwl_ops iwl5000_ops = { 427static const struct iwl_ops iwl5000_ops = {
428 .ucode = &iwlagn_ucode,
429 .lib = &iwl5000_lib, 428 .lib = &iwl5000_lib,
430 .hcmd = &iwlagn_hcmd, 429 .hcmd = &iwlagn_hcmd,
431 .utils = &iwlagn_hcmd_utils, 430 .utils = &iwlagn_hcmd_utils,
@@ -433,7 +432,6 @@ static const struct iwl_ops iwl5000_ops = {
433}; 432};
434 433
435static const struct iwl_ops iwl5150_ops = { 434static const struct iwl_ops iwl5150_ops = {
436 .ucode = &iwlagn_ucode,
437 .lib = &iwl5150_lib, 435 .lib = &iwl5150_lib,
438 .hcmd = &iwlagn_hcmd, 436 .hcmd = &iwlagn_hcmd,
439 .utils = &iwlagn_hcmd_utils, 437 .utils = &iwlagn_hcmd_utils,
@@ -466,6 +464,9 @@ struct iwl_cfg iwl5300_agn_cfg = {
466 .chain_noise_scale = 1000, 464 .chain_noise_scale = 1000,
467 .monitor_recover_period = IWL_MONITORING_PERIOD, 465 .monitor_recover_period = IWL_MONITORING_PERIOD,
468 .max_event_log_size = 512, 466 .max_event_log_size = 512,
467 .ucode_tracing = true,
468 .sensitivity_calib_by_driver = true,
469 .chain_noise_calib_by_driver = true,
469}; 470};
470 471
471struct iwl_cfg iwl5100_bgn_cfg = { 472struct iwl_cfg iwl5100_bgn_cfg = {
@@ -494,6 +495,9 @@ struct iwl_cfg iwl5100_bgn_cfg = {
494 .chain_noise_scale = 1000, 495 .chain_noise_scale = 1000,
495 .monitor_recover_period = IWL_MONITORING_PERIOD, 496 .monitor_recover_period = IWL_MONITORING_PERIOD,
496 .max_event_log_size = 512, 497 .max_event_log_size = 512,
498 .ucode_tracing = true,
499 .sensitivity_calib_by_driver = true,
500 .chain_noise_calib_by_driver = true,
497}; 501};
498 502
499struct iwl_cfg iwl5100_abg_cfg = { 503struct iwl_cfg iwl5100_abg_cfg = {
@@ -520,6 +524,9 @@ struct iwl_cfg iwl5100_abg_cfg = {
520 .chain_noise_scale = 1000, 524 .chain_noise_scale = 1000,
521 .monitor_recover_period = IWL_MONITORING_PERIOD, 525 .monitor_recover_period = IWL_MONITORING_PERIOD,
522 .max_event_log_size = 512, 526 .max_event_log_size = 512,
527 .ucode_tracing = true,
528 .sensitivity_calib_by_driver = true,
529 .chain_noise_calib_by_driver = true,
523}; 530};
524 531
525struct iwl_cfg iwl5100_agn_cfg = { 532struct iwl_cfg iwl5100_agn_cfg = {
@@ -548,6 +555,9 @@ struct iwl_cfg iwl5100_agn_cfg = {
548 .chain_noise_scale = 1000, 555 .chain_noise_scale = 1000,
549 .monitor_recover_period = IWL_MONITORING_PERIOD, 556 .monitor_recover_period = IWL_MONITORING_PERIOD,
550 .max_event_log_size = 512, 557 .max_event_log_size = 512,
558 .ucode_tracing = true,
559 .sensitivity_calib_by_driver = true,
560 .chain_noise_calib_by_driver = true,
551}; 561};
552 562
553struct iwl_cfg iwl5350_agn_cfg = { 563struct iwl_cfg iwl5350_agn_cfg = {
@@ -576,6 +586,9 @@ struct iwl_cfg iwl5350_agn_cfg = {
576 .chain_noise_scale = 1000, 586 .chain_noise_scale = 1000,
577 .monitor_recover_period = IWL_MONITORING_PERIOD, 587 .monitor_recover_period = IWL_MONITORING_PERIOD,
578 .max_event_log_size = 512, 588 .max_event_log_size = 512,
589 .ucode_tracing = true,
590 .sensitivity_calib_by_driver = true,
591 .chain_noise_calib_by_driver = true,
579}; 592};
580 593
581struct iwl_cfg iwl5150_agn_cfg = { 594struct iwl_cfg iwl5150_agn_cfg = {
@@ -604,6 +617,9 @@ struct iwl_cfg iwl5150_agn_cfg = {
604 .chain_noise_scale = 1000, 617 .chain_noise_scale = 1000,
605 .monitor_recover_period = IWL_MONITORING_PERIOD, 618 .monitor_recover_period = IWL_MONITORING_PERIOD,
606 .max_event_log_size = 512, 619 .max_event_log_size = 512,
620 .ucode_tracing = true,
621 .sensitivity_calib_by_driver = true,
622 .chain_noise_calib_by_driver = true,
607}; 623};
608 624
609struct iwl_cfg iwl5150_abg_cfg = { 625struct iwl_cfg iwl5150_abg_cfg = {
@@ -630,6 +646,9 @@ struct iwl_cfg iwl5150_abg_cfg = {
630 .chain_noise_scale = 1000, 646 .chain_noise_scale = 1000,
631 .monitor_recover_period = IWL_MONITORING_PERIOD, 647 .monitor_recover_period = IWL_MONITORING_PERIOD,
632 .max_event_log_size = 512, 648 .max_event_log_size = 512,
649 .ucode_tracing = true,
650 .sensitivity_calib_by_driver = true,
651 .chain_noise_calib_by_driver = true,
633}; 652};
634 653
635MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX)); 654MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 7acef703253a..9fbf54cd3e1a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -67,9 +67,10 @@
67#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode" 67#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode"
68#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api) 68#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api)
69 69
70#define IWL6000G2_FW_PRE "iwlwifi-6005-" 70#define IWL6000G2A_FW_PRE "iwlwifi-6000g2a-"
71#define _IWL6000G2_MODULE_FIRMWARE(api) IWL6000G2_FW_PRE #api ".ucode" 71#define _IWL6000G2A_MODULE_FIRMWARE(api) IWL6000G2A_FW_PRE #api ".ucode"
72#define IWL6000G2_MODULE_FIRMWARE(api) _IWL6000G2_MODULE_FIRMWARE(api) 72#define IWL6000G2A_MODULE_FIRMWARE(api) _IWL6000G2A_MODULE_FIRMWARE(api)
73
73 74
74static void iwl6000_set_ct_threshold(struct iwl_priv *priv) 75static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
75{ 76{
@@ -316,7 +317,7 @@ static struct iwl_lib_ops iwl6000_lib = {
316 .temperature = iwlagn_temperature, 317 .temperature = iwlagn_temperature,
317 .set_ct_kill = iwl6000_set_ct_threshold, 318 .set_ct_kill = iwl6000_set_ct_threshold,
318 }, 319 },
319 .add_bcast_station = iwl_add_bcast_station, 320 .manage_ibss_station = iwlagn_manage_ibss_station,
320 .debugfs_ops = { 321 .debugfs_ops = {
321 .rx_stats_read = iwl_ucode_rx_stats_read, 322 .rx_stats_read = iwl_ucode_rx_stats_read,
322 .tx_stats_read = iwl_ucode_tx_stats_read, 323 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -328,7 +329,6 @@ static struct iwl_lib_ops iwl6000_lib = {
328}; 329};
329 330
330static const struct iwl_ops iwl6000_ops = { 331static const struct iwl_ops iwl6000_ops = {
331 .ucode = &iwlagn_ucode,
332 .lib = &iwl6000_lib, 332 .lib = &iwl6000_lib,
333 .hcmd = &iwlagn_hcmd, 333 .hcmd = &iwlagn_hcmd,
334 .utils = &iwlagn_hcmd_utils, 334 .utils = &iwlagn_hcmd_utils,
@@ -389,7 +389,7 @@ static struct iwl_lib_ops iwl6050_lib = {
389 .set_ct_kill = iwl6000_set_ct_threshold, 389 .set_ct_kill = iwl6000_set_ct_threshold,
390 .set_calib_version = iwl6050_set_calib_version, 390 .set_calib_version = iwl6050_set_calib_version,
391 }, 391 },
392 .add_bcast_station = iwl_add_bcast_station, 392 .manage_ibss_station = iwlagn_manage_ibss_station,
393 .debugfs_ops = { 393 .debugfs_ops = {
394 .rx_stats_read = iwl_ucode_rx_stats_read, 394 .rx_stats_read = iwl_ucode_rx_stats_read,
395 .tx_stats_read = iwl_ucode_tx_stats_read, 395 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -401,19 +401,16 @@ static struct iwl_lib_ops iwl6050_lib = {
401}; 401};
402 402
403static const struct iwl_ops iwl6050_ops = { 403static const struct iwl_ops iwl6050_ops = {
404 .ucode = &iwlagn_ucode,
405 .lib = &iwl6050_lib, 404 .lib = &iwl6050_lib,
406 .hcmd = &iwlagn_hcmd, 405 .hcmd = &iwlagn_hcmd,
407 .utils = &iwlagn_hcmd_utils, 406 .utils = &iwlagn_hcmd_utils,
408 .led = &iwlagn_led_ops, 407 .led = &iwlagn_led_ops,
409}; 408};
410 409
411/* 410
412 * "i": Internal configuration, use internal Power Amplifier 411struct iwl_cfg iwl6000g2a_2agn_cfg = {
413 */ 412 .name = "6000 Series 2x2 AGN Gen2a",
414struct iwl_cfg iwl6000g2_2agn_cfg = { 413 .fw_name_pre = IWL6000G2A_FW_PRE,
415 .name = "6000 Series 2x2 AGN Gen2",
416 .fw_name_pre = IWL6000G2_FW_PRE,
417 .ucode_api_max = IWL6000G2_UCODE_API_MAX, 414 .ucode_api_max = IWL6000G2_UCODE_API_MAX,
418 .ucode_api_min = IWL6000G2_UCODE_API_MIN, 415 .ucode_api_min = IWL6000G2_UCODE_API_MIN,
419 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 416 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
@@ -442,9 +439,15 @@ struct iwl_cfg iwl6000g2_2agn_cfg = {
442 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 439 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
443 .chain_noise_scale = 1000, 440 .chain_noise_scale = 1000,
444 .monitor_recover_period = IWL_MONITORING_PERIOD, 441 .monitor_recover_period = IWL_MONITORING_PERIOD,
445 .max_event_log_size = 1024, 442 .max_event_log_size = 512,
443 .ucode_tracing = true,
444 .sensitivity_calib_by_driver = true,
445 .chain_noise_calib_by_driver = true,
446}; 446};
447 447
448/*
449 * "i": Internal configuration, use internal Power Amplifier
450 */
448struct iwl_cfg iwl6000i_2agn_cfg = { 451struct iwl_cfg iwl6000i_2agn_cfg = {
449 .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN", 452 .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN",
450 .fw_name_pre = IWL6000_FW_PRE, 453 .fw_name_pre = IWL6000_FW_PRE,
@@ -477,6 +480,9 @@ struct iwl_cfg iwl6000i_2agn_cfg = {
477 .chain_noise_scale = 1000, 480 .chain_noise_scale = 1000,
478 .monitor_recover_period = IWL_MONITORING_PERIOD, 481 .monitor_recover_period = IWL_MONITORING_PERIOD,
479 .max_event_log_size = 1024, 482 .max_event_log_size = 1024,
483 .ucode_tracing = true,
484 .sensitivity_calib_by_driver = true,
485 .chain_noise_calib_by_driver = true,
480}; 486};
481 487
482struct iwl_cfg iwl6000i_2abg_cfg = { 488struct iwl_cfg iwl6000i_2abg_cfg = {
@@ -509,6 +515,9 @@ struct iwl_cfg iwl6000i_2abg_cfg = {
509 .chain_noise_scale = 1000, 515 .chain_noise_scale = 1000,
510 .monitor_recover_period = IWL_MONITORING_PERIOD, 516 .monitor_recover_period = IWL_MONITORING_PERIOD,
511 .max_event_log_size = 1024, 517 .max_event_log_size = 1024,
518 .ucode_tracing = true,
519 .sensitivity_calib_by_driver = true,
520 .chain_noise_calib_by_driver = true,
512}; 521};
513 522
514struct iwl_cfg iwl6000i_2bg_cfg = { 523struct iwl_cfg iwl6000i_2bg_cfg = {
@@ -541,6 +550,9 @@ struct iwl_cfg iwl6000i_2bg_cfg = {
541 .chain_noise_scale = 1000, 550 .chain_noise_scale = 1000,
542 .monitor_recover_period = IWL_MONITORING_PERIOD, 551 .monitor_recover_period = IWL_MONITORING_PERIOD,
543 .max_event_log_size = 1024, 552 .max_event_log_size = 1024,
553 .ucode_tracing = true,
554 .sensitivity_calib_by_driver = true,
555 .chain_noise_calib_by_driver = true,
544}; 556};
545 557
546struct iwl_cfg iwl6050_2agn_cfg = { 558struct iwl_cfg iwl6050_2agn_cfg = {
@@ -575,6 +587,9 @@ struct iwl_cfg iwl6050_2agn_cfg = {
575 .chain_noise_scale = 1500, 587 .chain_noise_scale = 1500,
576 .monitor_recover_period = IWL_MONITORING_PERIOD, 588 .monitor_recover_period = IWL_MONITORING_PERIOD,
577 .max_event_log_size = 1024, 589 .max_event_log_size = 1024,
590 .ucode_tracing = true,
591 .sensitivity_calib_by_driver = true,
592 .chain_noise_calib_by_driver = true,
578}; 593};
579 594
580struct iwl_cfg iwl6050_2abg_cfg = { 595struct iwl_cfg iwl6050_2abg_cfg = {
@@ -607,6 +622,9 @@ struct iwl_cfg iwl6050_2abg_cfg = {
607 .chain_noise_scale = 1500, 622 .chain_noise_scale = 1500,
608 .monitor_recover_period = IWL_MONITORING_PERIOD, 623 .monitor_recover_period = IWL_MONITORING_PERIOD,
609 .max_event_log_size = 1024, 624 .max_event_log_size = 1024,
625 .ucode_tracing = true,
626 .sensitivity_calib_by_driver = true,
627 .chain_noise_calib_by_driver = true,
610}; 628};
611 629
612struct iwl_cfg iwl6000_3agn_cfg = { 630struct iwl_cfg iwl6000_3agn_cfg = {
@@ -641,8 +659,11 @@ struct iwl_cfg iwl6000_3agn_cfg = {
641 .chain_noise_scale = 1000, 659 .chain_noise_scale = 1000,
642 .monitor_recover_period = IWL_MONITORING_PERIOD, 660 .monitor_recover_period = IWL_MONITORING_PERIOD,
643 .max_event_log_size = 1024, 661 .max_event_log_size = 1024,
662 .ucode_tracing = true,
663 .sensitivity_calib_by_driver = true,
664 .chain_noise_calib_by_driver = true,
644}; 665};
645 666
646MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); 667MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
647MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX)); 668MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));
648MODULE_FIRMWARE(IWL6000G2_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX)); 669MODULE_FIRMWARE(IWL6000G2A_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
index f249b706bf17..48c023b4ca36 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
@@ -709,6 +709,22 @@ ssize_t iwl_ucode_tx_stats_read(struct file *file,
709 delta_tx->agg.rx_ba_rsp_cnt, 709 delta_tx->agg.rx_ba_rsp_cnt,
710 max_tx->agg.rx_ba_rsp_cnt); 710 max_tx->agg.rx_ba_rsp_cnt);
711 711
712 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
713 pos += scnprintf(buf + pos, bufsz - pos,
714 "tx power: (1/2 dB step)\n");
715 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
716 pos += scnprintf(buf + pos, bufsz - pos,
717 "\tantenna A: 0x%X\n",
718 tx->tx_power.ant_a);
719 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
720 pos += scnprintf(buf + pos, bufsz - pos,
721 "\tantenna B: 0x%X\n",
722 tx->tx_power.ant_b);
723 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
724 pos += scnprintf(buf + pos, bufsz - pos,
725 "\tantenna C: 0x%X\n",
726 tx->tx_power.ant_c);
727 }
712 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 728 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
713 kfree(buf); 729 kfree(buf);
714 return ret; 730 return ret;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index a27347425968..637d7b62fb56 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -38,6 +38,7 @@
38#include "iwl-helpers.h" 38#include "iwl-helpers.h"
39#include "iwl-agn-hw.h" 39#include "iwl-agn-hw.h"
40#include "iwl-agn.h" 40#include "iwl-agn.h"
41#include "iwl-sta.h"
41 42
42static inline u32 iwlagn_get_scd_ssn(struct iwl5000_tx_resp *tx_resp) 43static inline u32 iwlagn_get_scd_ssn(struct iwl5000_tx_resp *tx_resp)
43{ 44{
@@ -1113,8 +1114,9 @@ void iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,
1113} 1114}
1114 1115
1115static int iwl_get_single_channel_for_scan(struct iwl_priv *priv, 1116static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
1116 enum ieee80211_band band, 1117 struct ieee80211_vif *vif,
1117 struct iwl_scan_channel *scan_ch) 1118 enum ieee80211_band band,
1119 struct iwl_scan_channel *scan_ch)
1118{ 1120{
1119 const struct ieee80211_supported_band *sband; 1121 const struct ieee80211_supported_band *sband;
1120 const struct iwl_channel_info *ch_info; 1122 const struct iwl_channel_info *ch_info;
@@ -1130,7 +1132,7 @@ static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
1130 } 1132 }
1131 1133
1132 active_dwell = iwl_get_active_dwell_time(priv, band, 0); 1134 active_dwell = iwl_get_active_dwell_time(priv, band, 0);
1133 passive_dwell = iwl_get_passive_dwell_time(priv, band); 1135 passive_dwell = iwl_get_passive_dwell_time(priv, band, vif);
1134 1136
1135 if (passive_dwell <= active_dwell) 1137 if (passive_dwell <= active_dwell)
1136 passive_dwell = active_dwell + 1; 1138 passive_dwell = active_dwell + 1;
@@ -1179,6 +1181,7 @@ static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
1179} 1181}
1180 1182
1181static int iwl_get_channels_for_scan(struct iwl_priv *priv, 1183static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1184 struct ieee80211_vif *vif,
1182 enum ieee80211_band band, 1185 enum ieee80211_band band,
1183 u8 is_active, u8 n_probes, 1186 u8 is_active, u8 n_probes,
1184 struct iwl_scan_channel *scan_ch) 1187 struct iwl_scan_channel *scan_ch)
@@ -1196,7 +1199,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1196 return 0; 1199 return 0;
1197 1200
1198 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); 1201 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
1199 passive_dwell = iwl_get_passive_dwell_time(priv, band); 1202 passive_dwell = iwl_get_passive_dwell_time(priv, band, vif);
1200 1203
1201 if (passive_dwell <= active_dwell) 1204 if (passive_dwell <= active_dwell)
1202 passive_dwell = active_dwell + 1; 1205 passive_dwell = active_dwell + 1;
@@ -1256,7 +1259,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1256 return added; 1259 return added;
1257} 1260}
1258 1261
1259void iwlagn_request_scan(struct iwl_priv *priv) 1262void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1260{ 1263{
1261 struct iwl_host_cmd cmd = { 1264 struct iwl_host_cmd cmd = {
1262 .id = REPLY_SCAN_CMD, 1265 .id = REPLY_SCAN_CMD,
@@ -1342,7 +1345,7 @@ void iwlagn_request_scan(struct iwl_priv *priv)
1342 1345
1343 IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); 1346 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
1344 spin_lock_irqsave(&priv->lock, flags); 1347 spin_lock_irqsave(&priv->lock, flags);
1345 interval = priv->beacon_int; 1348 interval = vif ? vif->bss_conf.beacon_int : 0;
1346 spin_unlock_irqrestore(&priv->lock, flags); 1349 spin_unlock_irqrestore(&priv->lock, flags);
1347 1350
1348 scan->suspend_time = 0; 1351 scan->suspend_time = 0;
@@ -1473,12 +1476,12 @@ void iwlagn_request_scan(struct iwl_priv *priv)
1473 1476
1474 if (priv->is_internal_short_scan) { 1477 if (priv->is_internal_short_scan) {
1475 scan->channel_count = 1478 scan->channel_count =
1476 iwl_get_single_channel_for_scan(priv, band, 1479 iwl_get_single_channel_for_scan(priv, vif, band,
1477 (void *)&scan->data[le16_to_cpu( 1480 (void *)&scan->data[le16_to_cpu(
1478 scan->tx_cmd.len)]); 1481 scan->tx_cmd.len)]);
1479 } else { 1482 } else {
1480 scan->channel_count = 1483 scan->channel_count =
1481 iwl_get_channels_for_scan(priv, band, 1484 iwl_get_channels_for_scan(priv, vif, band,
1482 is_active, n_probes, 1485 is_active, n_probes,
1483 (void *)&scan->data[le16_to_cpu( 1486 (void *)&scan->data[le16_to_cpu(
1484 scan->tx_cmd.len)]); 1487 scan->tx_cmd.len)]);
@@ -1513,3 +1516,15 @@ void iwlagn_request_scan(struct iwl_priv *priv)
1513 /* inform mac80211 scan aborted */ 1516 /* inform mac80211 scan aborted */
1514 queue_work(priv->workqueue, &priv->scan_completed); 1517 queue_work(priv->workqueue, &priv->scan_completed);
1515} 1518}
1519
1520int iwlagn_manage_ibss_station(struct iwl_priv *priv,
1521 struct ieee80211_vif *vif, bool add)
1522{
1523 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1524
1525 if (add)
1526 return iwl_add_bssid_station(priv, vif->bss_conf.bssid, true,
1527 &vif_priv->ibss_bssid_sta_id);
1528 return iwl_remove_station(priv, vif_priv->ibss_bssid_sta_id,
1529 vif->bss_conf.bssid);
1530}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index c2a5c85542bf..c402bfc83f36 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -566,11 +566,11 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
566 566
567 hdr_len = ieee80211_hdrlen(fc); 567 hdr_len = ieee80211_hdrlen(fc);
568 568
569 /* Find (or create) index into station table for destination station */ 569 /* Find index into station table for destination station */
570 if (info->flags & IEEE80211_TX_CTL_INJECTED) 570 if (!info->control.sta)
571 sta_id = priv->hw_params.bcast_sta_id; 571 sta_id = priv->hw_params.bcast_sta_id;
572 else 572 else
573 sta_id = iwl_get_sta_id(priv, hdr); 573 sta_id = iwl_sta_id(info->control.sta);
574 if (sta_id == IWL_INVALID_STATION) { 574 if (sta_id == IWL_INVALID_STATION) {
575 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 575 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
576 hdr->addr1); 576 hdr->addr1);
@@ -961,7 +961,8 @@ static int iwlagn_txq_ctx_activate_free(struct iwl_priv *priv)
961 return -1; 961 return -1;
962} 962}
963 963
964int iwlagn_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn) 964int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
965 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
965{ 966{
966 int sta_id; 967 int sta_id;
967 int tx_fifo; 968 int tx_fifo;
@@ -975,9 +976,9 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
975 return tx_fifo; 976 return tx_fifo;
976 977
977 IWL_WARN(priv, "%s on ra = %pM tid = %d\n", 978 IWL_WARN(priv, "%s on ra = %pM tid = %d\n",
978 __func__, ra, tid); 979 __func__, sta->addr, tid);
979 980
980 sta_id = iwl_find_station(priv, ra); 981 sta_id = iwl_sta_id(sta);
981 if (sta_id == IWL_INVALID_STATION) { 982 if (sta_id == IWL_INVALID_STATION) {
982 IWL_ERR(priv, "Start AGG on invalid station\n"); 983 IWL_ERR(priv, "Start AGG on invalid station\n");
983 return -ENXIO; 984 return -ENXIO;
@@ -1011,7 +1012,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
1011 if (tid_data->tfds_in_queue == 0) { 1012 if (tid_data->tfds_in_queue == 0) {
1012 IWL_DEBUG_HT(priv, "HW queue is empty\n"); 1013 IWL_DEBUG_HT(priv, "HW queue is empty\n");
1013 tid_data->agg.state = IWL_AGG_ON; 1014 tid_data->agg.state = IWL_AGG_ON;
1014 ieee80211_start_tx_ba_cb_irqsafe(priv->vif, ra, tid); 1015 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1015 } else { 1016 } else {
1016 IWL_DEBUG_HT(priv, "HW queue is NOT empty: %d packets in HW queue\n", 1017 IWL_DEBUG_HT(priv, "HW queue is NOT empty: %d packets in HW queue\n",
1017 tid_data->tfds_in_queue); 1018 tid_data->tfds_in_queue);
@@ -1020,23 +1021,19 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
1020 return ret; 1021 return ret;
1021} 1022}
1022 1023
1023int iwlagn_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid) 1024int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
1025 struct ieee80211_sta *sta, u16 tid)
1024{ 1026{
1025 int tx_fifo_id, txq_id, sta_id, ssn = -1; 1027 int tx_fifo_id, txq_id, sta_id, ssn = -1;
1026 struct iwl_tid_data *tid_data; 1028 struct iwl_tid_data *tid_data;
1027 int write_ptr, read_ptr; 1029 int write_ptr, read_ptr;
1028 unsigned long flags; 1030 unsigned long flags;
1029 1031
1030 if (!ra) {
1031 IWL_ERR(priv, "ra = NULL\n");
1032 return -EINVAL;
1033 }
1034
1035 tx_fifo_id = get_fifo_from_tid(tid); 1032 tx_fifo_id = get_fifo_from_tid(tid);
1036 if (unlikely(tx_fifo_id < 0)) 1033 if (unlikely(tx_fifo_id < 0))
1037 return tx_fifo_id; 1034 return tx_fifo_id;
1038 1035
1039 sta_id = iwl_find_station(priv, ra); 1036 sta_id = iwl_sta_id(sta);
1040 1037
1041 if (sta_id == IWL_INVALID_STATION) { 1038 if (sta_id == IWL_INVALID_STATION) {
1042 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid); 1039 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid);
@@ -1046,7 +1043,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1046 if (priv->stations[sta_id].tid[tid].agg.state == 1043 if (priv->stations[sta_id].tid[tid].agg.state ==
1047 IWL_EMPTYING_HW_QUEUE_ADDBA) { 1044 IWL_EMPTYING_HW_QUEUE_ADDBA) {
1048 IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); 1045 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
1049 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid); 1046 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1050 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1047 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1051 return 0; 1048 return 0;
1052 } 1049 }
@@ -1083,7 +1080,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1083 tx_fifo_id); 1080 tx_fifo_id);
1084 spin_unlock_irqrestore(&priv->lock, flags); 1081 spin_unlock_irqrestore(&priv->lock, flags);
1085 1082
1086 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid); 1083 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1087 1084
1088 return 0; 1085 return 0;
1089} 1086}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index ae476c234a7c..637286c396fe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -52,6 +52,37 @@ static const s8 iwlagn_default_queue_to_tx_fifo[] = {
52 IWL_TX_FIFO_UNUSED, 52 IWL_TX_FIFO_UNUSED,
53}; 53};
54 54
55static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
56 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP,
57 0, COEX_UNASSOC_IDLE_FLAGS},
58 {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP,
59 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
60 {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP,
61 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
62 {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP,
63 0, COEX_CALIBRATION_FLAGS},
64 {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP,
65 0, COEX_PERIODIC_CALIBRATION_FLAGS},
66 {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP,
67 0, COEX_CONNECTION_ESTAB_FLAGS},
68 {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP,
69 0, COEX_ASSOCIATED_IDLE_FLAGS},
70 {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP,
71 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
72 {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP,
73 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
74 {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP,
75 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
76 {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS},
77 {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS},
78 {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP,
79 0, COEX_STAND_ALONE_DEBUG_FLAGS},
80 {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP,
81 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
82 {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS},
83 {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS}
84};
85
55/* 86/*
56 * ucode 87 * ucode
57 */ 88 */
@@ -151,55 +182,6 @@ int iwlagn_load_ucode(struct iwl_priv *priv)
151 return ret; 182 return ret;
152} 183}
153 184
154#define IWL_UCODE_GET(item) \
155static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\
156 u32 api_ver) \
157{ \
158 if (api_ver <= 2) \
159 return le32_to_cpu(ucode->u.v1.item); \
160 return le32_to_cpu(ucode->u.v2.item); \
161}
162
163static u32 iwlagn_ucode_get_header_size(u32 api_ver)
164{
165 if (api_ver <= 2)
166 return UCODE_HEADER_SIZE(1);
167 return UCODE_HEADER_SIZE(2);
168}
169
170static u32 iwlagn_ucode_get_build(const struct iwl_ucode_header *ucode,
171 u32 api_ver)
172{
173 if (api_ver <= 2)
174 return 0;
175 return le32_to_cpu(ucode->u.v2.build);
176}
177
178static u8 *iwlagn_ucode_get_data(const struct iwl_ucode_header *ucode,
179 u32 api_ver)
180{
181 if (api_ver <= 2)
182 return (u8 *) ucode->u.v1.data;
183 return (u8 *) ucode->u.v2.data;
184}
185
186IWL_UCODE_GET(inst_size);
187IWL_UCODE_GET(data_size);
188IWL_UCODE_GET(init_size);
189IWL_UCODE_GET(init_data_size);
190IWL_UCODE_GET(boot_size);
191
192struct iwl_ucode_ops iwlagn_ucode = {
193 .get_header_size = iwlagn_ucode_get_header_size,
194 .get_build = iwlagn_ucode_get_build,
195 .get_inst_size = iwlagn_ucode_get_inst_size,
196 .get_data_size = iwlagn_ucode_get_data_size,
197 .get_init_size = iwlagn_ucode_get_init_size,
198 .get_init_data_size = iwlagn_ucode_get_init_data_size,
199 .get_boot_size = iwlagn_ucode_get_boot_size,
200 .get_data = iwlagn_ucode_get_data,
201};
202
203/* 185/*
204 * Calibration 186 * Calibration
205 */ 187 */
@@ -320,6 +302,33 @@ restart:
320 queue_work(priv->workqueue, &priv->restart); 302 queue_work(priv->workqueue, &priv->restart);
321} 303}
322 304
305static int iwlagn_send_wimax_coex(struct iwl_priv *priv)
306{
307 struct iwl_wimax_coex_cmd coex_cmd;
308
309 if (priv->cfg->support_wimax_coexist) {
310 /* UnMask wake up src at associated sleep */
311 coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK;
312
313 /* UnMask wake up src at unassociated sleep */
314 coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK;
315 memcpy(coex_cmd.sta_prio, cu_priorities,
316 sizeof(struct iwl_wimax_coex_event_entry) *
317 COEX_NUM_OF_EVENTS);
318
319 /* enabling the coexistence feature */
320 coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK;
321
322 /* enabling the priorities tables */
323 coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK;
324 } else {
325 /* coexistence is disabled */
326 memset(&coex_cmd, 0, sizeof(coex_cmd));
327 }
328 return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD,
329 sizeof(coex_cmd), &coex_cmd);
330}
331
323int iwlagn_alive_notify(struct iwl_priv *priv) 332int iwlagn_alive_notify(struct iwl_priv *priv)
324{ 333{
325 u32 a; 334 u32 a;
@@ -407,7 +416,7 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
407 416
408 spin_unlock_irqrestore(&priv->lock, flags); 417 spin_unlock_irqrestore(&priv->lock, flags);
409 418
410 iwl_send_wimax_coex(priv); 419 iwlagn_send_wimax_coex(priv);
411 420
412 iwlagn_set_Xtal_calib(priv); 421 iwlagn_set_Xtal_calib(priv);
413 iwl_send_calib_results(priv); 422 iwl_send_calib_results(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index cc15e929a987..aef4f71f1981 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -157,7 +157,7 @@ int iwl_commit_rxon(struct iwl_priv *priv)
157 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); 157 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret);
158 return ret; 158 return ret;
159 } 159 }
160 iwl_clear_ucode_stations(priv, false); 160 iwl_clear_ucode_stations(priv);
161 iwl_restore_stations(priv); 161 iwl_restore_stations(priv);
162 ret = iwl_restore_default_wep_keys(priv); 162 ret = iwl_restore_default_wep_keys(priv);
163 if (ret) { 163 if (ret) {
@@ -189,7 +189,7 @@ int iwl_commit_rxon(struct iwl_priv *priv)
189 } 189 }
190 IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); 190 IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n");
191 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 191 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
192 iwl_clear_ucode_stations(priv, false); 192 iwl_clear_ucode_stations(priv);
193 iwl_restore_stations(priv); 193 iwl_restore_stations(priv);
194 ret = iwl_restore_default_wep_keys(priv); 194 ret = iwl_restore_default_wep_keys(priv);
195 if (ret) { 195 if (ret) {
@@ -1506,9 +1506,13 @@ static void iwl_nic_start(struct iwl_priv *priv)
1506 iwl_write32(priv, CSR_RESET, 0); 1506 iwl_write32(priv, CSR_RESET, 0);
1507} 1507}
1508 1508
1509struct iwlagn_ucode_capabilities {
1510 u32 max_probe_length;
1511};
1509 1512
1510static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); 1513static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
1511static int iwl_mac_setup_register(struct iwl_priv *priv); 1514static int iwl_mac_setup_register(struct iwl_priv *priv,
1515 struct iwlagn_ucode_capabilities *capa);
1512 1516
1513static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) 1517static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
1514{ 1518{
@@ -1535,6 +1539,199 @@ static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
1535 iwl_ucode_callback); 1539 iwl_ucode_callback);
1536} 1540}
1537 1541
1542struct iwlagn_firmware_pieces {
1543 const void *inst, *data, *init, *init_data, *boot;
1544 size_t inst_size, data_size, init_size, init_data_size, boot_size;
1545
1546 u32 build;
1547};
1548
1549static int iwlagn_load_legacy_firmware(struct iwl_priv *priv,
1550 const struct firmware *ucode_raw,
1551 struct iwlagn_firmware_pieces *pieces)
1552{
1553 struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
1554 u32 api_ver, hdr_size;
1555 const u8 *src;
1556
1557 priv->ucode_ver = le32_to_cpu(ucode->ver);
1558 api_ver = IWL_UCODE_API(priv->ucode_ver);
1559
1560 switch (api_ver) {
1561 default:
1562 /*
1563 * 4965 doesn't revision the firmware file format
1564 * along with the API version, it always uses v1
1565 * file format.
1566 */
1567 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) !=
1568 CSR_HW_REV_TYPE_4965) {
1569 hdr_size = 28;
1570 if (ucode_raw->size < hdr_size) {
1571 IWL_ERR(priv, "File size too small!\n");
1572 return -EINVAL;
1573 }
1574 pieces->build = le32_to_cpu(ucode->u.v2.build);
1575 pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size);
1576 pieces->data_size = le32_to_cpu(ucode->u.v2.data_size);
1577 pieces->init_size = le32_to_cpu(ucode->u.v2.init_size);
1578 pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size);
1579 pieces->boot_size = le32_to_cpu(ucode->u.v2.boot_size);
1580 src = ucode->u.v2.data;
1581 break;
1582 }
1583 /* fall through for 4965 */
1584 case 0:
1585 case 1:
1586 case 2:
1587 hdr_size = 24;
1588 if (ucode_raw->size < hdr_size) {
1589 IWL_ERR(priv, "File size too small!\n");
1590 return -EINVAL;
1591 }
1592 pieces->build = 0;
1593 pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size);
1594 pieces->data_size = le32_to_cpu(ucode->u.v1.data_size);
1595 pieces->init_size = le32_to_cpu(ucode->u.v1.init_size);
1596 pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size);
1597 pieces->boot_size = le32_to_cpu(ucode->u.v1.boot_size);
1598 src = ucode->u.v1.data;
1599 break;
1600 }
1601
1602 /* Verify size of file vs. image size info in file's header */
1603 if (ucode_raw->size != hdr_size + pieces->inst_size +
1604 pieces->data_size + pieces->init_size +
1605 pieces->init_data_size + pieces->boot_size) {
1606
1607 IWL_ERR(priv,
1608 "uCode file size %d does not match expected size\n",
1609 (int)ucode_raw->size);
1610 return -EINVAL;
1611 }
1612
1613 pieces->inst = src;
1614 src += pieces->inst_size;
1615 pieces->data = src;
1616 src += pieces->data_size;
1617 pieces->init = src;
1618 src += pieces->init_size;
1619 pieces->init_data = src;
1620 src += pieces->init_data_size;
1621 pieces->boot = src;
1622 src += pieces->boot_size;
1623
1624 return 0;
1625}
1626
1627static int iwlagn_wanted_ucode_alternative = 1;
1628
1629static int iwlagn_load_firmware(struct iwl_priv *priv,
1630 const struct firmware *ucode_raw,
1631 struct iwlagn_firmware_pieces *pieces,
1632 struct iwlagn_ucode_capabilities *capa)
1633{
1634 struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
1635 struct iwl_ucode_tlv *tlv;
1636 size_t len = ucode_raw->size;
1637 const u8 *data;
1638 int wanted_alternative = iwlagn_wanted_ucode_alternative, tmp;
1639 u64 alternatives;
1640
1641 if (len < sizeof(*ucode))
1642 return -EINVAL;
1643
1644 if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC))
1645 return -EINVAL;
1646
1647 /*
1648 * Check which alternatives are present, and "downgrade"
1649 * when the chosen alternative is not present, warning
1650 * the user when that happens. Some files may not have
1651 * any alternatives, so don't warn in that case.
1652 */
1653 alternatives = le64_to_cpu(ucode->alternatives);
1654 tmp = wanted_alternative;
1655 if (wanted_alternative > 63)
1656 wanted_alternative = 63;
1657 while (wanted_alternative && !(alternatives & BIT(wanted_alternative)))
1658 wanted_alternative--;
1659 if (wanted_alternative && wanted_alternative != tmp)
1660 IWL_WARN(priv,
1661 "uCode alternative %d not available, choosing %d\n",
1662 tmp, wanted_alternative);
1663
1664 priv->ucode_ver = le32_to_cpu(ucode->ver);
1665 pieces->build = le32_to_cpu(ucode->build);
1666 data = ucode->data;
1667
1668 len -= sizeof(*ucode);
1669
1670 while (len >= sizeof(*tlv)) {
1671 u32 tlv_len;
1672 enum iwl_ucode_tlv_type tlv_type;
1673 u16 tlv_alt;
1674 const u8 *tlv_data;
1675
1676 len -= sizeof(*tlv);
1677 tlv = (void *)data;
1678
1679 tlv_len = le32_to_cpu(tlv->length);
1680 tlv_type = le16_to_cpu(tlv->type);
1681 tlv_alt = le16_to_cpu(tlv->alternative);
1682 tlv_data = tlv->data;
1683
1684 if (len < tlv_len)
1685 return -EINVAL;
1686 len -= ALIGN(tlv_len, 4);
1687 data += sizeof(*tlv) + ALIGN(tlv_len, 4);
1688
1689 /*
1690 * Alternative 0 is always valid.
1691 *
1692 * Skip alternative TLVs that are not selected.
1693 */
1694 if (tlv_alt != 0 && tlv_alt != wanted_alternative)
1695 continue;
1696
1697 switch (tlv_type) {
1698 case IWL_UCODE_TLV_INST:
1699 pieces->inst = tlv_data;
1700 pieces->inst_size = tlv_len;
1701 break;
1702 case IWL_UCODE_TLV_DATA:
1703 pieces->data = tlv_data;
1704 pieces->data_size = tlv_len;
1705 break;
1706 case IWL_UCODE_TLV_INIT:
1707 pieces->init = tlv_data;
1708 pieces->init_size = tlv_len;
1709 break;
1710 case IWL_UCODE_TLV_INIT_DATA:
1711 pieces->init_data = tlv_data;
1712 pieces->init_data_size = tlv_len;
1713 break;
1714 case IWL_UCODE_TLV_BOOT:
1715 pieces->boot = tlv_data;
1716 pieces->boot_size = tlv_len;
1717 break;
1718 case IWL_UCODE_TLV_PROBE_MAX_LEN:
1719 if (tlv_len != 4)
1720 return -EINVAL;
1721 capa->max_probe_length =
1722 le32_to_cpup((__le32 *)tlv_data);
1723 break;
1724 default:
1725 break;
1726 }
1727 }
1728
1729 if (len)
1730 return -EINVAL;
1731
1732 return 0;
1733}
1734
1538/** 1735/**
1539 * iwl_ucode_callback - callback when firmware was loaded 1736 * iwl_ucode_callback - callback when firmware was loaded
1540 * 1737 *
@@ -1545,14 +1742,18 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1545{ 1742{
1546 struct iwl_priv *priv = context; 1743 struct iwl_priv *priv = context;
1547 struct iwl_ucode_header *ucode; 1744 struct iwl_ucode_header *ucode;
1745 int err;
1746 struct iwlagn_firmware_pieces pieces;
1548 const unsigned int api_max = priv->cfg->ucode_api_max; 1747 const unsigned int api_max = priv->cfg->ucode_api_max;
1549 const unsigned int api_min = priv->cfg->ucode_api_min; 1748 const unsigned int api_min = priv->cfg->ucode_api_min;
1550 u8 *src; 1749 u32 api_ver;
1551 size_t len; 1750 char buildstr[25];
1552 u32 api_ver, build; 1751 u32 build;
1553 u32 inst_size, data_size, init_size, init_data_size, boot_size; 1752 struct iwlagn_ucode_capabilities ucode_capa = {
1554 int err; 1753 .max_probe_length = 200,
1555 u16 eeprom_ver; 1754 };
1755
1756 memset(&pieces, 0, sizeof(pieces));
1556 1757
1557 if (!ucode_raw) { 1758 if (!ucode_raw) {
1558 IWL_ERR(priv, "request for firmware file '%s' failed.\n", 1759 IWL_ERR(priv, "request for firmware file '%s' failed.\n",
@@ -1563,8 +1764,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1563 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", 1764 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n",
1564 priv->firmware_name, ucode_raw->size); 1765 priv->firmware_name, ucode_raw->size);
1565 1766
1566 /* Make sure that we got at least the v1 header! */ 1767 /* Make sure that we got at least the API version number */
1567 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { 1768 if (ucode_raw->size < 4) {
1568 IWL_ERR(priv, "File size way too small!\n"); 1769 IWL_ERR(priv, "File size way too small!\n");
1569 goto try_again; 1770 goto try_again;
1570 } 1771 }
@@ -1572,21 +1773,23 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1572 /* Data from ucode file: header followed by uCode images */ 1773 /* Data from ucode file: header followed by uCode images */
1573 ucode = (struct iwl_ucode_header *)ucode_raw->data; 1774 ucode = (struct iwl_ucode_header *)ucode_raw->data;
1574 1775
1575 priv->ucode_ver = le32_to_cpu(ucode->ver); 1776 if (ucode->ver)
1777 err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces);
1778 else
1779 err = iwlagn_load_firmware(priv, ucode_raw, &pieces,
1780 &ucode_capa);
1781
1782 if (err)
1783 goto try_again;
1784
1576 api_ver = IWL_UCODE_API(priv->ucode_ver); 1785 api_ver = IWL_UCODE_API(priv->ucode_ver);
1577 build = priv->cfg->ops->ucode->get_build(ucode, api_ver); 1786 build = pieces.build;
1578 inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver);
1579 data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver);
1580 init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver);
1581 init_data_size =
1582 priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver);
1583 boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver);
1584 src = priv->cfg->ops->ucode->get_data(ucode, api_ver);
1585
1586 /* api_ver should match the api version forming part of the
1587 * firmware filename ... but we don't check for that and only rely
1588 * on the API version read from firmware header from here on forward */
1589 1787
1788 /*
1789 * api_ver should match the api version forming part of the
1790 * firmware filename ... but we don't check for that and only rely
1791 * on the API version read from firmware header from here on forward
1792 */
1590 if (api_ver < api_min || api_ver > api_max) { 1793 if (api_ver < api_min || api_ver > api_max) {
1591 IWL_ERR(priv, "Driver unable to support your firmware API. " 1794 IWL_ERR(priv, "Driver unable to support your firmware API. "
1592 "Driver supports v%u, firmware is v%u.\n", 1795 "Driver supports v%u, firmware is v%u.\n",
@@ -1600,40 +1803,26 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1600 "from http://www.intellinuxwireless.org.\n", 1803 "from http://www.intellinuxwireless.org.\n",
1601 api_max, api_ver); 1804 api_max, api_ver);
1602 1805
1603 IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", 1806 if (build)
1604 IWL_UCODE_MAJOR(priv->ucode_ver), 1807 sprintf(buildstr, " build %u", build);
1605 IWL_UCODE_MINOR(priv->ucode_ver), 1808 else
1606 IWL_UCODE_API(priv->ucode_ver), 1809 buildstr[0] = '\0';
1607 IWL_UCODE_SERIAL(priv->ucode_ver)); 1810
1811 IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\n",
1812 IWL_UCODE_MAJOR(priv->ucode_ver),
1813 IWL_UCODE_MINOR(priv->ucode_ver),
1814 IWL_UCODE_API(priv->ucode_ver),
1815 IWL_UCODE_SERIAL(priv->ucode_ver),
1816 buildstr);
1608 1817
1609 snprintf(priv->hw->wiphy->fw_version, 1818 snprintf(priv->hw->wiphy->fw_version,
1610 sizeof(priv->hw->wiphy->fw_version), 1819 sizeof(priv->hw->wiphy->fw_version),
1611 "%u.%u.%u.%u", 1820 "%u.%u.%u.%u%s",
1612 IWL_UCODE_MAJOR(priv->ucode_ver), 1821 IWL_UCODE_MAJOR(priv->ucode_ver),
1613 IWL_UCODE_MINOR(priv->ucode_ver), 1822 IWL_UCODE_MINOR(priv->ucode_ver),
1614 IWL_UCODE_API(priv->ucode_ver), 1823 IWL_UCODE_API(priv->ucode_ver),
1615 IWL_UCODE_SERIAL(priv->ucode_ver)); 1824 IWL_UCODE_SERIAL(priv->ucode_ver),
1616 1825 buildstr);
1617 if (build)
1618 IWL_DEBUG_INFO(priv, "Build %u\n", build);
1619
1620 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
1621 IWL_DEBUG_INFO(priv, "NVM Type: %s, version: 0x%x\n",
1622 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
1623 ? "OTP" : "EEPROM", eeprom_ver);
1624
1625 IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
1626 priv->ucode_ver);
1627 IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n",
1628 inst_size);
1629 IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n",
1630 data_size);
1631 IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n",
1632 init_size);
1633 IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n",
1634 init_data_size);
1635 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n",
1636 boot_size);
1637 1826
1638 /* 1827 /*
1639 * For any of the failures below (before allocating pci memory) 1828 * For any of the failures below (before allocating pci memory)
@@ -1641,43 +1830,47 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1641 * user just got a corrupted version of the latest API. 1830 * user just got a corrupted version of the latest API.
1642 */ 1831 */
1643 1832
1644 /* Verify size of file vs. image size info in file's header */ 1833 IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
1645 if (ucode_raw->size != 1834 priv->ucode_ver);
1646 priv->cfg->ops->ucode->get_header_size(api_ver) + 1835 IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n",
1647 inst_size + data_size + init_size + 1836 pieces.inst_size);
1648 init_data_size + boot_size) { 1837 IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n",
1649 1838 pieces.data_size);
1650 IWL_DEBUG_INFO(priv, 1839 IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n",
1651 "uCode file size %d does not match expected size\n", 1840 pieces.init_size);
1652 (int)ucode_raw->size); 1841 IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n",
1653 goto try_again; 1842 pieces.init_data_size);
1654 } 1843 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n",
1844 pieces.boot_size);
1655 1845
1656 /* Verify that uCode images will fit in card's SRAM */ 1846 /* Verify that uCode images will fit in card's SRAM */
1657 if (inst_size > priv->hw_params.max_inst_size) { 1847 if (pieces.inst_size > priv->hw_params.max_inst_size) {
1658 IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", 1848 IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n",
1659 inst_size); 1849 pieces.inst_size);
1660 goto try_again; 1850 goto try_again;
1661 } 1851 }
1662 1852
1663 if (data_size > priv->hw_params.max_data_size) { 1853 if (pieces.data_size > priv->hw_params.max_data_size) {
1664 IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", 1854 IWL_ERR(priv, "uCode data len %Zd too large to fit in\n",
1665 data_size); 1855 pieces.data_size);
1666 goto try_again; 1856 goto try_again;
1667 } 1857 }
1668 if (init_size > priv->hw_params.max_inst_size) { 1858
1669 IWL_INFO(priv, "uCode init instr len %d too large to fit in\n", 1859 if (pieces.init_size > priv->hw_params.max_inst_size) {
1670 init_size); 1860 IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n",
1861 pieces.init_size);
1671 goto try_again; 1862 goto try_again;
1672 } 1863 }
1673 if (init_data_size > priv->hw_params.max_data_size) { 1864
1674 IWL_INFO(priv, "uCode init data len %d too large to fit in\n", 1865 if (pieces.init_data_size > priv->hw_params.max_data_size) {
1675 init_data_size); 1866 IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n",
1867 pieces.init_data_size);
1676 goto try_again; 1868 goto try_again;
1677 } 1869 }
1678 if (boot_size > priv->hw_params.max_bsm_size) { 1870
1679 IWL_INFO(priv, "uCode boot instr len %d too large to fit in\n", 1871 if (pieces.boot_size > priv->hw_params.max_bsm_size) {
1680 boot_size); 1872 IWL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n",
1873 pieces.boot_size);
1681 goto try_again; 1874 goto try_again;
1682 } 1875 }
1683 1876
@@ -1686,13 +1879,13 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1686 /* Runtime instructions and 2 copies of data: 1879 /* Runtime instructions and 2 copies of data:
1687 * 1) unmodified from disk 1880 * 1) unmodified from disk
1688 * 2) backup cache for save/restore during power-downs */ 1881 * 2) backup cache for save/restore during power-downs */
1689 priv->ucode_code.len = inst_size; 1882 priv->ucode_code.len = pieces.inst_size;
1690 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); 1883 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);
1691 1884
1692 priv->ucode_data.len = data_size; 1885 priv->ucode_data.len = pieces.data_size;
1693 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); 1886 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);
1694 1887
1695 priv->ucode_data_backup.len = data_size; 1888 priv->ucode_data_backup.len = pieces.data_size;
1696 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); 1889 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
1697 1890
1698 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || 1891 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr ||
@@ -1700,11 +1893,11 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1700 goto err_pci_alloc; 1893 goto err_pci_alloc;
1701 1894
1702 /* Initialization instructions and data */ 1895 /* Initialization instructions and data */
1703 if (init_size && init_data_size) { 1896 if (pieces.init_size && pieces.init_data_size) {
1704 priv->ucode_init.len = init_size; 1897 priv->ucode_init.len = pieces.init_size;
1705 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); 1898 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);
1706 1899
1707 priv->ucode_init_data.len = init_data_size; 1900 priv->ucode_init_data.len = pieces.init_data_size;
1708 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); 1901 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);
1709 1902
1710 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) 1903 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
@@ -1712,8 +1905,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1712 } 1905 }
1713 1906
1714 /* Bootstrap (instructions only, no data) */ 1907 /* Bootstrap (instructions only, no data) */
1715 if (boot_size) { 1908 if (pieces.boot_size) {
1716 priv->ucode_boot.len = boot_size; 1909 priv->ucode_boot.len = pieces.boot_size;
1717 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); 1910 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot);
1718 1911
1719 if (!priv->ucode_boot.v_addr) 1912 if (!priv->ucode_boot.v_addr)
@@ -1723,51 +1916,48 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1723 /* Copy images into buffers for card's bus-master reads ... */ 1916 /* Copy images into buffers for card's bus-master reads ... */
1724 1917
1725 /* Runtime instructions (first block of data in file) */ 1918 /* Runtime instructions (first block of data in file) */
1726 len = inst_size; 1919 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n",
1727 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", len); 1920 pieces.inst_size);
1728 memcpy(priv->ucode_code.v_addr, src, len); 1921 memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size);
1729 src += len;
1730 1922
1731 IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", 1923 IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
1732 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); 1924 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
1733 1925
1734 /* Runtime data (2nd block) 1926 /*
1735 * NOTE: Copy into backup buffer will be done in iwl_up() */ 1927 * Runtime data
1736 len = data_size; 1928 * NOTE: Copy into backup buffer will be done in iwl_up()
1737 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", len); 1929 */
1738 memcpy(priv->ucode_data.v_addr, src, len); 1930 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n",
1739 memcpy(priv->ucode_data_backup.v_addr, src, len); 1931 pieces.data_size);
1740 src += len; 1932 memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size);
1741 1933 memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size);
1742 /* Initialization instructions (3rd block) */ 1934
1743 if (init_size) { 1935 /* Initialization instructions */
1744 len = init_size; 1936 if (pieces.init_size) {
1745 IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n", 1937 IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n",
1746 len); 1938 pieces.init_size);
1747 memcpy(priv->ucode_init.v_addr, src, len); 1939 memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size);
1748 src += len;
1749 } 1940 }
1750 1941
1751 /* Initialization data (4th block) */ 1942 /* Initialization data */
1752 if (init_data_size) { 1943 if (pieces.init_data_size) {
1753 len = init_data_size;
1754 IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n", 1944 IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n",
1755 len); 1945 pieces.init_data_size);
1756 memcpy(priv->ucode_init_data.v_addr, src, len); 1946 memcpy(priv->ucode_init_data.v_addr, pieces.init_data,
1757 src += len; 1947 pieces.init_data_size);
1758 } 1948 }
1759 1949
1760 /* Bootstrap instructions (5th block) */ 1950 /* Bootstrap instructions */
1761 len = boot_size; 1951 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n",
1762 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", len); 1952 pieces.boot_size);
1763 memcpy(priv->ucode_boot.v_addr, src, len); 1953 memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size);
1764 1954
1765 /************************************************** 1955 /**************************************************
1766 * This is still part of probe() in a sense... 1956 * This is still part of probe() in a sense...
1767 * 1957 *
1768 * 9. Setup and register with mac80211 and debugfs 1958 * 9. Setup and register with mac80211 and debugfs
1769 **************************************************/ 1959 **************************************************/
1770 err = iwl_mac_setup_register(priv); 1960 err = iwl_mac_setup_register(priv, &ucode_capa);
1771 if (err) 1961 if (err)
1772 goto out_unbind; 1962 goto out_unbind;
1773 1963
@@ -1777,6 +1967,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1777 1967
1778 /* We have our copies now, allow OS release its copies */ 1968 /* We have our copies now, allow OS release its copies */
1779 release_firmware(ucode_raw); 1969 release_firmware(ucode_raw);
1970 complete(&priv->_agn.firmware_loading_complete);
1780 return; 1971 return;
1781 1972
1782 try_again: 1973 try_again:
@@ -1790,6 +1981,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1790 IWL_ERR(priv, "failed to allocate pci memory\n"); 1981 IWL_ERR(priv, "failed to allocate pci memory\n");
1791 iwl_dealloc_ucode_pci(priv); 1982 iwl_dealloc_ucode_pci(priv);
1792 out_unbind: 1983 out_unbind:
1984 complete(&priv->_agn.firmware_loading_complete);
1793 device_release_driver(&priv->pci_dev->dev); 1985 device_release_driver(&priv->pci_dev->dev);
1794 release_firmware(ucode_raw); 1986 release_firmware(ucode_raw);
1795} 1987}
@@ -2165,7 +2357,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2165 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2357 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2166 } else { 2358 } else {
2167 /* Initialize our rx_config data */ 2359 /* Initialize our rx_config data */
2168 iwl_connection_init_rx_config(priv, priv->iw_mode); 2360 iwl_connection_init_rx_config(priv, NULL);
2169 2361
2170 if (priv->cfg->ops->hcmd->set_rxon_chain) 2362 if (priv->cfg->ops->hcmd->set_rxon_chain)
2171 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2363 priv->cfg->ops->hcmd->set_rxon_chain(priv);
@@ -2212,7 +2404,9 @@ static void __iwl_down(struct iwl_priv *priv)
2212 if (!exit_pending) 2404 if (!exit_pending)
2213 set_bit(STATUS_EXIT_PENDING, &priv->status); 2405 set_bit(STATUS_EXIT_PENDING, &priv->status);
2214 2406
2215 iwl_clear_ucode_stations(priv, true); 2407 iwl_clear_ucode_stations(priv);
2408 iwl_dealloc_bcast_station(priv);
2409 iwl_clear_driver_stations(priv);
2216 2410
2217 /* Unblock any waiting calls */ 2411 /* Unblock any waiting calls */
2218 wake_up_interruptible_all(&priv->wait_command_queue); 2412 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2359,6 +2553,10 @@ static int __iwl_up(struct iwl_priv *priv)
2359 return -EIO; 2553 return -EIO;
2360 } 2554 }
2361 2555
2556 ret = iwl_alloc_bcast_station(priv, true);
2557 if (ret)
2558 return ret;
2559
2362 iwl_prepare_card_hw(priv); 2560 iwl_prepare_card_hw(priv);
2363 2561
2364 if (!priv->hw_ready) { 2562 if (!priv->hw_ready) {
@@ -2537,12 +2735,15 @@ static void iwl_bg_rx_replenish(struct work_struct *data)
2537 2735
2538#define IWL_DELAY_NEXT_SCAN (HZ*2) 2736#define IWL_DELAY_NEXT_SCAN (HZ*2)
2539 2737
2540void iwl_post_associate(struct iwl_priv *priv) 2738void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
2541{ 2739{
2542 struct ieee80211_conf *conf = NULL; 2740 struct ieee80211_conf *conf = NULL;
2543 int ret = 0; 2741 int ret = 0;
2544 2742
2545 if (priv->iw_mode == NL80211_IFTYPE_AP) { 2743 if (!vif || !priv->is_open)
2744 return;
2745
2746 if (vif->type == NL80211_IFTYPE_AP) {
2546 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__); 2747 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__);
2547 return; 2748 return;
2548 } 2749 }
@@ -2550,10 +2751,6 @@ void iwl_post_associate(struct iwl_priv *priv)
2550 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2751 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2551 return; 2752 return;
2552 2753
2553
2554 if (!priv->vif || !priv->is_open)
2555 return;
2556
2557 iwl_scan_cancel_timeout(priv, 200); 2754 iwl_scan_cancel_timeout(priv, 200);
2558 2755
2559 conf = ieee80211_get_hw_conf(priv->hw); 2756 conf = ieee80211_get_hw_conf(priv->hw);
@@ -2561,7 +2758,7 @@ void iwl_post_associate(struct iwl_priv *priv)
2561 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2758 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2562 iwlcore_commit_rxon(priv); 2759 iwlcore_commit_rxon(priv);
2563 2760
2564 iwl_setup_rxon_timing(priv); 2761 iwl_setup_rxon_timing(priv, vif);
2565 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 2762 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
2566 sizeof(priv->rxon_timing), &priv->rxon_timing); 2763 sizeof(priv->rxon_timing), &priv->rxon_timing);
2567 if (ret) 2764 if (ret)
@@ -2575,49 +2772,41 @@ void iwl_post_associate(struct iwl_priv *priv)
2575 if (priv->cfg->ops->hcmd->set_rxon_chain) 2772 if (priv->cfg->ops->hcmd->set_rxon_chain)
2576 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2773 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2577 2774
2578 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 2775 priv->staging_rxon.assoc_id = cpu_to_le16(vif->bss_conf.aid);
2579 2776
2580 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", 2777 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
2581 priv->assoc_id, priv->beacon_int); 2778 vif->bss_conf.aid, vif->bss_conf.beacon_int);
2582 2779
2583 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 2780 if (vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
2584 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2781 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
2585 else 2782 else
2586 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 2783 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
2587 2784
2588 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 2785 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
2589 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 2786 if (vif->bss_conf.assoc_capability &
2787 WLAN_CAPABILITY_SHORT_SLOT_TIME)
2590 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 2788 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
2591 else 2789 else
2592 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2790 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2593 2791
2594 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 2792 if (vif->type == NL80211_IFTYPE_ADHOC)
2595 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2793 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2596
2597 } 2794 }
2598 2795
2599 iwlcore_commit_rxon(priv); 2796 iwlcore_commit_rxon(priv);
2600 2797
2601 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", 2798 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
2602 priv->assoc_id, priv->active_rxon.bssid_addr); 2799 vif->bss_conf.aid, priv->active_rxon.bssid_addr);
2603 2800
2604 switch (priv->iw_mode) { 2801 switch (vif->type) {
2605 case NL80211_IFTYPE_STATION: 2802 case NL80211_IFTYPE_STATION:
2606 break; 2803 break;
2607
2608 case NL80211_IFTYPE_ADHOC: 2804 case NL80211_IFTYPE_ADHOC:
2609
2610 /* assume default assoc id */
2611 priv->assoc_id = 1;
2612
2613 iwl_add_local_station(priv, priv->bssid, true);
2614 iwl_send_beacon_cmd(priv); 2805 iwl_send_beacon_cmd(priv);
2615
2616 break; 2806 break;
2617
2618 default: 2807 default:
2619 IWL_ERR(priv, "%s Should not be called in %d mode\n", 2808 IWL_ERR(priv, "%s Should not be called in %d mode\n",
2620 __func__, priv->iw_mode); 2809 __func__, vif->type);
2621 break; 2810 break;
2622 } 2811 }
2623 2812
@@ -2645,7 +2834,8 @@ void iwl_post_associate(struct iwl_priv *priv)
2645 * Not a mac80211 entry point function, but it fits in with all the 2834 * Not a mac80211 entry point function, but it fits in with all the
2646 * other mac80211 functions grouped here. 2835 * other mac80211 functions grouped here.
2647 */ 2836 */
2648static int iwl_mac_setup_register(struct iwl_priv *priv) 2837static int iwl_mac_setup_register(struct iwl_priv *priv,
2838 struct iwlagn_ucode_capabilities *capa)
2649{ 2839{
2650 int ret; 2840 int ret;
2651 struct ieee80211_hw *hw = priv->hw; 2841 struct ieee80211_hw *hw = priv->hw;
@@ -2665,6 +2855,8 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2665 IEEE80211_HW_SUPPORTS_STATIC_SMPS; 2855 IEEE80211_HW_SUPPORTS_STATIC_SMPS;
2666 2856
2667 hw->sta_data_size = sizeof(struct iwl_station_priv); 2857 hw->sta_data_size = sizeof(struct iwl_station_priv);
2858 hw->vif_data_size = sizeof(struct iwl_vif_priv);
2859
2668 hw->wiphy->interface_modes = 2860 hw->wiphy->interface_modes =
2669 BIT(NL80211_IFTYPE_STATION) | 2861 BIT(NL80211_IFTYPE_STATION) |
2670 BIT(NL80211_IFTYPE_ADHOC); 2862 BIT(NL80211_IFTYPE_ADHOC);
@@ -2680,7 +2872,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2680 2872
2681 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; 2873 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
2682 /* we create the 802.11 header and a zero-length SSID element */ 2874 /* we create the 802.11 header and a zero-length SSID element */
2683 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 2875 hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2;
2684 2876
2685 /* Default value; 4 EDCA QOS priorities */ 2877 /* Default value; 4 EDCA QOS priorities */
2686 hw->queues = 4; 2878 hw->queues = 4;
@@ -2793,7 +2985,7 @@ static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2793 return NETDEV_TX_OK; 2985 return NETDEV_TX_OK;
2794} 2986}
2795 2987
2796void iwl_config_ap(struct iwl_priv *priv) 2988void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
2797{ 2989{
2798 int ret = 0; 2990 int ret = 0;
2799 2991
@@ -2808,7 +3000,7 @@ void iwl_config_ap(struct iwl_priv *priv)
2808 iwlcore_commit_rxon(priv); 3000 iwlcore_commit_rxon(priv);
2809 3001
2810 /* RXON Timing */ 3002 /* RXON Timing */
2811 iwl_setup_rxon_timing(priv); 3003 iwl_setup_rxon_timing(priv, vif);
2812 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3004 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
2813 sizeof(priv->rxon_timing), &priv->rxon_timing); 3005 sizeof(priv->rxon_timing), &priv->rxon_timing);
2814 if (ret) 3006 if (ret)
@@ -2822,9 +3014,10 @@ void iwl_config_ap(struct iwl_priv *priv)
2822 if (priv->cfg->ops->hcmd->set_rxon_chain) 3014 if (priv->cfg->ops->hcmd->set_rxon_chain)
2823 priv->cfg->ops->hcmd->set_rxon_chain(priv); 3015 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2824 3016
2825 /* FIXME: what should be the assoc_id for AP? */ 3017 priv->staging_rxon.assoc_id = 0;
2826 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3018
2827 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3019 if (vif->bss_conf.assoc_capability &
3020 WLAN_CAPABILITY_SHORT_PREAMBLE)
2828 priv->staging_rxon.flags |= 3021 priv->staging_rxon.flags |=
2829 RXON_FLG_SHORT_PREAMBLE_MSK; 3022 RXON_FLG_SHORT_PREAMBLE_MSK;
2830 else 3023 else
@@ -2832,22 +3025,21 @@ void iwl_config_ap(struct iwl_priv *priv)
2832 ~RXON_FLG_SHORT_PREAMBLE_MSK; 3025 ~RXON_FLG_SHORT_PREAMBLE_MSK;
2833 3026
2834 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3027 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
2835 if (priv->assoc_capability & 3028 if (vif->bss_conf.assoc_capability &
2836 WLAN_CAPABILITY_SHORT_SLOT_TIME) 3029 WLAN_CAPABILITY_SHORT_SLOT_TIME)
2837 priv->staging_rxon.flags |= 3030 priv->staging_rxon.flags |=
2838 RXON_FLG_SHORT_SLOT_MSK; 3031 RXON_FLG_SHORT_SLOT_MSK;
2839 else 3032 else
2840 priv->staging_rxon.flags &= 3033 priv->staging_rxon.flags &=
2841 ~RXON_FLG_SHORT_SLOT_MSK; 3034 ~RXON_FLG_SHORT_SLOT_MSK;
2842 3035
2843 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3036 if (vif->type == NL80211_IFTYPE_ADHOC)
2844 priv->staging_rxon.flags &= 3037 priv->staging_rxon.flags &=
2845 ~RXON_FLG_SHORT_SLOT_MSK; 3038 ~RXON_FLG_SHORT_SLOT_MSK;
2846 } 3039 }
2847 /* restore RXON assoc */ 3040 /* restore RXON assoc */
2848 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3041 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
2849 iwlcore_commit_rxon(priv); 3042 iwlcore_commit_rxon(priv);
2850 iwl_add_bcast_station(priv);
2851 } 3043 }
2852 iwl_send_beacon_cmd(priv); 3044 iwl_send_beacon_cmd(priv);
2853 3045
@@ -2866,8 +3058,7 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
2866 struct iwl_priv *priv = hw->priv; 3058 struct iwl_priv *priv = hw->priv;
2867 IWL_DEBUG_MAC80211(priv, "enter\n"); 3059 IWL_DEBUG_MAC80211(priv, "enter\n");
2868 3060
2869 iwl_update_tkip_key(priv, keyconf, 3061 iwl_update_tkip_key(priv, keyconf, sta,
2870 sta ? sta->addr : iwl_bcast_addr,
2871 iv32, phase1key); 3062 iv32, phase1key);
2872 3063
2873 IWL_DEBUG_MAC80211(priv, "leave\n"); 3064 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -2879,7 +3070,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2879 struct ieee80211_key_conf *key) 3070 struct ieee80211_key_conf *key)
2880{ 3071{
2881 struct iwl_priv *priv = hw->priv; 3072 struct iwl_priv *priv = hw->priv;
2882 const u8 *addr;
2883 int ret; 3073 int ret;
2884 u8 sta_id; 3074 u8 sta_id;
2885 bool is_default_wep_key = false; 3075 bool is_default_wep_key = false;
@@ -2890,13 +3080,17 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2890 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); 3080 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
2891 return -EOPNOTSUPP; 3081 return -EOPNOTSUPP;
2892 } 3082 }
2893 addr = sta ? sta->addr : iwl_bcast_addr;
2894 sta_id = iwl_find_station(priv, addr);
2895 if (sta_id == IWL_INVALID_STATION) {
2896 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
2897 addr);
2898 return -EINVAL;
2899 3083
3084 if (sta) {
3085 sta_id = iwl_sta_id(sta);
3086
3087 if (sta_id == IWL_INVALID_STATION) {
3088 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
3089 sta->addr);
3090 return -EINVAL;
3091 }
3092 } else {
3093 sta_id = priv->hw_params.bcast_sta_id;
2900 } 3094 }
2901 3095
2902 mutex_lock(&priv->mutex); 3096 mutex_lock(&priv->mutex);
@@ -2945,8 +3139,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2945 3139
2946static int iwl_mac_ampdu_action(struct ieee80211_hw *hw, 3140static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2947 struct ieee80211_vif *vif, 3141 struct ieee80211_vif *vif,
2948 enum ieee80211_ampdu_mlme_action action, 3142 enum ieee80211_ampdu_mlme_action action,
2949 struct ieee80211_sta *sta, u16 tid, u16 *ssn) 3143 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
2950{ 3144{
2951 struct iwl_priv *priv = hw->priv; 3145 struct iwl_priv *priv = hw->priv;
2952 int ret; 3146 int ret;
@@ -2960,17 +3154,17 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2960 switch (action) { 3154 switch (action) {
2961 case IEEE80211_AMPDU_RX_START: 3155 case IEEE80211_AMPDU_RX_START:
2962 IWL_DEBUG_HT(priv, "start Rx\n"); 3156 IWL_DEBUG_HT(priv, "start Rx\n");
2963 return iwl_sta_rx_agg_start(priv, sta->addr, tid, *ssn); 3157 return iwl_sta_rx_agg_start(priv, sta, tid, *ssn);
2964 case IEEE80211_AMPDU_RX_STOP: 3158 case IEEE80211_AMPDU_RX_STOP:
2965 IWL_DEBUG_HT(priv, "stop Rx\n"); 3159 IWL_DEBUG_HT(priv, "stop Rx\n");
2966 ret = iwl_sta_rx_agg_stop(priv, sta->addr, tid); 3160 ret = iwl_sta_rx_agg_stop(priv, sta, tid);
2967 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3161 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2968 return 0; 3162 return 0;
2969 else 3163 else
2970 return ret; 3164 return ret;
2971 case IEEE80211_AMPDU_TX_START: 3165 case IEEE80211_AMPDU_TX_START:
2972 IWL_DEBUG_HT(priv, "start Tx\n"); 3166 IWL_DEBUG_HT(priv, "start Tx\n");
2973 ret = iwlagn_tx_agg_start(priv, sta->addr, tid, ssn); 3167 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
2974 if (ret == 0) { 3168 if (ret == 0) {
2975 priv->_agn.agg_tids_count++; 3169 priv->_agn.agg_tids_count++;
2976 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n", 3170 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
@@ -2979,7 +3173,7 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2979 return ret; 3173 return ret;
2980 case IEEE80211_AMPDU_TX_STOP: 3174 case IEEE80211_AMPDU_TX_STOP:
2981 IWL_DEBUG_HT(priv, "stop Tx\n"); 3175 IWL_DEBUG_HT(priv, "stop Tx\n");
2982 ret = iwlagn_tx_agg_stop(priv, sta->addr, tid); 3176 ret = iwlagn_tx_agg_stop(priv, vif, sta, tid);
2983 if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) { 3177 if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) {
2984 priv->_agn.agg_tids_count--; 3178 priv->_agn.agg_tids_count--;
2985 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n", 3179 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
@@ -3021,7 +3215,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
3021 if (!sta_priv->asleep) 3215 if (!sta_priv->asleep)
3022 break; 3216 break;
3023 sta_priv->asleep = false; 3217 sta_priv->asleep = false;
3024 sta_id = iwl_find_station(priv, sta->addr); 3218 sta_id = iwl_sta_id(sta);
3025 if (sta_id != IWL_INVALID_STATION) 3219 if (sta_id != IWL_INVALID_STATION)
3026 iwl_sta_modify_ps_wake(priv, sta_id); 3220 iwl_sta_modify_ps_wake(priv, sta_id);
3027 break; 3221 break;
@@ -3036,10 +3230,12 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3036{ 3230{
3037 struct iwl_priv *priv = hw->priv; 3231 struct iwl_priv *priv = hw->priv;
3038 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 3232 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
3039 bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION; 3233 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
3040 int ret; 3234 int ret;
3041 u8 sta_id; 3235 u8 sta_id;
3042 3236
3237 sta_priv->common.sta_id = IWL_INVALID_STATION;
3238
3043 IWL_DEBUG_INFO(priv, "received request to add station %pM\n", 3239 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3044 sta->addr); 3240 sta->addr);
3045 3241
@@ -3056,12 +3252,14 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3056 return ret; 3252 return ret;
3057 } 3253 }
3058 3254
3255 sta_priv->common.sta_id = sta_id;
3256
3059 /* Initialize rate scaling */ 3257 /* Initialize rate scaling */
3060 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", 3258 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
3061 sta->addr); 3259 sta->addr);
3062 iwl_rs_rate_init(priv, sta, sta_id); 3260 iwl_rs_rate_init(priv, sta, sta_id);
3063 3261
3064 return ret; 3262 return 0;
3065} 3263}
3066 3264
3067/***************************************************************************** 3265/*****************************************************************************
@@ -3586,6 +3784,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3586 iwl_power_initialize(priv); 3784 iwl_power_initialize(priv);
3587 iwl_tt_initialize(priv); 3785 iwl_tt_initialize(priv);
3588 3786
3787 init_completion(&priv->_agn.firmware_loading_complete);
3788
3589 err = iwl_request_firmware(priv, true); 3789 err = iwl_request_firmware(priv, true);
3590 if (err) 3790 if (err)
3591 goto out_remove_sysfs; 3791 goto out_remove_sysfs;
@@ -3626,6 +3826,8 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
3626 if (!priv) 3826 if (!priv)
3627 return; 3827 return;
3628 3828
3829 wait_for_completion(&priv->_agn.firmware_loading_complete);
3830
3629 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); 3831 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
3630 3832
3631 iwl_dbgfs_unregister(priv); 3833 iwl_dbgfs_unregister(priv);
@@ -3783,11 +3985,10 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
3783 {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)}, 3985 {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)},
3784 {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)}, 3986 {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)},
3785 3987
3786/* 6x00 Series Gen2 */ 3988/* 6x00 Series Gen2a */
3787 {IWL_PCI_DEVICE(0x0082, 0x1201, iwl6000g2_2agn_cfg)}, 3989 {IWL_PCI_DEVICE(0x0082, 0x1201, iwl6000g2a_2agn_cfg)},
3788 {IWL_PCI_DEVICE(0x0082, 0x1301, iwl6000g2_2agn_cfg)}, 3990 {IWL_PCI_DEVICE(0x0085, 0x1211, iwl6000g2a_2agn_cfg)},
3789 {IWL_PCI_DEVICE(0x0082, 0x1321, iwl6000g2_2agn_cfg)}, 3991 {IWL_PCI_DEVICE(0x0082, 0x1221, iwl6000g2a_2agn_cfg)},
3790 {IWL_PCI_DEVICE(0x0085, 0x1311, iwl6000g2_2agn_cfg)},
3791 3992
3792/* 6x50 WiFi/WiMax Series */ 3993/* 6x50 WiFi/WiMax Series */
3793 {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)}, 3994 {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)},
@@ -3900,3 +4101,8 @@ MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
3900module_param_named( 4101module_param_named(
3901 disable_hw_scan, iwlagn_mod_params.disable_hw_scan, int, S_IRUGO); 4102 disable_hw_scan, iwlagn_mod_params.disable_hw_scan, int, S_IRUGO);
3902MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)"); 4103MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");
4104
4105module_param_named(ucode_alternative, iwlagn_wanted_ucode_alternative, int,
4106 S_IRUGO);
4107MODULE_PARM_DESC(ucode_alternative,
4108 "specify ucode alternative to use from ucode file");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index cfee9994383e..2d748053358e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -66,7 +66,6 @@
66#include "iwl-dev.h" 66#include "iwl-dev.h"
67 67
68extern struct iwl_mod_params iwlagn_mod_params; 68extern struct iwl_mod_params iwlagn_mod_params;
69extern struct iwl_ucode_ops iwlagn_ucode;
70extern struct iwl_hcmd_ops iwlagn_hcmd; 69extern struct iwl_hcmd_ops iwlagn_hcmd;
71extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils; 70extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils;
72 71
@@ -136,9 +135,10 @@ void iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,
136void iwlagn_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, 135void iwlagn_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
137 struct ieee80211_tx_info *info); 136 struct ieee80211_tx_info *info);
138int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); 137int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb);
139int iwlagn_tx_agg_start(struct iwl_priv *priv, 138int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
140 const u8 *ra, u16 tid, u16 *ssn); 139 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
141int iwlagn_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid); 140int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
141 struct ieee80211_sta *sta, u16 tid);
142int iwlagn_txq_check_empty(struct iwl_priv *priv, 142int iwlagn_txq_check_empty(struct iwl_priv *priv,
143 int sta_id, u8 tid, int txq_id); 143 int sta_id, u8 tid, int txq_id);
144void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, 144void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
@@ -172,6 +172,10 @@ static inline bool iwl_is_tx_success(u32 status)
172} 172}
173 173
174/* scan */ 174/* scan */
175void iwlagn_request_scan(struct iwl_priv *priv); 175void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
176
177/* station mgmt */
178int iwlagn_manage_ibss_station(struct iwl_priv *priv,
179 struct ieee80211_vif *vif, bool add);
176 180
177#endif /* __iwl_agn_h__ */ 181#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 0086019b7a15..9aab020c474b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -2668,7 +2668,6 @@ struct iwl_ssid_ie {
2668#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) 2668#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
2669#define IWL_MAX_SCAN_SIZE 1024 2669#define IWL_MAX_SCAN_SIZE 1024
2670#define IWL_MAX_CMD_SIZE 4096 2670#define IWL_MAX_CMD_SIZE 4096
2671#define IWL_MAX_PROBE_REQUEST 200
2672 2671
2673/* 2672/*
2674 * REPLY_SCAN_CMD = 0x80 (command) 2673 * REPLY_SCAN_CMD = 0x80 (command)
@@ -3128,6 +3127,11 @@ struct statistics_tx {
3128 __le32 cts_timeout_collision; 3127 __le32 cts_timeout_collision;
3129 __le32 ack_or_ba_timeout_collision; 3128 __le32 ack_or_ba_timeout_collision;
3130 struct statistics_tx_non_phy_agg agg; 3129 struct statistics_tx_non_phy_agg agg;
3130 /*
3131 * "tx_power" are optional parameters provided by uCode,
3132 * 6000 series is the only device provide the information,
3133 * Those are reserved fields for all the other devices
3134 */
3131 struct statistics_tx_power tx_power; 3135 struct statistics_tx_power tx_power;
3132 __le32 reserved1; 3136 __le32 reserved1;
3133} __attribute__ ((packed)); 3137} __attribute__ ((packed));
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 87eb89f000f5..5a7eca8fb789 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -68,37 +68,6 @@ static bool bt_coex_active = true;
68module_param(bt_coex_active, bool, S_IRUGO); 68module_param(bt_coex_active, bool, S_IRUGO);
69MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); 69MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist");
70 70
71static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
72 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP,
73 0, COEX_UNASSOC_IDLE_FLAGS},
74 {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP,
75 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
76 {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP,
77 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
78 {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP,
79 0, COEX_CALIBRATION_FLAGS},
80 {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP,
81 0, COEX_PERIODIC_CALIBRATION_FLAGS},
82 {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP,
83 0, COEX_CONNECTION_ESTAB_FLAGS},
84 {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP,
85 0, COEX_ASSOCIATED_IDLE_FLAGS},
86 {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP,
87 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
88 {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP,
89 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
90 {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP,
91 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
92 {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS},
93 {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS},
94 {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP,
95 0, COEX_STAND_ALONE_DEBUG_FLAGS},
96 {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP,
97 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
98 {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS},
99 {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS}
100};
101
102#define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ 71#define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \
103 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ 72 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \
104 IWL_RATE_SISO_##s##M_PLCP, \ 73 IWL_RATE_SISO_##s##M_PLCP, \
@@ -512,7 +481,7 @@ static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
512 return new_val; 481 return new_val;
513} 482}
514 483
515void iwl_setup_rxon_timing(struct iwl_priv *priv) 484void iwl_setup_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif)
516{ 485{
517 u64 tsf; 486 u64 tsf;
518 s32 interval_tm, rem; 487 s32 interval_tm, rem;
@@ -526,15 +495,14 @@ void iwl_setup_rxon_timing(struct iwl_priv *priv)
526 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp); 495 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
527 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval); 496 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval);
528 497
529 if (priv->iw_mode == NL80211_IFTYPE_STATION) { 498 beacon_int = vif->bss_conf.beacon_int;
530 beacon_int = priv->beacon_int;
531 priv->rxon_timing.atim_window = 0;
532 } else {
533 beacon_int = priv->vif->bss_conf.beacon_int;
534 499
500 if (vif->type == NL80211_IFTYPE_ADHOC) {
535 /* TODO: we need to get atim_window from upper stack 501 /* TODO: we need to get atim_window from upper stack
536 * for now we set to 0 */ 502 * for now we set to 0 */
537 priv->rxon_timing.atim_window = 0; 503 priv->rxon_timing.atim_window = 0;
504 } else {
505 priv->rxon_timing.atim_window = 0;
538 } 506 }
539 507
540 beacon_int = iwl_adjust_beacon_interval(beacon_int, 508 beacon_int = iwl_adjust_beacon_interval(beacon_int,
@@ -925,8 +893,9 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch)
925} 893}
926EXPORT_SYMBOL(iwl_set_rxon_channel); 894EXPORT_SYMBOL(iwl_set_rxon_channel);
927 895
928void iwl_set_flags_for_band(struct iwl_priv *priv, 896static void iwl_set_flags_for_band(struct iwl_priv *priv,
929 enum ieee80211_band band) 897 enum ieee80211_band band,
898 struct ieee80211_vif *vif)
930{ 899{
931 if (band == IEEE80211_BAND_5GHZ) { 900 if (band == IEEE80211_BAND_5GHZ) {
932 priv->staging_rxon.flags &= 901 priv->staging_rxon.flags &=
@@ -935,12 +904,12 @@ void iwl_set_flags_for_band(struct iwl_priv *priv,
935 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 904 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
936 } else { 905 } else {
937 /* Copied from iwl_post_associate() */ 906 /* Copied from iwl_post_associate() */
938 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 907 if (vif && vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
939 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 908 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
940 else 909 else
941 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 910 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
942 911
943 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 912 if (vif && vif->type == NL80211_IFTYPE_ADHOC)
944 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 913 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
945 914
946 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 915 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
@@ -952,13 +921,18 @@ void iwl_set_flags_for_band(struct iwl_priv *priv,
952/* 921/*
953 * initialize rxon structure with default values from eeprom 922 * initialize rxon structure with default values from eeprom
954 */ 923 */
955void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode) 924void iwl_connection_init_rx_config(struct iwl_priv *priv,
925 struct ieee80211_vif *vif)
956{ 926{
957 const struct iwl_channel_info *ch_info; 927 const struct iwl_channel_info *ch_info;
928 enum nl80211_iftype type = NL80211_IFTYPE_STATION;
929
930 if (vif)
931 type = vif->type;
958 932
959 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 933 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
960 934
961 switch (mode) { 935 switch (type) {
962 case NL80211_IFTYPE_AP: 936 case NL80211_IFTYPE_AP:
963 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP; 937 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
964 break; 938 break;
@@ -976,7 +950,7 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
976 break; 950 break;
977 951
978 default: 952 default:
979 IWL_ERR(priv, "Unsupported interface type %d\n", mode); 953 IWL_ERR(priv, "Unsupported interface type %d\n", type);
980 break; 954 break;
981 } 955 }
982 956
@@ -998,7 +972,7 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
998 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 972 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
999 priv->band = ch_info->band; 973 priv->band = ch_info->band;
1000 974
1001 iwl_set_flags_for_band(priv, priv->band); 975 iwl_set_flags_for_band(priv, priv->band, vif);
1002 976
1003 priv->staging_rxon.ofdm_basic_rates = 977 priv->staging_rxon.ofdm_basic_rates =
1004 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 978 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
@@ -1099,6 +1073,9 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
1099 /* Cancel currently queued command. */ 1073 /* Cancel currently queued command. */
1100 clear_bit(STATUS_HCMD_ACTIVE, &priv->status); 1074 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
1101 1075
1076 IWL_ERR(priv, "Loaded firmware version: %s\n",
1077 priv->hw->wiphy->fw_version);
1078
1102 priv->cfg->ops->lib->dump_nic_error_log(priv); 1079 priv->cfg->ops->lib->dump_nic_error_log(priv);
1103 if (priv->cfg->ops->lib->dump_csr) 1080 if (priv->cfg->ops->lib->dump_csr)
1104 priv->cfg->ops->lib->dump_csr(priv); 1081 priv->cfg->ops->lib->dump_csr(priv);
@@ -1285,41 +1262,33 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
1285 u64 multicast) 1262 u64 multicast)
1286{ 1263{
1287 struct iwl_priv *priv = hw->priv; 1264 struct iwl_priv *priv = hw->priv;
1288 __le32 *filter_flags = &priv->staging_rxon.filter_flags; 1265 __le32 filter_or = 0, filter_nand = 0;
1266
1267#define CHK(test, flag) do { \
1268 if (*total_flags & (test)) \
1269 filter_or |= (flag); \
1270 else \
1271 filter_nand |= (flag); \
1272 } while (0)
1289 1273
1290 IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", 1274 IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n",
1291 changed_flags, *total_flags); 1275 changed_flags, *total_flags);
1292 1276
1293 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) { 1277 CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK);
1294 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) 1278 CHK(FIF_ALLMULTI, RXON_FILTER_ACCEPT_GRP_MSK);
1295 *filter_flags |= RXON_FILTER_PROMISC_MSK; 1279 CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK);
1296 else 1280 CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK);
1297 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
1298 }
1299 if (changed_flags & FIF_ALLMULTI) {
1300 if (*total_flags & FIF_ALLMULTI)
1301 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
1302 else
1303 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
1304 }
1305 if (changed_flags & FIF_CONTROL) {
1306 if (*total_flags & FIF_CONTROL)
1307 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
1308 else
1309 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
1310 }
1311 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
1312 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
1313 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
1314 else
1315 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
1316 }
1317 1281
1318 /* We avoid iwl_commit_rxon here to commit the new filter flags 1282#undef CHK
1319 * since mac80211 will call ieee80211_hw_config immediately. 1283
1320 * (mc_list is not supported at this time). Otherwise, we need to 1284 mutex_lock(&priv->mutex);
1321 * queue a background iwl_commit_rxon work. 1285
1322 */ 1286 priv->staging_rxon.filter_flags &= ~filter_nand;
1287 priv->staging_rxon.filter_flags |= filter_or;
1288
1289 iwlcore_commit_rxon(priv);
1290
1291 mutex_unlock(&priv->mutex);
1323 1292
1324 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | 1293 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
1325 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 1294 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
@@ -1771,10 +1740,11 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
1771EXPORT_SYMBOL(iwl_mac_conf_tx); 1740EXPORT_SYMBOL(iwl_mac_conf_tx);
1772 1741
1773static void iwl_ht_conf(struct iwl_priv *priv, 1742static void iwl_ht_conf(struct iwl_priv *priv,
1774 struct ieee80211_bss_conf *bss_conf) 1743 struct ieee80211_vif *vif)
1775{ 1744{
1776 struct iwl_ht_config *ht_conf = &priv->current_ht_config; 1745 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
1777 struct ieee80211_sta *sta; 1746 struct ieee80211_sta *sta;
1747 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1778 1748
1779 IWL_DEBUG_MAC80211(priv, "enter:\n"); 1749 IWL_DEBUG_MAC80211(priv, "enter:\n");
1780 1750
@@ -1788,10 +1758,10 @@ static void iwl_ht_conf(struct iwl_priv *priv,
1788 1758
1789 ht_conf->single_chain_sufficient = false; 1759 ht_conf->single_chain_sufficient = false;
1790 1760
1791 switch (priv->iw_mode) { 1761 switch (vif->type) {
1792 case NL80211_IFTYPE_STATION: 1762 case NL80211_IFTYPE_STATION:
1793 rcu_read_lock(); 1763 rcu_read_lock();
1794 sta = ieee80211_find_sta(priv->vif, priv->bssid); 1764 sta = ieee80211_find_sta(vif, bss_conf->bssid);
1795 if (sta) { 1765 if (sta) {
1796 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; 1766 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
1797 int maxstreams; 1767 int maxstreams;
@@ -1829,7 +1799,6 @@ static void iwl_ht_conf(struct iwl_priv *priv,
1829 1799
1830static inline void iwl_set_no_assoc(struct iwl_priv *priv) 1800static inline void iwl_set_no_assoc(struct iwl_priv *priv)
1831{ 1801{
1832 priv->assoc_id = 0;
1833 iwl_led_disassociate(priv); 1802 iwl_led_disassociate(priv);
1834 /* 1803 /*
1835 * inform the ucode that there is no longer an 1804 * inform the ucode that there is no longer an
@@ -1857,14 +1826,12 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1857 1826
1858 mutex_lock(&priv->mutex); 1827 mutex_lock(&priv->mutex);
1859 1828
1860 if (changes & BSS_CHANGED_BEACON && 1829 if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_AP) {
1861 priv->iw_mode == NL80211_IFTYPE_AP) {
1862 dev_kfree_skb(priv->ibss_beacon); 1830 dev_kfree_skb(priv->ibss_beacon);
1863 priv->ibss_beacon = ieee80211_beacon_get(hw, vif); 1831 priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
1864 } 1832 }
1865 1833
1866 if (changes & BSS_CHANGED_BEACON_INT) { 1834 if (changes & BSS_CHANGED_BEACON_INT) {
1867 priv->beacon_int = bss_conf->beacon_int;
1868 /* TODO: in AP mode, do something to make this take effect */ 1835 /* TODO: in AP mode, do something to make this take effect */
1869 } 1836 }
1870 1837
@@ -1884,8 +1851,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1884 } 1851 }
1885 1852
1886 /* mac80211 only sets assoc when in STATION mode */ 1853 /* mac80211 only sets assoc when in STATION mode */
1887 if (priv->iw_mode == NL80211_IFTYPE_ADHOC || 1854 if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) {
1888 bss_conf->assoc) {
1889 memcpy(priv->staging_rxon.bssid_addr, 1855 memcpy(priv->staging_rxon.bssid_addr,
1890 bss_conf->bssid, ETH_ALEN); 1856 bss_conf->bssid, ETH_ALEN);
1891 1857
@@ -1903,7 +1869,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1903 * mac80211 decides to do both changes at once because 1869 * mac80211 decides to do both changes at once because
1904 * it will invoke post_associate. 1870 * it will invoke post_associate.
1905 */ 1871 */
1906 if (priv->iw_mode == NL80211_IFTYPE_ADHOC && 1872 if (vif->type == NL80211_IFTYPE_ADHOC &&
1907 changes & BSS_CHANGED_BEACON) { 1873 changes & BSS_CHANGED_BEACON) {
1908 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); 1874 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
1909 1875
@@ -1946,7 +1912,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1946 } 1912 }
1947 1913
1948 if (changes & BSS_CHANGED_HT) { 1914 if (changes & BSS_CHANGED_HT) {
1949 iwl_ht_conf(priv, bss_conf); 1915 iwl_ht_conf(priv, vif);
1950 1916
1951 if (priv->cfg->ops->hcmd->set_rxon_chain) 1917 if (priv->cfg->ops->hcmd->set_rxon_chain)
1952 priv->cfg->ops->hcmd->set_rxon_chain(priv); 1918 priv->cfg->ops->hcmd->set_rxon_chain(priv);
@@ -1955,20 +1921,17 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1955 if (changes & BSS_CHANGED_ASSOC) { 1921 if (changes & BSS_CHANGED_ASSOC) {
1956 IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); 1922 IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
1957 if (bss_conf->assoc) { 1923 if (bss_conf->assoc) {
1958 priv->assoc_id = bss_conf->aid;
1959 priv->beacon_int = bss_conf->beacon_int;
1960 priv->timestamp = bss_conf->timestamp; 1924 priv->timestamp = bss_conf->timestamp;
1961 priv->assoc_capability = bss_conf->assoc_capability;
1962 1925
1963 iwl_led_associate(priv); 1926 iwl_led_associate(priv);
1964 1927
1965 if (!iwl_is_rfkill(priv)) 1928 if (!iwl_is_rfkill(priv))
1966 priv->cfg->ops->lib->post_associate(priv); 1929 priv->cfg->ops->lib->post_associate(priv, vif);
1967 } else 1930 } else
1968 iwl_set_no_assoc(priv); 1931 iwl_set_no_assoc(priv);
1969 } 1932 }
1970 1933
1971 if (changes && iwl_is_associated(priv) && priv->assoc_id) { 1934 if (changes && iwl_is_associated(priv) && bss_conf->aid) {
1972 IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", 1935 IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n",
1973 changes); 1936 changes);
1974 ret = iwl_send_rxon_assoc(priv); 1937 ret = iwl_send_rxon_assoc(priv);
@@ -1985,11 +1948,20 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1985 memcpy(priv->staging_rxon.bssid_addr, 1948 memcpy(priv->staging_rxon.bssid_addr,
1986 bss_conf->bssid, ETH_ALEN); 1949 bss_conf->bssid, ETH_ALEN);
1987 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); 1950 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
1988 iwlcore_config_ap(priv); 1951 iwlcore_config_ap(priv, vif);
1989 } else 1952 } else
1990 iwl_set_no_assoc(priv); 1953 iwl_set_no_assoc(priv);
1991 } 1954 }
1992 1955
1956 if (changes & BSS_CHANGED_IBSS) {
1957 ret = priv->cfg->ops->lib->manage_ibss_station(priv, vif,
1958 bss_conf->ibss_joined);
1959 if (ret)
1960 IWL_ERR(priv, "failed to %s IBSS station %pM\n",
1961 bss_conf->ibss_joined ? "add" : "remove",
1962 bss_conf->bssid);
1963 }
1964
1993 mutex_unlock(&priv->mutex); 1965 mutex_unlock(&priv->mutex);
1994 1966
1995 IWL_DEBUG_MAC80211(priv, "leave\n"); 1967 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -2016,14 +1988,13 @@ int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
2016 1988
2017 priv->ibss_beacon = skb; 1989 priv->ibss_beacon = skb;
2018 1990
2019 priv->assoc_id = 0;
2020 timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; 1991 timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
2021 priv->timestamp = le64_to_cpu(timestamp); 1992 priv->timestamp = le64_to_cpu(timestamp);
2022 1993
2023 IWL_DEBUG_MAC80211(priv, "leave\n"); 1994 IWL_DEBUG_MAC80211(priv, "leave\n");
2024 spin_unlock_irqrestore(&priv->lock, flags); 1995 spin_unlock_irqrestore(&priv->lock, flags);
2025 1996
2026 priv->cfg->ops->lib->post_associate(priv); 1997 priv->cfg->ops->lib->post_associate(priv, priv->vif);
2027 1998
2028 return 0; 1999 return 0;
2029} 2000}
@@ -2031,7 +2002,7 @@ EXPORT_SYMBOL(iwl_mac_beacon_update);
2031 2002
2032static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif) 2003static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif)
2033{ 2004{
2034 iwl_connection_init_rx_config(priv, vif->type); 2005 iwl_connection_init_rx_config(priv, vif);
2035 2006
2036 if (priv->cfg->ops->hcmd->set_rxon_chain) 2007 if (priv->cfg->ops->hcmd->set_rxon_chain)
2037 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2008 priv->cfg->ops->hcmd->set_rxon_chain(priv);
@@ -2071,9 +2042,6 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2071 if (err) 2042 if (err)
2072 goto out_err; 2043 goto out_err;
2073 2044
2074 /* Add the broadcast address so we can send broadcast frames */
2075 priv->cfg->ops->lib->add_bcast_station(priv);
2076
2077 goto out; 2045 goto out;
2078 2046
2079 out_err: 2047 out_err:
@@ -2096,8 +2064,6 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2096 2064
2097 mutex_lock(&priv->mutex); 2065 mutex_lock(&priv->mutex);
2098 2066
2099 iwl_clear_ucode_stations(priv, true);
2100
2101 if (iwl_is_ready_rf(priv)) { 2067 if (iwl_is_ready_rf(priv)) {
2102 iwl_scan_cancel_timeout(priv, 100); 2068 iwl_scan_cancel_timeout(priv, 100);
2103 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2069 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
@@ -2203,7 +2169,7 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2203 iwl_set_rxon_channel(priv, conf->channel); 2169 iwl_set_rxon_channel(priv, conf->channel);
2204 iwl_set_rxon_ht(priv, ht_conf); 2170 iwl_set_rxon_ht(priv, ht_conf);
2205 2171
2206 iwl_set_flags_for_band(priv, conf->channel->band); 2172 iwl_set_flags_for_band(priv, conf->channel->band, priv->vif);
2207 spin_unlock_irqrestore(&priv->lock, flags); 2173 spin_unlock_irqrestore(&priv->lock, flags);
2208 if (iwl_is_associated(priv) && 2174 if (iwl_is_associated(priv) &&
2209 (le16_to_cpu(priv->active_rxon.channel) != ch) && 2175 (le16_to_cpu(priv->active_rxon.channel) != ch) &&
@@ -2286,8 +2252,6 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2286 spin_unlock_irqrestore(&priv->lock, flags); 2252 spin_unlock_irqrestore(&priv->lock, flags);
2287 2253
2288 spin_lock_irqsave(&priv->lock, flags); 2254 spin_lock_irqsave(&priv->lock, flags);
2289 priv->assoc_id = 0;
2290 priv->assoc_capability = 0;
2291 2255
2292 /* new association get rid of ibss beacon skb */ 2256 /* new association get rid of ibss beacon skb */
2293 if (priv->ibss_beacon) 2257 if (priv->ibss_beacon)
@@ -2295,7 +2259,6 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2295 2259
2296 priv->ibss_beacon = NULL; 2260 priv->ibss_beacon = NULL;
2297 2261
2298 priv->beacon_int = priv->vif->bss_conf.beacon_int;
2299 priv->timestamp = 0; 2262 priv->timestamp = 0;
2300 2263
2301 spin_unlock_irqrestore(&priv->lock, flags); 2264 spin_unlock_irqrestore(&priv->lock, flags);
@@ -2342,34 +2305,6 @@ void iwl_free_txq_mem(struct iwl_priv *priv)
2342} 2305}
2343EXPORT_SYMBOL(iwl_free_txq_mem); 2306EXPORT_SYMBOL(iwl_free_txq_mem);
2344 2307
2345int iwl_send_wimax_coex(struct iwl_priv *priv)
2346{
2347 struct iwl_wimax_coex_cmd coex_cmd;
2348
2349 if (priv->cfg->support_wimax_coexist) {
2350 /* UnMask wake up src at associated sleep */
2351 coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK;
2352
2353 /* UnMask wake up src at unassociated sleep */
2354 coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK;
2355 memcpy(coex_cmd.sta_prio, cu_priorities,
2356 sizeof(struct iwl_wimax_coex_event_entry) *
2357 COEX_NUM_OF_EVENTS);
2358
2359 /* enabling the coexistence feature */
2360 coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK;
2361
2362 /* enabling the priorities tables */
2363 coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK;
2364 } else {
2365 /* coexistence is disabled */
2366 memset(&coex_cmd, 0, sizeof(coex_cmd));
2367 }
2368 return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD,
2369 sizeof(coex_cmd), &coex_cmd);
2370}
2371EXPORT_SYMBOL(iwl_send_wimax_coex);
2372
2373#ifdef CONFIG_IWLWIFI_DEBUGFS 2308#ifdef CONFIG_IWLWIFI_DEBUGFS
2374 2309
2375#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES) 2310#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES)
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 727360944859..7e5a5ba41fd2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -106,7 +106,7 @@ struct iwl_hcmd_utils_ops {
106 __le32 *tx_flags); 106 __le32 *tx_flags);
107 int (*calc_rssi)(struct iwl_priv *priv, 107 int (*calc_rssi)(struct iwl_priv *priv,
108 struct iwl_rx_phy_res *rx_resp); 108 struct iwl_rx_phy_res *rx_resp);
109 void (*request_scan)(struct iwl_priv *priv); 109 void (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif);
110}; 110};
111 111
112struct iwl_apm_ops { 112struct iwl_apm_ops {
@@ -131,17 +131,6 @@ struct iwl_temp_ops {
131 void (*set_calib_version)(struct iwl_priv *priv); 131 void (*set_calib_version)(struct iwl_priv *priv);
132}; 132};
133 133
134struct iwl_ucode_ops {
135 u32 (*get_header_size)(u32);
136 u32 (*get_build)(const struct iwl_ucode_header *, u32);
137 u32 (*get_inst_size)(const struct iwl_ucode_header *, u32);
138 u32 (*get_data_size)(const struct iwl_ucode_header *, u32);
139 u32 (*get_init_size)(const struct iwl_ucode_header *, u32);
140 u32 (*get_init_data_size)(const struct iwl_ucode_header *, u32);
141 u32 (*get_boot_size)(const struct iwl_ucode_header *, u32);
142 u8 * (*get_data)(const struct iwl_ucode_header *, u32);
143};
144
145struct iwl_lib_ops { 134struct iwl_lib_ops {
146 /* set hw dependent parameters */ 135 /* set hw dependent parameters */
147 int (*set_hw_params)(struct iwl_priv *priv); 136 int (*set_hw_params)(struct iwl_priv *priv);
@@ -191,8 +180,9 @@ struct iwl_lib_ops {
191 /* power */ 180 /* power */
192 int (*send_tx_power) (struct iwl_priv *priv); 181 int (*send_tx_power) (struct iwl_priv *priv);
193 void (*update_chain_flags)(struct iwl_priv *priv); 182 void (*update_chain_flags)(struct iwl_priv *priv);
194 void (*post_associate) (struct iwl_priv *priv); 183 void (*post_associate)(struct iwl_priv *priv,
195 void (*config_ap) (struct iwl_priv *priv); 184 struct ieee80211_vif *vif);
185 void (*config_ap)(struct iwl_priv *priv, struct ieee80211_vif *vif);
196 irqreturn_t (*isr) (int irq, void *data); 186 irqreturn_t (*isr) (int irq, void *data);
197 187
198 /* eeprom operations (as defined in iwl-eeprom.h) */ 188 /* eeprom operations (as defined in iwl-eeprom.h) */
@@ -201,7 +191,8 @@ struct iwl_lib_ops {
201 /* temperature */ 191 /* temperature */
202 struct iwl_temp_ops temp_ops; 192 struct iwl_temp_ops temp_ops;
203 /* station management */ 193 /* station management */
204 void (*add_bcast_station)(struct iwl_priv *priv); 194 int (*manage_ibss_station)(struct iwl_priv *priv,
195 struct ieee80211_vif *vif, bool add);
205 /* recover from tx queue stall */ 196 /* recover from tx queue stall */
206 void (*recover_from_tx_stall)(unsigned long data); 197 void (*recover_from_tx_stall)(unsigned long data);
207 /* check for plcp health */ 198 /* check for plcp health */
@@ -220,7 +211,6 @@ struct iwl_led_ops {
220}; 211};
221 212
222struct iwl_ops { 213struct iwl_ops {
223 const struct iwl_ucode_ops *ucode;
224 const struct iwl_lib_ops *lib; 214 const struct iwl_lib_ops *lib;
225 const struct iwl_hcmd_ops *hcmd; 215 const struct iwl_hcmd_ops *hcmd;
226 const struct iwl_hcmd_utils_ops *utils; 216 const struct iwl_hcmd_utils_ops *utils;
@@ -257,6 +247,18 @@ struct iwl_mod_params {
257 * @support_wimax_coexist: support wimax/wifi co-exist 247 * @support_wimax_coexist: support wimax/wifi co-exist
258 * @plcp_delta_threshold: plcp error rate threshold used to trigger 248 * @plcp_delta_threshold: plcp error rate threshold used to trigger
259 * radio tuning when there is a high receiving plcp error rate 249 * radio tuning when there is a high receiving plcp error rate
250 * @chain_noise_scale: default chain noise scale used for gain computation
251 * @monitor_recover_period: default timer used to check stuck queues
252 * @temperature_kelvin: temperature report by uCode in kelvin
253 * @max_event_log_size: size of event log buffer size for ucode event logging
254 * @tx_power_by_driver: tx power calibration performed by driver
255 * instead of uCode
256 * @ucode_tracing: support ucode continuous tracing
257 * @sensitivity_calib_by_driver: driver has the capability to perform
258 * sensitivity calibration operation
259 * @chain_noise_calib_by_driver: driver has the capability to perform
260 * chain noise calibration operation
261 * @scan_antennas: available antenna for scan operation
260 * 262 *
261 * We enable the driver to be backward compatible wrt API version. The 263 * We enable the driver to be backward compatible wrt API version. The
262 * driver specifies which APIs it supports (with @ucode_api_max being the 264 * driver specifies which APIs it supports (with @ucode_api_max being the
@@ -319,6 +321,10 @@ struct iwl_cfg {
319 u32 monitor_recover_period; 321 u32 monitor_recover_period;
320 bool temperature_kelvin; 322 bool temperature_kelvin;
321 u32 max_event_log_size; 323 u32 max_event_log_size;
324 const bool tx_power_by_driver;
325 const bool ucode_tracing;
326 const bool sensitivity_calib_by_driver;
327 const bool chain_noise_calib_by_driver;
322 u8 scan_antennas[IEEE80211_NUM_BANDS]; 328 u8 scan_antennas[IEEE80211_NUM_BANDS];
323}; 329};
324 330
@@ -340,8 +346,8 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch);
340void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf); 346void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
341u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv, 347u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
342 struct ieee80211_sta_ht_cap *sta_ht_inf); 348 struct ieee80211_sta_ht_cap *sta_ht_inf);
343void iwl_set_flags_for_band(struct iwl_priv *priv, enum ieee80211_band band); 349void iwl_connection_init_rx_config(struct iwl_priv *priv,
344void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode); 350 struct ieee80211_vif *vif);
345int iwl_set_decrypted_flag(struct iwl_priv *priv, 351int iwl_set_decrypted_flag(struct iwl_priv *priv,
346 struct ieee80211_hdr *hdr, 352 struct ieee80211_hdr *hdr,
347 u32 decrypt_res, 353 u32 decrypt_res,
@@ -351,7 +357,7 @@ void iwl_configure_filter(struct ieee80211_hw *hw,
351 unsigned int changed_flags, 357 unsigned int changed_flags,
352 unsigned int *total_flags, u64 multicast); 358 unsigned int *total_flags, u64 multicast);
353int iwl_set_hw_params(struct iwl_priv *priv); 359int iwl_set_hw_params(struct iwl_priv *priv);
354void iwl_post_associate(struct iwl_priv *priv); 360void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif);
355void iwl_bss_info_changed(struct ieee80211_hw *hw, 361void iwl_bss_info_changed(struct ieee80211_hw *hw,
356 struct ieee80211_vif *vif, 362 struct ieee80211_vif *vif,
357 struct ieee80211_bss_conf *bss_conf, 363 struct ieee80211_bss_conf *bss_conf,
@@ -363,13 +369,12 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
363void iwl_mac_remove_interface(struct ieee80211_hw *hw, 369void iwl_mac_remove_interface(struct ieee80211_hw *hw,
364 struct ieee80211_vif *vif); 370 struct ieee80211_vif *vif);
365int iwl_mac_config(struct ieee80211_hw *hw, u32 changed); 371int iwl_mac_config(struct ieee80211_hw *hw, u32 changed);
366void iwl_config_ap(struct iwl_priv *priv); 372void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif);
367void iwl_mac_reset_tsf(struct ieee80211_hw *hw); 373void iwl_mac_reset_tsf(struct ieee80211_hw *hw);
368int iwl_alloc_txq_mem(struct iwl_priv *priv); 374int iwl_alloc_txq_mem(struct iwl_priv *priv);
369void iwl_free_txq_mem(struct iwl_priv *priv); 375void iwl_free_txq_mem(struct iwl_priv *priv);
370void iwlcore_rts_tx_cmd_flag(struct ieee80211_tx_info *info, 376void iwlcore_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
371 __le32 *tx_flags); 377 __le32 *tx_flags);
372int iwl_send_wimax_coex(struct iwl_priv *priv);
373#ifdef CONFIG_IWLWIFI_DEBUGFS 378#ifdef CONFIG_IWLWIFI_DEBUGFS
374int iwl_alloc_traffic_mem(struct iwl_priv *priv); 379int iwl_alloc_traffic_mem(struct iwl_priv *priv);
375void iwl_free_traffic_mem(struct iwl_priv *priv); 380void iwl_free_traffic_mem(struct iwl_priv *priv);
@@ -448,6 +453,8 @@ bool iwl_good_plcp_health(struct iwl_priv *priv,
448 struct iwl_rx_packet *pkt); 453 struct iwl_rx_packet *pkt);
449bool iwl_good_ack_health(struct iwl_priv *priv, 454bool iwl_good_ack_health(struct iwl_priv *priv,
450 struct iwl_rx_packet *pkt); 455 struct iwl_rx_packet *pkt);
456void iwl_recover_from_statistics(struct iwl_priv *priv,
457 struct iwl_rx_packet *pkt);
451void iwl_rx_statistics(struct iwl_priv *priv, 458void iwl_rx_statistics(struct iwl_priv *priv,
452 struct iwl_rx_mem_buffer *rxb); 459 struct iwl_rx_mem_buffer *rxb);
453void iwl_reply_statistics(struct iwl_priv *priv, 460void iwl_reply_statistics(struct iwl_priv *priv,
@@ -515,6 +522,7 @@ int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
515int iwl_mac_hw_scan(struct ieee80211_hw *hw, 522int iwl_mac_hw_scan(struct ieee80211_hw *hw,
516 struct ieee80211_vif *vif, 523 struct ieee80211_vif *vif,
517 struct cfg80211_scan_request *req); 524 struct cfg80211_scan_request *req);
525void iwl_bg_start_internal_scan(struct work_struct *work);
518void iwl_internal_short_hw_scan(struct iwl_priv *priv); 526void iwl_internal_short_hw_scan(struct iwl_priv *priv);
519int iwl_force_reset(struct iwl_priv *priv, int mode); 527int iwl_force_reset(struct iwl_priv *priv, int mode);
520u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, 528u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
@@ -524,7 +532,8 @@ u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
524 enum ieee80211_band band, 532 enum ieee80211_band band,
525 u8 n_probes); 533 u8 n_probes);
526u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, 534u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
527 enum ieee80211_band band); 535 enum ieee80211_band band,
536 struct ieee80211_vif *vif);
528void iwl_bg_scan_check(struct work_struct *data); 537void iwl_bg_scan_check(struct work_struct *data);
529void iwl_bg_abort_scan(struct work_struct *work); 538void iwl_bg_abort_scan(struct work_struct *work);
530void iwl_bg_scan_completed(struct work_struct *work); 539void iwl_bg_scan_completed(struct work_struct *work);
@@ -688,7 +697,7 @@ extern int iwl_send_lq_cmd(struct iwl_priv *priv,
688void iwl_apm_stop(struct iwl_priv *priv); 697void iwl_apm_stop(struct iwl_priv *priv);
689int iwl_apm_init(struct iwl_priv *priv); 698int iwl_apm_init(struct iwl_priv *priv);
690 699
691void iwl_setup_rxon_timing(struct iwl_priv *priv); 700void iwl_setup_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif);
692static inline int iwl_send_rxon_assoc(struct iwl_priv *priv) 701static inline int iwl_send_rxon_assoc(struct iwl_priv *priv)
693{ 702{
694 return priv->cfg->ops->hcmd->rxon_assoc(priv); 703 return priv->cfg->ops->hcmd->rxon_assoc(priv);
@@ -697,9 +706,10 @@ static inline int iwlcore_commit_rxon(struct iwl_priv *priv)
697{ 706{
698 return priv->cfg->ops->hcmd->commit_rxon(priv); 707 return priv->cfg->ops->hcmd->commit_rxon(priv);
699} 708}
700static inline void iwlcore_config_ap(struct iwl_priv *priv) 709static inline void iwlcore_config_ap(struct iwl_priv *priv,
710 struct ieee80211_vif *vif)
701{ 711{
702 priv->cfg->ops->lib->config_ap(priv); 712 priv->cfg->ops->lib->config_ap(priv, vif);
703} 713}
704static inline const struct ieee80211_supported_band *iwl_get_hw_mode( 714static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
705 struct iwl_priv *priv, enum ieee80211_band band) 715 struct iwl_priv *priv, enum ieee80211_band band)
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 4aabb542fcbe..9659c5d01df9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -1220,46 +1220,6 @@ static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1220 return ret; 1220 return ret;
1221} 1221}
1222 1222
1223static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1224 char __user *user_buf,
1225 size_t count, loff_t *ppos) {
1226
1227 struct iwl_priv *priv = file->private_data;
1228 char buf[128];
1229 int pos = 0;
1230 const size_t bufsz = sizeof(buf);
1231 struct statistics_tx *tx;
1232
1233 if (!iwl_is_alive(priv))
1234 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1235 else {
1236 tx = &priv->statistics.tx;
1237 if (tx->tx_power.ant_a ||
1238 tx->tx_power.ant_b ||
1239 tx->tx_power.ant_c) {
1240 pos += scnprintf(buf + pos, bufsz - pos,
1241 "tx power: (1/2 dB step)\n");
1242 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1243 tx->tx_power.ant_a)
1244 pos += scnprintf(buf + pos, bufsz - pos,
1245 "\tantenna A: 0x%X\n",
1246 tx->tx_power.ant_a);
1247 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1248 tx->tx_power.ant_b)
1249 pos += scnprintf(buf + pos, bufsz - pos,
1250 "\tantenna B: 0x%X\n",
1251 tx->tx_power.ant_b);
1252 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1253 tx->tx_power.ant_c)
1254 pos += scnprintf(buf + pos, bufsz - pos,
1255 "\tantenna C: 0x%X\n",
1256 tx->tx_power.ant_c);
1257 } else
1258 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1259 }
1260 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1261}
1262
1263static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, 1223static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1264 char __user *user_buf, 1224 char __user *user_buf,
1265 size_t count, loff_t *ppos) 1225 size_t count, loff_t *ppos)
@@ -1571,7 +1531,6 @@ DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
1571DEBUGFS_READ_FILE_OPS(ucode_general_stats); 1531DEBUGFS_READ_FILE_OPS(ucode_general_stats);
1572DEBUGFS_READ_FILE_OPS(sensitivity); 1532DEBUGFS_READ_FILE_OPS(sensitivity);
1573DEBUGFS_READ_FILE_OPS(chain_noise); 1533DEBUGFS_READ_FILE_OPS(chain_noise);
1574DEBUGFS_READ_FILE_OPS(tx_power);
1575DEBUGFS_READ_FILE_OPS(power_save_status); 1534DEBUGFS_READ_FILE_OPS(power_save_status);
1576DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); 1535DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
1577DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); 1536DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
@@ -1618,8 +1577,11 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1618 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); 1577 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
1619 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); 1578 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
1620 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR); 1579 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
1621 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR); 1580 if (!priv->cfg->broken_powersave) {
1622 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); 1581 DEBUGFS_ADD_FILE(sleep_level_override, dir_data,
1582 S_IWUSR | S_IRUSR);
1583 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
1584 }
1623 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); 1585 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
1624 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); 1586 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
1625 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); 1587 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
@@ -1627,7 +1589,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1627 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); 1589 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
1628 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); 1590 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
1629 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); 1591 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
1630 DEBUGFS_ADD_FILE(tx_power, dir_debug, S_IRUSR);
1631 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); 1592 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
1632 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); 1593 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
1633 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); 1594 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
@@ -1640,18 +1601,21 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1640 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); 1601 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
1641 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); 1602 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1642 1603
1643 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 1604 if (priv->cfg->sensitivity_calib_by_driver)
1644 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); 1605 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
1606 if (priv->cfg->chain_noise_calib_by_driver)
1645 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 1607 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
1608 if (priv->cfg->ucode_tracing)
1646 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); 1609 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1647 }
1648 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 1610 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1649 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); 1611 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
1650 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal); 1612 if (priv->cfg->sensitivity_calib_by_driver)
1651 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, 1613 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
1652 &priv->disable_chain_noise_cal); 1614 &priv->disable_sens_cal);
1653 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || 1615 if (priv->cfg->chain_noise_calib_by_driver)
1654 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) 1616 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
1617 &priv->disable_chain_noise_cal);
1618 if (priv->cfg->tx_power_by_driver)
1655 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, 1619 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf,
1656 &priv->disable_tx_power_cal); 1620 &priv->disable_tx_power_cal);
1657 return 0; 1621 return 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 58c69a5798d4..f3f3473c5c7e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -57,8 +57,8 @@ extern struct iwl_cfg iwl5100_bgn_cfg;
57extern struct iwl_cfg iwl5100_abg_cfg; 57extern struct iwl_cfg iwl5100_abg_cfg;
58extern struct iwl_cfg iwl5150_agn_cfg; 58extern struct iwl_cfg iwl5150_agn_cfg;
59extern struct iwl_cfg iwl5150_abg_cfg; 59extern struct iwl_cfg iwl5150_abg_cfg;
60extern struct iwl_cfg iwl6000g2a_2agn_cfg;
60extern struct iwl_cfg iwl6000i_2agn_cfg; 61extern struct iwl_cfg iwl6000i_2agn_cfg;
61extern struct iwl_cfg iwl6000g2_2agn_cfg;
62extern struct iwl_cfg iwl6000i_2abg_cfg; 62extern struct iwl_cfg iwl6000i_2abg_cfg;
63extern struct iwl_cfg iwl6000i_2bg_cfg; 63extern struct iwl_cfg iwl6000i_2bg_cfg;
64extern struct iwl_cfg iwl6000_3agn_cfg; 64extern struct iwl_cfg iwl6000_3agn_cfg;
@@ -497,20 +497,38 @@ struct iwl_station_entry {
497 struct iwl_link_quality_cmd *lq; 497 struct iwl_link_quality_cmd *lq;
498}; 498};
499 499
500struct iwl_station_priv_common {
501 u8 sta_id;
502};
503
500/* 504/*
501 * iwl_station_priv: Driver's private station information 505 * iwl_station_priv: Driver's private station information
502 * 506 *
503 * When mac80211 creates a station it reserves some space (hw->sta_data_size) 507 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
504 * in the structure for use by driver. This structure is places in that 508 * in the structure for use by driver. This structure is places in that
505 * space. 509 * space.
510 *
511 * The common struct MUST be first because it is shared between
512 * 3945 and agn!
506 */ 513 */
507struct iwl_station_priv { 514struct iwl_station_priv {
515 struct iwl_station_priv_common common;
508 struct iwl_lq_sta lq_sta; 516 struct iwl_lq_sta lq_sta;
509 atomic_t pending_frames; 517 atomic_t pending_frames;
510 bool client; 518 bool client;
511 bool asleep; 519 bool asleep;
512}; 520};
513 521
522/**
523 * struct iwl_vif_priv - driver's private per-interface information
524 *
525 * When mac80211 allocates a virtual interface, it can allocate
526 * space for us to put data into.
527 */
528struct iwl_vif_priv {
529 u8 ibss_bssid_sta_id;
530};
531
514/* one for each uCode image (inst/data, boot/init/runtime) */ 532/* one for each uCode image (inst/data, boot/init/runtime) */
515struct fw_desc { 533struct fw_desc {
516 void *v_addr; /* access by driver */ 534 void *v_addr; /* access by driver */
@@ -518,7 +536,7 @@ struct fw_desc {
518 u32 len; /* bytes */ 536 u32 len; /* bytes */
519}; 537};
520 538
521/* uCode file layout */ 539/* v1/v2 uCode file layout */
522struct iwl_ucode_header { 540struct iwl_ucode_header {
523 __le32 ver; /* major/minor/API/serial */ 541 __le32 ver; /* major/minor/API/serial */
524 union { 542 union {
@@ -541,7 +559,62 @@ struct iwl_ucode_header {
541 } v2; 559 } v2;
542 } u; 560 } u;
543}; 561};
544#define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28) 562
563/*
564 * new TLV uCode file layout
565 *
566 * The new TLV file format contains TLVs, that each specify
567 * some piece of data. To facilitate "groups", for example
568 * different instruction image with different capabilities,
569 * bundled with the same init image, an alternative mechanism
570 * is provided:
571 * When the alternative field is 0, that means that the item
572 * is always valid. When it is non-zero, then it is only
573 * valid in conjunction with items of the same alternative,
574 * in which case the driver (user) selects one alternative
575 * to use.
576 */
577
578enum iwl_ucode_tlv_type {
579 IWL_UCODE_TLV_INVALID = 0, /* unused */
580 IWL_UCODE_TLV_INST = 1,
581 IWL_UCODE_TLV_DATA = 2,
582 IWL_UCODE_TLV_INIT = 3,
583 IWL_UCODE_TLV_INIT_DATA = 4,
584 IWL_UCODE_TLV_BOOT = 5,
585 IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
586};
587
588struct iwl_ucode_tlv {
589 __le16 type; /* see above */
590 __le16 alternative; /* see comment */
591 __le32 length; /* not including type/length fields */
592 u8 data[0];
593} __attribute__ ((packed));
594
595#define IWL_TLV_UCODE_MAGIC 0x0a4c5749
596
597struct iwl_tlv_ucode_header {
598 /*
599 * The TLV style ucode header is distinguished from
600 * the v1/v2 style header by first four bytes being
601 * zero, as such is an invalid combination of
602 * major/minor/API/serial versions.
603 */
604 __le32 zero;
605 __le32 magic;
606 u8 human_readable[64];
607 __le32 ver; /* major/minor/API/serial */
608 __le32 build;
609 __le64 alternatives; /* bitmask of valid alternatives */
610 /*
611 * The data contained herein has a TLV layout,
612 * see above for the TLV header and types.
613 * Note that each TLV is padded to a length
614 * that is a multiple of 4 for alignment.
615 */
616 u8 data[0];
617};
545 618
546struct iwl4965_ibss_seq { 619struct iwl4965_ibss_seq {
547 u8 mac[ETH_ALEN]; 620 u8 mac[ETH_ALEN];
@@ -1155,8 +1228,7 @@ struct iwl_priv {
1155#endif 1228#endif
1156 1229
1157 /* context information */ 1230 /* context information */
1158 u8 bssid[ETH_ALEN]; 1231 u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */
1159 u16 rts_threshold;
1160 u8 mac_addr[ETH_ALEN]; 1232 u8 mac_addr[ETH_ALEN];
1161 1233
1162 /*station table variables */ 1234 /*station table variables */
@@ -1189,7 +1261,6 @@ struct iwl_priv {
1189 1261
1190 /* Last Rx'd beacon timestamp */ 1262 /* Last Rx'd beacon timestamp */
1191 u64 timestamp; 1263 u64 timestamp;
1192 u16 beacon_int;
1193 struct ieee80211_vif *vif; 1264 struct ieee80211_vif *vif;
1194 1265
1195 union { 1266 union {
@@ -1242,6 +1313,8 @@ struct iwl_priv {
1242 1313
1243 struct iwl_rx_phy_res last_phy_res; 1314 struct iwl_rx_phy_res last_phy_res;
1244 bool last_phy_res_valid; 1315 bool last_phy_res_valid;
1316
1317 struct completion firmware_loading_complete;
1245 } _agn; 1318 } _agn;
1246#endif 1319#endif
1247 }; 1320 };
@@ -1249,10 +1322,6 @@ struct iwl_priv {
1249 struct iwl_hw_params hw_params; 1322 struct iwl_hw_params hw_params;
1250 1323
1251 u32 inta_mask; 1324 u32 inta_mask;
1252 /* Current association information needed to configure the
1253 * hardware */
1254 u16 assoc_id;
1255 u16 assoc_capability;
1256 1325
1257 struct iwl_qos_info qos_data; 1326 struct iwl_qos_info qos_data;
1258 1327
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index fb5bb487f3bc..ee11452519e6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -590,9 +590,16 @@ int iwl_eeprom_init(struct iwl_priv *priv)
590 e[addr / 2] = cpu_to_le16(r >> 16); 590 e[addr / 2] = cpu_to_le16(r >> 16);
591 } 591 }
592 } 592 }
593
594 IWL_DEBUG_INFO(priv, "NVM Type: %s, version: 0x%x\n",
595 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
596 ? "OTP" : "EEPROM",
597 iwl_eeprom_query16(priv, EEPROM_VERSION));
598
593 ret = 0; 599 ret = 0;
594done: 600done:
595 priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv); 601 priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv);
602
596err: 603err:
597 if (ret) 604 if (ret)
598 iwl_eeprom_free(priv); 605 iwl_eeprom_free(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 581c683a8507..cda6a94d6cc9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -318,10 +318,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
318 update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE || 318 update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
319 priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE; 319 priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
320 320
321 if (priv->vif) 321 dtimper = priv->hw->conf.ps_dtim_period ?: 1;
322 dtimper = priv->hw->conf.ps_dtim_period;
323 else
324 dtimper = 1;
325 322
326 if (priv->cfg->broken_powersave) 323 if (priv->cfg->broken_powersave)
327 iwl_power_sleep_cam_cmd(priv, &cmd); 324 iwl_power_sleep_cam_cmd(priv, &cmd);
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 267eb8935902..0a5d7cf25196 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -398,7 +398,7 @@ bool iwl_good_plcp_health(struct iwl_priv *priv,
398} 398}
399EXPORT_SYMBOL(iwl_good_plcp_health); 399EXPORT_SYMBOL(iwl_good_plcp_health);
400 400
401static void iwl_recover_from_statistics(struct iwl_priv *priv, 401void iwl_recover_from_statistics(struct iwl_priv *priv,
402 struct iwl_rx_packet *pkt) 402 struct iwl_rx_packet *pkt)
403{ 403{
404 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 404 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
@@ -413,9 +413,11 @@ static void iwl_recover_from_statistics(struct iwl_priv *priv,
413 */ 413 */
414 IWL_ERR(priv, "low ack count detected, " 414 IWL_ERR(priv, "low ack count detected, "
415 "restart firmware\n"); 415 "restart firmware\n");
416 iwl_force_reset(priv, IWL_FW_RESET); 416 if (!iwl_force_reset(priv, IWL_FW_RESET))
417 return;
417 } 418 }
418 } else if (priv->cfg->ops->lib->check_plcp_health) { 419 }
420 if (priv->cfg->ops->lib->check_plcp_health) {
419 if (!priv->cfg->ops->lib->check_plcp_health( 421 if (!priv->cfg->ops->lib->check_plcp_health(
420 priv, pkt)) { 422 priv, pkt)) {
421 /* 423 /*
@@ -427,6 +429,7 @@ static void iwl_recover_from_statistics(struct iwl_priv *priv,
427 } 429 }
428 } 430 }
429} 431}
432EXPORT_SYMBOL(iwl_recover_from_statistics);
430 433
431void iwl_rx_statistics(struct iwl_priv *priv, 434void iwl_rx_statistics(struct iwl_priv *priv,
432 struct iwl_rx_mem_buffer *rxb) 435 struct iwl_rx_mem_buffer *rxb)
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index d12fd5553846..107e173112f6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -265,7 +265,8 @@ inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
265EXPORT_SYMBOL(iwl_get_active_dwell_time); 265EXPORT_SYMBOL(iwl_get_active_dwell_time);
266 266
267u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, 267u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
268 enum ieee80211_band band) 268 enum ieee80211_band band,
269 struct ieee80211_vif *vif)
269{ 270{
270 u16 passive = (band == IEEE80211_BAND_2GHZ) ? 271 u16 passive = (band == IEEE80211_BAND_2GHZ) ?
271 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 272 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
@@ -275,7 +276,7 @@ u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
275 /* If we're associated, we clamp the maximum passive 276 /* If we're associated, we clamp the maximum passive
276 * dwell time to be 98% of the beacon interval (minus 277 * dwell time to be 98% of the beacon interval (minus
277 * 2 * channel tune time) */ 278 * 2 * channel tune time) */
278 passive = priv->beacon_int; 279 passive = vif ? vif->bss_conf.beacon_int : 0;
279 if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive) 280 if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive)
280 passive = IWL_PASSIVE_DWELL_BASE; 281 passive = IWL_PASSIVE_DWELL_BASE;
281 passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; 282 passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2;
@@ -295,7 +296,7 @@ void iwl_init_scan_params(struct iwl_priv *priv)
295} 296}
296EXPORT_SYMBOL(iwl_init_scan_params); 297EXPORT_SYMBOL(iwl_init_scan_params);
297 298
298static int iwl_scan_initiate(struct iwl_priv *priv) 299static int iwl_scan_initiate(struct iwl_priv *priv, struct ieee80211_vif *vif)
299{ 300{
300 WARN_ON(!mutex_is_locked(&priv->mutex)); 301 WARN_ON(!mutex_is_locked(&priv->mutex));
301 302
@@ -307,7 +308,7 @@ static int iwl_scan_initiate(struct iwl_priv *priv)
307 if (WARN_ON(!priv->cfg->ops->utils->request_scan)) 308 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
308 return -EOPNOTSUPP; 309 return -EOPNOTSUPP;
309 310
310 priv->cfg->ops->utils->request_scan(priv); 311 priv->cfg->ops->utils->request_scan(priv, vif);
311 312
312 return 0; 313 return 0;
313} 314}
@@ -348,7 +349,7 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
348 priv->scan_band = req->channels[0]->band; 349 priv->scan_band = req->channels[0]->band;
349 priv->scan_request = req; 350 priv->scan_request = req;
350 351
351 ret = iwl_scan_initiate(priv); 352 ret = iwl_scan_initiate(priv, vif);
352 353
353 IWL_DEBUG_MAC80211(priv, "leave\n"); 354 IWL_DEBUG_MAC80211(priv, "leave\n");
354 355
@@ -368,7 +369,7 @@ void iwl_internal_short_hw_scan(struct iwl_priv *priv)
368 queue_work(priv->workqueue, &priv->start_internal_scan); 369 queue_work(priv->workqueue, &priv->start_internal_scan);
369} 370}
370 371
371static void iwl_bg_start_internal_scan(struct work_struct *work) 372void iwl_bg_start_internal_scan(struct work_struct *work)
372{ 373{
373 struct iwl_priv *priv = 374 struct iwl_priv *priv =
374 container_of(work, struct iwl_priv, start_internal_scan); 375 container_of(work, struct iwl_priv, start_internal_scan);
@@ -399,10 +400,11 @@ static void iwl_bg_start_internal_scan(struct work_struct *work)
399 if (WARN_ON(!priv->cfg->ops->utils->request_scan)) 400 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
400 goto unlock; 401 goto unlock;
401 402
402 priv->cfg->ops->utils->request_scan(priv); 403 priv->cfg->ops->utils->request_scan(priv, NULL);
403 unlock: 404 unlock:
404 mutex_unlock(&priv->mutex); 405 mutex_unlock(&priv->mutex);
405} 406}
407EXPORT_SYMBOL(iwl_bg_start_internal_scan);
406 408
407void iwl_bg_scan_check(struct work_struct *data) 409void iwl_bg_scan_check(struct work_struct *data)
408{ 410{
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index db934476b5e9..85ed235ac901 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -35,62 +35,6 @@
35#include "iwl-core.h" 35#include "iwl-core.h"
36#include "iwl-sta.h" 36#include "iwl-sta.h"
37 37
38u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
39{
40 int i;
41 int start = 0;
42 int ret = IWL_INVALID_STATION;
43 unsigned long flags;
44
45 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
46 (priv->iw_mode == NL80211_IFTYPE_AP))
47 start = IWL_STA_ID;
48
49 if (is_broadcast_ether_addr(addr))
50 return priv->hw_params.bcast_sta_id;
51
52 spin_lock_irqsave(&priv->sta_lock, flags);
53 for (i = start; i < priv->hw_params.max_stations; i++)
54 if (priv->stations[i].used &&
55 (!compare_ether_addr(priv->stations[i].sta.sta.addr,
56 addr))) {
57 ret = i;
58 goto out;
59 }
60
61 IWL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n",
62 addr, priv->num_stations);
63
64 out:
65 /*
66 * It may be possible that more commands interacting with stations
67 * arrive before we completed processing the adding of
68 * station
69 */
70 if (ret != IWL_INVALID_STATION &&
71 (!(priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) ||
72 ((priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) &&
73 (priv->stations[ret].used & IWL_STA_UCODE_INPROGRESS)))) {
74 IWL_ERR(priv, "Requested station info for sta %d before ready.\n",
75 ret);
76 ret = IWL_INVALID_STATION;
77 }
78 spin_unlock_irqrestore(&priv->sta_lock, flags);
79 return ret;
80}
81EXPORT_SYMBOL(iwl_find_station);
82
83int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
84{
85 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
86 return IWL_AP_ID;
87 } else {
88 u8 *da = ieee80211_get_DA(hdr);
89 return iwl_find_station(priv, da);
90 }
91}
92EXPORT_SYMBOL(iwl_get_ra_sta_id);
93
94/* priv->sta_lock must be held */ 38/* priv->sta_lock must be held */
95static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) 39static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
96{ 40{
@@ -340,10 +284,12 @@ static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr,
340 station->sta.sta.sta_id = sta_id; 284 station->sta.sta.sta_id = sta_id;
341 station->sta.station_flags = 0; 285 station->sta.station_flags = 0;
342 286
343 /* BCAST station and IBSS stations do not work in HT mode */ 287 /*
344 if (sta_id != priv->hw_params.bcast_sta_id && 288 * OK to call unconditionally, since local stations (IBSS BSSID
345 priv->iw_mode != NL80211_IFTYPE_ADHOC) 289 * STA and broadcast STA) pass in a NULL ht_info, and mac80211
346 iwl_set_ht_add_station(priv, sta_id, ht_info); 290 * doesn't allow HT IBSS.
291 */
292 iwl_set_ht_add_station(priv, sta_id, ht_info);
347 293
348 /* 3945 only */ 294 /* 3945 only */
349 rate = (priv->band == IEEE80211_BAND_5GHZ) ? 295 rate = (priv->band == IEEE80211_BAND_5GHZ) ?
@@ -418,20 +364,21 @@ int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr,
418} 364}
419EXPORT_SYMBOL(iwl_add_station_common); 365EXPORT_SYMBOL(iwl_add_station_common);
420 366
421static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap) 367static struct iwl_link_quality_cmd *iwl_sta_alloc_lq(struct iwl_priv *priv,
368 u8 sta_id)
422{ 369{
423 int i, r; 370 int i, r;
424 struct iwl_link_quality_cmd link_cmd = { 371 struct iwl_link_quality_cmd *link_cmd;
425 .reserved1 = 0,
426 };
427 u32 rate_flags; 372 u32 rate_flags;
428 int ret = 0;
429 373
374 link_cmd = kzalloc(sizeof(struct iwl_link_quality_cmd), GFP_KERNEL);
375 if (!link_cmd) {
376 IWL_ERR(priv, "Unable to allocate memory for LQ cmd.\n");
377 return NULL;
378 }
430 /* Set up the rate scaling to start at selected rate, fall back 379 /* Set up the rate scaling to start at selected rate, fall back
431 * all the way down to 1M in IEEE order, and then spin on 1M */ 380 * all the way down to 1M in IEEE order, and then spin on 1M */
432 if (is_ap) 381 if (priv->band == IEEE80211_BAND_5GHZ)
433 r = IWL_RATE_54M_INDEX;
434 else if (priv->band == IEEE80211_BAND_5GHZ)
435 r = IWL_RATE_6M_INDEX; 382 r = IWL_RATE_6M_INDEX;
436 else 383 else
437 r = IWL_RATE_1M_INDEX; 384 r = IWL_RATE_1M_INDEX;
@@ -444,49 +391,48 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap)
444 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) << 391 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
445 RATE_MCS_ANT_POS; 392 RATE_MCS_ANT_POS;
446 393
447 link_cmd.rs_table[i].rate_n_flags = 394 link_cmd->rs_table[i].rate_n_flags =
448 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); 395 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
449 r = iwl_get_prev_ieee_rate(r); 396 r = iwl_get_prev_ieee_rate(r);
450 } 397 }
451 398
452 link_cmd.general_params.single_stream_ant_msk = 399 link_cmd->general_params.single_stream_ant_msk =
453 first_antenna(priv->hw_params.valid_tx_ant); 400 first_antenna(priv->hw_params.valid_tx_ant);
454 401
455 link_cmd.general_params.dual_stream_ant_msk = 402 link_cmd->general_params.dual_stream_ant_msk =
456 priv->hw_params.valid_tx_ant & 403 priv->hw_params.valid_tx_ant &
457 ~first_antenna(priv->hw_params.valid_tx_ant); 404 ~first_antenna(priv->hw_params.valid_tx_ant);
458 if (!link_cmd.general_params.dual_stream_ant_msk) { 405 if (!link_cmd->general_params.dual_stream_ant_msk) {
459 link_cmd.general_params.dual_stream_ant_msk = ANT_AB; 406 link_cmd->general_params.dual_stream_ant_msk = ANT_AB;
460 } else if (num_of_ant(priv->hw_params.valid_tx_ant) == 2) { 407 } else if (num_of_ant(priv->hw_params.valid_tx_ant) == 2) {
461 link_cmd.general_params.dual_stream_ant_msk = 408 link_cmd->general_params.dual_stream_ant_msk =
462 priv->hw_params.valid_tx_ant; 409 priv->hw_params.valid_tx_ant;
463 } 410 }
464 411
465 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; 412 link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
466 link_cmd.agg_params.agg_time_limit = 413 link_cmd->agg_params.agg_time_limit =
467 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); 414 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
468 415
469 /* Update the rate scaling for control frame Tx to AP */ 416 link_cmd->sta_id = sta_id;
470 link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id;
471 417
472 ret = iwl_send_cmd_pdu(priv, REPLY_TX_LINK_QUALITY_CMD, 418 return link_cmd;
473 sizeof(link_cmd), &link_cmd);
474 if (ret)
475 IWL_ERR(priv, "REPLY_TX_LINK_QUALITY_CMD failed (%d)\n", ret);
476} 419}
477 420
478/* 421/*
479 * iwl_add_local_stations - Add stations not requested by mac80211 422 * iwl_add_bssid_station - Add the special IBSS BSSID station
480 *
481 * This will be either the broadcast station or the bssid station needed by
482 * ad-hoc.
483 * 423 *
484 * Function sleeps. 424 * Function sleeps.
485 */ 425 */
486int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs) 426int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
427 u8 *sta_id_r)
487{ 428{
488 int ret; 429 int ret;
489 u8 sta_id; 430 u8 sta_id;
431 struct iwl_link_quality_cmd *link_cmd;
432 unsigned long flags;
433
434 if (*sta_id_r)
435 *sta_id_r = IWL_INVALID_STATION;
490 436
491 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id); 437 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id);
492 if (ret) { 438 if (ret) {
@@ -494,12 +440,34 @@ int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs)
494 return ret; 440 return ret;
495 } 441 }
496 442
497 if (init_rs) 443 if (sta_id_r)
444 *sta_id_r = sta_id;
445
446 spin_lock_irqsave(&priv->sta_lock, flags);
447 priv->stations[sta_id].used |= IWL_STA_LOCAL;
448 spin_unlock_irqrestore(&priv->sta_lock, flags);
449
450 if (init_rs) {
498 /* Set up default rate scaling table in device's station table */ 451 /* Set up default rate scaling table in device's station table */
499 iwl_sta_init_lq(priv, addr, false); 452 link_cmd = iwl_sta_alloc_lq(priv, sta_id);
453 if (!link_cmd) {
454 IWL_ERR(priv, "Unable to initialize rate scaling for station %pM.\n",
455 addr);
456 return -ENOMEM;
457 }
458
459 ret = iwl_send_lq_cmd(priv, link_cmd, CMD_SYNC, true);
460 if (ret)
461 IWL_ERR(priv, "Link quality command failed (%d)\n", ret);
462
463 spin_lock_irqsave(&priv->sta_lock, flags);
464 priv->stations[sta_id].lq = link_cmd;
465 spin_unlock_irqrestore(&priv->sta_lock, flags);
466 }
467
500 return 0; 468 return 0;
501} 469}
502EXPORT_SYMBOL(iwl_add_local_station); 470EXPORT_SYMBOL(iwl_add_bssid_station);
503 471
504/** 472/**
505 * iwl_sta_ucode_deactivate - deactivate ucode status for a station 473 * iwl_sta_ucode_deactivate - deactivate ucode status for a station
@@ -509,7 +477,8 @@ EXPORT_SYMBOL(iwl_add_local_station);
509static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id) 477static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id)
510{ 478{
511 /* Ucode must be active and driver must be non active */ 479 /* Ucode must be active and driver must be non active */
512 if (priv->stations[sta_id].used != IWL_STA_UCODE_ACTIVE) 480 if ((priv->stations[sta_id].used &
481 (IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) != IWL_STA_UCODE_ACTIVE)
513 IWL_ERR(priv, "removed non active STA %u\n", sta_id); 482 IWL_ERR(priv, "removed non active STA %u\n", sta_id);
514 483
515 priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; 484 priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE;
@@ -574,18 +543,16 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
574/** 543/**
575 * iwl_remove_station - Remove driver's knowledge of station. 544 * iwl_remove_station - Remove driver's knowledge of station.
576 */ 545 */
577static int iwl_remove_station(struct iwl_priv *priv, struct ieee80211_sta *sta) 546int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
547 const u8 *addr)
578{ 548{
579 int sta_id = IWL_INVALID_STATION;
580 int i, ret = -EINVAL;
581 unsigned long flags;
582 bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION;
583 struct iwl_station_entry *station; 549 struct iwl_station_entry *station;
550 unsigned long flags;
584 551
585 if (!iwl_is_ready(priv)) { 552 if (!iwl_is_ready(priv)) {
586 IWL_DEBUG_INFO(priv, 553 IWL_DEBUG_INFO(priv,
587 "Unable to remove station %pM, device not ready.\n", 554 "Unable to remove station %pM, device not ready.\n",
588 sta->addr); 555 addr);
589 /* 556 /*
590 * It is typical for stations to be removed when we are 557 * It is typical for stations to be removed when we are
591 * going down. Return success since device will be down 558 * going down. Return success since device will be down
@@ -594,37 +561,30 @@ static int iwl_remove_station(struct iwl_priv *priv, struct ieee80211_sta *sta)
594 return 0; 561 return 0;
595 } 562 }
596 563
597 spin_lock_irqsave(&priv->sta_lock, flags); 564 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n",
598 565 sta_id, addr);
599 if (is_ap)
600 sta_id = IWL_AP_ID;
601 else
602 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++)
603 if (priv->stations[i].used &&
604 !compare_ether_addr(priv->stations[i].sta.sta.addr,
605 sta->addr)) {
606 sta_id = i;
607 break;
608 }
609 566
610 if (unlikely(sta_id == IWL_INVALID_STATION)) 567 if (WARN_ON(sta_id == IWL_INVALID_STATION))
611 goto out; 568 return -EINVAL;
612 569
613 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", 570 spin_lock_irqsave(&priv->sta_lock, flags);
614 sta_id, sta->addr);
615 571
616 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { 572 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
617 IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", 573 IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n",
618 sta->addr); 574 addr);
619 goto out; 575 goto out_err;
620 } 576 }
621 577
622 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { 578 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
623 IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", 579 IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n",
624 sta->addr); 580 addr);
625 goto out; 581 goto out_err;
626 } 582 }
627 583
584 if (priv->stations[sta_id].used & IWL_STA_LOCAL) {
585 kfree(priv->stations[sta_id].lq);
586 priv->stations[sta_id].lq = NULL;
587 }
628 588
629 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; 589 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
630 590
@@ -635,56 +595,35 @@ static int iwl_remove_station(struct iwl_priv *priv, struct ieee80211_sta *sta)
635 station = &priv->stations[sta_id]; 595 station = &priv->stations[sta_id];
636 spin_unlock_irqrestore(&priv->sta_lock, flags); 596 spin_unlock_irqrestore(&priv->sta_lock, flags);
637 597
638 ret = iwl_send_remove_station(priv, station); 598 return iwl_send_remove_station(priv, station);
639 return ret; 599out_err:
640out:
641 spin_unlock_irqrestore(&priv->sta_lock, flags); 600 spin_unlock_irqrestore(&priv->sta_lock, flags);
642 return ret; 601 return -EINVAL;
643} 602}
603EXPORT_SYMBOL_GPL(iwl_remove_station);
644 604
645/** 605/**
646 * iwl_clear_ucode_stations() - clear entire station table driver and/or ucode 606 * iwl_clear_ucode_stations - clear ucode station table bits
647 * @priv: 607 *
648 * @force: If set then the uCode station table needs to be cleared here. If 608 * This function clears all the bits in the driver indicating
649 * not set then the uCode station table has already been cleared, 609 * which stations are active in the ucode. Call when something
650 * for example after sending it a RXON command without ASSOC bit 610 * other than explicit station management would cause this in
651 * set, and we just need to change driver state here. 611 * the ucode, e.g. unassociated RXON.
652 */ 612 */
653void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force) 613void iwl_clear_ucode_stations(struct iwl_priv *priv)
654{ 614{
655 int i; 615 int i;
656 unsigned long flags_spin; 616 unsigned long flags_spin;
657 bool cleared = false; 617 bool cleared = false;
658 618
659 IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver%s\n", 619 IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n");
660 force ? " and ucode" : "");
661
662 if (force) {
663 if (!iwl_is_ready(priv)) {
664 /*
665 * If device is not ready at this point the station
666 * table is likely already empty (uCode not ready
667 * to receive station requests) or will soon be
668 * due to interface going down.
669 */
670 IWL_DEBUG_INFO(priv, "Unable to remove stations from device - device not ready\n");
671 } else {
672 iwl_send_cmd_pdu_async(priv, REPLY_REMOVE_ALL_STA, 0, NULL, NULL);
673 }
674 }
675 620
676 spin_lock_irqsave(&priv->sta_lock, flags_spin); 621 spin_lock_irqsave(&priv->sta_lock, flags_spin);
677 if (force) { 622 for (i = 0; i < priv->hw_params.max_stations; i++) {
678 IWL_DEBUG_INFO(priv, "Clearing all station information in driver\n"); 623 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
679 priv->num_stations = 0; 624 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i);
680 memset(priv->stations, 0, sizeof(priv->stations)); 625 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
681 } else { 626 cleared = true;
682 for (i = 0; i < priv->hw_params.max_stations; i++) {
683 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
684 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i);
685 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
686 cleared = true;
687 }
688 } 627 }
689 } 628 }
690 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 629 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
@@ -1027,18 +966,23 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
1027 966
1028void iwl_update_tkip_key(struct iwl_priv *priv, 967void iwl_update_tkip_key(struct iwl_priv *priv,
1029 struct ieee80211_key_conf *keyconf, 968 struct ieee80211_key_conf *keyconf,
1030 const u8 *addr, u32 iv32, u16 *phase1key) 969 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key)
1031{ 970{
1032 u8 sta_id = IWL_INVALID_STATION; 971 u8 sta_id;
1033 unsigned long flags; 972 unsigned long flags;
1034 int i; 973 int i;
1035 974
1036 sta_id = iwl_find_station(priv, addr); 975 if (sta) {
1037 if (sta_id == IWL_INVALID_STATION) { 976 sta_id = iwl_sta_id(sta);
1038 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n", 977
1039 addr); 978 if (sta_id == IWL_INVALID_STATION) {
1040 return; 979 IWL_DEBUG_MAC80211(priv, "leave - %pM not initialised.\n",
1041 } 980 sta->addr);
981 return;
982 }
983 } else
984 sta_id = priv->hw_params.bcast_sta_id;
985
1042 986
1043 if (iwl_scan_cancel(priv)) { 987 if (iwl_scan_cancel(priv)) {
1044 /* cancel scan failed, just live w/ bad key and rely 988 /* cancel scan failed, just live w/ bad key and rely
@@ -1178,6 +1122,39 @@ static inline void iwl_dump_lq_cmd(struct iwl_priv *priv,
1178#endif 1122#endif
1179 1123
1180/** 1124/**
1125 * is_lq_table_valid() - Test one aspect of LQ cmd for validity
1126 *
1127 * It sometimes happens when a HT rate has been in use and we
1128 * loose connectivity with AP then mac80211 will first tell us that the
1129 * current channel is not HT anymore before removing the station. In such a
1130 * scenario the RXON flags will be updated to indicate we are not
1131 * communicating HT anymore, but the LQ command may still contain HT rates.
1132 * Test for this to prevent driver from sending LQ command between the time
1133 * RXON flags are updated and when LQ command is updated.
1134 */
1135static bool is_lq_table_valid(struct iwl_priv *priv,
1136 struct iwl_link_quality_cmd *lq)
1137{
1138 int i;
1139 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
1140
1141 if (ht_conf->is_ht)
1142 return true;
1143
1144 IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n",
1145 priv->active_rxon.channel);
1146 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1147 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) {
1148 IWL_DEBUG_INFO(priv,
1149 "index %d of LQ expects HT channel\n",
1150 i);
1151 return false;
1152 }
1153 }
1154 return true;
1155}
1156
1157/**
1181 * iwl_send_lq_cmd() - Send link quality command 1158 * iwl_send_lq_cmd() - Send link quality command
1182 * @init: This command is sent as part of station initialization right 1159 * @init: This command is sent as part of station initialization right
1183 * after station has been added. 1160 * after station has been added.
@@ -1206,8 +1183,12 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
1206 iwl_dump_lq_cmd(priv, lq); 1183 iwl_dump_lq_cmd(priv, lq);
1207 BUG_ON(init && (cmd.flags & CMD_ASYNC)); 1184 BUG_ON(init && (cmd.flags & CMD_ASYNC));
1208 1185
1209 ret = iwl_send_cmd(priv, &cmd); 1186 if (is_lq_table_valid(priv, lq))
1210 if (ret || (cmd.flags & CMD_ASYNC)) 1187 ret = iwl_send_cmd(priv, &cmd);
1188 else
1189 ret = -EINVAL;
1190
1191 if (cmd.flags & CMD_ASYNC)
1211 return ret; 1192 return ret;
1212 1193
1213 if (init) { 1194 if (init) {
@@ -1217,92 +1198,72 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
1217 priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; 1198 priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
1218 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 1199 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
1219 } 1200 }
1220 return 0; 1201 return ret;
1221} 1202}
1222EXPORT_SYMBOL(iwl_send_lq_cmd); 1203EXPORT_SYMBOL(iwl_send_lq_cmd);
1223 1204
1224/** 1205/**
1225 * iwl_add_bcast_station - add broadcast station into station table. 1206 * iwl_alloc_bcast_station - add broadcast station into driver's station table.
1207 *
1208 * This adds the broadcast station into the driver's station table
1209 * and marks it driver active, so that it will be restored to the
1210 * device at the next best time.
1226 */ 1211 */
1227void iwl_add_bcast_station(struct iwl_priv *priv) 1212int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq)
1228{ 1213{
1229 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); 1214 struct iwl_link_quality_cmd *link_cmd;
1230 iwl_add_local_station(priv, iwl_bcast_addr, true); 1215 unsigned long flags;
1231} 1216 u8 sta_id;
1232EXPORT_SYMBOL(iwl_add_bcast_station);
1233 1217
1234/** 1218 spin_lock_irqsave(&priv->sta_lock, flags);
1235 * iwl3945_add_bcast_station - add broadcast station into station table. 1219 sta_id = iwl_prep_station(priv, iwl_bcast_addr, false, NULL);
1236 */ 1220 if (sta_id == IWL_INVALID_STATION) {
1237void iwl3945_add_bcast_station(struct iwl_priv *priv) 1221 IWL_ERR(priv, "Unable to prepare broadcast station\n");
1238{ 1222 spin_unlock_irqrestore(&priv->sta_lock, flags);
1239 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n");
1240 iwl_add_local_station(priv, iwl_bcast_addr, false);
1241 /*
1242 * It is assumed that when station is added more initialization
1243 * needs to be done, but for 3945 it is not the case and we can
1244 * just release station table access right here.
1245 */
1246 priv->stations[priv->hw_params.bcast_sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
1247 1223
1248} 1224 return -EINVAL;
1249EXPORT_SYMBOL(iwl3945_add_bcast_station); 1225 }
1250 1226
1251/** 1227 priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE;
1252 * iwl_get_sta_id - Find station's index within station table 1228 priv->stations[sta_id].used |= IWL_STA_BCAST;
1253 * 1229 spin_unlock_irqrestore(&priv->sta_lock, flags);
1254 * If new IBSS station, create new entry in station table
1255 */
1256int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1257{
1258 int sta_id;
1259 __le16 fc = hdr->frame_control;
1260 1230
1261 /* If this frame is broadcast or management, use broadcast station id */ 1231 if (init_lq) {
1262 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) 1232 link_cmd = iwl_sta_alloc_lq(priv, sta_id);
1263 return priv->hw_params.bcast_sta_id; 1233 if (!link_cmd) {
1234 IWL_ERR(priv,
1235 "Unable to initialize rate scaling for bcast station.\n");
1236 return -ENOMEM;
1237 }
1264 1238
1265 switch (priv->iw_mode) { 1239 spin_lock_irqsave(&priv->sta_lock, flags);
1240 priv->stations[sta_id].lq = link_cmd;
1241 spin_unlock_irqrestore(&priv->sta_lock, flags);
1242 }
1266 1243
1267 /* If we are a client station in a BSS network, use the special 1244 return 0;
1268 * AP station entry (that's the only station we communicate with) */ 1245}
1269 case NL80211_IFTYPE_STATION: 1246EXPORT_SYMBOL_GPL(iwl_alloc_bcast_station);
1270 /*
1271 * If addition of station not complete yet, which means
1272 * that rate scaling has not been initialized, then return
1273 * the broadcast station.
1274 */
1275 if (!(priv->stations[IWL_AP_ID].used & IWL_STA_UCODE_ACTIVE))
1276 return priv->hw_params.bcast_sta_id;
1277 return IWL_AP_ID;
1278
1279 /* If we are an AP, then find the station, or use BCAST */
1280 case NL80211_IFTYPE_AP:
1281 sta_id = iwl_find_station(priv, hdr->addr1);
1282 if (sta_id != IWL_INVALID_STATION)
1283 return sta_id;
1284 return priv->hw_params.bcast_sta_id;
1285
1286 /* If this frame is going out to an IBSS network, find the station,
1287 * or create a new station table entry */
1288 case NL80211_IFTYPE_ADHOC:
1289 sta_id = iwl_find_station(priv, hdr->addr1);
1290 if (sta_id != IWL_INVALID_STATION)
1291 return sta_id;
1292
1293 IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
1294 "Defaulting to broadcast...\n",
1295 hdr->addr1);
1296 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
1297 return priv->hw_params.bcast_sta_id;
1298 1247
1299 default: 1248void iwl_dealloc_bcast_station(struct iwl_priv *priv)
1300 IWL_WARN(priv, "Unknown mode of operation: %d\n", 1249{
1301 priv->iw_mode); 1250 unsigned long flags;
1302 return priv->hw_params.bcast_sta_id; 1251 int i;
1252
1253 spin_lock_irqsave(&priv->sta_lock, flags);
1254 for (i = 0; i < priv->hw_params.max_stations; i++) {
1255 if (!(priv->stations[i].used & IWL_STA_BCAST))
1256 continue;
1257
1258 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
1259 priv->num_stations--;
1260 BUG_ON(priv->num_stations < 0);
1261 kfree(priv->stations[i].lq);
1262 priv->stations[i].lq = NULL;
1303 } 1263 }
1264 spin_unlock_irqrestore(&priv->sta_lock, flags);
1304} 1265}
1305EXPORT_SYMBOL(iwl_get_sta_id); 1266EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_station);
1306 1267
1307/** 1268/**
1308 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table 1269 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
@@ -1322,13 +1283,13 @@ void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
1322} 1283}
1323EXPORT_SYMBOL(iwl_sta_tx_modify_enable_tid); 1284EXPORT_SYMBOL(iwl_sta_tx_modify_enable_tid);
1324 1285
1325int iwl_sta_rx_agg_start(struct iwl_priv *priv, 1286int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
1326 const u8 *addr, int tid, u16 ssn) 1287 int tid, u16 ssn)
1327{ 1288{
1328 unsigned long flags; 1289 unsigned long flags;
1329 int sta_id; 1290 int sta_id;
1330 1291
1331 sta_id = iwl_find_station(priv, addr); 1292 sta_id = iwl_sta_id(sta);
1332 if (sta_id == IWL_INVALID_STATION) 1293 if (sta_id == IWL_INVALID_STATION)
1333 return -ENXIO; 1294 return -ENXIO;
1334 1295
@@ -1341,16 +1302,17 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv,
1341 spin_unlock_irqrestore(&priv->sta_lock, flags); 1302 spin_unlock_irqrestore(&priv->sta_lock, flags);
1342 1303
1343 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta, 1304 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1344 CMD_ASYNC); 1305 CMD_ASYNC);
1345} 1306}
1346EXPORT_SYMBOL(iwl_sta_rx_agg_start); 1307EXPORT_SYMBOL(iwl_sta_rx_agg_start);
1347 1308
1348int iwl_sta_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid) 1309int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
1310 int tid)
1349{ 1311{
1350 unsigned long flags; 1312 unsigned long flags;
1351 int sta_id; 1313 int sta_id;
1352 1314
1353 sta_id = iwl_find_station(priv, addr); 1315 sta_id = iwl_sta_id(sta);
1354 if (sta_id == IWL_INVALID_STATION) { 1316 if (sta_id == IWL_INVALID_STATION) {
1355 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid); 1317 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid);
1356 return -ENXIO; 1318 return -ENXIO;
@@ -1402,14 +1364,16 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt)
1402EXPORT_SYMBOL(iwl_sta_modify_sleep_tx_count); 1364EXPORT_SYMBOL(iwl_sta_modify_sleep_tx_count);
1403 1365
1404int iwl_mac_sta_remove(struct ieee80211_hw *hw, 1366int iwl_mac_sta_remove(struct ieee80211_hw *hw,
1405 struct ieee80211_vif *vif, 1367 struct ieee80211_vif *vif,
1406 struct ieee80211_sta *sta) 1368 struct ieee80211_sta *sta)
1407{ 1369{
1408 int ret;
1409 struct iwl_priv *priv = hw->priv; 1370 struct iwl_priv *priv = hw->priv;
1371 struct iwl_station_priv_common *sta_common = (void *)sta->drv_priv;
1372 int ret;
1373
1410 IWL_DEBUG_INFO(priv, "received request to remove station %pM\n", 1374 IWL_DEBUG_INFO(priv, "received request to remove station %pM\n",
1411 sta->addr); 1375 sta->addr);
1412 ret = iwl_remove_station(priv, sta); 1376 ret = iwl_remove_station(priv, sta_common->sta_id, sta->addr);
1413 if (ret) 1377 if (ret)
1414 IWL_ERR(priv, "Error removing station %pM\n", 1378 IWL_ERR(priv, "Error removing station %pM\n",
1415 sta->addr); 1379 sta->addr);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index 42cd2f4a01cd..c2a453a1a991 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -29,6 +29,8 @@
29#ifndef __iwl_sta_h__ 29#ifndef __iwl_sta_h__
30#define __iwl_sta_h__ 30#define __iwl_sta_h__
31 31
32#include "iwl-dev.h"
33
32#define HW_KEY_DYNAMIC 0 34#define HW_KEY_DYNAMIC 0
33#define HW_KEY_DEFAULT 1 35#define HW_KEY_DEFAULT 1
34 36
@@ -36,14 +38,11 @@
36#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ 38#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
37#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of 39#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of
38 being activated */ 40 being activated */
41#define IWL_STA_LOCAL BIT(3) /* station state not directed by mac80211;
42 (this is for the IBSS BSSID stations) */
43#define IWL_STA_BCAST BIT(4) /* this station is the special bcast station */
39 44
40 45
41/**
42 * iwl_find_station - Find station id for a given BSSID
43 * @bssid: MAC address of station ID to find
44 */
45u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid);
46
47int iwl_remove_default_wep_key(struct iwl_priv *priv, 46int iwl_remove_default_wep_key(struct iwl_priv *priv,
48 struct ieee80211_key_conf *key); 47 struct ieee80211_key_conf *key);
49int iwl_set_default_wep_key(struct iwl_priv *priv, 48int iwl_set_default_wep_key(struct iwl_priv *priv,
@@ -55,28 +54,57 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
55 struct ieee80211_key_conf *key, u8 sta_id); 54 struct ieee80211_key_conf *key, u8 sta_id);
56void iwl_update_tkip_key(struct iwl_priv *priv, 55void iwl_update_tkip_key(struct iwl_priv *priv,
57 struct ieee80211_key_conf *keyconf, 56 struct ieee80211_key_conf *keyconf,
58 const u8 *addr, u32 iv32, u16 *phase1key); 57 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
59 58
60void iwl_add_bcast_station(struct iwl_priv *priv);
61void iwl3945_add_bcast_station(struct iwl_priv *priv);
62void iwl_restore_stations(struct iwl_priv *priv); 59void iwl_restore_stations(struct iwl_priv *priv);
63void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force); 60void iwl_clear_ucode_stations(struct iwl_priv *priv);
61int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq);
62void iwl_dealloc_bcast_station(struct iwl_priv *priv);
64int iwl_get_free_ucode_key_index(struct iwl_priv *priv); 63int iwl_get_free_ucode_key_index(struct iwl_priv *priv);
65int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
66int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
67int iwl_send_add_sta(struct iwl_priv *priv, 64int iwl_send_add_sta(struct iwl_priv *priv,
68 struct iwl_addsta_cmd *sta, u8 flags); 65 struct iwl_addsta_cmd *sta, u8 flags);
69int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs); 66int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
67 u8 *sta_id_r);
70int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr, 68int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr,
71 bool is_ap, 69 bool is_ap,
72 struct ieee80211_sta_ht_cap *ht_info, 70 struct ieee80211_sta_ht_cap *ht_info,
73 u8 *sta_id_r); 71 u8 *sta_id_r);
72int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
73 const u8 *addr);
74int iwl_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 74int iwl_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
75 struct ieee80211_sta *sta); 75 struct ieee80211_sta *sta);
76void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid); 76void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid);
77int iwl_sta_rx_agg_start(struct iwl_priv *priv, 77int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
78 const u8 *addr, int tid, u16 ssn); 78 int tid, u16 ssn);
79int iwl_sta_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid); 79int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
80 int tid);
80void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id); 81void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id);
81void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt); 82void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt);
83
84/**
85 * iwl_clear_driver_stations - clear knowledge of all stations from driver
86 * @priv: iwl priv struct
87 *
88 * This is called during iwl_down() to make sure that in the case
89 * we're coming there from a hardware restart mac80211 will be
90 * able to reconfigure stations -- if we're getting there in the
91 * normal down flow then the stations will already be cleared.
92 */
93static inline void iwl_clear_driver_stations(struct iwl_priv *priv)
94{
95 unsigned long flags;
96
97 spin_lock_irqsave(&priv->sta_lock, flags);
98 memset(priv->stations, 0, sizeof(priv->stations));
99 priv->num_stations = 0;
100 spin_unlock_irqrestore(&priv->sta_lock, flags);
101}
102
103static inline int iwl_sta_id(struct ieee80211_sta *sta)
104{
105 if (WARN_ON(!sta))
106 return IWL_INVALID_STATION;
107
108 return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id;
109}
82#endif /* __iwl_sta_h__ */ 110#endif /* __iwl_sta_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 1beb81c0be68..3e5bffb6034f 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -509,11 +509,11 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
509 509
510 hdr_len = ieee80211_hdrlen(fc); 510 hdr_len = ieee80211_hdrlen(fc);
511 511
512 /* Find (or create) index into station table for destination station */ 512 /* Find index into station table for destination station */
513 if (info->flags & IEEE80211_TX_CTL_INJECTED) 513 if (!info->control.sta)
514 sta_id = priv->hw_params.bcast_sta_id; 514 sta_id = priv->hw_params.bcast_sta_id;
515 else 515 else
516 sta_id = iwl_get_sta_id(priv, hdr); 516 sta_id = iwl_sta_id(info->control.sta);
517 if (sta_id == IWL_INVALID_STATION) { 517 if (sta_id == IWL_INVALID_STATION) {
518 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 518 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
519 hdr->addr1); 519 hdr->addr1);
@@ -1847,7 +1847,8 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1847static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, 1847static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1848 enum ieee80211_band band, 1848 enum ieee80211_band band,
1849 u8 is_active, u8 n_probes, 1849 u8 is_active, u8 n_probes,
1850 struct iwl3945_scan_channel *scan_ch) 1850 struct iwl3945_scan_channel *scan_ch,
1851 struct ieee80211_vif *vif)
1851{ 1852{
1852 struct ieee80211_channel *chan; 1853 struct ieee80211_channel *chan;
1853 const struct ieee80211_supported_band *sband; 1854 const struct ieee80211_supported_band *sband;
@@ -1861,7 +1862,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1861 return 0; 1862 return 0;
1862 1863
1863 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); 1864 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
1864 passive_dwell = iwl_get_passive_dwell_time(priv, band); 1865 passive_dwell = iwl_get_passive_dwell_time(priv, band, vif);
1865 1866
1866 if (passive_dwell <= active_dwell) 1867 if (passive_dwell <= active_dwell)
1867 passive_dwell = active_dwell + 1; 1868 passive_dwell = active_dwell + 1;
@@ -2109,6 +2110,28 @@ static void iwl3945_nic_start(struct iwl_priv *priv)
2109 iwl_write32(priv, CSR_RESET, 0); 2110 iwl_write32(priv, CSR_RESET, 0);
2110} 2111}
2111 2112
2113#define IWL3945_UCODE_GET(item) \
2114static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode)\
2115{ \
2116 return le32_to_cpu(ucode->u.v1.item); \
2117}
2118
2119static u32 iwl3945_ucode_get_header_size(u32 api_ver)
2120{
2121 return 24;
2122}
2123
2124static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode)
2125{
2126 return (u8 *) ucode->u.v1.data;
2127}
2128
2129IWL3945_UCODE_GET(inst_size);
2130IWL3945_UCODE_GET(data_size);
2131IWL3945_UCODE_GET(init_size);
2132IWL3945_UCODE_GET(init_data_size);
2133IWL3945_UCODE_GET(boot_size);
2134
2112/** 2135/**
2113 * iwl3945_read_ucode - Read uCode images from disk file. 2136 * iwl3945_read_ucode - Read uCode images from disk file.
2114 * 2137 *
@@ -2157,7 +2180,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
2157 goto error; 2180 goto error;
2158 2181
2159 /* Make sure that we got at least our header! */ 2182 /* Make sure that we got at least our header! */
2160 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { 2183 if (ucode_raw->size < iwl3945_ucode_get_header_size(1)) {
2161 IWL_ERR(priv, "File size way too small!\n"); 2184 IWL_ERR(priv, "File size way too small!\n");
2162 ret = -EINVAL; 2185 ret = -EINVAL;
2163 goto err_release; 2186 goto err_release;
@@ -2168,13 +2191,12 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
2168 2191
2169 priv->ucode_ver = le32_to_cpu(ucode->ver); 2192 priv->ucode_ver = le32_to_cpu(ucode->ver);
2170 api_ver = IWL_UCODE_API(priv->ucode_ver); 2193 api_ver = IWL_UCODE_API(priv->ucode_ver);
2171 inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver); 2194 inst_size = iwl3945_ucode_get_inst_size(ucode);
2172 data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver); 2195 data_size = iwl3945_ucode_get_data_size(ucode);
2173 init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver); 2196 init_size = iwl3945_ucode_get_init_size(ucode);
2174 init_data_size = 2197 init_data_size = iwl3945_ucode_get_init_data_size(ucode);
2175 priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver); 2198 boot_size = iwl3945_ucode_get_boot_size(ucode);
2176 boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver); 2199 src = iwl3945_ucode_get_data(ucode);
2177 src = priv->cfg->ops->ucode->get_data(ucode, api_ver);
2178 2200
2179 /* api_ver should match the api version forming part of the 2201 /* api_ver should match the api version forming part of the
2180 * firmware filename ... but we don't check for that and only rely 2202 * firmware filename ... but we don't check for that and only rely
@@ -2223,7 +2245,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
2223 2245
2224 2246
2225 /* Verify size of file vs. image size info in file's header */ 2247 /* Verify size of file vs. image size info in file's header */
2226 if (ucode_raw->size != priv->cfg->ops->ucode->get_header_size(api_ver) + 2248 if (ucode_raw->size != iwl3945_ucode_get_header_size(api_ver) +
2227 inst_size + data_size + init_size + 2249 inst_size + data_size + init_size +
2228 init_data_size + boot_size) { 2250 init_data_size + boot_size) {
2229 2251
@@ -2522,7 +2544,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2522 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2544 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2523 } else { 2545 } else {
2524 /* Initialize our rx_config data */ 2546 /* Initialize our rx_config data */
2525 iwl_connection_init_rx_config(priv, priv->iw_mode); 2547 iwl_connection_init_rx_config(priv, NULL);
2526 } 2548 }
2527 2549
2528 /* Configure Bluetooth device coexistence support */ 2550 /* Configure Bluetooth device coexistence support */
@@ -2561,7 +2583,9 @@ static void __iwl3945_down(struct iwl_priv *priv)
2561 set_bit(STATUS_EXIT_PENDING, &priv->status); 2583 set_bit(STATUS_EXIT_PENDING, &priv->status);
2562 2584
2563 /* Station information will now be cleared in device */ 2585 /* Station information will now be cleared in device */
2564 iwl_clear_ucode_stations(priv, true); 2586 iwl_clear_ucode_stations(priv);
2587 iwl_dealloc_bcast_station(priv);
2588 iwl_clear_driver_stations(priv);
2565 2589
2566 /* Unblock any waiting calls */ 2590 /* Unblock any waiting calls */
2567 wake_up_interruptible_all(&priv->wait_command_queue); 2591 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2642,6 +2666,10 @@ static int __iwl3945_up(struct iwl_priv *priv)
2642{ 2666{
2643 int rc, i; 2667 int rc, i;
2644 2668
2669 rc = iwl_alloc_bcast_station(priv, false);
2670 if (rc)
2671 return rc;
2672
2645 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 2673 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
2646 IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); 2674 IWL_WARN(priv, "Exit pending; will not bring the NIC up\n");
2647 return -EIO; 2675 return -EIO;
@@ -2790,7 +2818,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
2790 2818
2791} 2819}
2792 2820
2793void iwl3945_request_scan(struct iwl_priv *priv) 2821void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2794{ 2822{
2795 struct iwl_host_cmd cmd = { 2823 struct iwl_host_cmd cmd = {
2796 .id = REPLY_SCAN_CMD, 2824 .id = REPLY_SCAN_CMD,
@@ -2871,7 +2899,7 @@ void iwl3945_request_scan(struct iwl_priv *priv)
2871 IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); 2899 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
2872 2900
2873 spin_lock_irqsave(&priv->lock, flags); 2901 spin_lock_irqsave(&priv->lock, flags);
2874 interval = priv->beacon_int; 2902 interval = vif ? vif->bss_conf.beacon_int : 0;
2875 spin_unlock_irqrestore(&priv->lock, flags); 2903 spin_unlock_irqrestore(&priv->lock, flags);
2876 2904
2877 scan->suspend_time = 0; 2905 scan->suspend_time = 0;
@@ -2966,7 +2994,7 @@ void iwl3945_request_scan(struct iwl_priv *priv)
2966 2994
2967 scan->channel_count = 2995 scan->channel_count =
2968 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, 2996 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
2969 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 2997 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)], vif);
2970 2998
2971 if (scan->channel_count == 0) { 2999 if (scan->channel_count == 0) {
2972 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 3000 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
@@ -3039,26 +3067,25 @@ static void iwl3945_bg_rx_replenish(struct work_struct *data)
3039 mutex_unlock(&priv->mutex); 3067 mutex_unlock(&priv->mutex);
3040} 3068}
3041 3069
3042void iwl3945_post_associate(struct iwl_priv *priv) 3070void iwl3945_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3043{ 3071{
3044 int rc = 0; 3072 int rc = 0;
3045 struct ieee80211_conf *conf = NULL; 3073 struct ieee80211_conf *conf = NULL;
3046 3074
3047 if (priv->iw_mode == NL80211_IFTYPE_AP) { 3075 if (!vif || !priv->is_open)
3076 return;
3077
3078 if (vif->type == NL80211_IFTYPE_AP) {
3048 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__); 3079 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__);
3049 return; 3080 return;
3050 } 3081 }
3051 3082
3052
3053 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", 3083 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
3054 priv->assoc_id, priv->active_rxon.bssid_addr); 3084 vif->bss_conf.aid, priv->active_rxon.bssid_addr);
3055 3085
3056 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3086 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3057 return; 3087 return;
3058 3088
3059 if (!priv->vif || !priv->is_open)
3060 return;
3061
3062 iwl_scan_cancel_timeout(priv, 200); 3089 iwl_scan_cancel_timeout(priv, 200);
3063 3090
3064 conf = ieee80211_get_hw_conf(priv->hw); 3091 conf = ieee80211_get_hw_conf(priv->hw);
@@ -3067,7 +3094,7 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3067 iwlcore_commit_rxon(priv); 3094 iwlcore_commit_rxon(priv);
3068 3095
3069 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 3096 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
3070 iwl_setup_rxon_timing(priv); 3097 iwl_setup_rxon_timing(priv, vif);
3071 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3098 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
3072 sizeof(priv->rxon_timing), &priv->rxon_timing); 3099 sizeof(priv->rxon_timing), &priv->rxon_timing);
3073 if (rc) 3100 if (rc)
@@ -3076,51 +3103,38 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3076 3103
3077 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3104 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
3078 3105
3079 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3106 priv->staging_rxon.assoc_id = cpu_to_le16(vif->bss_conf.aid);
3080 3107
3081 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", 3108 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
3082 priv->assoc_id, priv->beacon_int); 3109 vif->bss_conf.aid, vif->bss_conf.beacon_int);
3083 3110
3084 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3111 if (vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
3085 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 3112 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
3086 else 3113 else
3087 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 3114 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
3088 3115
3089 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3116 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
3090 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 3117 if (vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
3091 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 3118 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
3092 else 3119 else
3093 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3120 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3094 3121
3095 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3122 if (vif->type == NL80211_IFTYPE_ADHOC)
3096 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3123 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3097
3098 } 3124 }
3099 3125
3100 iwlcore_commit_rxon(priv); 3126 iwlcore_commit_rxon(priv);
3101 3127
3102 switch (priv->iw_mode) { 3128 switch (vif->type) {
3103 case NL80211_IFTYPE_STATION: 3129 case NL80211_IFTYPE_STATION:
3104 iwl3945_rate_scale_init(priv->hw, IWL_AP_ID); 3130 iwl3945_rate_scale_init(priv->hw, IWL_AP_ID);
3105 break; 3131 break;
3106
3107 case NL80211_IFTYPE_ADHOC: 3132 case NL80211_IFTYPE_ADHOC:
3108
3109 priv->assoc_id = 1;
3110 iwl_add_local_station(priv, priv->bssid, false);
3111 iwl3945_sync_sta(priv, IWL_STA_ID,
3112 (priv->band == IEEE80211_BAND_5GHZ) ?
3113 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP,
3114 CMD_ASYNC);
3115 iwl3945_rate_scale_init(priv->hw, IWL_STA_ID);
3116
3117 iwl3945_send_beacon_cmd(priv); 3133 iwl3945_send_beacon_cmd(priv);
3118
3119 break; 3134 break;
3120
3121 default: 3135 default:
3122 IWL_ERR(priv, "%s Should not be called in %d mode\n", 3136 IWL_ERR(priv, "%s Should not be called in %d mode\n",
3123 __func__, priv->iw_mode); 3137 __func__, vif->type);
3124 break; 3138 break;
3125 } 3139 }
3126} 3140}
@@ -3244,7 +3258,7 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3244 return NETDEV_TX_OK; 3258 return NETDEV_TX_OK;
3245} 3259}
3246 3260
3247void iwl3945_config_ap(struct iwl_priv *priv) 3261void iwl3945_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
3248{ 3262{
3249 int rc = 0; 3263 int rc = 0;
3250 3264
@@ -3260,7 +3274,7 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3260 3274
3261 /* RXON Timing */ 3275 /* RXON Timing */
3262 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 3276 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
3263 iwl_setup_rxon_timing(priv); 3277 iwl_setup_rxon_timing(priv, vif);
3264 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3278 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
3265 sizeof(priv->rxon_timing), 3279 sizeof(priv->rxon_timing),
3266 &priv->rxon_timing); 3280 &priv->rxon_timing);
@@ -3268,9 +3282,10 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3268 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3282 IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
3269 "Attempting to continue.\n"); 3283 "Attempting to continue.\n");
3270 3284
3271 /* FIXME: what should be the assoc_id for AP? */ 3285 priv->staging_rxon.assoc_id = 0;
3272 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3286
3273 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3287 if (vif->bss_conf.assoc_capability &
3288 WLAN_CAPABILITY_SHORT_PREAMBLE)
3274 priv->staging_rxon.flags |= 3289 priv->staging_rxon.flags |=
3275 RXON_FLG_SHORT_PREAMBLE_MSK; 3290 RXON_FLG_SHORT_PREAMBLE_MSK;
3276 else 3291 else
@@ -3278,22 +3293,21 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3278 ~RXON_FLG_SHORT_PREAMBLE_MSK; 3293 ~RXON_FLG_SHORT_PREAMBLE_MSK;
3279 3294
3280 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3295 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
3281 if (priv->assoc_capability & 3296 if (vif->bss_conf.assoc_capability &
3282 WLAN_CAPABILITY_SHORT_SLOT_TIME) 3297 WLAN_CAPABILITY_SHORT_SLOT_TIME)
3283 priv->staging_rxon.flags |= 3298 priv->staging_rxon.flags |=
3284 RXON_FLG_SHORT_SLOT_MSK; 3299 RXON_FLG_SHORT_SLOT_MSK;
3285 else 3300 else
3286 priv->staging_rxon.flags &= 3301 priv->staging_rxon.flags &=
3287 ~RXON_FLG_SHORT_SLOT_MSK; 3302 ~RXON_FLG_SHORT_SLOT_MSK;
3288 3303
3289 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3304 if (vif->type == NL80211_IFTYPE_ADHOC)
3290 priv->staging_rxon.flags &= 3305 priv->staging_rxon.flags &=
3291 ~RXON_FLG_SHORT_SLOT_MSK; 3306 ~RXON_FLG_SHORT_SLOT_MSK;
3292 } 3307 }
3293 /* restore RXON assoc */ 3308 /* restore RXON assoc */
3294 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3309 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
3295 iwlcore_commit_rxon(priv); 3310 iwlcore_commit_rxon(priv);
3296 iwl_add_local_station(priv, iwl_bcast_addr, false);
3297 } 3311 }
3298 iwl3945_send_beacon_cmd(priv); 3312 iwl3945_send_beacon_cmd(priv);
3299 3313
@@ -3308,7 +3322,6 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3308 struct ieee80211_key_conf *key) 3322 struct ieee80211_key_conf *key)
3309{ 3323{
3310 struct iwl_priv *priv = hw->priv; 3324 struct iwl_priv *priv = hw->priv;
3311 const u8 *addr;
3312 int ret = 0; 3325 int ret = 0;
3313 u8 sta_id = IWL_INVALID_STATION; 3326 u8 sta_id = IWL_INVALID_STATION;
3314 u8 static_key; 3327 u8 static_key;
@@ -3320,15 +3333,19 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3320 return -EOPNOTSUPP; 3333 return -EOPNOTSUPP;
3321 } 3334 }
3322 3335
3323 addr = sta ? sta->addr : iwl_bcast_addr;
3324 static_key = !iwl_is_associated(priv); 3336 static_key = !iwl_is_associated(priv);
3325 3337
3326 if (!static_key) { 3338 if (!static_key) {
3327 sta_id = iwl_find_station(priv, addr); 3339 if (!sta) {
3328 if (sta_id == IWL_INVALID_STATION) { 3340 sta_id = priv->hw_params.bcast_sta_id;
3329 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n", 3341 } else {
3330 addr); 3342 sta_id = iwl_sta_id(sta);
3331 return -EINVAL; 3343 if (sta_id == IWL_INVALID_STATION) {
3344 IWL_DEBUG_MAC80211(priv,
3345 "leave - %pM not in station map.\n",
3346 sta->addr);
3347 return -EINVAL;
3348 }
3332 } 3349 }
3333 } 3350 }
3334 3351
@@ -3365,10 +3382,13 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3365 struct ieee80211_sta *sta) 3382 struct ieee80211_sta *sta)
3366{ 3383{
3367 struct iwl_priv *priv = hw->priv; 3384 struct iwl_priv *priv = hw->priv;
3385 struct iwl3945_sta_priv *sta_priv = (void *)sta->drv_priv;
3368 int ret; 3386 int ret;
3369 bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION; 3387 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
3370 u8 sta_id; 3388 u8 sta_id;
3371 3389
3390 sta_priv->common.sta_id = IWL_INVALID_STATION;
3391
3372 IWL_DEBUG_INFO(priv, "received request to add station %pM\n", 3392 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3373 sta->addr); 3393 sta->addr);
3374 3394
@@ -3381,16 +3401,14 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3381 return ret; 3401 return ret;
3382 } 3402 }
3383 3403
3404 sta_priv->common.sta_id = sta_id;
3405
3384 /* Initialize rate scaling */ 3406 /* Initialize rate scaling */
3385 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", 3407 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
3386 sta->addr); 3408 sta->addr);
3387 iwl3945_rs_rate_init(priv, sta, sta_id); 3409 iwl3945_rs_rate_init(priv, sta, sta_id);
3388 3410
3389 return 0; 3411 return 0;
3390
3391
3392
3393 return ret;
3394} 3412}
3395/***************************************************************************** 3413/*****************************************************************************
3396 * 3414 *
@@ -3739,6 +3757,7 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv)
3739 INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll); 3757 INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll);
3740 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 3758 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
3741 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 3759 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
3760 INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
3742 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 3761 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
3743 3762
3744 iwl3945_hw_setup_deferred_work(priv); 3763 iwl3945_hw_setup_deferred_work(priv);
@@ -3761,6 +3780,7 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv)
3761 cancel_delayed_work_sync(&priv->init_alive_start); 3780 cancel_delayed_work_sync(&priv->init_alive_start);
3762 cancel_delayed_work(&priv->scan_check); 3781 cancel_delayed_work(&priv->scan_check);
3763 cancel_delayed_work(&priv->alive_start); 3782 cancel_delayed_work(&priv->alive_start);
3783 cancel_work_sync(&priv->start_internal_scan);
3764 cancel_work_sync(&priv->beacon_update); 3784 cancel_work_sync(&priv->beacon_update);
3765 if (priv->cfg->ops->lib->recover_from_tx_stall) 3785 if (priv->cfg->ops->lib->recover_from_tx_stall)
3766 del_timer_sync(&priv->monitor_recover); 3786 del_timer_sync(&priv->monitor_recover);
@@ -3863,6 +3883,8 @@ err:
3863 return ret; 3883 return ret;
3864} 3884}
3865 3885
3886#define IWL3945_MAX_PROBE_REQUEST 200
3887
3866static int iwl3945_setup_mac(struct iwl_priv *priv) 3888static int iwl3945_setup_mac(struct iwl_priv *priv)
3867{ 3889{
3868 int ret; 3890 int ret;
@@ -3870,6 +3892,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3870 3892
3871 hw->rate_control_algorithm = "iwl-3945-rs"; 3893 hw->rate_control_algorithm = "iwl-3945-rs";
3872 hw->sta_data_size = sizeof(struct iwl3945_sta_priv); 3894 hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
3895 hw->vif_data_size = sizeof(struct iwl_vif_priv);
3873 3896
3874 /* Tell mac80211 our characteristics */ 3897 /* Tell mac80211 our characteristics */
3875 hw->flags = IEEE80211_HW_SIGNAL_DBM | 3898 hw->flags = IEEE80211_HW_SIGNAL_DBM |
@@ -3888,7 +3911,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3888 3911
3889 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; 3912 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
3890 /* we create the 802.11 header and a zero-length SSID element */ 3913 /* we create the 802.11 header and a zero-length SSID element */
3891 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 3914 hw->wiphy->max_scan_ie_len = IWL3945_MAX_PROBE_REQUEST - 24 - 2;
3892 3915
3893 /* Default value; 4 EDCA QOS priorities */ 3916 /* Default value; 4 EDCA QOS priorities */
3894 hw->queues = 4; 3917 hw->queues = 4;
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 6126c0ab5880..4ba7b038928f 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -1007,15 +1007,15 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1007{ 1007{
1008 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 1008 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1009 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; 1009 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
1010 __le32 *txd = skbdesc->desc; 1010 __le32 *txd = entry_priv->desc;
1011 u32 word; 1011 u32 word;
1012 1012
1013 /* 1013 /*
1014 * Start writing the descriptor words. 1014 * Start writing the descriptor words.
1015 */ 1015 */
1016 rt2x00_desc_read(entry_priv->desc, 1, &word); 1016 rt2x00_desc_read(txd, 1, &word);
1017 rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma); 1017 rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
1018 rt2x00_desc_write(entry_priv->desc, 1, word); 1018 rt2x00_desc_write(txd, 1, word);
1019 1019
1020 rt2x00_desc_read(txd, 2, &word); 1020 rt2x00_desc_read(txd, 2, &word);
1021 rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, txdesc->length); 1021 rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, txdesc->length);
@@ -1040,6 +1040,11 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1040 rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_HIGH_BUSY, 1); 1040 rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_HIGH_BUSY, 1);
1041 rt2x00_desc_write(txd, 4, word); 1041 rt2x00_desc_write(txd, 4, word);
1042 1042
1043 /*
1044 * Writing TXD word 0 must the last to prevent a race condition with
1045 * the device, whereby the device may take hold of the TXD before we
1046 * finished updating it.
1047 */
1043 rt2x00_desc_read(txd, 0, &word); 1048 rt2x00_desc_read(txd, 0, &word);
1044 rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); 1049 rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1);
1045 rt2x00_set_field32(&word, TXD_W0_VALID, 1); 1050 rt2x00_set_field32(&word, TXD_W0_VALID, 1);
@@ -1055,6 +1060,12 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1055 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, 1060 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
1056 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); 1061 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
1057 rt2x00_desc_write(txd, 0, word); 1062 rt2x00_desc_write(txd, 0, word);
1063
1064 /*
1065 * Register descriptor details in skb frame descriptor.
1066 */
1067 skbdesc->desc = txd;
1068 skbdesc->desc_len = TXD_DESC_SIZE;
1058} 1069}
1059 1070
1060/* 1071/*
@@ -1077,15 +1088,6 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,
1077 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0); 1088 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1078 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 1089 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1079 1090
1080 /*
1081 * Replace rt2x00lib allocated descriptor with the
1082 * pointer to the _real_ hardware descriptor.
1083 * After that, map the beacon to DMA and update the
1084 * descriptor.
1085 */
1086 memcpy(entry_priv->desc, skbdesc->desc, skbdesc->desc_len);
1087 skbdesc->desc = entry_priv->desc;
1088
1089 rt2x00queue_map_txskb(rt2x00dev, entry->skb); 1091 rt2x00queue_map_txskb(rt2x00dev, entry->skb);
1090 1092
1091 rt2x00_desc_read(entry_priv->desc, 1, &word); 1093 rt2x00_desc_read(entry_priv->desc, 1, &word);
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 2e4f461406ae..89d132d4af12 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1165,15 +1165,15 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1165{ 1165{
1166 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 1166 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1167 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; 1167 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
1168 __le32 *txd = skbdesc->desc; 1168 __le32 *txd = entry_priv->desc;
1169 u32 word; 1169 u32 word;
1170 1170
1171 /* 1171 /*
1172 * Start writing the descriptor words. 1172 * Start writing the descriptor words.
1173 */ 1173 */
1174 rt2x00_desc_read(entry_priv->desc, 1, &word); 1174 rt2x00_desc_read(txd, 1, &word);
1175 rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma); 1175 rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
1176 rt2x00_desc_write(entry_priv->desc, 1, word); 1176 rt2x00_desc_write(txd, 1, word);
1177 1177
1178 rt2x00_desc_read(txd, 2, &word); 1178 rt2x00_desc_read(txd, 2, &word);
1179 rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER); 1179 rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER);
@@ -1194,6 +1194,11 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1194 test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)); 1194 test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags));
1195 rt2x00_desc_write(txd, 10, word); 1195 rt2x00_desc_write(txd, 10, word);
1196 1196
1197 /*
1198 * Writing TXD word 0 must the last to prevent a race condition with
1199 * the device, whereby the device may take hold of the TXD before we
1200 * finished updating it.
1201 */
1197 rt2x00_desc_read(txd, 0, &word); 1202 rt2x00_desc_read(txd, 0, &word);
1198 rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); 1203 rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1);
1199 rt2x00_set_field32(&word, TXD_W0_VALID, 1); 1204 rt2x00_set_field32(&word, TXD_W0_VALID, 1);
@@ -1212,6 +1217,12 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1212 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length); 1217 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
1213 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); 1218 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE);
1214 rt2x00_desc_write(txd, 0, word); 1219 rt2x00_desc_write(txd, 0, word);
1220
1221 /*
1222 * Register descriptor details in skb frame descriptor.
1223 */
1224 skbdesc->desc = txd;
1225 skbdesc->desc_len = TXD_DESC_SIZE;
1215} 1226}
1216 1227
1217/* 1228/*
@@ -1234,15 +1245,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,
1234 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0); 1245 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1235 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 1246 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1236 1247
1237 /*
1238 * Replace rt2x00lib allocated descriptor with the
1239 * pointer to the _real_ hardware descriptor.
1240 * After that, map the beacon to DMA and update the
1241 * descriptor.
1242 */
1243 memcpy(entry_priv->desc, skbdesc->desc, skbdesc->desc_len);
1244 skbdesc->desc = entry_priv->desc;
1245
1246 rt2x00queue_map_txskb(rt2x00dev, entry->skb); 1248 rt2x00queue_map_txskb(rt2x00dev, entry->skb);
1247 1249
1248 rt2x00_desc_read(entry_priv->desc, 1, &word); 1250 rt2x00_desc_read(entry_priv->desc, 1, &word);
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index e88d7033fbc9..9ae96a626e6d 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1034,12 +1034,30 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1034 struct txentry_desc *txdesc) 1034 struct txentry_desc *txdesc)
1035{ 1035{
1036 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 1036 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1037 __le32 *txd = skbdesc->desc; 1037 __le32 *txd = (__le32 *)(skb->data - TXD_DESC_SIZE);
1038 u32 word; 1038 u32 word;
1039 1039
1040 /* 1040 /*
1041 * Start writing the descriptor words. 1041 * Start writing the descriptor words.
1042 */ 1042 */
1043 rt2x00_desc_read(txd, 0, &word);
1044 rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit);
1045 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
1046 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1047 rt2x00_set_field32(&word, TXD_W0_ACK,
1048 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1049 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1050 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1051 rt2x00_set_field32(&word, TXD_W0_OFDM,
1052 (txdesc->rate_mode == RATE_MODE_OFDM));
1053 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
1054 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1055 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1056 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
1057 rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
1058 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
1059 rt2x00_desc_write(txd, 0, word);
1060
1043 rt2x00_desc_read(txd, 1, &word); 1061 rt2x00_desc_read(txd, 1, &word);
1044 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset); 1062 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
1045 rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs); 1063 rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs);
@@ -1059,23 +1077,11 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1059 _rt2x00_desc_write(txd, 4, skbdesc->iv[1]); 1077 _rt2x00_desc_write(txd, 4, skbdesc->iv[1]);
1060 } 1078 }
1061 1079
1062 rt2x00_desc_read(txd, 0, &word); 1080 /*
1063 rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit); 1081 * Register descriptor details in skb frame descriptor.
1064 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, 1082 */
1065 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); 1083 skbdesc->desc = txd;
1066 rt2x00_set_field32(&word, TXD_W0_ACK, 1084 skbdesc->desc_len = TXD_DESC_SIZE;
1067 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1068 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1069 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1070 rt2x00_set_field32(&word, TXD_W0_OFDM,
1071 (txdesc->rate_mode == RATE_MODE_OFDM));
1072 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
1073 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1074 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1075 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
1076 rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
1077 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
1078 rt2x00_desc_write(txd, 0, word);
1079} 1085}
1080 1086
1081/* 1087/*
@@ -1089,19 +1095,11 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,
1089 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1095 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1090 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); 1096 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
1091 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data; 1097 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
1092 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1093 int pipe = usb_sndbulkpipe(usb_dev, entry->queue->usb_endpoint); 1098 int pipe = usb_sndbulkpipe(usb_dev, entry->queue->usb_endpoint);
1094 int length; 1099 int length;
1095 u16 reg, reg0; 1100 u16 reg, reg0;
1096 1101
1097 /* 1102 /*
1098 * Add the descriptor in front of the skb.
1099 */
1100 skb_push(entry->skb, entry->queue->desc_size);
1101 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1102 skbdesc->desc = entry->skb->data;
1103
1104 /*
1105 * Disable beaconing while we are reloading the beacon data, 1103 * Disable beaconing while we are reloading the beacon data,
1106 * otherwise we might be sending out invalid data. 1104 * otherwise we might be sending out invalid data.
1107 */ 1105 */
@@ -1110,6 +1108,11 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,
1110 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg); 1108 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1111 1109
1112 /* 1110 /*
1111 * Take the descriptor in front of the skb into account.
1112 */
1113 skb_push(entry->skb, TXD_DESC_SIZE);
1114
1115 /*
1113 * USB devices cannot blindly pass the skb->len as the 1116 * USB devices cannot blindly pass the skb->len as the
1114 * length of the data to usb_fill_bulk_urb. Pass the skb 1117 * length of the data to usb_fill_bulk_urb. Pass the skb
1115 * to the driver to determine what the length should be. 1118 * to the driver to determine what the length should be.
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 7d4778d66e77..b2f23272c3aa 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -633,7 +633,8 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
633 struct txentry_desc *txdesc) 633 struct txentry_desc *txdesc)
634{ 634{
635 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 635 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
636 __le32 *txd = skbdesc->desc; 636 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
637 __le32 *txd = entry_priv->desc;
637 u32 word; 638 u32 word;
638 639
639 /* 640 /*
@@ -657,15 +658,14 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
657 !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); 658 !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
658 rt2x00_set_field32(&word, TXD_W1_BURST, 659 rt2x00_set_field32(&word, TXD_W1_BURST,
659 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 660 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
660 rt2x00_set_field32(&word, TXD_W1_SD_LEN0, 661 rt2x00_set_field32(&word, TXD_W1_SD_LEN0, TXWI_DESC_SIZE);
661 rt2x00dev->ops->extra_tx_headroom);
662 rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0); 662 rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0);
663 rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0); 663 rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0);
664 rt2x00_desc_write(txd, 1, word); 664 rt2x00_desc_write(txd, 1, word);
665 665
666 rt2x00_desc_read(txd, 2, &word); 666 rt2x00_desc_read(txd, 2, &word);
667 rt2x00_set_field32(&word, TXD_W2_SD_PTR1, 667 rt2x00_set_field32(&word, TXD_W2_SD_PTR1,
668 skbdesc->skb_dma + rt2x00dev->ops->extra_tx_headroom); 668 skbdesc->skb_dma + TXWI_DESC_SIZE);
669 rt2x00_desc_write(txd, 2, word); 669 rt2x00_desc_write(txd, 2, word);
670 670
671 rt2x00_desc_read(txd, 3, &word); 671 rt2x00_desc_read(txd, 3, &word);
@@ -673,6 +673,12 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
673 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); 673 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
674 rt2x00_set_field32(&word, TXD_W3_QSEL, 2); 674 rt2x00_set_field32(&word, TXD_W3_QSEL, 2);
675 rt2x00_desc_write(txd, 3, word); 675 rt2x00_desc_write(txd, 3, word);
676
677 /*
678 * Register descriptor details in skb frame descriptor.
679 */
680 skbdesc->desc = txd;
681 skbdesc->desc_len = TXD_DESC_SIZE;
676} 682}
677 683
678/* 684/*
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 8ad0669a1b99..0f8b84b7224c 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -400,7 +400,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
400 struct txentry_desc *txdesc) 400 struct txentry_desc *txdesc)
401{ 401{
402 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 402 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
403 __le32 *txi = skbdesc->desc; 403 __le32 *txi = (__le32 *)(skb->data - TXWI_DESC_SIZE - TXINFO_DESC_SIZE);
404 u32 word; 404 u32 word;
405 405
406 /* 406 /*
@@ -422,6 +422,12 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
422 rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST, 422 rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST,
423 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 423 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
424 rt2x00_desc_write(txi, 0, word); 424 rt2x00_desc_write(txi, 0, word);
425
426 /*
427 * Register descriptor details in skb frame descriptor.
428 */
429 skbdesc->desc = txi;
430 skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
425} 431}
426 432
427/* 433/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index e2497f820d75..e9fe93fd8042 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -156,10 +156,11 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
156 enum rt2x00_dump_type type, struct sk_buff *skb) 156 enum rt2x00_dump_type type, struct sk_buff *skb)
157{ 157{
158 struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf; 158 struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf;
159 struct skb_frame_desc *desc = get_skb_frame_desc(skb); 159 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
160 struct sk_buff *skbcopy; 160 struct sk_buff *skbcopy;
161 struct rt2x00dump_hdr *dump_hdr; 161 struct rt2x00dump_hdr *dump_hdr;
162 struct timeval timestamp; 162 struct timeval timestamp;
163 u32 data_len;
163 164
164 do_gettimeofday(&timestamp); 165 do_gettimeofday(&timestamp);
165 166
@@ -171,7 +172,11 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
171 return; 172 return;
172 } 173 }
173 174
174 skbcopy = alloc_skb(sizeof(*dump_hdr) + desc->desc_len + skb->len, 175 data_len = skb->len;
176 if (skbdesc->flags & SKBDESC_DESC_IN_SKB)
177 data_len -= skbdesc->desc_len;
178
179 skbcopy = alloc_skb(sizeof(*dump_hdr) + skbdesc->desc_len + data_len,
175 GFP_ATOMIC); 180 GFP_ATOMIC);
176 if (!skbcopy) { 181 if (!skbcopy) {
177 DEBUG(rt2x00dev, "Failed to copy skb for dump.\n"); 182 DEBUG(rt2x00dev, "Failed to copy skb for dump.\n");
@@ -181,18 +186,20 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
181 dump_hdr = (struct rt2x00dump_hdr *)skb_put(skbcopy, sizeof(*dump_hdr)); 186 dump_hdr = (struct rt2x00dump_hdr *)skb_put(skbcopy, sizeof(*dump_hdr));
182 dump_hdr->version = cpu_to_le32(DUMP_HEADER_VERSION); 187 dump_hdr->version = cpu_to_le32(DUMP_HEADER_VERSION);
183 dump_hdr->header_length = cpu_to_le32(sizeof(*dump_hdr)); 188 dump_hdr->header_length = cpu_to_le32(sizeof(*dump_hdr));
184 dump_hdr->desc_length = cpu_to_le32(desc->desc_len); 189 dump_hdr->desc_length = cpu_to_le32(skbdesc->desc_len);
185 dump_hdr->data_length = cpu_to_le32(skb->len); 190 dump_hdr->data_length = cpu_to_le32(data_len);
186 dump_hdr->chip_rt = cpu_to_le16(rt2x00dev->chip.rt); 191 dump_hdr->chip_rt = cpu_to_le16(rt2x00dev->chip.rt);
187 dump_hdr->chip_rf = cpu_to_le16(rt2x00dev->chip.rf); 192 dump_hdr->chip_rf = cpu_to_le16(rt2x00dev->chip.rf);
188 dump_hdr->chip_rev = cpu_to_le16(rt2x00dev->chip.rev); 193 dump_hdr->chip_rev = cpu_to_le16(rt2x00dev->chip.rev);
189 dump_hdr->type = cpu_to_le16(type); 194 dump_hdr->type = cpu_to_le16(type);
190 dump_hdr->queue_index = desc->entry->queue->qid; 195 dump_hdr->queue_index = skbdesc->entry->queue->qid;
191 dump_hdr->entry_index = desc->entry->entry_idx; 196 dump_hdr->entry_index = skbdesc->entry->entry_idx;
192 dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec); 197 dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec);
193 dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_usec); 198 dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_usec);
194 199
195 memcpy(skb_put(skbcopy, desc->desc_len), desc->desc, desc->desc_len); 200 if (!(skbdesc->flags & SKBDESC_DESC_IN_SKB))
201 memcpy(skb_put(skbcopy, skbdesc->desc_len), skbdesc->desc,
202 skbdesc->desc_len);
196 memcpy(skb_put(skbcopy, skb->len), skb->data, skb->len); 203 memcpy(skb_put(skbcopy, skb->len), skb->data, skb->len);
197 204
198 skb_queue_tail(&intf->frame_dump_skbqueue, skbcopy); 205 skb_queue_tail(&intf->frame_dump_skbqueue, skbcopy);
diff --git a/drivers/net/wireless/rt2x00/rt2x00dump.h b/drivers/net/wireless/rt2x00/rt2x00dump.h
index 727019a748e7..ed303b423e41 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dump.h
+++ b/drivers/net/wireless/rt2x00/rt2x00dump.h
@@ -62,11 +62,14 @@
62 * the tx event which has either succeeded or failed. A frame 62 * the tx event which has either succeeded or failed. A frame
63 * with this type should also have been reported with as a 63 * with this type should also have been reported with as a
64 * %DUMP_FRAME_TX frame. 64 * %DUMP_FRAME_TX frame.
65 * @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the
66 * hardware.
65 */ 67 */
66enum rt2x00_dump_type { 68enum rt2x00_dump_type {
67 DUMP_FRAME_RXDONE = 1, 69 DUMP_FRAME_RXDONE = 1,
68 DUMP_FRAME_TX = 2, 70 DUMP_FRAME_TX = 2,
69 DUMP_FRAME_TXDONE = 3, 71 DUMP_FRAME_TXDONE = 3,
72 DUMP_FRAME_BEACON = 4,
70}; 73};
71 74
72/** 75/**
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 4b941e9c794e..a016f7ccde29 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -67,8 +67,6 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry,
67 struct txentry_desc *txdesc) 67 struct txentry_desc *txdesc)
68{ 68{
69 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 69 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
70 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
71 struct skb_frame_desc *skbdesc;
72 70
73 /* 71 /*
74 * This should not happen, we already checked the entry 72 * This should not happen, we already checked the entry
@@ -83,13 +81,6 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry,
83 return -EINVAL; 81 return -EINVAL;
84 } 82 }
85 83
86 /*
87 * Fill in skb descriptor
88 */
89 skbdesc = get_skb_frame_desc(entry->skb);
90 skbdesc->desc = entry_priv->desc;
91 skbdesc->desc_len = entry->queue->desc_size;
92
93 return 0; 84 return 0;
94} 85}
95EXPORT_SYMBOL_GPL(rt2x00pci_write_tx_data); 86EXPORT_SYMBOL_GPL(rt2x00pci_write_tx_data);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 089a12c7b90f..20dbdd6fb904 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -421,6 +421,7 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
421{ 421{
422 struct data_queue *queue = entry->queue; 422 struct data_queue *queue = entry->queue;
423 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; 423 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
424 enum rt2x00_dump_type dump_type;
424 425
425 rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, entry->skb, txdesc); 426 rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, entry->skb, txdesc);
426 427
@@ -428,7 +429,9 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
428 * All processing on the frame has been completed, this means 429 * All processing on the frame has been completed, this means
429 * it is now ready to be dumped to userspace through debugfs. 430 * it is now ready to be dumped to userspace through debugfs.
430 */ 431 */
431 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TX, entry->skb); 432 dump_type = (txdesc->queue == QID_BEACON) ?
433 DUMP_FRAME_BEACON : DUMP_FRAME_TX;
434 rt2x00debug_dump_frame(rt2x00dev, dump_type, entry->skb);
432} 435}
433 436
434static void rt2x00queue_kick_tx_queue(struct queue_entry *entry, 437static void rt2x00queue_kick_tx_queue(struct queue_entry *entry,
@@ -553,7 +556,6 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
553 struct rt2x00_intf *intf = vif_to_intf(vif); 556 struct rt2x00_intf *intf = vif_to_intf(vif);
554 struct skb_frame_desc *skbdesc; 557 struct skb_frame_desc *skbdesc;
555 struct txentry_desc txdesc; 558 struct txentry_desc txdesc;
556 __le32 desc[16];
557 559
558 if (unlikely(!intf->beacon)) 560 if (unlikely(!intf->beacon))
559 return -ENOBUFS; 561 return -ENOBUFS;
@@ -586,19 +588,10 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
586 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); 588 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
587 589
588 /* 590 /*
589 * For the descriptor we use a local array from where the
590 * driver can move it to the correct location required for
591 * the hardware.
592 */
593 memset(desc, 0, sizeof(desc));
594
595 /*
596 * Fill in skb descriptor 591 * Fill in skb descriptor
597 */ 592 */
598 skbdesc = get_skb_frame_desc(intf->beacon->skb); 593 skbdesc = get_skb_frame_desc(intf->beacon->skb);
599 memset(skbdesc, 0, sizeof(*skbdesc)); 594 memset(skbdesc, 0, sizeof(*skbdesc));
600 skbdesc->desc = desc;
601 skbdesc->desc_len = intf->beacon->queue->desc_size;
602 skbdesc->entry = intf->beacon; 595 skbdesc->entry = intf->beacon;
603 596
604 /* 597 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index 36a957adc1f9..f79170849add 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -94,12 +94,15 @@ enum data_queue_qid {
94 * mac80211 but was stripped for processing by the driver. 94 * mac80211 but was stripped for processing by the driver.
95 * @SKBDESC_NOT_MAC80211: Frame didn't originate from mac80211, 95 * @SKBDESC_NOT_MAC80211: Frame didn't originate from mac80211,
96 * don't try to pass it back. 96 * don't try to pass it back.
97 * @SKBDESC_DESC_IN_SKB: The descriptor is at the start of the
98 * skb, instead of in the desc field.
97 */ 99 */
98enum skb_frame_desc_flags { 100enum skb_frame_desc_flags {
99 SKBDESC_DMA_MAPPED_RX = 1 << 0, 101 SKBDESC_DMA_MAPPED_RX = 1 << 0,
100 SKBDESC_DMA_MAPPED_TX = 1 << 1, 102 SKBDESC_DMA_MAPPED_TX = 1 << 1,
101 SKBDESC_IV_STRIPPED = 1 << 2, 103 SKBDESC_IV_STRIPPED = 1 << 2,
102 SKBDESC_NOT_MAC80211 = 1 << 3, 104 SKBDESC_NOT_MAC80211 = 1 << 3,
105 SKBDESC_DESC_IN_SKB = 1 << 4,
103}; 106};
104 107
105/** 108/**
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index da111c0c2928..bd1546ba7ad2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -222,7 +222,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,
222 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 222 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
223 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); 223 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
224 struct queue_entry_priv_usb *entry_priv = entry->priv_data; 224 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
225 struct skb_frame_desc *skbdesc;
226 u32 length; 225 u32 length;
227 226
228 /* 227 /*
@@ -232,13 +231,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,
232 memset(entry->skb->data, 0, entry->queue->desc_size); 231 memset(entry->skb->data, 0, entry->queue->desc_size);
233 232
234 /* 233 /*
235 * Fill in skb descriptor
236 */
237 skbdesc = get_skb_frame_desc(entry->skb);
238 skbdesc->desc = entry->skb->data;
239 skbdesc->desc_len = entry->queue->desc_size;
240
241 /*
242 * USB devices cannot blindly pass the skb->len as the 234 * USB devices cannot blindly pass the skb->len as the
243 * length of the data to usb_fill_bulk_urb. Pass the skb 235 * length of the data to usb_fill_bulk_urb. Pass the skb
244 * to the driver to determine what the length should be. 236 * to the driver to determine what the length should be.
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 86c75b9c3f25..2e3076f67535 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1764,7 +1764,8 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1764 struct txentry_desc *txdesc) 1764 struct txentry_desc *txdesc)
1765{ 1765{
1766 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 1766 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1767 __le32 *txd = skbdesc->desc; 1767 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
1768 __le32 *txd = entry_priv->desc;
1768 u32 word; 1769 u32 word;
1769 1770
1770 /* 1771 /*
@@ -1802,18 +1803,23 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1802 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1803 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
1803 rt2x00_desc_write(txd, 5, word); 1804 rt2x00_desc_write(txd, 5, word);
1804 1805
1805 rt2x00_desc_read(txd, 6, &word); 1806 if (txdesc->queue != QID_BEACON) {
1806 rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS, 1807 rt2x00_desc_read(txd, 6, &word);
1807 skbdesc->skb_dma); 1808 rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS,
1808 rt2x00_desc_write(txd, 6, word); 1809 skbdesc->skb_dma);
1810 rt2x00_desc_write(txd, 6, word);
1809 1811
1810 if (skbdesc->desc_len > TXINFO_SIZE) {
1811 rt2x00_desc_read(txd, 11, &word); 1812 rt2x00_desc_read(txd, 11, &word);
1812 rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, 1813 rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0,
1813 txdesc->length); 1814 txdesc->length);
1814 rt2x00_desc_write(txd, 11, word); 1815 rt2x00_desc_write(txd, 11, word);
1815 } 1816 }
1816 1817
1818 /*
1819 * Writing TXD word 0 must the last to prevent a race condition with
1820 * the device, whereby the device may take hold of the TXD before we
1821 * finished updating it.
1822 */
1817 rt2x00_desc_read(txd, 0, &word); 1823 rt2x00_desc_read(txd, 0, &word);
1818 rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); 1824 rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1);
1819 rt2x00_set_field32(&word, TXD_W0_VALID, 1); 1825 rt2x00_set_field32(&word, TXD_W0_VALID, 1);
@@ -1838,6 +1844,13 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1838 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 1844 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1839 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher); 1845 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher);
1840 rt2x00_desc_write(txd, 0, word); 1846 rt2x00_desc_write(txd, 0, word);
1847
1848 /*
1849 * Register descriptor details in skb frame descriptor.
1850 */
1851 skbdesc->desc = txd;
1852 skbdesc->desc_len =
1853 (txdesc->queue == QID_BEACON) ? TXINFO_SIZE : TXD_DESC_SIZE;
1841} 1854}
1842 1855
1843/* 1856/*
@@ -1847,7 +1860,7 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
1847 struct txentry_desc *txdesc) 1860 struct txentry_desc *txdesc)
1848{ 1861{
1849 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1862 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1850 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 1863 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
1851 unsigned int beacon_base; 1864 unsigned int beacon_base;
1852 u32 reg; 1865 u32 reg;
1853 1866
@@ -1863,11 +1876,9 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
1863 * Write entire beacon with descriptor to register. 1876 * Write entire beacon with descriptor to register.
1864 */ 1877 */
1865 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 1878 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1866 rt2x00pci_register_multiwrite(rt2x00dev, 1879 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base,
1867 beacon_base, 1880 entry_priv->desc, TXINFO_SIZE);
1868 skbdesc->desc, skbdesc->desc_len); 1881 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base + TXINFO_SIZE,
1869 rt2x00pci_register_multiwrite(rt2x00dev,
1870 beacon_base + skbdesc->desc_len,
1871 entry->skb->data, entry->skb->len); 1882 entry->skb->data, entry->skb->len);
1872 1883
1873 /* 1884 /*
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 11c130748206..e35bd19c3c5a 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1441,12 +1441,38 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1441 struct txentry_desc *txdesc) 1441 struct txentry_desc *txdesc)
1442{ 1442{
1443 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 1443 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1444 __le32 *txd = skbdesc->desc; 1444 __le32 *txd = (__le32 *)(skb->data - TXD_DESC_SIZE);
1445 u32 word; 1445 u32 word;
1446 1446
1447 /* 1447 /*
1448 * Start writing the descriptor words. 1448 * Start writing the descriptor words.
1449 */ 1449 */
1450 rt2x00_desc_read(txd, 0, &word);
1451 rt2x00_set_field32(&word, TXD_W0_BURST,
1452 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1453 rt2x00_set_field32(&word, TXD_W0_VALID, 1);
1454 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
1455 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1456 rt2x00_set_field32(&word, TXD_W0_ACK,
1457 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1458 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1459 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1460 rt2x00_set_field32(&word, TXD_W0_OFDM,
1461 (txdesc->rate_mode == RATE_MODE_OFDM));
1462 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1463 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
1464 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
1465 rt2x00_set_field32(&word, TXD_W0_TKIP_MIC,
1466 test_bit(ENTRY_TXD_ENCRYPT_MMIC, &txdesc->flags));
1467 rt2x00_set_field32(&word, TXD_W0_KEY_TABLE,
1468 test_bit(ENTRY_TXD_ENCRYPT_PAIRWISE, &txdesc->flags));
1469 rt2x00_set_field32(&word, TXD_W0_KEY_INDEX, txdesc->key_idx);
1470 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
1471 rt2x00_set_field32(&word, TXD_W0_BURST2,
1472 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1473 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher);
1474 rt2x00_desc_write(txd, 0, word);
1475
1450 rt2x00_desc_read(txd, 1, &word); 1476 rt2x00_desc_read(txd, 1, &word);
1451 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->queue); 1477 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->queue);
1452 rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs); 1478 rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs);
@@ -1475,31 +1501,11 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1475 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1501 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
1476 rt2x00_desc_write(txd, 5, word); 1502 rt2x00_desc_write(txd, 5, word);
1477 1503
1478 rt2x00_desc_read(txd, 0, &word); 1504 /*
1479 rt2x00_set_field32(&word, TXD_W0_BURST, 1505 * Register descriptor details in skb frame descriptor.
1480 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 1506 */
1481 rt2x00_set_field32(&word, TXD_W0_VALID, 1); 1507 skbdesc->desc = txd;
1482 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, 1508 skbdesc->desc_len = TXD_DESC_SIZE;
1483 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1484 rt2x00_set_field32(&word, TXD_W0_ACK,
1485 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1486 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1487 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1488 rt2x00_set_field32(&word, TXD_W0_OFDM,
1489 (txdesc->rate_mode == RATE_MODE_OFDM));
1490 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1491 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
1492 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
1493 rt2x00_set_field32(&word, TXD_W0_TKIP_MIC,
1494 test_bit(ENTRY_TXD_ENCRYPT_MMIC, &txdesc->flags));
1495 rt2x00_set_field32(&word, TXD_W0_KEY_TABLE,
1496 test_bit(ENTRY_TXD_ENCRYPT_PAIRWISE, &txdesc->flags));
1497 rt2x00_set_field32(&word, TXD_W0_KEY_INDEX, txdesc->key_idx);
1498 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
1499 rt2x00_set_field32(&word, TXD_W0_BURST2,
1500 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1501 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher);
1502 rt2x00_desc_write(txd, 0, word);
1503} 1509}
1504 1510
1505/* 1511/*
@@ -1509,18 +1515,10 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
1509 struct txentry_desc *txdesc) 1515 struct txentry_desc *txdesc)
1510{ 1516{
1511 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1517 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1512 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1513 unsigned int beacon_base; 1518 unsigned int beacon_base;
1514 u32 reg; 1519 u32 reg;
1515 1520
1516 /* 1521 /*
1517 * Add the descriptor in front of the skb.
1518 */
1519 skb_push(entry->skb, entry->queue->desc_size);
1520 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1521 skbdesc->desc = entry->skb->data;
1522
1523 /*
1524 * Disable beaconing while we are reloading the beacon data, 1522 * Disable beaconing while we are reloading the beacon data,
1525 * otherwise we might be sending out invalid data. 1523 * otherwise we might be sending out invalid data.
1526 */ 1524 */
@@ -1529,6 +1527,11 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
1529 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg); 1527 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1530 1528
1531 /* 1529 /*
1530 * Take the descriptor in front of the skb into account.
1531 */
1532 skb_push(entry->skb, TXD_DESC_SIZE);
1533
1534 /*
1532 * Write entire beacon with descriptor to register. 1535 * Write entire beacon with descriptor to register.
1533 */ 1536 */
1534 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 1537 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 5bb9e3fff961..b7d9137851ac 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -467,6 +467,7 @@ static void wl1271_irq_work(struct work_struct *work)
467 intr = le32_to_cpu(wl->fw_status->intr); 467 intr = le32_to_cpu(wl->fw_status->intr);
468 if (!intr) { 468 if (!intr) {
469 wl1271_debug(DEBUG_IRQ, "Zero interrupt received."); 469 wl1271_debug(DEBUG_IRQ, "Zero interrupt received.");
470 spin_lock_irqsave(&wl->wl_lock, flags);
470 continue; 471 continue;
471 } 472 }
472 473
@@ -852,7 +853,7 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
852 if (wl == wl_temp) 853 if (wl == wl_temp)
853 break; 854 break;
854 } 855 }
855 if (wl == NULL) 856 if (wl != wl_temp)
856 return NOTIFY_DONE; 857 return NOTIFY_DONE;
857 858
858 /* Get the interface IP address for the device. "ifa" will become 859 /* Get the interface IP address for the device. "ifa" will become
@@ -1558,8 +1559,6 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1558 default: 1559 default:
1559 wl1271_error("Unsupported key cmd 0x%x", cmd); 1560 wl1271_error("Unsupported key cmd 0x%x", cmd);
1560 ret = -EOPNOTSUPP; 1561 ret = -EOPNOTSUPP;
1561 goto out_sleep;
1562
1563 break; 1562 break;
1564 } 1563 }
1565 1564
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ac45c5b9d7e2..5be900d19660 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -712,6 +712,28 @@ struct ieee80211_conf {
712}; 712};
713 713
714/** 714/**
715 * struct ieee80211_channel_switch - holds the channel switch data
716 *
717 * The information provided in this structure is required for channel switch
718 * operation.
719 *
720 * @timestamp: value in microseconds of the 64-bit Time Synchronization
721 * Function (TSF) timer when the frame containing the channel switch
722 * announcement was received. This is simply the rx.mactime parameter
723 * the driver passed into mac80211.
724 * @block_tx: Indicates whether transmission must be blocked before the
725 * scheduled channel switch, as indicated by the AP.
726 * @channel: the new channel to switch to
727 * @count: the number of TBTT's until the channel switch event
728 */
729struct ieee80211_channel_switch {
730 u64 timestamp;
731 bool block_tx;
732 struct ieee80211_channel *channel;
733 u8 count;
734};
735
736/**
715 * struct ieee80211_vif - per-interface data 737 * struct ieee80211_vif - per-interface data
716 * 738 *
717 * Data in this structure is continually present for driver 739 * Data in this structure is continually present for driver
@@ -1631,6 +1653,11 @@ enum ieee80211_ampdu_mlme_action {
1631 * @flush: Flush all pending frames from the hardware queue, making sure 1653 * @flush: Flush all pending frames from the hardware queue, making sure
1632 * that the hardware queues are empty. If the parameter @drop is set 1654 * that the hardware queues are empty. If the parameter @drop is set
1633 * to %true, pending frames may be dropped. The callback can sleep. 1655 * to %true, pending frames may be dropped. The callback can sleep.
1656 *
1657 * @channel_switch: Drivers that need (or want) to offload the channel
1658 * switch operation for CSAs received from the AP may implement this
1659 * callback. They must then call ieee80211_chswitch_done() to indicate
1660 * completion of the channel switch.
1634 */ 1661 */
1635struct ieee80211_ops { 1662struct ieee80211_ops {
1636 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); 1663 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
@@ -1694,6 +1721,8 @@ struct ieee80211_ops {
1694 int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len); 1721 int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len);
1695#endif 1722#endif
1696 void (*flush)(struct ieee80211_hw *hw, bool drop); 1723 void (*flush)(struct ieee80211_hw *hw, bool drop);
1724 void (*channel_switch)(struct ieee80211_hw *hw,
1725 struct ieee80211_channel_switch *ch_switch);
1697}; 1726};
1698 1727
1699/** 1728/**
@@ -2444,6 +2473,16 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
2444 enum nl80211_cqm_rssi_threshold_event rssi_event, 2473 enum nl80211_cqm_rssi_threshold_event rssi_event,
2445 gfp_t gfp); 2474 gfp_t gfp);
2446 2475
2476/**
2477 * ieee80211_chswitch_done - Complete channel switch process
2478 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
2479 * @success: make the channel switch successful or not
2480 *
2481 * Complete the channel switch post-process: set the new operational channel
2482 * and wake up the suspended queues.
2483 */
2484void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
2485
2447/* Rate control API */ 2486/* Rate control API */
2448 2487
2449/** 2488/**
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index ee8b63f92f71..4f2271316650 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -371,4 +371,15 @@ static inline void drv_flush(struct ieee80211_local *local, bool drop)
371 if (local->ops->flush) 371 if (local->ops->flush)
372 local->ops->flush(&local->hw, drop); 372 local->ops->flush(&local->hw, drop);
373} 373}
374
375static inline void drv_channel_switch(struct ieee80211_local *local,
376 struct ieee80211_channel_switch *ch_switch)
377{
378 might_sleep();
379
380 local->ops->channel_switch(&local->hw, ch_switch);
381
382 trace_drv_channel_switch(local, ch_switch);
383}
384
374#endif /* __MAC80211_DRIVER_OPS */ 385#endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h
index ce734b58d07a..6a9b2342a9c2 100644
--- a/net/mac80211/driver-trace.h
+++ b/net/mac80211/driver-trace.h
@@ -774,6 +774,34 @@ TRACE_EVENT(drv_flush,
774 ) 774 )
775); 775);
776 776
777TRACE_EVENT(drv_channel_switch,
778 TP_PROTO(struct ieee80211_local *local,
779 struct ieee80211_channel_switch *ch_switch),
780
781 TP_ARGS(local, ch_switch),
782
783 TP_STRUCT__entry(
784 LOCAL_ENTRY
785 __field(u64, timestamp)
786 __field(bool, block_tx)
787 __field(u16, freq)
788 __field(u8, count)
789 ),
790
791 TP_fast_assign(
792 LOCAL_ASSIGN;
793 __entry->timestamp = ch_switch->timestamp;
794 __entry->block_tx = ch_switch->block_tx;
795 __entry->freq = ch_switch->channel->center_freq;
796 __entry->count = ch_switch->count;
797 ),
798
799 TP_printk(
800 LOCAL_PR_FMT " new freq:%u count:%d",
801 LOCAL_PR_ARG, __entry->freq, __entry->count
802 )
803);
804
777/* 805/*
778 * Tracing for API calls that drivers call. 806 * Tracing for API calls that drivers call.
779 */ 807 */
@@ -992,6 +1020,27 @@ TRACE_EVENT(api_sta_block_awake,
992 ) 1020 )
993); 1021);
994 1022
1023TRACE_EVENT(api_chswitch_done,
1024 TP_PROTO(struct ieee80211_sub_if_data *sdata, bool success),
1025
1026 TP_ARGS(sdata, success),
1027
1028 TP_STRUCT__entry(
1029 VIF_ENTRY
1030 __field(bool, success)
1031 ),
1032
1033 TP_fast_assign(
1034 VIF_ASSIGN;
1035 __entry->success = success;
1036 ),
1037
1038 TP_printk(
1039 VIF_PR_FMT " success=%d",
1040 VIF_PR_ARG, __entry->success
1041 )
1042);
1043
995/* 1044/*
996 * Tracing for internal functions 1045 * Tracing for internal functions
997 * (which may also be called in response to driver calls) 1046 * (which may also be called in response to driver calls)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 7ef7798d04cd..1a9e2da37a93 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -998,7 +998,8 @@ int ieee80211_max_network_latency(struct notifier_block *nb,
998 unsigned long data, void *dummy); 998 unsigned long data, void *dummy);
999void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, 999void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1000 struct ieee80211_channel_sw_ie *sw_elem, 1000 struct ieee80211_channel_sw_ie *sw_elem,
1001 struct ieee80211_bss *bss); 1001 struct ieee80211_bss *bss,
1002 u64 timestamp);
1002void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata); 1003void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata);
1003void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata); 1004void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
1004 1005
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 3093e46273c3..c6c1f49cc456 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -342,7 +342,11 @@ static void ieee80211_chswitch_work(struct work_struct *work)
342 goto out; 342 goto out;
343 343
344 sdata->local->oper_channel = sdata->local->csa_channel; 344 sdata->local->oper_channel = sdata->local->csa_channel;
345 ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL); 345 if (!sdata->local->ops->channel_switch) {
346 /* call "hw_config" only if doing sw channel switch */
347 ieee80211_hw_config(sdata->local,
348 IEEE80211_CONF_CHANGE_CHANNEL);
349 }
346 350
347 /* XXX: shouldn't really modify cfg80211-owned data! */ 351 /* XXX: shouldn't really modify cfg80211-owned data! */
348 ifmgd->associated->channel = sdata->local->oper_channel; 352 ifmgd->associated->channel = sdata->local->oper_channel;
@@ -354,6 +358,29 @@ static void ieee80211_chswitch_work(struct work_struct *work)
354 mutex_unlock(&ifmgd->mtx); 358 mutex_unlock(&ifmgd->mtx);
355} 359}
356 360
361void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
362{
363 struct ieee80211_sub_if_data *sdata;
364 struct ieee80211_if_managed *ifmgd;
365
366 sdata = vif_to_sdata(vif);
367 ifmgd = &sdata->u.mgd;
368
369 trace_api_chswitch_done(sdata, success);
370 if (!success) {
371 /*
372 * If the channel switch was not successful, stay
373 * around on the old channel. We currently lack
374 * good handling of this situation, possibly we
375 * should just drop the association.
376 */
377 sdata->local->csa_channel = sdata->local->oper_channel;
378 }
379
380 ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
381}
382EXPORT_SYMBOL(ieee80211_chswitch_done);
383
357static void ieee80211_chswitch_timer(unsigned long data) 384static void ieee80211_chswitch_timer(unsigned long data)
358{ 385{
359 struct ieee80211_sub_if_data *sdata = 386 struct ieee80211_sub_if_data *sdata =
@@ -370,7 +397,8 @@ static void ieee80211_chswitch_timer(unsigned long data)
370 397
371void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, 398void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
372 struct ieee80211_channel_sw_ie *sw_elem, 399 struct ieee80211_channel_sw_ie *sw_elem,
373 struct ieee80211_bss *bss) 400 struct ieee80211_bss *bss,
401 u64 timestamp)
374{ 402{
375 struct cfg80211_bss *cbss = 403 struct cfg80211_bss *cbss =
376 container_of((void *)bss, struct cfg80211_bss, priv); 404 container_of((void *)bss, struct cfg80211_bss, priv);
@@ -398,10 +426,29 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
398 426
399 sdata->local->csa_channel = new_ch; 427 sdata->local->csa_channel = new_ch;
400 428
429 if (sdata->local->ops->channel_switch) {
430 /* use driver's channel switch callback */
431 struct ieee80211_channel_switch ch_switch;
432 memset(&ch_switch, 0, sizeof(ch_switch));
433 ch_switch.timestamp = timestamp;
434 if (sw_elem->mode) {
435 ch_switch.block_tx = true;
436 ieee80211_stop_queues_by_reason(&sdata->local->hw,
437 IEEE80211_QUEUE_STOP_REASON_CSA);
438 }
439 ch_switch.channel = new_ch;
440 ch_switch.count = sw_elem->count;
441 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
442 drv_channel_switch(sdata->local, &ch_switch);
443 return;
444 }
445
446 /* channel switch handled in software */
401 if (sw_elem->count <= 1) { 447 if (sw_elem->count <= 1) {
402 ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); 448 ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
403 } else { 449 } else {
404 ieee80211_stop_queues_by_reason(&sdata->local->hw, 450 if (sw_elem->mode)
451 ieee80211_stop_queues_by_reason(&sdata->local->hw,
405 IEEE80211_QUEUE_STOP_REASON_CSA); 452 IEEE80211_QUEUE_STOP_REASON_CSA);
406 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; 453 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
407 mod_timer(&ifmgd->chswitch_timer, 454 mod_timer(&ifmgd->chswitch_timer,
@@ -1317,7 +1364,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1317 ETH_ALEN) == 0)) { 1364 ETH_ALEN) == 0)) {
1318 struct ieee80211_channel_sw_ie *sw_elem = 1365 struct ieee80211_channel_sw_ie *sw_elem =
1319 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; 1366 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem;
1320 ieee80211_sta_process_chanswitch(sdata, sw_elem, bss); 1367 ieee80211_sta_process_chanswitch(sdata, sw_elem,
1368 bss, rx_status->mactime);
1321 } 1369 }
1322} 1370}
1323 1371
@@ -1649,7 +1697,8 @@ static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1649 1697
1650 ieee80211_sta_process_chanswitch(sdata, 1698 ieee80211_sta_process_chanswitch(sdata,
1651 &mgmt->u.action.u.chan_switch.sw_elem, 1699 &mgmt->u.action.u.chan_switch.sw_elem,
1652 (void *)ifmgd->associated->priv); 1700 (void *)ifmgd->associated->priv,
1701 rx_status->mactime);
1653 break; 1702 break;
1654 } 1703 }
1655 mutex_unlock(&ifmgd->mtx); 1704 mutex_unlock(&ifmgd->mtx);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 9a08f2c446c6..6e2a7bcd8cb8 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1253,6 +1253,12 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1253 if (skb_linearize(rx->skb)) 1253 if (skb_linearize(rx->skb))
1254 return RX_DROP_UNUSABLE; 1254 return RX_DROP_UNUSABLE;
1255 1255
1256 /*
1257 * skb_linearize() might change the skb->data and
1258 * previously cached variables (in this case, hdr) need to
1259 * be refreshed with the new data.
1260 */
1261 hdr = (struct ieee80211_hdr *)rx->skb->data;
1256 seq = (sc & IEEE80211_SCTL_SEQ) >> 4; 1262 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
1257 1263
1258 if (frag == 0) { 1264 if (frag == 0) {
diff --git a/net/mac80211/work.c b/net/mac80211/work.c
index 3dd07600199d..be3d4a698692 100644
--- a/net/mac80211/work.c
+++ b/net/mac80211/work.c
@@ -33,6 +33,7 @@
33#define IEEE80211_MAX_PROBE_TRIES 5 33#define IEEE80211_MAX_PROBE_TRIES 5
34 34
35enum work_action { 35enum work_action {
36 WORK_ACT_MISMATCH,
36 WORK_ACT_NONE, 37 WORK_ACT_NONE,
37 WORK_ACT_TIMEOUT, 38 WORK_ACT_TIMEOUT,
38 WORK_ACT_DONE, 39 WORK_ACT_DONE,
@@ -585,7 +586,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_work *wk,
585 u16 auth_alg, auth_transaction, status_code; 586 u16 auth_alg, auth_transaction, status_code;
586 587
587 if (wk->type != IEEE80211_WORK_AUTH) 588 if (wk->type != IEEE80211_WORK_AUTH)
588 return WORK_ACT_NONE; 589 return WORK_ACT_MISMATCH;
589 590
590 if (len < 24 + 6) 591 if (len < 24 + 6)
591 return WORK_ACT_NONE; 592 return WORK_ACT_NONE;
@@ -636,6 +637,9 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_work *wk,
636 struct ieee802_11_elems elems; 637 struct ieee802_11_elems elems;
637 u8 *pos; 638 u8 *pos;
638 639
640 if (wk->type != IEEE80211_WORK_ASSOC)
641 return WORK_ACT_MISMATCH;
642
639 /* 643 /*
640 * AssocResp and ReassocResp have identical structure, so process both 644 * AssocResp and ReassocResp have identical structure, so process both
641 * of them in this function. 645 * of them in this function.
@@ -691,6 +695,12 @@ ieee80211_rx_mgmt_probe_resp(struct ieee80211_work *wk,
691 695
692 ASSERT_WORK_MTX(local); 696 ASSERT_WORK_MTX(local);
693 697
698 if (wk->type != IEEE80211_WORK_DIRECT_PROBE)
699 return WORK_ACT_MISMATCH;
700
701 if (len < 24 + 12)
702 return WORK_ACT_NONE;
703
694 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; 704 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
695 if (baselen > len) 705 if (baselen > len)
696 return WORK_ACT_NONE; 706 return WORK_ACT_NONE;
@@ -705,7 +715,7 @@ static void ieee80211_work_rx_queued_mgmt(struct ieee80211_local *local,
705 struct ieee80211_rx_status *rx_status; 715 struct ieee80211_rx_status *rx_status;
706 struct ieee80211_mgmt *mgmt; 716 struct ieee80211_mgmt *mgmt;
707 struct ieee80211_work *wk; 717 struct ieee80211_work *wk;
708 enum work_action rma = WORK_ACT_NONE; 718 enum work_action rma;
709 u16 fc; 719 u16 fc;
710 720
711 rx_status = (struct ieee80211_rx_status *) skb->cb; 721 rx_status = (struct ieee80211_rx_status *) skb->cb;
@@ -752,7 +762,17 @@ static void ieee80211_work_rx_queued_mgmt(struct ieee80211_local *local,
752 break; 762 break;
753 default: 763 default:
754 WARN_ON(1); 764 WARN_ON(1);
765 rma = WORK_ACT_NONE;
755 } 766 }
767
768 /*
769 * We've either received an unexpected frame, or we have
770 * multiple work items and need to match the frame to the
771 * right one.
772 */
773 if (rma == WORK_ACT_MISMATCH)
774 continue;
775
756 /* 776 /*
757 * We've processed this frame for that work, so it can't 777 * We've processed this frame for that work, so it can't
758 * belong to another work struct. 778 * belong to another work struct.
@@ -762,6 +782,9 @@ static void ieee80211_work_rx_queued_mgmt(struct ieee80211_local *local,
762 } 782 }
763 783
764 switch (rma) { 784 switch (rma) {
785 case WORK_ACT_MISMATCH:
786 /* ignore this unmatched frame */
787 break;
765 case WORK_ACT_NONE: 788 case WORK_ACT_NONE:
766 break; 789 break;
767 case WORK_ACT_DONE: 790 case WORK_ACT_DONE: