Skip to contentSkip to conversation

Add module parameter to override regioncode on libertas

PATCH In review Johan Adolfsson 4 participants 6 messages Jun 30, 2008 1 message not in the archive 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Add module parameter to override regioncode on libertas

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 [email protected]

Best regards
/Johan

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

net/wireless/libertas/main.c +6 -1
diff -u -r1.1.1.4 main.c
@@ -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

net/wireless/libertas/cmd.c +23 -11
diff -u -r1.1.1.4 cmd.c
@@ -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)
maintainer
#2 lore raw
Quoted 8 lines · Johan Adolfsson

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 [email protected]

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

johannes

#3 lore raw
Quoted 18 lines

-----Original Message-----
From: Johannes Berg [mailto:[email protected]]
Sent: den 30 juni 2008 13:05
To: Johan Adolfsson
Cc: [email protected]; 'Dan Williams'
Subject: Re: [PATCH] Add module parameter to override regioncode on libertas

Quoted 6 lines · Johan Adolfsson

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.

Quoted 8 lines
Quoted 2 lines

Hope the format is ok.

Signed-off-by [email protected]

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

#4 lore raw
In reply to Johan Adolfsson
Quoted 9 lines · Johan Adolfsson

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 [email protected]

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?

Quoted 1 line

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

Signature · 2 lines
John W. Linville
[email protected]
#5 lore raw
Quoted 10 lines · John W. Linville
Quoted 8 lines · Johan Adolfsson

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 [email protected]
Quoted 7 lines

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?

Quoted 1 line

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.

Signature · 4 lines
  "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
#6 lore raw
Quoted 9 lines · Henrique de Moraes Holschuh

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

Signature · 2 lines
John W. Linville
[email protected]