Region code support

Johan Adolfsson Johan.Adolfsson at axis.com
Wed Feb 17 18:02:47 EST 2010



> -----Original Message-----
> From: libertas-dev-bounces at lists.infradead.org [mailto:libertas-dev-
> bounces at lists.infradead.org] On Behalf Of Dan Williams
> Sent: den 17 februari 2010 21:18
> To: Johan Adolfsson
> Cc: Sebastian Andrzej Siewior; libertas-dev at lists.infradead.org
> Subject: RE: Region code support
> 
> On Wed, 2010-02-17 at 12:55 +0100, Johan Adolfsson wrote:
> > Hi,
> > I posted a patch quite some time ago (June 2008 or so) to set
> > the region code with a module parameter during module load.
> > Maybe that can work for you as well.
> 
> The discussion then hinged around cfg80211/regdb and of course things
> didn't go as quickly as planned.  So there's two paths here: (1) make
> sure the patch still applies to 2.6.32 and below and repost as a stable
> update, then we'll go through review again etc, and (2) make it work
> through cfg80211 in 2.6.33+.
> 
> I'm not opposed to adding the parameter (as I said back in 2008) to
> already released kernels as long as we understand that it's a dead-end
> for 2.6.33+ with the work that Holger's done for cfg80211.
> 
> Dan

Hi,
If I remember correctly, in practice we currently only need to switch between
US (channel 1-11) and EU (channel 1-13), everyone seems to have moved 
to one of those - possibly with the exception of Japan which has channel 14,
but only for 802.11b and not 802.11g or something like that, so I'm not 
sure anyone cares about channel 14 anymore.
Also there seems to be some misunderstanding regarding allowed transmit 
power for Japan, it seems it is only specified in a different way 
than EU and US does, (peak vs mean across the band or something)
but the powerlevel is actually the same, so EU works in Japan.
(May perhaps depend on your antenna gain for your hardware though)

Below is the diff we have against 2.6.31 - didn't have 2.6.32 available.
The diff is a lot cleaner with the -b flag though, and the tabs are probably
screwed up.
/Johan

--- linux-2.6.31.org/drivers/net/wireless/libertas/cmd.c	26 Nov 2009 11:47:03 -0000	1.1.1.10
+++ linux-2.6.31.new/drivers/net/wireless/libertas/cmd.c	26 Nov 2009 14:40:45 -0000	1.6
@@ -119,41 +119,57 @@
 	lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
 		    cmd.hwifversion, cmd.version);

-	/* Determine mesh_fw_ver from fwrelease and fwcapinfo */
-	/* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
-	/* 5.110.22 have mesh command with 0xa3 command id */
-	/* 10.0.0.p0 FW brings in mesh config command with different id */
-	/* Check FW version MSB and initialize mesh_fw_ver */
-	if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5)
-		priv->mesh_fw_ver = MESH_FW_OLD;
-	else if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
-		(priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK))
-		priv->mesh_fw_ver = MESH_FW_NEW;
-	else
-		priv->mesh_fw_ver = MESH_NONE;
+	/* 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.
+		 */

-	/* 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.
-	 *
-	 * Firmware version 4.0.102 used in CF8381 has region code shifted.  We
-	 * need to check for this problem and handle it properly.
-	 */
-	if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V4)
-		priv->regioncode = (le16_to_cpu(cmd.regioncode) >> 8) & 0xFF;
-	else
-		priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
+		/* Determine mesh_fw_ver from fwrelease and fwcapinfo */
+		/* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
+		/* 5.110.22 have mesh command with 0xa3 command id */
+		/* 10.0.0.p0 FW brings in mesh config command with different id */
+		/* Check FW version MSB and initialize mesh_fw_ver */
+		if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5)
+			priv->mesh_fw_ver = MESH_FW_OLD;
+		else if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
+			(priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK))
+			priv->mesh_fw_ver = MESH_FW_NEW;
+		else
+			priv->mesh_fw_ver = MESH_NONE;

-	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;
-	}
+		/* 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.
+		 *
+		 * Firmware version 4.0.102 used in CF8381 has region code shifted.  We
+		 * need to check for this problem and handle it properly.
+		 */
+		if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V4)
+			priv->regioncode = (le16_to_cpu(cmd.regioncode) >> 8) & 0xFF;
+		else
+			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)
Index: 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.10
retrieving revision 1.6
diff -u -r1.1.1.10 -r1.6
--- linux-2.6.31.org/drivers/net/wireless/libertas/main.c
+++ linux-2.6.31.new/drivers/net/wireless/libertas/main.c
@@ -37,6 +37,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);
+

 /* This global structure is used to send the confirm_sleep command as
  * fast as possible down to the firmware. */
@@ -1007,6 +1010,8 @@

 	/* Read MAC address from firmware */
 	memset(priv->current_addr, 0xff, ETH_ALEN);
+	if (lbs_regioncode > 0)
+		priv->regioncode = lbs_regioncode;
 	ret = lbs_update_hw_spec(priv);
 	if (ret)
 		goto done;




More information about the libertas-dev mailing list