1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -202,6 +202,7 @@ struct ath_atx_ac {
6 struct list_head tid_q;
7 + bool clear_ps_filter;
10 struct ath_frame_info {
11 @@ -259,6 +260,8 @@ struct ath_node {
12 struct ath_atx_ac ac[WME_NUM_AC];
19 #define AGGR_CLEANUP BIT(1)
20 @@ -340,6 +343,9 @@ int ath_tx_aggr_start(struct ath_softc *
21 void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
22 void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
24 +void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
25 +bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an);
30 --- a/drivers/net/wireless/ath/ath9k/main.c
31 +++ b/drivers/net/wireless/ath/ath9k/main.c
32 @@ -1791,6 +1791,27 @@ static int ath9k_sta_remove(struct ieee8
36 +static void ath9k_sta_notify(struct ieee80211_hw *hw,
37 + struct ieee80211_vif *vif,
38 + enum sta_notify_cmd cmd,
39 + struct ieee80211_sta *sta)
41 + struct ath_softc *sc = hw->priv;
42 + struct ath_node *an = (struct ath_node *) sta->drv_priv;
45 + case STA_NOTIFY_SLEEP:
46 + an->sleeping = true;
47 + if (ath_tx_aggr_sleep(sc, an))
48 + ieee80211_sta_set_tim(sta);
50 + case STA_NOTIFY_AWAKE:
51 + an->sleeping = false;
52 + ath_tx_aggr_wakeup(sc, an);
57 static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
58 const struct ieee80211_tx_queue_params *params)
60 @@ -2177,6 +2198,7 @@ struct ieee80211_ops ath9k_ops = {
61 .configure_filter = ath9k_configure_filter,
62 .sta_add = ath9k_sta_add,
63 .sta_remove = ath9k_sta_remove,
64 + .sta_notify = ath9k_sta_notify,
65 .conf_tx = ath9k_conf_tx,
66 .bss_info_changed = ath9k_bss_info_changed,
67 .set_key = ath9k_set_key,
68 --- a/drivers/net/wireless/ath/ath9k/xmit.c
69 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
70 @@ -357,6 +357,7 @@ static void ath_tx_complete_aggr(struct
71 struct ath_frame_info *fi;
77 hdr = (struct ieee80211_hdr *)skb->data;
78 @@ -442,7 +443,11 @@ static void ath_tx_complete_aggr(struct
81 if (!(tid->state & AGGR_CLEANUP) && retry) {
82 - if (fi->retries < ATH_MAX_SW_RETRIES) {
83 + if (ts->ts_status & ATH9K_TXERR_FILT) {
85 + clear_filter = true;
87 + } else if (fi->retries < ATH_MAX_SW_RETRIES) {
88 ath_tx_set_retry(sc, txq, bf->bf_mpdu);
91 @@ -496,6 +501,7 @@ static void ath_tx_complete_aggr(struct
94 /* retry the un-acked ones */
95 + ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, false);
96 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) {
97 if (bf->bf_next == NULL && bf_last->bf_stale) {
99 @@ -546,7 +552,12 @@ static void ath_tx_complete_aggr(struct
101 /* prepend un-acked frames to the beginning of the pending frame queue */
102 if (!list_empty(&bf_pending)) {
104 + ieee80211_sta_set_tim(sta);
106 spin_lock_bh(&txq->axq_lock);
108 + tid->ac->clear_ps_filter = true;
109 list_splice(&bf_pending, &tid->buf_q);
110 ath_tx_queue_tid(txq, tid);
111 spin_unlock_bh(&txq->axq_lock);
112 @@ -816,6 +827,11 @@ static void ath_tx_sched_aggr(struct ath
113 bf = list_first_entry(&bf_q, struct ath_buf, list);
114 bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
116 + if (tid->ac->clear_ps_filter) {
117 + tid->ac->clear_ps_filter = false;
118 + ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
121 /* if only one frame, send as non-aggregate */
122 if (bf == bf->bf_lastbf) {
123 fi = get_frame_info(bf->bf_mpdu);
124 @@ -896,6 +912,67 @@ void ath_tx_aggr_stop(struct ath_softc *
125 ath_tx_flush_tid(sc, txtid);
128 +bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
130 + struct ath_atx_tid *tid;
131 + struct ath_atx_ac *ac;
132 + struct ath_txq *txq;
133 + bool buffered = false;
136 + for (tidno = 0, tid = &an->tid[tidno];
137 + tidno < WME_NUM_TID; tidno++, tid++) {
145 + spin_lock_bh(&txq->axq_lock);
147 + if (!list_empty(&tid->buf_q))
150 + tid->sched = false;
151 + list_del(&tid->list);
155 + list_del(&ac->list);
158 + spin_unlock_bh(&txq->axq_lock);
164 +void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
166 + struct ath_atx_tid *tid;
167 + struct ath_atx_ac *ac;
168 + struct ath_txq *txq;
171 + for (tidno = 0, tid = &an->tid[tidno];
172 + tidno < WME_NUM_TID; tidno++, tid++) {
177 + spin_lock_bh(&txq->axq_lock);
178 + ac->clear_ps_filter = true;
180 + if (!list_empty(&tid->buf_q) && !tid->paused) {
181 + ath_tx_queue_tid(txq, tid);
182 + ath_txq_schedule(sc, txq);
185 + spin_unlock_bh(&txq->axq_lock);
189 void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
191 struct ath_atx_tid *txtid;
192 @@ -1491,7 +1568,6 @@ static int setup_tx_flags(struct sk_buff
193 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
196 - flags |= ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */
197 flags |= ATH9K_TXDESC_INTREQ;
199 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
200 @@ -1754,6 +1830,9 @@ static void ath_tx_start_dma(struct ath_
202 bf->bf_state.bfs_paprd_timestamp = jiffies;
204 + if (tx_info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
205 + ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, true);
207 ath_tx_send_normal(sc, txctl->txq, tid, &bf_head);
210 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
211 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
212 @@ -128,6 +128,11 @@ static inline void ath9k_hw_set11n_virtu
213 ath9k_hw_ops(ah)->set11n_virtualmorefrag(ah, ds, vmf);
216 +static inline void ath9k_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
218 + ath9k_hw_ops(ah)->set_clrdmask(ah, ds, val);
221 /* Private hardware call ops */
224 --- a/drivers/net/wireless/ath/ath9k/hw.h
225 +++ b/drivers/net/wireless/ath/ath9k/hw.h
226 @@ -642,6 +642,7 @@ struct ath_hw_ops {
228 void (*set11n_virtualmorefrag)(struct ath_hw *ah, void *ds,
230 + void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val);
233 struct ath_nf_limits {
234 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
235 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
236 @@ -290,7 +290,6 @@ static void ar9002_hw_set11n_txdesc(stru
237 | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
238 | SM(txPower, AR_XmitPower)
239 | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
240 - | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
241 | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
242 | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
244 @@ -311,6 +310,16 @@ static void ar9002_hw_set11n_txdesc(stru
248 +static void ar9002_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
250 + struct ar5416_desc *ads = AR5416DESC(ds);
253 + ads->ds_ctl0 |= AR_ClrDestMask;
255 + ads->ds_ctl0 &= ~AR_ClrDestMask;
258 static void ar9002_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
260 u32 durUpdateEn, u32 rtsctsRate,
261 @@ -460,4 +469,5 @@ void ar9002_hw_attach_mac_ops(struct ath
262 ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
263 ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
264 ops->set11n_virtualmorefrag = ar9002_hw_set11n_virtualmorefrag;
265 + ops->set_clrdmask = ar9002_hw_set_clrdmask;
267 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
268 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
269 @@ -329,7 +329,6 @@ static void ar9003_hw_set11n_txdesc(stru
270 | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
271 | SM(txpower, AR_XmitPower)
272 | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
273 - | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
274 | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0)
275 | (flags & ATH9K_TXDESC_LOWRXCHAIN ? AR_LowRxChain : 0);
277 @@ -350,6 +349,16 @@ static void ar9003_hw_set11n_txdesc(stru
281 +static void ar9003_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
283 + struct ar9003_txc *ads = (struct ar9003_txc *) ds;
286 + ads->ctl11 |= AR_ClrDestMask;
288 + ads->ctl11 &= ~AR_ClrDestMask;
291 static void ar9003_hw_set11n_ratescenario(struct ath_hw *ah, void *ds,
293 u32 durUpdateEn, u32 rtsctsRate,
294 @@ -522,6 +531,7 @@ void ar9003_hw_attach_mac_ops(struct ath
295 ops->clr11n_aggr = ar9003_hw_clr11n_aggr;
296 ops->set11n_burstduration = ar9003_hw_set11n_burstduration;
297 ops->set11n_virtualmorefrag = ar9003_hw_set11n_virtualmorefrag;
298 + ops->set_clrdmask = ar9003_hw_set_clrdmask;
301 void ath9k_hw_set_rx_bufsize(struct ath_hw *ah, u16 buf_size)
302 --- a/drivers/net/wireless/ath/ath9k/mac.h
303 +++ b/drivers/net/wireless/ath/ath9k/mac.h
304 @@ -239,7 +239,6 @@ struct ath_desc {
306 } __packed __aligned(4);
308 -#define ATH9K_TXDESC_CLRDMASK 0x0001
309 #define ATH9K_TXDESC_NOACK 0x0002
310 #define ATH9K_TXDESC_RTSENA 0x0004
311 #define ATH9K_TXDESC_CTSENA 0x0008