linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH v2 10/16] mac80211: reply only once to each PS-poll
Date: Thu, 29 Sep 2011 16:04:35 +0200	[thread overview]
Message-ID: <20110929140501.289739880@sipsolutions.net> (raw)
In-Reply-To: 20110929140425.390322480@sipsolutions.net

From: Johannes Berg <johannes.berg@intel.com>

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>
---
 include/net/mac80211.h  |    9 ++++++++-
 net/mac80211/rx.c       |   10 ++++++----
 net/mac80211/sta_info.c |   22 +++++++++++-----------
 net/mac80211/sta_info.h |    2 +-
 4 files changed, 26 insertions(+), 17 deletions(-)

--- a/net/mac80211/rx.c	2011-09-29 16:03:17.000000000 +0200
+++ b/net/mac80211/rx.c	2011-09-29 16:03:23.000000000 +0200
@@ -1194,10 +1194,12 @@ ieee80211_rx_h_uapsd_and_pspoll(struct i
 		return RX_CONTINUE;
 
 	if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) {
-		if (!test_sta_flags(rx->sta, WLAN_STA_PS_DRIVER))
-			ieee80211_sta_ps_deliver_poll_response(rx->sta);
-		else
-			set_sta_flags(rx->sta, WLAN_STA_PSPOLL);
+		if (!test_sta_flags(rx->sta, WLAN_STA_SP)) {
+			if (!test_sta_flags(rx->sta, WLAN_STA_PS_DRIVER))
+				ieee80211_sta_ps_deliver_poll_response(rx->sta);
+			else
+				set_sta_flags(rx->sta, WLAN_STA_PSPOLL);
+		}
 
 		/* Free PS Poll skb here instead of returning RX_DROP that would
 		 * count as an dropped frame. */
--- a/net/mac80211/sta_info.h	2011-09-29 16:03:17.000000000 +0200
+++ b/net/mac80211/sta_info.h	2011-09-29 16:03:23.000000000 +0200
@@ -50,7 +50,7 @@
  *	keeping station in power-save mode, reply when the driver
  *	unblocks the station.
  * @WLAN_STA_SP: Station is in a service period, so don't try to
- *	reply to other uAPSD trigger frames.
+ *	reply to other uAPSD trigger frames or PS-Poll.
  */
 enum ieee80211_sta_info_flags {
 	WLAN_STA_AUTH		= 1<<0,
--- a/include/net/mac80211.h	2011-09-29 16:03:17.000000000 +0200
+++ b/include/net/mac80211.h	2011-09-29 16:03:23.000000000 +0200
@@ -370,7 +370,8 @@ struct ieee80211_bss_conf {
  * @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period,
  *	when its status is reported the service period ends. For frames in
  *	an SP that mac80211 transmits, it is already set; for driver frames
- *	the driver may set this flag.
+ *	the driver may set this flag. It is also used to do the same for
+ *	PS-Poll responses.
  *
  * Note: If you have to add new flags to the enumeration, then don't
  *	 forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
@@ -1959,6 +1960,12 @@ enum ieee80211_frame_release_type {
  *	more-data bit must always be set.
  *	The @tids parameter tells the driver which TIDs to release frames
  *	from, for PS-poll it will always have only a single bit set.
+ *	In the case this is used for a PS-poll initiated release, the
+ *	@num_frames parameter will always be 1 so code can be shared. In
+ *	this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag
+ *	on the TX status (and must report TX status) so that the PS-poll
+ *	period is properly ended. This is used to avoid sending multiple
+ *	responses for a retried PS-poll frame.
  *	In the case this is used for uAPSD, the @num_frames parameter may be
  *	bigger than one, but the driver may send fewer frames (it must send
  *	at least one, however). In this case it is also responsible for
--- a/net/mac80211/sta_info.c	2011-09-29 16:03:20.000000000 +0200
+++ b/net/mac80211/sta_info.c	2011-09-29 16:03:23.000000000 +0200
@@ -1217,13 +1217,12 @@ static void ieee80211_send_null_response
 	/*
 	 * Tell TX path to send this frame even though the
 	 * STA may still remain is PS mode after this frame
-	 * exchange.
+	 * exchange. Also set EOSP to indicate this packet
+	 * ends the poll/service period.
 	 */
-	info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE;
-
-	if (uapsd)
-		info->flags |= IEEE80211_TX_STATUS_EOSP |
-			       IEEE80211_TX_CTL_REQ_TX_STATUS;
+	info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE |
+		       IEEE80211_TX_STATUS_EOSP |
+		       IEEE80211_TX_CTL_REQ_TX_STATUS;
 
 	ieee80211_xmit(sdata, skb);
 }
@@ -1241,6 +1240,9 @@ ieee80211_sta_ps_deliver_response(struct
 	unsigned long driver_release_tids = 0;
 	struct sk_buff_head frames;
 
+	/* Service or PS-Poll period starts */
+	set_sta_flags(sta, WLAN_STA_SP);
+
 	__skb_queue_head_init(&frames);
 
 	/*
@@ -1357,10 +1359,11 @@ ieee80211_sta_ps_deliver_response(struct
 				/* set EOSP for the frame */
 				u8 *p = ieee80211_get_qos_ctl(hdr);
 				*p |= IEEE80211_QOS_CTL_EOSP;
-				info->flags |= IEEE80211_TX_STATUS_EOSP |
-					       IEEE80211_TX_CTL_REQ_TX_STATUS;
 			}
 
+			info->flags |= IEEE80211_TX_STATUS_EOSP |
+				       IEEE80211_TX_CTL_REQ_TX_STATUS;
+
 			__skb_queue_tail(&pending, skb);
 		}
 
@@ -1422,9 +1425,6 @@ void ieee80211_sta_ps_deliver_uapsd(stru
 	if (!delivery_enabled)
 		return;
 
-	/* Ohh, finally, the service period starts :-) */
-	set_sta_flags(sta, WLAN_STA_SP);
-
 	switch (sta->sta.max_sp) {
 	case 1:
 		n_frames = 2;



  parent reply	other threads:[~2011-09-29 14:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 14:04 [PATCH v2 00/16] mac80211 uAPSD support Johannes Berg
2011-09-29 14:04 ` [PATCH v2 01/16] mac80211: let drivers inform it about per TID buffered frames Johannes Berg
2011-09-29 14:04 ` [PATCH v2 02/16] mac80211: unify TIM bit handling Johannes Berg
2011-09-29 14:04 ` [PATCH v2 03/16] mac80211: also expire filtered frames Johannes Berg
2011-09-29 14:04 ` [PATCH v2 04/16] mac80211: split PS buffers into ACs Johannes Berg
2011-09-29 14:04 ` [PATCH v2 05/16] mac80211: remove return value from add_pending_skbs Johannes Berg
2011-09-29 14:04 ` [PATCH v2 06/16] mac80211: clear more-data bit on filtered frames Johannes Berg
2011-09-29 14:04 ` [PATCH v2 07/16] mac80211: allow releasing driver-buffered frames Johannes Berg
2011-09-29 14:04 ` [PATCH v2 08/16] mac80211: implement uAPSD Johannes Berg
2011-09-29 14:04 ` [PATCH v2 09/16] mac80211: send (QoS) Null if no buffered frames Johannes Berg
2011-09-29 14:04 ` Johannes Berg [this message]
2011-09-29 14:04 ` [PATCH v2 11/16] mac80211: optimise station flags Johannes Berg
2011-09-29 14:04 ` [PATCH v2 12/16] mac80211: add missing station flags to debugfs Johannes Berg
2011-09-29 14:04 ` [PATCH v2 13/16] mac80211: explicitly notify drivers of frame release Johannes Berg
2011-09-29 14:04 ` [PATCH v2 14/16] mac80211: allow out-of-band EOSP notification Johannes Berg
2011-09-29 14:04 ` [PATCH v2 15/16] mac80211: document client powersave Johannes Berg
2011-09-29 14:04 ` [PATCH v2 16/16] mac80211: dont assign seqno to or aggregate QoS Null frames Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110929140501.289739880@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).