mac80211: update to 2013-01-07, add several ath9k stability fixes
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/net/mac80211/agg-rx.c
2 +++ b/net/mac80211/agg-rx.c
3 @@ -203,6 +203,8 @@ static void ieee80211_send_addba_resp(st
4                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
5         else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
6                 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
7 +       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
8 +               memcpy(mgmt->bssid, da, ETH_ALEN);
9  
10         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
11                                           IEEE80211_STYPE_ACTION);
12 --- a/net/mac80211/agg-tx.c
13 +++ b/net/mac80211/agg-tx.c
14 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
15         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
16         if (sdata->vif.type == NL80211_IFTYPE_AP ||
17             sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
18 -           sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
19 +           sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
20 +           sdata->vif.type == NL80211_IFTYPE_WDS)
21                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
22         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
23                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
24 @@ -520,6 +521,7 @@ int ieee80211_start_tx_ba_session(struct
25             sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
26             sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
27             sdata->vif.type != NL80211_IFTYPE_AP &&
28 +           sdata->vif.type != NL80211_IFTYPE_WDS &&
29             sdata->vif.type != NL80211_IFTYPE_ADHOC)
30                 return -EINVAL;
31  
32 --- a/net/mac80211/debugfs_sta.c
33 +++ b/net/mac80211/debugfs_sta.c
34 @@ -65,11 +65,11 @@ static ssize_t sta_flags_read(struct fil
35         test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
36  
37         int res = scnprintf(buf, sizeof(buf),
38 -                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
39 +                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
40                             TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
41                             TEST(PS_DRIVER), TEST(AUTHORIZED),
42                             TEST(SHORT_PREAMBLE),
43 -                           TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
44 +                           TEST(WME), TEST(CLEAR_PS_FILT),
45                             TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
46                             TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
47                             TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
48 --- a/net/mac80211/iface.c
49 +++ b/net/mac80211/iface.c
50 @@ -501,7 +501,6 @@ int ieee80211_do_open(struct wireless_de
51         struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
52         struct net_device *dev = wdev->netdev;
53         struct ieee80211_local *local = sdata->local;
54 -       struct sta_info *sta;
55         u32 changed = 0;
56         int res;
57         u32 hw_reconf_flags = 0;
58 @@ -658,30 +657,8 @@ int ieee80211_do_open(struct wireless_de
59  
60         set_bit(SDATA_STATE_RUNNING, &sdata->state);
61  
62 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
63 -               /* Create STA entry for the WDS peer */
64 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
65 -                                    GFP_KERNEL);
66 -               if (!sta) {
67 -                       res = -ENOMEM;
68 -                       goto err_del_interface;
69 -               }
70 -
71 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
72 -               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
73 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
74 -
75 -               res = sta_info_insert(sta);
76 -               if (res) {
77 -                       /* STA has been freed */
78 -                       goto err_del_interface;
79 -               }
80 -
81 -               rate_control_rate_init(sta);
82 -               netif_carrier_on(dev);
83 -       } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
84 +       if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
85                 rcu_assign_pointer(local->p2p_sdata, sdata);
86 -       }
87  
88         /*
89          * set_multicast_list will be invoked by the networking core
90 @@ -1066,6 +1043,72 @@ static void ieee80211_if_setup(struct ne
91         dev->destructor = free_netdev;
92  }
93  
94 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
95 +                                        struct sk_buff *skb)
96 +{
97 +       struct ieee80211_local *local = sdata->local;
98 +       struct ieee80211_rx_status *rx_status;
99 +       struct ieee802_11_elems elems;
100 +       struct ieee80211_mgmt *mgmt;
101 +       struct sta_info *sta;
102 +       size_t baselen;
103 +       u32 rates = 0;
104 +       u16 stype;
105 +       bool new = false;
106 +       enum ieee80211_band band = local->hw.conf.channel->band;
107 +       struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
108 +
109 +       rx_status = IEEE80211_SKB_RXCB(skb);
110 +       mgmt = (struct ieee80211_mgmt *) skb->data;
111 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
112 +
113 +       if (stype != IEEE80211_STYPE_BEACON)
114 +               return;
115 +
116 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
117 +       if (baselen > skb->len)
118 +               return;
119 +
120 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
121 +                              skb->len - baselen, &elems);
122 +
123 +       rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
124 +
125 +       rcu_read_lock();
126 +
127 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
128 +
129 +       if (!sta) {
130 +               rcu_read_unlock();
131 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
132 +                                    GFP_KERNEL);
133 +               if (!sta)
134 +                       return;
135 +
136 +               new = true;
137 +       }
138 +
139 +       sta->last_rx = jiffies;
140 +       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
141 +
142 +       if (elems.ht_cap_elem)
143 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
144 +                               elems.ht_cap_elem, &sta->sta.ht_cap);
145 +
146 +       if (elems.wmm_param)
147 +               set_sta_flag(sta, WLAN_STA_WME);
148 +
149 +       if (new) {
150 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
151 +               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
152 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
153 +               rate_control_rate_init(sta);
154 +               sta_info_insert_rcu(sta);
155 +       }
156 +
157 +       rcu_read_unlock();
158 +}
159 +
160  static void ieee80211_iface_work(struct work_struct *work)
161  {
162         struct ieee80211_sub_if_data *sdata =
163 @@ -1170,6 +1213,9 @@ static void ieee80211_iface_work(struct 
164                                 break;
165                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
166                         break;
167 +               case NL80211_IFTYPE_WDS:
168 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
169 +                       break;
170                 default:
171                         WARN(1, "frame for unexpected interface type");
172                         break;
173 --- a/net/mac80211/rx.c
174 +++ b/net/mac80211/rx.c
175 @@ -2350,6 +2350,7 @@ ieee80211_rx_h_action(struct ieee80211_r
176                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
177                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
178                     sdata->vif.type != NL80211_IFTYPE_AP &&
179 +                   sdata->vif.type != NL80211_IFTYPE_WDS &&
180                     sdata->vif.type != NL80211_IFTYPE_ADHOC)
181                         break;
182  
183 @@ -2655,14 +2656,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
184  
185         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
186             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
187 -           sdata->vif.type != NL80211_IFTYPE_STATION)
188 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
189 +           sdata->vif.type != NL80211_IFTYPE_WDS)
190                 return RX_DROP_MONITOR;
191  
192         switch (stype) {
193         case cpu_to_le16(IEEE80211_STYPE_AUTH):
194         case cpu_to_le16(IEEE80211_STYPE_BEACON):
195         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
196 -               /* process for all: mesh, mlme, ibss */
197 +               /* process for all: mesh, mlme, ibss, wds */
198                 break;
199         case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
200         case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
201 @@ -2987,10 +2989,16 @@ static int prepare_for_handlers(struct i
202                 }
203                 break;
204         case NL80211_IFTYPE_WDS:
205 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
206 -                       return 0;
207                 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
208                         return 0;
209 +
210 +               if (ieee80211_is_data(hdr->frame_control) ||
211 +                   ieee80211_is_action(hdr->frame_control)) {
212 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
213 +                               return 0;
214 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
215 +                       return 0;
216 +
217                 break;
218         case NL80211_IFTYPE_P2P_DEVICE:
219                 if (!ieee80211_is_public_action(hdr, skb->len) &&
220 --- a/net/mac80211/sta_info.h
221 +++ b/net/mac80211/sta_info.h
222 @@ -32,7 +32,6 @@
223   * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
224   *     frames.
225   * @WLAN_STA_WME: Station is a QoS-STA.
226 - * @WLAN_STA_WDS: Station is one of our WDS peers.
227   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
228   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
229   *     frame to this station is transmitted.
230 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
231         WLAN_STA_AUTHORIZED,
232         WLAN_STA_SHORT_PREAMBLE,
233         WLAN_STA_WME,
234 -       WLAN_STA_WDS,
235         WLAN_STA_CLEAR_PS_FILT,
236         WLAN_STA_MFP,
237         WLAN_STA_BLOCK_BA,
238 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
239 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
240 @@ -324,7 +324,6 @@ struct ath_rx {
241  
242  int ath_startrecv(struct ath_softc *sc);
243  bool ath_stoprecv(struct ath_softc *sc);
244 -void ath_flushrecv(struct ath_softc *sc);
245  u32 ath_calcrxfilter(struct ath_softc *sc);
246  int ath_rx_init(struct ath_softc *sc, int nbufs);
247  void ath_rx_cleanup(struct ath_softc *sc);
248 @@ -641,7 +640,6 @@ void ath_ant_comb_update(struct ath_soft
249  enum sc_op_flags {
250         SC_OP_INVALID,
251         SC_OP_BEACONS,
252 -       SC_OP_RXFLUSH,
253         SC_OP_ANI_RUN,
254         SC_OP_PRIM_STA_VIF,
255         SC_OP_HW_RESET,
256 --- a/drivers/net/wireless/ath/ath9k/beacon.c
257 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
258 @@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_gene
259                                  skb->len, DMA_TO_DEVICE);
260                 dev_kfree_skb_any(skb);
261                 bf->bf_buf_addr = 0;
262 +               bf->bf_mpdu = NULL;
263         }
264  
265         skb = ieee80211_beacon_get(hw, vif);
266 @@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long 
267                 return;
268  
269         bf = ath9k_beacon_generate(sc->hw, vif);
270 -       WARN_ON(!bf);
271  
272         if (sc->beacon.bmisscnt != 0) {
273                 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
274 --- a/drivers/net/wireless/ath/ath9k/debug.c
275 +++ b/drivers/net/wireless/ath/ath9k/debug.c
276 @@ -861,7 +861,6 @@ static ssize_t read_file_recv(struct fil
277         RXS_ERR("RX-LENGTH-ERR", rx_len_err);
278         RXS_ERR("RX-OOM-ERR", rx_oom_err);
279         RXS_ERR("RX-RATE-ERR", rx_rate_err);
280 -       RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
281         RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
282  
283         PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
284 --- a/drivers/net/wireless/ath/ath9k/debug.h
285 +++ b/drivers/net/wireless/ath/ath9k/debug.h
286 @@ -216,7 +216,6 @@ struct ath_tx_stats {
287   * @rx_oom_err:  No. of frames dropped due to OOM issues.
288   * @rx_rate_err:  No. of frames dropped due to rate errors.
289   * @rx_too_many_frags_err:  Frames dropped due to too-many-frags received.
290 - * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
291   * @rx_beacons:  No. of beacons received.
292   * @rx_frags:  No. of rx-fragements received.
293   */
294 @@ -235,7 +234,6 @@ struct ath_rx_stats {
295         u32 rx_oom_err;
296         u32 rx_rate_err;
297         u32 rx_too_many_frags_err;
298 -       u32 rx_drop_rxflush;
299         u32 rx_beacons;
300         u32 rx_frags;
301  };
302 --- a/drivers/net/wireless/ath/ath9k/main.c
303 +++ b/drivers/net/wireless/ath/ath9k/main.c
304 @@ -182,7 +182,7 @@ static void ath_restart_work(struct ath_
305         ath_start_ani(sc);
306  }
307  
308 -static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
309 +static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
310  {
311         struct ath_hw *ah = sc->sc_ah;
312         bool ret = true;
313 @@ -196,19 +196,15 @@ static bool ath_prepare_reset(struct ath
314         ath9k_debug_samp_bb_mac(sc);
315         ath9k_hw_disable_interrupts(ah);
316  
317 +       tasklet_disable(&sc->intr_tq);
318 +
319         if (!ath_stoprecv(sc))
320                 ret = false;
321  
322         if (!ath_drain_all_txq(sc, retry_tx))
323                 ret = false;
324  
325 -       if (!flush) {
326 -               if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
327 -                       ath_rx_tasklet(sc, 1, true);
328 -               ath_rx_tasklet(sc, 1, false);
329 -       } else {
330 -               ath_flushrecv(sc);
331 -       }
332 +       tasklet_enable(&sc->intr_tq);
333  
334         return ret;
335  }
336 @@ -262,7 +258,6 @@ static int ath_reset_internal(struct ath
337         struct ath_common *common = ath9k_hw_common(ah);
338         struct ath9k_hw_cal_data *caldata = NULL;
339         bool fastcc = true;
340 -       bool flush = false;
341         int r;
342  
343         __ath_cancel_work(sc);
344 @@ -276,11 +271,10 @@ static int ath_reset_internal(struct ath
345  
346         if (!hchan) {
347                 fastcc = false;
348 -               flush = true;
349                 hchan = ah->curchan;
350         }
351  
352 -       if (!ath_prepare_reset(sc, retry_tx, flush))
353 +       if (!ath_prepare_reset(sc, retry_tx))
354                 fastcc = false;
355  
356         ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
357 @@ -804,7 +798,7 @@ static void ath9k_stop(struct ieee80211_
358                 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
359         }
360  
361 -       ath_prepare_reset(sc, false, true);
362 +       ath_prepare_reset(sc, false);
363  
364         if (sc->rx.frag) {
365                 dev_kfree_skb_any(sc->rx.frag);
366 --- a/drivers/net/wireless/ath/ath9k/recv.c
367 +++ b/drivers/net/wireless/ath/ath9k/recv.c
368 @@ -280,7 +280,6 @@ int ath_rx_init(struct ath_softc *sc, in
369  
370         spin_lock_init(&sc->sc_pcu_lock);
371         spin_lock_init(&sc->rx.rxbuflock);
372 -       clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
373  
374         common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
375                              sc->sc_ah->caps.rx_status_len;
376 @@ -464,6 +463,13 @@ start_recv:
377         return 0;
378  }
379  
380 +static void ath_flushrecv(struct ath_softc *sc)
381 +{
382 +       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
383 +               ath_rx_tasklet(sc, 1, true);
384 +       ath_rx_tasklet(sc, 1, false);
385 +}
386 +
387  bool ath_stoprecv(struct ath_softc *sc)
388  {
389         struct ath_hw *ah = sc->sc_ah;
390 @@ -474,6 +480,8 @@ bool ath_stoprecv(struct ath_softc *sc)
391         ath9k_hw_setrxfilter(ah, 0);
392         stopped = ath9k_hw_stopdmarecv(ah, &reset);
393  
394 +       ath_flushrecv(sc);
395 +
396         if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
397                 ath_edma_stop_recv(sc);
398         else
399 @@ -490,15 +498,6 @@ bool ath_stoprecv(struct ath_softc *sc)
400         return stopped && !reset;
401  }
402  
403 -void ath_flushrecv(struct ath_softc *sc)
404 -{
405 -       set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
406 -       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
407 -               ath_rx_tasklet(sc, 1, true);
408 -       ath_rx_tasklet(sc, 1, false);
409 -       clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
410 -}
411 -
412  static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
413  {
414         /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
415 @@ -735,6 +734,7 @@ static struct ath_buf *ath_get_next_rx_b
416                         return NULL;
417         }
418  
419 +       list_del(&bf->list);
420         if (!bf->bf_mpdu)
421                 return bf;
422  
423 @@ -1057,9 +1057,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
424  
425         do {
426                 bool decrypt_error = false;
427 -               /* If handling rx interrupt and flush is in progress => exit */
428 -               if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
429 -                       break;
430  
431                 memset(&rs, 0, sizeof(rs));
432                 if (edma)
433 @@ -1102,15 +1099,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
434  
435                 ath_debug_stat_rx(sc, &rs);
436  
437 -               /*
438 -                * If we're asked to flush receive queue, directly
439 -                * chain it back at the queue without processing it.
440 -                */
441 -               if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
442 -                       RX_STAT_INC(rx_drop_rxflush);
443 -                       goto requeue_drop_frag;
444 -               }
445 -
446                 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
447  
448                 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
449 @@ -1245,14 +1233,15 @@ requeue_drop_frag:
450                         sc->rx.frag = NULL;
451                 }
452  requeue:
453 +               list_add_tail(&bf->list, &sc->rx.rxbuf);
454 +               if (!flush)
455 +                       continue;
456 +
457                 if (edma) {
458 -                       list_add_tail(&bf->list, &sc->rx.rxbuf);
459                         ath_rx_edma_buf_link(sc, qtype);
460                 } else {
461 -                       list_move_tail(&bf->list, &sc->rx.rxbuf);
462                         ath_rx_buf_link(sc, bf);
463 -                       if (!flush)
464 -                               ath9k_hw_rxena(ah);
465 +                       ath9k_hw_rxena(ah);
466                 }
467         } while (1);
468