aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2013-04-24 10:54:20 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-04-24 10:54:20 -0400
commit6ed0e321a0aef14a894e26658108bf7e895c36a6 (patch)
treef49428d68ebcb1beb757296ea1559079210babbe /drivers/net/wireless/ath
parent3dec2246c2ff11beb24ca1950f074b2bcbc85953 (diff)
parentb006ed545cbadf1ebd4683719554742d20dbcede (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next into for-davem
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ar5523/ar5523.c14
-rw-r--r--drivers/net/wireless/ath/ath5k/Makefile1
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/mac80211-ops.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/trace.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c92
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_hw.c17
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h9
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h6
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c19
-rw-r--r--drivers/net/wireless/ath/ath9k/common.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c43
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h6
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pri_detector.c49
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pri_detector.h27
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c18
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c18
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c15
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h13
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/link.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c19
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c170
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c137
-rw-r--r--drivers/net/wireless/ath/carl9170/debug.c4
-rw-r--r--drivers/net/wireless/ath/carl9170/mac.c8
-rw-r--r--drivers/net/wireless/ath/carl9170/main.c9
-rw-r--r--drivers/net/wireless/ath/carl9170/phy.c4
-rw-r--r--drivers/net/wireless/ath/hw.c6
-rw-r--r--drivers/net/wireless/ath/reg.h4
-rw-r--r--drivers/net/wireless/ath/wil6210/txrx.c29
-rw-r--r--drivers/net/wireless/ath/wil6210/txrx.h49
40 files changed, 420 insertions, 410 deletions
diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c
index afd1e36d308f..17d7fece35d2 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
@@ -457,14 +457,14 @@ static int ar5523_set_chan(struct ar5523 *ar)
457 memset(&reset, 0, sizeof(reset)); 457 memset(&reset, 0, sizeof(reset));
458 reset.flags |= cpu_to_be32(UATH_CHAN_2GHZ); 458 reset.flags |= cpu_to_be32(UATH_CHAN_2GHZ);
459 reset.flags |= cpu_to_be32(UATH_CHAN_OFDM); 459 reset.flags |= cpu_to_be32(UATH_CHAN_OFDM);
460 reset.freq = cpu_to_be32(conf->channel->center_freq); 460 reset.freq = cpu_to_be32(conf->chandef.chan->center_freq);
461 reset.maxrdpower = cpu_to_be32(50); /* XXX */ 461 reset.maxrdpower = cpu_to_be32(50); /* XXX */
462 reset.channelchange = cpu_to_be32(1); 462 reset.channelchange = cpu_to_be32(1);
463 reset.keeprccontent = cpu_to_be32(0); 463 reset.keeprccontent = cpu_to_be32(0);
464 464
465 ar5523_dbg(ar, "set chan flags 0x%x freq %d\n", 465 ar5523_dbg(ar, "set chan flags 0x%x freq %d\n",
466 be32_to_cpu(reset.flags), 466 be32_to_cpu(reset.flags),
467 conf->channel->center_freq); 467 conf->chandef.chan->center_freq);
468 return ar5523_cmd_write(ar, WDCMSG_RESET, &reset, sizeof(reset), 0); 468 return ar5523_cmd_write(ar, WDCMSG_RESET, &reset, sizeof(reset), 0);
469} 469}
470 470
@@ -594,7 +594,7 @@ static void ar5523_data_rx_cb(struct urb *urb)
594 rx_status = IEEE80211_SKB_RXCB(data->skb); 594 rx_status = IEEE80211_SKB_RXCB(data->skb);
595 memset(rx_status, 0, sizeof(*rx_status)); 595 memset(rx_status, 0, sizeof(*rx_status));
596 rx_status->freq = be32_to_cpu(desc->channel); 596 rx_status->freq = be32_to_cpu(desc->channel);
597 rx_status->band = hw->conf.channel->band; 597 rx_status->band = hw->conf.chandef.chan->band;
598 rx_status->signal = -95 + be32_to_cpu(desc->rssi); 598 rx_status->signal = -95 + be32_to_cpu(desc->rssi);
599 599
600 ieee80211_rx_irqsafe(hw, data->skb); 600 ieee80211_rx_irqsafe(hw, data->skb);
@@ -1153,13 +1153,13 @@ static int ar5523_get_wlan_mode(struct ar5523 *ar,
1153 struct ieee80211_sta *sta; 1153 struct ieee80211_sta *sta;
1154 u32 sta_rate_set; 1154 u32 sta_rate_set;
1155 1155
1156 band = ar->hw->wiphy->bands[ar->hw->conf.channel->band]; 1156 band = ar->hw->wiphy->bands[ar->hw->conf.chandef.chan->band];
1157 sta = ieee80211_find_sta(ar->vif, bss_conf->bssid); 1157 sta = ieee80211_find_sta(ar->vif, bss_conf->bssid);
1158 if (!sta) { 1158 if (!sta) {
1159 ar5523_info(ar, "STA not found!\n"); 1159 ar5523_info(ar, "STA not found!\n");
1160 return WLAN_MODE_11b; 1160 return WLAN_MODE_11b;
1161 } 1161 }
1162 sta_rate_set = sta->supp_rates[ar->hw->conf.channel->band]; 1162 sta_rate_set = sta->supp_rates[ar->hw->conf.chandef.chan->band];
1163 1163
1164 for (bit = 0; bit < band->n_bitrates; bit++) { 1164 for (bit = 0; bit < band->n_bitrates; bit++) {
1165 if (sta_rate_set & 1) { 1165 if (sta_rate_set & 1) {
@@ -1197,11 +1197,11 @@ static void ar5523_create_rateset(struct ar5523 *ar,
1197 ar5523_info(ar, "STA not found. Cannot set rates\n"); 1197 ar5523_info(ar, "STA not found. Cannot set rates\n");
1198 sta_rate_set = bss_conf->basic_rates; 1198 sta_rate_set = bss_conf->basic_rates;
1199 } else 1199 } else
1200 sta_rate_set = sta->supp_rates[ar->hw->conf.channel->band]; 1200 sta_rate_set = sta->supp_rates[ar->hw->conf.chandef.chan->band];
1201 1201
1202 ar5523_dbg(ar, "sta rate_set = %08x\n", sta_rate_set); 1202 ar5523_dbg(ar, "sta rate_set = %08x\n", sta_rate_set);
1203 1203
1204 band = ar->hw->wiphy->bands[ar->hw->conf.channel->band]; 1204 band = ar->hw->wiphy->bands[ar->hw->conf.chandef.chan->band];
1205 for (bit = 0; bit < band->n_bitrates; bit++) { 1205 for (bit = 0; bit < band->n_bitrates; bit++) {
1206 BUG_ON(i >= AR5523_MAX_NRATES); 1206 BUG_ON(i >= AR5523_MAX_NRATES);
1207 ar5523_dbg(ar, "Considering rate %d : %d\n", 1207 ar5523_dbg(ar, "Considering rate %d : %d\n",
diff --git a/drivers/net/wireless/ath/ath5k/Makefile b/drivers/net/wireless/ath/ath5k/Makefile
index f60b3899afc4..1b3a34f7f224 100644
--- a/drivers/net/wireless/ath/ath5k/Makefile
+++ b/drivers/net/wireless/ath/ath5k/Makefile
@@ -10,6 +10,7 @@ ath5k-y += phy.o
10ath5k-y += reset.o 10ath5k-y += reset.o
11ath5k-y += attach.o 11ath5k-y += attach.o
12ath5k-y += base.o 12ath5k-y += base.o
13CFLAGS_base.o += -I$(src)
13ath5k-y += led.o 14ath5k-y += led.o
14ath5k-y += rfkill.o 15ath5k-y += rfkill.o
15ath5k-y += ani.o 16ath5k-y += ani.o
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 1d264c0f5a9b..9b20d9ee2719 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -2639,7 +2639,7 @@ int ath5k_start(struct ieee80211_hw *hw)
2639 * be followed by initialization of the appropriate bits 2639 * be followed by initialization of the appropriate bits
2640 * and then setup of the interrupt mask. 2640 * and then setup of the interrupt mask.
2641 */ 2641 */
2642 ah->curchan = ah->hw->conf.channel; 2642 ah->curchan = ah->hw->conf.chandef.chan;
2643 ah->imask = AR5K_INT_RXOK 2643 ah->imask = AR5K_INT_RXOK
2644 | AR5K_INT_RXERR 2644 | AR5K_INT_RXERR
2645 | AR5K_INT_RXEOL 2645 | AR5K_INT_RXEOL
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
index 4264341533ea..06f86f435711 100644
--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
@@ -202,7 +202,7 @@ ath5k_config(struct ieee80211_hw *hw, u32 changed)
202 mutex_lock(&ah->lock); 202 mutex_lock(&ah->lock);
203 203
204 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 204 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
205 ret = ath5k_chan_set(ah, conf->channel); 205 ret = ath5k_chan_set(ah, conf->chandef.chan);
206 if (ret < 0) 206 if (ret < 0)
207 goto unlock; 207 goto unlock;
208 } 208 }
@@ -678,7 +678,7 @@ ath5k_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey)
678 678
679 memcpy(survey, &ah->survey, sizeof(*survey)); 679 memcpy(survey, &ah->survey, sizeof(*survey));
680 680
681 survey->channel = conf->channel; 681 survey->channel = conf->chandef.chan;
682 survey->noise = ah->ah_noise_floor; 682 survey->noise = ah->ah_noise_floor;
683 survey->filled = SURVEY_INFO_NOISE_DBM | 683 survey->filled = SURVEY_INFO_NOISE_DBM |
684 SURVEY_INFO_CHANNEL_TIME | 684 SURVEY_INFO_CHANNEL_TIME |
diff --git a/drivers/net/wireless/ath/ath5k/trace.h b/drivers/net/wireless/ath/ath5k/trace.h
index 00f015819344..c6eef519bb61 100644
--- a/drivers/net/wireless/ath/ath5k/trace.h
+++ b/drivers/net/wireless/ath/ath5k/trace.h
@@ -97,7 +97,7 @@ TRACE_EVENT(ath5k_tx_complete,
97#if defined(CONFIG_ATH5K_TRACER) && !defined(__CHECKER__) 97#if defined(CONFIG_ATH5K_TRACER) && !defined(__CHECKER__)
98 98
99#undef TRACE_INCLUDE_PATH 99#undef TRACE_INCLUDE_PATH
100#define TRACE_INCLUDE_PATH ../../drivers/net/wireless/ath/ath5k 100#define TRACE_INCLUDE_PATH .
101#undef TRACE_INCLUDE_FILE 101#undef TRACE_INCLUDE_FILE
102#define TRACE_INCLUDE_FILE trace 102#define TRACE_INCLUDE_FILE trace
103 103
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index fd69376ecc83..391da5ad6a99 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -18,6 +18,7 @@
18#include "hw-ops.h" 18#include "hw-ops.h"
19#include "../regd.h" 19#include "../regd.h"
20#include "ar9002_phy.h" 20#include "ar9002_phy.h"
21#include "ar5008_initvals.h"
21 22
22/* All code below is for AR5008, AR9001, AR9002 */ 23/* All code below is for AR5008, AR9001, AR9002 */
23 24
@@ -43,23 +44,16 @@ static const int m2ThreshLowExt_off = 127;
43static const int m1ThreshExt_off = 127; 44static const int m1ThreshExt_off = 127;
44static const int m2ThreshExt_off = 127; 45static const int m2ThreshExt_off = 127;
45 46
47static const struct ar5416IniArray bank0 = STATIC_INI_ARRAY(ar5416Bank0);
48static const struct ar5416IniArray bank1 = STATIC_INI_ARRAY(ar5416Bank1);
49static const struct ar5416IniArray bank2 = STATIC_INI_ARRAY(ar5416Bank2);
50static const struct ar5416IniArray bank3 = STATIC_INI_ARRAY(ar5416Bank3);
51static const struct ar5416IniArray bank7 = STATIC_INI_ARRAY(ar5416Bank7);
46 52
47static void ar5008_rf_bank_setup(u32 *bank, struct ar5416IniArray *array, 53static void ar5008_write_bank6(struct ath_hw *ah, unsigned int *writecnt)
48 int col)
49{
50 int i;
51
52 for (i = 0; i < array->ia_rows; i++)
53 bank[i] = INI_RA(array, i, col);
54}
55
56
57#define REG_WRITE_RF_ARRAY(iniarray, regData, regWr) \
58 ar5008_write_rf_array(ah, iniarray, regData, &(regWr))
59
60static void ar5008_write_rf_array(struct ath_hw *ah, struct ar5416IniArray *array,
61 u32 *data, unsigned int *writecnt)
62{ 54{
55 struct ar5416IniArray *array = &ah->iniBank6;
56 u32 *data = ah->analogBank6Data;
63 int r; 57 int r;
64 58
65 ENABLE_REGWRITE_BUFFER(ah); 59 ENABLE_REGWRITE_BUFFER(ah);
@@ -165,7 +159,7 @@ static void ar5008_hw_force_bias(struct ath_hw *ah, u16 synth_freq)
165 ar5008_hw_phy_modify_rx_buffer(ah->analogBank6Data, tmp_reg, 3, 181, 3); 159 ar5008_hw_phy_modify_rx_buffer(ah->analogBank6Data, tmp_reg, 3, 181, 3);
166 160
167 /* write Bank 6 with new params */ 161 /* write Bank 6 with new params */
168 REG_WRITE_RF_ARRAY(&ah->iniBank6, ah->analogBank6Data, reg_writes); 162 ar5008_write_bank6(ah, &reg_writes);
169} 163}
170 164
171/** 165/**
@@ -469,31 +463,16 @@ static void ar5008_hw_spur_mitigate(struct ath_hw *ah,
469 */ 463 */
470static int ar5008_hw_rf_alloc_ext_banks(struct ath_hw *ah) 464static int ar5008_hw_rf_alloc_ext_banks(struct ath_hw *ah)
471{ 465{
472#define ATH_ALLOC_BANK(bank, size) do { \ 466 int size = ah->iniBank6.ia_rows * sizeof(u32);
473 bank = devm_kzalloc(ah->dev, sizeof(u32) * size, GFP_KERNEL); \
474 if (!bank) \
475 goto error; \
476 } while (0);
477
478 struct ath_common *common = ath9k_hw_common(ah);
479 467
480 if (AR_SREV_9280_20_OR_LATER(ah)) 468 if (AR_SREV_9280_20_OR_LATER(ah))
481 return 0; 469 return 0;
482 470
483 ATH_ALLOC_BANK(ah->analogBank0Data, ah->iniBank0.ia_rows); 471 ah->analogBank6Data = devm_kzalloc(ah->dev, size, GFP_KERNEL);
484 ATH_ALLOC_BANK(ah->analogBank1Data, ah->iniBank1.ia_rows); 472 if (!ah->analogBank6Data)
485 ATH_ALLOC_BANK(ah->analogBank2Data, ah->iniBank2.ia_rows); 473 return -ENOMEM;
486 ATH_ALLOC_BANK(ah->analogBank3Data, ah->iniBank3.ia_rows);
487 ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
488 ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
489 ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
490 ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
491 474
492 return 0; 475 return 0;
493#undef ATH_ALLOC_BANK
494error:
495 ath_err(common, "Cannot allocate RF banks\n");
496 return -ENOMEM;
497} 476}
498 477
499 478
@@ -517,6 +496,7 @@ static bool ar5008_hw_set_rf_regs(struct ath_hw *ah,
517 u32 ob5GHz = 0, db5GHz = 0; 496 u32 ob5GHz = 0, db5GHz = 0;
518 u32 ob2GHz = 0, db2GHz = 0; 497 u32 ob2GHz = 0, db2GHz = 0;
519 int regWrites = 0; 498 int regWrites = 0;
499 int i;
520 500
521 /* 501 /*
522 * Software does not need to program bank data 502 * Software does not need to program bank data
@@ -529,25 +509,8 @@ static bool ar5008_hw_set_rf_regs(struct ath_hw *ah,
529 /* Setup rf parameters */ 509 /* Setup rf parameters */
530 eepMinorRev = ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV); 510 eepMinorRev = ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV);
531 511
532 /* Setup Bank 0 Write */ 512 for (i = 0; i < ah->iniBank6.ia_rows; i++)
533 ar5008_rf_bank_setup(ah->analogBank0Data, &ah->iniBank0, 1); 513 ah->analogBank6Data[i] = INI_RA(&ah->iniBank6, i, modesIndex);
534
535 /* Setup Bank 1 Write */
536 ar5008_rf_bank_setup(ah->analogBank1Data, &ah->iniBank1, 1);
537
538 /* Setup Bank 2 Write */
539 ar5008_rf_bank_setup(ah->analogBank2Data, &ah->iniBank2, 1);
540
541 /* Setup Bank 6 Write */
542 ar5008_rf_bank_setup(ah->analogBank3Data, &ah->iniBank3,
543 modesIndex);
544 {
545 int i;
546 for (i = 0; i < ah->iniBank6TPC.ia_rows; i++) {
547 ah->analogBank6Data[i] =
548 INI_RA(&ah->iniBank6TPC, i, modesIndex);
549 }
550 }
551 514
552 /* Only the 5 or 2 GHz OB/DB need to be set for a mode */ 515 /* Only the 5 or 2 GHz OB/DB need to be set for a mode */
553 if (eepMinorRev >= 2) { 516 if (eepMinorRev >= 2) {
@@ -568,22 +531,13 @@ static bool ar5008_hw_set_rf_regs(struct ath_hw *ah,
568 } 531 }
569 } 532 }
570 533
571 /* Setup Bank 7 Setup */
572 ar5008_rf_bank_setup(ah->analogBank7Data, &ah->iniBank7, 1);
573
574 /* Write Analog registers */ 534 /* Write Analog registers */
575 REG_WRITE_RF_ARRAY(&ah->iniBank0, ah->analogBank0Data, 535 REG_WRITE_ARRAY(&bank0, 1, regWrites);
576 regWrites); 536 REG_WRITE_ARRAY(&bank1, 1, regWrites);
577 REG_WRITE_RF_ARRAY(&ah->iniBank1, ah->analogBank1Data, 537 REG_WRITE_ARRAY(&bank2, 1, regWrites);
578 regWrites); 538 REG_WRITE_ARRAY(&bank3, modesIndex, regWrites);
579 REG_WRITE_RF_ARRAY(&ah->iniBank2, ah->analogBank2Data, 539 ar5008_write_bank6(ah, &regWrites);
580 regWrites); 540 REG_WRITE_ARRAY(&bank7, 1, regWrites);
581 REG_WRITE_RF_ARRAY(&ah->iniBank3, ah->analogBank3Data,
582 regWrites);
583 REG_WRITE_RF_ARRAY(&ah->iniBank6TPC, ah->analogBank6Data,
584 regWrites);
585 REG_WRITE_RF_ARRAY(&ah->iniBank7, ah->analogBank7Data,
586 regWrites);
587 541
588 return true; 542 return true;
589} 543}
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
index f053d978540e..830daa12feb6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
@@ -67,12 +67,10 @@ static int ar9002_hw_init_mode_regs(struct ath_hw *ah)
67 } else if (AR_SREV_9100_OR_LATER(ah)) { 67 } else if (AR_SREV_9100_OR_LATER(ah)) {
68 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100); 68 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100);
69 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100); 69 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100);
70 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100);
71 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100); 70 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100);
72 } else { 71 } else {
73 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes); 72 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes);
74 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common); 73 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common);
75 INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC);
76 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac); 74 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac);
77 } 75 }
78 76
@@ -80,20 +78,11 @@ static int ar9002_hw_init_mode_regs(struct ath_hw *ah)
80 /* Common for AR5416, AR913x, AR9160 */ 78 /* Common for AR5416, AR913x, AR9160 */
81 INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain); 79 INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain);
82 80
83 INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0);
84 INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1);
85 INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2);
86 INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3);
87 INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7);
88
89 /* Common for AR5416, AR9160 */
90 if (!AR_SREV_9100(ah))
91 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6);
92
93 /* Common for AR913x, AR9160 */ 81 /* Common for AR913x, AR9160 */
94 if (!AR_SREV_5416(ah)) 82 if (!AR_SREV_5416(ah))
95 INIT_INI_ARRAY(&ah->iniBank6TPC, 83 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6TPC_9100);
96 ar5416Bank6TPC_9100); 84 else
85 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6TPC);
97 } 86 }
98 87
99 /* iniAddac needs to be modified for these chips */ 88 /* iniAddac needs to be modified for these chips */
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index a56b2416e2f9..8a1888d02070 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -234,6 +234,7 @@ struct ath_buf {
234 dma_addr_t bf_daddr; /* physical addr of desc */ 234 dma_addr_t bf_daddr; /* physical addr of desc */
235 dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */ 235 dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */
236 bool bf_stale; 236 bool bf_stale;
237 struct ieee80211_tx_rate rates[4];
237 struct ath_buf_state bf_state; 238 struct ath_buf_state bf_state;
238}; 239};
239 240
@@ -311,6 +312,7 @@ struct ath_rx_edma {
311struct ath_rx { 312struct ath_rx {
312 u8 defant; 313 u8 defant;
313 u8 rxotherant; 314 u8 rxotherant;
315 bool discard_next;
314 u32 *rxlink; 316 u32 *rxlink;
315 u32 num_pkts; 317 u32 num_pkts;
316 unsigned int rxfilter; 318 unsigned int rxfilter;
@@ -657,11 +659,10 @@ enum sc_op_flags {
657struct ath_rate_table; 659struct ath_rate_table;
658 660
659struct ath9k_vif_iter_data { 661struct ath9k_vif_iter_data {
660 const u8 *hw_macaddr; /* phy's hardware address, set 662 u8 hw_macaddr[ETH_ALEN]; /* address of the first vif */
661 * before starting iteration for
662 * valid bssid mask.
663 */
664 u8 mask[ETH_ALEN]; /* bssid mask */ 663 u8 mask[ETH_ALEN]; /* bssid mask */
664 bool has_hw_macaddr;
665
665 int naps; /* number of AP vifs */ 666 int naps; /* number of AP vifs */
666 int nmeshes; /* number of mesh vifs */ 667 int nmeshes; /* number of mesh vifs */
667 int nstations; /* number of station vifs */ 668 int nstations; /* number of station vifs */
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 5f05c26d1ec4..2ff570f7f8ff 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -79,7 +79,7 @@ static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
79 u8 chainmask = ah->txchainmask; 79 u8 chainmask = ah->txchainmask;
80 u8 rate = 0; 80 u8 rate = 0;
81 81
82 sband = &sc->sbands[common->hw->conf.channel->band]; 82 sband = &sc->sbands[common->hw->conf.chandef.chan->band];
83 rate = sband->bitrates[rateidx].hw_value; 83 rate = sband->bitrates[rateidx].hw_value;
84 if (vif->bss_conf.use_short_preamble) 84 if (vif->bss_conf.use_short_preamble)
85 rate |= sband->bitrates[rateidx].hw_value_short; 85 rate |= sband->bitrates[rateidx].hw_value_short;
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 7bdd726c7a8f..7304e7585009 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -208,7 +208,7 @@ bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
208 return true; 208 return true;
209 209
210 ath_dbg(common, CALIBRATE, "Resetting Cal %d state for channel %u\n", 210 ath_dbg(common, CALIBRATE, "Resetting Cal %d state for channel %u\n",
211 currCal->calData->calType, conf->channel->center_freq); 211 currCal->calData->calType, conf->chandef.chan->center_freq);
212 212
213 ah->caldata->CalValid &= ~currCal->calData->calType; 213 ah->caldata->CalValid &= ~currCal->calData->calType;
214 currCal->calState = CAL_WAITING; 214 currCal->calState = CAL_WAITING;
diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index 60dcb6c22db9..3d70b8c2bcdd 100644
--- a/drivers/net/wireless/ath/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -33,6 +33,12 @@ struct ar5416IniArray {
33 u32 ia_columns; 33 u32 ia_columns;
34}; 34};
35 35
36#define STATIC_INI_ARRAY(array) { \
37 .ia_array = (u32 *)(array), \
38 .ia_rows = ARRAY_SIZE(array), \
39 .ia_columns = ARRAY_SIZE(array[0]), \
40 }
41
36#define INIT_INI_ARRAY(iniarray, array) do { \ 42#define INIT_INI_ARRAY(iniarray, array) do { \
37 (iniarray)->ia_array = (u32 *)(array); \ 43 (iniarray)->ia_array = (u32 *)(array); \
38 (iniarray)->ia_rows = ARRAY_SIZE(array); \ 44 (iniarray)->ia_rows = ARRAY_SIZE(array); \
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index 905f1b313961..344fdde1d7a3 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -27,20 +27,6 @@ MODULE_AUTHOR("Atheros Communications");
27MODULE_DESCRIPTION("Shared library for Atheros wireless 802.11n LAN cards."); 27MODULE_DESCRIPTION("Shared library for Atheros wireless 802.11n LAN cards.");
28MODULE_LICENSE("Dual BSD/GPL"); 28MODULE_LICENSE("Dual BSD/GPL");
29 29
30int ath9k_cmn_padpos(__le16 frame_control)
31{
32 int padpos = 24;
33 if (ieee80211_has_a4(frame_control)) {
34 padpos += ETH_ALEN;
35 }
36 if (ieee80211_is_data_qos(frame_control)) {
37 padpos += IEEE80211_QOS_CTL_LEN;
38 }
39
40 return padpos;
41}
42EXPORT_SYMBOL(ath9k_cmn_padpos);
43
44int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb) 30int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
45{ 31{
46 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 32 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -133,13 +119,14 @@ EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
133struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, 119struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
134 struct ath_hw *ah) 120 struct ath_hw *ah)
135{ 121{
136 struct ieee80211_channel *curchan = hw->conf.channel; 122 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
137 struct ath9k_channel *channel; 123 struct ath9k_channel *channel;
138 u8 chan_idx; 124 u8 chan_idx;
139 125
140 chan_idx = curchan->hw_value; 126 chan_idx = curchan->hw_value;
141 channel = &ah->channels[chan_idx]; 127 channel = &ah->channels[chan_idx];
142 ath9k_cmn_update_ichannel(channel, curchan, hw->conf.channel_type); 128 ath9k_cmn_update_ichannel(channel, curchan,
129 cfg80211_get_chandef_type(&hw->conf.chandef));
143 130
144 return channel; 131 return channel;
145} 132}
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 6102476a65de..207d06995b15 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -42,7 +42,6 @@
42#define ATH_EP_RND(x, mul) \ 42#define ATH_EP_RND(x, mul) \
43 (((x) + ((mul)/2)) / (mul)) 43 (((x) + ((mul)/2)) / (mul))
44 44
45int ath9k_cmn_padpos(__le16 frame_control);
46int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); 45int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
47void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, 46void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
48 struct ieee80211_channel *chan, 47 struct ieee80211_channel *chan,
diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c
index 508f8b33f0ef..7187d3671512 100644
--- a/drivers/net/wireless/ath/ath9k/dfs.c
+++ b/drivers/net/wireless/ath/ath9k/dfs.c
@@ -55,12 +55,6 @@ ath9k_postprocess_radar_event(struct ath_softc *sc,
55 u8 rssi; 55 u8 rssi;
56 u16 dur; 56 u16 dur;
57 57
58 ath_dbg(ath9k_hw_common(sc->sc_ah), DFS,
59 "pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n",
60 ard->pulse_bw_info,
61 ard->pulse_length_pri, ard->rssi,
62 ard->pulse_length_ext, ard->ext_rssi);
63
64 /* 58 /*
65 * Only the last 2 bits of the BW info are relevant, they indicate 59 * Only the last 2 bits of the BW info are relevant, they indicate
66 * which channel the radar was detected in. 60 * which channel the radar was detected in.
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
index 73fe8d6db566..491305c81fce 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
@@ -19,6 +19,7 @@
19 19
20#include "dfs_pattern_detector.h" 20#include "dfs_pattern_detector.h"
21#include "dfs_pri_detector.h" 21#include "dfs_pri_detector.h"
22#include "ath9k.h"
22 23
23/* 24/*
24 * tolerated deviation of radar time stamp in usecs on both sides 25 * tolerated deviation of radar time stamp in usecs on both sides
@@ -142,6 +143,7 @@ channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq)
142{ 143{
143 u32 sz, i; 144 u32 sz, i;
144 struct channel_detector *cd; 145 struct channel_detector *cd;
146 struct ath_common *common = ath9k_hw_common(dpd->ah);
145 147
146 cd = kmalloc(sizeof(*cd), GFP_ATOMIC); 148 cd = kmalloc(sizeof(*cd), GFP_ATOMIC);
147 if (cd == NULL) 149 if (cd == NULL)
@@ -165,7 +167,8 @@ channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq)
165 return cd; 167 return cd;
166 168
167fail: 169fail:
168 pr_err("failed to allocate channel_detector for freq=%d\n", freq); 170 ath_dbg(common, DFS,
171 "failed to allocate channel_detector for freq=%d\n", freq);
169 channel_detector_exit(dpd, cd); 172 channel_detector_exit(dpd, cd);
170 return NULL; 173 return NULL;
171} 174}
@@ -216,34 +219,34 @@ static bool
216dpd_add_pulse(struct dfs_pattern_detector *dpd, struct pulse_event *event) 219dpd_add_pulse(struct dfs_pattern_detector *dpd, struct pulse_event *event)
217{ 220{
218 u32 i; 221 u32 i;
219 bool ts_wraparound;
220 struct channel_detector *cd; 222 struct channel_detector *cd;
221 223
222 if (dpd->region == NL80211_DFS_UNSET) { 224 /*
223 /* 225 * pulses received for a non-supported or un-initialized
224 * pulses received for a non-supported or un-initialized 226 * domain are treated as detected radars for fail-safety
225 * domain are treated as detected radars 227 */
226 */ 228 if (dpd->region == NL80211_DFS_UNSET)
227 return true; 229 return true;
228 }
229 230
230 cd = channel_detector_get(dpd, event->freq); 231 cd = channel_detector_get(dpd, event->freq);
231 if (cd == NULL) 232 if (cd == NULL)
232 return false; 233 return false;
233 234
234 ts_wraparound = (event->ts < dpd->last_pulse_ts);
235 dpd->last_pulse_ts = event->ts; 235 dpd->last_pulse_ts = event->ts;
236 if (ts_wraparound) { 236 /* reset detector on time stamp wraparound, caused by TSF reset */
237 /* 237 if (event->ts < dpd->last_pulse_ts)
238 * reset detector on time stamp wraparound
239 * with monotonic time stamps, this should never happen
240 */
241 pr_warn("DFS: time stamp wraparound detected, resetting\n");
242 dpd_reset(dpd); 238 dpd_reset(dpd);
243 } 239
244 /* do type individual pattern matching */ 240 /* do type individual pattern matching */
245 for (i = 0; i < dpd->num_radar_types; i++) { 241 for (i = 0; i < dpd->num_radar_types; i++) {
246 if (cd->detectors[i]->add_pulse(cd->detectors[i], event) != 0) { 242 struct pri_detector *pd = cd->detectors[i];
243 struct pri_sequence *ps = pd->add_pulse(pd, event);
244 if (ps != NULL) {
245 ath_dbg(ath9k_hw_common(dpd->ah), DFS,
246 "DFS: radar found on freq=%d: id=%d, pri=%d, "
247 "count=%d, count_false=%d\n",
248 event->freq, pd->rs->type_id,
249 ps->pri, ps->count, ps->count_falses);
247 channel_detector_reset(dpd, cd); 250 channel_detector_reset(dpd, cd);
248 return true; 251 return true;
249 } 252 }
@@ -285,9 +288,10 @@ static struct dfs_pattern_detector default_dpd = {
285}; 288};
286 289
287struct dfs_pattern_detector * 290struct dfs_pattern_detector *
288dfs_pattern_detector_init(enum nl80211_dfs_regions region) 291dfs_pattern_detector_init(struct ath_hw *ah, enum nl80211_dfs_regions region)
289{ 292{
290 struct dfs_pattern_detector *dpd; 293 struct dfs_pattern_detector *dpd;
294 struct ath_common *common = ath9k_hw_common(ah);
291 295
292 dpd = kmalloc(sizeof(*dpd), GFP_KERNEL); 296 dpd = kmalloc(sizeof(*dpd), GFP_KERNEL);
293 if (dpd == NULL) 297 if (dpd == NULL)
@@ -296,10 +300,11 @@ dfs_pattern_detector_init(enum nl80211_dfs_regions region)
296 *dpd = default_dpd; 300 *dpd = default_dpd;
297 INIT_LIST_HEAD(&dpd->channel_detectors); 301 INIT_LIST_HEAD(&dpd->channel_detectors);
298 302
303 dpd->ah = ah;
299 if (dpd->set_dfs_domain(dpd, region)) 304 if (dpd->set_dfs_domain(dpd, region))
300 return dpd; 305 return dpd;
301 306
302 pr_err("Could not set DFS domain to %d. ", region); 307 ath_dbg(common, DFS,"Could not set DFS domain to %d", region);
303 kfree(dpd); 308 kfree(dpd);
304 return NULL; 309 return NULL;
305} 310}
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
index cda52f39f28a..90a5abcc4265 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
+++ b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
@@ -80,6 +80,8 @@ struct dfs_pattern_detector {
80 enum nl80211_dfs_regions region; 80 enum nl80211_dfs_regions region;
81 u8 num_radar_types; 81 u8 num_radar_types;
82 u64 last_pulse_ts; 82 u64 last_pulse_ts;
83 /* needed for ath_dbg() */
84 struct ath_hw *ah;
83 85
84 const struct radar_detector_specs *radar_spec; 86 const struct radar_detector_specs *radar_spec;
85 struct list_head channel_detectors; 87 struct list_head channel_detectors;
@@ -92,10 +94,10 @@ struct dfs_pattern_detector {
92 */ 94 */
93#if defined(CONFIG_ATH9K_DFS_CERTIFIED) 95#if defined(CONFIG_ATH9K_DFS_CERTIFIED)
94extern struct dfs_pattern_detector * 96extern struct dfs_pattern_detector *
95dfs_pattern_detector_init(enum nl80211_dfs_regions region); 97dfs_pattern_detector_init(struct ath_hw *ah, enum nl80211_dfs_regions region);
96#else 98#else
97static inline struct dfs_pattern_detector * 99static inline struct dfs_pattern_detector *
98dfs_pattern_detector_init(enum nl80211_dfs_regions region) 100dfs_pattern_detector_init(struct ath_hw *ah, enum nl80211_dfs_regions region)
99{ 101{
100 return NULL; 102 return NULL;
101} 103}
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
index 5e48c5515b8c..5ba4b6fe37c0 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
@@ -23,28 +23,6 @@
23#include "dfs_debug.h" 23#include "dfs_debug.h"
24 24
25/** 25/**
26 * struct pri_sequence - sequence of pulses matching one PRI
27 * @head: list_head
28 * @pri: pulse repetition interval (PRI) in usecs
29 * @dur: duration of sequence in usecs
30 * @count: number of pulses in this sequence
31 * @count_falses: number of not matching pulses in this sequence
32 * @first_ts: time stamp of first pulse in usecs
33 * @last_ts: time stamp of last pulse in usecs
34 * @deadline_ts: deadline when this sequence becomes invalid (first_ts + dur)
35 */
36struct pri_sequence {
37 struct list_head head;
38 u32 pri;
39 u32 dur;
40 u32 count;
41 u32 count_falses;
42 u64 first_ts;
43 u64 last_ts;
44 u64 deadline_ts;
45};
46
47/**
48 * struct pulse_elem - elements in pulse queue 26 * struct pulse_elem - elements in pulse queue
49 * @ts: time stamp in usecs 27 * @ts: time stamp in usecs
50 */ 28 */
@@ -393,8 +371,8 @@ static void pri_detector_exit(struct pri_detector *de)
393 kfree(de); 371 kfree(de);
394} 372}
395 373
396static bool pri_detector_add_pulse(struct pri_detector *de, 374static struct pri_sequence *pri_detector_add_pulse(struct pri_detector *de,
397 struct pulse_event *event) 375 struct pulse_event *event)
398{ 376{
399 u32 max_updated_seq; 377 u32 max_updated_seq;
400 struct pri_sequence *ps; 378 struct pri_sequence *ps;
@@ -403,38 +381,33 @@ static bool pri_detector_add_pulse(struct pri_detector *de,
403 381
404 /* ignore pulses not within width range */ 382 /* ignore pulses not within width range */
405 if ((rs->width_min > event->width) || (rs->width_max < event->width)) 383 if ((rs->width_min > event->width) || (rs->width_max < event->width))
406 return false; 384 return NULL;
407 385
408 if ((ts - de->last_ts) < rs->max_pri_tolerance) 386 if ((ts - de->last_ts) < rs->max_pri_tolerance)
409 /* if delta to last pulse is too short, don't use this pulse */ 387 /* if delta to last pulse is too short, don't use this pulse */
410 return false; 388 return NULL;
411 de->last_ts = ts; 389 de->last_ts = ts;
412 390
413 max_updated_seq = pseq_handler_add_to_existing_seqs(de, ts); 391 max_updated_seq = pseq_handler_add_to_existing_seqs(de, ts);
414 392
415 if (!pseq_handler_create_sequences(de, ts, max_updated_seq)) { 393 if (!pseq_handler_create_sequences(de, ts, max_updated_seq)) {
416 pr_err("failed to create pulse sequences\n");
417 pri_detector_reset(de, ts); 394 pri_detector_reset(de, ts);
418 return false; 395 return false;
419 } 396 }
420 397
421 ps = pseq_handler_check_detection(de); 398 ps = pseq_handler_check_detection(de);
422 399
423 if (ps != NULL) { 400 if (ps == NULL)
424 pr_info("DFS: radar found: pri=%d, count=%d, count_false=%d\n", 401 pulse_queue_enqueue(de, ts);
425 ps->pri, ps->count, ps->count_falses); 402
426 pri_detector_reset(de, ts); 403 return ps;
427 return true;
428 }
429 pulse_queue_enqueue(de, ts);
430 return false;
431} 404}
432 405
433struct pri_detector * 406struct pri_detector *pri_detector_init(const struct radar_detector_specs *rs)
434pri_detector_init(const struct radar_detector_specs *rs)
435{ 407{
436 struct pri_detector *de; 408 struct pri_detector *de;
437 de = kzalloc(sizeof(*de), GFP_KERNEL); 409
410 de = kzalloc(sizeof(*de), GFP_ATOMIC);
438 if (de == NULL) 411 if (de == NULL)
439 return NULL; 412 return NULL;
440 de->exit = pri_detector_exit; 413 de->exit = pri_detector_exit;
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h
index 81cde9f28e44..723962d1abc6 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h
+++ b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h
@@ -20,9 +20,31 @@
20#include <linux/list.h> 20#include <linux/list.h>
21 21
22/** 22/**
23 * struct pri_sequence - sequence of pulses matching one PRI
24 * @head: list_head
25 * @pri: pulse repetition interval (PRI) in usecs
26 * @dur: duration of sequence in usecs
27 * @count: number of pulses in this sequence
28 * @count_falses: number of not matching pulses in this sequence
29 * @first_ts: time stamp of first pulse in usecs
30 * @last_ts: time stamp of last pulse in usecs
31 * @deadline_ts: deadline when this sequence becomes invalid (first_ts + dur)
32 */
33struct pri_sequence {
34 struct list_head head;
35 u32 pri;
36 u32 dur;
37 u32 count;
38 u32 count_falses;
39 u64 first_ts;
40 u64 last_ts;
41 u64 deadline_ts;
42};
43
44/**
23 * struct pri_detector - PRI detector element for a dedicated radar type 45 * struct pri_detector - PRI detector element for a dedicated radar type
24 * @exit(): destructor 46 * @exit(): destructor
25 * @add_pulse(): add pulse event, returns true if pattern was detected 47 * @add_pulse(): add pulse event, returns pri_sequence if pattern was detected
26 * @reset(): clear states and reset to given time stamp 48 * @reset(): clear states and reset to given time stamp
27 * @rs: detector specs for this detector element 49 * @rs: detector specs for this detector element
28 * @last_ts: last pulse time stamp considered for this element in usecs 50 * @last_ts: last pulse time stamp considered for this element in usecs
@@ -34,7 +56,8 @@
34 */ 56 */
35struct pri_detector { 57struct pri_detector {
36 void (*exit) (struct pri_detector *de); 58 void (*exit) (struct pri_detector *de);
37 bool (*add_pulse)(struct pri_detector *de, struct pulse_event *e); 59 struct pri_sequence *
60 (*add_pulse)(struct pri_detector *de, struct pulse_event *e);
38 void (*reset) (struct pri_detector *de, u64 ts); 61 void (*reset) (struct pri_detector *de, u64 ts);
39 62
40/* private: internal use only */ 63/* private: internal use only */
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
index d0ce1f5bba10..f13f458dd656 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
@@ -308,7 +308,7 @@ static void ath9k_htc_send_buffered(struct ath9k_htc_priv *priv,
308 while(skb) { 308 while(skb) {
309 hdr = (struct ieee80211_hdr *) skb->data; 309 hdr = (struct ieee80211_hdr *) skb->data;
310 310
311 padpos = ath9k_cmn_padpos(hdr->frame_control); 311 padpos = ieee80211_hdrlen(hdr->frame_control);
312 padsize = padpos & 3; 312 padsize = padpos & 3;
313 if (padsize && skb->len > padpos) { 313 if (padsize && skb->len > padpos) {
314 if (skb_headroom(skb) < padsize) { 314 if (skb_headroom(skb) < padsize) {
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index a8016d70088a..0743a47cef8f 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -190,7 +190,7 @@ void ath9k_htc_reset(struct ath9k_htc_priv *priv)
190{ 190{
191 struct ath_hw *ah = priv->ah; 191 struct ath_hw *ah = priv->ah;
192 struct ath_common *common = ath9k_hw_common(ah); 192 struct ath_common *common = ath9k_hw_common(ah);
193 struct ieee80211_channel *channel = priv->hw->conf.channel; 193 struct ieee80211_channel *channel = priv->hw->conf.chandef.chan;
194 struct ath9k_hw_cal_data *caldata = NULL; 194 struct ath9k_hw_cal_data *caldata = NULL;
195 enum htc_phymode mode; 195 enum htc_phymode mode;
196 __be16 htc_mode; 196 __be16 htc_mode;
@@ -250,7 +250,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
250 struct ath_common *common = ath9k_hw_common(ah); 250 struct ath_common *common = ath9k_hw_common(ah);
251 struct ieee80211_conf *conf = &common->hw->conf; 251 struct ieee80211_conf *conf = &common->hw->conf;
252 bool fastcc; 252 bool fastcc;
253 struct ieee80211_channel *channel = hw->conf.channel; 253 struct ieee80211_channel *channel = hw->conf.chandef.chan;
254 struct ath9k_hw_cal_data *caldata = NULL; 254 struct ath9k_hw_cal_data *caldata = NULL;
255 enum htc_phymode mode; 255 enum htc_phymode mode;
256 __be16 htc_mode; 256 __be16 htc_mode;
@@ -602,7 +602,7 @@ static void ath9k_htc_setup_rate(struct ath9k_htc_priv *priv,
602 u32 caps = 0; 602 u32 caps = 0;
603 int i, j; 603 int i, j;
604 604
605 sband = priv->hw->wiphy->bands[priv->hw->conf.channel->band]; 605 sband = priv->hw->wiphy->bands[priv->hw->conf.chandef.chan->band];
606 606
607 for (i = 0, j = 0; i < sband->n_bitrates; i++) { 607 for (i = 0, j = 0; i < sband->n_bitrates; i++) {
608 if (sta->supp_rates[sband->band] & BIT(i)) { 608 if (sta->supp_rates[sband->band] & BIT(i)) {
@@ -866,7 +866,7 @@ static void ath9k_htc_tx(struct ieee80211_hw *hw,
866 hdr = (struct ieee80211_hdr *) skb->data; 866 hdr = (struct ieee80211_hdr *) skb->data;
867 867
868 /* Add the padding after the header if this is not already done */ 868 /* Add the padding after the header if this is not already done */
869 padpos = ath9k_cmn_padpos(hdr->frame_control); 869 padpos = ieee80211_hdrlen(hdr->frame_control);
870 padsize = padpos & 3; 870 padsize = padpos & 3;
871 if (padsize && skb->len > padpos) { 871 if (padsize && skb->len > padpos) {
872 if (skb_headroom(skb) < padsize) { 872 if (skb_headroom(skb) < padsize) {
@@ -904,7 +904,7 @@ static int ath9k_htc_start(struct ieee80211_hw *hw)
904 struct ath9k_htc_priv *priv = hw->priv; 904 struct ath9k_htc_priv *priv = hw->priv;
905 struct ath_hw *ah = priv->ah; 905 struct ath_hw *ah = priv->ah;
906 struct ath_common *common = ath9k_hw_common(ah); 906 struct ath_common *common = ath9k_hw_common(ah);
907 struct ieee80211_channel *curchan = hw->conf.channel; 907 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
908 struct ath9k_channel *init_channel; 908 struct ath9k_channel *init_channel;
909 int ret = 0; 909 int ret = 0;
910 enum htc_phymode mode; 910 enum htc_phymode mode;
@@ -1193,15 +1193,17 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
1193 } 1193 }
1194 1194
1195 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) { 1195 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) {
1196 struct ieee80211_channel *curchan = hw->conf.channel; 1196 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
1197 enum nl80211_channel_type channel_type =
1198 cfg80211_get_chandef_type(&hw->conf.chandef);
1197 int pos = curchan->hw_value; 1199 int pos = curchan->hw_value;
1198 1200
1199 ath_dbg(common, CONFIG, "Set channel: %d MHz\n", 1201 ath_dbg(common, CONFIG, "Set channel: %d MHz\n",
1200 curchan->center_freq); 1202 curchan->center_freq);
1201 1203
1202 ath9k_cmn_update_ichannel(&priv->ah->channels[pos], 1204 ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
1203 hw->conf.channel, 1205 hw->conf.chandef.chan,
1204 hw->conf.channel_type); 1206 channel_type);
1205 1207
1206 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { 1208 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
1207 ath_err(common, "Unable to set channel\n"); 1209 ath_err(common, "Unable to set channel\n");
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index bd8251c1c749..6bd0e92ea2aa 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -490,7 +490,7 @@ static void ath9k_htc_tx_process(struct ath9k_htc_priv *priv,
490 if (txs->ts_flags & ATH9K_HTC_TXSTAT_SGI) 490 if (txs->ts_flags & ATH9K_HTC_TXSTAT_SGI)
491 rate->flags |= IEEE80211_TX_RC_SHORT_GI; 491 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
492 } else { 492 } else {
493 if (cur_conf->channel->band == IEEE80211_BAND_5GHZ) 493 if (cur_conf->chandef.chan->band == IEEE80211_BAND_5GHZ)
494 rate->idx += 4; /* No CCK rates */ 494 rate->idx += 4; /* No CCK rates */
495 } 495 }
496 496
@@ -939,7 +939,7 @@ static void ath9k_process_rate(struct ieee80211_hw *hw,
939 return; 939 return;
940 } 940 }
941 941
942 band = hw->conf.channel->band; 942 band = hw->conf.chandef.chan->band;
943 sband = hw->wiphy->bands[band]; 943 sband = hw->wiphy->bands[band];
944 944
945 for (i = 0; i < sband->n_bitrates; i++) { 945 for (i = 0; i < sband->n_bitrates; i++) {
@@ -966,7 +966,7 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
966 struct sk_buff *skb = rxbuf->skb; 966 struct sk_buff *skb = rxbuf->skb;
967 struct ath_common *common = ath9k_hw_common(priv->ah); 967 struct ath_common *common = ath9k_hw_common(priv->ah);
968 struct ath_htc_rx_status *rxstatus; 968 struct ath_htc_rx_status *rxstatus;
969 int hdrlen, padpos, padsize; 969 int hdrlen, padsize;
970 int last_rssi = ATH_RSSI_DUMMY_MARKER; 970 int last_rssi = ATH_RSSI_DUMMY_MARKER;
971 __le16 fc; 971 __le16 fc;
972 972
@@ -996,11 +996,9 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
996 fc = hdr->frame_control; 996 fc = hdr->frame_control;
997 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 997 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
998 998
999 padpos = ath9k_cmn_padpos(fc); 999 padsize = hdrlen & 3;
1000 1000 if (padsize && skb->len >= hdrlen+padsize+FCS_LEN) {
1001 padsize = padpos & 3; 1001 memmove(skb->data + padsize, skb->data, hdrlen);
1002 if (padsize && skb->len >= padpos+padsize+FCS_LEN) {
1003 memmove(skb->data + padsize, skb->data, padpos);
1004 skb_pull(skb, padsize); 1002 skb_pull(skb, padsize);
1005 } 1003 }
1006 1004
@@ -1082,8 +1080,8 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
1082 } 1080 }
1083 1081
1084 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp); 1082 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
1085 rx_status->band = hw->conf.channel->band; 1083 rx_status->band = hw->conf.chandef.chan->band;
1086 rx_status->freq = hw->conf.channel->center_freq; 1084 rx_status->freq = hw->conf.chandef.chan->center_freq;
1087 rx_status->signal = rxbuf->rxstatus.rs_rssi + ATH_DEFAULT_NOISE_FLOOR; 1085 rx_status->signal = rxbuf->rxstatus.rs_rssi + ATH_DEFAULT_NOISE_FLOOR;
1088 rx_status->antenna = rxbuf->rxstatus.rs_antenna; 1086 rx_status->antenna = rxbuf->rxstatus.rs_antenna;
1089 rx_status->flag |= RX_FLAG_MACTIME_END; 1087 rx_status->flag |= RX_FLAG_MACTIME_END;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 3473a797651a..7f25da8444fe 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -139,7 +139,7 @@ static void ath9k_hw_set_clockrate(struct ath_hw *ah)
139 clockrate = 117; 139 clockrate = 117;
140 else if (!ah->curchan) /* should really check for CCK instead */ 140 else if (!ah->curchan) /* should really check for CCK instead */
141 clockrate = ATH9K_CLOCK_RATE_CCK; 141 clockrate = ATH9K_CLOCK_RATE_CCK;
142 else if (conf->channel->band == IEEE80211_BAND_2GHZ) 142 else if (conf->chandef.chan->band == IEEE80211_BAND_2GHZ)
143 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM; 143 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
144 else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK) 144 else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
145 clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM; 145 clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
@@ -1100,7 +1100,8 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah)
1100 } 1100 }
1101 1101
1102 /* As defined by IEEE 802.11-2007 17.3.8.6 */ 1102 /* As defined by IEEE 802.11-2007 17.3.8.6 */
1103 acktimeout = slottime + sifstime + 3 * ah->coverage_class + ack_offset; 1103 slottime += 3 * ah->coverage_class;
1104 acktimeout = slottime + sifstime + ack_offset;
1104 ctstimeout = acktimeout; 1105 ctstimeout = acktimeout;
1105 1106
1106 /* 1107 /*
@@ -1110,7 +1111,8 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah)
1110 * BA frames in some implementations, but it has been found to fix ACK 1111 * BA frames in some implementations, but it has been found to fix ACK
1111 * timeout issues in other cases as well. 1112 * timeout issues in other cases as well.
1112 */ 1113 */
1113 if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ && 1114 if (conf->chandef.chan &&
1115 conf->chandef.chan->band == IEEE80211_BAND_2GHZ &&
1114 !IS_CHAN_HALF_RATE(chan) && !IS_CHAN_QUARTER_RATE(chan)) { 1116 !IS_CHAN_HALF_RATE(chan) && !IS_CHAN_QUARTER_RATE(chan)) {
1115 acktimeout += 64 - sifstime - ah->slottime; 1117 acktimeout += 64 - sifstime - ah->slottime;
1116 ctstimeout += 48 - sifstime - ah->slottime; 1118 ctstimeout += 48 - sifstime - ah->slottime;
@@ -1697,12 +1699,11 @@ static void ath9k_hw_reset_opmode(struct ath_hw *ah,
1697 1699
1698 ENABLE_REGWRITE_BUFFER(ah); 1700 ENABLE_REGWRITE_BUFFER(ah);
1699 1701
1700 REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr)); 1702 REG_RMW(ah, AR_STA_ID1, macStaId1
1701 REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4)
1702 | macStaId1
1703 | AR_STA_ID1_RTS_USE_DEF 1703 | AR_STA_ID1_RTS_USE_DEF
1704 | (ah->config.ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0) 1704 | (ah->config.ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0)
1705 | ah->sta_id1_defaults); 1705 | ah->sta_id1_defaults,
1706 ~AR_STA_ID1_SADH_MASK);
1706 ath_hw_setbssidmask(common); 1707 ath_hw_setbssidmask(common);
1707 REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna); 1708 REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna);
1708 ath9k_hw_write_associd(ah); 1709 ath9k_hw_write_associd(ah);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 30e62d92d46d..ae3034374bc4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -847,14 +847,7 @@ struct ath_hw {
847 struct ath_hw_ops ops; 847 struct ath_hw_ops ops;
848 848
849 /* Used to program the radio on non single-chip devices */ 849 /* Used to program the radio on non single-chip devices */
850 u32 *analogBank0Data;
851 u32 *analogBank1Data;
852 u32 *analogBank2Data;
853 u32 *analogBank3Data;
854 u32 *analogBank6Data; 850 u32 *analogBank6Data;
855 u32 *analogBank6TPCData;
856 u32 *analogBank7Data;
857 u32 *bank6Temp;
858 851
859 int coverage_class; 852 int coverage_class;
860 u32 slottime; 853 u32 slottime;
@@ -885,14 +878,8 @@ struct ath_hw {
885 878
886 struct ar5416IniArray iniModes; 879 struct ar5416IniArray iniModes;
887 struct ar5416IniArray iniCommon; 880 struct ar5416IniArray iniCommon;
888 struct ar5416IniArray iniBank0;
889 struct ar5416IniArray iniBB_RfGain; 881 struct ar5416IniArray iniBB_RfGain;
890 struct ar5416IniArray iniBank1;
891 struct ar5416IniArray iniBank2;
892 struct ar5416IniArray iniBank3;
893 struct ar5416IniArray iniBank6; 882 struct ar5416IniArray iniBank6;
894 struct ar5416IniArray iniBank6TPC;
895 struct ar5416IniArray iniBank7;
896 struct ar5416IniArray iniAddac; 883 struct ar5416IniArray iniAddac;
897 struct ar5416IniArray iniPcieSerdes; 884 struct ar5416IniArray iniPcieSerdes;
898#ifdef CONFIG_PM_SLEEP 885#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 3be2eb0da84a..0237b2868961 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -577,7 +577,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
577 atomic_set(&ah->intr_ref_cnt, -1); 577 atomic_set(&ah->intr_ref_cnt, -1);
578 sc->sc_ah = ah; 578 sc->sc_ah = ah;
579 579
580 sc->dfs_detector = dfs_pattern_detector_init(NL80211_DFS_UNSET); 580 sc->dfs_detector = dfs_pattern_detector_init(ah, NL80211_DFS_UNSET);
581 581
582 if (!pdata) { 582 if (!pdata) {
583 ah->ah_flags |= AH_USE_EEPROM; 583 ah->ah_flags |= AH_USE_EEPROM;
@@ -766,7 +766,8 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
766 IEEE80211_HW_SUPPORTS_PS | 766 IEEE80211_HW_SUPPORTS_PS |
767 IEEE80211_HW_PS_NULLFUNC_STACK | 767 IEEE80211_HW_PS_NULLFUNC_STACK |
768 IEEE80211_HW_SPECTRUM_MGMT | 768 IEEE80211_HW_SPECTRUM_MGMT |
769 IEEE80211_HW_REPORTS_TX_ACK_STATUS; 769 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
770 IEEE80211_HW_SUPPORTS_RC_TABLE;
770 771
771 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) 772 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
772 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION; 773 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c
index 7fdac6c7b3ea..849259b07370 100644
--- a/drivers/net/wireless/ath/ath9k/link.c
+++ b/drivers/net/wireless/ath/ath9k/link.c
@@ -214,7 +214,7 @@ static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int
214 txctl.txq = sc->tx.txq_map[IEEE80211_AC_BE]; 214 txctl.txq = sc->tx.txq_map[IEEE80211_AC_BE];
215 215
216 memset(tx_info, 0, sizeof(*tx_info)); 216 memset(tx_info, 0, sizeof(*tx_info));
217 tx_info->band = hw->conf.channel->band; 217 tx_info->band = hw->conf.chandef.chan->band;
218 tx_info->flags |= IEEE80211_TX_CTL_NO_ACK; 218 tx_info->flags |= IEEE80211_TX_CTL_NO_ACK;
219 tx_info->control.rates[0].idx = 0; 219 tx_info->control.rates[0].idx = 0;
220 tx_info->control.rates[0].count = 1; 220 tx_info->control.rates[0].count = 1;
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 811007ec07a7..498fee04afa0 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -615,6 +615,14 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
615 rs->rs_status |= ATH9K_RXERR_DECRYPT; 615 rs->rs_status |= ATH9K_RXERR_DECRYPT;
616 else if (ads.ds_rxstatus8 & AR_MichaelErr) 616 else if (ads.ds_rxstatus8 & AR_MichaelErr)
617 rs->rs_status |= ATH9K_RXERR_MIC; 617 rs->rs_status |= ATH9K_RXERR_MIC;
618 } else {
619 if (ads.ds_rxstatus8 &
620 (AR_CRCErr | AR_PHYErr | AR_DecryptCRCErr | AR_MichaelErr))
621 rs->rs_status |= ATH9K_RXERR_CORRUPT_DESC;
622
623 /* Only up to MCS16 supported, everything above is invalid */
624 if (rs->rs_rate >= 0x90)
625 rs->rs_status |= ATH9K_RXERR_CORRUPT_DESC;
618 } 626 }
619 627
620 if (ads.ds_rxstatus8 & AR_KeyMiss) 628 if (ads.ds_rxstatus8 & AR_KeyMiss)
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index 1ff817061ebc..5865f92998e1 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -183,6 +183,7 @@ struct ath_htc_rx_status {
183#define ATH9K_RXERR_DECRYPT 0x08 183#define ATH9K_RXERR_DECRYPT 0x08
184#define ATH9K_RXERR_MIC 0x10 184#define ATH9K_RXERR_MIC 0x10
185#define ATH9K_RXERR_KEYMISS 0x20 185#define ATH9K_RXERR_KEYMISS 0x20
186#define ATH9K_RXERR_CORRUPT_DESC 0x40
186 187
187#define ATH9K_RX_MORE 0x01 188#define ATH9K_RX_MORE 0x01
188#define ATH9K_RX_MORE_AGGR 0x02 189#define ATH9K_RX_MORE_AGGR 0x02
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 1bf52c88004a..6963862a1872 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -589,7 +589,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
589 struct ath_softc *sc = hw->priv; 589 struct ath_softc *sc = hw->priv;
590 struct ath_hw *ah = sc->sc_ah; 590 struct ath_hw *ah = sc->sc_ah;
591 struct ath_common *common = ath9k_hw_common(ah); 591 struct ath_common *common = ath9k_hw_common(ah);
592 struct ieee80211_channel *curchan = hw->conf.channel; 592 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
593 struct ath9k_channel *init_channel; 593 struct ath9k_channel *init_channel;
594 int r; 594 int r;
595 595
@@ -839,10 +839,14 @@ static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
839 struct ath9k_vif_iter_data *iter_data = data; 839 struct ath9k_vif_iter_data *iter_data = data;
840 int i; 840 int i;
841 841
842 if (iter_data->hw_macaddr) 842 if (iter_data->has_hw_macaddr) {
843 for (i = 0; i < ETH_ALEN; i++) 843 for (i = 0; i < ETH_ALEN; i++)
844 iter_data->mask[i] &= 844 iter_data->mask[i] &=
845 ~(iter_data->hw_macaddr[i] ^ mac[i]); 845 ~(iter_data->hw_macaddr[i] ^ mac[i]);
846 } else {
847 memcpy(iter_data->hw_macaddr, mac, ETH_ALEN);
848 iter_data->has_hw_macaddr = true;
849 }
846 850
847 switch (vif->type) { 851 switch (vif->type) {
848 case NL80211_IFTYPE_AP: 852 case NL80211_IFTYPE_AP:
@@ -891,7 +895,6 @@ void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
891 * together with the BSSID mask when matching addresses. 895 * together with the BSSID mask when matching addresses.
892 */ 896 */
893 memset(iter_data, 0, sizeof(*iter_data)); 897 memset(iter_data, 0, sizeof(*iter_data));
894 iter_data->hw_macaddr = common->macaddr;
895 memset(&iter_data->mask, 0xff, ETH_ALEN); 898 memset(&iter_data->mask, 0xff, ETH_ALEN);
896 899
897 if (vif) 900 if (vif)
@@ -901,6 +904,8 @@ void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
901 ieee80211_iterate_active_interfaces_atomic( 904 ieee80211_iterate_active_interfaces_atomic(
902 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL, 905 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
903 ath9k_vif_iter, iter_data); 906 ath9k_vif_iter, iter_data);
907
908 memcpy(common->macaddr, iter_data->hw_macaddr, ETH_ALEN);
904} 909}
905 910
906/* Called with sc->mutex held. */ 911/* Called with sc->mutex held. */
@@ -1188,7 +1193,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1188 } 1193 }
1189 1194
1190 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) { 1195 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
1191 struct ieee80211_channel *curchan = hw->conf.channel; 1196 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
1197 enum nl80211_channel_type channel_type =
1198 cfg80211_get_chandef_type(&conf->chandef);
1192 int pos = curchan->hw_value; 1199 int pos = curchan->hw_value;
1193 int old_pos = -1; 1200 int old_pos = -1;
1194 unsigned long flags; 1201 unsigned long flags;
@@ -1197,7 +1204,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1197 old_pos = ah->curchan - &ah->channels[0]; 1204 old_pos = ah->curchan - &ah->channels[0];
1198 1205
1199 ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n", 1206 ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n",
1200 curchan->center_freq, conf->channel_type); 1207 curchan->center_freq, channel_type);
1201 1208
1202 /* update survey stats for the old channel before switching */ 1209 /* update survey stats for the old channel before switching */
1203 spin_lock_irqsave(&common->cc_lock, flags); 1210 spin_lock_irqsave(&common->cc_lock, flags);
@@ -1212,7 +1219,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1212 ath9k_hw_getnf(ah, ah->curchan); 1219 ath9k_hw_getnf(ah, ah->curchan);
1213 1220
1214 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos], 1221 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
1215 curchan, conf->channel_type); 1222 curchan, channel_type);
1216 1223
1217 /* 1224 /*
1218 * If the operating channel changes, change the survey in-use flags 1225 * If the operating channel changes, change the survey in-use flags
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 96ac433ba7f6..aa4d368d8d3d 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -814,7 +814,7 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
814 * So, set fourth rate in series to be same as third one for 814 * So, set fourth rate in series to be same as third one for
815 * above conditions. 815 * above conditions.
816 */ 816 */
817 if ((sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ) && 817 if ((sc->hw->conf.chandef.chan->band == IEEE80211_BAND_2GHZ) &&
818 (conf_is_ht(&sc->hw->conf))) { 818 (conf_is_ht(&sc->hw->conf))) {
819 u8 dot11rate = rate_table->info[rix].dot11rate; 819 u8 dot11rate = rate_table->info[rix].dot11rate;
820 u8 phy = rate_table->info[rix].phy; 820 u8 phy = rate_table->info[rix].phy;
@@ -1328,7 +1328,7 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1328 1328
1329 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, 1329 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG,
1330 "Operating HT Bandwidth changed to: %d\n", 1330 "Operating HT Bandwidth changed to: %d\n",
1331 sc->hw->conf.channel_type); 1331 cfg80211_get_chandef_type(&sc->hw->conf.chandef));
1332 } 1332 }
1333} 1333}
1334 1334
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index ee7ca5aecdb0..8be2b5d8c155 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -124,13 +124,13 @@ static bool ath_rx_edma_buf_link(struct ath_softc *sc,
124 124
125 SKB_CB_ATHBUF(skb) = bf; 125 SKB_CB_ATHBUF(skb) = bf;
126 ath9k_hw_addrxbuf_edma(ah, bf->bf_buf_addr, qtype); 126 ath9k_hw_addrxbuf_edma(ah, bf->bf_buf_addr, qtype);
127 skb_queue_tail(&rx_edma->rx_fifo, skb); 127 __skb_queue_tail(&rx_edma->rx_fifo, skb);
128 128
129 return true; 129 return true;
130} 130}
131 131
132static void ath_rx_addbuffer_edma(struct ath_softc *sc, 132static void ath_rx_addbuffer_edma(struct ath_softc *sc,
133 enum ath9k_rx_qtype qtype, int size) 133 enum ath9k_rx_qtype qtype)
134{ 134{
135 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 135 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
136 struct ath_buf *bf, *tbf; 136 struct ath_buf *bf, *tbf;
@@ -155,7 +155,7 @@ static void ath_rx_remove_buffer(struct ath_softc *sc,
155 155
156 rx_edma = &sc->rx.rx_edma[qtype]; 156 rx_edma = &sc->rx.rx_edma[qtype];
157 157
158 while ((skb = skb_dequeue(&rx_edma->rx_fifo)) != NULL) { 158 while ((skb = __skb_dequeue(&rx_edma->rx_fifo)) != NULL) {
159 bf = SKB_CB_ATHBUF(skb); 159 bf = SKB_CB_ATHBUF(skb);
160 BUG_ON(!bf); 160 BUG_ON(!bf);
161 list_add_tail(&bf->list, &sc->rx.rxbuf); 161 list_add_tail(&bf->list, &sc->rx.rxbuf);
@@ -250,15 +250,9 @@ rx_init_fail:
250static void ath_edma_start_recv(struct ath_softc *sc) 250static void ath_edma_start_recv(struct ath_softc *sc)
251{ 251{
252 ath9k_hw_rxena(sc->sc_ah); 252 ath9k_hw_rxena(sc->sc_ah);
253 253 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP);
254 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP, 254 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_LP);
255 sc->rx.rx_edma[ATH9K_RX_QUEUE_HP].rx_fifo_hwsize);
256
257 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_LP,
258 sc->rx.rx_edma[ATH9K_RX_QUEUE_LP].rx_fifo_hwsize);
259
260 ath_opmode_init(sc); 255 ath_opmode_init(sc);
261
262 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)); 256 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
263} 257}
264 258
@@ -280,49 +274,47 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
280 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 + 274 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
281 sc->sc_ah->caps.rx_status_len; 275 sc->sc_ah->caps.rx_status_len;
282 276
283 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 277 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
284 return ath_rx_edma_init(sc, nbufs); 278 return ath_rx_edma_init(sc, nbufs);
285 } else {
286 ath_dbg(common, CONFIG, "cachelsz %u rxbufsize %u\n",
287 common->cachelsz, common->rx_bufsize);
288 279
289 /* Initialize rx descriptors */ 280 ath_dbg(common, CONFIG, "cachelsz %u rxbufsize %u\n",
281 common->cachelsz, common->rx_bufsize);
290 282
291 error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf, 283 /* Initialize rx descriptors */
292 "rx", nbufs, 1, 0); 284
293 if (error != 0) { 285 error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf,
294 ath_err(common, 286 "rx", nbufs, 1, 0);
295 "failed to allocate rx descriptors: %d\n", 287 if (error != 0) {
296 error); 288 ath_err(common,
289 "failed to allocate rx descriptors: %d\n",
290 error);
291 goto err;
292 }
293
294 list_for_each_entry(bf, &sc->rx.rxbuf, list) {
295 skb = ath_rxbuf_alloc(common, common->rx_bufsize,
296 GFP_KERNEL);
297 if (skb == NULL) {
298 error = -ENOMEM;
297 goto err; 299 goto err;
298 } 300 }
299 301
300 list_for_each_entry(bf, &sc->rx.rxbuf, list) { 302 bf->bf_mpdu = skb;
301 skb = ath_rxbuf_alloc(common, common->rx_bufsize, 303 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
302 GFP_KERNEL); 304 common->rx_bufsize,
303 if (skb == NULL) { 305 DMA_FROM_DEVICE);
304 error = -ENOMEM; 306 if (unlikely(dma_mapping_error(sc->dev,
305 goto err; 307 bf->bf_buf_addr))) {
306 } 308 dev_kfree_skb_any(skb);
307 309 bf->bf_mpdu = NULL;
308 bf->bf_mpdu = skb; 310 bf->bf_buf_addr = 0;
309 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, 311 ath_err(common,
310 common->rx_bufsize, 312 "dma_mapping_error() on RX init\n");
311 DMA_FROM_DEVICE); 313 error = -ENOMEM;
312 if (unlikely(dma_mapping_error(sc->dev, 314 goto err;
313 bf->bf_buf_addr))) {
314 dev_kfree_skb_any(skb);
315 bf->bf_mpdu = NULL;
316 bf->bf_buf_addr = 0;
317 ath_err(common,
318 "dma_mapping_error() on RX init\n");
319 error = -ENOMEM;
320 goto err;
321 }
322 } 315 }
323 sc->rx.rxlink = NULL;
324 } 316 }
325 317 sc->rx.rxlink = NULL;
326err: 318err:
327 if (error) 319 if (error)
328 ath_rx_cleanup(sc); 320 ath_rx_cleanup(sc);
@@ -340,17 +332,17 @@ void ath_rx_cleanup(struct ath_softc *sc)
340 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 332 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
341 ath_rx_edma_cleanup(sc); 333 ath_rx_edma_cleanup(sc);
342 return; 334 return;
343 } else { 335 }
344 list_for_each_entry(bf, &sc->rx.rxbuf, list) { 336
345 skb = bf->bf_mpdu; 337 list_for_each_entry(bf, &sc->rx.rxbuf, list) {
346 if (skb) { 338 skb = bf->bf_mpdu;
347 dma_unmap_single(sc->dev, bf->bf_buf_addr, 339 if (skb) {
348 common->rx_bufsize, 340 dma_unmap_single(sc->dev, bf->bf_buf_addr,
349 DMA_FROM_DEVICE); 341 common->rx_bufsize,
350 dev_kfree_skb(skb); 342 DMA_FROM_DEVICE);
351 bf->bf_buf_addr = 0; 343 dev_kfree_skb(skb);
352 bf->bf_mpdu = NULL; 344 bf->bf_buf_addr = 0;
353 } 345 bf->bf_mpdu = NULL;
354 } 346 }
355 } 347 }
356} 348}
@@ -727,6 +719,13 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
727 ret = ath9k_hw_rxprocdesc(ah, tds, &trs); 719 ret = ath9k_hw_rxprocdesc(ah, tds, &trs);
728 if (ret == -EINPROGRESS) 720 if (ret == -EINPROGRESS)
729 return NULL; 721 return NULL;
722
723 /*
724 * mark descriptor as zero-length and set the 'more'
725 * flag to ensure that both buffers get discarded
726 */
727 rs->rs_datalen = 0;
728 rs->rs_more = true;
730 } 729 }
731 730
732 list_del(&bf->list); 731 list_del(&bf->list);
@@ -863,7 +862,7 @@ static int ath9k_process_rate(struct ath_common *common,
863 unsigned int i = 0; 862 unsigned int i = 0;
864 struct ath_softc __maybe_unused *sc = common->priv; 863 struct ath_softc __maybe_unused *sc = common->priv;
865 864
866 band = hw->conf.channel->band; 865 band = hw->conf.chandef.chan->band;
867 sband = hw->wiphy->bands[band]; 866 sband = hw->wiphy->bands[band];
868 867
869 if (rx_stats->rs_rate & 0x80) { 868 if (rx_stats->rs_rate & 0x80) {
@@ -933,14 +932,20 @@ static void ath9k_process_rssi(struct ath_common *common,
933 * up the frame up to let mac80211 handle the actual error case, be it no 932 * up the frame up to let mac80211 handle the actual error case, be it no
934 * decryption key or real decryption error. This let us keep statistics there. 933 * decryption key or real decryption error. This let us keep statistics there.
935 */ 934 */
936static int ath9k_rx_skb_preprocess(struct ath_common *common, 935static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
937 struct ieee80211_hw *hw,
938 struct ieee80211_hdr *hdr, 936 struct ieee80211_hdr *hdr,
939 struct ath_rx_status *rx_stats, 937 struct ath_rx_status *rx_stats,
940 struct ieee80211_rx_status *rx_status, 938 struct ieee80211_rx_status *rx_status,
941 bool *decrypt_error) 939 bool *decrypt_error)
942{ 940{
943 struct ath_hw *ah = common->ah; 941 struct ieee80211_hw *hw = sc->hw;
942 struct ath_hw *ah = sc->sc_ah;
943 struct ath_common *common = ath9k_hw_common(ah);
944 bool discard_current = sc->rx.discard_next;
945
946 sc->rx.discard_next = rx_stats->rs_more;
947 if (discard_current)
948 return -EINVAL;
944 949
945 /* 950 /*
946 * everything but the rate is checked here, the rate check is done 951 * everything but the rate is checked here, the rate check is done
@@ -958,14 +963,15 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common,
958 if (ath9k_process_rate(common, hw, rx_stats, rx_status)) 963 if (ath9k_process_rate(common, hw, rx_stats, rx_status))
959 return -EINVAL; 964 return -EINVAL;
960 965
961 rx_status->band = hw->conf.channel->band; 966 rx_status->band = hw->conf.chandef.chan->band;
962 rx_status->freq = hw->conf.channel->center_freq; 967 rx_status->freq = hw->conf.chandef.chan->center_freq;
963 rx_status->signal = ah->noise + rx_stats->rs_rssi; 968 rx_status->signal = ah->noise + rx_stats->rs_rssi;
964 rx_status->antenna = rx_stats->rs_antenna; 969 rx_status->antenna = rx_stats->rs_antenna;
965 rx_status->flag |= RX_FLAG_MACTIME_END; 970 rx_status->flag |= RX_FLAG_MACTIME_END;
966 if (rx_stats->rs_moreaggr) 971 if (rx_stats->rs_moreaggr)
967 rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL; 972 rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
968 973
974 sc->rx.discard_next = false;
969 return 0; 975 return 0;
970} 976}
971 977
@@ -985,7 +991,7 @@ static void ath9k_rx_skb_postprocess(struct ath_common *common,
985 hdr = (struct ieee80211_hdr *) skb->data; 991 hdr = (struct ieee80211_hdr *) skb->data;
986 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 992 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
987 fc = hdr->frame_control; 993 fc = hdr->frame_control;
988 padpos = ath9k_cmn_padpos(hdr->frame_control); 994 padpos = ieee80211_hdrlen(fc);
989 995
990 /* The MAC header is padded to have 32-bit boundary if the 996 /* The MAC header is padded to have 32-bit boundary if the
991 * packet payload is non-zero. The general calculation for 997 * packet payload is non-zero. The general calculation for
@@ -1166,6 +1172,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1166 u64 tsf = 0; 1172 u64 tsf = 0;
1167 u32 tsf_lower = 0; 1173 u32 tsf_lower = 0;
1168 unsigned long flags; 1174 unsigned long flags;
1175 dma_addr_t new_buf_addr;
1169 1176
1170 if (edma) 1177 if (edma)
1171 dma_type = DMA_BIDIRECTIONAL; 1178 dma_type = DMA_BIDIRECTIONAL;
@@ -1242,8 +1249,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1242 } 1249 }
1243 } 1250 }
1244 1251
1245 retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs, 1252 retval = ath9k_rx_skb_preprocess(sc, hdr, &rs, rxs,
1246 rxs, &decrypt_error); 1253 &decrypt_error);
1247 if (retval) 1254 if (retval)
1248 goto requeue_drop_frag; 1255 goto requeue_drop_frag;
1249 1256
@@ -1264,10 +1271,20 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1264 goto requeue_drop_frag; 1271 goto requeue_drop_frag;
1265 } 1272 }
1266 1273
1274 /* We will now give hardware our shiny new allocated skb */
1275 new_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
1276 common->rx_bufsize, dma_type);
1277 if (unlikely(dma_mapping_error(sc->dev, new_buf_addr))) {
1278 dev_kfree_skb_any(requeue_skb);
1279 goto requeue_drop_frag;
1280 }
1281
1267 /* Unmap the frame */ 1282 /* Unmap the frame */
1268 dma_unmap_single(sc->dev, bf->bf_buf_addr, 1283 dma_unmap_single(sc->dev, bf->bf_buf_addr,
1269 common->rx_bufsize, 1284 common->rx_bufsize, dma_type);
1270 dma_type); 1285
1286 bf->bf_mpdu = requeue_skb;
1287 bf->bf_buf_addr = new_buf_addr;
1271 1288
1272 skb_put(skb, rs.rs_datalen + ah->caps.rx_status_len); 1289 skb_put(skb, rs.rs_datalen + ah->caps.rx_status_len);
1273 if (ah->caps.rx_status_len) 1290 if (ah->caps.rx_status_len)
@@ -1277,21 +1294,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1277 ath9k_rx_skb_postprocess(common, hdr_skb, &rs, 1294 ath9k_rx_skb_postprocess(common, hdr_skb, &rs,
1278 rxs, decrypt_error); 1295 rxs, decrypt_error);
1279 1296
1280 /* We will now give hardware our shiny new allocated skb */
1281 bf->bf_mpdu = requeue_skb;
1282 bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
1283 common->rx_bufsize,
1284 dma_type);
1285 if (unlikely(dma_mapping_error(sc->dev,
1286 bf->bf_buf_addr))) {
1287 dev_kfree_skb_any(requeue_skb);
1288 bf->bf_mpdu = NULL;
1289 bf->bf_buf_addr = 0;
1290 ath_err(common, "dma_mapping_error() on RX\n");
1291 ieee80211_rx(hw, skb);
1292 break;
1293 }
1294
1295 if (rs.rs_more) { 1297 if (rs.rs_more) {
1296 RX_STAT_INC(rx_frags); 1298 RX_STAT_INC(rx_frags);
1297 /* 1299 /*
@@ -1309,6 +1311,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1309 sc->rx.frag = skb; 1311 sc->rx.frag = skb;
1310 goto requeue; 1312 goto requeue;
1311 } 1313 }
1314 if (rs.rs_status & ATH9K_RXERR_CORRUPT_DESC)
1315 goto requeue_drop_frag;
1312 1316
1313 if (sc->rx.frag) { 1317 if (sc->rx.frag) {
1314 int space = skb->len - skb_tailroom(hdr_skb); 1318 int space = skb->len - skb_tailroom(hdr_skb);
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 5929850649f0..5c4ab5026dca 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -1493,9 +1493,6 @@ enum {
1493#define AR9271_RADIO_RF_RST 0x20 1493#define AR9271_RADIO_RF_RST 0x20
1494#define AR9271_GATE_MAC_CTL 0x4000 1494#define AR9271_GATE_MAC_CTL 0x4000
1495 1495
1496#define AR_STA_ID0 0x8000
1497#define AR_STA_ID1 0x8004
1498#define AR_STA_ID1_SADH_MASK 0x0000FFFF
1499#define AR_STA_ID1_STA_AP 0x00010000 1496#define AR_STA_ID1_STA_AP 0x00010000
1500#define AR_STA_ID1_ADHOC 0x00020000 1497#define AR_STA_ID1_ADHOC 0x00020000
1501#define AR_STA_ID1_PWR_SAV 0x00040000 1498#define AR_STA_ID1_PWR_SAV 0x00040000
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 89a64411b82e..eab0fcb7ded6 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -157,6 +157,13 @@ static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
157 seqno << IEEE80211_SEQ_SEQ_SHIFT); 157 seqno << IEEE80211_SEQ_SEQ_SHIFT);
158} 158}
159 159
160static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
161 struct ath_buf *bf)
162{
163 ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
164 ARRAY_SIZE(bf->rates));
165}
166
160static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) 167static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
161{ 168{
162 struct ath_txq *txq = tid->ac->txq; 169 struct ath_txq *txq = tid->ac->txq;
@@ -189,6 +196,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
189 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); 196 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
190 sendbar = true; 197 sendbar = true;
191 } else { 198 } else {
199 ath_set_rates(tid->an->vif, tid->an->sta, bf);
192 ath_tx_send_normal(sc, txq, NULL, skb); 200 ath_tx_send_normal(sc, txq, NULL, skb);
193 } 201 }
194 } 202 }
@@ -407,7 +415,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
407 415
408 tx_info = IEEE80211_SKB_CB(skb); 416 tx_info = IEEE80211_SKB_CB(skb);
409 417
410 memcpy(rates, tx_info->control.rates, sizeof(rates)); 418 memcpy(rates, bf->rates, sizeof(rates));
411 419
412 retries = ts->ts_longretry + 1; 420 retries = ts->ts_longretry + 1;
413 for (i = 0; i < ts->ts_rateindex; i++) 421 for (i = 0; i < ts->ts_rateindex; i++)
@@ -516,8 +524,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
516 * not a holding desc. 524 * not a holding desc.
517 */ 525 */
518 INIT_LIST_HEAD(&bf_head); 526 INIT_LIST_HEAD(&bf_head);
519 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) || 527 if (bf_next != NULL || !bf_last->bf_stale)
520 bf_next != NULL || !bf_last->bf_stale)
521 list_move_tail(&bf->list, &bf_head); 528 list_move_tail(&bf->list, &bf_head);
522 529
523 if (!txpending || (tid->state & AGGR_CLEANUP)) { 530 if (!txpending || (tid->state & AGGR_CLEANUP)) {
@@ -537,8 +544,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
537 !txfail); 544 !txfail);
538 } else { 545 } else {
539 /* retry the un-acked ones */ 546 /* retry the un-acked ones */
540 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) && 547 if (bf->bf_next == NULL && bf_last->bf_stale) {
541 bf->bf_next == NULL && bf_last->bf_stale) {
542 struct ath_buf *tbf; 548 struct ath_buf *tbf;
543 549
544 tbf = ath_clone_txbuf(sc, bf_last); 550 tbf = ath_clone_txbuf(sc, bf_last);
@@ -738,8 +744,6 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
738 bool first_subfrm) 744 bool first_subfrm)
739{ 745{
740#define FIRST_DESC_NDELIMS 60 746#define FIRST_DESC_NDELIMS 60
741 struct sk_buff *skb = bf->bf_mpdu;
742 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
743 u32 nsymbits, nsymbols; 747 u32 nsymbits, nsymbols;
744 u16 minlen; 748 u16 minlen;
745 u8 flags, rix; 749 u8 flags, rix;
@@ -780,8 +784,8 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
780 if (tid->an->mpdudensity == 0) 784 if (tid->an->mpdudensity == 0)
781 return ndelim; 785 return ndelim;
782 786
783 rix = tx_info->control.rates[0].idx; 787 rix = bf->rates[0].idx;
784 flags = tx_info->control.rates[0].flags; 788 flags = bf->rates[0].flags;
785 width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0; 789 width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0;
786 half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0; 790 half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0;
787 791
@@ -860,6 +864,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
860 bf_first = bf; 864 bf_first = bf;
861 865
862 if (!rl) { 866 if (!rl) {
867 ath_set_rates(tid->an->vif, tid->an->sta, bf);
863 aggr_limit = ath_lookup_rate(sc, bf, tid); 868 aggr_limit = ath_lookup_rate(sc, bf, tid);
864 rl = 1; 869 rl = 1;
865 } 870 }
@@ -1000,14 +1005,14 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
1000 1005
1001 skb = bf->bf_mpdu; 1006 skb = bf->bf_mpdu;
1002 tx_info = IEEE80211_SKB_CB(skb); 1007 tx_info = IEEE80211_SKB_CB(skb);
1003 rates = tx_info->control.rates; 1008 rates = bf->rates;
1004 hdr = (struct ieee80211_hdr *)skb->data; 1009 hdr = (struct ieee80211_hdr *)skb->data;
1005 1010
1006 /* set dur_update_en for l-sig computation except for PS-Poll frames */ 1011 /* set dur_update_en for l-sig computation except for PS-Poll frames */
1007 info->dur_update = !ieee80211_is_pspoll(hdr->frame_control); 1012 info->dur_update = !ieee80211_is_pspoll(hdr->frame_control);
1008 info->rtscts_rate = fi->rtscts_rate; 1013 info->rtscts_rate = fi->rtscts_rate;
1009 1014
1010 for (i = 0; i < 4; i++) { 1015 for (i = 0; i < ARRAY_SIZE(bf->rates); i++) {
1011 bool is_40, is_sgi, is_sp; 1016 bool is_40, is_sgi, is_sp;
1012 int phy; 1017 int phy;
1013 1018
@@ -1745,6 +1750,7 @@ static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_atx_tid *tid,
1745 return; 1750 return;
1746 } 1751 }
1747 1752
1753 ath_set_rates(tid->an->vif, tid->an->sta, bf);
1748 bf->bf_state.bf_type = BUF_AMPDU; 1754 bf->bf_state.bf_type = BUF_AMPDU;
1749 INIT_LIST_HEAD(&bf_head); 1755 INIT_LIST_HEAD(&bf_head);
1750 list_add(&bf->list, &bf_head); 1756 list_add(&bf->list, &bf_head);
@@ -1894,49 +1900,6 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
1894 return bf; 1900 return bf;
1895} 1901}
1896 1902
1897/* FIXME: tx power */
1898static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb,
1899 struct ath_tx_control *txctl)
1900{
1901 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1902 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1903 struct ath_atx_tid *tid = NULL;
1904 struct ath_buf *bf;
1905 u8 tidno;
1906
1907 if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
1908 tidno = ieee80211_get_qos_ctl(hdr)[0] &
1909 IEEE80211_QOS_CTL_TID_MASK;
1910 tid = ATH_AN_2_TID(txctl->an, tidno);
1911
1912 WARN_ON(tid->ac->txq != txctl->txq);
1913 }
1914
1915 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
1916 /*
1917 * Try aggregation if it's a unicast data frame
1918 * and the destination is HT capable.
1919 */
1920 ath_tx_send_ampdu(sc, tid, skb, txctl);
1921 } else {
1922 bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
1923 if (!bf) {
1924 if (txctl->paprd)
1925 dev_kfree_skb_any(skb);
1926 else
1927 ieee80211_free_txskb(sc->hw, skb);
1928 return;
1929 }
1930
1931 bf->bf_state.bfs_paprd = txctl->paprd;
1932
1933 if (txctl->paprd)
1934 bf->bf_state.bfs_paprd_timestamp = jiffies;
1935
1936 ath_tx_send_normal(sc, txctl->txq, tid, skb);
1937 }
1938}
1939
1940/* Upon failure caller should free skb */ 1903/* Upon failure caller should free skb */
1941int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, 1904int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
1942 struct ath_tx_control *txctl) 1905 struct ath_tx_control *txctl)
@@ -1947,8 +1910,11 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
1947 struct ieee80211_vif *vif = info->control.vif; 1910 struct ieee80211_vif *vif = info->control.vif;
1948 struct ath_softc *sc = hw->priv; 1911 struct ath_softc *sc = hw->priv;
1949 struct ath_txq *txq = txctl->txq; 1912 struct ath_txq *txq = txctl->txq;
1913 struct ath_atx_tid *tid = NULL;
1914 struct ath_buf *bf;
1950 int padpos, padsize; 1915 int padpos, padsize;
1951 int frmlen = skb->len + FCS_LEN; 1916 int frmlen = skb->len + FCS_LEN;
1917 u8 tidno;
1952 int q; 1918 int q;
1953 1919
1954 /* NOTE: sta can be NULL according to net/mac80211.h */ 1920 /* NOTE: sta can be NULL according to net/mac80211.h */
@@ -1971,7 +1937,7 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
1971 } 1937 }
1972 1938
1973 /* Add the padding after the header if this is not already done */ 1939 /* Add the padding after the header if this is not already done */
1974 padpos = ath9k_cmn_padpos(hdr->frame_control); 1940 padpos = ieee80211_hdrlen(hdr->frame_control);
1975 padsize = padpos & 3; 1941 padsize = padpos & 3;
1976 if (padsize && skb->len > padpos) { 1942 if (padsize && skb->len > padpos) {
1977 if (skb_headroom(skb) < padsize) 1943 if (skb_headroom(skb) < padsize)
@@ -2004,8 +1970,41 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
2004 txq->stopped = true; 1970 txq->stopped = true;
2005 } 1971 }
2006 1972
2007 ath_tx_start_dma(sc, skb, txctl); 1973 if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
1974 tidno = ieee80211_get_qos_ctl(hdr)[0] &
1975 IEEE80211_QOS_CTL_TID_MASK;
1976 tid = ATH_AN_2_TID(txctl->an, tidno);
1977
1978 WARN_ON(tid->ac->txq != txctl->txq);
1979 }
1980
1981 if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
1982 /*
1983 * Try aggregation if it's a unicast data frame
1984 * and the destination is HT capable.
1985 */
1986 ath_tx_send_ampdu(sc, tid, skb, txctl);
1987 goto out;
1988 }
2008 1989
1990 bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
1991 if (!bf) {
1992 if (txctl->paprd)
1993 dev_kfree_skb_any(skb);
1994 else
1995 ieee80211_free_txskb(sc->hw, skb);
1996 goto out;
1997 }
1998
1999 bf->bf_state.bfs_paprd = txctl->paprd;
2000
2001 if (txctl->paprd)
2002 bf->bf_state.bfs_paprd_timestamp = jiffies;
2003
2004 ath_set_rates(vif, sta, bf);
2005 ath_tx_send_normal(sc, txctl->txq, tid, skb);
2006
2007out:
2009 ath_txq_unlock(sc, txq); 2008 ath_txq_unlock(sc, txq);
2010 2009
2011 return 0; 2010 return 0;
@@ -2033,7 +2032,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
2033 /* Frame was ACKed */ 2032 /* Frame was ACKed */
2034 tx_info->flags |= IEEE80211_TX_STAT_ACK; 2033 tx_info->flags |= IEEE80211_TX_STAT_ACK;
2035 2034
2036 padpos = ath9k_cmn_padpos(hdr->frame_control); 2035 padpos = ieee80211_hdrlen(hdr->frame_control);
2037 padsize = padpos & 3; 2036 padsize = padpos & 3;
2038 if (padsize && skb->len>padpos+padsize) { 2037 if (padsize && skb->len>padpos+padsize) {
2039 /* 2038 /*
@@ -2264,6 +2263,7 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
2264 struct ath_txq *txq; 2263 struct ath_txq *txq;
2265 struct ath_buf *bf, *lastbf; 2264 struct ath_buf *bf, *lastbf;
2266 struct list_head bf_head; 2265 struct list_head bf_head;
2266 struct list_head *fifo_list;
2267 int status; 2267 int status;
2268 2268
2269 for (;;) { 2269 for (;;) {
@@ -2291,20 +2291,24 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
2291 2291
2292 TX_STAT_INC(txq->axq_qnum, txprocdesc); 2292 TX_STAT_INC(txq->axq_qnum, txprocdesc);
2293 2293
2294 if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) { 2294 fifo_list = &txq->txq_fifo[txq->txq_tailidx];
2295 if (list_empty(fifo_list)) {
2295 ath_txq_unlock(sc, txq); 2296 ath_txq_unlock(sc, txq);
2296 return; 2297 return;
2297 } 2298 }
2298 2299
2299 bf = list_first_entry(&txq->txq_fifo[txq->txq_tailidx], 2300 bf = list_first_entry(fifo_list, struct ath_buf, list);
2300 struct ath_buf, list); 2301 if (bf->bf_stale) {
2302 list_del(&bf->list);
2303 ath_tx_return_buffer(sc, bf);
2304 bf = list_first_entry(fifo_list, struct ath_buf, list);
2305 }
2306
2301 lastbf = bf->bf_lastbf; 2307 lastbf = bf->bf_lastbf;
2302 2308
2303 INIT_LIST_HEAD(&bf_head); 2309 INIT_LIST_HEAD(&bf_head);
2304 list_cut_position(&bf_head, &txq->txq_fifo[txq->txq_tailidx], 2310 if (list_is_last(&lastbf->list, fifo_list)) {
2305 &lastbf->list); 2311 list_splice_tail_init(fifo_list, &bf_head);
2306
2307 if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
2308 INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH); 2312 INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH);
2309 2313
2310 if (!list_empty(&txq->axq_q)) { 2314 if (!list_empty(&txq->axq_q)) {
@@ -2315,6 +2319,11 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
2315 list_splice_tail_init(&txq->axq_q, &bf_q); 2319 list_splice_tail_init(&txq->axq_q, &bf_q);
2316 ath_tx_txqaddbuf(sc, txq, &bf_q, true); 2320 ath_tx_txqaddbuf(sc, txq, &bf_q, true);
2317 } 2321 }
2322 } else {
2323 lastbf->bf_stale = true;
2324 if (bf != lastbf)
2325 list_cut_position(&bf_head, fifo_list,
2326 lastbf->list.prev);
2318 } 2327 }
2319 2328
2320 ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head); 2329 ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
index 40109be81f7c..3d70cd277fd7 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -654,8 +654,8 @@ static ssize_t carl9170_debugfs_bug_write(struct ar9170 *ar, const char *buf,
654 goto out; 654 goto out;
655 655
656 case 'P': 656 case 'P':
657 err = carl9170_set_channel(ar, ar->hw->conf.channel, 657 err = carl9170_set_channel(ar, ar->hw->conf.chandef.chan,
658 ar->hw->conf.channel_type); 658 cfg80211_get_chandef_type(&ar->hw->conf.chandef));
659 if (err < 0) 659 if (err < 0)
660 count = err; 660 count = err;
661 661
diff --git a/drivers/net/wireless/ath/carl9170/mac.c b/drivers/net/wireless/ath/carl9170/mac.c
index 24d75ab94f0d..a2f005703c04 100644
--- a/drivers/net/wireless/ath/carl9170/mac.c
+++ b/drivers/net/wireless/ath/carl9170/mac.c
@@ -48,7 +48,7 @@ int carl9170_set_dyn_sifs_ack(struct ar9170 *ar)
48 if (conf_is_ht40(&ar->hw->conf)) 48 if (conf_is_ht40(&ar->hw->conf))
49 val = 0x010a; 49 val = 0x010a;
50 else { 50 else {
51 if (ar->hw->conf.channel->band == IEEE80211_BAND_2GHZ) 51 if (ar->hw->conf.chandef.chan->band == IEEE80211_BAND_2GHZ)
52 val = 0x105; 52 val = 0x105;
53 else 53 else
54 val = 0x104; 54 val = 0x104;
@@ -66,7 +66,7 @@ int carl9170_set_rts_cts_rate(struct ar9170 *ar)
66 rts_rate = 0x1da; 66 rts_rate = 0x1da;
67 cts_rate = 0x10a; 67 cts_rate = 0x10a;
68 } else { 68 } else {
69 if (ar->hw->conf.channel->band == IEEE80211_BAND_2GHZ) { 69 if (ar->hw->conf.chandef.chan->band == IEEE80211_BAND_2GHZ) {
70 /* 11 mbit CCK */ 70 /* 11 mbit CCK */
71 rts_rate = 033; 71 rts_rate = 033;
72 cts_rate = 003; 72 cts_rate = 003;
@@ -93,7 +93,7 @@ int carl9170_set_slot_time(struct ar9170 *ar)
93 return 0; 93 return 0;
94 } 94 }
95 95
96 if ((ar->hw->conf.channel->band == IEEE80211_BAND_5GHZ) || 96 if ((ar->hw->conf.chandef.chan->band == IEEE80211_BAND_5GHZ) ||
97 vif->bss_conf.use_short_slot) 97 vif->bss_conf.use_short_slot)
98 slottime = 9; 98 slottime = 9;
99 99
@@ -120,7 +120,7 @@ int carl9170_set_mac_rates(struct ar9170 *ar)
120 basic |= (vif->bss_conf.basic_rates & 0xff0) << 4; 120 basic |= (vif->bss_conf.basic_rates & 0xff0) << 4;
121 rcu_read_unlock(); 121 rcu_read_unlock();
122 122
123 if (ar->hw->conf.channel->band == IEEE80211_BAND_5GHZ) 123 if (ar->hw->conf.chandef.chan->band == IEEE80211_BAND_5GHZ)
124 mandatory = 0xff00; /* OFDM 6/9/12/18/24/36/48/54 */ 124 mandatory = 0xff00; /* OFDM 6/9/12/18/24/36/48/54 */
125 else 125 else
126 mandatory = 0xff0f; /* OFDM (6/9../54) + CCK (1/2/5.5/11) */ 126 mandatory = 0xff0f; /* OFDM (6/9../54) + CCK (1/2/5.5/11) */
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index 699c557bc2c7..e9010a481dfd 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -929,6 +929,9 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed)
929 } 929 }
930 930
931 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 931 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
932 enum nl80211_channel_type channel_type =
933 cfg80211_get_chandef_type(&hw->conf.chandef);
934
932 /* adjust slot time for 5 GHz */ 935 /* adjust slot time for 5 GHz */
933 err = carl9170_set_slot_time(ar); 936 err = carl9170_set_slot_time(ar);
934 if (err) 937 if (err)
@@ -938,8 +941,8 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed)
938 if (err) 941 if (err)
939 goto out; 942 goto out;
940 943
941 err = carl9170_set_channel(ar, hw->conf.channel, 944 err = carl9170_set_channel(ar, hw->conf.chandef.chan,
942 hw->conf.channel_type); 945 channel_type);
943 if (err) 946 if (err)
944 goto out; 947 goto out;
945 948
@@ -957,7 +960,7 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed)
957 } 960 }
958 961
959 if (changed & IEEE80211_CONF_CHANGE_POWER) { 962 if (changed & IEEE80211_CONF_CHANGE_POWER) {
960 err = carl9170_set_mac_tpc(ar, ar->hw->conf.channel); 963 err = carl9170_set_mac_tpc(ar, ar->hw->conf.chandef.chan);
961 if (err) 964 if (err)
962 goto out; 965 goto out;
963 } 966 }
diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c
index 07f82234c860..ab4ee7d39ad3 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -1331,7 +1331,7 @@ static void carl9170_calc_ctl(struct ar9170 *ar, u32 freq, enum carl9170_bw bw)
1331 * CTL_ETSI for 2GHz and CTL_FCC for 5GHz. 1331 * CTL_ETSI for 2GHz and CTL_FCC for 5GHz.
1332 */ 1332 */
1333 ctl_grp = ath_regd_get_band_ctl(&ar->common.regulatory, 1333 ctl_grp = ath_regd_get_band_ctl(&ar->common.regulatory,
1334 ar->hw->conf.channel->band); 1334 ar->hw->conf.chandef.chan->band);
1335 1335
1336 /* ctl group not found - either invalid band (NO_CTL) or ww roaming */ 1336 /* ctl group not found - either invalid band (NO_CTL) or ww roaming */
1337 if (ctl_grp == NO_CTL || ctl_grp == SD_NO_CTL) 1337 if (ctl_grp == NO_CTL || ctl_grp == SD_NO_CTL)
@@ -1341,7 +1341,7 @@ static void carl9170_calc_ctl(struct ar9170 *ar, u32 freq, enum carl9170_bw bw)
1341 /* skip CTL and heavy clip for CTL_MKK and CTL_ETSI */ 1341 /* skip CTL and heavy clip for CTL_MKK and CTL_ETSI */
1342 return; 1342 return;
1343 1343
1344 if (ar->hw->conf.channel->band == IEEE80211_BAND_2GHZ) { 1344 if (ar->hw->conf.chandef.chan->band == IEEE80211_BAND_2GHZ) {
1345 modes = mode_list_2ghz; 1345 modes = mode_list_2ghz;
1346 nr_modes = ARRAY_SIZE(mode_list_2ghz); 1346 nr_modes = ARRAY_SIZE(mode_list_2ghz);
1347 } else { 1347 } else {
diff --git a/drivers/net/wireless/ath/hw.c b/drivers/net/wireless/ath/hw.c
index 39e8a590d7fc..eae9abf540a7 100644
--- a/drivers/net/wireless/ath/hw.c
+++ b/drivers/net/wireless/ath/hw.c
@@ -118,6 +118,12 @@
118void ath_hw_setbssidmask(struct ath_common *common) 118void ath_hw_setbssidmask(struct ath_common *common)
119{ 119{
120 void *ah = common->ah; 120 void *ah = common->ah;
121 u32 id1;
122
123 REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr));
124 id1 = REG_READ(ah, AR_STA_ID1) & ~AR_STA_ID1_SADH_MASK;
125 id1 |= get_unaligned_le16(common->macaddr + 4);
126 REG_WRITE(ah, AR_STA_ID1, id1);
121 127
122 REG_WRITE(ah, AR_BSSMSKL, get_unaligned_le32(common->bssidmask)); 128 REG_WRITE(ah, AR_BSSMSKL, get_unaligned_le32(common->bssidmask));
123 REG_WRITE(ah, AR_BSSMSKU, get_unaligned_le16(common->bssidmask + 4)); 129 REG_WRITE(ah, AR_BSSMSKU, get_unaligned_le16(common->bssidmask + 4));
diff --git a/drivers/net/wireless/ath/reg.h b/drivers/net/wireless/ath/reg.h
index 298e53f3fa48..3ad4c774bd22 100644
--- a/drivers/net/wireless/ath/reg.h
+++ b/drivers/net/wireless/ath/reg.h
@@ -23,6 +23,10 @@
23#define AR_MIBC_CMC 0x00000004 23#define AR_MIBC_CMC 0x00000004
24#define AR_MIBC_MCS 0x00000008 24#define AR_MIBC_MCS 0x00000008
25 25
26#define AR_STA_ID0 0x8000
27#define AR_STA_ID1 0x8004
28#define AR_STA_ID1_SADH_MASK 0x0000ffff
29
26/* 30/*
27 * BSSID mask registers. See ath_hw_set_bssid_mask() 31 * BSSID mask registers. See ath_hw_set_bssid_mask()
28 * for detailed documentation about these registers. 32 * for detailed documentation about these registers.
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c
index 79d4e3271b00..797024507c71 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -191,8 +191,7 @@ static int wil_vring_alloc_skb(struct wil6210_priv *wil, struct vring *vring,
191 * - Phy info 191 * - Phy info
192 */ 192 */
193static void wil_rx_add_radiotap_header(struct wil6210_priv *wil, 193static void wil_rx_add_radiotap_header(struct wil6210_priv *wil,
194 struct sk_buff *skb, 194 struct sk_buff *skb)
195 volatile struct vring_rx_desc *d)
196{ 195{
197 struct wireless_dev *wdev = wil->wdev; 196 struct wireless_dev *wdev = wil->wdev;
198 struct wil6210_rtap { 197 struct wil6210_rtap {
@@ -216,6 +215,7 @@ static void wil_rx_add_radiotap_header(struct wil6210_priv *wil,
216 __le16 vendor_skip; 215 __le16 vendor_skip;
217 u8 vendor_data[0]; 216 u8 vendor_data[0];
218 } __packed; 217 } __packed;
218 struct vring_rx_desc *d = wil_skb_rxdesc(skb);
219 struct wil6210_rtap_vendor *rtap_vendor; 219 struct wil6210_rtap_vendor *rtap_vendor;
220 int rtap_len = sizeof(struct wil6210_rtap); 220 int rtap_len = sizeof(struct wil6210_rtap);
221 int phy_length = 0; /* phy info header size, bytes */ 221 int phy_length = 0; /* phy info header size, bytes */
@@ -312,6 +312,8 @@ static void wil_swap_ethaddr(void *data)
312/** 312/**
313 * reap 1 frame from @swhead 313 * reap 1 frame from @swhead
314 * 314 *
315 * Rx descriptor copied to skb->cb
316 *
315 * Safe to call from IRQ 317 * Safe to call from IRQ
316 */ 318 */
317static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil, 319static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
@@ -320,12 +322,15 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
320 struct device *dev = wil_to_dev(wil); 322 struct device *dev = wil_to_dev(wil);
321 struct net_device *ndev = wil_to_ndev(wil); 323 struct net_device *ndev = wil_to_ndev(wil);
322 volatile struct vring_rx_desc *d; 324 volatile struct vring_rx_desc *d;
325 struct vring_rx_desc *d1;
323 struct sk_buff *skb; 326 struct sk_buff *skb;
324 dma_addr_t pa; 327 dma_addr_t pa;
325 unsigned int sz = RX_BUF_LEN; 328 unsigned int sz = RX_BUF_LEN;
326 u8 ftype; 329 u8 ftype;
327 u8 ds_bits; 330 u8 ds_bits;
328 331
332 BUILD_BUG_ON(sizeof(struct vring_rx_desc) > sizeof(skb->cb));
333
329 if (wil_vring_is_empty(vring)) 334 if (wil_vring_is_empty(vring))
330 return NULL; 335 return NULL;
331 336
@@ -340,11 +345,14 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
340 dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE); 345 dma_unmap_single(dev, pa, sz, DMA_FROM_DEVICE);
341 skb_trim(skb, d->dma.length); 346 skb_trim(skb, d->dma.length);
342 347
343 wil->stats.last_mcs_rx = wil_rxdesc_mcs(d); 348 d1 = wil_skb_rxdesc(skb);
349 *d1 = *d;
350
351 wil->stats.last_mcs_rx = wil_rxdesc_mcs(d1);
344 352
345 /* use radiotap header only if required */ 353 /* use radiotap header only if required */
346 if (ndev->type == ARPHRD_IEEE80211_RADIOTAP) 354 if (ndev->type == ARPHRD_IEEE80211_RADIOTAP)
347 wil_rx_add_radiotap_header(wil, skb, d); 355 wil_rx_add_radiotap_header(wil, skb);
348 356
349 wil_dbg_txrx(wil, "Rx[%3d] : %d bytes\n", vring->swhead, d->dma.length); 357 wil_dbg_txrx(wil, "Rx[%3d] : %d bytes\n", vring->swhead, d->dma.length);
350 wil_hex_dump_txrx("Rx ", DUMP_PREFIX_NONE, 32, 4, 358 wil_hex_dump_txrx("Rx ", DUMP_PREFIX_NONE, 32, 4,
@@ -360,7 +368,7 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
360 * Driver should recognize it by frame type, that is found 368 * Driver should recognize it by frame type, that is found
361 * in Rx descriptor. If type is not data, it is 802.11 frame as is 369 * in Rx descriptor. If type is not data, it is 802.11 frame as is
362 */ 370 */
363 ftype = wil_rxdesc_ftype(d) << 2; 371 ftype = wil_rxdesc_ftype(d1) << 2;
364 if (ftype != IEEE80211_FTYPE_DATA) { 372 if (ftype != IEEE80211_FTYPE_DATA) {
365 wil_dbg_txrx(wil, "Non-data frame ftype 0x%08x\n", ftype); 373 wil_dbg_txrx(wil, "Non-data frame ftype 0x%08x\n", ftype);
366 /* TODO: process it */ 374 /* TODO: process it */
@@ -375,7 +383,7 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
375 return NULL; 383 return NULL;
376 } 384 }
377 385
378 ds_bits = wil_rxdesc_ds_bits(d); 386 ds_bits = wil_rxdesc_ds_bits(d1);
379 if (ds_bits == 1) { 387 if (ds_bits == 1) {
380 /* 388 /*
381 * HW bug - in ToDS mode, i.e. Rx on AP side, 389 * HW bug - in ToDS mode, i.e. Rx on AP side,
@@ -517,6 +525,7 @@ int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
517 .vring_cfg = { 525 .vring_cfg = {
518 .tx_sw_ring = { 526 .tx_sw_ring = {
519 .max_mpdu_size = cpu_to_le16(TX_BUF_LEN), 527 .max_mpdu_size = cpu_to_le16(TX_BUF_LEN),
528 .ring_size = cpu_to_le16(size),
520 }, 529 },
521 .ringid = id, 530 .ringid = id,
522 .cidxtid = (cid & 0xf) | ((tid & 0xf) << 4), 531 .cidxtid = (cid & 0xf) | ((tid & 0xf) << 4),
@@ -548,7 +557,6 @@ int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
548 goto out; 557 goto out;
549 558
550 cmd.vring_cfg.tx_sw_ring.ring_mem_base = cpu_to_le64(vring->pa); 559 cmd.vring_cfg.tx_sw_ring.ring_mem_base = cpu_to_le64(vring->pa);
551 cmd.vring_cfg.tx_sw_ring.ring_size = cpu_to_le16(vring->size);
552 560
553 rc = wmi_call(wil, WMI_VRING_CFG_CMDID, &cmd, sizeof(cmd), 561 rc = wmi_call(wil, WMI_VRING_CFG_CMDID, &cmd, sizeof(cmd),
554 WMI_VRING_CFG_DONE_EVENTID, &reply, sizeof(reply), 100); 562 WMI_VRING_CFG_DONE_EVENTID, &reply, sizeof(reply), 100);
@@ -779,9 +787,14 @@ void wil_tx_complete(struct wil6210_priv *wil, int ringid)
779 wil_dbg_txrx(wil, "%s(%d)\n", __func__, ringid); 787 wil_dbg_txrx(wil, "%s(%d)\n", __func__, ringid);
780 788
781 while (!wil_vring_is_empty(vring)) { 789 while (!wil_vring_is_empty(vring)) {
782 volatile struct vring_tx_desc *d = &vring->va[vring->swtail].tx; 790 volatile struct vring_tx_desc *d1 =
791 &vring->va[vring->swtail].tx;
792 struct vring_tx_desc dd, *d = &dd;
783 dma_addr_t pa; 793 dma_addr_t pa;
784 struct sk_buff *skb; 794 struct sk_buff *skb;
795
796 dd = *d1;
797
785 if (!(d->dma.status & TX_DMA_STATUS_DU)) 798 if (!(d->dma.status & TX_DMA_STATUS_DU))
786 break; 799 break;
787 800
diff --git a/drivers/net/wireless/ath/wil6210/txrx.h b/drivers/net/wireless/ath/wil6210/txrx.h
index 45a61f597c5c..adef12fb2aee 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.h
+++ b/drivers/net/wireless/ath/wil6210/txrx.h
@@ -339,24 +339,59 @@ union vring_desc {
339 struct vring_rx_desc rx; 339 struct vring_rx_desc rx;
340} __packed; 340} __packed;
341 341
342static inline int wil_rxdesc_phy_length(volatile struct vring_rx_desc *d) 342static inline int wil_rxdesc_tid(struct vring_rx_desc *d)
343{ 343{
344 return WIL_GET_BITS(d->dma.d0, 16, 29); 344 return WIL_GET_BITS(d->mac.d0, 0, 3);
345} 345}
346 346
347static inline int wil_rxdesc_mcs(volatile struct vring_rx_desc *d) 347static inline int wil_rxdesc_cid(struct vring_rx_desc *d)
348{ 348{
349 return WIL_GET_BITS(d->mac.d1, 21, 24); 349 return WIL_GET_BITS(d->mac.d0, 4, 6);
350} 350}
351 351
352static inline int wil_rxdesc_ds_bits(volatile struct vring_rx_desc *d) 352static inline int wil_rxdesc_mid(struct vring_rx_desc *d)
353{ 353{
354 return WIL_GET_BITS(d->mac.d1, 8, 9); 354 return WIL_GET_BITS(d->mac.d0, 8, 9);
355} 355}
356 356
357static inline int wil_rxdesc_ftype(volatile struct vring_rx_desc *d) 357static inline int wil_rxdesc_ftype(struct vring_rx_desc *d)
358{ 358{
359 return WIL_GET_BITS(d->mac.d0, 10, 11); 359 return WIL_GET_BITS(d->mac.d0, 10, 11);
360} 360}
361 361
362static inline int wil_rxdesc_subtype(struct vring_rx_desc *d)
363{
364 return WIL_GET_BITS(d->mac.d0, 12, 15);
365}
366
367static inline int wil_rxdesc_seq(struct vring_rx_desc *d)
368{
369 return WIL_GET_BITS(d->mac.d0, 16, 27);
370}
371
372static inline int wil_rxdesc_ext_subtype(struct vring_rx_desc *d)
373{
374 return WIL_GET_BITS(d->mac.d0, 28, 31);
375}
376
377static inline int wil_rxdesc_ds_bits(struct vring_rx_desc *d)
378{
379 return WIL_GET_BITS(d->mac.d1, 8, 9);
380}
381
382static inline int wil_rxdesc_mcs(struct vring_rx_desc *d)
383{
384 return WIL_GET_BITS(d->mac.d1, 21, 24);
385}
386
387static inline int wil_rxdesc_phy_length(struct vring_rx_desc *d)
388{
389 return WIL_GET_BITS(d->dma.d0, 16, 29);
390}
391
392static inline struct vring_rx_desc *wil_skb_rxdesc(struct sk_buff *skb)
393{
394 return (void *)skb->cb;
395}
396
362#endif /* WIL6210_TXRX_H */ 397#endif /* WIL6210_TXRX_H */