提交 d6bad496 编写于 作者: S Sujith 提交者: John W. Linville

ath9k: Move regulatory information to a separate structure

Signed-off-by: NSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 d535a42a
master alk-4.19.24 alk-4.19.30 alk-4.19.34 alk-4.19.36 alk-4.19.43 alk-4.19.48 alk-4.19.57 ck-4.19.67 ck-4.19.81 ck-4.19.91 github/fork/deepanshu1422/fix-typo-in-comment github/fork/haosdent/fix-typo linux-next v4.19.91 v4.19.90 v4.19.89 v4.19.88 v4.19.87 v4.19.86 v4.19.85 v4.19.84 v4.19.83 v4.19.82 v4.19.81 v4.19.80 v4.19.79 v4.19.78 v4.19.77 v4.19.76 v4.19.75 v4.19.74 v4.19.73 v4.19.72 v4.19.71 v4.19.70 v4.19.69 v4.19.68 v4.19.67 v4.19.66 v4.19.65 v4.19.64 v4.19.63 v4.19.62 v4.19.61 v4.19.60 v4.19.59 v4.19.58 v4.19.57 v4.19.56 v4.19.55 v4.19.54 v4.19.53 v4.19.52 v4.19.51 v4.19.50 v4.19.49 v4.19.48 v4.19.47 v4.19.46 v4.19.45 v4.19.44 v4.19.43 v4.19.42 v4.19.41 v4.19.40 v4.19.39 v4.19.38 v4.19.37 v4.19.36 v4.19.35 v4.19.34 v4.19.33 v4.19.32 v4.19.31 v4.19.30 v4.19.29 v4.19.28 v4.19.27 v4.19.26 v4.19.25 v4.19.24 v4.19.23 v4.19.22 v4.19.21 v4.19.20 v4.19.19 v4.19.18 v4.19.17 v4.19.16 v4.19.15 v4.19.14 v4.19.13 v4.19.12 v4.19.11 v4.19.10 v4.19.9 v4.19.8 v4.19.7 v4.19.6 v4.19.5 v4.19.4 v4.19.3 v4.19.2 v4.19.1 v4.19 v4.19-rc8 v4.19-rc7 v4.19-rc6 v4.19-rc5 v4.19-rc4 v4.19-rc3 v4.19-rc2 v4.19-rc1 ck-release-21 ck-release-20 ck-release-19.2 ck-release-19.1 ck-release-19 ck-release-18 ck-release-17.2 ck-release-17.1 ck-release-17 ck-release-16 ck-release-15.1 ck-release-15 ck-release-14 ck-release-13.2 ck-release-13 ck-release-12 ck-release-11 ck-release-10 ck-release-9 ck-release-7 alk-release-15 alk-release-14 alk-release-13.2 alk-release-13 alk-release-12 alk-release-11 alk-release-10 alk-release-9 alk-release-7
无相关合并请求
......@@ -1232,9 +1232,9 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
if (ah->ah_tpScale != ATH9K_TP_SCALE_MAX) {
if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
maxRegAllowedPower -=
(tpScaleReductionTable[(ah->ah_tpScale)] * 2);
(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
}
scaledPower = min(powerLimit, maxRegAllowedPower);
......@@ -1510,9 +1510,9 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
if (ah->ah_tpScale != ATH9K_TP_SCALE_MAX) {
if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
maxRegAllowedPower -=
(tpScaleReductionTable[(ah->ah_tpScale)] * 2);
(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
}
scaledPower = min(powerLimit, maxRegAllowedPower);
......@@ -1823,10 +1823,10 @@ static int ath9k_hw_def_set_txpower(struct ath_hal *ah,
i = rateHt20_0;
if (AR_SREV_9280_10_OR_LATER(ah))
ah->ah_maxPowerLevel =
ah->regulatory.max_power_level =
ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
else
ah->ah_maxPowerLevel = ratesArray[i];
ah->regulatory.max_power_level = ratesArray[i];
return 0;
}
......@@ -1951,10 +1951,10 @@ static int ath9k_hw_4k_set_txpower(struct ath_hal *ah,
i = rateHt20_0;
if (AR_SREV_9280_10_OR_LATER(ah))
ah->ah_maxPowerLevel =
ah->regulatory.max_power_level =
ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
else
ah->ah_maxPowerLevel = ratesArray[i];
ah->regulatory.max_power_level = ratesArray[i];
return 0;
}
......
......@@ -409,7 +409,7 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
ah->ah_sc = sc;
ah->ah_sh = mem;
ah->hw_version.magic = AR5416_MAGIC;
ah->ah_countryCode = CTRY_DEFAULT;
ah->regulatory.country_code = CTRY_DEFAULT;
ah->hw_version.devid = devid;
ah->hw_version.subvendorid = 0;
......@@ -419,8 +419,8 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
if (!AR_SREV_9100(ah))
ah->ah_flags = AH_USE_EEPROM;
ah->ah_powerLimit = MAX_RATE_POWER;
ah->ah_tpScale = ATH9K_TP_SCALE_MAX;
ah->regulatory.power_limit = MAX_RATE_POWER;
ah->regulatory.tp_scale = ATH9K_TP_SCALE_MAX;
ahp->ah_atimWindow = 0;
ahp->ah_diversityControl = ah->ah_config.diversity_control;
ahp->ah_antennaSwitchSwap =
......@@ -1337,7 +1337,7 @@ static int ath9k_hw_process_ini(struct ath_hal *ah,
channel->max_antenna_gain * 2,
channel->max_power * 2,
min((u32) MAX_RATE_POWER,
(u32) ah->ah_powerLimit));
(u32) ah->regulatory.power_limit));
if (status != 0) {
DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
"error init'ing transmit power\n");
......@@ -1668,7 +1668,7 @@ static bool ath9k_hw_channel_change(struct ath_hal *ah,
channel->max_antenna_gain * 2,
channel->max_power * 2,
min((u32) MAX_RATE_POWER,
(u32) ah->ah_powerLimit)) != 0) {
(u32) ah->regulatory.power_limit)) != 0) {
DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
"error init'ing transmit power\n");
return false;
......@@ -3136,21 +3136,22 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
eeval = ath9k_hw_get_eeprom(ah, EEP_REG_0);
ah->ah_currentRD = eeval;
ah->regulatory.current_rd = eeval;
eeval = ath9k_hw_get_eeprom(ah, EEP_REG_1);
ah->ah_currentRDExt = eeval;
ah->regulatory.current_rd_ext = eeval;
capField = ath9k_hw_get_eeprom(ah, EEP_OP_CAP);
if (ah->ah_opmode != NL80211_IFTYPE_AP &&
ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
if (ah->ah_currentRD == 0x64 || ah->ah_currentRD == 0x65)
ah->ah_currentRD += 5;
else if (ah->ah_currentRD == 0x41)
ah->ah_currentRD = 0x43;
if (ah->regulatory.current_rd == 0x64 ||
ah->regulatory.current_rd == 0x65)
ah->regulatory.current_rd += 5;
else if (ah->regulatory.current_rd == 0x41)
ah->regulatory.current_rd = 0x43;
DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
"regdomain mapped to 0x%x\n", ah->ah_currentRD);
"regdomain mapped to 0x%x\n", ah->regulatory.current_rd);
}
eeval = ath9k_hw_get_eeprom(ah, EEP_OP_MODE);
......@@ -3292,7 +3293,7 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
else
pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
if (ah->ah_currentRDExt & (1 << REG_EXT_JAPAN_MIDBAND)) {
if (ah->regulatory.current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) {
pCap->reg_cap =
AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN |
......@@ -3392,13 +3393,13 @@ bool ath9k_hw_getcapability(struct ath_hal *ah, enum ath9k_capability_type type,
case 0:
return 0;
case 1:
*result = ah->ah_powerLimit;
*result = ah->regulatory.power_limit;
return 0;
case 2:
*result = ah->ah_maxPowerLevel;
*result = ah->regulatory.max_power_level;
return 0;
case 3:
*result = ah->ah_tpScale;
*result = ah->regulatory.tp_scale;
return 0;
}
return false;
......@@ -3655,14 +3656,14 @@ bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit)
struct ath9k_channel *chan = ah->ah_curchan;
struct ieee80211_channel *channel = chan->chan;
ah->ah_powerLimit = min(limit, (u32) MAX_RATE_POWER);
ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER);
if (ath9k_hw_set_txpower(ah, chan,
ath9k_regd_get_ctl(ah, chan),
channel->max_antenna_gain * 2,
channel->max_power * 2,
min((u32) MAX_RATE_POWER,
(u32) ah->ah_powerLimit)) != 0)
(u32) ah->regulatory.power_limit)) != 0)
return false;
return true;
......
......@@ -425,17 +425,9 @@ struct ath_hal {
enum nl80211_iftype ah_opmode;
struct ath9k_ops_config ah_config;
struct ath9k_hw_capabilities ah_caps;
u16 ah_countryCode;
struct ath9k_regulatory regulatory;
u32 ah_flags;
int16_t ah_powerLimit;
u16 ah_maxPowerLevel;
u32 ah_tpScale;
u16 ah_currentRD;
u16 ah_currentRDExt;
u16 ah_currentRDInUse;
char alpha2[2];
struct reg_dmn_pair_mapping *regpair;
enum ath9k_power_mode ah_power_mode;
enum ath9k_power_mode ah_restore_mode;
......
......@@ -1659,7 +1659,7 @@ int ath_attach(u16 devid, struct ath_softc *sc)
error = ieee80211_register_hw(hw);
if (!ath9k_is_world_regd(sc->sc_ah))
regulatory_hint(hw->wiphy, sc->sc_ah->alpha2);
regulatory_hint(hw->wiphy, sc->sc_ah->regulatory.alpha2);
/* Initialize LED control */
ath_init_leds(sc);
......
......@@ -108,7 +108,7 @@ static const struct ieee80211_regdomain ath9k_world_regdom_67_68_6A = {
static u16 ath9k_regd_get_eepromRD(struct ath_hal *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)
......@@ -129,7 +129,7 @@ const struct ieee80211_regdomain *ath9k_default_world_regdomain(void)
const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hal *ah)
{
switch (ah->regpair->regDmnEnum) {
switch (ah->regulatory.regpair->regDmnEnum) {
case 0x60:
case 0x61:
case 0x62:
......@@ -284,7 +284,7 @@ void ath9k_reg_apply_world_flags(struct wiphy *wiphy, enum reg_set_by setby)
struct ath_softc *sc = hw->priv;
struct ath_hal *ah = sc->sc_ah;
switch (ah->regpair->regDmnEnum) {
switch (ah->regulatory.regpair->regDmnEnum) {
case 0x60:
case 0x63:
case 0x66:
......@@ -413,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;
......@@ -446,18 +446,18 @@ 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;
}
......@@ -466,8 +466,8 @@ u32 ath9k_regd_get_ctl(struct ath_hal *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))
......@@ -478,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;
}
......@@ -45,6 +45,18 @@ struct country_code_to_enum_rd {
const char *isoName;
};
struct ath9k_regulatory {
char alpha2[2];
u16 country_code;
u16 max_power_level;
u32 tp_scale;
u16 current_rd;
u16 current_rd_ext;
u16 current_rd_inuse;
int16_t power_limit;
struct reg_dmn_pair_mapping *regpair;
};
enum CountryCode {
CTRY_ALBANIA = 8,
CTRY_ALGERIA = 12,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部