All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-12 16:38 greearb
  2012-04-16 17:33   ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: greearb @ 2012-04-12 16:38 UTC (permalink / raw)
  To: linux-wireless; +Cc: netdev, Ben Greear

From: Ben Greear <greearb@candelatech.com>

This based on an idea posted by Stanislaw Gruszka,
though I accept full blame for the implementation!

This is compile-tested only at this point.

The idea is to let users scan on the current operating
channel without interrupting normal traffic more than
absolutely necessary (changing power level might reset
some hardware, for instance).

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

v3:  Fix up formatting as requested.
     Add call to notify driver scan is starting
     (Scan complete logic notifies scan is complete already.)

:100644 100644 4be11ea... f71a8d6... M	net/mac80211/ieee80211_i.h
:100644 100644 ac79d5e... b70f7f0... M	net/mac80211/main.c
:100644 100644 54a0491... dd2fbec... M	net/mac80211/rx.c
:100644 100644 c70e176... c33afa8... M	net/mac80211/scan.c
 net/mac80211/ieee80211_i.h |    3 +
 net/mac80211/main.c        |    4 +-
 net/mac80211/rx.c          |    2 +
 net/mac80211/scan.c        |   89 +++++++++++++++++++++++++++++++-------------
 4 files changed, 71 insertions(+), 27 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 4be11ea..f71a8d6 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -803,6 +803,8 @@ struct tpt_led_trigger {
  *	well be on the operating channel
  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
  *	determine if we are on the operating channel or not
+ * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
+ *	channel. This should not interrupt normal traffic.
  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
  *	that the scan completed.
  * @SCAN_ABORTED: Set for our scan work function when the driver reported
@@ -811,6 +813,7 @@ struct tpt_led_trigger {
 enum {
 	SCAN_SW_SCANNING,
 	SCAN_HW_SCANNING,
+	SCAN_ONCHANNEL_SCANNING,
 	SCAN_COMPLETED,
 	SCAN_ABORTED,
 };
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index ac79d5e..b70f7f0 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -47,7 +47,8 @@ void ieee80211_configure_filter(struct ieee80211_local *local)
 	if (atomic_read(&local->iff_allmultis))
 		new_flags |= FIF_ALLMULTI;
 
-	if (local->monitors || test_bit(SCAN_SW_SCANNING, &local->scanning))
+	if (local->monitors || test_bit(SCAN_SW_SCANNING, &local->scanning) ||
+	    test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning))
 		new_flags |= FIF_BCN_PRBRESP_PROMISC;
 
 	if (local->fif_probe_req || local->probe_req_reg)
@@ -148,6 +149,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
 	}
 
 	if (test_bit(SCAN_SW_SCANNING, &local->scanning) ||
+	    test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) ||
 	    test_bit(SCAN_HW_SCANNING, &local->scanning))
 		power = chan->max_power;
 	else
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 54a0491..dd2fbec 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -425,6 +425,7 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
 
 	if (test_bit(SCAN_HW_SCANNING, &local->scanning) ||
 	    test_bit(SCAN_SW_SCANNING, &local->scanning) ||
+	    test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) ||
 	    local->sched_scanning)
 		return ieee80211_scan_rx(rx->sdata, skb);
 
@@ -2915,6 +2916,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
 		local->dot11ReceivedFragmentCount++;
 
 	if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) ||
+		     test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) ||
 		     test_bit(SCAN_SW_SCANNING, &local->scanning)))
 		status->rx_flags |= IEEE80211_RX_IN_SCAN;
 
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index c70e176..c33afa8 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -387,6 +387,29 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
 	return 0;
 }
 
+static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
+					    unsigned long *next_delay)
+{
+	int i;
+	struct ieee80211_sub_if_data *sdata = local->scan_sdata;
+	enum ieee80211_band band = local->hw.conf.channel->band;
+
+	for (i = 0; i < local->scan_req->n_ssids; i++)
+		ieee80211_send_probe_req(
+			sdata, NULL,
+			local->scan_req->ssids[i].ssid,
+			local->scan_req->ssids[i].ssid_len,
+			local->scan_req->ie, local->scan_req->ie_len,
+			local->scan_req->rates[band], false,
+			local->scan_req->no_cck);
+
+	/*
+	 * After sending probe requests, wait for probe responses
+	 * on the channel.
+	 */
+	*next_delay = IEEE80211_CHANNEL_TIME;
+	local->next_scan_state = SCAN_DECISION;
+}
 
 static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 				  struct cfg80211_scan_request *req)
@@ -438,10 +461,42 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 	local->scan_req = req;
 	local->scan_sdata = sdata;
 
-	if (local->ops->hw_scan)
+	if (local->ops->hw_scan) {
 		__set_bit(SCAN_HW_SCANNING, &local->scanning);
-	else
+	} else if ((req->n_channels == 1) &&
+		   (req->channels[0]->center_freq ==
+		    local->hw.conf.channel->center_freq)) {
+		/* If we are scanning only on the current channel, then
+		 * we do not need to stop normal activities
+		 */
+		unsigned long next_delay;
+
+		__set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
+		ieee80211_recalc_idle(local);
+		/* Notify driver scan is starting, keep order of operations
+		 * same as normal software scan, in case that matters. */
+		drv_sw_scan_start(local);
+		ieee80211_configure_filter(local); /* accept probe-responses */
+		/* We need to ensure power level is at max for scanning. */
+		ieee80211_hw_config(local, 0);
+
+		if ((req->channels[0]->flags &
+		     IEEE80211_CHAN_PASSIVE_SCAN) ||
+		    !local->scan_req->n_ssids) {
+			next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
+		} else {
+			ieee80211_scan_state_send_probe(local, &next_delay);
+			next_delay = IEEE80211_CHANNEL_TIME;
+		}
+
+		/* Now, just wait a bit and we are all done! */
+		ieee80211_queue_delayed_work(&local->hw, &local->scan_work,
+					     next_delay);
+		return 0;
+	} else {
+		/* Do normal software scan */
 		__set_bit(SCAN_SW_SCANNING, &local->scanning);
+	}
 
 	ieee80211_recalc_idle(local);
 
@@ -598,30 +653,6 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
 	local->next_scan_state = SCAN_SEND_PROBE;
 }
 
-static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
-					    unsigned long *next_delay)
-{
-	int i;
-	struct ieee80211_sub_if_data *sdata = local->scan_sdata;
-	enum ieee80211_band band = local->hw.conf.channel->band;
-
-	for (i = 0; i < local->scan_req->n_ssids; i++)
-		ieee80211_send_probe_req(
-			sdata, NULL,
-			local->scan_req->ssids[i].ssid,
-			local->scan_req->ssids[i].ssid_len,
-			local->scan_req->ie, local->scan_req->ie_len,
-			local->scan_req->rates[band], false,
-			local->scan_req->no_cck);
-
-	/*
-	 * After sending probe requests, wait for probe responses
-	 * on the channel.
-	 */
-	*next_delay = IEEE80211_CHANNEL_TIME;
-	local->next_scan_state = SCAN_DECISION;
-}
-
 static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
 					 unsigned long *next_delay)
 {
@@ -672,6 +703,12 @@ void ieee80211_scan_work(struct work_struct *work)
 
 	sdata = local->scan_sdata;
 
+	/* When scanning on-channel, the first-callback means completed. */
+	if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) {
+		aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
+		goto out_complete;
+	}
+
 	if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
 		aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
 		goto out_complete;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 17:33   ` Johannes Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Berg @ 2012-04-16 17:33 UTC (permalink / raw)
  To: greearb; +Cc: linux-wireless, netdev

Did you test it?

> +		/* If we are scanning only on the current channel, then
> +		 * we do not need to stop normal activities
> +		 */
> +		unsigned long next_delay;
> +
> +		__set_bit(SCAN_ONCHANNEL_SCANNING,&local->scanning);
> +		ieee80211_recalc_idle(local);
> +		/* Notify driver scan is starting, keep order of operations
> +		 * same as normal software scan, in case that matters. */
> +		drv_sw_scan_start(local);
> +		ieee80211_configure_filter(local); /* accept probe-responses */
> +		/* We need to ensure power level is at max for scanning. */
> +		ieee80211_hw_config(local, 0);

a few blank lines would be nice :)

> +		if ((req->channels[0]->flags&
> +		     IEEE80211_CHAN_PASSIVE_SCAN) ||
> +		    !local->scan_req->n_ssids) {

That formatting is a bit off it seems. Or is that just my mailer?

johannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 17:33   ` Johannes Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Berg @ 2012-04-16 17:33 UTC (permalink / raw)
  To: greearb-my8/4N5VtI7c+919tysfdA
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA

Did you test it?

> +		/* If we are scanning only on the current channel, then
> +		 * we do not need to stop normal activities
> +		 */
> +		unsigned long next_delay;
> +
> +		__set_bit(SCAN_ONCHANNEL_SCANNING,&local->scanning);
> +		ieee80211_recalc_idle(local);
> +		/* Notify driver scan is starting, keep order of operations
> +		 * same as normal software scan, in case that matters. */
> +		drv_sw_scan_start(local);
> +		ieee80211_configure_filter(local); /* accept probe-responses */
> +		/* We need to ensure power level is at max for scanning. */
> +		ieee80211_hw_config(local, 0);

a few blank lines would be nice :)

> +		if ((req->channels[0]->flags&
> +		     IEEE80211_CHAN_PASSIVE_SCAN) ||
> +		    !local->scan_req->n_ssids) {

That formatting is a bit off it seems. Or is that just my mailer?

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 17:41     ` Ben Greear
  0 siblings, 0 replies; 9+ messages in thread
From: Ben Greear @ 2012-04-16 17:41 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, netdev

On 04/16/2012 10:33 AM, Johannes Berg wrote:
> Did you test it?

Yes.  I added my old can-scan-one patch on top of this
so that as soon as one station is associated the rest
of the hostap-generated scans can just scan the current channel. I
then bring up 100 or so virtual stations and they all scan
and do their thing...

I also tried some manual scans on a fixed frequency.  Those
appeared to work, though I got scan results for APs on different
channels.  Does that seem right?  I can't see how my patch
would affect that sort of thing one way or another...

If you have some suggestions for other ways to test this
please let me know.

>> + /* If we are scanning only on the current channel, then
>> + * we do not need to stop normal activities
>> + */
>> + unsigned long next_delay;
>> +
>> + __set_bit(SCAN_ONCHANNEL_SCANNING,&local->scanning);
>> + ieee80211_recalc_idle(local);
>> + /* Notify driver scan is starting, keep order of operations
>> + * same as normal software scan, in case that matters. */
>> + drv_sw_scan_start(local);
>> + ieee80211_configure_filter(local); /* accept probe-responses */
>> + /* We need to ensure power level is at max for scanning. */
>> + ieee80211_hw_config(local, 0);
>
> a few blank lines would be nice :)

Sure, will do.

>> + if ((req->channels[0]->flags&
>> + IEEE80211_CHAN_PASSIVE_SCAN) ||
>> + !local->scan_req->n_ssids) {
>
> That formatting is a bit off it seems. Or is that just my mailer?

Well, it looked OK to me..though when I replied my mailer
certainly made it look funky.  I'll re-run it through checkpatch
just in case.

Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 17:41     ` Ben Greear
  0 siblings, 0 replies; 9+ messages in thread
From: Ben Greear @ 2012-04-16 17:41 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA

On 04/16/2012 10:33 AM, Johannes Berg wrote:
> Did you test it?

Yes.  I added my old can-scan-one patch on top of this
so that as soon as one station is associated the rest
of the hostap-generated scans can just scan the current channel. I
then bring up 100 or so virtual stations and they all scan
and do their thing...

I also tried some manual scans on a fixed frequency.  Those
appeared to work, though I got scan results for APs on different
channels.  Does that seem right?  I can't see how my patch
would affect that sort of thing one way or another...

If you have some suggestions for other ways to test this
please let me know.

>> + /* If we are scanning only on the current channel, then
>> + * we do not need to stop normal activities
>> + */
>> + unsigned long next_delay;
>> +
>> + __set_bit(SCAN_ONCHANNEL_SCANNING,&local->scanning);
>> + ieee80211_recalc_idle(local);
>> + /* Notify driver scan is starting, keep order of operations
>> + * same as normal software scan, in case that matters. */
>> + drv_sw_scan_start(local);
>> + ieee80211_configure_filter(local); /* accept probe-responses */
>> + /* We need to ensure power level is at max for scanning. */
>> + ieee80211_hw_config(local, 0);
>
> a few blank lines would be nice :)

Sure, will do.

>> + if ((req->channels[0]->flags&
>> + IEEE80211_CHAN_PASSIVE_SCAN) ||
>> + !local->scan_req->n_ssids) {
>
> That formatting is a bit off it seems. Or is that just my mailer?

Well, it looked OK to me..though when I replied my mailer
certainly made it look funky.  I'll re-run it through checkpatch
just in case.

Thanks,
Ben


-- 
Ben Greear <greearb-my8/4N5VtI7c+919tysfdA@public.gmane.org>
Candela Technologies Inc  http://www.candelatech.com

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 18:03       ` Adrian Chadd
  0 siblings, 0 replies; 9+ messages in thread
From: Adrian Chadd @ 2012-04-16 18:03 UTC (permalink / raw)
  To: Ben Greear; +Cc: Johannes Berg, linux-wireless, netdev

On 16 April 2012 10:41, Ben Greear <greearb@candelatech.com> wrote:

> I also tried some manual scans on a fixed frequency.  Those
> appeared to work, though I got scan results for APs on different
> channels.  Does that seem right?  I can't see how my patch
> would affect that sort of thing one way or another...

You'll see off-channel beacons in 11bg mode. :-)

It's actually rather helpful, except that the RSSI reported isn't
anywhere near as valid as you'd like.



Adrian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 18:03       ` Adrian Chadd
  0 siblings, 0 replies; 9+ messages in thread
From: Adrian Chadd @ 2012-04-16 18:03 UTC (permalink / raw)
  To: Ben Greear
  Cc: Johannes Berg, linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

On 16 April 2012 10:41, Ben Greear <greearb-my8/4N5VtI7c+919tysfdA@public.gmane.org> wrote:

> I also tried some manual scans on a fixed frequency.  Those
> appeared to work, though I got scan results for APs on different
> channels.  Does that seem right?  I can't see how my patch
> would affect that sort of thing one way or another...

You'll see off-channel beacons in 11bg mode. :-)

It's actually rather helpful, except that the RSSI reported isn't
anywhere near as valid as you'd like.



Adrian
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 19:58       ` Johannes Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Berg @ 2012-04-16 19:58 UTC (permalink / raw)
  To: Ben Greear; +Cc: linux-wireless, netdev

On 4/16/2012 10:41 AM, Ben Greear wrote:
>>> + if ((req->channels[0]->flags&
>>> + IEEE80211_CHAN_PASSIVE_SCAN) ||
>>> + !local->scan_req->n_ssids) {
>>
>> That formatting is a bit off it seems. Or is that just my mailer?
>
> Well, it looked OK to me..though when I replied my mailer
> certainly made it look funky. I'll re-run it through checkpatch
> just in case.

It just seemed the & should have a space in front, and it could be on a 
single line with the constant? Anyway, I'm using thunderbird right now 
and don't know what kind of messes it makes.

johannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] mac80211: Support on-channel scan option.
@ 2012-04-16 19:58       ` Johannes Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Berg @ 2012-04-16 19:58 UTC (permalink / raw)
  To: Ben Greear
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA

On 4/16/2012 10:41 AM, Ben Greear wrote:
>>> + if ((req->channels[0]->flags&
>>> + IEEE80211_CHAN_PASSIVE_SCAN) ||
>>> + !local->scan_req->n_ssids) {
>>
>> That formatting is a bit off it seems. Or is that just my mailer?
>
> Well, it looked OK to me..though when I replied my mailer
> certainly made it look funky. I'll re-run it through checkpatch
> just in case.

It just seemed the & should have a space in front, and it could be on a 
single line with the constant? Anyway, I'm using thunderbird right now 
and don't know what kind of messes it makes.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-16 19:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12 16:38 [PATCH v3] mac80211: Support on-channel scan option greearb
2012-04-16 17:33 ` Johannes Berg
2012-04-16 17:33   ` Johannes Berg
2012-04-16 17:41   ` Ben Greear
2012-04-16 17:41     ` Ben Greear
2012-04-16 18:03     ` Adrian Chadd
2012-04-16 18:03       ` Adrian Chadd
2012-04-16 19:58     ` Johannes Berg
2012-04-16 19:58       ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.