Skip to content

Commit 47086fc

Browse files
jmberg-intellinvjw
authored andcommitted
mac80211: implement uAPSD
Add uAPSD support to mac80211. This is probably not possible with all devices, so advertising it with the cfg80211 flag will be left up to drivers that want it. Due to my previous patches it is now a fairly straight-forward extension. Drivers need to have accurate TX status reporting for the EOSP frame. For drivers that buffer themselves, the provided APIs allow releasing the right number of frames, but then drivers need to set EOSP and more-data themselves. This is documented in more detail in the new code itself. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 4049e09 commit 47086fc

9 files changed

Lines changed: 244 additions & 89 deletions

File tree

‎drivers/net/wireless/iwlegacy/iwl-4965-tx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
335335
sta_priv = (void *)sta->drv_priv;
336336

337337
if (sta_priv && sta_priv->asleep &&
338-
(info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)) {
338+
(info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
339339
/*
340340
* This sends an asynchronous command to the device,
341341
* but we can rely on it being processed before the

‎drivers/net/wireless/iwlwifi/iwl-agn-tx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
300300
sta_priv = (void *)info->control.sta->drv_priv;
301301

302302
if (sta_priv && sta_priv->asleep &&
303-
(info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)) {
303+
(info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) {
304304
/*
305305
* This sends an asynchronous command to the device,
306306
* but we can rely on it being processed before the

‎drivers/net/wireless/p54/txrx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
689689
if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))
690690
*flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
691691

692-
if (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)
692+
if (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)
693693
*flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL;
694694

695695
if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)

‎include/net/mac80211.h‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ struct ieee80211_bss_conf {
339339
* used to indicate that a frame was already retried due to PS
340340
* @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
341341
* used to indicate frame should not be encrypted
342-
* @IEEE80211_TX_CTL_PSPOLL_RESPONSE: (internal?)
343-
* This frame is a response to a PS-poll frame and should be sent
344-
* although the station is in powersave mode.
342+
* @IEEE80211_TX_CTL_POLL_RESPONSE: This frame is a response to a poll
343+
* frame (PS-Poll or uAPSD) and should be sent although the station
344+
* is in powersave mode.
345345
* @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
346346
* transmit function after the current frame, this can be used
347347
* by drivers to kick the DMA queue only if unset or when the
@@ -367,6 +367,10 @@ struct ieee80211_bss_conf {
367367
* @IEEE80211_TX_CTL_NO_CCK_RATE: This frame will be sent at non CCK rate.
368368
* This flag is actually used for management frame especially for P2P
369369
* frames not being sent at CCK rate in 2GHz band.
370+
* @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period,
371+
* when its status is reported the service period ends. For frames in
372+
* an SP that mac80211 transmits, it is already set; for driver frames
373+
* the driver may set this flag.
370374
*
371375
* Note: If you have to add new flags to the enumeration, then don't
372376
* forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
@@ -388,7 +392,7 @@ enum mac80211_tx_control_flags {
388392
IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14),
389393
IEEE80211_TX_INTFL_RETRIED = BIT(15),
390394
IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16),
391-
IEEE80211_TX_CTL_PSPOLL_RESPONSE = BIT(17),
395+
IEEE80211_TX_CTL_POLL_RESPONSE = BIT(17),
392396
IEEE80211_TX_CTL_MORE_FRAMES = BIT(18),
393397
IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19),
394398
IEEE80211_TX_INTFL_HAS_RADIOTAP = BIT(20),
@@ -398,6 +402,7 @@ enum mac80211_tx_control_flags {
398402
IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25),
399403
IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26),
400404
IEEE80211_TX_CTL_NO_CCK_RATE = BIT(27),
405+
IEEE80211_TX_STATUS_EOSP = BIT(28),
401406
};
402407

403408
#define IEEE80211_TX_CTL_STBC_SHIFT 23
@@ -411,9 +416,9 @@ enum mac80211_tx_control_flags {
411416
IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \
412417
IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \
413418
IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \
414-
IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_PSPOLL_RESPONSE | \
419+
IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_POLL_RESPONSE | \
415420
IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \
416-
IEEE80211_TX_CTL_STBC)
421+
IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP)
417422

418423
/**
419424
* enum mac80211_rate_control_flags - per-rate flags set by the
@@ -1624,9 +1629,12 @@ enum ieee80211_tx_sync_type {
16241629
/**
16251630
* enum ieee80211_frame_release_type - frame release reason
16261631
* @IEEE80211_FRAME_RELEASE_PSPOLL: frame released for PS-Poll
1632+
* @IEEE80211_FRAME_RELEASE_UAPSD: frame(s) released due to
1633+
* frame received on trigger-enabled AC
16271634
*/
16281635
enum ieee80211_frame_release_type {
16291636
IEEE80211_FRAME_RELEASE_PSPOLL,
1637+
IEEE80211_FRAME_RELEASE_UAPSD,
16301638
};
16311639

16321640
/**
@@ -1954,7 +1962,9 @@ enum ieee80211_frame_release_type {
19541962
* In the case this is used for uAPSD, the @num_frames parameter may be
19551963
* bigger than one, but the driver may send fewer frames (it must send
19561964
* at least one, however). In this case it is also responsible for
1957-
* setting the EOSP flag in the QoS header of the frames.
1965+
* setting the EOSP flag in the QoS header of the frames. Also, when the
1966+
* service period ends, the driver must set %IEEE80211_TX_STATUS_EOSP
1967+
* on the last frame in the SP.
19581968
* This callback must be atomic.
19591969
*/
19601970
struct ieee80211_ops {

‎net/mac80211/rx.c‎

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,79 @@ int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start)
11621162
}
11631163
EXPORT_SYMBOL(ieee80211_sta_ps_transition);
11641164

1165+
static ieee80211_rx_result debug_noinline
1166+
ieee80211_rx_h_uapsd_and_pspoll(struct ieee80211_rx_data *rx)
1167+
{
1168+
struct ieee80211_sub_if_data *sdata = rx->sdata;
1169+
struct ieee80211_hdr *hdr = (void *)rx->skb->data;
1170+
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
1171+
int tid, ac;
1172+
1173+
if (!rx->sta || !(status->rx_flags & IEEE80211_RX_RA_MATCH))
1174+
return RX_CONTINUE;
1175+
1176+
if (sdata->vif.type != NL80211_IFTYPE_AP &&
1177+
sdata->vif.type != NL80211_IFTYPE_AP_VLAN)
1178+
return RX_CONTINUE;
1179+
1180+
/*
1181+
* The device handles station powersave, so don't do anything about
1182+
* uAPSD and PS-Poll frames (the latter shouldn't even come up from
1183+
* it to mac80211 since they're handled.)
1184+
*/
1185+
if (sdata->local->hw.flags & IEEE80211_HW_AP_LINK_PS)
1186+
return RX_CONTINUE;
1187+
1188+
/*
1189+
* Don't do anything if the station isn't already asleep. In
1190+
* the uAPSD case, the station will probably be marked asleep,
1191+
* in the PS-Poll case the station must be confused ...
1192+
*/
1193+
if (!test_sta_flags(rx->sta, WLAN_STA_PS_STA))
1194+
return RX_CONTINUE;
1195+
1196+
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);
1201+
1202+
/* Free PS Poll skb here instead of returning RX_DROP that would
1203+
* count as an dropped frame. */
1204+
dev_kfree_skb(rx->skb);
1205+
1206+
return RX_QUEUED;
1207+
} else if (!ieee80211_has_morefrags(hdr->frame_control) &&
1208+
!(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
1209+
ieee80211_has_pm(hdr->frame_control) &&
1210+
(ieee80211_is_data_qos(hdr->frame_control) ||
1211+
ieee80211_is_qos_nullfunc(hdr->frame_control))) {
1212+
tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
1213+
ac = ieee802_1d_to_ac[tid & 7];
1214+
1215+
/*
1216+
* If this AC is not trigger-enabled do nothing.
1217+
*
1218+
* NB: This could/should check a separate bitmap of trigger-
1219+
* enabled queues, but for now we only implement uAPSD w/o
1220+
* TSPEC changes to the ACs, so they're always the same.
1221+
*/
1222+
if (!(rx->sta->sta.uapsd_queues & BIT(ac)))
1223+
return RX_CONTINUE;
1224+
1225+
/* if we are in a service period, do nothing */
1226+
if (test_sta_flags(rx->sta, WLAN_STA_SP))
1227+
return RX_CONTINUE;
1228+
1229+
if (!test_sta_flags(rx->sta, WLAN_STA_PS_DRIVER))
1230+
ieee80211_sta_ps_deliver_uapsd(rx->sta);
1231+
else
1232+
set_sta_flags(rx->sta, WLAN_STA_UAPSD);
1233+
}
1234+
1235+
return RX_CONTINUE;
1236+
}
1237+
11651238
static ieee80211_rx_result debug_noinline
11661239
ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
11671240
{
@@ -1472,33 +1545,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
14721545
return RX_CONTINUE;
14731546
}
14741547

1475-
static ieee80211_rx_result debug_noinline
1476-
ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
1477-
{
1478-
struct ieee80211_sub_if_data *sdata = rx->sdata;
1479-
__le16 fc = ((struct ieee80211_hdr *)rx->skb->data)->frame_control;
1480-
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
1481-
1482-
if (likely(!rx->sta || !ieee80211_is_pspoll(fc) ||
1483-
!(status->rx_flags & IEEE80211_RX_RA_MATCH)))
1484-
return RX_CONTINUE;
1485-
1486-
if ((sdata->vif.type != NL80211_IFTYPE_AP) &&
1487-
(sdata->vif.type != NL80211_IFTYPE_AP_VLAN))
1488-
return RX_DROP_UNUSABLE;
1489-
1490-
if (!test_sta_flags(rx->sta, WLAN_STA_PS_DRIVER))
1491-
ieee80211_sta_ps_deliver_poll_response(rx->sta);
1492-
else
1493-
set_sta_flags(rx->sta, WLAN_STA_PSPOLL);
1494-
1495-
/* Free PS Poll skb here instead of returning RX_DROP that would
1496-
* count as an dropped frame. */
1497-
dev_kfree_skb(rx->skb);
1498-
1499-
return RX_QUEUED;
1500-
}
1501-
15021548
static ieee80211_rx_result debug_noinline
15031549
ieee80211_rx_h_remove_qos_control(struct ieee80211_rx_data *rx)
15041550
{
@@ -2567,9 +2613,9 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx)
25672613

25682614
CALL_RXH(ieee80211_rx_h_decrypt)
25692615
CALL_RXH(ieee80211_rx_h_check_more_data)
2616+
CALL_RXH(ieee80211_rx_h_uapsd_and_pspoll)
25702617
CALL_RXH(ieee80211_rx_h_sta_process)
25712618
CALL_RXH(ieee80211_rx_h_defragment)
2572-
CALL_RXH(ieee80211_rx_h_ps_poll)
25732619
CALL_RXH(ieee80211_rx_h_michael_mic_verify)
25742620
/* must be after MMIC verify so header is counted in MPDU mic */
25752621
#ifdef CONFIG_MAC80211_MESH

0 commit comments

Comments
 (0)