* [PATCH v2 0/3] cfg80211: send regulatory events
@ 2009-02-26 23:23 Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 1/3] cfg80211: remove REGDOM_SET_BY_INIT Luis R. Rodriguez
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-02-26 23:23 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, mb, Luis R. Rodriguez
This series does the work to prep and then send regulatory
events to userspace. This v2 keeps the country IE environment
within cfg80211.h as we don't want to inform userspace about
details of the country IE. We also now add the defines to help
userspace determine when the kernel has the new command request
and attributes.
Luis R. Rodriguez (3):
cfg80211: remove REGDOM_SET_BY_INIT
cfg80211: move enum reg_set_by to nl80211.h
cfg80211: add regulatory netlink multicast group
drivers/net/wireless/ath9k/main.c | 2 +-
drivers/net/wireless/ath9k/regd.c | 32 +++++++------
drivers/net/wireless/ath9k/regd.h | 3 +-
include/linux/nl80211.h | 45 +++++++++++++++++
include/net/cfg80211.h | 27 +---------
net/wireless/core.c | 2 +-
net/wireless/core.h | 3 +-
net/wireless/nl80211.c | 46 +++++++++++++++++
net/wireless/nl80211.h | 5 ++
net/wireless/reg.c | 97 ++++++++++++++++++++++---------------
10 files changed, 179 insertions(+), 83 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] cfg80211: remove REGDOM_SET_BY_INIT
2009-02-26 23:23 [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
@ 2009-02-26 23:23 ` Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 2/3] cfg80211: move enum reg_set_by to nl80211.h Luis R. Rodriguez
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-02-26 23:23 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, mb, Luis R. Rodriguez
This is not used as we can always just assume the first
regulatory domain set will _always_ be a static regulatory
domain. REGDOM_SET_BY_CORE will be the first request from
cfg80211 for a regdomain and that then populates the first
regulatory request.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
drivers/net/wireless/ath9k/main.c | 2 +-
drivers/net/wireless/ath9k/regd.c | 1 -
include/net/cfg80211.h | 3 ---
net/wireless/reg.c | 2 --
4 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index f5f5739..67a151e 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -1652,7 +1652,7 @@ int ath_attach(u16 devid, struct ath_softc *sc)
}
wiphy_apply_custom_regulatory(hw->wiphy, regd);
ath9k_reg_apply_radar_flags(hw->wiphy);
- ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_INIT);
+ ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_DRIVER);
error = ieee80211_register_hw(hw);
diff --git a/drivers/net/wireless/ath9k/regd.c b/drivers/net/wireless/ath9k/regd.c
index f7d7cc2..4f27cec 100644
--- a/drivers/net/wireless/ath9k/regd.c
+++ b/drivers/net/wireless/ath9k/regd.c
@@ -339,7 +339,6 @@ int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
switch (request->initiator) {
case REGDOM_SET_BY_DRIVER:
- case REGDOM_SET_BY_INIT:
case REGDOM_SET_BY_CORE:
case REGDOM_SET_BY_USER:
break;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 75fa556..f195ea4 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -350,8 +350,6 @@ struct bss_parameters {
/**
* enum reg_set_by - Indicates who is trying to set the regulatory domain
- * @REGDOM_SET_BY_INIT: regulatory domain was set by initialization. We will be
- * using a static world regulatory domain by default.
* @REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world regulatory domain.
* @REGDOM_SET_BY_USER: User asked the wireless core to set the
* regulatory domain.
@@ -362,7 +360,6 @@ struct bss_parameters {
* should consider.
*/
enum reg_set_by {
- REGDOM_SET_BY_INIT,
REGDOM_SET_BY_CORE,
REGDOM_SET_BY_USER,
REGDOM_SET_BY_DRIVER,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ce66bfd..a230d4b 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1243,8 +1243,6 @@ static int ignore_request(struct wiphy *wiphy,
return 0;
switch (pending_request->initiator) {
- case REGDOM_SET_BY_INIT:
- return -EINVAL;
case REGDOM_SET_BY_CORE:
return -EINVAL;
case REGDOM_SET_BY_COUNTRY_IE:
--
1.6.0.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] cfg80211: move enum reg_set_by to nl80211.h
2009-02-26 23:23 [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 1/3] cfg80211: remove REGDOM_SET_BY_INIT Luis R. Rodriguez
@ 2009-02-26 23:23 ` Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 3/3] cfg80211: add regulatory netlink multicast group Luis R. Rodriguez
2009-02-26 23:29 ` [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
3 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-02-26 23:23 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, mb, Luis R. Rodriguez
We do this so we can later inform userspace who set the
regulatory domain and provide details of the request.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
drivers/net/wireless/ath9k/main.c | 2 +-
drivers/net/wireless/ath9k/regd.c | 31 ++++++++------
drivers/net/wireless/ath9k/regd.h | 3 +-
include/linux/nl80211.h | 19 +++++++++
include/net/cfg80211.h | 24 +---------
net/wireless/core.c | 2 +-
net/wireless/core.h | 3 +-
net/wireless/reg.c | 82 ++++++++++++++++++++-----------------
8 files changed, 90 insertions(+), 76 deletions(-)
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 67a151e..dca1ab6 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -1652,7 +1652,7 @@ int ath_attach(u16 devid, struct ath_softc *sc)
}
wiphy_apply_custom_regulatory(hw->wiphy, regd);
ath9k_reg_apply_radar_flags(hw->wiphy);
- ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_DRIVER);
+ ath9k_reg_apply_world_flags(hw->wiphy, NL80211_REGDOM_SET_BY_DRIVER);
error = ieee80211_register_hw(hw);
diff --git a/drivers/net/wireless/ath9k/regd.c b/drivers/net/wireless/ath9k/regd.c
index 4f27cec..eb09ccd 100644
--- a/drivers/net/wireless/ath9k/regd.c
+++ b/drivers/net/wireless/ath9k/regd.c
@@ -168,8 +168,9 @@ static bool ath9k_is_radar_freq(u16 center_freq)
* received a beacon on a channel we can enable active scan and
* adhoc (or beaconing).
*/
-static void ath9k_reg_apply_beaconing_flags(struct wiphy *wiphy,
- enum reg_set_by setby)
+static void ath9k_reg_apply_beaconing_flags(
+ struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
enum ieee80211_band band;
struct ieee80211_supported_band *sband;
@@ -194,7 +195,7 @@ static void ath9k_reg_apply_beaconing_flags(struct wiphy *wiphy,
(ch->flags & IEEE80211_CHAN_RADAR))
continue;
- if (setby == REGDOM_SET_BY_COUNTRY_IE) {
+ if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
r = freq_reg_info(wiphy, ch->center_freq,
&bandwidth, ®_rule);
if (r)
@@ -226,8 +227,9 @@ static void ath9k_reg_apply_beaconing_flags(struct wiphy *wiphy,
}
/* Allows active scan scan on Ch 12 and 13 */
-static void ath9k_reg_apply_active_scan_flags(struct wiphy *wiphy,
- enum reg_set_by setby)
+static void ath9k_reg_apply_active_scan_flags(
+ struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch;
@@ -241,7 +243,7 @@ static void ath9k_reg_apply_active_scan_flags(struct wiphy *wiphy,
* If no country IE has been received always enable active scan
* on these channels. This is only done for specific regulatory SKUs
*/
- if (setby != REGDOM_SET_BY_COUNTRY_IE) {
+ if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
ch = &sband->channels[11]; /* CH 12 */
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
@@ -308,7 +310,8 @@ void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
}
}
-void ath9k_reg_apply_world_flags(struct wiphy *wiphy, enum reg_set_by setby)
+void ath9k_reg_apply_world_flags(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
struct ath_softc *sc = hw->priv;
@@ -319,11 +322,11 @@ void ath9k_reg_apply_world_flags(struct wiphy *wiphy, enum reg_set_by setby)
case 0x63:
case 0x66:
case 0x67:
- ath9k_reg_apply_beaconing_flags(wiphy, setby);
+ ath9k_reg_apply_beaconing_flags(wiphy, initiator);
break;
case 0x68:
- ath9k_reg_apply_beaconing_flags(wiphy, setby);
- ath9k_reg_apply_active_scan_flags(wiphy, setby);
+ ath9k_reg_apply_beaconing_flags(wiphy, initiator);
+ ath9k_reg_apply_active_scan_flags(wiphy, initiator);
break;
}
return;
@@ -338,11 +341,11 @@ int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
ath9k_reg_apply_radar_flags(wiphy);
switch (request->initiator) {
- case REGDOM_SET_BY_DRIVER:
- case REGDOM_SET_BY_CORE:
- case REGDOM_SET_BY_USER:
+ case NL80211_REGDOM_SET_BY_DRIVER:
+ case NL80211_REGDOM_SET_BY_CORE:
+ case NL80211_REGDOM_SET_BY_USER:
break;
- case REGDOM_SET_BY_COUNTRY_IE:
+ case NL80211_REGDOM_SET_BY_COUNTRY_IE:
if (ath9k_is_world_regd(sc->sc_ah))
ath9k_reg_apply_world_flags(wiphy, request->initiator);
break;
diff --git a/drivers/net/wireless/ath9k/regd.h b/drivers/net/wireless/ath9k/regd.h
index d48160d..8f885f3 100644
--- a/drivers/net/wireless/ath9k/regd.h
+++ b/drivers/net/wireless/ath9k/regd.h
@@ -236,7 +236,8 @@ enum CountryCode {
bool ath9k_is_world_regd(struct ath_hw *ah);
const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hw *ah);
const struct ieee80211_regdomain *ath9k_default_world_regdomain(void);
-void ath9k_reg_apply_world_flags(struct wiphy *wiphy, enum reg_set_by setby);
+void ath9k_reg_apply_world_flags(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator);
void ath9k_reg_apply_radar_flags(struct wiphy *wiphy);
int ath9k_regd_init(struct ath_hw *ah);
bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah);
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index f6e5637..c0fd432 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -673,6 +673,25 @@ enum nl80211_bitrate_attr {
};
/**
+ * enum nl80211_initiator - Indicates the initiator of a reg domain request
+ * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+ * thinks we should consider.
+ */
+enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+ NL80211_REGDOM_SET_BY_USER,
+ NL80211_REGDOM_SET_BY_DRIVER,
+ NL80211_REGDOM_SET_BY_COUNTRY_IE,
+};
+
+/**
* enum nl80211_reg_rule_attr - regulatory rule attributes
* @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
* considerations for a given frequency range. These are the
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index f195ea4..50f3fd9 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -349,27 +349,9 @@ struct bss_parameters {
};
/**
- * enum reg_set_by - Indicates who is trying to set the regulatory domain
- * @REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world regulatory domain.
- * @REGDOM_SET_BY_USER: User asked the wireless core to set the
- * regulatory domain.
- * @REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the wireless core
- * it thinks its knows the regulatory domain we should be in.
- * @REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an 802.11 country
- * information element with regulatory information it thinks we
- * should consider.
- */
-enum reg_set_by {
- REGDOM_SET_BY_CORE,
- REGDOM_SET_BY_USER,
- REGDOM_SET_BY_DRIVER,
- REGDOM_SET_BY_COUNTRY_IE,
-};
-
-/**
* enum environment_cap - Environment parsed from country IE
* @ENVIRON_ANY: indicates country IE applies to both indoor and
- * outdoor operation.
+ * outdoor operation.
* @ENVIRON_INDOOR: indicates country IE applies only to indoor operation
* @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation
*/
@@ -388,7 +370,7 @@ enum environment_cap {
* and potentially inform users of which devices specifically
* cased the conflicts.
* @initiator: indicates who sent this request, could be any of
- * of those set in reg_set_by, %REGDOM_SET_BY_*
+ * of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*)
* @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
* regulatory domain. We have a few special codes:
* 00 - World regulatory domain
@@ -405,7 +387,7 @@ enum environment_cap {
*/
struct regulatory_request {
int wiphy_idx;
- enum reg_set_by initiator;
+ enum nl80211_reg_initiator initiator;
char alpha2[2];
bool intersect;
u32 country_ie_checksum;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index dd7f222..c939f5e 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -350,7 +350,7 @@ int wiphy_register(struct wiphy *wiphy)
mutex_lock(&cfg80211_mutex);
/* set up regulatory info */
- wiphy_update_regulatory(wiphy, REGDOM_SET_BY_CORE);
+ wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
res = device_add(&drv->wiphy.dev);
if (res)
diff --git a/net/wireless/core.h b/net/wireless/core.h
index f6c53f5..6acd483 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -136,7 +136,8 @@ extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv,
char *newname);
void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
-void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby);
+void wiphy_update_regulatory(struct wiphy *wiphy,
+ enum nl80211_reg_initiator setby);
void cfg80211_bss_expire(struct cfg80211_registered_device *dev);
void cfg80211_bss_age(struct cfg80211_registered_device *dev,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index a230d4b..7341288 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -845,8 +845,8 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
* Follow the driver's regulatory domain, if present, unless a country
* IE has been processed or a user wants to help complaince further
*/
- if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE &&
- last_request->initiator != REGDOM_SET_BY_USER &&
+ if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
+ last_request->initiator != NL80211_REGDOM_SET_BY_USER &&
wiphy->regd)
regd = wiphy->regd;
@@ -931,7 +931,8 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
* http://tinyurl.com/11d-clarification
*/
if (r == -ERANGE &&
- last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
+ last_request->initiator ==
+ NL80211_REGDOM_SET_BY_COUNTRY_IE) {
#ifdef CONFIG_CFG80211_REG_DEBUG
printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz "
"intact on %s - no rule found in band on "
@@ -944,7 +945,8 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
* for the band so we respect its band definitions
*/
#ifdef CONFIG_CFG80211_REG_DEBUG
- if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
+ if (last_request->initiator ==
+ NL80211_REGDOM_SET_BY_COUNTRY_IE)
printk(KERN_DEBUG "cfg80211: Disabling "
"channel %d MHz on %s due to "
"Country IE\n",
@@ -958,7 +960,7 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
power_rule = ®_rule->power_rule;
- if (last_request->initiator == REGDOM_SET_BY_DRIVER &&
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
request_wiphy && request_wiphy == wiphy &&
request_wiphy->strict_regulatory) {
/*
@@ -999,11 +1001,12 @@ static void handle_band(struct wiphy *wiphy, enum ieee80211_band band)
handle_channel(wiphy, band, i);
}
-static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby)
+static bool ignore_reg_update(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
if (!last_request)
return true;
- if (setby == REGDOM_SET_BY_CORE &&
+ if (initiator == NL80211_REGDOM_SET_BY_CORE &&
wiphy->custom_regulatory)
return true;
/*
@@ -1016,12 +1019,12 @@ static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby)
return false;
}
-static void update_all_wiphy_regulatory(enum reg_set_by setby)
+static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator)
{
struct cfg80211_registered_device *drv;
list_for_each_entry(drv, &cfg80211_drv_list, list)
- wiphy_update_regulatory(&drv->wiphy, setby);
+ wiphy_update_regulatory(&drv->wiphy, initiator);
}
static void handle_reg_beacon(struct wiphy *wiphy,
@@ -1112,7 +1115,7 @@ static bool reg_is_world_roaming(struct wiphy *wiphy)
if (is_world_regdom(cfg80211_regdomain->alpha2) ||
(wiphy->regd && is_world_regdom(wiphy->regd->alpha2)))
return true;
- if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE &&
+ if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
wiphy->custom_regulatory)
return true;
return false;
@@ -1126,11 +1129,12 @@ static void reg_process_beacons(struct wiphy *wiphy)
wiphy_update_beacon_reg(wiphy);
}
-void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby)
+void wiphy_update_regulatory(struct wiphy *wiphy,
+ enum nl80211_reg_initiator initiator)
{
enum ieee80211_band band;
- if (ignore_reg_update(wiphy, setby))
+ if (ignore_reg_update(wiphy, initiator))
goto out;
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
if (wiphy->bands[band])
@@ -1243,15 +1247,16 @@ static int ignore_request(struct wiphy *wiphy,
return 0;
switch (pending_request->initiator) {
- case REGDOM_SET_BY_CORE:
+ case NL80211_REGDOM_SET_BY_CORE:
return -EINVAL;
- case REGDOM_SET_BY_COUNTRY_IE:
+ case NL80211_REGDOM_SET_BY_COUNTRY_IE:
last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx);
if (unlikely(!is_an_alpha2(pending_request->alpha2)))
return -EINVAL;
- if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
+ if (last_request->initiator ==
+ NL80211_REGDOM_SET_BY_COUNTRY_IE) {
if (last_wiphy != wiphy) {
/*
* Two cards with two APs claiming different
@@ -1272,8 +1277,8 @@ static int ignore_request(struct wiphy *wiphy,
return -EALREADY;
}
return REG_INTERSECT;
- case REGDOM_SET_BY_DRIVER:
- if (last_request->initiator == REGDOM_SET_BY_CORE) {
+ case NL80211_REGDOM_SET_BY_DRIVER:
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE) {
if (is_old_static_regdom(cfg80211_regdomain))
return 0;
if (regdom_changes(pending_request->alpha2))
@@ -1286,28 +1291,28 @@ static int ignore_request(struct wiphy *wiphy,
* back in or if you add a new device for which the previously
* loaded card also agrees on the regulatory domain.
*/
- if (last_request->initiator == REGDOM_SET_BY_DRIVER &&
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
!regdom_changes(pending_request->alpha2))
return -EALREADY;
return REG_INTERSECT;
- case REGDOM_SET_BY_USER:
- if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
+ case NL80211_REGDOM_SET_BY_USER:
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE)
return REG_INTERSECT;
/*
* If the user knows better the user should set the regdom
* to their country before the IE is picked up
*/
- if (last_request->initiator == REGDOM_SET_BY_USER &&
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_USER &&
last_request->intersect)
return -EOPNOTSUPP;
/*
* Process user requests only after previous user/driver/core
* requests have been processed
*/
- if (last_request->initiator == REGDOM_SET_BY_CORE ||
- last_request->initiator == REGDOM_SET_BY_DRIVER ||
- last_request->initiator == REGDOM_SET_BY_USER) {
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE ||
+ last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER ||
+ last_request->initiator == NL80211_REGDOM_SET_BY_USER) {
if (regdom_changes(last_request->alpha2))
return -EAGAIN;
}
@@ -1347,7 +1352,8 @@ static int __regulatory_hint(struct wiphy *wiphy,
r = ignore_request(wiphy, pending_request);
if (r == REG_INTERSECT) {
- if (pending_request->initiator == REGDOM_SET_BY_DRIVER) {
+ if (pending_request->initiator ==
+ NL80211_REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
if (r) {
kfree(pending_request);
@@ -1362,7 +1368,8 @@ static int __regulatory_hint(struct wiphy *wiphy,
* wiphy
*/
if (r == -EALREADY &&
- pending_request->initiator == REGDOM_SET_BY_DRIVER) {
+ pending_request->initiator ==
+ NL80211_REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
if (r) {
kfree(pending_request);
@@ -1413,7 +1420,7 @@ static void reg_process_hint(struct regulatory_request *reg_request)
if (wiphy_idx_valid(reg_request->wiphy_idx))
wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
- if (reg_request->initiator == REGDOM_SET_BY_DRIVER &&
+ if (reg_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
!wiphy) {
kfree(reg_request);
goto out;
@@ -1427,7 +1434,7 @@ out:
mutex_unlock(&cfg80211_mutex);
}
-/* Processes regulatory hints, this is all the REGDOM_SET_BY_* */
+/* Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_* */
static void reg_process_pending_hints(void)
{
struct regulatory_request *reg_request;
@@ -1511,7 +1518,7 @@ static int regulatory_hint_core(const char *alpha2)
request->alpha2[0] = alpha2[0];
request->alpha2[1] = alpha2[1];
- request->initiator = REGDOM_SET_BY_CORE;
+ request->initiator = NL80211_REGDOM_SET_BY_CORE;
queue_regulatory_request(request);
@@ -1532,7 +1539,7 @@ int regulatory_hint_user(const char *alpha2)
request->wiphy_idx = WIPHY_IDX_STALE;
request->alpha2[0] = alpha2[0];
request->alpha2[1] = alpha2[1];
- request->initiator = REGDOM_SET_BY_USER,
+ request->initiator = NL80211_REGDOM_SET_BY_USER,
queue_regulatory_request(request);
@@ -1558,7 +1565,7 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
request->alpha2[0] = alpha2[0];
request->alpha2[1] = alpha2[1];
- request->initiator = REGDOM_SET_BY_DRIVER;
+ request->initiator = NL80211_REGDOM_SET_BY_DRIVER;
queue_regulatory_request(request);
@@ -1707,7 +1714,7 @@ void regulatory_hint_11d(struct wiphy *wiphy,
request->wiphy_idx = get_wiphy_idx(wiphy);
request->alpha2[0] = rd->alpha2[0];
request->alpha2[1] = rd->alpha2[1];
- request->initiator = REGDOM_SET_BY_COUNTRY_IE;
+ request->initiator = NL80211_REGDOM_SET_BY_COUNTRY_IE;
request->country_ie_checksum = checksum;
request->country_ie_env = env;
@@ -1815,7 +1822,8 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
if (is_intersected_alpha2(rd->alpha2)) {
- if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
+ if (last_request->initiator ==
+ NL80211_REGDOM_SET_BY_COUNTRY_IE) {
struct cfg80211_registered_device *drv;
drv = cfg80211_drv_by_wiphy_idx(
last_request->wiphy_idx);
@@ -1907,7 +1915,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
* rd is non static (it means CRDA was present and was used last)
* and the pending request came in from a country IE
*/
- if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) {
+ if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
/*
* If someone else asked us to change the rd lets only bother
* checking if the alpha2 changes if CRDA was already called
@@ -1939,7 +1947,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
if (!last_request->intersect) {
int r;
- if (last_request->initiator != REGDOM_SET_BY_DRIVER) {
+ if (last_request->initiator != NL80211_REGDOM_SET_BY_DRIVER) {
reset_regdomains();
cfg80211_regdomain = rd;
return 0;
@@ -1963,7 +1971,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
/* Intersection requires a bit more work */
- if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) {
+ if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
intersected_rd = regdom_intersect(rd, cfg80211_regdomain);
if (!intersected_rd)
@@ -1974,7 +1982,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
* However if a driver requested this specific regulatory
* domain we keep it for its private use
*/
- if (last_request->initiator == REGDOM_SET_BY_DRIVER)
+ if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER)
request_wiphy->regd = rd;
else
kfree(rd);
--
1.6.0.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] cfg80211: add regulatory netlink multicast group
2009-02-26 23:23 [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 1/3] cfg80211: remove REGDOM_SET_BY_INIT Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 2/3] cfg80211: move enum reg_set_by to nl80211.h Luis R. Rodriguez
@ 2009-02-26 23:23 ` Luis R. Rodriguez
2009-02-26 23:29 ` [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
3 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-02-26 23:23 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, mb, Luis R. Rodriguez
This allows us to send to userspace "regulatory" events.
For now we just send an event when we change regulatory domains.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
include/linux/nl80211.h | 26 ++++++++++++++++++++++++++
net/wireless/nl80211.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
net/wireless/nl80211.h | 5 +++++
net/wireless/reg.c | 13 ++++++++++++-
4 files changed, 89 insertions(+), 1 deletions(-)
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index c0fd432..b4b65ad 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -150,6 +150,16 @@
* @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
* partial scan results may be available
*
+ * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
+ * has been changed and provides details of the request information
+ * that caused the change such as who initiated the regulatory request
+ * (%NL80211_ATTR_REG_INITIATOR), the alpha2 to which we have moved on
+ * to (%NL80211_ATTR_REG_ALPHA2), whether or not the regulatory domain
+ * is the product of an intersection (%NL80211_ATTR_REG_INTERSECT) and
+ * the registered device's wiphy_idx (NL80211_ATTR_WIPHY) on which the
+ * request was made from (if the request came from a country IE or a
+ * driver regulatory hint).
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -204,6 +214,8 @@ enum nl80211_commands {
NL80211_CMD_NEW_SCAN_RESULTS,
NL80211_CMD_SCAN_ABORTED,
+ NL80211_CMD_REG_CHANGE,
+
/* add new commands above here */
/* used to define NL80211_CMD_MAX below */
@@ -218,6 +230,8 @@ enum nl80211_commands {
#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
+
/**
* enum nl80211_attrs - nl80211 netlink attributes
*
@@ -329,6 +343,13 @@ enum nl80211_commands {
* messages carried the same generation number)
* @NL80211_ATTR_BSS: scan result BSS
*
+ * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
+ * currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*
+ * @NL80211_ATTR_REG_INTERSECT: indicates whether or not the current regulatory
+ * domain is the product of an interesection between two regulatory
+ * domains. This is a boolean value so if this is set it means it was
+ * the product of an intersection.
+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
@@ -403,6 +424,9 @@ enum nl80211_attrs {
NL80211_ATTR_SCAN_GENERATION,
NL80211_ATTR_BSS,
+ NL80211_ATTR_REG_INITIATOR,
+ NL80211_ATTR_REG_INTERSECT,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -420,6 +444,8 @@ enum nl80211_attrs {
#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
#define NL80211_ATTR_IE NL80211_ATTR_IE
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
+#define NL80211_ATTR_REG_INTERSECT NL80211_ATTR_REG_INTERSECT
#define NL80211_MAX_SUPP_RATES 32
#define NL80211_MAX_SUPP_REG_RULES 32
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 04ef828..f384fab 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2705,6 +2705,9 @@ static struct genl_multicast_group nl80211_config_mcgrp = {
static struct genl_multicast_group nl80211_scan_mcgrp = {
.name = "scan",
};
+static struct genl_multicast_group nl80211_regulatory_mcgrp = {
+ .name = "regulatory",
+};
/* notification functions */
@@ -2784,6 +2787,45 @@ void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
genlmsg_multicast(msg, 0, nl80211_scan_mcgrp.id, GFP_KERNEL);
}
+void nl80211_send_reg_change_event(struct regulatory_request *request)
+{
+ struct sk_buff *msg;
+ void *hdr;
+
+ msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+ if (!msg)
+ return;
+
+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_CHANGE);
+ if (!hdr) {
+ nlmsg_free(msg);
+ return;
+ }
+
+ /* Userspace can count on these two always being set */
+ NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, request->alpha2);
+ NLA_PUT_U8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator);
+
+ if (wiphy_idx_valid(request->wiphy_idx))
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx);
+
+ if (request->intersect)
+ NLA_PUT_U8(msg, NL80211_ATTR_REG_INTERSECT, 1);
+
+ if (genlmsg_end(msg, hdr) < 0) {
+ nlmsg_free(msg);
+ return;
+ }
+
+ genlmsg_multicast(msg, 0, nl80211_regulatory_mcgrp.id, GFP_KERNEL);
+
+ return;
+
+nla_put_failure:
+ genlmsg_cancel(msg, hdr);
+ nlmsg_free(msg);
+}
+
/* initialisation/exit functions */
int nl80211_init(void)
@@ -2808,6 +2850,10 @@ int nl80211_init(void)
if (err)
goto err_out;
+ err = genl_register_mc_group(&nl80211_fam, &nl80211_regulatory_mcgrp);
+ if (err)
+ goto err_out;
+
return 0;
err_out:
genl_unregister_family(&nl80211_fam);
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 69787b6..e65a3c3 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -11,6 +11,7 @@ extern void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
struct net_device *netdev);
extern void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
struct net_device *netdev);
+extern void nl80211_send_reg_change_event(struct regulatory_request *request);
#else
static inline int nl80211_init(void)
{
@@ -31,6 +32,10 @@ static inline void nl80211_send_scan_aborted(
struct cfg80211_registered_device *rdev,
struct net_device *netdev)
{}
+static inline void
+nl80211_send_reg_change_event(struct regulatory_request *request)
+{
+}
#endif /* CONFIG_NL80211 */
#endif /* __NET_WIRELESS_NL80211_H */
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7341288..a9ce557 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -41,6 +41,7 @@
#include <net/cfg80211.h>
#include "core.h"
#include "reg.h"
+#include "nl80211.h"
/* Receipt of information from last regulatory request */
static struct regulatory_request *last_request;
@@ -1391,8 +1392,16 @@ new_request:
pending_request = NULL;
/* When r == REG_INTERSECT we do need to call CRDA */
- if (r < 0)
+ if (r < 0) {
+ /*
+ * Since CRDA will not be called in this case as we already
+ * have applied the requested regulatory domain before we just
+ * inform userspace we have processed the request
+ */
+ if (r == -EALREADY)
+ nl80211_send_reg_change_event(last_request);
return r;
+ }
/*
* Note: When CONFIG_WIRELESS_OLD_REGULATORY is enabled
@@ -2072,6 +2081,8 @@ int set_regdom(const struct ieee80211_regdomain *rd)
print_regdomain(cfg80211_regdomain);
+ nl80211_send_reg_change_event(last_request);
+
return r;
}
--
1.6.0.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] cfg80211: send regulatory events
2009-02-26 23:23 [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
` (2 preceding siblings ...)
2009-02-26 23:23 ` [PATCH v2 3/3] cfg80211: add regulatory netlink multicast group Luis R. Rodriguez
@ 2009-02-26 23:29 ` Luis R. Rodriguez
2009-02-27 0:40 ` Luis R. Rodriguez
3 siblings, 1 reply; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-02-26 23:29 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, mb, Luis R. Rodriguez
On Thu, Feb 26, 2009 at 3:23 PM, Luis R. Rodriguez
<lrodriguez@atheros.com> wrote:
> This series does the work to prep and then send regulatory
> events to userspace. This v2 keeps the country IE environment
> within cfg80211.h as we don't want to inform userspace about
> details of the country IE. We also now add the defines to help
> userspace determine when the kernel has the new command request
> and attributes.
I forgot to mention this is also no longer based on top of Jouni's
MLME patch as that will be resent later so this can go in first.
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] cfg80211: send regulatory events
2009-02-26 23:29 ` [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
@ 2009-02-27 0:40 ` Luis R. Rodriguez
2009-03-06 19:42 ` John W. Linville
0 siblings, 1 reply; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-02-27 0:40 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, mb, Luis R. Rodriguez
On Thu, Feb 26, 2009 at 3:29 PM, Luis R. Rodriguez
<lrodriguez@atheros.com> wrote:
> On Thu, Feb 26, 2009 at 3:23 PM, Luis R. Rodriguez
> <lrodriguez@atheros.com> wrote:
>> This series does the work to prep and then send regulatory
>> events to userspace. This v2 keeps the country IE environment
>> within cfg80211.h as we don't want to inform userspace about
>> details of the country IE. We also now add the defines to help
>> userspace determine when the kernel has the new command request
>> and attributes.
>
> I forgot to mention this is also no longer based on top of Jouni's
> MLME patch as that will be resent later so this can go in first.
Dah -- turns out NL80211_ATTR_REG_INTERSECT is not required as we
already pass that on the alpha2. Will resend with that removed. So
this now would only add one more attribute, the initiator.
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] cfg80211: send regulatory events
2009-02-27 0:40 ` Luis R. Rodriguez
@ 2009-03-06 19:42 ` John W. Linville
2009-03-06 21:34 ` Luis R. Rodriguez
0 siblings, 1 reply; 8+ messages in thread
From: John W. Linville @ 2009-03-06 19:42 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: johannes, linux-wireless, mb
On Thu, Feb 26, 2009 at 04:40:40PM -0800, Luis R. Rodriguez wrote:
> On Thu, Feb 26, 2009 at 3:29 PM, Luis R. Rodriguez
> <lrodriguez@atheros.com> wrote:
> > On Thu, Feb 26, 2009 at 3:23 PM, Luis R. Rodriguez
> > <lrodriguez@atheros.com> wrote:
> >> This series does the work to prep and then send regulatory
> >> events to userspace. This v2 keeps the country IE environment
> >> within cfg80211.h as we don't want to inform userspace about
> >> details of the country IE. We also now add the defines to help
> >> userspace determine when the kernel has the new command request
> >> and attributes.
> >
> > I forgot to mention this is also no longer based on top of Jouni's
> > MLME patch as that will be resent later so this can go in first.
>
> Dah -- turns out NL80211_ATTR_REG_INTERSECT is not required as we
> already pass that on the alpha2. Will resend with that removed. So
> this now would only add one more attribute, the initiator.
Did I miss the resend?
--
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] 8+ messages in thread
* Re: [PATCH v2 0/3] cfg80211: send regulatory events
2009-03-06 19:42 ` John W. Linville
@ 2009-03-06 21:34 ` Luis R. Rodriguez
0 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2009-03-06 21:34 UTC (permalink / raw)
To: John W. Linville
Cc: Luis Rodriguez, johannes@sipsolutions.net,
linux-wireless@vger.kernel.org, mb@bu3sch.de
On Fri, Mar 06, 2009 at 11:42:43AM -0800, John W. Linville wrote:
> On Thu, Feb 26, 2009 at 04:40:40PM -0800, Luis R. Rodriguez wrote:
> > On Thu, Feb 26, 2009 at 3:29 PM, Luis R. Rodriguez
> > <lrodriguez@atheros.com> wrote:
> > > On Thu, Feb 26, 2009 at 3:23 PM, Luis R. Rodriguez
> > > <lrodriguez@atheros.com> wrote:
> > >> This series does the work to prep and then send regulatory
> > >> events to userspace. This v2 keeps the country IE environment
> > >> within cfg80211.h as we don't want to inform userspace about
> > >> details of the country IE. We also now add the defines to help
> > >> userspace determine when the kernel has the new command request
> > >> and attributes.
> > >
> > > I forgot to mention this is also no longer based on top of Jouni's
> > > MLME patch as that will be resent later so this can go in first.
> >
> > Dah -- turns out NL80211_ATTR_REG_INTERSECT is not required as we
> > already pass that on the alpha2. Will resend with that removed. So
> > this now would only add one more attribute, the initiator.
>
> Did I miss the resend?
Nah sorry, was working on korg bugzilla 12110 [1] which seemd a little more
important than this, but I think today I can get these out, will resend.
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-03-06 21:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-26 23:23 [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 1/3] cfg80211: remove REGDOM_SET_BY_INIT Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 2/3] cfg80211: move enum reg_set_by to nl80211.h Luis R. Rodriguez
2009-02-26 23:23 ` [PATCH v2 3/3] cfg80211: add regulatory netlink multicast group Luis R. Rodriguez
2009-02-26 23:29 ` [PATCH v2 0/3] cfg80211: send regulatory events Luis R. Rodriguez
2009-02-27 0:40 ` Luis R. Rodriguez
2009-03-06 19:42 ` John W. Linville
2009-03-06 21:34 ` Luis R. Rodriguez
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).