linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kalle.valo@nokia.com>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes@sipsolutions.net>,
	Jouni Malinen <j@w1.fi>,
	"Luis R. Rodriguez" <lrodriguez@atheros.com>
Subject: [RFC PATCH v2 3/4] mac80211: disable power save when scanning
Date: Sat, 14 Mar 2009 19:14:45 +0200	[thread overview]
Message-ID: <20090314171445.11126.97668.stgit@tikku> (raw)
In-Reply-To: <20090314171234.11126.21125.stgit@tikku>

When software scanning we need to disable power save so that all possible
probe responses and beacons are received. For hardware scanning assume that
hardware will take care of that and document that assumption.

Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
---

 include/net/mac80211.h |   12 ++++++-----
 net/mac80211/scan.c    |   54 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 12a52ef..9ef131d 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1318,11 +1318,13 @@ enum ieee80211_ampdu_mlme_action {
  *
  * @hw_scan: Ask the hardware to service the scan request, no need to start
  *	the scan state machine in stack. The scan must honour the channel
- *	configuration done by the regulatory agent in the wiphy's registered
- *	bands. When the scan finishes, ieee80211_scan_completed() must be
- *	called; note that it also must be called when the scan cannot finish
- *	because the hardware is turned off! Anything else is a bug!
- *	Returns a negative error code which will be seen in userspace.
+ *	configuration done by the regulatory agent in the wiphy's
+ *	registered bands. The hardware (or the driver) needs to make sure
+ *	that power save is disabled. When the scan finishes,
+ *	ieee80211_scan_completed() must be called; note that it also must
+ *	be called when the scan cannot finish because the hardware is
+ *	turned off! Anything else is a bug! Returns a negative error code
+ *	which will be seen in userspace.
  *
  * @sw_scan_start: Notifier function that is called just before a software scan
  *	is started. Can be NULL, if the driver doesn't need this notification.
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 0e81e16..dec7d5a 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -202,6 +202,56 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
 	return RX_QUEUED;
 }
 
+/*
+ * inform AP that we will go to sleep so that it will buffer the frames
+ * while we scan
+ */
+static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
+{
+	struct ieee80211_local *local = sdata->local;
+	bool ps = false;
+
+	/* FIXME: what to do when local->pspolling is true? */
+
+	del_timer_sync(&local->dynamic_ps_timer);
+	cancel_work_sync(&local->dynamic_ps_enable_work);
+
+	if (local->hw.conf.flags & IEEE80211_CONF_PS) {
+		ps = true;
+		local->hw.conf.flags &= ~IEEE80211_CONF_PS;
+		ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
+	}
+
+	if (!ps || (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+		/*
+		 * with IEEE80211_HW_PS_NULLFUNC_STACK and power save
+		 * enabled the firmware sent a null frame when power save
+		 * was disabled, so we need to send a new null frame
+		 */
+		ieee80211_send_nullfunc(local, sdata, 1);
+}
+
+/* inform AP that we are awake again, unless power save is enabled */
+static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
+{
+	struct ieee80211_local *local = sdata->local;
+
+	if (!local->powersave)
+		ieee80211_send_nullfunc(local, sdata, 0);
+	else {
+		/*
+		 * In IEEE80211_HW_PS_NULLFUNC_STACK case firmware will
+		 * send a null frame with powersave bit set again even
+		 * though the AP already knows that we are sleeping. This
+		 * could be avoided by sending a null frame with power save
+		 * bit disabled before enabling the power save but it
+		 * doesn't gain anything.
+		 */
+		local->hw.conf.flags |= IEEE80211_CONF_PS;
+		ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
+	}
+}
+
 void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
 {
 	struct ieee80211_local *local = hw_to_local(hw);
@@ -256,7 +306,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
 		/* Tell AP we're back */
 		if (sdata->vif.type == NL80211_IFTYPE_STATION) {
 			if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) {
-				ieee80211_send_nullfunc(local, sdata, 0);
+				ieee80211_scan_ps_disable(sdata);
 				netif_tx_wake_all_queues(sdata->dev);
 			}
 		} else
@@ -416,7 +466,7 @@ int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata,
 		if (sdata->vif.type == NL80211_IFTYPE_STATION) {
 			if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) {
 				netif_tx_stop_all_queues(sdata->dev);
-				ieee80211_send_nullfunc(local, sdata, 1);
+				ieee80211_scan_ps_enable(sdata);
 			}
 		} else
 			netif_tx_stop_all_queues(sdata->dev);


  parent reply	other threads:[~2009-03-14 17:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-14 17:14 [RFC PATCH v2 0/4] mac80211: beacon filtering Kalle Valo
2009-03-14 17:14 ` [RFC PATCH v2 1/4] mac80211: decrease execution of the associated timer Kalle Valo
2009-03-14 17:18   ` Johannes Berg
2009-03-14 18:46     ` Kalle Valo
2009-03-14 19:33       ` Luis R. Rodriguez
2009-03-20  9:22       ` Kalle Valo
2009-03-20  9:42         ` Johannes Berg
2009-03-20 10:37           ` Kalle Valo
2009-03-20 10:41             ` Johannes Berg
2009-03-14 17:14 ` [RFC PATCH v2 2/4] mac80211: track beacons separately from the rx path activity Kalle Valo
2009-03-14 17:21   ` Johannes Berg
2009-03-14 19:45   ` Luis R. Rodriguez
2009-03-14 19:55     ` Johannes Berg
2009-03-14 20:19       ` Luis R. Rodriguez
2009-03-15  6:52     ` Kalle Valo
2009-03-14 17:14 ` Kalle Valo [this message]
2009-03-14 17:25   ` [RFC PATCH v2 3/4] mac80211: disable power save when scanning Johannes Berg
2009-03-14 17:37     ` Kalle Valo
2009-03-14 17:14 ` [RFC PATCH v2 4/4] mac80211: add beacon filtering support Kalle Valo
2009-03-14 17:28   ` Johannes Berg
2009-03-14 17:55     ` Kalle Valo
2009-03-14 20:18   ` Luis R. Rodriguez
2009-03-15  7:22     ` Kalle Valo
2009-03-15 17:59       ` Johannes Berg
2009-03-15 19:27         ` Luis R. Rodriguez
2009-03-15 20:10           ` Kalle Valo
2009-03-16  8:50       ` Jouni Malinen
2009-03-16 12:25         ` Kalle Valo

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=20090314171445.11126.97668.stgit@tikku \
    --to=kalle.valo@nokia.com \
    --cc=j@w1.fi \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lrodriguez@atheros.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).