[PATCH v3 2/3] cfg80211: allow wiphy specific regdomain management

2014-11-23 Thread Arik Nemtsov
From: Jonathan Doron 

Add a new regulatory flag that allows a driver to manage regdomain
changes/updates for its own wiphy.
A self-managed wiphys only employs regulatory information obtained from
the FW and driver and does not use other cfg80211 sources like
beacon-hints, country-code IEs and hints from other devices on the same
system. Conversely, a self-managed wiphy does not share its regulatory
hints with other devices in the system. If a system contains several
devices, one or more of which are self-managed, there might be
contradictory regulatory settings between them. Usage of flag is
generally discouraged. Only use it if the FW/driver is incompatible
with non-locally originated hints.

A new API lets the driver send a complete regdomain, to be applied on
its wiphy only.

After a wiphy-specific regdomain change takes place, usermode will get
a new type of change notification. The regulatory core also takes care
enforce regulatory restrictions, in case some interfaces are on
forbidden channels.

Signed-off-by: Jonathan Doron 
Signed-off-by: Arik Nemtsov 
---
 include/net/cfg80211.h   | 16 +
 include/net/regulatory.h | 19 +++
 include/uapi/linux/nl80211.h |  5 +++
 net/wireless/core.c  |  8 +
 net/wireless/nl80211.c   | 80 ++--
 net/wireless/nl80211.h   |  1 +
 net/wireless/reg.c   | 59 
 7 files changed, 170 insertions(+), 18 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bb748c4..bfe630f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3808,6 +3808,22 @@ const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 
oui_type,
 int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
 
 /**
+ * regulatory_set_wiphy_regd_rtnl - set regdom info for self managed drivers
+ * @wiphy: the wireless device we want to process the regulatory domain on
+ * @rd: the regulatory domain informatoin to use for this wiphy
+ *
+ * Set the regulatory domain information for self-managed wiphys, only they
+ * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
+ * information.
+ *
+ * This function requires the caller to hold the rtnl_lock.
+ *
+ * Return: 0 on success. -EINVAL, -EPERM
+ */
+int regulatory_set_wiphy_regd_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/include/net/regulatory.h b/include/net/regulatory.h
index 701177c..d69c3db 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -141,6 +141,24 @@ struct regulatory_request {
  * change, the interfaces are given a grace period to disconnect or move
  * to an allowed channels. Interfaces on forbidden channels are forcibly
  * disconnected.
+ * @REGULATORY_WIPHY_SELF_MANAGED: for devices that employ wiphy-specific
+ * regdom management. These devices will ignore all regdom changes not
+ * originating from their own wiphy.
+ * A self-managed wiphys only employs regulatory information obtained from
+ * the FW and driver and does not use other cfg80211 sources like
+ * beacon-hints, country-code IEs and hints from other devices on the same
+ * system. Conversely, a self-managed wiphy does not share its regulatory
+ * hints with other devices in the system. If a system contains several
+ * devices, one or more of which are self-managed, there might be
+ * contradictory regulatory settings between them. Usage of flag is
+ * generally discouraged. Only use it if the FW/driver is incompatible
+ * with non-locally originated hints.
+ * This flag is incompatible with the flags: %REGULATORY_CUSTOM_REG,
+ * %REGULATORY_STRICT_REG, %REGULATORY_COUNTRY_IE_FOLLOW_POWER,
+ * %REGULATORY_COUNTRY_IE_IGNORE and %REGULATORY_DISABLE_BEACON_HINTS.
+ * Mixing any of the above flags with this flag will result in a failure
+ * to register the wiphy. This flag implies
+ * %REGULATORY_DISABLE_BEACON_HINTS.
  */
 enum ieee80211_regulatory_flags {
REGULATORY_CUSTOM_REG   = BIT(0),
@@ -150,6 +168,7 @@ enum ieee80211_regulatory_flags {
REGULATORY_COUNTRY_IE_IGNORE= BIT(4),
REGULATORY_ENABLE_RELAX_NO_IR   = BIT(5),
REGULATORY_ENFORCE_CHANNELS = BIT(6),
+   REGULATORY_WIPHY_SELF_MANAGED   = BIT(7),
 };
 
 struct ieee80211_freq_range {
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index d775245..3771e7d 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -774,6 +774,9 @@
  * peer given by %NL80211_ATTR_MAC. Both peers must be on the base channel
  * when this command completes.
  

Re: [PATCH v3 2/3] cfg80211: allow wiphy specific regdomain management

2014-11-25 Thread Luis R. Rodriguez
On Sun, Nov 23, 2014 at 05:02:20PM +0200, Arik Nemtsov wrote:
> From: Jonathan Doron 
> 
> Add a new regulatory flag that allows a driver to manage regdomain
> changes/updates for its own wiphy.
> A self-managed wiphys only employs regulatory information obtained from
> the FW and driver and does not use other cfg80211 sources like
> beacon-hints, country-code IEs and hints from other devices on the same
> system. Conversely, a self-managed wiphy does not share its regulatory
> hints with other devices in the system. If a system contains several
> devices, one or more of which are self-managed, there might be
> contradictory regulatory settings between them. Usage of flag is
> generally discouraged. Only use it if the FW/driver is incompatible
> with non-locally originated hints.
> 
> A new API lets the driver send a complete regdomain, to be applied on
> its wiphy only.
> 
> After a wiphy-specific regdomain change takes place, usermode will get
> a new type of change notification. The regulatory core also takes care
> enforce regulatory restrictions, in case some interfaces are on
> forbidden channels.
> 
> Signed-off-by: Jonathan Doron 
> Signed-off-by: Arik Nemtsov 

Reviewed-by: Luis R. Rodriguez 

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/3] cfg80211: allow wiphy specific regdomain management

2014-11-26 Thread Arik Nemtsov
On Sun, Nov 23, 2014 at 5:02 PM, Arik Nemtsov  wrote:

> +int regulatory_set_wiphy_regd_rtnl(struct wiphy *wiphy,
> +  struct ieee80211_regdomain *rd)
> +{

You gave us Reviewed-by, and it's appreciated, but unfortunately we
have to change the API a bit.

It appears we can't take the RTNL from within a driver safely - on
driver unload, we might have a work-item that needs the RTNL pending,
and the driver unload itself already acquires RTNL.
So we'll modify the code a bit to set a wiphy->requested_regd and do
the actual work inside reg_todo.

We'll resubmit shortly.

Arik
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html