Here is a v2 for some enhancements for country IE processing and disconnect events.
Thanks to Rajkumar for spotting this issue and working on some further enhancements.
This series adds a new patch which restores the custom regulatory settings upon
disconnect. As for the optimizations for applying these changes in hardware
immediately for now my recommendation is to do it in the reg_notifier() for
each driver because as can be seen the alternative that I supplied was a bit
nasty.
Luis R. Rodriguez (1):
cfg80211: allow following country IE power for custom regdom cards
Rajkumar Manoharan (1):
cfg80211: Restore orig channel values upon disconnect
include/net/cfg80211.h | 4 +++-
net/wireless/reg.c | 40 ++++++++++++++++++++++++++++++++++++----
2 files changed, 39 insertions(+), 5 deletions(-)
--
1.7.4.15.g7811d
From: Rajkumar Manoharan <[email protected]>
When we restore regulatory settings the world regulatory domain
is properly reset on cfg80211 (or user prefered regulatory domain)
but we were never setting back channel values for drivers that use
WIPHY_FLAG_CUSTOM_REGULATORY. Set these values up again by using
the orig_ channel parameters.
This fixes restoring custom regulatory settings upon disconnect
events.
Cc: [email protected]
Cc: Paul Stewart <[email protected]>
Cc: Rajkumar Manoharan <[email protected]>
Cc: Senthilkumar Balasubramanian <[email protected]>
Signed-off-by: Rajkumar Manoharan <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
net/wireless/reg.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 4fe396a..3d60b8d 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1801,6 +1801,7 @@ static void restore_regulatory_settings(bool reset_user)
struct reg_beacon *reg_beacon, *btmp;
struct regulatory_request *reg_request, *tmp;
LIST_HEAD(tmp_reg_req_list);
+ struct wiphy *wiphy;
mutex_lock(&cfg80211_mutex);
mutex_lock(®_mutex);
@@ -1853,6 +1854,25 @@ static void restore_regulatory_settings(bool reset_user)
kfree(last_request);
last_request = &core_request_world;
+ wiphy = wiphy_idx_to_wiphy(0);
+ if (wiphy && wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) {
+ struct ieee80211_supported_band *sband;
+ enum ieee80211_band band;
+ struct ieee80211_channel *chan;
+ int i;
+ for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+ sband = wiphy->bands[band];
+ if (!sband)
+ continue;
+ for (i = 0; i < sband->n_channels; i++) {
+ chan = &sband->channels[i];
+ chan->flags = chan->orig_flags;
+ chan->max_antenna_gain = chan->orig_mag;
+ chan->max_power = chan->orig_mpwr;
+ }
+ }
+ }
+
mutex_unlock(®_mutex);
mutex_unlock(&cfg80211_mutex);
--
1.7.4.15.g7811d
By definition WIPHY_FLAG_STRICT_REGULATORY was intended to allow the
wiphy to adjust itself to the country IE power information if the
card had no regulatory data but we had no way to tell cfg80211 that if
the card also had its own custom regulatory domain (these are typically
custom world regulatory domains) that we want to follow the country IE's
noted values for power for each channel. We add support for this and
document it.
This is not a critical fix but a performance optimization for cards
with custom regulatory domains that associate to an AP with sends
out country IEs with a higher EIRP than the one on the custom
regulatory domain. In practice the only driver affected right now
are the Atheros drivers as they are the only drivers using both
WIPHY_FLAG_STRICT_REGULATORY and WIPHY_FLAG_CUSTOM_REGULATORY --
used on cards that have an Atheros world regulatory domain. Cards
that have been programmed to follow a country specifically will not
follow the country IE power. So although not a stable fix distributions
should consider cherry picking this.
Cc: [email protected]
Cc: Paul Stewart <[email protected]>
Cc: Rajkumar Manoharan <[email protected]>
Cc: Senthilkumar Balasubramanian <[email protected]>
Reported-by: Rajkumar Manoharan <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
include/net/cfg80211.h | 4 +++-
net/wireless/reg.c | 20 ++++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index a992782..d21d764 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1684,7 +1684,9 @@ struct cfg80211_ops {
* regulatory domain no user regulatory domain can enable these channels
* at a later time. This can be used for devices which do not have
* calibration information guaranteed for frequencies or settings
- * outside of its regulatory domain.
+ * outside of its regulatory domain. If used in combination with
+ * WIPHY_FLAG_CUSTOM_REGULATORY the inspected country IE power settings
+ * will be followed.
* @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure
* that passive scan flags and beaconing flags may not be lifted by
* cfg80211 due to regulatory beacon hints. For more information on beacon
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index d9ba091..4fe396a 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -873,10 +873,22 @@ static void handle_channel(struct wiphy *wiphy,
chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags);
chan->max_antenna_gain = min(chan->orig_mag,
(int) MBI_TO_DBI(power_rule->max_antenna_gain));
- if (chan->orig_mpwr)
- chan->max_power = min(chan->orig_mpwr,
- (int) MBM_TO_DBM(power_rule->max_eirp));
- else
+ if (chan->orig_mpwr) {
+ /*
+ * Devices that have their own custom regulatory domain
+ * but also use WIPHY_FLAG_STRICT_REGULATORY will follow the
+ * passed country IE power settings.
+ */
+ if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
+ wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY &&
+ wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) {
+ chan->max_power =
+ MBM_TO_DBM(power_rule->max_eirp);
+ } else {
+ chan->max_power = min(chan->orig_mpwr,
+ (int) MBM_TO_DBM(power_rule->max_eirp));
+ }
+ } else
chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp);
}
--
1.7.4.15.g7811d
On Mon, Nov 28, 2011 at 05:23:11PM -0500, Luis R. Rodriguez wrote:
> From: Rajkumar Manoharan <[email protected]>
>
> When we restore regulatory settings the world regulatory domain
> is properly reset on cfg80211 (or user prefered regulatory domain)
> but we were never setting back channel values for drivers that use
> WIPHY_FLAG_CUSTOM_REGULATORY. Set these values up again by using
> the orig_ channel parameters.
>
> This fixes restoring custom regulatory settings upon disconnect
> events.
>
> Cc: [email protected]
> Cc: Paul Stewart <[email protected]>
> Cc: Rajkumar Manoharan <[email protected]>
> Cc: Senthilkumar Balasubramanian <[email protected]>
> Signed-off-by: Rajkumar Manoharan <[email protected]>
> Signed-off-by: Luis R. Rodriguez <[email protected]>
> ---
> net/wireless/reg.c | 20 ++++++++++++++++++++
> 1 files changed, 20 insertions(+), 0 deletions(-)
>
John,
Can you please push these two RFC patches?
--
Rajkumar
On Wed, Dec 07, 2011 at 07:34:08PM +0530, Rajkumar Manoharan wrote:
> On Mon, Nov 28, 2011 at 05:23:11PM -0500, Luis R. Rodriguez wrote:
> > From: Rajkumar Manoharan <[email protected]>
> >
> > When we restore regulatory settings the world regulatory domain
> > is properly reset on cfg80211 (or user prefered regulatory domain)
> > but we were never setting back channel values for drivers that use
> > WIPHY_FLAG_CUSTOM_REGULATORY. Set these values up again by using
> > the orig_ channel parameters.
> >
> > This fixes restoring custom regulatory settings upon disconnect
> > events.
> >
> > Cc: [email protected]
> > Cc: Paul Stewart <[email protected]>
> > Cc: Rajkumar Manoharan <[email protected]>
> > Cc: Senthilkumar Balasubramanian <[email protected]>
> > Signed-off-by: Rajkumar Manoharan <[email protected]>
> > Signed-off-by: Luis R. Rodriguez <[email protected]>
> > ---
> > net/wireless/reg.c | 20 ++++++++++++++++++++
> > 1 files changed, 20 insertions(+), 0 deletions(-)
> >
> John,
>
> Can you please push these two RFC patches?
>
> --
> Rajkumar
Can you resend them?
Thanks,
John
--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.