All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed
@ 2015-01-01 11:42 Arik Nemtsov
  2015-01-01 11:42 ` [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems Arik Nemtsov
  2015-01-06 10:54 ` [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Johannes Berg
  0 siblings, 2 replies; 10+ messages in thread
From: Arik Nemtsov @ 2015-01-01 11:42 UTC (permalink / raw)
  To: linux-wireless; +Cc: Johannes Berg, Luis R. Rodriguez, Arik Nemtsov

A self-managed device will sometimes need to set its regdomain synchronously.
Notably it should be set before usermode has a chance to query it. Expose
a new API to accomplish this which requires the RTNL.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 include/net/cfg80211.h | 14 ++++++++++++++
 net/wireless/reg.c     | 17 +++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bd672ea..cb0bba2 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3827,6 +3827,20 @@ int regulatory_set_wiphy_regd(struct wiphy *wiphy,
 			      struct ieee80211_regdomain *rd);
 
 /**
+ * regulatory_set_wiphy_regd_sync_rtnl - set regdom for self-managed drivers
+ * @wiphy: the wireless device we want to process the regulatory domain on
+ * @rd: the regulatory domain information to use for this wiphy
+ *
+ * This functions requires the RTNL to be held and applies the new regdomain
+ * synchronously to this wiphy. For more details see
+ * regulatory_set_wiphy_regd().
+ *
+ * Return: 0 on success. -EINVAL, -EPERM
+ */
+int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
+					struct ieee80211_regdomain *rd);
+
+/**
  * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  * @wiphy: the wireless device we want to process the regulatory domain on
  * @regd: the custom regulatory domain to use for this wiphy
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 9a5411c..9b5662f 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2928,6 +2928,23 @@ int regulatory_set_wiphy_regd(struct wiphy *wiphy,
 }
 EXPORT_SYMBOL(regulatory_set_wiphy_regd);
 
+int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
+					struct ieee80211_regdomain *rd)
+{
+	int ret;
+
+	ASSERT_RTNL();
+
+	ret = regulatory_set_wiphy_regd(wiphy, rd);
+	if (ret)
+		return ret;
+
+	/* process the request immediately */
+	reg_process_self_managed_hints();
+	return 0;
+}
+EXPORT_SYMBOL(regulatory_set_wiphy_regd_sync_rtnl);
+
 void wiphy_regulatory_register(struct wiphy *wiphy)
 {
 	struct regulatory_request *lr;
-- 
2.1.0


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

* [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-01 11:42 [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Arik Nemtsov
@ 2015-01-01 11:42 ` Arik Nemtsov
  2015-01-06 10:56   ` Johannes Berg
  2015-01-06 10:54 ` [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Johannes Berg
  1 sibling, 1 reply; 10+ messages in thread
From: Arik Nemtsov @ 2015-01-01 11:42 UTC (permalink / raw)
  To: linux-wireless; +Cc: Johannes Berg, Luis R. Rodriguez, Arik Nemtsov

When a system contains only self-managed regulatory devices all hints
from the regulatory core are ignored. Stop hint processing early in this
case. These systems usually don't have CRDA deployed, which results in
endless (irrelevent) logs of the form:
cfg80211: Calling CRDA to update world regulatory domain

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
---
 net/wireless/reg.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 9b5662f..21b2095 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2102,6 +2102,22 @@ out_free:
 	reg_free_request(reg_request);
 }
 
+static bool reg_only_self_managed_wiphys(void)
+{
+	struct cfg80211_registered_device *rdev;
+	struct wiphy *wiphy;
+
+	ASSERT_RTNL();
+
+	list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
+		wiphy = &rdev->wiphy;
+		if (!(wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED))
+			return false;
+	}
+
+	return true;
+}
+
 /*
  * Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_*
  * Regulatory hints come on a first come first serve basis and we
@@ -2133,6 +2149,11 @@ static void reg_process_pending_hints(void)
 
 	spin_unlock(&reg_requests_lock);
 
+	if (reg_only_self_managed_wiphys()) {
+		reg_free_request(reg_request);
+		return;
+	}
+
 	reg_process_hint(reg_request);
 }
 
-- 
2.1.0


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

* Re: [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed
  2015-01-01 11:42 [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Arik Nemtsov
  2015-01-01 11:42 ` [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems Arik Nemtsov
@ 2015-01-06 10:54 ` Johannes Berg
  2015-01-07 13:35   ` Arik Nemtsov
  1 sibling, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2015-01-06 10:54 UTC (permalink / raw)
  To: Arik Nemtsov; +Cc: linux-wireless, Luis R. Rodriguez

On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> A self-managed device will sometimes need to set its regdomain synchronously.
> Notably it should be set before usermode has a chance to query it. Expose
> a new API to accomplish this which requires the RTNL.

> +	ret = regulatory_set_wiphy_regd(wiphy, rd);
> +	if (ret)
> +		return ret;

It seems to me you should refactor that and avoid scheduling the work
struct when you're going to run the necessary work below by hand.

johannes


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

* Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-01 11:42 ` [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems Arik Nemtsov
@ 2015-01-06 10:56   ` Johannes Berg
  2015-01-06 13:59     ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2015-01-06 10:56 UTC (permalink / raw)
  To: Arik Nemtsov; +Cc: linux-wireless, Luis R. Rodriguez

On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> When a system contains only self-managed regulatory devices all hints
> from the regulatory core are ignored. Stop hint processing early in this
> case. These systems usually don't have CRDA deployed, which results in
> endless (irrelevent) logs of the form:
> cfg80211: Calling CRDA to update world regulatory domain

Applied.

johannes


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

* Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-06 10:56   ` Johannes Berg
@ 2015-01-06 13:59     ` Johannes Berg
  2015-01-06 14:04       ` Arik Nemtsov
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2015-01-06 13:59 UTC (permalink / raw)
  To: Arik Nemtsov; +Cc: linux-wireless, Luis R. Rodriguez

On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> > When a system contains only self-managed regulatory devices all hints
> > from the regulatory core are ignored. Stop hint processing early in this
> > case. These systems usually don't have CRDA deployed, which results in
> > endless (irrelevent) logs of the form:
> > cfg80211: Calling CRDA to update world regulatory domain
> 
> Applied.

I take that back - dropped again. This was causing spurious messages in
the hwsim test run VM, saying something like "couldn't set reg domain:
-7". Maybe at that point not a single wiphy existed?

johannes


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

* Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-06 13:59     ` Johannes Berg
@ 2015-01-06 14:04       ` Arik Nemtsov
  2015-01-07 13:38         ` Arik Nemtsov
  0 siblings, 1 reply; 10+ messages in thread
From: Arik Nemtsov @ 2015-01-06 14:04 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Luis R. Rodriguez

On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>> > When a system contains only self-managed regulatory devices all hints
>> > from the regulatory core are ignored. Stop hint processing early in this
>> > case. These systems usually don't have CRDA deployed, which results in
>> > endless (irrelevent) logs of the form:
>> > cfg80211: Calling CRDA to update world regulatory domain
>>
>> Applied.
>
> I take that back - dropped again. This was causing spurious messages in
> the hwsim test run VM, saying something like "couldn't set reg domain:
> -7". Maybe at that point not a single wiphy existed?

Interesting. I guess I should fix this to only drop the request in
case there's at least one self-managed wiphy.

Arik

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

* Re: [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed
  2015-01-06 10:54 ` [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Johannes Berg
@ 2015-01-07 13:35   ` Arik Nemtsov
  0 siblings, 0 replies; 10+ messages in thread
From: Arik Nemtsov @ 2015-01-07 13:35 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Luis R. Rodriguez

On Tue, Jan 6, 2015 at 12:54 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>> A self-managed device will sometimes need to set its regdomain synchronously.
>> Notably it should be set before usermode has a chance to query it. Expose
>> a new API to accomplish this which requires the RTNL.
>
>> +     ret = regulatory_set_wiphy_regd(wiphy, rd);
>> +     if (ret)
>> +             return ret;
>
> It seems to me you should refactor that and avoid scheduling the work
> struct when you're going to run the necessary work below by hand.

Sounds good.

Arik

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

* Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-06 14:04       ` Arik Nemtsov
@ 2015-01-07 13:38         ` Arik Nemtsov
  2015-01-07 13:42           ` Johannes Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Arik Nemtsov @ 2015-01-07 13:38 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Luis R. Rodriguez

On Tue, Jan 6, 2015 at 4:04 PM, Arik Nemtsov <arik@wizery.com> wrote:
> On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
>>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>>> > When a system contains only self-managed regulatory devices all hints
>>> > from the regulatory core are ignored. Stop hint processing early in this
>>> > case. These systems usually don't have CRDA deployed, which results in
>>> > endless (irrelevent) logs of the form:
>>> > cfg80211: Calling CRDA to update world regulatory domain
>>>
>>> Applied.
>>
>> I take that back - dropped again. This was causing spurious messages in
>> the hwsim test run VM, saying something like "couldn't set reg domain:
>> -7". Maybe at that point not a single wiphy existed?
>
> Interesting. I guess I should fix this to only drop the request in
> case there's at least one self-managed wiphy.

Could you point me to the hwsim test that failed for you?
Also where is that message coming from? I don't see it in wpa_s or the kernel.

Arik

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

* Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-07 13:38         ` Arik Nemtsov
@ 2015-01-07 13:42           ` Johannes Berg
  2015-01-07 13:45             ` Arik Nemtsov
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2015-01-07 13:42 UTC (permalink / raw)
  To: Arik Nemtsov; +Cc: linux-wireless, Luis R. Rodriguez

On Wed, 2015-01-07 at 15:38 +0200, Arik Nemtsov wrote:
> On Tue, Jan 6, 2015 at 4:04 PM, Arik Nemtsov <arik@wizery.com> wrote:
> > On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> >> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
> >>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> >>> > When a system contains only self-managed regulatory devices all hints
> >>> > from the regulatory core are ignored. Stop hint processing early in this
> >>> > case. These systems usually don't have CRDA deployed, which results in
> >>> > endless (irrelevent) logs of the form:
> >>> > cfg80211: Calling CRDA to update world regulatory domain
> >>>
> >>> Applied.
> >>
> >> I take that back - dropped again. This was causing spurious messages in
> >> the hwsim test run VM, saying something like "couldn't set reg domain:
> >> -7". Maybe at that point not a single wiphy existed?
> >
> > Interesting. I guess I should fix this to only drop the request in
> > case there's at least one self-managed wiphy.
> 
> Could you point me to the hwsim test that failed for you?

I don't think it was a specific test case - the message seems to have
come during boot. OTOH, I also reverted some of Eliad's patches, so
perhaps I should retest without those?

> Also where is that message coming from? I don't see it in wpa_s or the kernel.

I have no idea! I can't even explain where the -7 (-E2BIG) came from!

johannes


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

* Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems
  2015-01-07 13:42           ` Johannes Berg
@ 2015-01-07 13:45             ` Arik Nemtsov
  0 siblings, 0 replies; 10+ messages in thread
From: Arik Nemtsov @ 2015-01-07 13:45 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Luis R. Rodriguez

On Wed, Jan 7, 2015 at 3:42 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Wed, 2015-01-07 at 15:38 +0200, Arik Nemtsov wrote:
>> On Tue, Jan 6, 2015 at 4:04 PM, Arik Nemtsov <arik@wizery.com> wrote:
>> > On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> >> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
>> >>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>> >>> > When a system contains only self-managed regulatory devices all hints
>> >>> > from the regulatory core are ignored. Stop hint processing early in this
>> >>> > case. These systems usually don't have CRDA deployed, which results in
>> >>> > endless (irrelevent) logs of the form:
>> >>> > cfg80211: Calling CRDA to update world regulatory domain
>> >>>
>> >>> Applied.
>> >>
>> >> I take that back - dropped again. This was causing spurious messages in
>> >> the hwsim test run VM, saying something like "couldn't set reg domain:
>> >> -7". Maybe at that point not a single wiphy existed?
>> >
>> > Interesting. I guess I should fix this to only drop the request in
>> > case there's at least one self-managed wiphy.
>>
>> Could you point me to the hwsim test that failed for you?
>
> I don't think it was a specific test case - the message seems to have
> come during boot. OTOH, I also reverted some of Eliad's patches, so
> perhaps I should retest without those?

It's a good check to add anyway (at least one self-managed device).
Since the regulatory queues us the world-update core hint right away..
Not sure why I haven't encountered it, I'll try to introduce some
sleep() calls to reproduce. It's a real bug I believe.

>
>> Also where is that message coming from? I don't see it in wpa_s or the kernel.
>
> I have no idea! I can't even explain where the -7 (-E2BIG) came from!

Yea that's what I was after as well. :)

Arik

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

end of thread, other threads:[~2015-01-07 13:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01 11:42 [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Arik Nemtsov
2015-01-01 11:42 ` [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems Arik Nemtsov
2015-01-06 10:56   ` Johannes Berg
2015-01-06 13:59     ` Johannes Berg
2015-01-06 14:04       ` Arik Nemtsov
2015-01-07 13:38         ` Arik Nemtsov
2015-01-07 13:42           ` Johannes Berg
2015-01-07 13:45             ` Arik Nemtsov
2015-01-06 10:54 ` [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed Johannes Berg
2015-01-07 13:35   ` Arik Nemtsov

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.