8a5fa6e50233142dd7d197214d576d4d20ae260c
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/net/mac80211/agg-rx.c
2 +++ b/net/mac80211/agg-rx.c
3 @@ -204,6 +204,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 @@ -527,6 +528,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 @@ -66,11 +66,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%s%s",
39 +                           "%s%s%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/ht.c
49 +++ b/net/mac80211/ht.c
50 @@ -281,13 +281,14 @@ void ieee80211_ba_session_work(struct wo
51                                 sta, tid, WLAN_BACK_RECIPIENT,
52                                 WLAN_REASON_UNSPECIFIED, true);
53  
54 +               spin_lock_bh(&sta->lock);
55 +
56                 tid_tx = sta->ampdu_mlme.tid_start_tx[tid];
57                 if (tid_tx) {
58                         /*
59                          * Assign it over to the normal tid_tx array
60                          * where it "goes live".
61                          */
62 -                       spin_lock_bh(&sta->lock);
63  
64                         sta->ampdu_mlme.tid_start_tx[tid] = NULL;
65                         /* could there be a race? */
66 @@ -300,6 +301,7 @@ void ieee80211_ba_session_work(struct wo
67                         ieee80211_tx_ba_session_handle_start(sta, tid);
68                         continue;
69                 }
70 +               spin_unlock_bh(&sta->lock);
71  
72                 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
73                 if (tid_tx && test_and_clear_bit(HT_AGG_STATE_WANT_STOP,
74 --- a/net/mac80211/iface.c
75 +++ b/net/mac80211/iface.c
76 @@ -463,7 +463,6 @@ int ieee80211_do_open(struct wireless_de
77         struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
78         struct net_device *dev = wdev->netdev;
79         struct ieee80211_local *local = sdata->local;
80 -       struct sta_info *sta;
81         u32 changed = 0;
82         int res;
83         u32 hw_reconf_flags = 0;
84 @@ -629,30 +628,8 @@ int ieee80211_do_open(struct wireless_de
85  
86         set_bit(SDATA_STATE_RUNNING, &sdata->state);
87  
88 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
89 -               /* Create STA entry for the WDS peer */
90 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
91 -                                    GFP_KERNEL);
92 -               if (!sta) {
93 -                       res = -ENOMEM;
94 -                       goto err_del_interface;
95 -               }
96 -
97 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
98 -               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
99 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
100 -
101 -               res = sta_info_insert(sta);
102 -               if (res) {
103 -                       /* STA has been freed */
104 -                       goto err_del_interface;
105 -               }
106 -
107 -               rate_control_rate_init(sta);
108 -               netif_carrier_on(dev);
109 -       } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
110 +       if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
111                 rcu_assign_pointer(local->p2p_sdata, sdata);
112 -       }
113  
114         /*
115          * set_multicast_list will be invoked by the networking core
116 @@ -1116,6 +1093,74 @@ static void ieee80211_if_setup(struct ne
117         dev->destructor = free_netdev;
118  }
119  
120 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
121 +                                        struct sk_buff *skb)
122 +{
123 +       struct ieee80211_local *local = sdata->local;
124 +       struct ieee80211_rx_status *rx_status;
125 +       struct ieee802_11_elems elems;
126 +       struct ieee80211_mgmt *mgmt;
127 +       struct sta_info *sta;
128 +       size_t baselen;
129 +       u32 rates = 0;
130 +       u16 stype;
131 +       bool new = false;
132 +       enum ieee80211_band band;
133 +       struct ieee80211_supported_band *sband;
134 +
135 +       rx_status = IEEE80211_SKB_RXCB(skb);
136 +       band = rx_status->band;
137 +       sband = local->hw.wiphy->bands[band];
138 +       mgmt = (struct ieee80211_mgmt *) skb->data;
139 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
140 +
141 +       if (stype != IEEE80211_STYPE_BEACON)
142 +               return;
143 +
144 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
145 +       if (baselen > skb->len)
146 +               return;
147 +
148 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
149 +                              skb->len - baselen, false, &elems);
150 +
151 +       rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
152 +
153 +       rcu_read_lock();
154 +
155 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
156 +
157 +       if (!sta) {
158 +               rcu_read_unlock();
159 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
160 +                                    GFP_KERNEL);
161 +               if (!sta)
162 +                       return;
163 +
164 +               new = true;
165 +       }
166 +
167 +       sta->last_rx = jiffies;
168 +       sta->sta.supp_rates[band] = rates;
169 +
170 +       if (elems.ht_cap_elem)
171 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
172 +                               elems.ht_cap_elem, sta);
173 +
174 +       if (elems.wmm_param)
175 +               set_sta_flag(sta, WLAN_STA_WME);
176 +
177 +       if (new) {
178 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
179 +               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
180 +               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
181 +               rate_control_rate_init(sta);
182 +               sta_info_insert_rcu(sta);
183 +       }
184 +
185 +       rcu_read_unlock();
186 +}
187 +
188  static void ieee80211_iface_work(struct work_struct *work)
189  {
190         struct ieee80211_sub_if_data *sdata =
191 @@ -1220,6 +1265,9 @@ static void ieee80211_iface_work(struct 
192                                 break;
193                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
194                         break;
195 +               case NL80211_IFTYPE_WDS:
196 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
197 +                       break;
198                 default:
199                         WARN(1, "frame for unexpected interface type");
200                         break;
201 --- a/net/mac80211/rx.c
202 +++ b/net/mac80211/rx.c
203 @@ -2369,6 +2369,7 @@ ieee80211_rx_h_action(struct ieee80211_r
204                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
205                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
206                     sdata->vif.type != NL80211_IFTYPE_AP &&
207 +                   sdata->vif.type != NL80211_IFTYPE_WDS &&
208                     sdata->vif.type != NL80211_IFTYPE_ADHOC)
209                         break;
210  
211 @@ -2720,14 +2721,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
212  
213         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
214             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
215 -           sdata->vif.type != NL80211_IFTYPE_STATION)
216 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
217 +           sdata->vif.type != NL80211_IFTYPE_WDS)
218                 return RX_DROP_MONITOR;
219  
220         switch (stype) {
221         case cpu_to_le16(IEEE80211_STYPE_AUTH):
222         case cpu_to_le16(IEEE80211_STYPE_BEACON):
223         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
224 -               /* process for all: mesh, mlme, ibss */
225 +               /* process for all: mesh, mlme, ibss, wds */
226                 break;
227         case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
228         case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
229 @@ -3059,10 +3061,16 @@ static int prepare_for_handlers(struct i
230                 }
231                 break;
232         case NL80211_IFTYPE_WDS:
233 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
234 -                       return 0;
235                 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
236                         return 0;
237 +
238 +               if (ieee80211_is_data(hdr->frame_control) ||
239 +                   ieee80211_is_action(hdr->frame_control)) {
240 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
241 +                               return 0;
242 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
243 +                       return 0;
244 +
245                 break;
246         case NL80211_IFTYPE_P2P_DEVICE:
247                 if (!ieee80211_is_public_action(hdr, skb->len) &&
248 --- a/net/mac80211/sta_info.c
249 +++ b/net/mac80211/sta_info.c
250 @@ -149,6 +149,7 @@ static void cleanup_single_sta(struct st
251          * directly by station destruction.
252          */
253         for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
254 +               kfree(sta->ampdu_mlme.tid_start_tx[i]);
255                 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
256                 if (!tid_tx)
257                         continue;
258 --- a/net/mac80211/sta_info.h
259 +++ b/net/mac80211/sta_info.h
260 @@ -32,7 +32,6 @@
261   * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
262   *     frames.
263   * @WLAN_STA_WME: Station is a QoS-STA.
264 - * @WLAN_STA_WDS: Station is one of our WDS peers.
265   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
266   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
267   *     frame to this station is transmitted.
268 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
269         WLAN_STA_AUTHORIZED,
270         WLAN_STA_SHORT_PREAMBLE,
271         WLAN_STA_WME,
272 -       WLAN_STA_WDS,
273         WLAN_STA_CLEAR_PS_FILT,
274         WLAN_STA_MFP,
275         WLAN_STA_BLOCK_BA,
276 @@ -203,6 +201,7 @@ struct tid_ampdu_rx {
277   *     driver requested to close until the work for it runs
278   * @mtx: mutex to protect all TX data (except non-NULL assignments
279   *     to tid_tx[idx], which are protected by the sta spinlock)
280 + *     tid_start_tx is also protected by sta->lock.
281   */
282  struct sta_ampdu_mlme {
283         struct mutex mtx;
284 --- a/drivers/net/wireless/ath/ath9k/xmit.c
285 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
286 @@ -1778,9 +1778,13 @@ static void ath_tx_txqaddbuf(struct ath_
287         }
288  
289         if (!internal) {
290 -               txq->axq_depth++;
291 -               if (bf_is_ampdu_not_probing(bf))
292 -                       txq->axq_ampdu_depth++;
293 +               while (bf) {
294 +                       txq->axq_depth++;
295 +                       if (bf_is_ampdu_not_probing(bf))
296 +                               txq->axq_ampdu_depth++;
297 +
298 +                       bf = bf->bf_lastbf->bf_next;
299 +               }
300         }
301  }
302