ath9k: Merge ath_hal and ath_hal_5416 structures
[deliverable/linux.git] / drivers / net / wireless / ath9k / regd.c
index ec88f78743e9ac06a83c52bfbd3a2aadfe6a6553..8c2b56ac55ff250c68f8914d00c3c2377a8cfea6 100644 (file)
@@ -16,9 +16,7 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include "core.h"
-#include "hw.h"
-#include "regd.h"
+#include "ath9k.h"
 #include "regd_common.h"
 
 /*
@@ -108,17 +106,17 @@ static const struct ieee80211_regdomain ath9k_world_regdom_67_68_6A = {
        }
 };
 
-static u16 ath9k_regd_get_eepromRD(struct ath_hal *ah)
+static u16 ath9k_regd_get_eepromRD(struct ath_hw *ah)
 {
-       return ah->ah_currentRD & ~WORLDWIDE_ROAMING_FLAG;
+       return ah->regulatory.current_rd & ~WORLDWIDE_ROAMING_FLAG;
 }
 
-u16 ath9k_regd_get_rd(struct ath_hal *ah)
+u16 ath9k_regd_get_rd(struct ath_hw *ah)
 {
        return ath9k_regd_get_eepromRD(ah);
 }
 
-bool ath9k_is_world_regd(struct ath_hal *ah)
+bool ath9k_is_world_regd(struct ath_hw *ah)
 {
        return isWwrSKU(ah);
 }
@@ -129,9 +127,9 @@ const struct ieee80211_regdomain *ath9k_default_world_regdomain(void)
        return &ath9k_world_regdom_64;
 }
 
-const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hal *ah)
+const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hw *ah)
 {
-       switch (ah->regpair->regDmnEnum) {
+       switch (ah->regulatory.regpair->regDmnEnum) {
        case 0x60:
        case 0x61:
        case 0x62:
@@ -154,12 +152,20 @@ const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hal *ah)
        }
 }
 
-/* Enable adhoc on 5 GHz if allowed by 11d */
-static void ath9k_reg_apply_5ghz_adhoc_flags(struct wiphy *wiphy,
+/* Frequency is one where radar detection is required */
+static bool ath9k_is_radar_freq(u16 center_freq)
+{
+       return (center_freq >= 5260 && center_freq <= 5700);
+}
+
+/*
+ * Enable adhoc on 5 GHz if allowed by 11d.
+ * Remove passive scan if channel is allowed by 11d,
+ * except when on radar frequencies.
+ */
+static void ath9k_reg_apply_5ghz_beaconing_flags(struct wiphy *wiphy,
                                             enum reg_set_by setby)
 {
-       struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
-       struct ath_softc *sc = hw->priv;
        struct ieee80211_supported_band *sband;
        const struct ieee80211_reg_rule *reg_rule;
        struct ieee80211_channel *ch;
@@ -169,8 +175,7 @@ static void ath9k_reg_apply_5ghz_adhoc_flags(struct wiphy *wiphy,
 
        if (setby != REGDOM_SET_BY_COUNTRY_IE)
                return;
-       if (!test_bit(ATH9K_MODE_11A,
-           sc->sc_ah->ah_caps.wireless_modes))
+       if (!wiphy->bands[IEEE80211_BAND_5GHZ])
                return;
 
        sband = wiphy->bands[IEEE80211_BAND_5GHZ];
@@ -185,7 +190,11 @@ static void ath9k_reg_apply_5ghz_adhoc_flags(struct wiphy *wiphy,
                 * it by applying our static world regdomain by default during
                 * probe */
                if (!(reg_rule->flags & NL80211_RRF_NO_IBSS))
-                       ch->flags &= ~NL80211_RRF_NO_IBSS;
+                       ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
+               if (!ath9k_is_radar_freq(ch->center_freq))
+                       continue;
+               if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
+                       ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
        }
 }
 
@@ -250,9 +259,7 @@ void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
 
        for (i = 0; i < sband->n_channels; i++) {
                ch = &sband->channels[i];
-               if (ch->center_freq < 5260)
-                       continue;
-               if (ch->center_freq > 5700)
+               if (!ath9k_is_radar_freq(ch->center_freq))
                        continue;
                /* We always enable radar detection/DFS on this
                 * frequency range. Additionally we also apply on
@@ -275,17 +282,17 @@ void ath9k_reg_apply_world_flags(struct wiphy *wiphy, enum reg_set_by setby)
 {
        struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
        struct ath_softc *sc = hw->priv;
-       struct ath_hal *ah = sc->sc_ah;
+       struct ath_hw *ah = sc->sc_ah;
 
-       switch (ah->regpair->regDmnEnum) {
+       switch (ah->regulatory.regpair->regDmnEnum) {
        case 0x60:
        case 0x63:
        case 0x66:
        case 0x67:
-               ath9k_reg_apply_5ghz_adhoc_flags(wiphy, setby);
+               ath9k_reg_apply_5ghz_beaconing_flags(wiphy, setby);
                break;
        case 0x68:
-               ath9k_reg_apply_5ghz_adhoc_flags(wiphy, setby);
+               ath9k_reg_apply_5ghz_beaconing_flags(wiphy, setby);
                ath9k_reg_apply_active_scan_flags(wiphy, setby);
                break;
        }
@@ -315,7 +322,7 @@ int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
        return 0;
 }
 
-bool ath9k_regd_is_eeprom_valid(struct ath_hal *ah)
+bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah)
 {
        u16 rd = ath9k_regd_get_eepromRD(ah);
        int i;
@@ -364,7 +371,7 @@ ath9k_regd_find_country_by_rd(int regdmn)
 }
 
 /* Returns the map of the EEPROM set RD to a country code */
-static u16 ath9k_regd_get_default_country(struct ath_hal *ah)
+static u16 ath9k_regd_get_default_country(struct ath_hw *ah)
 {
        u16 rd;
 
@@ -395,7 +402,7 @@ ath9k_get_regpair(int regdmn)
        return NULL;
 }
 
-int ath9k_regd_init(struct ath_hal *ah)
+int ath9k_regd_init(struct ath_hw *ah)
 {
        struct country_code_to_enum_rd *country = NULL;
        int regdmn;
@@ -406,30 +413,30 @@ int ath9k_regd_init(struct ath_hal *ah)
                return -EINVAL;
        }
 
-       ah->ah_countryCode = ath9k_regd_get_default_country(ah);
+       ah->regulatory.country_code = ath9k_regd_get_default_country(ah);
 
-       if (ah->ah_countryCode == CTRY_DEFAULT &&
+       if (ah->regulatory.country_code == CTRY_DEFAULT &&
            ath9k_regd_get_eepromRD(ah) == CTRY_DEFAULT)
-               ah->ah_countryCode = CTRY_UNITED_STATES;
+               ah->regulatory.country_code = CTRY_UNITED_STATES;
 
-       if (ah->ah_countryCode == CTRY_DEFAULT) {
+       if (ah->regulatory.country_code == CTRY_DEFAULT) {
                regdmn = ath9k_regd_get_eepromRD(ah);
                country = NULL;
        } else {
-               country = ath9k_regd_find_country(ah->ah_countryCode);
+               country = ath9k_regd_find_country(ah->regulatory.country_code);
                if (country == NULL) {
                        DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
                                "Country is NULL!!!!, cc= %d\n",
-                               ah->ah_countryCode);
+                               ah->regulatory.country_code);
                        return -EINVAL;
                } else
                        regdmn = country->regDmnEnum;
        }
 
-       ah->ah_currentRDInUse = regdmn;
-       ah->regpair = ath9k_get_regpair(regdmn);
+       ah->regulatory.current_rd_inuse = regdmn;
+       ah->regulatory.regpair = ath9k_get_regpair(regdmn);
 
-       if (!ah->regpair) {
+       if (!ah->regulatory.regpair) {
                DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
                        "No regulatory domain pair found, cannot continue\n");
                return -EINVAL;
@@ -439,28 +446,28 @@ int ath9k_regd_init(struct ath_hal *ah)
                country = ath9k_regd_find_country_by_rd(regdmn);
 
        if (country) {
-               ah->alpha2[0] = country->isoName[0];
-               ah->alpha2[1] = country->isoName[1];
+               ah->regulatory.alpha2[0] = country->isoName[0];
+               ah->regulatory.alpha2[1] = country->isoName[1];
        } else {
-               ah->alpha2[0] = '0';
-               ah->alpha2[1] = '0';
+               ah->regulatory.alpha2[0] = '0';
+               ah->regulatory.alpha2[1] = '0';
        }
 
        DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
                "Country alpha2 being used: %c%c\n"
-               "Regpair detected: 0x%0x\n",
-               ah->alpha2[0], ah->alpha2[1],
-               ah->regpair->regDmnEnum);
+               "Regulatory.Regpair detected: 0x%0x\n",
+               ah->regulatory.alpha2[0], ah->regulatory.alpha2[1],
+               ah->regulatory.regpair->regDmnEnum);
 
        return 0;
 }
 
-u32 ath9k_regd_get_ctl(struct ath_hal *ah, struct ath9k_channel *chan)
+u32 ath9k_regd_get_ctl(struct ath_hw *ah, struct ath9k_channel *chan)
 {
        u32 ctl = NO_CTL;
 
-       if (!ah->regpair ||
-           (ah->ah_countryCode == CTRY_DEFAULT && isWwrSKU(ah))) {
+       if (!ah->regulatory.regpair ||
+           (ah->regulatory.country_code == CTRY_DEFAULT && isWwrSKU(ah))) {
                if (IS_CHAN_B(chan))
                        ctl = SD_NO_CTL | CTL_11B;
                else if (IS_CHAN_G(chan))
@@ -471,11 +478,11 @@ u32 ath9k_regd_get_ctl(struct ath_hal *ah, struct ath9k_channel *chan)
        }
 
        if (IS_CHAN_B(chan))
-               ctl = ah->regpair->reg_2ghz_ctl | CTL_11B;
+               ctl = ah->regulatory.regpair->reg_2ghz_ctl | CTL_11B;
        else if (IS_CHAN_G(chan))
-               ctl = ah->regpair->reg_5ghz_ctl | CTL_11G;
+               ctl = ah->regulatory.regpair->reg_5ghz_ctl | CTL_11G;
        else
-               ctl = ah->regpair->reg_5ghz_ctl | CTL_11A;
+               ctl = ah->regulatory.regpair->reg_5ghz_ctl | CTL_11A;
 
        return ctl;
 }
This page took 0.029011 seconds and 5 git commands to generate.