mac80211: update to wireless-testing 2013-02-22
[openwrt/staging/jow.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/common.h
2 +++ b/drivers/net/wireless/ath/ath9k/common.h
3 @@ -27,7 +27,7 @@
4 #define WME_MAX_BA WME_BA_BMP_SIZE
5 #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
6
7 -#define ATH_RSSI_DUMMY_MARKER 0x127
8 +#define ATH_RSSI_DUMMY_MARKER 127
9 #define ATH_RSSI_LPF_LEN 10
10 #define RSSI_LPF_THRESHOLD -20
11 #define ATH_RSSI_EP_MULTIPLIER (1<<7)
12 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
13 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
14 @@ -1067,15 +1067,19 @@ static bool ath9k_rx_prepare(struct ath9
15
16 last_rssi = priv->rx.last_rssi;
17
18 - if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
19 - rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
20 - ATH_RSSI_EP_MULTIPLIER);
21 + if (ieee80211_is_beacon(hdr->frame_control) &&
22 + !is_zero_ether_addr(common->curbssid) &&
23 + ether_addr_equal(hdr->addr3, common->curbssid)) {
24 + s8 rssi = rxbuf->rxstatus.rs_rssi;
25
26 - if (rxbuf->rxstatus.rs_rssi < 0)
27 - rxbuf->rxstatus.rs_rssi = 0;
28 + if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
29 + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
30
31 - if (ieee80211_is_beacon(fc))
32 - priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
33 + if (rssi < 0)
34 + rssi = 0;
35 +
36 + priv->ah->stats.avgbrssi = rssi;
37 + }
38
39 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp);
40 rx_status->band = hw->conf.channel->band;
41 --- a/include/linux/ieee80211.h
42 +++ b/include/linux/ieee80211.h
43 @@ -185,7 +185,7 @@ struct ieee80211_hdr {
44 u8 addr3[6];
45 __le16 seq_ctrl;
46 u8 addr4[6];
47 -} __packed;
48 +} __packed __aligned(2);
49
50 struct ieee80211_hdr_3addr {
51 __le16 frame_control;
52 @@ -194,7 +194,7 @@ struct ieee80211_hdr_3addr {
53 u8 addr2[6];
54 u8 addr3[6];
55 __le16 seq_ctrl;
56 -} __packed;
57 +} __packed __aligned(2);
58
59 struct ieee80211_qos_hdr {
60 __le16 frame_control;
61 @@ -204,7 +204,7 @@ struct ieee80211_qos_hdr {
62 u8 addr3[6];
63 __le16 seq_ctrl;
64 __le16 qos_ctrl;
65 -} __packed;
66 +} __packed __aligned(2);
67
68 /**
69 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
70 @@ -581,7 +581,7 @@ struct ieee80211s_hdr {
71 __le32 seqnum;
72 u8 eaddr1[6];
73 u8 eaddr2[6];
74 -} __packed;
75 +} __packed __aligned(2);
76
77 /* Mesh flags */
78 #define MESH_FLAGS_AE_A4 0x1
79 @@ -875,7 +875,7 @@ struct ieee80211_mgmt {
80 } u;
81 } __packed action;
82 } u;
83 -} __packed;
84 +} __packed __aligned(2);
85
86 /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
87 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
88 @@ -906,20 +906,20 @@ struct ieee80211_rts {
89 __le16 duration;
90 u8 ra[6];
91 u8 ta[6];
92 -} __packed;
93 +} __packed __aligned(2);
94
95 struct ieee80211_cts {
96 __le16 frame_control;
97 __le16 duration;
98 u8 ra[6];
99 -} __packed;
100 +} __packed __aligned(2);
101
102 struct ieee80211_pspoll {
103 __le16 frame_control;
104 __le16 aid;
105 u8 bssid[6];
106 u8 ta[6];
107 -} __packed;
108 +} __packed __aligned(2);
109
110 /* TDLS */
111
112 --- a/net/mac80211/agg-rx.c
113 +++ b/net/mac80211/agg-rx.c
114 @@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
115 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
116 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
117 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
118 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
119 + memcpy(mgmt->bssid, da, ETH_ALEN);
120
121 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
122 IEEE80211_STYPE_ACTION);
123 --- a/net/mac80211/agg-tx.c
124 +++ b/net/mac80211/agg-tx.c
125 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
126 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
127 if (sdata->vif.type == NL80211_IFTYPE_AP ||
128 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
129 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
130 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
131 + sdata->vif.type == NL80211_IFTYPE_WDS)
132 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
133 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
134 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
135 @@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
136 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
137 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
138 sdata->vif.type != NL80211_IFTYPE_AP &&
139 + sdata->vif.type != NL80211_IFTYPE_WDS &&
140 sdata->vif.type != NL80211_IFTYPE_ADHOC)
141 return -EINVAL;
142
143 --- a/net/mac80211/debugfs_sta.c
144 +++ b/net/mac80211/debugfs_sta.c
145 @@ -65,11 +65,11 @@ static ssize_t sta_flags_read(struct fil
146 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
147
148 int res = scnprintf(buf, sizeof(buf),
149 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
150 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
151 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
152 TEST(PS_DRIVER), TEST(AUTHORIZED),
153 TEST(SHORT_PREAMBLE),
154 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
155 + TEST(WME), TEST(CLEAR_PS_FILT),
156 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
157 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
158 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
159 --- a/net/mac80211/iface.c
160 +++ b/net/mac80211/iface.c
161 @@ -436,7 +436,6 @@ int ieee80211_do_open(struct wireless_de
162 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
163 struct net_device *dev = wdev->netdev;
164 struct ieee80211_local *local = sdata->local;
165 - struct sta_info *sta;
166 u32 changed = 0;
167 int res;
168 u32 hw_reconf_flags = 0;
169 @@ -595,30 +594,8 @@ int ieee80211_do_open(struct wireless_de
170
171 set_bit(SDATA_STATE_RUNNING, &sdata->state);
172
173 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
174 - /* Create STA entry for the WDS peer */
175 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
176 - GFP_KERNEL);
177 - if (!sta) {
178 - res = -ENOMEM;
179 - goto err_del_interface;
180 - }
181 -
182 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
183 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
184 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
185 -
186 - res = sta_info_insert(sta);
187 - if (res) {
188 - /* STA has been freed */
189 - goto err_del_interface;
190 - }
191 -
192 - rate_control_rate_init(sta);
193 - netif_carrier_on(dev);
194 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
195 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
196 rcu_assign_pointer(local->p2p_sdata, sdata);
197 - }
198
199 /*
200 * set_multicast_list will be invoked by the networking core
201 @@ -1022,6 +999,72 @@ static void ieee80211_if_setup(struct ne
202 dev->destructor = free_netdev;
203 }
204
205 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
206 + struct sk_buff *skb)
207 +{
208 + struct ieee80211_local *local = sdata->local;
209 + struct ieee80211_rx_status *rx_status;
210 + struct ieee802_11_elems elems;
211 + struct ieee80211_mgmt *mgmt;
212 + struct sta_info *sta;
213 + size_t baselen;
214 + u32 rates = 0;
215 + u16 stype;
216 + bool new = false;
217 + enum ieee80211_band band = local->hw.conf.channel->band;
218 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
219 +
220 + rx_status = IEEE80211_SKB_RXCB(skb);
221 + mgmt = (struct ieee80211_mgmt *) skb->data;
222 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
223 +
224 + if (stype != IEEE80211_STYPE_BEACON)
225 + return;
226 +
227 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
228 + if (baselen > skb->len)
229 + return;
230 +
231 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
232 + skb->len - baselen, &elems);
233 +
234 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
235 +
236 + rcu_read_lock();
237 +
238 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
239 +
240 + if (!sta) {
241 + rcu_read_unlock();
242 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
243 + GFP_KERNEL);
244 + if (!sta)
245 + return;
246 +
247 + new = true;
248 + }
249 +
250 + sta->last_rx = jiffies;
251 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
252 +
253 + if (elems.ht_cap_elem)
254 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
255 + elems.ht_cap_elem, sta);
256 +
257 + if (elems.wmm_param)
258 + set_sta_flag(sta, WLAN_STA_WME);
259 +
260 + if (new) {
261 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
262 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
263 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
264 + rate_control_rate_init(sta);
265 + sta_info_insert_rcu(sta);
266 + }
267 +
268 + rcu_read_unlock();
269 +}
270 +
271 static void ieee80211_iface_work(struct work_struct *work)
272 {
273 struct ieee80211_sub_if_data *sdata =
274 @@ -1126,6 +1169,9 @@ static void ieee80211_iface_work(struct
275 break;
276 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
277 break;
278 + case NL80211_IFTYPE_WDS:
279 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
280 + break;
281 default:
282 WARN(1, "frame for unexpected interface type");
283 break;
284 --- a/net/mac80211/rx.c
285 +++ b/net/mac80211/rx.c
286 @@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
287 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
288 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
289 sdata->vif.type != NL80211_IFTYPE_AP &&
290 + sdata->vif.type != NL80211_IFTYPE_WDS &&
291 sdata->vif.type != NL80211_IFTYPE_ADHOC)
292 break;
293
294 @@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
295
296 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
297 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
298 - sdata->vif.type != NL80211_IFTYPE_STATION)
299 + sdata->vif.type != NL80211_IFTYPE_STATION &&
300 + sdata->vif.type != NL80211_IFTYPE_WDS)
301 return RX_DROP_MONITOR;
302
303 switch (stype) {
304 case cpu_to_le16(IEEE80211_STYPE_AUTH):
305 case cpu_to_le16(IEEE80211_STYPE_BEACON):
306 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
307 - /* process for all: mesh, mlme, ibss */
308 + /* process for all: mesh, mlme, ibss, wds */
309 break;
310 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
311 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
312 @@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
313 }
314 break;
315 case NL80211_IFTYPE_WDS:
316 - if (bssid || !ieee80211_is_data(hdr->frame_control))
317 - return 0;
318 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
319 return 0;
320 +
321 + if (ieee80211_is_data(hdr->frame_control) ||
322 + ieee80211_is_action(hdr->frame_control)) {
323 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
324 + return 0;
325 + } else if (!ieee80211_is_beacon(hdr->frame_control))
326 + return 0;
327 +
328 break;
329 case NL80211_IFTYPE_P2P_DEVICE:
330 if (!ieee80211_is_public_action(hdr, skb->len) &&
331 --- a/net/mac80211/sta_info.h
332 +++ b/net/mac80211/sta_info.h
333 @@ -32,7 +32,6 @@
334 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
335 * frames.
336 * @WLAN_STA_WME: Station is a QoS-STA.
337 - * @WLAN_STA_WDS: Station is one of our WDS peers.
338 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
339 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
340 * frame to this station is transmitted.
341 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
342 WLAN_STA_AUTHORIZED,
343 WLAN_STA_SHORT_PREAMBLE,
344 WLAN_STA_WME,
345 - WLAN_STA_WDS,
346 WLAN_STA_CLEAR_PS_FILT,
347 WLAN_STA_MFP,
348 WLAN_STA_BLOCK_BA,
349 --- a/net/mac80211/tx.c
350 +++ b/net/mac80211/tx.c
351 @@ -1848,9 +1848,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
352 }
353
354 if (!is_multicast_ether_addr(skb->data)) {
355 + struct sta_info *next_hop;
356 + bool mpp_lookup = true;
357 +
358 mpath = mesh_path_lookup(sdata, skb->data);
359 - if (!mpath)
360 + if (mpath) {
361 + mpp_lookup = false;
362 + next_hop = rcu_dereference(mpath->next_hop);
363 + if (!next_hop ||
364 + !(mpath->flags & (MESH_PATH_ACTIVE |
365 + MESH_PATH_RESOLVING)))
366 + mpp_lookup = true;
367 + }
368 +
369 + if (mpp_lookup)
370 mppath = mpp_path_lookup(sdata, skb->data);
371 +
372 + if (mppath && mpath)
373 + mesh_path_del(mpath->sdata, mpath->dst);
374 }
375
376 /*
377 --- a/net/wireless/nl80211.c
378 +++ b/net/wireless/nl80211.c
379 @@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
380 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
381 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
382 goto nla_put_failure;
383 - if (chan->flags & IEEE80211_CHAN_RADAR) {
384 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
385 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
386 - goto nla_put_failure;
387 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
388 - chan->dfs_state))
389 - goto nla_put_failure;
390 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
391 - goto nla_put_failure;
392 - }
393 + if ((chan->flags & IEEE80211_CHAN_RADAR) &&
394 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
395 + goto nla_put_failure;
396 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
397 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
398 goto nla_put_failure;
399 @@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
400 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
401 c->max_interfaces))
402 goto nla_put_failure;
403 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
404 - c->radar_detect_widths))
405 - goto nla_put_failure;
406
407 nla_nest_end(msg, nl_combi);
408 }
409 @@ -914,48 +904,6 @@ nla_put_failure:
410 return -ENOBUFS;
411 }
412
413 -#ifdef CONFIG_PM
414 -static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
415 - struct sk_buff *msg)
416 -{
417 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
418 - struct nlattr *nl_tcp;
419 -
420 - if (!tcp)
421 - return 0;
422 -
423 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
424 - if (!nl_tcp)
425 - return -ENOBUFS;
426 -
427 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
428 - tcp->data_payload_max))
429 - return -ENOBUFS;
430 -
431 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
432 - tcp->data_payload_max))
433 - return -ENOBUFS;
434 -
435 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
436 - return -ENOBUFS;
437 -
438 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
439 - sizeof(*tcp->tok), tcp->tok))
440 - return -ENOBUFS;
441 -
442 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
443 - tcp->data_interval_max))
444 - return -ENOBUFS;
445 -
446 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
447 - tcp->wake_payload_max))
448 - return -ENOBUFS;
449 -
450 - nla_nest_end(msg, nl_tcp);
451 - return 0;
452 -}
453 -#endif
454 -
455 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
456 struct cfg80211_registered_device *dev)
457 {
458 @@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
459 goto nla_put_failure;
460 }
461
462 - if (nl80211_send_wowlan_tcp_caps(dev, msg))
463 - goto nla_put_failure;
464 -
465 nla_nest_end(msg, nl_wowlan);
466 }
467 #endif