--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
-@@ -203,6 +203,8 @@ static void ieee80211_send_addba_resp(st
+@@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
else if (sdata->vif.type == NL80211_IFTYPE_STATION)
memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
-@@ -520,6 +521,7 @@ int ieee80211_start_tx_ba_session(struct
+@@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
sdata->vif.type != NL80211_IFTYPE_AP &&
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
-@@ -65,11 +65,11 @@ static ssize_t sta_flags_read(struct fil
+@@ -66,11 +66,11 @@ static ssize_t sta_flags_read(struct fil
test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
int res = scnprintf(buf, sizeof(buf),
-- "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
-+ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+- "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
++ "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
TEST(PS_DRIVER), TEST(AUTHORIZED),
TEST(SHORT_PREAMBLE),
TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
+--- a/net/mac80211/ht.c
++++ b/net/mac80211/ht.c
+@@ -281,13 +281,14 @@ void ieee80211_ba_session_work(struct wo
+ sta, tid, WLAN_BACK_RECIPIENT,
+ WLAN_REASON_UNSPECIFIED, true);
+
++ spin_lock_bh(&sta->lock);
++
+ tid_tx = sta->ampdu_mlme.tid_start_tx[tid];
+ if (tid_tx) {
+ /*
+ * Assign it over to the normal tid_tx array
+ * where it "goes live".
+ */
+- spin_lock_bh(&sta->lock);
+
+ sta->ampdu_mlme.tid_start_tx[tid] = NULL;
+ /* could there be a race? */
+@@ -300,6 +301,7 @@ void ieee80211_ba_session_work(struct wo
+ ieee80211_tx_ba_session_handle_start(sta, tid);
+ continue;
+ }
++ spin_unlock_bh(&sta->lock);
+
+ tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
+ if (tid_tx && test_and_clear_bit(HT_AGG_STATE_WANT_STOP,
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
-@@ -501,7 +501,6 @@ int ieee80211_do_open(struct wireless_de
+@@ -463,7 +463,6 @@ int ieee80211_do_open(struct wireless_de
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
struct net_device *dev = wdev->netdev;
struct ieee80211_local *local = sdata->local;
u32 changed = 0;
int res;
u32 hw_reconf_flags = 0;
-@@ -658,30 +657,8 @@ int ieee80211_do_open(struct wireless_de
+@@ -629,30 +628,8 @@ int ieee80211_do_open(struct wireless_de
set_bit(SDATA_STATE_RUNNING, &sdata->state);
/*
* set_multicast_list will be invoked by the networking core
-@@ -1066,6 +1043,72 @@ static void ieee80211_if_setup(struct ne
+@@ -1116,6 +1093,74 @@ static void ieee80211_if_setup(struct ne
dev->destructor = free_netdev;
}
+ u32 rates = 0;
+ u16 stype;
+ bool new = false;
-+ enum ieee80211_band band = local->hw.conf.channel->band;
-+ struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
++ enum ieee80211_band band;
++ struct ieee80211_supported_band *sband;
+
+ rx_status = IEEE80211_SKB_RXCB(skb);
++ band = rx_status->band;
++ sband = local->hw.wiphy->bands[band];
+ mgmt = (struct ieee80211_mgmt *) skb->data;
+ stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
+
+ return;
+
+ ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
-+ skb->len - baselen, &elems);
++ skb->len - baselen, false, &elems);
+
+ rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
+
+ }
+
+ sta->last_rx = jiffies;
-+ sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
++ sta->sta.supp_rates[band] = rates;
+
+ if (elems.ht_cap_elem)
+ ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
-+ elems.ht_cap_elem, &sta->sta.ht_cap);
++ elems.ht_cap_elem, sta);
+
+ if (elems.wmm_param)
+ set_sta_flag(sta, WLAN_STA_WME);
static void ieee80211_iface_work(struct work_struct *work)
{
struct ieee80211_sub_if_data *sdata =
-@@ -1170,6 +1213,9 @@ static void ieee80211_iface_work(struct
+@@ -1220,6 +1265,9 @@ static void ieee80211_iface_work(struct
break;
ieee80211_mesh_rx_queued_mgmt(sdata, skb);
break;
break;
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
-@@ -2350,6 +2350,7 @@ ieee80211_rx_h_action(struct ieee80211_r
+@@ -2369,6 +2369,7 @@ ieee80211_rx_h_action(struct ieee80211_r
sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
sdata->vif.type != NL80211_IFTYPE_AP &&
sdata->vif.type != NL80211_IFTYPE_ADHOC)
break;
-@@ -2655,14 +2656,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
+@@ -2720,14 +2721,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
if (!ieee80211_vif_is_mesh(&sdata->vif) &&
sdata->vif.type != NL80211_IFTYPE_ADHOC &&
break;
case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
-@@ -2987,10 +2989,16 @@ static int prepare_for_handlers(struct i
+@@ -3059,10 +3061,16 @@ static int prepare_for_handlers(struct i
}
break;
case NL80211_IFTYPE_WDS:
break;
case NL80211_IFTYPE_P2P_DEVICE:
if (!ieee80211_is_public_action(hdr, skb->len) &&
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -149,6 +149,7 @@ static void cleanup_single_sta(struct st
+ * directly by station destruction.
+ */
+ for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
++ kfree(sta->ampdu_mlme.tid_start_tx[i]);
+ tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
+ if (!tid_tx)
+ continue;
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -32,7 +32,6 @@
* @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
* IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
* frame to this station is transmitted.
-@@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
+@@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
WLAN_STA_AUTHORIZED,
WLAN_STA_SHORT_PREAMBLE,
WLAN_STA_WME,
WLAN_STA_CLEAR_PS_FILT,
WLAN_STA_MFP,
WLAN_STA_BLOCK_BA,
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -324,7 +324,6 @@ struct ath_rx {
-
- int ath_startrecv(struct ath_softc *sc);
- bool ath_stoprecv(struct ath_softc *sc);
--void ath_flushrecv(struct ath_softc *sc);
- u32 ath_calcrxfilter(struct ath_softc *sc);
- int ath_rx_init(struct ath_softc *sc, int nbufs);
- void ath_rx_cleanup(struct ath_softc *sc);
-@@ -641,7 +640,6 @@ void ath_ant_comb_update(struct ath_soft
- enum sc_op_flags {
- SC_OP_INVALID,
- SC_OP_BEACONS,
-- SC_OP_RXFLUSH,
- SC_OP_ANI_RUN,
- SC_OP_PRIM_STA_VIF,
- SC_OP_HW_RESET,
---- a/drivers/net/wireless/ath/ath9k/beacon.c
-+++ b/drivers/net/wireless/ath/ath9k/beacon.c
-@@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_gene
- skb->len, DMA_TO_DEVICE);
- dev_kfree_skb_any(skb);
- bf->bf_buf_addr = 0;
-+ bf->bf_mpdu = NULL;
- }
-
- skb = ieee80211_beacon_get(hw, vif);
-@@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long
- return;
-
- bf = ath9k_beacon_generate(sc->hw, vif);
-- WARN_ON(!bf);
-
- if (sc->beacon.bmisscnt != 0) {
- ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
---- a/drivers/net/wireless/ath/ath9k/debug.c
-+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -861,7 +861,6 @@ static ssize_t read_file_recv(struct fil
- RXS_ERR("RX-LENGTH-ERR", rx_len_err);
- RXS_ERR("RX-OOM-ERR", rx_oom_err);
- RXS_ERR("RX-RATE-ERR", rx_rate_err);
-- RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
- RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
-
- PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
---- a/drivers/net/wireless/ath/ath9k/debug.h
-+++ b/drivers/net/wireless/ath/ath9k/debug.h
-@@ -216,7 +216,6 @@ struct ath_tx_stats {
- * @rx_oom_err: No. of frames dropped due to OOM issues.
- * @rx_rate_err: No. of frames dropped due to rate errors.
- * @rx_too_many_frags_err: Frames dropped due to too-many-frags received.
-- * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
- * @rx_beacons: No. of beacons received.
- * @rx_frags: No. of rx-fragements received.
+@@ -203,6 +201,7 @@ struct tid_ampdu_rx {
+ * driver requested to close until the work for it runs
+ * @mtx: mutex to protect all TX data (except non-NULL assignments
+ * to tid_tx[idx], which are protected by the sta spinlock)
++ * tid_start_tx is also protected by sta->lock.
*/
-@@ -235,7 +234,6 @@ struct ath_rx_stats {
- u32 rx_oom_err;
- u32 rx_rate_err;
- u32 rx_too_many_frags_err;
-- u32 rx_drop_rxflush;
- u32 rx_beacons;
- u32 rx_frags;
- };
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -182,7 +182,7 @@ static void ath_restart_work(struct ath_
- ath_start_ani(sc);
- }
-
--static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
-+static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
- {
- struct ath_hw *ah = sc->sc_ah;
- bool ret = true;
-@@ -196,19 +196,15 @@ static bool ath_prepare_reset(struct ath
- ath9k_debug_samp_bb_mac(sc);
- ath9k_hw_disable_interrupts(ah);
-
-+ tasklet_disable(&sc->intr_tq);
-+
- if (!ath_stoprecv(sc))
- ret = false;
-
- if (!ath_drain_all_txq(sc, retry_tx))
- ret = false;
-
-- if (!flush) {
-- if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
-- ath_rx_tasklet(sc, 1, true);
-- ath_rx_tasklet(sc, 1, false);
-- } else {
-- ath_flushrecv(sc);
-- }
-+ tasklet_enable(&sc->intr_tq);
-
- return ret;
- }
-@@ -262,7 +258,6 @@ static int ath_reset_internal(struct ath
- struct ath_common *common = ath9k_hw_common(ah);
- struct ath9k_hw_cal_data *caldata = NULL;
- bool fastcc = true;
-- bool flush = false;
- int r;
-
- __ath_cancel_work(sc);
-@@ -276,11 +271,10 @@ static int ath_reset_internal(struct ath
-
- if (!hchan) {
- fastcc = false;
-- flush = true;
- hchan = ah->curchan;
- }
-
-- if (!ath_prepare_reset(sc, retry_tx, flush))
-+ if (!ath_prepare_reset(sc, retry_tx))
- fastcc = false;
-
- ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
-@@ -804,7 +798,7 @@ static void ath9k_stop(struct ieee80211_
- ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
- }
-
-- ath_prepare_reset(sc, false, true);
-+ ath_prepare_reset(sc, false);
-
- if (sc->rx.frag) {
- dev_kfree_skb_any(sc->rx.frag);
---- a/drivers/net/wireless/ath/ath9k/recv.c
-+++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -280,7 +280,6 @@ int ath_rx_init(struct ath_softc *sc, in
-
- spin_lock_init(&sc->sc_pcu_lock);
- spin_lock_init(&sc->rx.rxbuflock);
-- clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
-
- common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
- sc->sc_ah->caps.rx_status_len;
-@@ -464,6 +463,13 @@ start_recv:
- return 0;
- }
-
-+static void ath_flushrecv(struct ath_softc *sc)
-+{
-+ if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
-+ ath_rx_tasklet(sc, 1, true);
-+ ath_rx_tasklet(sc, 1, false);
-+}
-+
- bool ath_stoprecv(struct ath_softc *sc)
- {
- struct ath_hw *ah = sc->sc_ah;
-@@ -474,6 +480,8 @@ bool ath_stoprecv(struct ath_softc *sc)
- ath9k_hw_setrxfilter(ah, 0);
- stopped = ath9k_hw_stopdmarecv(ah, &reset);
-
-+ ath_flushrecv(sc);
-+
- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
- ath_edma_stop_recv(sc);
- else
-@@ -490,15 +498,6 @@ bool ath_stoprecv(struct ath_softc *sc)
- return stopped && !reset;
- }
-
--void ath_flushrecv(struct ath_softc *sc)
--{
-- set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
-- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
-- ath_rx_tasklet(sc, 1, true);
-- ath_rx_tasklet(sc, 1, false);
-- clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
--}
--
- static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
- {
- /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
-@@ -735,6 +734,7 @@ static struct ath_buf *ath_get_next_rx_b
- return NULL;
- }
-
-+ list_del(&bf->list);
- if (!bf->bf_mpdu)
- return bf;
-
-@@ -1057,9 +1057,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
-
- do {
- bool decrypt_error = false;
-- /* If handling rx interrupt and flush is in progress => exit */
-- if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
-- break;
-
- memset(&rs, 0, sizeof(rs));
- if (edma)
-@@ -1102,15 +1099,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
-
- ath_debug_stat_rx(sc, &rs);
-
-- /*
-- * If we're asked to flush receive queue, directly
-- * chain it back at the queue without processing it.
-- */
-- if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
-- RX_STAT_INC(rx_drop_rxflush);
-- goto requeue_drop_frag;
-- }
--
- memset(rxs, 0, sizeof(struct ieee80211_rx_status));
-
- rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
-@@ -1245,14 +1233,15 @@ requeue_drop_frag:
- sc->rx.frag = NULL;
- }
- requeue:
-+ list_add_tail(&bf->list, &sc->rx.rxbuf);
-+ if (!flush)
-+ continue;
-+
- if (edma) {
-- list_add_tail(&bf->list, &sc->rx.rxbuf);
- ath_rx_edma_buf_link(sc, qtype);
- } else {
-- list_move_tail(&bf->list, &sc->rx.rxbuf);
- ath_rx_buf_link(sc, bf);
-- if (!flush)
-- ath9k_hw_rxena(ah);
-+ ath9k_hw_rxena(ah);
- }
- } while (1);
-
+ struct sta_ampdu_mlme {
+ struct mutex mtx;