Skip to contentSkip to conversation

wireless: Support can-scan-one logic.

PATCH In review [email protected] 3 participants 8 messages May 16, 2011 – Jun 2, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wireless: Support can-scan-one logic.

From: Ben Greear <[email protected]>

Enable this by passing a -1 for a scan frequency.

When enabled, the system will only scan the current active channel if at least one VIF is actively using it. If no VIFS are active or this flag is disabled, then default behaviour is used.

This helps when using multiple STA interfaces that otherwise might constantly be trying to scan all channels.

---

v2: Remove verbose printk commands, fix up comment syntax.

:100644 100644 c32e683... c0be322... M include/net/cfg80211.h
:100644 100644 489b6ad... d00287f... M net/mac80211/scan.c
:100644 100644 0a199a1... c0b9cad... M net/wireless/nl80211.c
:100644 100644 e17b0be... 9044120... M net/wireless/sme.c

 include/net/cfg80211.h |    3 +++
 net/mac80211/scan.c    |   42 ++++++++++++++++++++++++++++++++++++++++++
 net/wireless/nl80211.c |   22 ++++++++++++++++++++--
 net/wireless/sme.c     |    6 ++++++
 4 files changed, 71 insertions(+), 2 deletions(-)
include/net/cfg80211.h +3 -0
index c32e683..c0be322 100644
@@ -780,6 +780,8 @@ struct cfg80211_ssid {
  * @wiphy: the wiphy this was for
  * @dev: the interface
  * @aborted: (internal) scan request was notified as aborted
+ * @can_scan_one:  If true, only scan active channel if at least one
+ *       vif is already associated.
  */
 struct cfg80211_scan_request {
 	struct cfg80211_ssid *ssids;
@@ -792,6 +794,7 @@ struct cfg80211_scan_request {
 	struct wiphy *wiphy;
 	struct net_device *dev;
 	bool aborted;
+	bool can_scan_one;
 
 	/* keep last */
 	struct ieee80211_channel *channels[0];
net/mac80211/scan.c +42 -0

48 lines not on this page · raw message

net/wireless/nl80211.c +20 -2
index 0a199a1..c0b9cad 100644
@@ -3176,6 +3176,9 @@ static int validate_scan_freqs(struct nlattr *freqs)
 	int n_channels = 0, tmp1, tmp2;
 
 	nla_for_each_nested(attr1, freqs, tmp1) {
+		if (nla_get_u32(attr1) == 0xFFFFFFFF)
+			continue; /* skip can-scan-one flag */
+
 		n_channels++;
 		/*
 		 * Some hardware has a limited channel list for
@@ -3207,6 +3210,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 	int err, tmp, n_ssids = 0, n_channels, i;
 	enum ieee80211_band band;
 	size_t ie_len;
+	bool do_all_chan = true;
 
 	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
 		return -EINVAL;
@@ -3223,8 +3227,9 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 		n_channels = validate_scan_freqs(
 				info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]);
 		if (!n_channels)
-			return -EINVAL;
+			goto auto_channels;
 	} else {
+auto_channels:
 		n_channels = 0;
 
 		for (band = 0; band < IEEE80211_NUM_BANDS; band++)
@@ -3270,6 +3275,17 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 		nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_FREQUENCIES], tmp) {
 			struct ieee80211_channel *chan;
 
+			/*
+			 * Special hack:  channel -1 means 'scan only active
+			 * channel if any VIFs on this device are associated
+			 * on the channel.
+			 */
+			if (nla_get_u32(attr) == 0xFFFFFFFF) {
+				request->can_scan_one = true;
+				continue;
+			}
+
+			do_all_chan = false;
 			chan = ieee80211_get_channel(wiphy, nla_get_u32(attr));
 
 			if (!chan) {
@@ -3284,7 +3300,9 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 			request->channels[i] = chan;
 			i++;
 		}
-	} else {
+	}
+
+	if (do_all_chan) {
 		/* all channels */
 		for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
 			int j;
net/wireless/sme.c +6 -0
index e17b0be..9044120 100644
@@ -105,6 +105,12 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
 	if (!request)
 		return -ENOMEM;
 
+	/*
+	 * If at least one VIF on this hardware is already associated, then
+	 * only scan on the active channel.
+	 */
+	request->can_scan_one = true;
+
 	if (wdev->conn->params.channel)
 		request->channels[0] = wdev->conn->params.channel;
 	else {
Signature · 1 line
1.7.3.4
maintainer
#1 lore raw
Quoted 3 lines · On Mon, 2011-05-16 at 15:51 -0700, [email protected] wrote:

From: Ben Greear <[email protected]>

Enable this by passing a -1 for a scan frequency.

I still don't think we should do that, especially not with -1. That's totally non-netlink like inband signalling. I'll also reply to your other mail though since I don't think it makes sense to have this sort of convenience function in the kernel.

johannes

author
#2 lore raw
Quoted 9 lines · Johannes Berg
Quoted 3 lines · On Mon, 2011-05-16 at 15:51 -0700, [email protected] wrote:

From: Ben Greear<[email protected]>

Enable this by passing a -1 for a scan frequency.

I still don't think we should do that, especially not with -1. That's totally non-netlink like inband signalling. I'll also reply to your other mail though since I don't think it makes sense to have this sort of convenience function in the kernel.

It's virtually impossible (as far as I can tell) to carry an out-of-tree netlink patch that uses a new netlink message and still keep things backwards-compat when someone adds a new message to the upstream kernel. So, the -1 hack works well for me.

If it were to go into the kernel proper, then we could add a proper flag to the netlink API and start using that.

If you just don't like the feature, thats OK...it is a pretty specialized feature, and easy enough to carry in my own tree.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#3 lore raw
Quoted 19 lines · Ben Greear
Quoted 11 lines · Johannes Berg
Quoted 4 lines · On Mon, 2011-05-16 at 15:51 -0700, [email protected] wrote:

From: Ben Greear<[email protected]>

Enable this by passing a -1 for a scan frequency.

I still don't think we should do that, especially not with -1. That's totally non-netlink like inband signalling. I'll also reply to your other mail though since I don't think it makes sense to have this sort of convenience function in the kernel.

It's virtually impossible (as far as I can tell) to carry an out-of-tree netlink patch that uses a new netlink message and still keep things backwards-compat when someone adds a new message to the upstream kernel.  So, the -1 hack works well for me.

Quoted 6 lines

If it were to go into the kernel proper, then we could add a proper flag to the netlink API and start using that.

If you just don't like the feature, thats OK...it is a pretty specialized feature, and easy enough to carry in my own tree.

Since this shit was merged can you add a respective documentation extension for the command for nl80211.h?

Luis

maintainer
#4 lore raw
Quoted 2 lines · Luis R. Rodriguez

Since this shit was merged can you add a respective documentation extension for the command for nl80211.h?

You're kidding, right? The -1 crap was merged? Breaking all drivers other than mac80211?

johannes

#5 lore raw
Quoted 7 lines · Johannes Berg
Quoted 2 lines · Luis R. Rodriguez

Since this shit was merged can you add a respective documentation extension for the command for nl80211.h?

You're kidding, right? The -1 crap was merged? Breaking all drivers other than mac80211?

commit 718ab883ccd1258c1e5c150edfb407880df9eeaa

Author: Ben Greear <[email protected]>
Date:   Mon May 16 15:51:36 2011 -0700

wireless: Support can-scan-one logic.

Enable this by passing a -1 for a scan frequency.

When enabled, the system will only scan the current active channel if at least one VIF is actively using it. If no VIFS are active or this flag is disabled, then default behaviour is used.

This helps when using multiple STA interfaces that otherwise might constantly be trying to scan all channels.

My baby just turned.

Luis

author
#6 lore raw
In reply to Luis R. Rodriguez
Quoted 24 lines · Luis R. Rodriguez
Quoted 23 lines · Ben Greear
Quoted 11 lines · Johannes Berg
Quoted 4 lines · On Mon, 2011-05-16 at 15:51 -0700, [email protected] wrote:

From: Ben Greear<[email protected]>

Enable this by passing a -1 for a scan frequency.

I still don't think we should do that, especially not with -1. That's totally non-netlink like inband signalling. I'll also reply to your other mail though since I don't think it makes sense to have this sort of convenience function in the kernel.

It's virtually impossible (as far as I can tell) to carry an out-of-tree netlink patch that uses a new netlink message and still keep things backwards-compat when someone adds a new message to the upstream kernel. So, the -1 hack works well for me.

If it were to go into the kernel proper, then we could add a proper flag to the netlink API and start using that.

Quoted 5 lines
Quoted 2 lines

If you just don't like the feature, thats OK...it is a pretty specialized feature, and easy enough to carry in my own tree.

Since this shit was merged can you add a respective documentation extension for the command for nl80211.h?

You un-merged it almost immediately, as far as I can tell.

What tree is it merged in?

Thanks,
Ben

Quoted 2 lines

Luis

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#7 lore raw
Quoted 1 line · Ben Greear

What tree is it merged in?

Ah it was reverted. Sorry.

Luis