linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath5k: reduce exported channel list
@ 2009-03-30 12:05 Bob Copeland
  2009-03-30 12:14 ` Jiri Slaby
  2009-04-05  2:20 ` Bob Copeland
  0 siblings, 2 replies; 4+ messages in thread
From: Bob Copeland @ 2009-03-30 12:05 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, ath5k-devel, jirislaby, mickflemm, lrodriguez,
	Bob Copeland

Claiming every available 5 ghz channel has a couple of negative
side-effects: scanning takes a long time, and the channel list
overflows the available buffer space for netlink commands,
resulting in:

    $ iw phy phy0 info
    command failed: No buffer space available (-105)

This patch adds a modparam so people who want to see all the channels
can do so by passing all_channels=1.  By default users will see a
smaller list of channels.  This also halves scan time, from 10 seconds
down to less than 5 when using world regulatory.

Changes-licensed-under: 3-Clause-BSD

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
 drivers/net/wireless/ath5k/base.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index 5d57d77..a018106 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -64,6 +64,10 @@ static int modparam_nohwcrypt;
 module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
 
+static int modparam_all_channels;
+module_param_named(all_channels, modparam_all_channels, int, 0444);
+MODULE_PARM_DESC(all_channels, "Expose all channels the device can use.");
+
 
 /******************\
 * Internal defines *
@@ -862,6 +866,20 @@ ath5k_ieee2mhz(short chan)
 		return 2212 + chan * 20;
 }
 
+/*
+ * Returns true for the channel numbers used without all_channels modparam.
+ */
+static bool ath5k_is_standard_channel(short chan)
+{
+	return ((chan <= 14) ||
+		/* UNII 1,2 */
+		((chan & 3) == 0 && chan >= 36 && chan <= 64) ||
+		/* midband */
+		((chan & 3) == 0 && chan >= 100 && chan <= 140) ||
+		/* UNII-3 */
+		((chan & 3) == 1 && chan >= 149 && chan <= 165));
+}
+
 static unsigned int
 ath5k_copy_channels(struct ath5k_hw *ah,
 		struct ieee80211_channel *channels,
@@ -899,6 +917,9 @@ ath5k_copy_channels(struct ath5k_hw *ah,
 		if (!ath5k_channel_ok(ah, freq, chfreq))
 			continue;
 
+		if (!modparam_all_channels && !ath5k_is_standard_channel(ch))
+			continue;
+
 		/* Write channel info and increment counter */
 		channels[count].center_freq = freq;
 		channels[count].band = (chfreq == CHANNEL_2GHZ) ?
-- 
1.6.0.6



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

* Re: [PATCH] ath5k: reduce exported channel list
  2009-03-30 12:05 [PATCH] ath5k: reduce exported channel list Bob Copeland
@ 2009-03-30 12:14 ` Jiri Slaby
  2009-03-30 13:22   ` Bob Copeland
  2009-04-05  2:20 ` Bob Copeland
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2009-03-30 12:14 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linville, linux-wireless, ath5k-devel, mickflemm, lrodriguez

On 03/30/2009 02:05 PM, Bob Copeland wrote:
> --- a/drivers/net/wireless/ath5k/base.c
> +++ b/drivers/net/wireless/ath5k/base.c
> @@ -64,6 +64,10 @@ static int modparam_nohwcrypt;
>  module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444);
>  MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
>  
> +static int modparam_all_channels;
> +module_param_named(all_channels, modparam_all_channels, int, 0444);

Make it bool and use S_* constants for perms, please (S_IRUGO). Maybe do
it as a followup also cleaning up the former one.

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

* Re: [PATCH] ath5k: reduce exported channel list
  2009-03-30 12:14 ` Jiri Slaby
@ 2009-03-30 13:22   ` Bob Copeland
  0 siblings, 0 replies; 4+ messages in thread
From: Bob Copeland @ 2009-03-30 13:22 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linville, linux-wireless, ath5k-devel, mickflemm, lrodriguez

On Mon, Mar 30, 2009 at 8:14 AM, Jiri Slaby <jirislaby@gmail.com> wrote:
>> +static int modparam_all_channels;
>> +module_param_named(all_channels, modparam_all_channels, int, 0444);
>
> Make it bool and use S_* constants for perms, please (S_IRUGO). Maybe do
> it as a followup also cleaning up the former one.

Ok, I'll do it as a follow-up if John doesn't mind.

-- 
Bob Copeland %% www.bobcopeland.com

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

* Re: [PATCH] ath5k: reduce exported channel list
  2009-03-30 12:05 [PATCH] ath5k: reduce exported channel list Bob Copeland
  2009-03-30 12:14 ` Jiri Slaby
@ 2009-04-05  2:20 ` Bob Copeland
  1 sibling, 0 replies; 4+ messages in thread
From: Bob Copeland @ 2009-04-05  2:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, ath5k-devel, jirislaby, mickflemm, lrodriguez,
	simon

On Mon, Mar 30, 2009 at 08:05:29AM -0400, Bob Copeland wrote:
> Claiming every available 5 ghz channel has a couple of negative
> side-effects: scanning takes a long time, and the channel list
> overflows the available buffer space for netlink commands,
> resulting in:
[...]
> 
> Signed-off-by: Bob Copeland <me@bobcopeland.com>

I forgot to include appropriate credit -- John, if you don't mind 
adding, that would be great, or I can resend.

Reported-by: Simon Farnsworth <simon@farnz.org.uk> 
Tested-By: Simon Farnsworth <simon@farnz.org.uk> 

-- 
Bob Copeland %% www.bobcopeland.com


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

end of thread, other threads:[~2009-04-05  2:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-30 12:05 [PATCH] ath5k: reduce exported channel list Bob Copeland
2009-03-30 12:14 ` Jiri Slaby
2009-03-30 13:22   ` Bob Copeland
2009-04-05  2:20 ` Bob Copeland

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).