#include <linux/kernel.h>
#include <linux/slab.h>
-#include "core.h"
-#include "hw.h"
-#include "regd.h"
+#include "ath9k.h"
#include "regd_common.h"
/*
}
};
-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);
}
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:
}
}
-/* 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;
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];
* 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;
}
}
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
{
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;
}
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;
}
/* 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;
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;
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;
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))
}
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;
}