ath9k: suggested improvements and bugfixes
cover ath9k: suggested improvements and bugfixes
This patchset contains suggested improvements and bugfixes to ath9k that I came across while attempting to implement QCN550x support. The patches should be independent.
Wenli Looi (6):
ath9k: make ATH_SREV macros more consistent
ath9k: split set11nRateFlags and set11nChainSel
ath9k: use AR9300_MAX_CHAINS when appropriate
ath9k: fix ar9003_get_eepmisc
ath9k: refactor ar9003_hw_spur_mitigate_ofdm
ath9k: add functions to get paprd rate mask
drivers/net/wireless/ath/ath9k/ar9002_mac.c | 9 +++-- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 2 +- .../net/wireless/ath/ath9k/ar9003_eeprom.c | 39 ++++++++++--------- .../net/wireless/ath/ath9k/ar9003_eeprom.h | 2 + drivers/net/wireless/ath/ath9k/ar9003_mac.c | 9 +++-- drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 10 ++--- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 25 ++++-------- drivers/net/wireless/ath/ath9k/mac.h | 6 ++- drivers/net/wireless/ath/ath9k/reg.h | 10 ++--- 9 files changed, 56 insertions(+), 56 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/6 ath9k: make ATH_SREV macros more consistent
This makes the macros more consistent and removes hidden dependencies on ah for macros that take _ah as a parameter.
This change does not appear to affect the final binary.
--- drivers/net/wireless/ath/ath9k/reg.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/reg.h +5 -5
@@ -834,8 +834,8 @@ ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_22)) || \ ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9100)) -#define AR_SREV_9100 (ah) \ - ((ah->hw_version.macVersion) == AR_SREV_VERSION_9100) +#define AR_SREV_9100 (_ah) \ + (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9100))#define AR_SREV_9100_OR_LATER (_ah) \ (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9100))
@@ -891,7 +891,7 @@#define AR_SREV_9300_20_OR_LATER (_ah) \ ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9300)#define AR_SREV_9300_22 (_ah) \ - (AR_SREV_9300(ah) && \ + (AR_SREV_9300((_ah)) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9300_22))#define AR_SREV_9330 (_ah) \
@@ -994,8 +994,8 @@ (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9561))#define AR_SREV_SOC (_ah) \ - (AR_SREV_9340(_ah) || AR_SREV_9531(_ah) || AR_SREV_9550(ah) || \ - AR_SREV_9561(ah)) + (AR_SREV_9340(_ah) || AR_SREV_9531(_ah) || AR_SREV_9550(_ah) || \ + AR_SREV_9561(_ah))/* NOTE: When adding chips newer than Peacock, add chip check here */ #define AR_SREV_9580_10_OR_LATER (_ah) \
Signature · 1 line
2.25.1
Re: [PATCH 1/6] ath9k: make ATH_SREV macros more consistent
Quoted 6 lines · Wenli Looi
This makes the macros more consistent and removes hidden dependencies on ah for macros that take
_ahas a parameter.This change does not appear to affect the final binary.
Signed-off-by Wenli Looi <[email protected]>
Re: [PATCH 1/6] ath9k: make ATH_SREV macros more consistent
In reply to Wenli LooiQuoted 8 lines · Wenli Looi
This makes the macros more consistent and removes hidden dependencies on ah for macros that take
_ahas a parameter.This change does not appear to affect the final binary.
Signed-off-by Wenli Looi <[email protected]>Signed-off-by Kalle Valo <[email protected]>
6 patches applied to ath-next branch of ath.git, thanks.
26c31016fe7e ath9k: make ATH_SREV macros more consistent a96474a794e1 ath9k: split set11nRateFlags and set11nChainSel 3096a4d9eb9b ath9k: use AR9300_MAX_CHAINS when appropriate 9aaff3864b60 ath9k: fix ar9003_get_eepmisc 193025378c44 ath9k: refactor ar9003_hw_spur_mitigate_ofdm 673424ce0e77 ath9k: add functions to get paprd rate mask
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 2/6 ath9k: split set11nRateFlags and set11nChainSel
In reply to Wenli LooiThis makes the code clearer since set11nRateFlags currently sets both the rate flags and chain sel. This may also be required for QCN550x support, where the rate flags and chain sel are in separate fields.
This change does not appear to affect the final binary.
--- drivers/net/wireless/ath/ath9k/ar9002_mac.c | 9 +++++---- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 9 +++++---- drivers/net/wireless/ath/ath9k/mac.h | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_mac.c +5 -4
@@ -301,10 +301,11 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)WRITE_ONCE (ads->ds_ctl5,set11nPktDurRTSCTS (i->rates,2 ) |set11nPktDurRTSCTS (i->rates,3 )); -WRITE_ONCE (ads->ds_ctl7,set11nRateFlags (i->rates,0 ) - |set11nRateFlags (i->rates,1 ) - |set11nRateFlags (i->rates,2 ) - |set11nRateFlags (i->rates,3 ) +WRITE_ONCE (ads->ds_ctl7, +set11nRateFlags (i->rates,0 ) |set11nChainSel (i->rates,0 ) + |set11nRateFlags (i->rates,1 ) |set11nChainSel (i->rates,1 ) + |set11nRateFlags (i->rates,2 ) |set11nChainSel (i->rates,2 ) + |set11nRateFlags (i->rates,3 ) |set11nChainSel (i->rates,3 ) |SM (i->rtscts_rate, AR_RTSCTSRate));WRITE_ONCE (ads->ds_ctl9,SM (i->txpower[1 ], AR_XmitPower1));
drivers/net/wireless/ath/ath9k/ar9003_mac.c +5 -4
@@ -144,10 +144,11 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)WRITE_ONCE (ads->ctl16,set11nPktDurRTSCTS (i->rates,2 ) |set11nPktDurRTSCTS (i->rates,3 )); -WRITE_ONCE (ads->ctl18,set11nRateFlags (i->rates,0 ) - |set11nRateFlags (i->rates,1 ) - |set11nRateFlags (i->rates,2 ) - |set11nRateFlags (i->rates,3 ) +WRITE_ONCE (ads->ctl18, +set11nRateFlags (i->rates,0 ) |set11nChainSel (i->rates,0 ) + |set11nRateFlags (i->rates,1 ) |set11nChainSel (i->rates,1 ) + |set11nRateFlags (i->rates,2 ) |set11nChainSel (i->rates,2 ) + |set11nRateFlags (i->rates,3 ) |set11nChainSel (i->rates,3 ) |SM (i->rtscts_rate, AR_RTSCTSRate));WRITE_ONCE (ads->ctl19, AR_Not_Sounding);
drivers/net/wireless/ath/ath9k/mac.h +4 -2
@@ -35,8 +35,10 @@ |((_series)[_index].RateFlags & ATH9K_RATESERIES_HALFGI ? \ AR_GI##_index : 0) \ |((_series)[_index].RateFlags & ATH9K_RATESERIES_STBC ? \ - AR_STBC##_index : 0) \ - |SM((_series)[_index].ChSel, AR_ChainSel##_index)) + AR_STBC##_index : 0)) + +#define set11nChainSel (_series, _index) \ + (SM((_series)[_index].ChSel, AR_ChainSel##_index))#define CCK_SIFS_TIME 10#define CCK_PREAMBLE_BITS 144
Signature · 1 line
2.25.1
Re: [PATCH 2/6] ath9k: split set11nRateFlags and set11nChainSel
Quoted 8 lines · Wenli Looi
This makes the code clearer since set11nRateFlags currently sets both the rate flags and chain sel. This may also be required for QCN550x support, where the rate flags and chain sel are in separate fields.
This change does not appear to affect the final binary.
Signed-off-by Wenli Looi <[email protected]>
PATCH 3/6 ath9k: use AR9300_MAX_CHAINS when appropriate
In reply to Wenli LooiReplace other constants with AR9300_MAX_CHAINS when appropriate.
This change does not appear to affect the final binary.
--- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 2 +- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_calib.c +1 -1
@@ -177,7 +177,7 @@ static void ar9003_hw_iqcal_collect(struct ath_hw *ah)int i;/* Accumulate IQ cal measures for active chains */ -for (i =0 ; i <AR5416_MAX_CHAINS ; i++) { +for (i =0 ; i <AR9300_MAX_CHAINS ; i++) {if (ah->txchainmask &BIT (i)) { ah->totalPowerMeasI[i] +=REG_READ (ah,AR_PHY_CAL_MEAS_0 (i));
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +2 -2
@@ -3911,7 +3911,7 @@ static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan) }/* Test value. if 0 then attenuation is unused. Don't load anything. */ -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <AR9300_MAX_CHAINS ; i++) {if (ah->txchainmask &BIT (i)) { value =ar9003_hw_atten_chain_get (ah, i, chan); REG_RMW_FIELD(ah, ext_atten_reg[i],
@@ -5126,7 +5126,7 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency) frequency, correction[0], correction[1], correction[2]);/* Store calibrated noise floor values */ -for (ichain =0 ; ichain <AR5416_MAX_CHAINS ; ichain++) +for (ichain =0 ; ichain <AR9300_MAX_CHAINS ; ichain++)if (mode) { ah->nf_5g.cal[ichain] = nf_cal[ichain]; ah->nf_5g.pwr[ichain] = nf_pwr[ichain];
Signature · 1 line
2.25.1
Re: [PATCH 3/6] ath9k: use AR9300_MAX_CHAINS when appropriate
Quoted 5 lines · Wenli Looi
Replace other constants with
AR9300_MAX_CHAINSwhen appropriate.This change does not appear to affect the final binary.
Signed-off-by Wenli Looi <[email protected]>
PATCH 4/6 ath9k: fix ar9003_get_eepmisc
In reply to Wenli LooiThe current implementation is reading the wrong eeprom type.
--- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +1 -1
@@ -5615,7 +5615,7 @@ unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,static u8 ar9003_get_eepmisc (struct ath_hw *ah) { -return ah->eeprom.map4k.baseEepHeader.eepMisc; +return ah->eeprom.ar9300_eep.baseEepHeader.opCapFlags.eepMisc; }const struct eeprom_ops eep_ar9300_ops = {
Signature · 1 line
2.25.1
Toke Høiland-Jørgensen
maintainerRe: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
Quoted 13 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>--- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +0
-0
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah, · line 5619
Quoted 6 lines
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +1
-1@@ -5615,7 +5615,7 @@ unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,static u8 ar9003_get_eepmisc (struct ath_hw *ah) { -return ah->eeprom.map4k.baseEepHeader.eepMisc; +return ah->eeprom.ar9300_eep.baseEepHeader.opCapFlags.eepMisc; }
Looks like this is only ever used to check for the AR5416_EEPMISC_BIG_ENDIAN flag - so is that never used by AR9300, or how was this ever working given that it's a completely different offset?
-Toke
Re: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
Quoted 27 lines · Toke Høiland-Jørgensen
Quoted 13 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>--- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +0
-0drivers/net/wireless/ath/ath9k/ar9003_eeprom.c unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah, · line 5619
Quoted 6 lines
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +1
-1@@ -5615,7 +5615,7 @@ unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,static u8 ar9003_get_eepmisc (struct ath_hw *ah) { -return ah->eeprom.map4k.baseEepHeader.eepMisc; +return ah->eeprom.ar9300_eep.baseEepHeader.opCapFlags.eepMisc; }Looks like this is only ever used to check for the
AR5416_EEPMISC_BIG_ENDIANflag - so is that never used by AR9300, or how was this ever working given that it's a completely different offset?
Quoted 1 line
-Toke
I think it's never used by AR9300, because get_eepmisc is only used in ath9k_hw_nvram_swap_data, which is only used in the eeprom types other than AR9300.
Toke Høiland-Jørgensen
maintainerRe: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
Quoted 28 lines · Wenli Looi
Quoted 27 lines · Toke Høiland-Jørgensen
Quoted 13 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>--- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +0
-0drivers/net/wireless/ath/ath9k/ar9003_eeprom.c unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah, · line 5619
Quoted 6 lines
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +1
-1@@ -5615,7 +5615,7 @@ unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,static u8 ar9003_get_eepmisc (struct ath_hw *ah) { -return ah->eeprom.map4k.baseEepHeader.eepMisc; +return ah->eeprom.ar9300_eep.baseEepHeader.opCapFlags.eepMisc; }Looks like this is only ever used to check for the
AR5416_EEPMISC_BIG_ENDIANflag - so is that never used by AR9300, or how was this ever working given that it's a completely different offset?
Quoted 5 lines
Quoted 1 line
-Toke
I think it's never used by AR9300, because
get_eepmiscis only used inath9k_hw_nvram_swap_data, which is only used in the eeprom types other than AR9300.
Alright, fair enough; let's merge this as a fix anyway...
-Toke
Re: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
In reply to Wenli LooiQuoted 4 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>
Re: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
In reply to Wenli LooiQuoted 4 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>
The Fixes tag is wrong, I fixed it in the pending branch.
In commit
265e303cc469 ("ath9k: fix ar9003_get_eepmisc")
Fixes tag
has these problem(s):
- SHA1 should be at least 12 digits long
Can be fixed by setting core.abbrev to 12 (or more) or (for git v2.11 or later) just making sure it is not set (or set to "auto").
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Toke Høiland-Jørgensen
maintainerRe: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
Quoted 8 lines · Kalle Valo
Quoted 4 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>The Fixes tag is wrong, I fixed it in the pending branch.
Ah, oops, my bad for not catching that; thanks for the fixup! :)
-Toke
Re: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
Quoted 6 lines · Toke Høiland-Jørgensen
Quoted 4 lines · Kalle Valo
Quoted 2 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes: d8ec2e ("ath9k: Add an
eeprom_opscallback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>The Fixes tag is wrong, I fixed it in the pending branch.
Ah, oops, my bad for not catching that; thanks for the fixup! :)
No worries, I'm using Stephen's script which check that :)
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Toke Høiland-Jørgensen
maintainerRe: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
Quoted 12 lines · Kalle Valo
Quoted 10 lines · Toke Høiland-Jørgensen
Quoted 8 lines · Kalle Valo
Quoted 5 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes: d8ec2e ("ath9k: Add an
eeprom_opscallback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
The Fixes tag is wrong, I fixed it in the pending branch.
Ah, oops, my bad for not catching that; thanks for the fixup! :)
No worries, I'm using Stephen's script which check that :)
Ah yes, I thought I recognised the format of the notice ;)
-Toke
Re: [PATCH 4/6] ath9k: fix ar9003_get_eepmisc
In reply to Kalle ValoQuoted 10 lines · Kalle Valo
Quoted 4 lines · Wenli Looi
The current implementation is reading the wrong eeprom type.
Fixes d8ec2e ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")Signed-off-by Wenli Looi <[email protected]>The Fixes tag is wrong, I fixed it in the pending branch.
Thanks for the fix!
PATCH 5/6 ath9k: refactor ar9003_hw_spur_mitigate_ofdm
In reply to Wenli LooiSimilar to ar9003_hw_spur_mitigate_mrc_cck, simplify the code by using ar9003_get_spur_chan_ptr. This may also be required for QCN550x support, to provide an abstraction over the underlying EEPROM format.
--- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 25 +++++++-------------- 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_phy.c +8 -17
@@ -523,21 +523,10 @@ static void ar9003_hw_spur_mitigate_ofdm(struct ath_hw *ah,int synth_freq;int range =10 ;int freq_offset =0 ; -int mode; -u8 * spurChansPtr; +u8 *spur_fbin_ptr =ar9003_get_spur_chan_ptr (ah,IS_CHAN_2GHZ (chan));unsigned int i; -struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; - -if (IS_CHAN_5GHZ (chan)) { - spurChansPtr = &(eep->modalHeader5G.spurChans[0 ]); - mode =0 ; - } -else { - spurChansPtr = &(eep->modalHeader2G.spurChans[0 ]); - mode =1 ; - } -if (spurChansPtr[0 ] ==0 ) +if (spur_fbin_ptr[0 ] ==0 )return ;/* No spur in the mode */ if (IS_CHAN_HT40 (chan)) {
@@ -554,16 +543,18 @@ static void ar9003_hw_spur_mitigate_ofdm(struct ath_hw *ah,ar9003_hw_spur_ofdm_clear (ah); -for (i =0 ; i <AR_EEPROM_MODAL_SPURS && spurChansPtr[i]; i++) { - freq_offset =ath9k_hw_fbin2freq (spurChansPtr[i], mode); +for (i =0 ; i <AR_EEPROM_MODAL_SPURS && spur_fbin_ptr[i]; i++) { + freq_offset =ath9k_hw_fbin2freq (spur_fbin_ptr[i], +IS_CHAN_2GHZ (chan)); freq_offset -= synth_freq;if (abs (freq_offset) < range) {ar9003_hw_spur_ofdm_work (ah, chan, freq_offset, range, synth_freq);if (AR_SREV_9565 (ah) && (i <4 )) { - freq_offset =ath9k_hw_fbin2freq (spurChansPtr[i +1 ], - mode); + freq_offset = +ath9k_hw_fbin2freq (spur_fbin_ptr[i +1 ], +IS_CHAN_2GHZ (chan)); freq_offset -= synth_freq;if (abs (freq_offset) < range)ar9003_hw_spur_ofdm_9565 (ah, freq_offset);
Signature · 1 line
2.25.1
Re: [PATCH 5/6] ath9k: refactor ar9003_hw_spur_mitigate_ofdm
Quoted 5 lines · Wenli Looi
Similar to
ar9003_hw_spur_mitigate_mrc_cck, simplify the code by usingar9003_get_spur_chan_ptr. This may also be required for QCN550x support, to provide an abstraction over the underlying EEPROM format.Signed-off-by Wenli Looi <[email protected]>
PATCH 6/6 ath9k: add functions to get paprd rate mask
In reply to Wenli LooiThis removes some code duplication with le32_to_cpu. This may also be required for QCN550x support, to provide an abstraction over the underlying EEPROM format.
--- .../net/wireless/ath/ath9k/ar9003_eeprom.c | 33 ++++++++++--------- .../net/wireless/ath/ath9k/ar9003_eeprom.h | 2 ++ drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 10 +++--- 3 files changed, 25 insertions(+), 20 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +18 -15
@@ -5449,8 +5449,6 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, {struct ath_regulatory *regulatory =ath9k_hw_regulatory (ah);struct ath_common *common =ath9k_hw_common (ah); -struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; -struct ar9300_modal_eep_header *modal_hdr;u8 targetPowerValT2[ar9300RateSize];u8 target_power_val_t2_eep[ar9300RateSize];u8 targetPowerValT2_tpc[ar9300RateSize];
@@ -5465,17 +5463,12 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,ar9003_hw_get_target_power_eeprom (ah, chan, targetPowerValT2);if (ar9003_is_paprd_enabled (ah)) { -if (IS_CHAN_2GHZ (chan)) - modal_hdr = &eep->modalHeader2G; -else - modal_hdr = &eep->modalHeader5G; - ah->paprd_ratemask = -le32_to_cpu (modal_hdr->papdRateMaskHt20) & +ar9003_get_paprd_rate_mask_ht20 (ah,IS_CHAN_2GHZ (chan)) &AR9300_PAPRD_RATE_MASK ; ah->paprd_ratemask_ht40 = -le32_to_cpu (modal_hdr->papdRateMaskHt40) & +ar9003_get_paprd_rate_mask_ht40 (ah,IS_CHAN_2GHZ (chan)) &AR9300_PAPRD_RATE_MASK ; paprd_scale_factor =ar9003_get_paprd_scale_factor (ah, chan);
@@ -5592,23 +5585,33 @@ u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is2ghz)return ar9003_modal_header (ah, is2ghz)->spurChans; } +u32 ar9003_get_paprd_rate_mask_ht20 (struct ath_hw *ah,bool is2ghz) +{ +return le32_to_cpu (ar9003_modal_header (ah, is2ghz)->papdRateMaskHt20); +} + +u32 ar9003_get_paprd_rate_mask_ht40 (struct ath_hw *ah,bool is2ghz) +{ +return le32_to_cpu (ar9003_modal_header (ah, is2ghz)->papdRateMaskHt40); +} +unsigned int ar9003_get_paprd_scale_factor (struct ath_hw *ah,struct ath9k_channel *chan) { -struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; +bool is2ghz =IS_CHAN_2GHZ (chan); -if (IS_CHAN_2GHZ (chan)) -return MS (le32_to_cpu (eep->modalHeader2G.papdRateMaskHt20), +if (is2ghz) +return MS (ar9003_get_paprd_rate_mask_ht20 (ah, is2ghz),AR9300_PAPRD_SCALE_1 );else {if (chan->channel >=5700 ) -return MS (le32_to_cpu (eep->modalHeader5G.papdRateMaskHt20), +return MS (ar9003_get_paprd_rate_mask_ht20 (ah, is2ghz),AR9300_PAPRD_SCALE_1 );else if (chan->channel >=5400 ) -return MS (le32_to_cpu (eep->modalHeader5G.papdRateMaskHt40), +return MS (ar9003_get_paprd_rate_mask_ht40 (ah, is2ghz),AR9300_PAPRD_SCALE_2 );else -return MS (le32_to_cpu (eep->modalHeader5G.papdRateMaskHt40), +return MS (ar9003_get_paprd_rate_mask_ht40 (ah, is2ghz),AR9300_PAPRD_SCALE_1 ); } }
drivers/net/wireless/ath/ath9k/ar9003_eeprom.h +2 -0
@@ -363,6 +363,8 @@ u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz);u8 *ar9003_get_spur_chan_ptr (struct ath_hw *ah,bool is_2ghz); +u32 ar9003_get_paprd_rate_mask_ht20 (struct ath_hw *ah,bool is2ghz); +u32 ar9003_get_paprd_rate_mask_ht40 (struct ath_hw *ah,bool is2ghz);unsigned int ar9003_get_paprd_scale_factor (struct ath_hw *ah,struct ath9k_channel *chan);
drivers/net/wireless/ath/ath9k/ar9003_paprd.c +5 -5
@@ -21,7 +21,7 @@void ar9003_paprd_enable (struct ath_hw *ah,bool val) {struct ath9k_channel *chan = ah->curchan; -struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; +bool is2ghz =IS_CHAN_2GHZ (chan);/* * 3 bits for modalHeader5G.papdRateMaskHt20
@@ -36,17 +36,17 @@ void ar9003_paprd_enable(struct ath_hw *ah, bool val)* -- disable PAPRD for lower band 5GHz */ -if (IS_CHAN_5GHZ (chan)) { +if (!is2ghz) {if (chan->channel >=UPPER_5G_SUB_BAND_START ) { -if (le32_to_cpu (eep->modalHeader5G.papdRateMaskHt20) +if (ar9003_get_paprd_rate_mask_ht20 (ah, is2ghz) &BIT (30 )) val = false; }else if (chan->channel >=MID_5G_SUB_BAND_START ) { -if (le32_to_cpu (eep->modalHeader5G.papdRateMaskHt20) +if (ar9003_get_paprd_rate_mask_ht20 (ah, is2ghz) &BIT (29 )) val = false; }else { -if (le32_to_cpu (eep->modalHeader5G.papdRateMaskHt20) +if (ar9003_get_paprd_rate_mask_ht20 (ah, is2ghz) &BIT (28 )) val = false; }
Signature · 1 line
2.25.1
Re: [PATCH 6/6] ath9k: add functions to get paprd rate mask
Quoted 5 lines · Wenli Looi
This removes some code duplication with
le32_to_cpu. This may also be required for QCN550x support, to provide an abstraction over the underlying EEPROM format.Signed-off-by Wenli Looi <[email protected]>