Skip to content

Commit 042ec45

Browse files
jmberg-intellinvjw
authored andcommitted
mac80211: let drivers inform it about per TID buffered frames
For uAPSD implementation, it is necessary to know on which ACs frames are buffered. mac80211 obviously knows about the frames it has buffered itself, but with aggregation many drivers buffer frames. Thus, mac80211 needs to be informed about this. For now, since we don't have APSD in any form, this will unconditionally set the TIM bit for the station but later with uAPSD only some ACs might cause the TIM bit to be set. ath9k is the only driver using this API and I only modify it in the most basic way, it won't be able to implement uAPSD with this yet. But it can't do that anyway since there's no way to selectively release frames to the peer yet. Since drivers will buffer frames per TID, let them inform mac80211 on a per TID basis, mac80211 will then sort out the AC mapping itself. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 941c93c commit 042ec45

5 files changed

Lines changed: 42 additions & 20 deletions

File tree

‎drivers/net/wireless/ath/ath9k/ath9k.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
340340
void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
341341

342342
void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
343-
bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an);
343+
void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
344+
struct ath_node *an);
344345

345346
/********/
346347
/* VIFs */

‎drivers/net/wireless/ath/ath9k/main.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,8 +1833,7 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
18331833
switch (cmd) {
18341834
case STA_NOTIFY_SLEEP:
18351835
an->sleeping = true;
1836-
if (ath_tx_aggr_sleep(sc, an))
1837-
ieee80211_sta_set_tim(sta);
1836+
ath_tx_aggr_sleep(sta, sc, an);
18381837
break;
18391838
case STA_NOTIFY_AWAKE:
18401839
an->sleeping = false;

‎drivers/net/wireless/ath/ath9k/xmit.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
542542
/* prepend un-acked frames to the beginning of the pending frame queue */
543543
if (!skb_queue_empty(&bf_pending)) {
544544
if (an->sleeping)
545-
ieee80211_sta_set_tim(sta);
545+
ieee80211_sta_set_buffered(sta, tid->tidno, true);
546546

547547
spin_lock_bh(&txq->axq_lock);
548548
if (clear_filter)
@@ -1153,12 +1153,13 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
11531153
ath_tx_flush_tid(sc, txtid);
11541154
}
11551155

1156-
bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
1156+
void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
1157+
struct ath_node *an)
11571158
{
11581159
struct ath_atx_tid *tid;
11591160
struct ath_atx_ac *ac;
11601161
struct ath_txq *txq;
1161-
bool buffered = false;
1162+
bool buffered;
11621163
int tidno;
11631164

11641165
for (tidno = 0, tid = &an->tid[tidno];
@@ -1172,8 +1173,7 @@ bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
11721173

11731174
spin_lock_bh(&txq->axq_lock);
11741175

1175-
if (!skb_queue_empty(&tid->buf_q))
1176-
buffered = true;
1176+
buffered = !skb_queue_empty(&tid->buf_q);
11771177

11781178
tid->sched = false;
11791179
list_del(&tid->list);
@@ -1184,9 +1184,9 @@ bool ath_tx_aggr_sleep(struct ath_softc *sc, struct ath_node *an)
11841184
}
11851185

11861186
spin_unlock_bh(&txq->axq_lock);
1187-
}
11881187

1189-
return buffered;
1188+
ieee80211_sta_set_buffered(sta, tidno, buffered);
1189+
}
11901190
}
11911191

11921192
void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)

‎include/net/mac80211.h‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,17 +2361,35 @@ static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta,
23612361
#define IEEE80211_TX_STATUS_HEADROOM 13
23622362

23632363
/**
2364-
* ieee80211_sta_set_tim - set the TIM bit for a sleeping station
2364+
* ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames
23652365
* @sta: &struct ieee80211_sta pointer for the sleeping station
2366+
* @tid: the TID that has buffered frames
2367+
* @buffered: indicates whether or not frames are buffered for this TID
23662368
*
23672369
* If a driver buffers frames for a powersave station instead of passing
2368-
* them back to mac80211 for retransmission, the station needs to be told
2369-
* to wake up using the TIM bitmap in the beacon.
2370-
*
2371-
* This function sets the station's TIM bit - it will be cleared when the
2372-
* station wakes up.
2373-
*/
2374-
void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
2370+
* them back to mac80211 for retransmission, the station may still need
2371+
* to be told that there are buffered frames via the TIM bit.
2372+
*
2373+
* This function informs mac80211 whether or not there are frames that are
2374+
* buffered in the driver for a given TID; mac80211 can then use this data
2375+
* to set the TIM bit (NOTE: This may call back into the driver's set_tim
2376+
* call! Beware of the locking!)
2377+
*
2378+
* If all frames are released to the station (due to PS-poll or uAPSD)
2379+
* then the driver needs to inform mac80211 that there no longer are
2380+
* frames buffered. However, when the station wakes up mac80211 assumes
2381+
* that all buffered frames will be transmitted and clears this data,
2382+
* drivers need to make sure they inform mac80211 about all buffered
2383+
* frames on the sleep transition (sta_notify() with %STA_NOTIFY_SLEEP).
2384+
*
2385+
* Note that technically mac80211 only needs to know this per AC, not per
2386+
* TID, but since driver buffering will inevitably happen per TID (since
2387+
* it is related to aggregation) it is easier to make mac80211 map the
2388+
* TID to the AC as required instead of keeping track in all drivers that
2389+
* use this API.
2390+
*/
2391+
void ieee80211_sta_set_buffered(struct ieee80211_sta *sta,
2392+
u8 tid, bool buffered);
23752393

23762394
/**
23772395
* ieee80211_tx_status - transmit status callback

‎net/mac80211/sta_info.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,11 +1117,15 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
11171117
}
11181118
EXPORT_SYMBOL(ieee80211_sta_block_awake);
11191119

1120-
void ieee80211_sta_set_tim(struct ieee80211_sta *pubsta)
1120+
void ieee80211_sta_set_buffered(struct ieee80211_sta *pubsta,
1121+
u8 tid, bool buffered)
11211122
{
11221123
struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
11231124

1125+
if (!buffered)
1126+
return;
1127+
11241128
set_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
11251129
sta_info_set_tim_bit(sta);
11261130
}
1127-
EXPORT_SYMBOL(ieee80211_sta_set_tim);
1131+
EXPORT_SYMBOL(ieee80211_sta_set_buffered);

0 commit comments

Comments
 (0)