]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
cfg80211: allow following country IE power for custom regdom cards
authorLuis R. Rodriguez <rodrigue@qca.qualcomm.com>
Wed, 7 Dec 2011 16:20:07 +0000 (21:50 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 16 Dec 2011 14:30:42 +0000 (09:30 -0500)
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: compat@orbit-lab.org
Cc: Paul Stewart <pstew@google.com>
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Cc: Senthilkumar Balasubramanian <senthilb@qca.qualcomm.com>
Reported-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/cfg80211.h
net/wireless/reg.c

index 5eda5933ae01c1e84d73bab2091da7d759bb036d..9f85fca0b676606e0f04c4baa3a80bf6888778c4 100644 (file)
@@ -1699,7 +1699,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
index 2f5b0505c95d59e9362bddf01432a1f2b2a50778..481caafc6ba5bda9e712205fe7aa4cce7a104c6a 100644 (file)
@@ -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);
 }