cf4272d92bbee7048dc3552ee0dee9b8f6885022
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
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)
5                 return;
6  
7 -       ath9k_ps_wakeup(sc);
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
12         }
13  
14         ar9003_paprd_enable(ah, true);
15 -       ath9k_ps_restore(sc);
16  }
17  
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);
28 +               }
29         }
30  }
31  
32 @@ -1376,7 +1377,6 @@ static void ath9k_calculate_summary_stat
33  
34         ath9k_calculate_iter_data(hw, vif, &iter_data);
35  
36 -       ath9k_ps_wakeup(sc);
37         /* Set BSSID mask. */
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
41         }
42  
43         ath9k_hw_set_interrupts(ah, ah->imask);
44 -       ath9k_ps_restore(sc);
45  
46         /* Set up ANI */
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;
50         int ret = 0;
51  
52 +       ath9k_ps_wakeup(sc);
53         mutex_lock(&sc->mutex);
54  
55         switch (vif->type) {
56 @@ -1503,6 +1503,7 @@ static int ath9k_add_interface(struct ie
57         ath9k_do_vif_add_setup(hw, vif);
58  out:
59         mutex_unlock(&sc->mutex);
60 +       ath9k_ps_restore(sc);
61         return ret;
62  }
63  
64 @@ -1517,6 +1518,7 @@ static int ath9k_change_interface(struct
65  
66         ath_dbg(common, ATH_DBG_CONFIG, "Change Interface\n");
67         mutex_lock(&sc->mutex);
68 +       ath9k_ps_wakeup(sc);
69  
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
73  
74         ath9k_do_vif_add_setup(hw, vif);
75  out:
76 +       ath9k_ps_restore(sc);
77         mutex_unlock(&sc->mutex);
78         return ret;
79  }
80 @@ -1558,6 +1561,7 @@ static void ath9k_remove_interface(struc
81  
82         ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
83  
84 +       ath9k_ps_wakeup(sc);
85         mutex_lock(&sc->mutex);
86  
87         sc->nvifs--;
88 @@ -1569,6 +1573,7 @@ static void ath9k_remove_interface(struc
89         ath9k_calculate_summary_state(hw, NULL);
90  
91         mutex_unlock(&sc->mutex);
92 +       ath9k_ps_restore(sc);
93  }
94  
95  static void ath9k_enable_ps(struct ath_softc *sc)
96 @@ -1809,6 +1814,7 @@ static int ath9k_conf_tx(struct ieee8021
97  
98         txq = sc->tx.txq_map[queue];
99  
100 +       ath9k_ps_wakeup(sc);
101         mutex_lock(&sc->mutex);
102  
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);
106  
107         mutex_unlock(&sc->mutex);
108 +       ath9k_ps_restore(sc);
109  
110         return ret;
111  }
112 @@ -1908,6 +1915,7 @@ static void ath9k_bss_info_changed(struc
113         int slottime;
114         int error;
115  
116 +       ath9k_ps_wakeup(sc);
117         mutex_lock(&sc->mutex);
118  
119         if (changed & BSS_CHANGED_BSSID) {
120 @@ -2008,6 +2016,7 @@ static void ath9k_bss_info_changed(struc
121         }
122  
123         mutex_unlock(&sc->mutex);
124 +       ath9k_ps_restore(sc);
125  }
126  
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;
134 -       /*
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.
140 -        */
141 -       slot = ATH_BCBUF - slot - 1;
142         vif = sc->beacon.bslot[slot];
143  
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;
148  
149 -       switch (iftype) {
150 +       switch (sc->sc_ah->opmode) {
151         case NL80211_IFTYPE_AP:
152                 ath_beacon_config_ap(sc, cur_conf);
153                 break;
154 --- a/net/mac80211/rx.c
155 +++ b/net/mac80211/rx.c
156 @@ -1585,7 +1585,7 @@ ieee80211_drop_unencrypted_mgmt(struct i
157  }
158  
159  static int
160 -__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
161 +__ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
162  {
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
166         struct ethhdr *ehdr;
167         int ret;
168  
169 +       *port_control = false;
170         if (ieee80211_has_a4(hdr->frame_control) &&
171             sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
172                 return -1;
173 @@ -1611,12 +1612,16 @@ __ieee80211_data_to_8023(struct ieee8021
174                 return -1;
175  
176         ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
177 -       if (ret < 0 || !check_port_control)
178 +       if (ret < 0)
179                 return ret;
180  
181         ehdr = (struct ethhdr *) rx->skb->data;
182 -       if (ehdr->h_proto != rx->sdata->control_port_protocol)
183 -               return -1;
184 +       if (ehdr->h_proto == rx->sdata->control_port_protocol) {
185 +               *port_control = true;
186 +
187 +               if (check_port_control)
188 +                       return -1;
189 +       }
190  
191         return 0;
192  }
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;
197 +       bool port_control;
198         int err;
199  
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;
204  
205 -       err = __ieee80211_data_to_8023(rx);
206 +       err = __ieee80211_data_to_8023(rx, &port_control);
207         if (unlikely(err))
208                 return RX_DROP_UNUSABLE;
209  
210         if (!ieee80211_frame_allowed(rx, fc))
211                 return RX_DROP_MONITOR;
212  
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,
216 +                                    u.ap);
217 +               dev = sdata->dev;
218 +               rx->sdata = sdata;
219 +       }
220 +
221         rx->skb->dev = dev;
222  
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;
228  
229         sc->rx.rxlink = &ds->ds_link;
230 -       ath9k_hw_rxena(ah);
231  }
232  
233  static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
234 @@ -426,9 +425,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
235         else
236                 rfilt |= ATH9K_RX_FILTER_BEACON;
237  
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;
244  
245 @@ -486,12 +483,12 @@ start_recv:
246  bool ath_stoprecv(struct ath_softc *sc)
247  {
248         struct ath_hw *ah = sc->sc_ah;
249 -       bool stopped;
250 +       bool stopped, reset = false;
251  
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);
257  
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);
263         }
264 -       return stopped;
265 +       return stopped || reset;
266  }
267  
268  void ath_flushrecv(struct ath_softc *sc)
269 @@ -1767,6 +1764,7 @@ requeue:
270                 } else {
271                         list_move_tail(&bf->list, &sc->rx.rxbuf);
272                         ath_rx_buf_link(sc, bf);
273 +                       ath9k_hw_rxena(ah);
274                 }
275         } while (1);
276  
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;
282  
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;
289 -               }
290 -       }
291 -
292         if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
293                 return -EIO;
294  
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
298  }
299  EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
300  
301 -bool ath9k_hw_stopdmarecv(struct ath_hw *ah)
302 +bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset)
303  {
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;
307         int i;
308  
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)));
314 +
315         REG_WRITE(ah, AR_CR, AR_CR_RXD);
316  
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)
320                         break;
321 +
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) {
325 +                               *reset = true;
326 +                               break;
327 +                       }
328 +
329 +                       last_mac_status = mac_status;
330 +               }
331 +
332                 udelay(AH_TIME_QUANTUM);
333         }
334  
335         if (i == 0) {
336                 ath_err(common,
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,
340                         REG_READ(ah, AR_CR),
341 -                       REG_READ(ah, AR_DIAG_SW));
342 +                       REG_READ(ah, AR_DIAG_SW),
343 +                       REG_READ(ah, AR_DMADBG_7));
344                 return false;
345         } else {
346                 return true;
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);
356  
357  /* Interrupt Handling */