1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -324,7 +324,6 @@ static void ath_paprd_activate(struct at
4 if (!caldata || !caldata->paprd_done)
8 ar9003_paprd_enable(ah, false);
9 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
10 if (!(common->tx_chainmask & BIT(chain)))
11 @@ -334,7 +333,6 @@ static void ath_paprd_activate(struct at
14 ar9003_paprd_enable(ah, true);
15 - ath9k_ps_restore(sc);
18 static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int chain)
19 @@ -554,8 +552,11 @@ set_timer:
20 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) {
21 if (!ah->caldata->paprd_done)
22 ieee80211_queue_work(sc->hw, &sc->paprd_work);
23 - else if (!ah->paprd_table_write_done)
24 + else if (!ah->paprd_table_write_done) {
25 + ath9k_ps_wakeup(sc);
26 ath_paprd_activate(sc);
27 + ath9k_ps_restore(sc);
32 @@ -1376,7 +1377,6 @@ static void ath9k_calculate_summary_stat
34 ath9k_calculate_iter_data(hw, vif, &iter_data);
36 - ath9k_ps_wakeup(sc);
38 memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
39 ath_hw_setbssidmask(common);
40 @@ -1411,7 +1411,6 @@ static void ath9k_calculate_summary_stat
43 ath9k_hw_set_interrupts(ah, ah->imask);
44 - ath9k_ps_restore(sc);
47 if ((iter_data.naps + iter_data.nadhocs) > 0) {
48 @@ -1457,6 +1456,7 @@ static int ath9k_add_interface(struct ie
49 struct ath_vif *avp = (void *)vif->drv_priv;
52 + ath9k_ps_wakeup(sc);
53 mutex_lock(&sc->mutex);
56 @@ -1503,6 +1503,7 @@ static int ath9k_add_interface(struct ie
57 ath9k_do_vif_add_setup(hw, vif);
59 mutex_unlock(&sc->mutex);
60 + ath9k_ps_restore(sc);
64 @@ -1517,6 +1518,7 @@ static int ath9k_change_interface(struct
66 ath_dbg(common, ATH_DBG_CONFIG, "Change Interface\n");
67 mutex_lock(&sc->mutex);
68 + ath9k_ps_wakeup(sc);
70 /* See if new interface type is valid. */
71 if ((new_type == NL80211_IFTYPE_ADHOC) &&
72 @@ -1546,6 +1548,7 @@ static int ath9k_change_interface(struct
74 ath9k_do_vif_add_setup(hw, vif);
76 + ath9k_ps_restore(sc);
77 mutex_unlock(&sc->mutex);
80 @@ -1558,6 +1561,7 @@ static void ath9k_remove_interface(struc
82 ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
84 + ath9k_ps_wakeup(sc);
85 mutex_lock(&sc->mutex);
88 @@ -1569,6 +1573,7 @@ static void ath9k_remove_interface(struc
89 ath9k_calculate_summary_state(hw, NULL);
91 mutex_unlock(&sc->mutex);
92 + ath9k_ps_restore(sc);
95 static void ath9k_enable_ps(struct ath_softc *sc)
96 @@ -1809,6 +1814,7 @@ static int ath9k_conf_tx(struct ieee8021
98 txq = sc->tx.txq_map[queue];
100 + ath9k_ps_wakeup(sc);
101 mutex_lock(&sc->mutex);
103 memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
104 @@ -1832,6 +1838,7 @@ static int ath9k_conf_tx(struct ieee8021
105 ath_beaconq_config(sc);
107 mutex_unlock(&sc->mutex);
108 + ath9k_ps_restore(sc);
112 @@ -1908,6 +1915,7 @@ static void ath9k_bss_info_changed(struc
116 + ath9k_ps_wakeup(sc);
117 mutex_lock(&sc->mutex);
119 if (changed & BSS_CHANGED_BSSID) {
120 @@ -2008,6 +2016,7 @@ static void ath9k_bss_info_changed(struc
123 mutex_unlock(&sc->mutex);
124 + ath9k_ps_restore(sc);
127 static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
128 --- a/drivers/net/wireless/ath/ath9k/beacon.c
129 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
130 @@ -392,14 +392,6 @@ void ath_beacon_tasklet(unsigned long da
131 tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
132 tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
133 slot = (tsftu % (intval * ATH_BCBUF)) / intval;
135 - * Reverse the slot order to get slot 0 on the TBTT offset that does
136 - * not require TSF adjustment and other slots adding
137 - * slot/ATH_BCBUF * beacon_int to timestamp. For example, with
138 - * ATH_BCBUF = 4, we process beacon slots as follows: 3 2 1 0 3 2 1 ..
139 - * and slot 0 is at correct offset to TBTT.
141 - slot = ATH_BCBUF - slot - 1;
142 vif = sc->beacon.bslot[slot];
144 ath_dbg(common, ATH_DBG_BEACON,
145 @@ -708,7 +700,7 @@ void ath_beacon_config(struct ath_softc
146 if (cur_conf->dtim_period == 0)
147 cur_conf->dtim_period = 1;
150 + switch (sc->sc_ah->opmode) {
151 case NL80211_IFTYPE_AP:
152 ath_beacon_config_ap(sc, cur_conf);
154 --- a/net/mac80211/rx.c
155 +++ b/net/mac80211/rx.c
156 @@ -1585,7 +1585,7 @@ ieee80211_drop_unencrypted_mgmt(struct i
160 -__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
161 +__ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
163 struct ieee80211_sub_if_data *sdata = rx->sdata;
164 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
165 @@ -1593,6 +1593,7 @@ __ieee80211_data_to_8023(struct ieee8021
169 + *port_control = false;
170 if (ieee80211_has_a4(hdr->frame_control) &&
171 sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
173 @@ -1611,11 +1612,13 @@ __ieee80211_data_to_8023(struct ieee8021
176 ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
177 - if (ret < 0 || !check_port_control)
181 ehdr = (struct ethhdr *) rx->skb->data;
182 - if (ehdr->h_proto != rx->sdata->control_port_protocol)
183 + if (ehdr->h_proto == rx->sdata->control_port_protocol)
184 + *port_control = true;
185 + else if (check_port_control)
189 @@ -1916,6 +1919,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_
190 struct net_device *dev = sdata->dev;
191 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
192 __le16 fc = hdr->frame_control;
196 if (unlikely(!ieee80211_is_data(hdr->frame_control)))
197 @@ -1932,13 +1936,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_
198 sdata->vif.type == NL80211_IFTYPE_AP)
199 return RX_DROP_MONITOR;
201 - err = __ieee80211_data_to_8023(rx);
202 + err = __ieee80211_data_to_8023(rx, &port_control);
204 return RX_DROP_UNUSABLE;
206 if (!ieee80211_frame_allowed(rx, fc))
207 return RX_DROP_MONITOR;
209 + if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
210 + unlikely(port_control) && sdata->bss) {
211 + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
219 dev->stats.rx_packets++;
220 --- a/drivers/net/wireless/ath/ath9k/recv.c
221 +++ b/drivers/net/wireless/ath/ath9k/recv.c
222 @@ -75,7 +75,6 @@ static void ath_rx_buf_link(struct ath_s
223 *sc->rx.rxlink = bf->bf_daddr;
225 sc->rx.rxlink = &ds->ds_link;
226 - ath9k_hw_rxena(ah);
229 static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
230 @@ -426,9 +425,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
232 rfilt |= ATH9K_RX_FILTER_BEACON;
234 - if ((AR_SREV_9280_20_OR_LATER(sc->sc_ah) ||
235 - AR_SREV_9285_12_OR_LATER(sc->sc_ah)) &&
236 - (sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
237 + if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
238 (sc->rx.rxfilter & FIF_PSPOLL))
239 rfilt |= ATH9K_RX_FILTER_PSPOLL;
241 @@ -486,12 +483,12 @@ start_recv:
242 bool ath_stoprecv(struct ath_softc *sc)
244 struct ath_hw *ah = sc->sc_ah;
246 + bool stopped, reset = false;
248 spin_lock_bh(&sc->rx.rxbuflock);
249 ath9k_hw_abortpcurecv(ah);
250 ath9k_hw_setrxfilter(ah, 0);
251 - stopped = ath9k_hw_stopdmarecv(ah);
252 + stopped = ath9k_hw_stopdmarecv(ah, &reset);
254 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
255 ath_edma_stop_recv(sc);
256 @@ -506,7 +503,7 @@ bool ath_stoprecv(struct ath_softc *sc)
257 "confusing the DMA engine when we start RX up\n");
258 ATH_DBG_WARN_ON_ONCE(!stopped);
261 + return stopped || reset;
264 void ath_flushrecv(struct ath_softc *sc)
265 @@ -1767,6 +1764,7 @@ requeue:
267 list_move_tail(&bf->list, &sc->rx.rxbuf);
268 ath_rx_buf_link(sc, bf);
269 + ath9k_hw_rxena(ah);
273 --- a/drivers/net/wireless/ath/ath9k/hw.c
274 +++ b/drivers/net/wireless/ath/ath9k/hw.c
275 @@ -1249,15 +1249,6 @@ int ath9k_hw_reset(struct ath_hw *ah, st
276 ah->txchainmask = common->tx_chainmask;
277 ah->rxchainmask = common->rx_chainmask;
279 - if ((common->bus_ops->ath_bus_type != ATH_USB) && !ah->chip_fullsleep) {
280 - ath9k_hw_abortpcurecv(ah);
281 - if (!ath9k_hw_stopdmarecv(ah)) {
282 - ath_dbg(common, ATH_DBG_XMIT,
283 - "Failed to stop receive dma\n");
284 - bChannelChange = false;
288 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
291 --- a/drivers/net/wireless/ath/ath9k/mac.c
292 +++ b/drivers/net/wireless/ath/ath9k/mac.c
293 @@ -710,27 +710,46 @@ void ath9k_hw_abortpcurecv(struct ath_hw
295 EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
297 -bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
298 +bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset)
300 #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
301 struct ath_common *common = ath9k_hw_common(ah);
302 + u32 mac_status, last_mac_status = 0;
305 + /* Enable access to the DMA observation bus */
306 + REG_WRITE(ah, AR_MACMISC,
307 + ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
308 + (AR_MACMISC_MISC_OBS_BUS_1 <<
309 + AR_MACMISC_MISC_OBS_BUS_MSB_S)));
311 REG_WRITE(ah, AR_CR, AR_CR_RXD);
313 /* Wait for rx enable bit to go low */
314 for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
315 if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
318 + if (!AR_SREV_9300_20_OR_LATER(ah)) {
319 + mac_status = REG_READ(ah, AR_DMADBG_7) & 0x7f0;
320 + if (mac_status == 0x1c0 && mac_status == last_mac_status) {
325 + last_mac_status = mac_status;
328 udelay(AH_TIME_QUANTUM);
333 - "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
334 + "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
335 AH_RX_STOP_DMA_TIMEOUT / 1000,
337 - REG_READ(ah, AR_DIAG_SW));
338 + REG_READ(ah, AR_DIAG_SW),
339 + REG_READ(ah, AR_DMADBG_7));
343 --- a/drivers/net/wireless/ath/ath9k/mac.h
344 +++ b/drivers/net/wireless/ath/ath9k/mac.h
345 @@ -695,7 +695,7 @@ bool ath9k_hw_setrxabort(struct ath_hw *
346 void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp);
347 void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning);
348 void ath9k_hw_abortpcurecv(struct ath_hw *ah);
349 -bool ath9k_hw_stopdmarecv(struct ath_hw *ah);
350 +bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset);
351 int ath9k_hw_beaconq_setup(struct ath_hw *ah);
353 /* Interrupt Handling */