1 --- a/include/net/mac80211.h
2 +++ b/include/net/mac80211.h
3 @@ -2216,6 +2216,18 @@ static inline int ieee80211_sta_ps_trans
4 #define IEEE80211_TX_STATUS_HEADROOM 13
7 + * ieee80211_sta_set_tim - set the TIM bit for a sleeping station
9 + * If a driver buffers frames for a powersave station instead of passing
10 + * them back to mac80211 for retransmission, the station needs to be told
11 + * to wake up using the TIM bitmap in the beacon.
13 + * This function sets the station's TIM bit - it will be cleared when the
16 +void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
19 * ieee80211_tx_status - transmit status callback
21 * Call this function for all transmitted frames after they have been
22 --- a/net/mac80211/sta_info.c
23 +++ b/net/mac80211/sta_info.c
24 @@ -609,7 +609,8 @@ static bool sta_info_cleanup_expire_buff
28 - if (skb_queue_empty(&sta->ps_tx_buf))
29 + if (skb_queue_empty(&sta->ps_tx_buf) &&
30 + !test_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF))
31 sta_info_clear_tim_bit(sta);
34 @@ -902,6 +903,7 @@ void ieee80211_sta_ps_deliver_wakeup(str
35 struct ieee80211_local *local = sdata->local;
38 + clear_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
39 if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
40 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
42 @@ -994,3 +996,12 @@ void ieee80211_sta_block_awake(struct ie
43 ieee80211_queue_work(hw, &sta->drv_unblock_wk);
45 EXPORT_SYMBOL(ieee80211_sta_block_awake);
47 +void ieee80211_sta_set_tim(struct ieee80211_sta *pubsta)
49 + struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
51 + set_sta_flags(sta, WLAN_STA_PS_DRIVER_BUF);
52 + sta_info_set_tim_bit(sta);
54 +EXPORT_SYMBOL(ieee80211_sta_set_tim);
55 --- a/net/mac80211/sta_info.h
56 +++ b/net/mac80211/sta_info.h
59 * @WLAN_STA_PSPOLL: Station sent PS-poll while driver was keeping
60 * station in power-save mode, reply when the driver unblocks.
61 + * @WLAN_STA_PS_DRIVER_BUF: Station has frames pending in driver internal
62 + * buffers. Automatically cleared on station wake-up.
64 enum ieee80211_sta_info_flags {
66 @@ -58,6 +60,7 @@ enum ieee80211_sta_info_flags {
67 WLAN_STA_BLOCK_BA = 1<<11,
68 WLAN_STA_PS_DRIVER = 1<<12,
69 WLAN_STA_PSPOLL = 1<<13,
70 + WLAN_STA_PS_DRIVER_BUF = 1<<14,
73 #define STA_TID_NUM 16