All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mwifiex: Add module parameter for regdomain
@ 2013-06-10 22:40 Bing Zhao
  2013-06-12  7:15 ` Kalle Valo
  0 siblings, 1 reply; 11+ messages in thread
From: Bing Zhao @ 2013-06-10 22:40 UTC (permalink / raw)
  To: linux-wireless
  Cc: John W. Linville, Amitkumar Karwar, Avinash Patil,
	Yogesh Ashok Powar, Nishant Sarmukadam, Frank Huang, Bing Zhao,
	Paul Stewart

From: Avinash Patil <patila@marvell.com>

Allow a regulatory domain country code to be specified at boot
using a module argument.  This overrides the firmware regulatory
mode.

This patch also enables uAP to operate in 11a mode with hostapd.

Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Paul Stewart <pstew@chromium.org>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
 drivers/net/wireless/mwifiex/cfg80211.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 00a8281..0d27952 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -20,6 +20,9 @@
 #include "cfg80211.h"
 #include "main.h"
 
+static char *reg_alpha2;
+module_param(reg_alpha2, charp, 0);
+
 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
 	{
 		.max = 2, .types = BIT(NL80211_IFTYPE_STATION),
@@ -2475,6 +2478,17 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = {
 #endif
 };
 
+static bool mwifiex_is_valid_alpha2(const char *alpha2)
+{
+	if (!alpha2 || strlen(alpha2) != 2)
+		return false;
+
+	if (isalpha(alpha2[0]) && isalpha(alpha2[1]))
+		return true;
+
+	return false;
+}
+
 /*
  * This function registers the device with CFG802.11 subsystem.
  *
@@ -2527,6 +2541,7 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
 			WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
 			WIPHY_FLAG_AP_UAPSD |
 			WIPHY_FLAG_CUSTOM_REGULATORY |
+			WIPHY_FLAG_STRICT_REGULATORY |
 			WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
 
 	wiphy_apply_custom_regulatory(wiphy, &mwifiex_world_regdom_custom);
@@ -2568,10 +2583,16 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
 		wiphy_free(wiphy);
 		return ret;
 	}
-	country_code = mwifiex_11d_code_2_region(priv->adapter->region_code);
-	if (country_code)
-		dev_info(adapter->dev,
-			 "ignoring F/W country code %2.2s\n", country_code);
+
+	if (reg_alpha2 && mwifiex_is_valid_alpha2(reg_alpha2)) {
+		wiphy_info(wiphy, "driver hint alpha2: %2.2s\n", reg_alpha2);
+		regulatory_hint(wiphy, reg_alpha2);
+	} else {
+		country_code = mwifiex_11d_code_2_region(adapter->region_code);
+		if (country_code)
+			wiphy_info(wiphy, "ignoring F/W country code %2.2s\n",
+				   country_code);
+	}
 
 	adapter->wiphy = wiphy;
 	return ret;
-- 
1.8.2.3


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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-10 22:40 [PATCH] mwifiex: Add module parameter for regdomain Bing Zhao
@ 2013-06-12  7:15 ` Kalle Valo
  2013-06-12 17:43   ` Bing Zhao
  0 siblings, 1 reply; 11+ messages in thread
From: Kalle Valo @ 2013-06-12  7:15 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, John W. Linville, Amitkumar Karwar,
	Avinash Patil, Yogesh Ashok Powar, Nishant Sarmukadam,
	Frank Huang, Paul Stewart

Bing Zhao <bzhao@marvell.com> writes:

> From: Avinash Patil <patila@marvell.com>
>
> Allow a regulatory domain country code to be specified at boot
> using a module argument.  This overrides the firmware regulatory
> mode.
>
> This patch also enables uAP to operate in 11a mode with hostapd.
>
> Signed-off-by: Avinash Patil <patila@marvell.com>
> Signed-off-by: Paul Stewart <pstew@chromium.org>
> Signed-off-by: Bing Zhao <bzhao@marvell.com>

This looks ugly. Why can't you use the proper nl80211 interface and
instead want to add a driver specific hack?

-- 
Kalle Valo

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

* RE: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-12  7:15 ` Kalle Valo
@ 2013-06-12 17:43   ` Bing Zhao
  2013-06-12 18:52     ` Kalle Valo
  0 siblings, 1 reply; 11+ messages in thread
From: Bing Zhao @ 2013-06-12 17:43 UTC (permalink / raw)
  To: Kalle Valo
  Cc: linux-wireless, John W. Linville, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang,
	Paul Stewart

Hi Kalle,

> > From: Avinash Patil <patila@marvell.com>
> >
> > Allow a regulatory domain country code to be specified at boot
> > using a module argument.  This overrides the firmware regulatory
> > mode.
> >
> > This patch also enables uAP to operate in 11a mode with hostapd.
> >
> > Signed-off-by: Avinash Patil <patila@marvell.com>
> > Signed-off-by: Paul Stewart <pstew@chromium.org>
> > Signed-off-by: Bing Zhao <bzhao@marvell.com>
> 
> This looks ugly. Why can't you use the proper nl80211 interface and
> instead want to add a driver specific hack?

"iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
What we need here is a *driver* hint.
Furthermore, with a driver regulatory hint, the passive-scan and no-ibss flags are cleared so we can start AP with hostapd on 5G band.

Thanks,
Bing

> 
> --
> Kalle Valo

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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-12 17:43   ` Bing Zhao
@ 2013-06-12 18:52     ` Kalle Valo
  2013-06-12 18:55       ` Ben Greear
  0 siblings, 1 reply; 11+ messages in thread
From: Kalle Valo @ 2013-06-12 18:52 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, John W. Linville, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang,
	Paul Stewart

Bing Zhao <bzhao@marvell.com> writes:

> Hi Kalle,
>
>> > From: Avinash Patil <patila@marvell.com>
>> >
>> > Allow a regulatory domain country code to be specified at boot
>> > using a module argument.  This overrides the firmware regulatory
>> > mode.
>> >
>> > This patch also enables uAP to operate in 11a mode with hostapd.
>> >
>> > Signed-off-by: Avinash Patil <patila@marvell.com>
>> > Signed-off-by: Paul Stewart <pstew@chromium.org>
>> > Signed-off-by: Bing Zhao <bzhao@marvell.com>
>> 
>> This looks ugly. Why can't you use the proper nl80211 interface and
>> instead want to add a driver specific hack?
>
> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
>
> What we need here is a *driver* hint. Furthermore, with a driver
> regulatory hint, the passive-scan and no-ibss flags are cleared so we
> can start AP with hostapd on 5G band.

So it's a driver hint which is coming from user space via a module
parameter. IMHO you are abusing interfaces here. Is there any better way
to solve your problem?

-- 
Kalle Valo

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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-12 18:52     ` Kalle Valo
@ 2013-06-12 18:55       ` Ben Greear
  2013-06-12 19:01         ` Bing Zhao
  0 siblings, 1 reply; 11+ messages in thread
From: Ben Greear @ 2013-06-12 18:55 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Bing Zhao, linux-wireless, John W. Linville, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang,
	Paul Stewart

On 06/12/2013 11:52 AM, Kalle Valo wrote:
> Bing Zhao <bzhao@marvell.com> writes:
>
>> Hi Kalle,
>>
>>>> From: Avinash Patil <patila@marvell.com>
>>>>
>>>> Allow a regulatory domain country code to be specified at boot
>>>> using a module argument.  This overrides the firmware regulatory
>>>> mode.
>>>>
>>>> This patch also enables uAP to operate in 11a mode with hostapd.
>>>>
>>>> Signed-off-by: Avinash Patil <patila@marvell.com>
>>>> Signed-off-by: Paul Stewart <pstew@chromium.org>
>>>> Signed-off-by: Bing Zhao <bzhao@marvell.com>
>>>
>>> This looks ugly. Why can't you use the proper nl80211 interface and
>>> instead want to add a driver specific hack?
>>
>> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
>>
>> What we need here is a *driver* hint. Furthermore, with a driver
>> regulatory hint, the passive-scan and no-ibss flags are cleared so we
>> can start AP with hostapd on 5G band.
>
> So it's a driver hint which is coming from user space via a module
> parameter. IMHO you are abusing interfaces here. Is there any better way
> to solve your problem?

It would be nice to have some way to do this for ath9k and other NICs
as well.  Best I could come up with is a similar hack for ath9k.

I think part of the problem is that this config info needs to be
available very early in the module loading/init logic, so it's
too late to be configured using 'iw' or similar.

Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


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

* RE: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-12 18:55       ` Ben Greear
@ 2013-06-12 19:01         ` Bing Zhao
  2013-06-13 17:30           ` John W. Linville
  0 siblings, 1 reply; 11+ messages in thread
From: Bing Zhao @ 2013-06-12 19:01 UTC (permalink / raw)
  To: Ben Greear, Kalle Valo
  Cc: linux-wireless, John W. Linville, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang,
	Paul Stewart


> >> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
> >>
> >> What we need here is a *driver* hint. Furthermore, with a driver
> >> regulatory hint, the passive-scan and no-ibss flags are cleared so we
> >> can start AP with hostapd on 5G band.
> >
> > So it's a driver hint which is coming from user space via a module
> > parameter. IMHO you are abusing interfaces here. Is there any better way
> > to solve your problem?
> 
> It would be nice to have some way to do this for ath9k and other NICs
> as well.  Best I could come up with is a similar hack for ath9k.
> 
> I think part of the problem is that this config info needs to be
> available very early in the module loading/init logic, so it's
> too late to be configured using 'iw' or similar.

Exactly. regulatory_hint () needs to be called right after wiphy registration.

Thanks,
Bing

> 
> Thanks,
> Ben


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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-12 19:01         ` Bing Zhao
@ 2013-06-13 17:30           ` John W. Linville
  2013-06-13 17:33             ` Paul Stewart
  2013-06-13 17:36             ` Ben Greear
  0 siblings, 2 replies; 11+ messages in thread
From: John W. Linville @ 2013-06-13 17:30 UTC (permalink / raw)
  To: Bing Zhao
  Cc: Ben Greear, Kalle Valo, linux-wireless, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang,
	Paul Stewart

On Wed, Jun 12, 2013 at 12:01:23PM -0700, Bing Zhao wrote:
> 
> > >> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
> > >>
> > >> What we need here is a *driver* hint. Furthermore, with a driver
> > >> regulatory hint, the passive-scan and no-ibss flags are cleared so we
> > >> can start AP with hostapd on 5G band.
> > >
> > > So it's a driver hint which is coming from user space via a module
> > > parameter. IMHO you are abusing interfaces here. Is there any better way
> > > to solve your problem?
> > 
> > It would be nice to have some way to do this for ath9k and other NICs
> > as well.  Best I could come up with is a similar hack for ath9k.
> > 
> > I think part of the problem is that this config info needs to be
> > available very early in the module loading/init logic, so it's
> > too late to be configured using 'iw' or similar.
> 
> Exactly. regulatory_hint () needs to be called right after wiphy registration.

It does seem a bit ugly.  But if Marvell wants it, I don't see any
"regulatory" argument to disallow something like this.

Does anyone have a better suggestion for a user interface for such
a feature?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-13 17:30           ` John W. Linville
@ 2013-06-13 17:33             ` Paul Stewart
  2013-06-13 17:35               ` Paul Stewart
  2013-06-13 17:36             ` Ben Greear
  1 sibling, 1 reply; 11+ messages in thread
From: Paul Stewart @ 2013-06-13 17:33 UTC (permalink / raw)
  To: John W. Linville
  Cc: Bing Zhao, Ben Greear, Kalle Valo, linux-wireless,
	Amitkumar Karwar, Avinash Patil, Yogesh Powar,
	Nishant Sarmukadam, Frank Huang

On Thu, Jun 13, 2013 at 10:30 AM, John W. Linville
<linville@tuxdriver.com> wrote:
>
> On Wed, Jun 12, 2013 at 12:01:23PM -0700, Bing Zhao wrote:
> >
> > > >> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
> > > >>
> > > >> What we need here is a *driver* hint. Furthermore, with a driver
> > > >> regulatory hint, the passive-scan and no-ibss flags are cleared so we
> > > >> can start AP with hostapd on 5G band.
> > > >
> > > > So it's a driver hint which is coming from user space via a module
> > > > parameter. IMHO you are abusing interfaces here. Is there any better way
> > > > to solve your problem?
> > >
> > > It would be nice to have some way to do this for ath9k and other NICs
> > > as well.  Best I could come up with is a similar hack for ath9k.
> > >
> > > I think part of the problem is that this config info needs to be
> > > available very early in the module loading/init logic, so it's
> > > too late to be configured using 'iw' or similar.
> >
> > Exactly. regulatory_hint () needs to be called right after wiphy registration.
>
> It does seem a bit ugly.  But if Marvell wants it, I don't see any
> "regulatory" argument to disallow something like this.
>
> Does anyone have a better suggestion for a user interface for such
> a feature?


The only (slightly) cleaner thing I could think of is a module
parameter to cfg80211 so all drivers in the system would be made aware
of the boot-time regulatory domain.

>
>
> John
> --
> John W. Linville                Someday the world will need a hero, and you
> linville@tuxdriver.com                  might be all we have.  Be ready.

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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-13 17:33             ` Paul Stewart
@ 2013-06-13 17:35               ` Paul Stewart
  2013-06-13 17:46                 ` Bing Zhao
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Stewart @ 2013-06-13 17:35 UTC (permalink / raw)
  To: John W. Linville
  Cc: Bing Zhao, Ben Greear, Kalle Valo, linux-wireless,
	Amitkumar Karwar, Avinash Patil, Yogesh Powar,
	Nishant Sarmukadam, Frank Huang

On Thu, Jun 13, 2013 at 10:33 AM, Paul Stewart <pstew@chromium.org> wrote:
> On Thu, Jun 13, 2013 at 10:30 AM, John W. Linville
> <linville@tuxdriver.com> wrote:
>>
>> On Wed, Jun 12, 2013 at 12:01:23PM -0700, Bing Zhao wrote:
>> >
>> > > >> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
>> > > >>
>> > > >> What we need here is a *driver* hint. Furthermore, with a driver
>> > > >> regulatory hint, the passive-scan and no-ibss flags are cleared so we
>> > > >> can start AP with hostapd on 5G band.
>> > > >
>> > > > So it's a driver hint which is coming from user space via a module
>> > > > parameter. IMHO you are abusing interfaces here. Is there any better way
>> > > > to solve your problem?
>> > >
>> > > It would be nice to have some way to do this for ath9k and other NICs
>> > > as well.  Best I could come up with is a similar hack for ath9k.
>> > >
>> > > I think part of the problem is that this config info needs to be
>> > > available very early in the module loading/init logic, so it's
>> > > too late to be configured using 'iw' or similar.
>> >
>> > Exactly. regulatory_hint () needs to be called right after wiphy registration.
>>
>> It does seem a bit ugly.  But if Marvell wants it, I don't see any
>> "regulatory" argument to disallow something like this.
>>
>> Does anyone have a better suggestion for a user interface for such
>> a feature?
>
>
> The only (slightly) cleaner thing I could think of is a module
> parameter to cfg80211 so all drivers in the system would be made aware
> of the boot-time regulatory domain.

Oh, wait.  That exists in the 'ieee80211_regdom' parameter to
cfg80211.  You should use that. :-)

>>
>>
>> John
>> --
>> John W. Linville                Someday the world will need a hero, and you
>> linville@tuxdriver.com                  might be all we have.  Be ready.

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

* Re: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-13 17:30           ` John W. Linville
  2013-06-13 17:33             ` Paul Stewart
@ 2013-06-13 17:36             ` Ben Greear
  1 sibling, 0 replies; 11+ messages in thread
From: Ben Greear @ 2013-06-13 17:36 UTC (permalink / raw)
  To: John W. Linville
  Cc: Bing Zhao, Kalle Valo, linux-wireless, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang,
	Paul Stewart

On 06/13/2013 10:30 AM, John W. Linville wrote:
> On Wed, Jun 12, 2013 at 12:01:23PM -0700, Bing Zhao wrote:
>>
>>>>> "iw reg set XX" or "country_code=XX" in hostapd.conf is a *user* hint.
>>>>>
>>>>> What we need here is a *driver* hint. Furthermore, with a driver
>>>>> regulatory hint, the passive-scan and no-ibss flags are cleared so we
>>>>> can start AP with hostapd on 5G band.
>>>>
>>>> So it's a driver hint which is coming from user space via a module
>>>> parameter. IMHO you are abusing interfaces here. Is there any better way
>>>> to solve your problem?
>>>
>>> It would be nice to have some way to do this for ath9k and other NICs
>>> as well.  Best I could come up with is a similar hack for ath9k.
>>>
>>> I think part of the problem is that this config info needs to be
>>> available very early in the module loading/init logic, so it's
>>> too late to be configured using 'iw' or similar.
>>
>> Exactly. regulatory_hint () needs to be called right after wiphy registration.
>
> It does seem a bit ugly.  But if Marvell wants it, I don't see any
> "regulatory" argument to disallow something like this.
>
> Does anyone have a better suggestion for a user interface for such
> a feature?

Maybe a global over-ride module-option in cfg80211 module so that
we wouldn't have to have an individual module-option hack for
each driver?

But, then again, maybe we would still want individual driver
config options....

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


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

* RE: [PATCH] mwifiex: Add module parameter for regdomain
  2013-06-13 17:35               ` Paul Stewart
@ 2013-06-13 17:46                 ` Bing Zhao
  0 siblings, 0 replies; 11+ messages in thread
From: Bing Zhao @ 2013-06-13 17:46 UTC (permalink / raw)
  To: Paul Stewart, John W. Linville
  Cc: Ben Greear, Kalle Valo, linux-wireless, Amitkumar Karwar,
	Avinash Patil, Yogesh Powar, Nishant Sarmukadam, Frank Huang


> Oh, wait.  That exists in the 'ieee80211_regdom' parameter to
> cfg80211.  You should use that. :-)

'ieee80211_regdom' parameter is also a user regulatory hint.

        /*
         * Finally, if the user set the module parameter treat it
         * as a user hint.
         */
        if (!is_world_regdom(ieee80211_regdom))
                regulatory_hint_user(ieee80211_regdom,
                                     NL80211_USER_REG_HINT_USER);

Regards,
Bing

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

end of thread, other threads:[~2013-06-13 17:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-10 22:40 [PATCH] mwifiex: Add module parameter for regdomain Bing Zhao
2013-06-12  7:15 ` Kalle Valo
2013-06-12 17:43   ` Bing Zhao
2013-06-12 18:52     ` Kalle Valo
2013-06-12 18:55       ` Ben Greear
2013-06-12 19:01         ` Bing Zhao
2013-06-13 17:30           ` John W. Linville
2013-06-13 17:33             ` Paul Stewart
2013-06-13 17:35               ` Paul Stewart
2013-06-13 17:46                 ` Bing Zhao
2013-06-13 17:36             ` Ben Greear

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.