1 --- a/drivers/net/wireless/ath/ath9k/common.h
2 +++ b/drivers/net/wireless/ath/ath9k/common.h
4 #define WME_MAX_BA WME_BA_BMP_SIZE
5 #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
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
16 last_rssi = priv->rx.last_rssi;
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;
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);
31 - if (ieee80211_is_beacon(fc))
32 - priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
36 + priv->ah->stats.avgbrssi = rssi;
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 {
48 +} __packed __aligned(2);
50 struct ieee80211_hdr_3addr {
52 @@ -194,7 +194,7 @@ struct ieee80211_hdr_3addr {
57 +} __packed __aligned(2);
59 struct ieee80211_qos_hdr {
61 @@ -204,7 +204,7 @@ struct ieee80211_qos_hdr {
66 +} __packed __aligned(2);
69 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
70 @@ -581,7 +581,7 @@ struct ieee80211s_hdr {
75 +} __packed __aligned(2);
78 #define MESH_FLAGS_AE_A4 0x1
79 @@ -875,7 +875,7 @@ struct ieee80211_mgmt {
84 +} __packed __aligned(2);
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 {
93 +} __packed __aligned(2);
95 struct ieee80211_cts {
100 +} __packed __aligned(2);
102 struct ieee80211_pspoll {
103 __le16 frame_control;
108 +} __packed __aligned(2);
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);
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)
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" : ""
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 @@ -107,7 +107,7 @@ void ieee80211_recalc_idle(struct ieee80
163 lockdep_assert_held(&local->mtx);
165 - active = !list_empty(&local->chanctx_list);
166 + active = !list_empty(&local->chanctx_list) || local->monitors;
168 if (!local->ops->remain_on_channel) {
169 list_for_each_entry(roc, &local->roc_list, list) {
170 @@ -436,7 +436,6 @@ int ieee80211_do_open(struct wireless_de
171 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
172 struct net_device *dev = wdev->netdev;
173 struct ieee80211_local *local = sdata->local;
174 - struct sta_info *sta;
177 u32 hw_reconf_flags = 0;
178 @@ -595,30 +594,8 @@ int ieee80211_do_open(struct wireless_de
180 set_bit(SDATA_STATE_RUNNING, &sdata->state);
182 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
183 - /* Create STA entry for the WDS peer */
184 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
188 - goto err_del_interface;
191 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
192 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
193 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
195 - res = sta_info_insert(sta);
197 - /* STA has been freed */
198 - goto err_del_interface;
201 - rate_control_rate_init(sta);
202 - netif_carrier_on(dev);
203 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
204 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
205 rcu_assign_pointer(local->p2p_sdata, sdata);
209 * set_multicast_list will be invoked by the networking core
210 @@ -1022,6 +999,72 @@ static void ieee80211_if_setup(struct ne
211 dev->destructor = free_netdev;
214 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
215 + struct sk_buff *skb)
217 + struct ieee80211_local *local = sdata->local;
218 + struct ieee80211_rx_status *rx_status;
219 + struct ieee802_11_elems elems;
220 + struct ieee80211_mgmt *mgmt;
221 + struct sta_info *sta;
226 + enum ieee80211_band band = local->hw.conf.channel->band;
227 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
229 + rx_status = IEEE80211_SKB_RXCB(skb);
230 + mgmt = (struct ieee80211_mgmt *) skb->data;
231 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
233 + if (stype != IEEE80211_STYPE_BEACON)
236 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
237 + if (baselen > skb->len)
240 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
241 + skb->len - baselen, &elems);
243 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
247 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
251 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
259 + sta->last_rx = jiffies;
260 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
262 + if (elems.ht_cap_elem)
263 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
264 + elems.ht_cap_elem, sta);
266 + if (elems.wmm_param)
267 + set_sta_flag(sta, WLAN_STA_WME);
270 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
271 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
272 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
273 + rate_control_rate_init(sta);
274 + sta_info_insert_rcu(sta);
280 static void ieee80211_iface_work(struct work_struct *work)
282 struct ieee80211_sub_if_data *sdata =
283 @@ -1126,6 +1169,9 @@ static void ieee80211_iface_work(struct
285 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
287 + case NL80211_IFTYPE_WDS:
288 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
291 WARN(1, "frame for unexpected interface type");
293 --- a/net/mac80211/rx.c
294 +++ b/net/mac80211/rx.c
295 @@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
296 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
297 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
298 sdata->vif.type != NL80211_IFTYPE_AP &&
299 + sdata->vif.type != NL80211_IFTYPE_WDS &&
300 sdata->vif.type != NL80211_IFTYPE_ADHOC)
303 @@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
305 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
306 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
307 - sdata->vif.type != NL80211_IFTYPE_STATION)
308 + sdata->vif.type != NL80211_IFTYPE_STATION &&
309 + sdata->vif.type != NL80211_IFTYPE_WDS)
310 return RX_DROP_MONITOR;
313 case cpu_to_le16(IEEE80211_STYPE_AUTH):
314 case cpu_to_le16(IEEE80211_STYPE_BEACON):
315 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
316 - /* process for all: mesh, mlme, ibss */
317 + /* process for all: mesh, mlme, ibss, wds */
319 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
320 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
321 @@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
324 case NL80211_IFTYPE_WDS:
325 - if (bssid || !ieee80211_is_data(hdr->frame_control))
327 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
330 + if (ieee80211_is_data(hdr->frame_control) ||
331 + ieee80211_is_action(hdr->frame_control)) {
332 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
334 + } else if (!ieee80211_is_beacon(hdr->frame_control))
338 case NL80211_IFTYPE_P2P_DEVICE:
339 if (!ieee80211_is_public_action(hdr, skb->len) &&
340 --- a/net/mac80211/sta_info.h
341 +++ b/net/mac80211/sta_info.h
343 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
345 * @WLAN_STA_WME: Station is a QoS-STA.
346 - * @WLAN_STA_WDS: Station is one of our WDS peers.
347 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
348 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
349 * frame to this station is transmitted.
350 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
352 WLAN_STA_SHORT_PREAMBLE,
355 WLAN_STA_CLEAR_PS_FILT,
358 --- a/net/mac80211/tx.c
359 +++ b/net/mac80211/tx.c
360 @@ -1231,34 +1231,40 @@ static bool ieee80211_tx_frags(struct ie
361 if (local->queue_stop_reasons[q] ||
362 (!txpending && !skb_queue_empty(&local->pending[q]))) {
363 if (unlikely(info->flags &
364 - IEEE80211_TX_INTFL_OFFCHAN_TX_OK &&
365 - local->queue_stop_reasons[q] &
366 - ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) {
367 + IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) {
368 + if (local->queue_stop_reasons[q] &
369 + ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) {
371 + * Drop off-channel frames if queues
372 + * are stopped for any reason other
373 + * than off-channel operation. Never
376 + spin_unlock_irqrestore(
377 + &local->queue_stop_reason_lock,
379 + ieee80211_purge_tx_queue(&local->hw,
386 - * Drop off-channel frames if queues are stopped
387 - * for any reason other than off-channel
388 - * operation. Never queue them.
389 + * Since queue is stopped, queue up frames for
390 + * later transmission from the tx-pending
391 + * tasklet when the queue is woken again.
393 - spin_unlock_irqrestore(
394 - &local->queue_stop_reason_lock, flags);
395 - ieee80211_purge_tx_queue(&local->hw, skbs);
398 + skb_queue_splice_init(skbs,
399 + &local->pending[q]);
401 + skb_queue_splice_tail_init(skbs,
402 + &local->pending[q]);
404 + spin_unlock_irqrestore(&local->queue_stop_reason_lock,
410 - * Since queue is stopped, queue up frames for later
411 - * transmission from the tx-pending tasklet when the
412 - * queue is woken again.
415 - skb_queue_splice_init(skbs, &local->pending[q]);
417 - skb_queue_splice_tail_init(skbs,
418 - &local->pending[q]);
420 - spin_unlock_irqrestore(&local->queue_stop_reason_lock,
424 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
426 @@ -1848,9 +1854,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
429 if (!is_multicast_ether_addr(skb->data)) {
430 + struct sta_info *next_hop;
431 + bool mpp_lookup = true;
433 mpath = mesh_path_lookup(sdata, skb->data);
436 + mpp_lookup = false;
437 + next_hop = rcu_dereference(mpath->next_hop);
439 + !(mpath->flags & (MESH_PATH_ACTIVE |
440 + MESH_PATH_RESOLVING)))
445 mppath = mpp_path_lookup(sdata, skb->data);
447 + if (mppath && mpath)
448 + mesh_path_del(mpath->sdata, mpath->dst);
452 --- a/net/wireless/nl80211.c
453 +++ b/net/wireless/nl80211.c
454 @@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
455 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
456 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
457 goto nla_put_failure;
458 - if (chan->flags & IEEE80211_CHAN_RADAR) {
459 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
460 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
461 - goto nla_put_failure;
462 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
464 - goto nla_put_failure;
465 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
466 - goto nla_put_failure;
468 + if ((chan->flags & IEEE80211_CHAN_RADAR) &&
469 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
470 + goto nla_put_failure;
471 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
472 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
473 goto nla_put_failure;
474 @@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
475 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
477 goto nla_put_failure;
478 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
479 - c->radar_detect_widths))
480 - goto nla_put_failure;
482 nla_nest_end(msg, nl_combi);
484 @@ -914,48 +904,6 @@ nla_put_failure:
489 -static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
490 - struct sk_buff *msg)
492 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
493 - struct nlattr *nl_tcp;
498 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
502 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
503 - tcp->data_payload_max))
506 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
507 - tcp->data_payload_max))
510 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
513 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
514 - sizeof(*tcp->tok), tcp->tok))
517 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
518 - tcp->data_interval_max))
521 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
522 - tcp->wake_payload_max))
525 - nla_nest_end(msg, nl_tcp);
530 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
531 struct cfg80211_registered_device *dev)
533 @@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
534 goto nla_put_failure;
537 - if (nl80211_send_wowlan_tcp_caps(dev, msg))
538 - goto nla_put_failure;
540 nla_nest_end(msg, nl_wowlan);
543 --- a/net/mac80211/cfg.c
544 +++ b/net/mac80211/cfg.c
545 @@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
546 struct cfg80211_chan_def *chandef)
548 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
549 + struct ieee80211_local *local = wiphy_priv(wiphy);
550 struct ieee80211_chanctx_conf *chanctx_conf;
554 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
555 - if (chanctx_conf) {
556 - *chandef = chanctx_conf->def;
557 + if (local->use_chanctx) {
558 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
559 + if (chanctx_conf) {
560 + *chandef = chanctx_conf->def;
563 + } else if (local->open_count == local->monitors) {
564 + *chandef = local->monitor_chandef;
568 --- a/drivers/net/wireless/ath/ath9k/hw.c
569 +++ b/drivers/net/wireless/ath/ath9k/hw.c
570 @@ -1463,7 +1463,9 @@ static bool ath9k_hw_chip_reset(struct a
571 reset_type = ATH9K_RESET_POWER_ON;
573 reset_type = ATH9K_RESET_COLD;
575 + } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
576 + (REG_READ(ah, AR_CR) & AR_CR_RXE))
577 + reset_type = ATH9K_RESET_COLD;
579 if (!ath9k_hw_set_reset_reg(ah, reset_type))
581 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
582 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
583 @@ -1236,8 +1236,10 @@ static inline void rt2x00lib_set_if_comb
585 if_limit = &rt2x00dev->if_limits_ap;
586 if_limit->max = rt2x00dev->ops->max_ap_intf;
587 - if_limit->types = BIT(NL80211_IFTYPE_AP) |
588 - BIT(NL80211_IFTYPE_MESH_POINT);
589 + if_limit->types = BIT(NL80211_IFTYPE_AP);
590 +#ifdef CONFIG_MAC80211_MESH
591 + if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
595 * Build up AP interface combinations structure.
596 @@ -1309,7 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_de
597 rt2x00dev->hw->wiphy->interface_modes |=
598 BIT(NL80211_IFTYPE_ADHOC) |
599 BIT(NL80211_IFTYPE_AP) |
600 +#ifdef CONFIG_MAC80211_MESH
601 BIT(NL80211_IFTYPE_MESH_POINT) |
603 BIT(NL80211_IFTYPE_WDS);
605 rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;