All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helmut Schaa <helmut.schaa@googlemail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: "linux-wireless" <linux-wireless@vger.kernel.org>
Subject: Re: [RFC/RFT 5/5] mac80211: implement basic background scanning
Date: Thu, 16 Jul 2009 11:50:53 +0200	[thread overview]
Message-ID: <200907161150.54237.helmut.schaa@gmail.com> (raw)
In-Reply-To: <1247736318.24433.10.camel@johannes.local>

Am Donnerstag, 16. Juli 2009 schrieb Johannes Berg:
> On Thu, 2009-07-16 at 11:09 +0200, Helmut Schaa wrote:
> 
> Looks nice! Some nitpicks ;)

Great, thanks ;)

> > Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.>
> 
> Missing "com" :)

Oops.

> > +/**
> > + * enum mac80211_scan_flag - currently active scan mode
> > + *
> > + * @SCAN_SW_SCANNING: We're off our operating channel for scanning
> > + * @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_BG_SCANNING: We're currently in the process of scanning but may
> > + *	as well be on the operating channel
> > + */
> >  enum mac80211_scan_flag {
> >  	SCAN_SW_SCANNING = 1,"SCAN_ENTER_OPER_CHANNEL"
> >  	SCAN_HW_SCANNING = 2,
> > +	SCAN_BG_SCANNING = 4,
> 
> There's some random stuff in there that doesn't belong.

Right, that does not belong there.

> Also I would 
> prefer you used BIT(0) etc. or maybe __test_bit().

Fine with me.

> > --- a/net/mac80211/iface.c
> > +++ b/net/mac80211/iface.c
> > @@ -513,7 +513,7 @@ static int ieee80211_stop(struct net_device *dev)
> >  			 * the scan_sdata is NULL already don't send out a
> >  			 * scan event to userspace -- the scan is incomplete.
> >  			 */
> > -			if (local->scanning & SCAN_SW_SCANNING)
> > +			if (local->scanning & SCAN_BG_SCANNING)
> >  				ieee80211_scan_completed(&local->hw, true);
> >  		}
> 
> That doesn't seem correct -- it should be kept I think.

See below.

> > diff --git a/net/mac80211/main.c b/net/mac80211/main.c
> > index a1b4887..a87522f 100644
> > --- a/net/mac80211/main.c
> > +++ b/net/mac80211/main.c
> > @@ -198,7 +198,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
> >  	}
> >  
> >  	if (changed & BSS_CHANGED_BEACON_ENABLED) {
> > -		if (local->scanning & SCAN_SW_SCANNING) {
> > +		if (local->scanning & SCAN_BG_SCANNING) {
> >  			sdata->vif.bss_conf.enable_beacon = false;
> 
> That too.
> 
> > diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> > index 3df8a6e..24739ab 100644
> > --- a/net/mac80211/rx.c
> > +++ b/net/mac80211/rx.c
> > @@ -2136,7 +2136,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
> >  		return;
> >  	}
> >  
> > -	if (unlikely(local->scanning))
> > +	if (unlikely((local->scanning & SCAN_HW_SCANNING) || (local->scanning & SCAN_SW_SCANNING)))
> 
> I would prefer
> 	if (unlikely(local->scanning & (SCAN_HW_SCANNING | SCAN_SW_SCANNING)))

Ack.

> >  		rx.flags |= IEEE80211_RX_IN_SCAN;
> >  
> >  	ieee80211_parse_qos(&rx);
> > diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
> > index b4cc556..8f33fb5 100644
> > --- a/net/mac80211/scan.c
> > +++ b/net/mac80211/scan.c
> > @@ -282,7 +282,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
> >  		cfg80211_scan_done(local->scan_req, aborted);
> >  	local->scan_req = NULL;
> >  
> > -	was_hw_scan = local->scanning & SCAN_HW_SCANNING;
> > +	was_hw_scan = !!(local->scanning & SCAN_HW_SCANNING);
> 
> Should that be in the other patch?

Yep.

> > @@ -435,7 +434,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
> >  	if (local->ops->hw_scan)
> >  		local->scanning |= SCAN_HW_SCANNING;
> >  	else
> > -		local->scanning |= SCAN_SW_SCANNING;
> > +		local->scanning |= SCAN_BG_SCANNING;
> 
> Ok now I'm confused. Did you really intend to replace all these?
> 
> Based on your initial description I thought it was going to be
> 	scanning == SW_SCANNING
> or
> 	scanning == SW_SCANNING | BG_SCANNING

It's exactly the other way round :)

It is either BG_SCANNING or SW_SCANNING | BG_SCANNING.

I already thought that this might cause confusion but I think
BG_SCANNING better reflects that we are currently running a scan
(independant of the current scan state) whereas SW_SCANNING better
reflects that we are on a different channel for scanning.

Maybe I should use other terms. Ideas?

> > +	if (local->scan_channel) {
> > +		/*
> > +		 * we're currently scanning a different channel, let's
> > +		 * switch back to the operating channel now if at least
> > +		 * one interface is associated. Otherwise just scan the
> > +		 * next channel
> > +		 */
> > +		if (associated)
> > +			local->scan_state = SCAN_ENTER_OPER_CHANNEL;
> > +		else
> > +			local->scan_state = SCAN_SET_CHANNEL;
> 
> :)
>  
> > +	/* advance to the next channel to be scanned */
> > +	*next_delay = HZ / 10;
> > +	local->scan_state = SCAN_SET_CHANNEL;
> 
> Maybe we should rename scan_state to next_scan_state.

Makes sense.

> > +	if (ieee80211_hw_config(local,
> > +					IEEE80211_CONF_CHANGE_CHANNEL))
> 
> That looks weird. I don't think you really need to care about the return
> value anyway, now that we have rfkill integrated it shouldn't ever be
> nonzero (and if it is, while rfkill is being activated, it doesn't
> really matter since we're taking down interfaces)

Ok, will change that.

> > +	/*
> > +	 * notify the AP about us being back and restart all STA interfaces
> > +	 */
> > +	mutex_lock(&local->iflist_mtx);
> > +	list_for_each_entry(sdata, &local->interfaces, list) {
> > +		if (!netif_running(sdata->dev))
> > +			continue;
> > +
> > +		/* Tell AP we're back */
> > +		if (sdata->vif.type == NL80211_IFTYPE_STATION) {
> > +			if (sdata->u.mgd.associated) {
> > +				ieee80211_scan_ps_disable(sdata);
> > +			}
> 
> Could drop a set of {} here.

Right.

> > @@ -657,7 +760,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
> >  	 * queued -- mostly at suspend under RTNL.
> >  	 */
> >  	mutex_lock(&local->scan_mtx);
> > -	swscan = !!(local->scanning & SCAN_SW_SCANNING);
> > +	swscan = !!(local->scanning & SCAN_BG_SCANNING);
> 
> and another one -- please explain?

See above.

> Anyway looks pretty good to me! How does it fare during ping -f or
> something?

I compared it to the hw_scan implementation of iwlwifi. We loose a few
more frames (I guess due to not flushing the queues before channel switch)
but it's not really much, it was <1% for ping -f).

I didn't do much performance testing, just a single wget and the performance
dropped to about 50%. I still have to run some iperf tests (both RX and TX) to
see how it behaves.

Helmut

  reply	other threads:[~2009-07-16  9:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-16  9:04 [RFC/RFT 0/5] mac80211: implement background scan Helmut Schaa
2009-07-16  9:06 ` [RFC/RFT 1/5] mac80211: refactor the scan code Helmut Schaa
2009-07-16  9:07 ` [RFC/RFT 2/5] mac80211: advance the state machine immediately if no delay is needed Helmut Schaa
2009-07-16  9:08 ` [RFC/RFT 3/5] mac80211: introduce a new scan state "decision" Helmut Schaa
2009-07-16  9:08 ` [RFC/RFT 4/5] mac80211: Replace {sw,hw}_scanning variables with a bitfield Helmut Schaa
2009-07-16 16:30   ` Luis R. Rodriguez
2009-07-16 16:43     ` Johannes Berg
2009-07-16 16:49       ` Luis R. Rodriguez
2009-07-16  9:09 ` [RFC/RFT 5/5] mac80211: implement basic background scanning Helmut Schaa
2009-07-16  9:25   ` Johannes Berg
2009-07-16  9:50     ` Helmut Schaa [this message]
2009-07-16 10:16       ` Johannes Berg
2009-07-16 10:40         ` Helmut Schaa
2009-07-16 20:52         ` Helmut Schaa
2009-07-16 21:17           ` Johannes Berg
2009-07-16 14:20       ` Johannes Berg
2009-07-16 21:22 ` [RFC/RFT 0/5] mac80211: implement background scan Johannes Berg
2009-07-16 21:52   ` Helmut Schaa
2009-07-17 12:50     ` Helmut Schaa

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=200907161150.54237.helmut.schaa@gmail.com \
    --to=helmut.schaa@googlemail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /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 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.