提交 6b21fd20 编写于 作者: F Felix Fietkau 提交者: John W. Linville

ath9k_hw: simplify channel flags

There was some duplication between channelFlags and chanmode, as well as
a lot of redundant checks based on the combinations of flags.
Signed-off-by: NFelix Fietkau <nbd@openwrt.org>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 81c507a8
...@@ -408,7 +408,6 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, ...@@ -408,7 +408,6 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
ah->caldata->channel = chan->channel; ah->caldata->channel = chan->channel;
ah->caldata->channelFlags = chan->channelFlags; ah->caldata->channelFlags = chan->channelFlags;
ah->caldata->chanmode = chan->chanmode;
h = ah->caldata->nfCalHist; h = ah->caldata->nfCalHist;
default_nf = ath9k_hw_get_default_nf(ah, chan); default_nf = ath9k_hw_get_default_nf(ah, chan);
for (i = 0; i < NUM_NF_READINGS; i++) { for (i = 0; i < NUM_NF_READINGS; i++) {
......
...@@ -49,83 +49,44 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb) ...@@ -49,83 +49,44 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
} }
EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype); EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype);
static u32 ath9k_get_extchanmode(struct cfg80211_chan_def *chandef)
{
u32 chanmode = 0;
switch (chandef->chan->band) {
case IEEE80211_BAND_2GHZ:
switch (chandef->width) {
case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_WIDTH_20:
chanmode = CHANNEL_G_HT20;
break;
case NL80211_CHAN_WIDTH_40:
if (chandef->center_freq1 > chandef->chan->center_freq)
chanmode = CHANNEL_G_HT40PLUS;
else
chanmode = CHANNEL_G_HT40MINUS;
break;
default:
break;
}
break;
case IEEE80211_BAND_5GHZ:
switch (chandef->width) {
case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_WIDTH_20:
chanmode = CHANNEL_A_HT20;
break;
case NL80211_CHAN_WIDTH_40:
if (chandef->center_freq1 > chandef->chan->center_freq)
chanmode = CHANNEL_A_HT40PLUS;
else
chanmode = CHANNEL_A_HT40MINUS;
break;
default:
break;
}
break;
default:
break;
}
return chanmode;
}
/* /*
* Update internal channel flags. * Update internal channel flags.
*/ */
void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
struct cfg80211_chan_def *chandef) struct cfg80211_chan_def *chandef)
{ {
ichan->channel = chandef->chan->center_freq; struct ieee80211_channel *chan = chandef->chan;
ichan->chan = chandef->chan; u16 flags = 0;
if (chandef->chan->band == IEEE80211_BAND_2GHZ) { ichan->channel = chan->center_freq;
ichan->chanmode = CHANNEL_G; ichan->chan = chan;
ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM;
} else { if (chan->band == IEEE80211_BAND_5GHZ)
ichan->chanmode = CHANNEL_A; flags |= CHANNEL_5GHZ;
ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
}
switch (chandef->width) { switch (chandef->width) {
case NL80211_CHAN_WIDTH_5: case NL80211_CHAN_WIDTH_5:
ichan->channelFlags |= CHANNEL_QUARTER; flags |= CHANNEL_QUARTER;
break; break;
case NL80211_CHAN_WIDTH_10: case NL80211_CHAN_WIDTH_10:
ichan->channelFlags |= CHANNEL_HALF; flags |= CHANNEL_HALF;
break; break;
case NL80211_CHAN_WIDTH_20_NOHT: case NL80211_CHAN_WIDTH_20_NOHT:
break; break;
case NL80211_CHAN_WIDTH_20: case NL80211_CHAN_WIDTH_20:
flags |= CHANNEL_HT;
break;
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
ichan->chanmode = ath9k_get_extchanmode(chandef); if (chandef->center_freq1 > chandef->chan->center_freq)
flags |= CHANNEL_HT40PLUS | CHANNEL_HT;
else
flags |= CHANNEL_HT40MINUS | CHANNEL_HT;
break; break;
default: default:
WARN_ON(1); WARN_ON(1);
} }
ichan->channelFlags = flags;
} }
EXPORT_SYMBOL(ath9k_cmn_update_ichannel); EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
......
...@@ -1156,7 +1156,7 @@ u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan) ...@@ -1156,7 +1156,7 @@ u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan)
{ {
u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band); u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band);
if (IS_CHAN_G(chan)) if (IS_CHAN_2GHZ(chan))
ctl |= CTL_11G; ctl |= CTL_11G;
else else
ctl |= CTL_11A; ctl |= CTL_11A;
...@@ -1505,7 +1505,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, ...@@ -1505,7 +1505,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) { if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan); band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan);
mode_diff = (chan->chanmode != ah->curchan->chanmode); mode_diff = (chan->channelFlags != ah->curchan->channelFlags);
} }
for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
...@@ -1814,20 +1814,11 @@ static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan) ...@@ -1814,20 +1814,11 @@ static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan)
goto fail; goto fail;
/* /*
* If cross-band fcc is not supoprted, bail out if * If cross-band fcc is not supoprted, bail out if channelFlags differ.
* either channelFlags or chanmode differ.
*
* chanmode will be different if the HT operating mode
* changes because of CSA.
*/ */
if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH)) { if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) &&
if ((chan->channelFlags & CHANNEL_ALL) != chan->channelFlags != ah->curchan->channelFlags)
(ah->curchan->channelFlags & CHANNEL_ALL)) goto fail;
goto fail;
if (chan->chanmode != ah->curchan->chanmode)
goto fail;
}
if (!ath9k_hw_check_alive(ah)) if (!ath9k_hw_check_alive(ah))
goto fail; goto fail;
...@@ -1889,8 +1880,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, ...@@ -1889,8 +1880,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
ah->caldata = caldata; ah->caldata = caldata;
if (caldata && (chan->channel != caldata->channel || if (caldata && (chan->channel != caldata->channel ||
chan->channelFlags != caldata->channelFlags || chan->channelFlags != caldata->channelFlags)) {
chan->chanmode != caldata->chanmode)) {
/* Operating channel changed, reset channel calibration data */ /* Operating channel changed, reset channel calibration data */
memset(caldata, 0, sizeof(*caldata)); memset(caldata, 0, sizeof(*caldata));
ath9k_init_nfcal_hist_buffer(ah, chan); ath9k_init_nfcal_hist_buffer(ah, chan);
......
...@@ -369,36 +369,6 @@ enum ath9k_int { ...@@ -369,36 +369,6 @@ enum ath9k_int {
ATH9K_INT_NOCARD = 0xffffffff ATH9K_INT_NOCARD = 0xffffffff
}; };
#define CHANNEL_CCK 0x00020
#define CHANNEL_OFDM 0x00040
#define CHANNEL_2GHZ 0x00080
#define CHANNEL_5GHZ 0x00100
#define CHANNEL_PASSIVE 0x00200
#define CHANNEL_DYN 0x00400
#define CHANNEL_HALF 0x04000
#define CHANNEL_QUARTER 0x08000
#define CHANNEL_HT20 0x10000
#define CHANNEL_HT40PLUS 0x20000
#define CHANNEL_HT40MINUS 0x40000
#define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM)
#define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK)
#define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM)
#define CHANNEL_G_HT20 (CHANNEL_2GHZ|CHANNEL_HT20)
#define CHANNEL_A_HT20 (CHANNEL_5GHZ|CHANNEL_HT20)
#define CHANNEL_G_HT40PLUS (CHANNEL_2GHZ|CHANNEL_HT40PLUS)
#define CHANNEL_G_HT40MINUS (CHANNEL_2GHZ|CHANNEL_HT40MINUS)
#define CHANNEL_A_HT40PLUS (CHANNEL_5GHZ|CHANNEL_HT40PLUS)
#define CHANNEL_A_HT40MINUS (CHANNEL_5GHZ|CHANNEL_HT40MINUS)
#define CHANNEL_ALL \
(CHANNEL_OFDM| \
CHANNEL_CCK| \
CHANNEL_2GHZ | \
CHANNEL_5GHZ | \
CHANNEL_HT20 | \
CHANNEL_HT40PLUS | \
CHANNEL_HT40MINUS)
#define MAX_RTT_TABLE_ENTRY 6 #define MAX_RTT_TABLE_ENTRY 6
#define MAX_IQCAL_MEASUREMENT 8 #define MAX_IQCAL_MEASUREMENT 8
#define MAX_CL_TAB_ENTRY 16 #define MAX_CL_TAB_ENTRY 16
...@@ -417,8 +387,7 @@ enum ath9k_cal_flags { ...@@ -417,8 +387,7 @@ enum ath9k_cal_flags {
struct ath9k_hw_cal_data { struct ath9k_hw_cal_data {
u16 channel; u16 channel;
u32 channelFlags; u16 channelFlags;
u32 chanmode;
unsigned long cal_flags; unsigned long cal_flags;
int32_t CalValid; int32_t CalValid;
int8_t iCoff; int8_t iCoff;
...@@ -436,33 +405,34 @@ struct ath9k_hw_cal_data { ...@@ -436,33 +405,34 @@ struct ath9k_hw_cal_data {
struct ath9k_channel { struct ath9k_channel {
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
u16 channel; u16 channel;
u32 channelFlags; u16 channelFlags;
u32 chanmode;
s16 noisefloor; s16 noisefloor;
}; };
#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ #define CHANNEL_5GHZ BIT(0)
(((_c)->channelFlags & CHANNEL_G_HT20) == CHANNEL_G_HT20) || \ #define CHANNEL_HALF BIT(1)
(((_c)->channelFlags & CHANNEL_G_HT40PLUS) == CHANNEL_G_HT40PLUS) || \ #define CHANNEL_QUARTER BIT(2)
(((_c)->channelFlags & CHANNEL_G_HT40MINUS) == CHANNEL_G_HT40MINUS)) #define CHANNEL_HT BIT(3)
#define IS_CHAN_5GHZ(_c) (((_c)->channelFlags & CHANNEL_5GHZ) != 0) #define CHANNEL_HT40PLUS BIT(4)
#define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0) #define CHANNEL_HT40MINUS BIT(5)
#define IS_CHAN_HALF_RATE(_c) (((_c)->channelFlags & CHANNEL_HALF) != 0)
#define IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0) #define IS_CHAN_5GHZ(_c) (!!((_c)->channelFlags & CHANNEL_5GHZ))
#define IS_CHAN_2GHZ(_c) (!IS_CHAN_5GHZ(_c))
#define IS_CHAN_HALF_RATE(_c) (!!((_c)->channelFlags & CHANNEL_HALF))
#define IS_CHAN_QUARTER_RATE(_c) (!!((_c)->channelFlags & CHANNEL_QUARTER))
#define IS_CHAN_A_FAST_CLOCK(_ah, _c) \ #define IS_CHAN_A_FAST_CLOCK(_ah, _c) \
((((_c)->channelFlags & CHANNEL_5GHZ) != 0) && \ (IS_CHAN_5GHZ(_c) && ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK))
((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK))
#define IS_CHAN_HT(_c) ((_c)->channelFlags & CHANNEL_HT)
/* These macros check chanmode and not channelFlags */
#define IS_CHAN_HT20(_c) (((_c)->chanmode == CHANNEL_A_HT20) || \ #define IS_CHAN_HT20(_c) (IS_CHAN_HT(_c) && !IS_CHAN_HT40(_c))
((_c)->chanmode == CHANNEL_G_HT20))
#define IS_CHAN_HT40(_c) (((_c)->chanmode == CHANNEL_A_HT40PLUS) || \ #define IS_CHAN_HT40(_c) \
((_c)->chanmode == CHANNEL_A_HT40MINUS) || \ (!!((_c)->channelFlags & (CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)))
((_c)->chanmode == CHANNEL_G_HT40PLUS) || \
((_c)->chanmode == CHANNEL_G_HT40MINUS)) #define IS_CHAN_HT40PLUS(_c) ((_c)->channelFlags & CHANNEL_HT40PLUS)
#define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c))) #define IS_CHAN_HT40MINUS(_c) ((_c)->channelFlags & CHANNEL_HT40MINUS)
#define IS_CHAN_HT40PLUS(_c) ((_c)->chanmode & CHANNEL_HT40PLUS)
#define IS_CHAN_HT40MINUS(_c) ((_c)->chanmode & CHANNEL_HT40MINUS)
enum ath9k_power_mode { enum ath9k_power_mode {
ATH9K_PM_AWAKE = 0, ATH9K_PM_AWAKE = 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册