Skip to content

Commit deeaee1

Browse files
jmberg-intellinvjw
authored andcommitted
mac80211: reply only once to each PS-poll
If a PS-poll frame is retried (but was received) there is no way to detect that since it has no sequence number. As a consequence, the standard asks us to not react to PS-poll frames until the response to one made it out (was ACKed or lost). Implement this by using the WLAN_STA_SP flags to also indicate a PS-Poll "service period" and the IEEE80211_TX_STATUS_EOSP flag for the response packet to indicate the end of the "SP" as usual. We could use separate flags, but that will most likely completely confuse drivers, and while the standard doesn't exclude simultaneously polling using uAPSD and PS-Poll, doing that seems quite problematic. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent ce662b4 commit deeaee1

4 files changed

Lines changed: 26 additions & 17 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ struct ieee80211_bss_conf {
370370
* @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period,
371371
* when its status is reported the service period ends. For frames in
372372
* an SP that mac80211 transmits, it is already set; for driver frames
373-
* the driver may set this flag.
373+
* the driver may set this flag. It is also used to do the same for
374+
* PS-Poll responses.
374375
*
375376
* Note: If you have to add new flags to the enumeration, then don't
376377
* forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
@@ -1959,6 +1960,12 @@ enum ieee80211_frame_release_type {
19591960
* more-data bit must always be set.
19601961
* The @tids parameter tells the driver which TIDs to release frames
19611962
* from, for PS-poll it will always have only a single bit set.
1963+
* In the case this is used for a PS-poll initiated release, the
1964+
* @num_frames parameter will always be 1 so code can be shared. In
1965+
* this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag
1966+
* on the TX status (and must report TX status) so that the PS-poll
1967+
* period is properly ended. This is used to avoid sending multiple
1968+
* responses for a retried PS-poll frame.
19621969
* In the case this is used for uAPSD, the @num_frames parameter may be
19631970
* bigger than one, but the driver may send fewer frames (it must send
19641971
* at least one, however). In this case it is also responsible for

‎net/mac80211/rx.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,10 +1194,12 @@ ieee80211_rx_h_uapsd_and_pspoll(struct ieee80211_rx_data *rx)
11941194
return RX_CONTINUE;
11951195

11961196
if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) {
1197-
if (!test_sta_flags(rx->sta, WLAN_STA_PS_DRIVER))
1198-
ieee80211_sta_ps_deliver_poll_response(rx->sta);
1199-
else
1200-
set_sta_flags(rx->sta, WLAN_STA_PSPOLL);
1197+
if (!test_sta_flags(rx->sta, WLAN_STA_SP)) {
1198+
if (!test_sta_flags(rx->sta, WLAN_STA_PS_DRIVER))
1199+
ieee80211_sta_ps_deliver_poll_response(rx->sta);
1200+
else
1201+
set_sta_flags(rx->sta, WLAN_STA_PSPOLL);
1202+
}
12011203

12021204
/* Free PS Poll skb here instead of returning RX_DROP that would
12031205
* count as an dropped frame. */

‎net/mac80211/sta_info.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,13 +1217,12 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
12171217
/*
12181218
* Tell TX path to send this frame even though the
12191219
* STA may still remain is PS mode after this frame
1220-
* exchange.
1220+
* exchange. Also set EOSP to indicate this packet
1221+
* ends the poll/service period.
12211222
*/
1222-
info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE;
1223-
1224-
if (uapsd)
1225-
info->flags |= IEEE80211_TX_STATUS_EOSP |
1226-
IEEE80211_TX_CTL_REQ_TX_STATUS;
1223+
info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE |
1224+
IEEE80211_TX_STATUS_EOSP |
1225+
IEEE80211_TX_CTL_REQ_TX_STATUS;
12271226

12281227
ieee80211_xmit(sdata, skb);
12291228
}
@@ -1241,6 +1240,9 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
12411240
unsigned long driver_release_tids = 0;
12421241
struct sk_buff_head frames;
12431242

1243+
/* Service or PS-Poll period starts */
1244+
set_sta_flags(sta, WLAN_STA_SP);
1245+
12441246
__skb_queue_head_init(&frames);
12451247

12461248
/*
@@ -1357,10 +1359,11 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
13571359
/* set EOSP for the frame */
13581360
u8 *p = ieee80211_get_qos_ctl(hdr);
13591361
*p |= IEEE80211_QOS_CTL_EOSP;
1360-
info->flags |= IEEE80211_TX_STATUS_EOSP |
1361-
IEEE80211_TX_CTL_REQ_TX_STATUS;
13621362
}
13631363

1364+
info->flags |= IEEE80211_TX_STATUS_EOSP |
1365+
IEEE80211_TX_CTL_REQ_TX_STATUS;
1366+
13641367
__skb_queue_tail(&pending, skb);
13651368
}
13661369

@@ -1422,9 +1425,6 @@ void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta)
14221425
if (!delivery_enabled)
14231426
return;
14241427

1425-
/* Ohh, finally, the service period starts :-) */
1426-
set_sta_flags(sta, WLAN_STA_SP);
1427-
14281428
switch (sta->sta.max_sp) {
14291429
case 1:
14301430
n_frames = 2;

‎net/mac80211/sta_info.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* keeping station in power-save mode, reply when the driver
5151
* unblocks the station.
5252
* @WLAN_STA_SP: Station is in a service period, so don't try to
53-
* reply to other uAPSD trigger frames.
53+
* reply to other uAPSD trigger frames or PS-Poll.
5454
*/
5555
enum ieee80211_sta_info_flags {
5656
WLAN_STA_AUTH = 1<<0,

0 commit comments

Comments
 (0)