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 @@ -78,7 +78,7 @@ void ieee80211_recalc_txpower(struct iee
162 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER);
165 -static u32 ieee80211_idle_off(struct ieee80211_local *local)
166 +u32 ieee80211_idle_off(struct ieee80211_local *local)
168 if (!(local->hw.conf.flags & IEEE80211_CONF_IDLE))
170 @@ -107,7 +107,7 @@ void ieee80211_recalc_idle(struct ieee80
172 lockdep_assert_held(&local->mtx);
174 - active = !list_empty(&local->chanctx_list);
175 + active = !list_empty(&local->chanctx_list) || local->monitors;
177 if (!local->ops->remain_on_channel) {
178 list_for_each_entry(roc, &local->roc_list, list) {
179 @@ -436,7 +436,6 @@ int ieee80211_do_open(struct wireless_de
180 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
181 struct net_device *dev = wdev->netdev;
182 struct ieee80211_local *local = sdata->local;
183 - struct sta_info *sta;
186 u32 hw_reconf_flags = 0;
187 @@ -541,6 +540,9 @@ int ieee80211_do_open(struct wireless_de
189 ieee80211_adjust_monitor_flags(sdata, 1);
190 ieee80211_configure_filter(local);
191 + mutex_lock(&local->mtx);
192 + ieee80211_recalc_idle(local);
193 + mutex_unlock(&local->mtx);
195 netif_carrier_on(dev);
197 @@ -595,30 +597,8 @@ int ieee80211_do_open(struct wireless_de
199 set_bit(SDATA_STATE_RUNNING, &sdata->state);
201 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
202 - /* Create STA entry for the WDS peer */
203 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
207 - goto err_del_interface;
210 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
211 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
212 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
214 - res = sta_info_insert(sta);
216 - /* STA has been freed */
217 - goto err_del_interface;
220 - rate_control_rate_init(sta);
221 - netif_carrier_on(dev);
222 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
223 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
224 rcu_assign_pointer(local->p2p_sdata, sdata);
228 * set_multicast_list will be invoked by the networking core
229 @@ -817,6 +797,9 @@ static void ieee80211_do_stop(struct iee
231 ieee80211_adjust_monitor_flags(sdata, -1);
232 ieee80211_configure_filter(local);
233 + mutex_lock(&local->mtx);
234 + ieee80211_recalc_idle(local);
235 + mutex_unlock(&local->mtx);
237 case NL80211_IFTYPE_P2P_DEVICE:
238 /* relies on synchronize_rcu() below */
239 @@ -1022,6 +1005,72 @@ static void ieee80211_if_setup(struct ne
240 dev->destructor = free_netdev;
243 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
244 + struct sk_buff *skb)
246 + struct ieee80211_local *local = sdata->local;
247 + struct ieee80211_rx_status *rx_status;
248 + struct ieee802_11_elems elems;
249 + struct ieee80211_mgmt *mgmt;
250 + struct sta_info *sta;
255 + enum ieee80211_band band = local->hw.conf.channel->band;
256 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
258 + rx_status = IEEE80211_SKB_RXCB(skb);
259 + mgmt = (struct ieee80211_mgmt *) skb->data;
260 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
262 + if (stype != IEEE80211_STYPE_BEACON)
265 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
266 + if (baselen > skb->len)
269 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
270 + skb->len - baselen, &elems);
272 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
276 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
280 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
288 + sta->last_rx = jiffies;
289 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
291 + if (elems.ht_cap_elem)
292 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
293 + elems.ht_cap_elem, sta);
295 + if (elems.wmm_param)
296 + set_sta_flag(sta, WLAN_STA_WME);
299 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
300 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
301 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
302 + rate_control_rate_init(sta);
303 + sta_info_insert_rcu(sta);
309 static void ieee80211_iface_work(struct work_struct *work)
311 struct ieee80211_sub_if_data *sdata =
312 @@ -1126,6 +1175,9 @@ static void ieee80211_iface_work(struct
314 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
316 + case NL80211_IFTYPE_WDS:
317 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
320 WARN(1, "frame for unexpected interface type");
322 --- a/net/mac80211/rx.c
323 +++ b/net/mac80211/rx.c
324 @@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
325 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
326 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
327 sdata->vif.type != NL80211_IFTYPE_AP &&
328 + sdata->vif.type != NL80211_IFTYPE_WDS &&
329 sdata->vif.type != NL80211_IFTYPE_ADHOC)
332 @@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
334 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
335 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
336 - sdata->vif.type != NL80211_IFTYPE_STATION)
337 + sdata->vif.type != NL80211_IFTYPE_STATION &&
338 + sdata->vif.type != NL80211_IFTYPE_WDS)
339 return RX_DROP_MONITOR;
342 case cpu_to_le16(IEEE80211_STYPE_AUTH):
343 case cpu_to_le16(IEEE80211_STYPE_BEACON):
344 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
345 - /* process for all: mesh, mlme, ibss */
346 + /* process for all: mesh, mlme, ibss, wds */
348 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
349 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
350 @@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
353 case NL80211_IFTYPE_WDS:
354 - if (bssid || !ieee80211_is_data(hdr->frame_control))
356 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
359 + if (ieee80211_is_data(hdr->frame_control) ||
360 + ieee80211_is_action(hdr->frame_control)) {
361 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
363 + } else if (!ieee80211_is_beacon(hdr->frame_control))
367 case NL80211_IFTYPE_P2P_DEVICE:
368 if (!ieee80211_is_public_action(hdr, skb->len) &&
369 --- a/net/mac80211/sta_info.h
370 +++ b/net/mac80211/sta_info.h
372 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
374 * @WLAN_STA_WME: Station is a QoS-STA.
375 - * @WLAN_STA_WDS: Station is one of our WDS peers.
376 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
377 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
378 * frame to this station is transmitted.
379 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
381 WLAN_STA_SHORT_PREAMBLE,
384 WLAN_STA_CLEAR_PS_FILT,
387 --- a/net/mac80211/tx.c
388 +++ b/net/mac80211/tx.c
389 @@ -1231,34 +1231,40 @@ static bool ieee80211_tx_frags(struct ie
390 if (local->queue_stop_reasons[q] ||
391 (!txpending && !skb_queue_empty(&local->pending[q]))) {
392 if (unlikely(info->flags &
393 - IEEE80211_TX_INTFL_OFFCHAN_TX_OK &&
394 - local->queue_stop_reasons[q] &
395 - ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) {
396 + IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) {
397 + if (local->queue_stop_reasons[q] &
398 + ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) {
400 + * Drop off-channel frames if queues
401 + * are stopped for any reason other
402 + * than off-channel operation. Never
405 + spin_unlock_irqrestore(
406 + &local->queue_stop_reason_lock,
408 + ieee80211_purge_tx_queue(&local->hw,
415 - * Drop off-channel frames if queues are stopped
416 - * for any reason other than off-channel
417 - * operation. Never queue them.
418 + * Since queue is stopped, queue up frames for
419 + * later transmission from the tx-pending
420 + * tasklet when the queue is woken again.
422 - spin_unlock_irqrestore(
423 - &local->queue_stop_reason_lock, flags);
424 - ieee80211_purge_tx_queue(&local->hw, skbs);
427 + skb_queue_splice_init(skbs,
428 + &local->pending[q]);
430 + skb_queue_splice_tail_init(skbs,
431 + &local->pending[q]);
433 + spin_unlock_irqrestore(&local->queue_stop_reason_lock,
439 - * Since queue is stopped, queue up frames for later
440 - * transmission from the tx-pending tasklet when the
441 - * queue is woken again.
444 - skb_queue_splice_init(skbs, &local->pending[q]);
446 - skb_queue_splice_tail_init(skbs,
447 - &local->pending[q]);
449 - spin_unlock_irqrestore(&local->queue_stop_reason_lock,
453 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
455 @@ -1848,9 +1854,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
458 if (!is_multicast_ether_addr(skb->data)) {
459 + struct sta_info *next_hop;
460 + bool mpp_lookup = true;
462 mpath = mesh_path_lookup(sdata, skb->data);
465 + mpp_lookup = false;
466 + next_hop = rcu_dereference(mpath->next_hop);
468 + !(mpath->flags & (MESH_PATH_ACTIVE |
469 + MESH_PATH_RESOLVING)))
474 mppath = mpp_path_lookup(sdata, skb->data);
476 + if (mppath && mpath)
477 + mesh_path_del(mpath->sdata, mpath->dst);
481 --- a/net/wireless/nl80211.c
482 +++ b/net/wireless/nl80211.c
483 @@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
484 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
485 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
486 goto nla_put_failure;
487 - if (chan->flags & IEEE80211_CHAN_RADAR) {
488 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
489 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
490 - goto nla_put_failure;
491 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
493 - goto nla_put_failure;
494 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
495 - goto nla_put_failure;
497 + if ((chan->flags & IEEE80211_CHAN_RADAR) &&
498 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
499 + goto nla_put_failure;
500 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
501 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
502 goto nla_put_failure;
503 @@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
504 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
506 goto nla_put_failure;
507 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
508 - c->radar_detect_widths))
509 - goto nla_put_failure;
511 nla_nest_end(msg, nl_combi);
513 @@ -914,48 +904,6 @@ nla_put_failure:
518 -static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
519 - struct sk_buff *msg)
521 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
522 - struct nlattr *nl_tcp;
527 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
531 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
532 - tcp->data_payload_max))
535 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
536 - tcp->data_payload_max))
539 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
542 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
543 - sizeof(*tcp->tok), tcp->tok))
546 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
547 - tcp->data_interval_max))
550 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
551 - tcp->wake_payload_max))
554 - nla_nest_end(msg, nl_tcp);
559 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
560 struct cfg80211_registered_device *dev)
562 @@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
563 goto nla_put_failure;
566 - if (nl80211_send_wowlan_tcp_caps(dev, msg))
567 - goto nla_put_failure;
569 nla_nest_end(msg, nl_wowlan);
572 --- a/net/mac80211/cfg.c
573 +++ b/net/mac80211/cfg.c
574 @@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
575 struct cfg80211_chan_def *chandef)
577 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
578 + struct ieee80211_local *local = wiphy_priv(wiphy);
579 struct ieee80211_chanctx_conf *chanctx_conf;
583 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
584 - if (chanctx_conf) {
585 - *chandef = chanctx_conf->def;
586 + if (local->use_chanctx) {
587 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
588 + if (chanctx_conf) {
589 + *chandef = chanctx_conf->def;
592 + } else if (local->open_count == local->monitors) {
593 + *chandef = local->monitor_chandef;
597 --- a/drivers/net/wireless/ath/ath9k/hw.c
598 +++ b/drivers/net/wireless/ath/ath9k/hw.c
599 @@ -1463,7 +1463,9 @@ static bool ath9k_hw_chip_reset(struct a
600 reset_type = ATH9K_RESET_POWER_ON;
602 reset_type = ATH9K_RESET_COLD;
604 + } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
605 + (REG_READ(ah, AR_CR) & AR_CR_RXE))
606 + reset_type = ATH9K_RESET_COLD;
608 if (!ath9k_hw_set_reset_reg(ah, reset_type))
610 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
611 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
612 @@ -1236,8 +1236,10 @@ static inline void rt2x00lib_set_if_comb
614 if_limit = &rt2x00dev->if_limits_ap;
615 if_limit->max = rt2x00dev->ops->max_ap_intf;
616 - if_limit->types = BIT(NL80211_IFTYPE_AP) |
617 - BIT(NL80211_IFTYPE_MESH_POINT);
618 + if_limit->types = BIT(NL80211_IFTYPE_AP);
619 +#ifdef CONFIG_MAC80211_MESH
620 + if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
624 * Build up AP interface combinations structure.
625 @@ -1309,7 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_de
626 rt2x00dev->hw->wiphy->interface_modes |=
627 BIT(NL80211_IFTYPE_ADHOC) |
628 BIT(NL80211_IFTYPE_AP) |
629 +#ifdef CONFIG_MAC80211_MESH
630 BIT(NL80211_IFTYPE_MESH_POINT) |
632 BIT(NL80211_IFTYPE_WDS);
634 rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
635 --- a/net/mac80211/rc80211_minstrel_ht.c
636 +++ b/net/mac80211/rc80211_minstrel_ht.c
638 /* Number of symbols for a packet with (bps) bits per symbol */
639 #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps))
641 -/* Transmission time for a packet containing (syms) symbols */
642 +/* Transmission time (nanoseconds) for a packet containing (syms) symbols */
643 #define MCS_SYMBOL_TIME(sgi, syms) \
645 - ((syms) * 18 + 4) / 5 : /* syms * 3.6 us */ \
646 - (syms) << 2 /* syms * 4 us */ \
647 + ((syms) * 18000 + 4000) / 5 : /* syms * 3.6 us */ \
648 + ((syms) * 1000) << 2 /* syms * 4 us */ \
651 /* Transmit duration for the raw data part of an average sized packet */
655 #define CCK_DURATION(_bitrate, _short, _len) \
657 + (1000 * (10 /* SIFS */ + \
658 (_short ? 72 + 24 : 144 + 48 ) + \
659 - (8 * (_len + 4) * 10) / (_bitrate))
660 + (8 * (_len + 4) * 10) / (_bitrate)))
662 #define CCK_ACK_DURATION(_bitrate, _short) \
663 (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \
664 @@ -211,20 +211,32 @@ static void
665 minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
667 struct minstrel_rate_stats *mr;
668 - unsigned int usecs = 0;
669 + unsigned int nsecs = 0;
673 mr = &mi->groups[group].rates[rate];
674 + prob = mr->probability;
676 - if (mr->probability < MINSTREL_FRAC(1, 10)) {
677 + if (prob < MINSTREL_FRAC(1, 10)) {
683 + * For the throughput calculation, limit the probability value to 90% to
684 + * account for collision related packet error rate fluctuation
686 + if (prob > MINSTREL_FRAC(9, 10))
687 + prob = MINSTREL_FRAC(9, 10);
689 if (group != MINSTREL_CCK_GROUP)
690 - usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
691 + nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
693 - usecs += minstrel_mcs_groups[group].duration[rate];
694 - mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
695 + nsecs += minstrel_mcs_groups[group].duration[rate];
696 + tp = 1000000 * ((mr->probability * 1000) / nsecs);
698 + mr->cur_tp = MINSTREL_TRUNC(tp);
702 @@ -308,8 +320,8 @@ minstrel_ht_update_stats(struct minstrel
706 - /* try to sample up to half of the available rates during each interval */
707 - mi->sample_count *= 4;
708 + /* try to sample all available rates during each interval */
709 + mi->sample_count *= 8;
713 @@ -320,20 +332,13 @@ minstrel_ht_update_stats(struct minstrel
717 - mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
718 - if (cur_prob_tp < mr->cur_tp &&
719 - minstrel_mcs_groups[group].streams == 1) {
720 - mi->max_prob_rate = mg->max_prob_rate;
721 - cur_prob = mr->cur_prob;
722 - cur_prob_tp = mr->cur_tp;
725 mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
726 if (cur_tp < mr->cur_tp) {
727 mi->max_tp_rate2 = mi->max_tp_rate;
729 mi->max_tp_rate = mg->max_tp_rate;
731 + mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
734 mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
735 @@ -343,6 +348,23 @@ minstrel_ht_update_stats(struct minstrel
739 + if (mi->max_prob_streams < 1)
740 + mi->max_prob_streams = 1;
742 + for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
743 + mg = &mi->groups[group];
744 + if (!mg->supported)
746 + mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
747 + if (cur_prob_tp < mr->cur_tp &&
748 + minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
749 + mi->max_prob_rate = mg->max_prob_rate;
750 + cur_prob = mr->cur_prob;
751 + cur_prob_tp = mr->cur_tp;
756 mi->stats_update = jiffies;
759 @@ -467,7 +489,7 @@ minstrel_ht_tx_status(void *priv, struct
761 if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
762 mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
763 - mi->sample_tries = 2;
764 + mi->sample_tries = 1;
768 @@ -536,7 +558,7 @@ minstrel_calc_retransmit(struct minstrel
769 mr->retry_updated = true;
771 group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
772 - tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len;
773 + tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000;
775 /* Contention time for first 2 tries */
776 ctime = (t_slot * cw) >> 1;
777 @@ -616,6 +638,7 @@ minstrel_get_sample_rate(struct minstrel
779 struct minstrel_rate_stats *mr;
780 struct minstrel_mcs_group_data *mg;
781 + unsigned int sample_dur, sample_group;
784 if (mi->sample_wait > 0) {
785 @@ -626,39 +649,46 @@ minstrel_get_sample_rate(struct minstrel
786 if (!mi->sample_tries)
789 - mi->sample_tries--;
790 mg = &mi->groups[mi->sample_group];
791 sample_idx = sample_table[mg->column][mg->index];
792 mr = &mg->rates[sample_idx];
793 - sample_idx += mi->sample_group * MCS_GROUP_RATES;
794 + sample_group = mi->sample_group;
795 + sample_idx += sample_group * MCS_GROUP_RATES;
796 minstrel_next_sample_idx(mi);
799 * Sampling might add some overhead (RTS, no aggregation)
800 * to the frame. Hence, don't use sampling for the currently
801 - * used max TP rate.
804 - if (sample_idx == mi->max_tp_rate)
805 + if (sample_idx == mi->max_tp_rate ||
806 + sample_idx == mi->max_tp_rate2 ||
807 + sample_idx == mi->max_prob_rate)
811 - * When not using MRR, do not sample if the probability is already
812 - * higher than 95% to avoid wasting airtime
813 + * Do not sample if the probability is already higher than 95%
814 + * to avoid wasting airtime.
816 - if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
817 + if (mr->probability > MINSTREL_FRAC(95, 100))
821 * Make sure that lower rates get sampled only occasionally,
822 * if the link is working perfectly.
824 - if (minstrel_get_duration(sample_idx) >
825 - minstrel_get_duration(mi->max_tp_rate)) {
826 + sample_dur = minstrel_get_duration(sample_idx);
827 + if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
828 + (mi->max_prob_streams <
829 + minstrel_mcs_groups[sample_group].streams ||
830 + sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
831 if (mr->sample_skipped < 20)
834 if (mi->sample_slow++ > 2)
837 + mi->sample_tries--;
841 --- a/net/mac80211/rc80211_minstrel_ht.h
842 +++ b/net/mac80211/rc80211_minstrel_ht.h
843 @@ -85,6 +85,7 @@ struct minstrel_ht_sta {
845 /* best probability rate */
846 unsigned int max_prob_rate;
847 + unsigned int max_prob_streams;
849 /* time of last status update */
850 unsigned long stats_update;
851 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
852 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
853 @@ -1023,6 +1023,7 @@ static bool ar9003_hw_init_cal(struct at
854 AR_PHY_AGC_CONTROL_FLTR_CAL |
855 AR_PHY_AGC_CONTROL_PKDET_CAL;
857 + /* Use chip chainmask only for calibration */
858 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
861 @@ -1150,6 +1151,9 @@ skip_tx_iqcal:
862 ar9003_hw_rtt_disable(ah);
865 + /* Revert chainmask to runtime parameters */
866 + ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
868 /* Initialize list pointers */
869 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
871 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
872 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
873 @@ -3606,6 +3606,12 @@ static void ar9003_hw_ant_ctrl_apply(str
874 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
875 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
877 + if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
878 + value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
879 + REG_RMW_FIELD(ah, switch_chain_reg[0],
880 + AR_SWITCH_TABLE_ALL, value);
883 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
884 if ((ah->rxchainmask & BIT(chain)) ||
885 (ah->txchainmask & BIT(chain))) {
886 @@ -3772,6 +3778,17 @@ static void ar9003_hw_atten_apply(struct
887 AR_PHY_EXT_ATTEN_CTL_2,
890 + if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
891 + value = ar9003_hw_atten_chain_get(ah, 1, chan);
892 + REG_RMW_FIELD(ah, ext_atten_reg[0],
893 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
895 + value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
896 + REG_RMW_FIELD(ah, ext_atten_reg[0],
897 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
901 /* Test value. if 0 then attenuation is unused. Don't load anything. */
902 for (i = 0; i < 3; i++) {
903 if (ah->txchainmask & BIT(i)) {
904 --- a/drivers/net/wireless/ath/ath9k/link.c
905 +++ b/drivers/net/wireless/ath/ath9k/link.c
906 @@ -28,21 +28,21 @@ void ath_tx_complete_poll_work(struct wo
908 bool needreset = false;
910 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
911 - if (ATH_TXQ_SETUP(sc, i)) {
912 - txq = &sc->tx.txq[i];
913 - ath_txq_lock(sc, txq);
914 - if (txq->axq_depth) {
915 - if (txq->axq_tx_inprogress) {
917 - ath_txq_unlock(sc, txq);
920 - txq->axq_tx_inprogress = true;
922 + for (i = 0; i < IEEE80211_NUM_ACS; i++) {
923 + txq = sc->tx.txq_map[i];
925 + ath_txq_lock(sc, txq);
926 + if (txq->axq_depth) {
927 + if (txq->axq_tx_inprogress) {
929 + ath_txq_unlock(sc, txq);
932 + txq->axq_tx_inprogress = true;
934 - ath_txq_unlock_complete(sc, txq);
936 + ath_txq_unlock_complete(sc, txq);
940 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
941 --- a/net/mac80211/sta_info.c
942 +++ b/net/mac80211/sta_info.c
943 @@ -766,6 +766,7 @@ int __must_check __sta_info_destroy(stru
944 struct ieee80211_local *local;
945 struct ieee80211_sub_if_data *sdata;
947 + bool have_key = false;
951 @@ -793,12 +794,19 @@ int __must_check __sta_info_destroy(stru
952 list_del_rcu(&sta->list);
954 mutex_lock(&local->key_mtx);
955 - for (i = 0; i < NUM_DEFAULT_KEYS; i++)
956 + for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
957 __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]));
962 __ieee80211_key_free(key_mtx_dereference(local, sta->ptk));
965 mutex_unlock(&local->key_mtx);
973 --- a/net/mac80211/chan.c
974 +++ b/net/mac80211/chan.c
975 @@ -63,6 +63,7 @@ ieee80211_new_chanctx(struct ieee80211_l
976 enum ieee80211_chanctx_mode mode)
978 struct ieee80211_chanctx *ctx;
982 lockdep_assert_held(&local->chanctx_mtx);
983 @@ -76,6 +77,13 @@ ieee80211_new_chanctx(struct ieee80211_l
984 ctx->conf.rx_chains_dynamic = 1;
987 + /* acquire mutex to prevent idle from changing */
988 + mutex_lock(&local->mtx);
989 + /* turn idle off *before* setting channel -- some drivers need that */
990 + changed = ieee80211_idle_off(local);
992 + ieee80211_hw_config(local, changed);
994 if (!local->use_chanctx) {
995 local->_oper_channel_type =
996 cfg80211_get_chandef_type(chandef);
997 @@ -85,14 +93,17 @@ ieee80211_new_chanctx(struct ieee80211_l
998 err = drv_add_chanctx(local, ctx);
1001 - return ERR_PTR(err);
1002 + ctx = ERR_PTR(err);
1004 + ieee80211_recalc_idle(local);
1009 + /* and keep the mutex held until the new chanctx is on the list */
1010 list_add_rcu(&ctx->list, &local->chanctx_list);
1012 - mutex_lock(&local->mtx);
1013 - ieee80211_recalc_idle(local);
1015 mutex_unlock(&local->mtx);
1018 --- a/net/mac80211/ieee80211_i.h
1019 +++ b/net/mac80211/ieee80211_i.h
1020 @@ -1366,6 +1366,7 @@ int ieee80211_if_change_type(struct ieee
1021 enum nl80211_iftype type);
1022 void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
1023 void ieee80211_remove_interfaces(struct ieee80211_local *local);
1024 +u32 ieee80211_idle_off(struct ieee80211_local *local);
1025 void ieee80211_recalc_idle(struct ieee80211_local *local);
1026 void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
1028 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
1029 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
1030 @@ -799,7 +799,7 @@ static int ath9k_init_firmware_version(s
1033 if (priv->fw_version_major != MAJOR_VERSION_REQ ||
1034 - priv->fw_version_minor != MINOR_VERSION_REQ) {
1035 + priv->fw_version_minor < MINOR_VERSION_REQ) {
1036 dev_err(priv->dev, "ath9k_htc: Please upgrade to FW version %d.%d\n",
1037 MAJOR_VERSION_REQ, MINOR_VERSION_REQ);
1039 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1040 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1041 @@ -516,8 +516,7 @@ static void ath_tx_complete_aggr(struct
1042 * not a holding desc.
1044 INIT_LIST_HEAD(&bf_head);
1045 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) ||
1046 - bf_next != NULL || !bf_last->bf_stale)
1047 + if (bf_next != NULL || !bf_last->bf_stale)
1048 list_move_tail(&bf->list, &bf_head);
1050 if (!txpending || (tid->state & AGGR_CLEANUP)) {
1051 @@ -537,8 +536,7 @@ static void ath_tx_complete_aggr(struct
1054 /* retry the un-acked ones */
1055 - if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
1056 - bf->bf_next == NULL && bf_last->bf_stale) {
1057 + if (bf->bf_next == NULL && bf_last->bf_stale) {
1058 struct ath_buf *tbf;
1060 tbf = ath_clone_txbuf(sc, bf_last);
1061 @@ -2264,6 +2262,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1062 struct ath_txq *txq;
1063 struct ath_buf *bf, *lastbf;
1064 struct list_head bf_head;
1065 + struct list_head *fifo_list;
1069 @@ -2291,20 +2290,24 @@ void ath_tx_edma_tasklet(struct ath_soft
1071 TX_STAT_INC(txq->axq_qnum, txprocdesc);
1073 - if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
1074 + fifo_list = &txq->txq_fifo[txq->txq_tailidx];
1075 + if (list_empty(fifo_list)) {
1076 ath_txq_unlock(sc, txq);
1080 - bf = list_first_entry(&txq->txq_fifo[txq->txq_tailidx],
1081 - struct ath_buf, list);
1082 + bf = list_first_entry(fifo_list, struct ath_buf, list);
1083 + if (bf->bf_stale) {
1084 + list_del(&bf->list);
1085 + ath_tx_return_buffer(sc, bf);
1086 + bf = list_first_entry(fifo_list, struct ath_buf, list);
1089 lastbf = bf->bf_lastbf;
1091 INIT_LIST_HEAD(&bf_head);
1092 - list_cut_position(&bf_head, &txq->txq_fifo[txq->txq_tailidx],
1095 - if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
1096 + if (list_is_last(&lastbf->list, fifo_list)) {
1097 + list_splice_tail_init(fifo_list, &bf_head);
1098 INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH);
1100 if (!list_empty(&txq->axq_q)) {
1101 @@ -2315,6 +2318,11 @@ void ath_tx_edma_tasklet(struct ath_soft
1102 list_splice_tail_init(&txq->axq_q, &bf_q);
1103 ath_tx_txqaddbuf(sc, txq, &bf_q, true);
1106 + lastbf->bf_stale = true;
1108 + list_cut_position(&bf_head, fifo_list,
1109 + lastbf->list.prev);
1112 ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);