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 @@ -541,6 +540,9 @@ int ieee80211_do_open(struct wireless_de
180 ieee80211_adjust_monitor_flags(sdata, 1);
181 ieee80211_configure_filter(local);
182 + mutex_lock(&local->mtx);
183 + ieee80211_recalc_idle(local);
184 + mutex_unlock(&local->mtx);
186 netif_carrier_on(dev);
188 @@ -595,30 +597,8 @@ int ieee80211_do_open(struct wireless_de
190 set_bit(SDATA_STATE_RUNNING, &sdata->state);
192 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
193 - /* Create STA entry for the WDS peer */
194 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
198 - goto err_del_interface;
201 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
202 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
203 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
205 - res = sta_info_insert(sta);
207 - /* STA has been freed */
208 - goto err_del_interface;
211 - rate_control_rate_init(sta);
212 - netif_carrier_on(dev);
213 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
214 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
215 rcu_assign_pointer(local->p2p_sdata, sdata);
219 * set_multicast_list will be invoked by the networking core
220 @@ -817,6 +797,9 @@ static void ieee80211_do_stop(struct iee
222 ieee80211_adjust_monitor_flags(sdata, -1);
223 ieee80211_configure_filter(local);
224 + mutex_lock(&local->mtx);
225 + ieee80211_recalc_idle(local);
226 + mutex_unlock(&local->mtx);
228 case NL80211_IFTYPE_P2P_DEVICE:
229 /* relies on synchronize_rcu() below */
230 @@ -1022,6 +1005,72 @@ static void ieee80211_if_setup(struct ne
231 dev->destructor = free_netdev;
234 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
235 + struct sk_buff *skb)
237 + struct ieee80211_local *local = sdata->local;
238 + struct ieee80211_rx_status *rx_status;
239 + struct ieee802_11_elems elems;
240 + struct ieee80211_mgmt *mgmt;
241 + struct sta_info *sta;
246 + enum ieee80211_band band = local->hw.conf.channel->band;
247 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
249 + rx_status = IEEE80211_SKB_RXCB(skb);
250 + mgmt = (struct ieee80211_mgmt *) skb->data;
251 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
253 + if (stype != IEEE80211_STYPE_BEACON)
256 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
257 + if (baselen > skb->len)
260 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
261 + skb->len - baselen, &elems);
263 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
267 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
271 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
279 + sta->last_rx = jiffies;
280 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
282 + if (elems.ht_cap_elem)
283 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
284 + elems.ht_cap_elem, sta);
286 + if (elems.wmm_param)
287 + set_sta_flag(sta, WLAN_STA_WME);
290 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
291 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
292 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
293 + rate_control_rate_init(sta);
294 + sta_info_insert_rcu(sta);
300 static void ieee80211_iface_work(struct work_struct *work)
302 struct ieee80211_sub_if_data *sdata =
303 @@ -1126,6 +1175,9 @@ static void ieee80211_iface_work(struct
305 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
307 + case NL80211_IFTYPE_WDS:
308 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
311 WARN(1, "frame for unexpected interface type");
313 --- a/net/mac80211/rx.c
314 +++ b/net/mac80211/rx.c
315 @@ -2365,6 +2365,7 @@ ieee80211_rx_h_action(struct ieee80211_r
316 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
317 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
318 sdata->vif.type != NL80211_IFTYPE_AP &&
319 + sdata->vif.type != NL80211_IFTYPE_WDS &&
320 sdata->vif.type != NL80211_IFTYPE_ADHOC)
323 @@ -2692,14 +2693,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
325 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
326 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
327 - sdata->vif.type != NL80211_IFTYPE_STATION)
328 + sdata->vif.type != NL80211_IFTYPE_STATION &&
329 + sdata->vif.type != NL80211_IFTYPE_WDS)
330 return RX_DROP_MONITOR;
333 case cpu_to_le16(IEEE80211_STYPE_AUTH):
334 case cpu_to_le16(IEEE80211_STYPE_BEACON):
335 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
336 - /* process for all: mesh, mlme, ibss */
337 + /* process for all: mesh, mlme, ibss, wds */
339 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
340 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
341 @@ -3028,10 +3030,16 @@ static int prepare_for_handlers(struct i
344 case NL80211_IFTYPE_WDS:
345 - if (bssid || !ieee80211_is_data(hdr->frame_control))
347 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
350 + if (ieee80211_is_data(hdr->frame_control) ||
351 + ieee80211_is_action(hdr->frame_control)) {
352 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
354 + } else if (!ieee80211_is_beacon(hdr->frame_control))
358 case NL80211_IFTYPE_P2P_DEVICE:
359 if (!ieee80211_is_public_action(hdr, skb->len) &&
360 --- a/net/mac80211/sta_info.h
361 +++ b/net/mac80211/sta_info.h
363 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
365 * @WLAN_STA_WME: Station is a QoS-STA.
366 - * @WLAN_STA_WDS: Station is one of our WDS peers.
367 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
368 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
369 * frame to this station is transmitted.
370 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
372 WLAN_STA_SHORT_PREAMBLE,
375 WLAN_STA_CLEAR_PS_FILT,
378 --- a/net/mac80211/tx.c
379 +++ b/net/mac80211/tx.c
380 @@ -1231,34 +1231,40 @@ static bool ieee80211_tx_frags(struct ie
381 if (local->queue_stop_reasons[q] ||
382 (!txpending && !skb_queue_empty(&local->pending[q]))) {
383 if (unlikely(info->flags &
384 - IEEE80211_TX_INTFL_OFFCHAN_TX_OK &&
385 - local->queue_stop_reasons[q] &
386 - ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) {
387 + IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) {
388 + if (local->queue_stop_reasons[q] &
389 + ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) {
391 + * Drop off-channel frames if queues
392 + * are stopped for any reason other
393 + * than off-channel operation. Never
396 + spin_unlock_irqrestore(
397 + &local->queue_stop_reason_lock,
399 + ieee80211_purge_tx_queue(&local->hw,
406 - * Drop off-channel frames if queues are stopped
407 - * for any reason other than off-channel
408 - * operation. Never queue them.
409 + * Since queue is stopped, queue up frames for
410 + * later transmission from the tx-pending
411 + * tasklet when the queue is woken again.
413 - spin_unlock_irqrestore(
414 - &local->queue_stop_reason_lock, flags);
415 - ieee80211_purge_tx_queue(&local->hw, skbs);
418 + skb_queue_splice_init(skbs,
419 + &local->pending[q]);
421 + skb_queue_splice_tail_init(skbs,
422 + &local->pending[q]);
424 + spin_unlock_irqrestore(&local->queue_stop_reason_lock,
430 - * Since queue is stopped, queue up frames for later
431 - * transmission from the tx-pending tasklet when the
432 - * queue is woken again.
435 - skb_queue_splice_init(skbs, &local->pending[q]);
437 - skb_queue_splice_tail_init(skbs,
438 - &local->pending[q]);
440 - spin_unlock_irqrestore(&local->queue_stop_reason_lock,
444 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
446 @@ -1848,9 +1854,24 @@ netdev_tx_t ieee80211_subif_start_xmit(s
449 if (!is_multicast_ether_addr(skb->data)) {
450 + struct sta_info *next_hop;
451 + bool mpp_lookup = true;
453 mpath = mesh_path_lookup(sdata, skb->data);
456 + mpp_lookup = false;
457 + next_hop = rcu_dereference(mpath->next_hop);
459 + !(mpath->flags & (MESH_PATH_ACTIVE |
460 + MESH_PATH_RESOLVING)))
465 mppath = mpp_path_lookup(sdata, skb->data);
467 + if (mppath && mpath)
468 + mesh_path_del(mpath->sdata, mpath->dst);
472 --- a/net/wireless/nl80211.c
473 +++ b/net/wireless/nl80211.c
474 @@ -554,16 +554,9 @@ static int nl80211_msg_put_channel(struc
475 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
476 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
477 goto nla_put_failure;
478 - if (chan->flags & IEEE80211_CHAN_RADAR) {
479 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered);
480 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
481 - goto nla_put_failure;
482 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE,
484 - goto nla_put_failure;
485 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time))
486 - goto nla_put_failure;
488 + if ((chan->flags & IEEE80211_CHAN_RADAR) &&
489 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
490 + goto nla_put_failure;
491 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) &&
492 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS))
493 goto nla_put_failure;
494 @@ -900,9 +893,6 @@ static int nl80211_put_iface_combination
495 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
497 goto nla_put_failure;
498 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
499 - c->radar_detect_widths))
500 - goto nla_put_failure;
502 nla_nest_end(msg, nl_combi);
504 @@ -914,48 +904,6 @@ nla_put_failure:
509 -static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev,
510 - struct sk_buff *msg)
512 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp;
513 - struct nlattr *nl_tcp;
518 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION);
522 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
523 - tcp->data_payload_max))
526 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD,
527 - tcp->data_payload_max))
530 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ))
533 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
534 - sizeof(*tcp->tok), tcp->tok))
537 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL,
538 - tcp->data_interval_max))
541 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
542 - tcp->wake_payload_max))
545 - nla_nest_end(msg, nl_tcp);
550 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
551 struct cfg80211_registered_device *dev)
553 @@ -1330,9 +1278,6 @@ static int nl80211_send_wiphy(struct sk_
554 goto nla_put_failure;
557 - if (nl80211_send_wowlan_tcp_caps(dev, msg))
558 - goto nla_put_failure;
560 nla_nest_end(msg, nl_wowlan);
563 --- a/net/mac80211/cfg.c
564 +++ b/net/mac80211/cfg.c
565 @@ -3285,13 +3285,19 @@ static int ieee80211_cfg_get_channel(str
566 struct cfg80211_chan_def *chandef)
568 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
569 + struct ieee80211_local *local = wiphy_priv(wiphy);
570 struct ieee80211_chanctx_conf *chanctx_conf;
574 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
575 - if (chanctx_conf) {
576 - *chandef = chanctx_conf->def;
577 + if (local->use_chanctx) {
578 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
579 + if (chanctx_conf) {
580 + *chandef = chanctx_conf->def;
583 + } else if (local->open_count == local->monitors) {
584 + *chandef = local->monitor_chandef;
588 --- a/drivers/net/wireless/ath/ath9k/hw.c
589 +++ b/drivers/net/wireless/ath/ath9k/hw.c
590 @@ -1463,7 +1463,9 @@ static bool ath9k_hw_chip_reset(struct a
591 reset_type = ATH9K_RESET_POWER_ON;
593 reset_type = ATH9K_RESET_COLD;
595 + } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
596 + (REG_READ(ah, AR_CR) & AR_CR_RXE))
597 + reset_type = ATH9K_RESET_COLD;
599 if (!ath9k_hw_set_reset_reg(ah, reset_type))
601 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
602 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
603 @@ -1236,8 +1236,10 @@ static inline void rt2x00lib_set_if_comb
605 if_limit = &rt2x00dev->if_limits_ap;
606 if_limit->max = rt2x00dev->ops->max_ap_intf;
607 - if_limit->types = BIT(NL80211_IFTYPE_AP) |
608 - BIT(NL80211_IFTYPE_MESH_POINT);
609 + if_limit->types = BIT(NL80211_IFTYPE_AP);
610 +#ifdef CONFIG_MAC80211_MESH
611 + if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
615 * Build up AP interface combinations structure.
616 @@ -1309,7 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_de
617 rt2x00dev->hw->wiphy->interface_modes |=
618 BIT(NL80211_IFTYPE_ADHOC) |
619 BIT(NL80211_IFTYPE_AP) |
620 +#ifdef CONFIG_MAC80211_MESH
621 BIT(NL80211_IFTYPE_MESH_POINT) |
623 BIT(NL80211_IFTYPE_WDS);
625 rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
626 --- a/net/mac80211/rc80211_minstrel_ht.c
627 +++ b/net/mac80211/rc80211_minstrel_ht.c
629 /* Number of symbols for a packet with (bps) bits per symbol */
630 #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps))
632 -/* Transmission time for a packet containing (syms) symbols */
633 +/* Transmission time (nanoseconds) for a packet containing (syms) symbols */
634 #define MCS_SYMBOL_TIME(sgi, syms) \
636 - ((syms) * 18 + 4) / 5 : /* syms * 3.6 us */ \
637 - (syms) << 2 /* syms * 4 us */ \
638 + ((syms) * 18000 + 4000) / 5 : /* syms * 3.6 us */ \
639 + ((syms) * 1000) << 2 /* syms * 4 us */ \
642 /* Transmit duration for the raw data part of an average sized packet */
646 #define CCK_DURATION(_bitrate, _short, _len) \
648 + (1000 * (10 /* SIFS */ + \
649 (_short ? 72 + 24 : 144 + 48 ) + \
650 - (8 * (_len + 4) * 10) / (_bitrate))
651 + (8 * (_len + 4) * 10) / (_bitrate)))
653 #define CCK_ACK_DURATION(_bitrate, _short) \
654 (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \
655 @@ -211,20 +211,32 @@ static void
656 minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
658 struct minstrel_rate_stats *mr;
659 - unsigned int usecs = 0;
660 + unsigned int nsecs = 0;
664 mr = &mi->groups[group].rates[rate];
665 + prob = mr->probability;
667 - if (mr->probability < MINSTREL_FRAC(1, 10)) {
668 + if (prob < MINSTREL_FRAC(1, 10)) {
674 + * For the throughput calculation, limit the probability value to 90% to
675 + * account for collision related packet error rate fluctuation
677 + if (prob > MINSTREL_FRAC(9, 10))
678 + prob = MINSTREL_FRAC(9, 10);
680 if (group != MINSTREL_CCK_GROUP)
681 - usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
682 + nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
684 - usecs += minstrel_mcs_groups[group].duration[rate];
685 - mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
686 + nsecs += minstrel_mcs_groups[group].duration[rate];
687 + tp = 1000000 * ((mr->probability * 1000) / nsecs);
689 + mr->cur_tp = MINSTREL_TRUNC(tp);
693 @@ -308,8 +320,8 @@ minstrel_ht_update_stats(struct minstrel
697 - /* try to sample up to half of the available rates during each interval */
698 - mi->sample_count *= 4;
699 + /* try to sample all available rates during each interval */
700 + mi->sample_count *= 8;
704 @@ -320,20 +332,13 @@ minstrel_ht_update_stats(struct minstrel
708 - mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
709 - if (cur_prob_tp < mr->cur_tp &&
710 - minstrel_mcs_groups[group].streams == 1) {
711 - mi->max_prob_rate = mg->max_prob_rate;
712 - cur_prob = mr->cur_prob;
713 - cur_prob_tp = mr->cur_tp;
716 mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
717 if (cur_tp < mr->cur_tp) {
718 mi->max_tp_rate2 = mi->max_tp_rate;
720 mi->max_tp_rate = mg->max_tp_rate;
722 + mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
725 mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
726 @@ -343,6 +348,23 @@ minstrel_ht_update_stats(struct minstrel
730 + if (mi->max_prob_streams < 1)
731 + mi->max_prob_streams = 1;
733 + for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
734 + mg = &mi->groups[group];
735 + if (!mg->supported)
737 + mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
738 + if (cur_prob_tp < mr->cur_tp &&
739 + minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
740 + mi->max_prob_rate = mg->max_prob_rate;
741 + cur_prob = mr->cur_prob;
742 + cur_prob_tp = mr->cur_tp;
747 mi->stats_update = jiffies;
750 @@ -467,7 +489,7 @@ minstrel_ht_tx_status(void *priv, struct
752 if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
753 mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
754 - mi->sample_tries = 2;
755 + mi->sample_tries = 1;
759 @@ -536,7 +558,7 @@ minstrel_calc_retransmit(struct minstrel
760 mr->retry_updated = true;
762 group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
763 - tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len;
764 + tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000;
766 /* Contention time for first 2 tries */
767 ctime = (t_slot * cw) >> 1;
768 @@ -616,6 +638,7 @@ minstrel_get_sample_rate(struct minstrel
770 struct minstrel_rate_stats *mr;
771 struct minstrel_mcs_group_data *mg;
772 + unsigned int sample_dur, sample_group;
775 if (mi->sample_wait > 0) {
776 @@ -626,39 +649,46 @@ minstrel_get_sample_rate(struct minstrel
777 if (!mi->sample_tries)
780 - mi->sample_tries--;
781 mg = &mi->groups[mi->sample_group];
782 sample_idx = sample_table[mg->column][mg->index];
783 mr = &mg->rates[sample_idx];
784 - sample_idx += mi->sample_group * MCS_GROUP_RATES;
785 + sample_group = mi->sample_group;
786 + sample_idx += sample_group * MCS_GROUP_RATES;
787 minstrel_next_sample_idx(mi);
790 * Sampling might add some overhead (RTS, no aggregation)
791 * to the frame. Hence, don't use sampling for the currently
792 - * used max TP rate.
795 - if (sample_idx == mi->max_tp_rate)
796 + if (sample_idx == mi->max_tp_rate ||
797 + sample_idx == mi->max_tp_rate2 ||
798 + sample_idx == mi->max_prob_rate)
802 - * When not using MRR, do not sample if the probability is already
803 - * higher than 95% to avoid wasting airtime
804 + * Do not sample if the probability is already higher than 95%
805 + * to avoid wasting airtime.
807 - if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
808 + if (mr->probability > MINSTREL_FRAC(95, 100))
812 * Make sure that lower rates get sampled only occasionally,
813 * if the link is working perfectly.
815 - if (minstrel_get_duration(sample_idx) >
816 - minstrel_get_duration(mi->max_tp_rate)) {
817 + sample_dur = minstrel_get_duration(sample_idx);
818 + if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
819 + (mi->max_prob_streams <
820 + minstrel_mcs_groups[sample_group].streams ||
821 + sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
822 if (mr->sample_skipped < 20)
825 if (mi->sample_slow++ > 2)
828 + mi->sample_tries--;
832 --- a/net/mac80211/rc80211_minstrel_ht.h
833 +++ b/net/mac80211/rc80211_minstrel_ht.h
834 @@ -85,6 +85,7 @@ struct minstrel_ht_sta {
836 /* best probability rate */
837 unsigned int max_prob_rate;
838 + unsigned int max_prob_streams;
840 /* time of last status update */
841 unsigned long stats_update;
842 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
843 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
844 @@ -1023,6 +1023,7 @@ static bool ar9003_hw_init_cal(struct at
845 AR_PHY_AGC_CONTROL_FLTR_CAL |
846 AR_PHY_AGC_CONTROL_PKDET_CAL;
848 + /* Use chip chainmask only for calibration */
849 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
852 @@ -1150,6 +1151,9 @@ skip_tx_iqcal:
853 ar9003_hw_rtt_disable(ah);
856 + /* Revert chainmask to runtime parameters */
857 + ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
859 /* Initialize list pointers */
860 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
862 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
863 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
864 @@ -3606,6 +3606,12 @@ static void ar9003_hw_ant_ctrl_apply(str
865 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
866 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
868 + if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
869 + value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
870 + REG_RMW_FIELD(ah, switch_chain_reg[0],
871 + AR_SWITCH_TABLE_ALL, value);
874 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
875 if ((ah->rxchainmask & BIT(chain)) ||
876 (ah->txchainmask & BIT(chain))) {
877 @@ -3772,6 +3778,17 @@ static void ar9003_hw_atten_apply(struct
878 AR_PHY_EXT_ATTEN_CTL_2,
881 + if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
882 + value = ar9003_hw_atten_chain_get(ah, 1, chan);
883 + REG_RMW_FIELD(ah, ext_atten_reg[0],
884 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
886 + value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
887 + REG_RMW_FIELD(ah, ext_atten_reg[0],
888 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
892 /* Test value. if 0 then attenuation is unused. Don't load anything. */
893 for (i = 0; i < 3; i++) {
894 if (ah->txchainmask & BIT(i)) {
895 --- a/drivers/net/wireless/ath/ath9k/link.c
896 +++ b/drivers/net/wireless/ath/ath9k/link.c
897 @@ -28,21 +28,21 @@ void ath_tx_complete_poll_work(struct wo
899 bool needreset = false;
901 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
902 - if (ATH_TXQ_SETUP(sc, i)) {
903 - txq = &sc->tx.txq[i];
904 - ath_txq_lock(sc, txq);
905 - if (txq->axq_depth) {
906 - if (txq->axq_tx_inprogress) {
908 - ath_txq_unlock(sc, txq);
911 - txq->axq_tx_inprogress = true;
913 + for (i = 0; i < IEEE80211_NUM_ACS; i++) {
914 + txq = sc->tx.txq_map[i];
916 + ath_txq_lock(sc, txq);
917 + if (txq->axq_depth) {
918 + if (txq->axq_tx_inprogress) {
920 + ath_txq_unlock(sc, txq);
923 + txq->axq_tx_inprogress = true;
925 - ath_txq_unlock_complete(sc, txq);
927 + ath_txq_unlock_complete(sc, txq);
931 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
932 --- a/net/mac80211/sta_info.c
933 +++ b/net/mac80211/sta_info.c
934 @@ -766,6 +766,7 @@ int __must_check __sta_info_destroy(stru
935 struct ieee80211_local *local;
936 struct ieee80211_sub_if_data *sdata;
938 + bool have_key = false;
942 @@ -793,12 +794,19 @@ int __must_check __sta_info_destroy(stru
943 list_del_rcu(&sta->list);
945 mutex_lock(&local->key_mtx);
946 - for (i = 0; i < NUM_DEFAULT_KEYS; i++)
947 + for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
948 __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]));
953 __ieee80211_key_free(key_mtx_dereference(local, sta->ptk));
956 mutex_unlock(&local->key_mtx);