linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath6kl: Process regulatory requests from firmware.
@ 2011-09-05  9:42 Vivek Natarajan
  2011-09-06  6:42 ` Kalle Valo
  0 siblings, 1 reply; 3+ messages in thread
From: Vivek Natarajan @ 2011-09-05  9:42 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

Process the regulatory code from eeprom and pass the
country information to cfg80211.

Signed-off-by: Vivek Natarajan <nataraja@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/wmi.c |   74 +++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath6kl/wmi.h |    6 +++
 2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index c9ec630..0203e00 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -18,6 +18,8 @@
 #include "core.h"
 #include "debug.h"
 #include "testmode.h"
+#include "../regd.h"
+#include "../regd_common.h"
 
 static int ath6kl_wmi_sync_point(struct wmi *wmi);
 
@@ -745,6 +747,77 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len)
 	return 0;
 }
 
+static struct country_code_to_enum_rd*
+ath6kl_regd_find_country(u16 countryCode)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
+		if (allCountries[i].countryCode == countryCode)
+			return &allCountries[i];
+	}
+	return NULL;
+}
+
+static struct reg_dmn_pair_mapping*
+ath6kl_get_regpair(u16 regdmn)
+{
+	int i;
+
+	if (regdmn == NO_ENUMRD)
+		return NULL;
+	for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
+		if (regDomainPairs[i].regDmnEnum == regdmn)
+			return &regDomainPairs[i];
+	}
+	return NULL;
+}
+
+static struct country_code_to_enum_rd*
+ath6kl_regd_find_country_by_rd(u16 regdmn)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
+		if (allCountries[i].regDmnEnum == regdmn)
+			return &allCountries[i];
+	}
+	return NULL;
+}
+
+static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
+{
+
+	struct ath6kl_wmi_regdomain *ev;
+	struct country_code_to_enum_rd *country = NULL;
+	struct reg_dmn_pair_mapping *regpair = NULL;
+	char alpha2[2];
+	u32 reg_code;
+
+	ev = (struct ath6kl_wmi_regdomain *) datap;
+	reg_code = le32_to_cpu(ev->reg_code);
+
+	if ((reg_code >> COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG)
+		country = ath6kl_regd_find_country((u16) reg_code);
+	else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
+
+		regpair = ath6kl_get_regpair((u16) reg_code);
+		country = ath6kl_regd_find_country_by_rd((u16) reg_code);
+		printk(KERN_DEBUG "ath6kl: Regpair used: 0x%0x\n",
+				regpair->regDmnEnum);
+	}
+
+	if (country) {
+		alpha2[0] = country->isoName[0];
+		alpha2[1] = country->isoName[1];
+
+		regulatory_hint(wmi->parent_dev->wdev->wiphy, alpha2);
+
+		printk(KERN_DEBUG "ath6kl: Country alpha2 being used: %c%c\n",
+				alpha2[0], alpha2[1]);
+	}
+}
+
 static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len)
 {
 	struct wmi_disconnect_event *ev;
@@ -3033,6 +3106,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
 		break;
 	case WMI_REGDOMAIN_EVENTID:
 		ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
+		ath6kl_wmi_regdomain_event(wmi, datap, len);
 		break;
 	case WMI_PSTREAM_TIMEOUT_EVENTID:
 		ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h
index a78e21b..abd9f6d 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.h
+++ b/drivers/net/wireless/ath/ath6kl/wmi.h
@@ -1306,6 +1306,12 @@ enum wmi_disconnect_reason {
 	IBSS_MERGE = 0xe,
 };
 
+#define COUNTRY_RD_SHIFT        16
+
+struct ath6kl_wmi_regdomain {
+	__le32 reg_code;
+};
+
 struct wmi_disconnect_event {
 	/* reason code, see 802.11 spec. */
 	__le16 proto_reason_status;
-- 
1.7.1


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

* Re: [PATCH] ath6kl: Process regulatory requests from firmware.
  2011-09-05  9:42 [PATCH] ath6kl: Process regulatory requests from firmware Vivek Natarajan
@ 2011-09-06  6:42 ` Kalle Valo
  2011-09-06  7:22   ` Vivek Natarajan
  0 siblings, 1 reply; 3+ messages in thread
From: Kalle Valo @ 2011-09-06  6:42 UTC (permalink / raw)
  To: Vivek Natarajan; +Cc: linux-wireless

On 09/05/2011 12:42 PM, Vivek Natarajan wrote:
> Process the regulatory code from eeprom and pass the
> country information to cfg80211.

Minor comments:

> +static struct country_code_to_enum_rd*
> +ath6kl_regd_find_country(u16 countryCode)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
> +		if (allCountries[i].countryCode == countryCode)
> +			return &allCountries[i];
> +	}

Insert space here.

> +	return NULL;
> +}
> +
> +static struct reg_dmn_pair_mapping*
> +ath6kl_get_regpair(u16 regdmn)
> +{
> +	int i;
> +
> +	if (regdmn == NO_ENUMRD)
> +		return NULL;

Space here as well

> +	for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
> +		if (regDomainPairs[i].regDmnEnum == regdmn)
> +			return &regDomainPairs[i];
> +	}

And here :)

> +	return NULL;
> +}
> +
> +static struct country_code_to_enum_rd*
> +ath6kl_regd_find_country_by_rd(u16 regdmn)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
> +		if (allCountries[i].regDmnEnum == regdmn)
> +			return &allCountries[i];
> +	}

Here also

> +	return NULL;
> +}
> +
> +static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap,
int len)
> +{
> +
> +	struct ath6kl_wmi_regdomain *ev;
> +	struct country_code_to_enum_rd *country = NULL;
> +	struct reg_dmn_pair_mapping *regpair = NULL;
> +	char alpha2[2];
> +	u32 reg_code;
> +
> +	ev = (struct ath6kl_wmi_regdomain *) datap;
> +	reg_code = le32_to_cpu(ev->reg_code);
> +
> +	if ((reg_code >> COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG)
> +		country = ath6kl_regd_find_country((u16) reg_code);
> +	else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
> +
> +		regpair = ath6kl_get_regpair((u16) reg_code);
> +		country = ath6kl_regd_find_country_by_rd((u16) reg_code);
> +		printk(KERN_DEBUG "ath6kl: Regpair used: 0x%0x\n",
> +				regpair->regDmnEnum);

ath6kl_dbg() is more approriate here.

> +	}
> +
> +	if (country) {
> +		alpha2[0] = country->isoName[0];
> +		alpha2[1] = country->isoName[1];
> +
> +		regulatory_hint(wmi->parent_dev->wdev->wiphy, alpha2);
> +
> +		printk(KERN_DEBUG "ath6kl: Country alpha2 being used: %c%c\n",
> +				alpha2[0], alpha2[1]);

Please use ath6kl_dbg() or, if we really need to log this, you can use
ath6kl_info(). But is there a reason to log this everytime?

> +#define COUNTRY_RD_SHIFT        16

Please add ATH6KL_ prefix.

Kalle

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

* Re: [PATCH] ath6kl: Process regulatory requests from firmware.
  2011-09-06  6:42 ` Kalle Valo
@ 2011-09-06  7:22   ` Vivek Natarajan
  0 siblings, 0 replies; 3+ messages in thread
From: Vivek Natarajan @ 2011-09-06  7:22 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Vivek Natarajan, linux-wireless

On Tue, Sep 6, 2011 at 12:12 PM, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> On 09/05/2011 12:42 PM, Vivek Natarajan wrote:
>> Process the regulatory code from eeprom and pass the
>> country information to cfg80211.
...
>> +     else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
>> +
>> +             regpair = ath6kl_get_regpair((u16) reg_code);
>> +             country = ath6kl_regd_find_country_by_rd((u16) reg_code);
>> +             printk(KERN_DEBUG "ath6kl: Regpair used: 0x%0x\n",
>> +                             regpair->regDmnEnum);
>
> ath6kl_dbg() is more approriate here.
>
>> +             regulatory_hint(wmi->parent_dev->wdev->wiphy, alpha2);
>> +
>> +             printk(KERN_DEBUG "ath6kl: Country alpha2 being used: %c%c\n",
>> +                             alpha2[0], alpha2[1]);
>
> Please use ath6kl_dbg() or, if we really need to log this, you can use
> ath6kl_info(). But is there a reason to log this everytime?

I had kept this print similar to ath9k. Anyhow, cfg80211 also prints
the country code from the driver. So, I will change this to
ath6kl_dbg.

Thanks
Vivek.

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

end of thread, other threads:[~2011-09-06  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05  9:42 [PATCH] ath6kl: Process regulatory requests from firmware Vivek Natarajan
2011-09-06  6:42 ` Kalle Valo
2011-09-06  7:22   ` Vivek Natarajan

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