linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add module parameter to override regioncode on libertas
       [not found] <1214580776.10355.16.camel@localhost.localdomain>
@ 2008-06-30  6:36 ` Johan Adolfsson
  2008-06-30 11:05   ` Johannes Berg
  2008-06-30 14:03   ` John W. Linville
  0 siblings, 2 replies; 6+ messages in thread
From: Johan Adolfsson @ 2008-06-30  6:36 UTC (permalink / raw)
  To: linux-wireless; +Cc: 'Dan Williams', 'Johan Adolfsson'

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]


Resending to linux-wireless after positive feedback on libertas-dev.

Attached is a patch against the 2.6.25 driver that adds a 
module parameter called "regioncode" to set the region code
in the libertas driver.

Hope the format is ok.
Signed-off-by: Johan.Adolfsson@axis.com

Best regards
/Johan

[-- Attachment #2: regioncode_patch.txt --]
[-- Type: text/plain, Size: 3177 bytes --]

Index: drivers/net/wireless/libertas/main.c
===================================================================
RCS file: /usr/local/cvs/linux/os/linux-2.6/drivers/net/wireless/libertas/main.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 main.c
--- drivers/net/wireless/libertas/main.c	2 Jun 2008 15:08:37 -0000	1.1.1.4
+++ drivers/net/wireless/libertas/main.c	27 Jun 2008 13:08:19 -0000
@@ -36,6 +36,9 @@
 EXPORT_SYMBOL_GPL(lbs_debug);
 module_param_named(libertas_debug, lbs_debug, int, 0644);
 
+static int lbs_regioncode;
+module_param_named(regioncode, lbs_regioncode, int, 0644);
+
 
 #define LBS_TX_PWR_DEFAULT		20	/*100mW */
 #define LBS_TX_PWR_US_DEFAULT		20	/*100mW */
@@ -936,9 +939,11 @@
 	lbs_deb_enter(LBS_DEB_FW);
 
 	/*
-	 * Read MAC address from HW
+	 * Read MAC address and regioncode etc. from HW
 	 */
 	memset(priv->current_addr, 0xff, ETH_ALEN);
+	if (lbs_regioncode > 0)
+		priv->regioncode = lbs_regioncode;
 	ret = lbs_update_hw_spec(priv);
 	if (ret) {
 		ret = -1;
Index: drivers/net/wireless/libertas/cmd.c
===================================================================
RCS file: /usr/local/cvs/linux/os/linux-2.6/drivers/net/wireless/libertas/cmd.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 cmd.c
--- drivers/net/wireless/libertas/cmd.c	2 Jun 2008 15:08:37 -0000	1.1.1.4
+++ drivers/net/wireless/libertas/cmd.c	27 Jun 2008 13:08:19 -0000
@@ -81,22 +81,34 @@
 	lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
 		    cmd.hwifversion, cmd.version);
 
-	/* Clamp region code to 8-bit since FW spec indicates that it should
-	 * only ever be 8-bit, even though the field size is 16-bit.  Some firmware
-	 * returns non-zero high 8 bits here.
-	 */
-	priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
-
-	for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
-		/* use the region code to search for the index */
-		if (priv->regioncode == lbs_region_code_to_index[i])
-			break;
+	/* First check if a regioncode already provided */
+	if (priv->regioncode) {
+		for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
+			/* use the region code to search for the index */
+			if (priv->regioncode == lbs_region_code_to_index[i])
+				break;
+		}
+	} else {
+		i = MRVDRV_MAX_REGION_CODE; /* Check the from from cmd */
 	}
+	if (i >= MRVDRV_MAX_REGION_CODE) {
+		/* Clamp region code to 8-bit since FW spec indicates that it should
+		 * only ever be 8-bit, even though the field size is 16-bit.  Some firmware
+		 * returns non-zero high 8 bits here.
+		 */
+
+		priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
 
+		for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
+			/* use the region code to search for the index */
+			if (priv->regioncode == lbs_region_code_to_index[i])
+				break;
+		}
+	}
 	/* if it's unidentified region code, use the default (USA) */
 	if (i >= MRVDRV_MAX_REGION_CODE) {
+		lbs_pr_info("unidentified region code 0x%02x; using the default (USA)\n", priv->regioncode);
 		priv->regioncode = 0x10;
-		lbs_pr_info("unidentified region code; using the default (USA)\n");
 	}
 
 	if (priv->current_addr[0] == 0xff)

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

* Re: [PATCH] Add module parameter to override regioncode on libertas
  2008-06-30  6:36 ` [PATCH] Add module parameter to override regioncode on libertas Johan Adolfsson
@ 2008-06-30 11:05   ` Johannes Berg
  2008-06-30 11:58     ` Johan Adolfsson
  2008-06-30 14:03   ` John W. Linville
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2008-06-30 11:05 UTC (permalink / raw)
  To: Johan Adolfsson; +Cc: linux-wireless, 'Dan Williams'

[-- Attachment #1: Type: text/plain, Size: 492 bytes --]

On Mon, 2008-06-30 at 08:36 +0200, Johan Adolfsson wrote:
> Resending to linux-wireless after positive feedback on libertas-dev.
> 
> Attached is a patch against the 2.6.25 driver that adds a 
> module parameter called "regioncode" to set the region code
> in the libertas driver.
> 
> Hope the format is ok.
> Signed-off-by: Johan.Adolfsson@axis.com

I wonder if libertas could start using cfg80211 for this? Just register
a wiphy and use the enabled channels there?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* RE: [PATCH] Add module parameter to override regioncode on libertas
  2008-06-30 11:05   ` Johannes Berg
@ 2008-06-30 11:58     ` Johan Adolfsson
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Adolfsson @ 2008-06-30 11:58 UTC (permalink / raw)
  To: 'Johannes Berg', 'Johan Adolfsson'
  Cc: linux-wireless, 'Dan Williams', libertas-dev



> -----Original Message-----
> From: Johannes Berg [mailto:johannes@sipsolutions.net] 
> Sent: den 30 juni 2008 13:05
> To: Johan Adolfsson
> Cc: linux-wireless@vger.kernel.org; 'Dan Williams'
> Subject: Re: [PATCH] Add module parameter to override 
> regioncode on libertas
> 
> 
> On Mon, 2008-06-30 at 08:36 +0200, Johan Adolfsson wrote:
> > Resending to linux-wireless after positive feedback on libertas-dev.
> > 
> > Attached is a patch against the 2.6.25 driver that adds a 
> > module parameter called "regioncode" to set the region code
> > in the libertas driver.
> > 
> > Hope the format is ok.
> > Signed-off-by: Johan.Adolfsson@axis.com
> 
> I wonder if libertas could start using cfg80211 for this? 
> Just register
> a wiphy and use the enabled channels there?
> 
> johannes

I suppose it could, just read a little on the subject, but it's unclear 
to me how mature the cfg80211 is and how much overkill it is compared 
to what we really need (embedded solution, regulatory domains set at 
production time (before shipping) and not easaly selectable by end user).

(I added liberas-dev to Cc:)

/Johan


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

* Re: [PATCH] Add module parameter to override regioncode on libertas
  2008-06-30  6:36 ` [PATCH] Add module parameter to override regioncode on libertas Johan Adolfsson
  2008-06-30 11:05   ` Johannes Berg
@ 2008-06-30 14:03   ` John W. Linville
  2008-06-30 15:44     ` Henrique de Moraes Holschuh
  1 sibling, 1 reply; 6+ messages in thread
From: John W. Linville @ 2008-06-30 14:03 UTC (permalink / raw)
  To: Johan Adolfsson; +Cc: linux-wireless, 'Dan Williams'

On Mon, Jun 30, 2008 at 08:36:56AM +0200, Johan Adolfsson wrote:
> 
> Resending to linux-wireless after positive feedback on libertas-dev.
> 
> Attached is a patch against the 2.6.25 driver that adds a 
> module parameter called "regioncode" to set the region code
> in the libertas driver.
> 
> Hope the format is ok.
> Signed-off-by: Johan.Adolfsson@axis.com

Anyone want to offer an opinion on how this (overriding the region
code from the hardware) differs in effect from the patch that disabled
all regulatory controls on mac80211 devices?

>From what I understand about regulatory practices, it seems
irresponsible to allow a regulatory setting embedded in a device's
ROM to be so easily overridden?

John
-- 
John W. Linville
linville@tuxdriver.com

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

* Re: [PATCH] Add module parameter to override regioncode on libertas
  2008-06-30 14:03   ` John W. Linville
@ 2008-06-30 15:44     ` Henrique de Moraes Holschuh
  2008-06-30 17:29       ` John W. Linville
  0 siblings, 1 reply; 6+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-06-30 15:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: Johan Adolfsson, linux-wireless, 'Dan Williams'

On Mon, 30 Jun 2008, John W. Linville wrote:
> On Mon, Jun 30, 2008 at 08:36:56AM +0200, Johan Adolfsson wrote:
> > Resending to linux-wireless after positive feedback on libertas-dev.
> > 
> > Attached is a patch against the 2.6.25 driver that adds a 
> > module parameter called "regioncode" to set the region code
> > in the libertas driver.
> > 
> > Hope the format is ok.
> > Signed-off-by: Johan.Adolfsson@axis.com
> 
> Anyone want to offer an opinion on how this (overriding the region
> code from the hardware) differs in effect from the patch that disabled
> all regulatory controls on mac80211 devices?
> 
> >From what I understand about regulatory practices, it seems
> irresponsible to allow a regulatory setting embedded in a device's
> ROM to be so easily overridden?

IMO, it is actually the right thing to do.  We should just plain ignore
EEPROM regulatory domain information (not antenna gain and other data, just
the "where in the world the card is" data) in the general case, except maybe
if you want to use as a last resort default.

Let me explain my reasoning through an example:  I live in Brazil.  It is
extremely common to get crippled wireless devices here, because we get
paired up with the USA and rest of the North, Central and South Americas by
some very big vendors in one big regulatory domain.  That's annoying, and I
have been left without connectivity more than once when I was in a hotzone
operating in channel 13 (which has *exactly* the same restrictions for usage
as those for channels 1-12 in Brazil), but my card thought channel 13 was
illegal to operate at.

Now I get my trusty laptop with the EEPROM-based regdomain driver, and
travel to somewhere where the channel overlap with the Americas regdomain
the vendor used is such that the card can actually operate outside of the
requirements for the local government.   If I am lucky, it just won't allow
me to talk to everyone like what happens in Brazil.  If I am not, I could be
breaking the law.

Where, in the entire scenario above, was the regulatory information in the
EEPROM useful to me?  NEVER.  It was a hindrance in every step.

We live in a small world.  Regulatory information in EEPROMs is something
that just plain doesn't work well in the general case for any mobile
hardware that you're going to travel with.  Heck, in most cases it doesn't
work that well even if you are NOT going to travel with, given the corners
the vendors cut out of their regulatory domain tables...

The whole idea of EEPROM-based selection of a regulatory domains is a failed
concept.  It cannot be fixed, so let's get rid of it.  We can do better.  

I'd rather I could tell the system "I am in country foo", and it would apply
all the regulatory information for country foo correctly.  That's the way to
go, since the system can't find out where it is automatically (but userspace
could, actually, if given a sophisticated world map and (GPS or something
else) geo-location feed).

And, if we have devices that are exceptions (and I bet we do) and must be
always locked to some specific regulatory domain, we deal with it on the
drivers of these devices, instead of causing issues for everyone else.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH] Add module parameter to override regioncode on libertas
  2008-06-30 15:44     ` Henrique de Moraes Holschuh
@ 2008-06-30 17:29       ` John W. Linville
  0 siblings, 0 replies; 6+ messages in thread
From: John W. Linville @ 2008-06-30 17:29 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: Johan Adolfsson, linux-wireless, 'Dan Williams'

On Mon, Jun 30, 2008 at 12:44:26PM -0300, Henrique de Moraes Holschuh wrote:

> Now I get my trusty laptop with the EEPROM-based regdomain driver, and
> travel to somewhere where the channel overlap with the Americas regdomain
> the vendor used is such that the card can actually operate outside of the
> requirements for the local government.   If I am lucky, it just won't allow
> me to talk to everyone like what happens in Brazil.  If I am not, I could be
> breaking the law.
> 
> Where, in the entire scenario above, was the regulatory information in the
> EEPROM useful to me?  NEVER.  It was a hindrance in every step.

Hardware vendor representatives insist that regulaions should be
enforced as the product of both where you are (or claim to be) _and_
where the device was certified to operate when it was produced.  I have
no specific examples to cite of what might happen if e.g. a USA device
is operated on channel 13, but the hardware vendors insist that this
should not be allowed to happen.  "It works for me" anecdotes aside,
it seems like a bad idea to encourage (or fail to discourage) users
to override certified hardware regulatory settings.

If this is the only way to influence the regulatory enforcement
then your 2nd example is a valid.  But in that case moving to a
cfg80211-based regulatory enforcement seems like a better way to go.

John
-- 
John W. Linville
linville@tuxdriver.com

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

end of thread, other threads:[~2008-06-30 17:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1214580776.10355.16.camel@localhost.localdomain>
2008-06-30  6:36 ` [PATCH] Add module parameter to override regioncode on libertas Johan Adolfsson
2008-06-30 11:05   ` Johannes Berg
2008-06-30 11:58     ` Johan Adolfsson
2008-06-30 14:03   ` John W. Linville
2008-06-30 15:44     ` Henrique de Moraes Holschuh
2008-06-30 17:29       ` John W. Linville

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