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,12 +1612,16 @@ __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)
184 + if (ehdr->h_proto == rx->sdata->control_port_protocol) {
185 + *port_control = true;
187 + if (check_port_control)
193 @@ -1916,6 +1921,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_
194 struct net_device *dev = sdata->dev;
195 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
196 __le16 fc = hdr->frame_control;
200 if (unlikely(!ieee80211_is_data(hdr->frame_control)))
201 @@ -1932,13 +1938,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_
202 sdata->vif.type == NL80211_IFTYPE_AP)
203 return RX_DROP_MONITOR;
205 - err = __ieee80211_data_to_8023(rx);
206 + err = __ieee80211_data_to_8023(rx, &port_control);
208 return RX_DROP_UNUSABLE;
210 if (!ieee80211_frame_allowed(rx, fc))
211 return RX_DROP_MONITOR;
213 + if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
214 + unlikely(port_control) && sdata->bss) {
215 + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
223 dev->stats.rx_packets++;
224 --- a/drivers/net/wireless/ath/ath9k/recv.c
225 +++ b/drivers/net/wireless/ath/ath9k/recv.c
226 @@ -75,7 +75,6 @@ static void ath_rx_buf_link(struct ath_s
227 *sc->rx.rxlink = bf->bf_daddr;
229 sc->rx.rxlink = &ds->ds_link;
230 - ath9k_hw_rxena(ah);
233 static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
234 @@ -426,9 +425,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
236 rfilt |= ATH9K_RX_FILTER_BEACON;
238 - if ((AR_SREV_9280_20_OR_LATER(sc->sc_ah) ||
239 - AR_SREV_9285_12_OR_LATER(sc->sc_ah)) &&
240 - (sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
241 + if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
242 (sc->rx.rxfilter & FIF_PSPOLL))
243 rfilt |= ATH9K_RX_FILTER_PSPOLL;
245 @@ -486,12 +483,12 @@ start_recv:
246 bool ath_stoprecv(struct ath_softc *sc)
248 struct ath_hw *ah = sc->sc_ah;
250 + bool stopped, reset = false;
252 spin_lock_bh(&sc->rx.rxbuflock);
253 ath9k_hw_abortpcurecv(ah);
254 ath9k_hw_setrxfilter(ah, 0);
255 - stopped = ath9k_hw_stopdmarecv(ah);
256 + stopped = ath9k_hw_stopdmarecv(ah, &reset);
258 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
259 ath_edma_stop_recv(sc);
260 @@ -506,7 +503,7 @@ bool ath_stoprecv(struct ath_softc *sc)
261 "confusing the DMA engine when we start RX up\n");
262 ATH_DBG_WARN_ON_ONCE(!stopped);
265 + return stopped || reset;
268 void ath_flushrecv(struct ath_softc *sc)
269 @@ -1767,6 +1764,7 @@ requeue:
271 list_move_tail(&bf->list, &sc->rx.rxbuf);
272 ath_rx_buf_link(sc, bf);
273 + ath9k_hw_rxena(ah);
277 --- a/drivers/net/wireless/ath/ath9k/hw.c
278 +++ b/drivers/net/wireless/ath/ath9k/hw.c
279 @@ -1249,15 +1249,6 @@ int ath9k_hw_reset(struct ath_hw *ah, st
280 ah->txchainmask = common->tx_chainmask;
281 ah->rxchainmask = common->rx_chainmask;
283 - if ((common->bus_ops->ath_bus_type != ATH_USB) && !ah->chip_fullsleep) {
284 - ath9k_hw_abortpcurecv(ah);
285 - if (!ath9k_hw_stopdmarecv(ah)) {
286 - ath_dbg(common, ATH_DBG_XMIT,
287 - "Failed to stop receive dma\n");
288 - bChannelChange = false;
292 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
295 --- a/drivers/net/wireless/ath/ath9k/mac.c
296 +++ b/drivers/net/wireless/ath/ath9k/mac.c
297 @@ -710,27 +710,46 @@ void ath9k_hw_abortpcurecv(struct ath_hw
299 EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
301 -bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
302 +bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset)
304 #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
305 struct ath_common *common = ath9k_hw_common(ah);
306 + u32 mac_status, last_mac_status = 0;
309 + /* Enable access to the DMA observation bus */
310 + REG_WRITE(ah, AR_MACMISC,
311 + ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
312 + (AR_MACMISC_MISC_OBS_BUS_1 <<
313 + AR_MACMISC_MISC_OBS_BUS_MSB_S)));
315 REG_WRITE(ah, AR_CR, AR_CR_RXD);
317 /* Wait for rx enable bit to go low */
318 for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
319 if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
322 + if (!AR_SREV_9300_20_OR_LATER(ah)) {
323 + mac_status = REG_READ(ah, AR_DMADBG_7) & 0x7f0;
324 + if (mac_status == 0x1c0 && mac_status == last_mac_status) {
329 + last_mac_status = mac_status;
332 udelay(AH_TIME_QUANTUM);
337 - "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
338 + "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
339 AH_RX_STOP_DMA_TIMEOUT / 1000,
341 - REG_READ(ah, AR_DIAG_SW));
342 + REG_READ(ah, AR_DIAG_SW),
343 + REG_READ(ah, AR_DMADBG_7));
347 --- a/drivers/net/wireless/ath/ath9k/mac.h
348 +++ b/drivers/net/wireless/ath/ath9k/mac.h
349 @@ -695,7 +695,7 @@ bool ath9k_hw_setrxabort(struct ath_hw *
350 void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp);
351 void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning);
352 void ath9k_hw_abortpcurecv(struct ath_hw *ah);
353 -bool ath9k_hw_stopdmarecv(struct ath_hw *ah);
354 +bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset);
355 int ath9k_hw_beaconq_setup(struct ath_hw *ah);
357 /* Interrupt Handling */