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 @@ -1848,9 +1848,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
363 if (!is_multicast_ether_addr(skb->data)) {
364 + struct sta_info *next_hop;
365 + bool mpp_lookup = true;
367 mpath = mesh_path_lookup(sdata, skb->data);
370 + mpp_lookup = false;
371 + next_hop = rcu_dereference(mpath->next_hop);
373 + !(mpath->flags & (MESH_PATH_ACTIVE |
374 + MESH_PATH_RESOLVING)))
379 mppath = mpp_path_lookup(sdata, skb->data);
381 + if (mppath && mpath)
382 + mesh_path_del(mpath->sdata, mpath->dst);
386 --- a/net/wireless/nl80211.c
387 +++ b/net/wireless/nl80211.c
388 @@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
389 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
390 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
391 goto nla_put_failure;
392 - if (chan->flags & IEEE80211_CHAN_RADAR) {
393 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
394 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
395 - goto nla_put_failure;
396 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
398 - goto nla_put_failure;
399 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
400 - goto nla_put_failure;
402 + if ((chan->flags & IEEE80211_CHAN_RADAR) &&
403 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
404 + goto nla_put_failure;
405 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
406 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
407 goto nla_put_failure;
408 @@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
409 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
411 goto nla_put_failure;
412 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
413 - c->radar_detect_widths))
414 - goto nla_put_failure;
416 nla_nest_end(msg, nl_combi);
418 @@ -914,48 +904,6 @@ nla_put_failure:
423 -static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
424 - struct sk_buff *msg)
426 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
427 - struct nlattr *nl_tcp;
432 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
436 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
437 - tcp->data_payload_max))
440 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
441 - tcp->data_payload_max))
444 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
447 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
448 - sizeof(*tcp->tok), tcp->tok))
451 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
452 - tcp->data_interval_max))
455 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
456 - tcp->wake_payload_max))
459 - nla_nest_end(msg, nl_tcp);
464 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
465 struct cfg80211_registered_device *dev)
467 @@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
468 goto nla_put_failure;
471 - if (nl80211_send_wowlan_tcp_caps(dev, msg))
472 - goto nla_put_failure;
474 nla_nest_end(msg, nl_wowlan);
477 --- a/net/mac80211/cfg.c
478 +++ b/net/mac80211/cfg.c
479 @@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
480 struct cfg80211_chan_def *chandef)
482 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
483 + struct ieee80211_local *local = wiphy_priv(wiphy);
484 struct ieee80211_chanctx_conf *chanctx_conf;
488 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
489 - if (chanctx_conf) {
490 - *chandef = chanctx_conf->def;
491 + if (local->use_chanctx) {
492 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
493 + if (chanctx_conf) {
494 + *chandef = chanctx_conf->def;
497 + } else if (local->open_count == local->monitors) {
498 + *chandef = local->monitor_chandef;