ath9k_hw: embed the ath_ops callbacks in the ath_hw struct
PATCH 1/10 ath9k_hw: embed the ath_ops callbacks in the ath_hw struct
With this change, loading the address to a register read/write function costs only one pointer dereference instead of two. On MIPS this reduces ath9k_hw binary size from 326k down to 321k.
--- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 15 ++++++--------- drivers/net/wireless/ath/ath9k/hw.h | 16 +++++++++------- drivers/net/wireless/ath/ath9k/init.c | 9 +++------ 3 files changed, 18 insertions(+), 22 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_init.c +6 -9
@@ -430,14 +430,6 @@ static void ath9k_regwrite_flush(void *hw_priv)mutex_unlock (&priv->wmi->multi_write_mutex); } -static const struct ath_ops ath9k_common_ops = { - .read = ath9k_regread, - .multi_read = ath9k_multi_regread, - .write = ath9k_regwrite, - .enable_write_buffer = ath9k_enable_regwrite_buffer, - .write_flush = ath9k_regwrite_flush, -}; -static void ath_usb_read_cachesize (struct ath_common *common,int *csz) { *csz =L1_CACHE_BYTES >>2 ;
@@ -658,10 +650,15 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv, ah->hw_version.subsysid =0 ;/* FIXME */ ah->hw_version.usbdev = drv_info; ah->ah_flags |=AH_USE_EEPROM ; + ah->reg_ops.read = ath9k_regread; + ah->reg_ops.multi_read = ath9k_multi_regread; + ah->reg_ops.write = ath9k_regwrite; + ah->reg_ops.enable_write_buffer = ath9k_enable_regwrite_buffer; + ah->reg_ops.write_flush = ath9k_regwrite_flush; priv->ah = ah; common =ath9k_hw_common (ah); - common->ops = &ath9k_common_ops; + common->ops = &ah->reg_ops; common->bus_ops = &ath9k_usb_bus_ops; common->ah = ah; common->hw = priv->hw;
drivers/net/wireless/ath/ath9k/hw.h +9 -7
@@ -65,24 +65,24 @@/* Register read/write primitives */ #define REG_WRITE (_ah, _reg, _val) \ - ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) + (_ah)->reg_ops.write((_ah), (_val), (_reg))#define REG_READ (_ah, _reg) \ - ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) + (_ah)->reg_ops.read((_ah), (_reg))#define REG_READ_MULTI (_ah, _addr, _val, _cnt) \ - ath9k_hw_common(_ah)->ops->multi_read((_ah), (_addr), (_val), (_cnt)) + (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt))#define ENABLE_REGWRITE_BUFFER (_ah) \ do { \ - if (ath9k_hw_common(_ah)->ops->enable_write_buffer) \ - ath9k_hw_common(_ah)->ops->enable_write_buffer((_ah)); \ + if ((_ah)->reg_ops.enable_write_buffer) \ + (_ah)->reg_ops.enable_write_buffer((_ah)); \ } while (0)#define REGWRITE_BUFFER_FLUSH (_ah) \ do { \ - if (ath9k_hw_common(_ah)->ops->write_flush) \ - ath9k_hw_common(_ah)->ops->write_flush((_ah)); \ + if ((_ah)->reg_ops.write_flush) \ + (_ah)->reg_ops.write_flush((_ah)); \ } while (0)#define SM (_v, _f) (((_v) << _f##_S) & _f)
@@ -657,6 +657,8 @@ struct ath_nf_limits {#define AH_UNPLUGGED 0x2/* The card has been physically removed. */ struct ath_hw { +struct ath_ops reg_ops; +struct ieee80211_hw *hw;struct ath_common common;struct ath9k_hw_version hw_version;
drivers/net/wireless/ath/ath9k/init.c +3 -6
@@ -196,11 +196,6 @@ static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)return val; } -static const struct ath_ops ath9k_common_ops = { - .read = ath9k_ioread32, - .write = ath9k_iowrite32, -}; -/**************************/ /* Initialization */ /**************************/
@@ -551,6 +546,8 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, ah->hw = sc->hw; ah->hw_version.devid = devid; ah->hw_version.subsysid = subsysid; + ah->reg_ops.read = ath9k_ioread32; + ah->reg_ops.write = ath9k_iowrite32; sc->sc_ah = ah;if (!pdata) {
@@ -563,7 +560,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, } common =ath9k_hw_common (ah); - common->ops = &ath9k_common_ops; + common->ops = &ah->reg_ops; common->bus_ops = bus_ops; common->ah = ah; common->hw = sc->hw;
Signature · 1 line
1.7.3.2
PATCH 2/10 ath9k_hw: add a new register op for read-mask-write
Reduces the number of calls to register ops. On MIPS this reduces the ath9k_hw binary size from 321k down to 310k
--- drivers/net/wireless/ath/ath.h | 1 + drivers/net/wireless/ath/ath9k/htc_drv_init.c | 12 ++++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 12 ++++++------ drivers/net/wireless/ath/ath9k/init.c | 23 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath.h +1 -0
@@ -119,6 +119,7 @@ struct ath_ops {void (*write)(void *,u32 val,u32 reg_offset);void (*enable_write_buffer)(void *);void (*write_flush) (void *); +u32 (*rmw)(void *,u32 reg_offset,u32 set,u32 clr); };struct ath_common ;
drivers/net/wireless/ath/ath9k/htc_drv_init.c +12 -0
@@ -430,6 +430,17 @@ static void ath9k_regwrite_flush(void *hw_priv)mutex_unlock (&priv->wmi->multi_write_mutex); } +static u32 ath9k_reg_rmw (void *hw_priv,u32 reg_offset,u32 set,u32 clr) +{ +u32 val; + + val =ath9k_regread (hw_priv, reg_offset); + val &= ~clr; + val |= set; +ath9k_regwrite (hw_priv, val, reg_offset); +return val; +} +static void ath_usb_read_cachesize (struct ath_common *common,int *csz) { *csz =L1_CACHE_BYTES >>2 ;
@@ -655,6 +666,7 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv, ah->reg_ops.write = ath9k_regwrite; ah->reg_ops.enable_write_buffer = ath9k_enable_regwrite_buffer; ah->reg_ops.write_flush = ath9k_regwrite_flush; + ah->reg_ops.rmw = ath9k_reg_rmw; priv->ah = ah; common =ath9k_hw_common (ah);
drivers/net/wireless/ath/ath9k/hw.h +6 -6
@@ -73,6 +73,9 @@#define REG_READ_MULTI (_ah, _addr, _val, _cnt) \ (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt)) +#define REG_RMW (_ah, _reg, _set, _clr) \ + (_ah)->reg_ops.rmw((_ah), (_reg), (_set), (_clr)) +#define ENABLE_REGWRITE_BUFFER (_ah) \ do { \ if ((_ah)->reg_ops.enable_write_buffer) \
@@ -87,17 +90,14 @@#define SM (_v, _f) (((_v) << _f##_S) & _f)#define MS (_v, _f) (((_v) & _f) >> _f##_S) -#define REG_RMW (_a, _r, _set, _clr) \ - REG_WRITE(_a, _r, (REG_READ(_a, _r) & ~(_clr)) | (_set))#define REG_RMW_FIELD (_a, _r, _f, _v) \ - REG_WRITE(_a, _r, \ - (REG_READ(_a, _r) & ~_f) | (((_v) << _f##_S) & _f)) + REG_RMW(_a, _r, (((_v) << _f##_S) & _f), (_f))#define REG_READ_FIELD (_a, _r, _f) \ (((REG_READ(_a, _r) & _f) >> _f##_S))#define REG_SET_BIT (_a, _r, _f) \ - REG_WRITE(_a, _r, REG_READ(_a, _r) | (_f)) + REG_RMW(_a, _r, (_f), 0)#define REG_CLR_BIT (_a, _r, _f) \ - REG_WRITE(_a, _r, REG_READ(_a, _r) & ~(_f)) + REG_RMW(_a, _r, 0, (_f))#define DO_DELAY (x) do { \ if (((++(x) % 64) == 0) && \
drivers/net/wireless/ath/ath9k/init.c +23 -0
@@ -196,6 +196,28 @@ static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)return val; } +static unsigned int ath9k_reg_rmw (void *hw_priv,u32 reg_offset,u32 set,u32 clr) +{ +struct ath_hw *ah = (struct ath_hw *) hw_priv; +struct ath_common *common =ath9k_hw_common (ah); +struct ath_softc *sc = (struct ath_softc *) common->priv; +unsigned long uninitialized_var (flags ); +u32 val; + +if (ah->config.serialize_regmode ==SER_REG_MODE_ON ) +spin_lock_irqsave (&sc->sc_serial_rw, flags); + + val =ioread32 (sc->mem + reg_offset); + val &= ~clr; + val |= set; +iowrite32 (val, sc->mem + reg_offset); + +if (ah->config.serialize_regmode ==SER_REG_MODE_ON ) +spin_unlock_irqrestore (&sc->sc_serial_rw, flags); + +return val; +} +/**************************/ /* Initialization */ /**************************/
@@ -548,6 +570,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, ah->hw_version.subsysid = subsysid; ah->reg_ops.read = ath9k_ioread32; ah->reg_ops.write = ath9k_iowrite32; + ah->reg_ops.rmw = ath9k_reg_rmw; sc->sc_ah = ah;if (!pdata) {
Signature · 1 line
1.7.3.2
PATCH 3/10 ath9k_hw: replace REG_READ+REG_WRITE with REG_RMW
It's easier to read and it slightly decreases code size
--- drivers/net/wireless/ath/ath9k/hw.c | 66 ++++++++++++------------------ drivers/net/wireless/ath/ath9k/mac.c | 73 ++++++++++++++-------------------- 2 files changed, 56 insertions(+), 83 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +26 -40
@@ -675,14 +675,14 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)unsigned long ar9003_get_pll_sqsum_dvc (struct ath_hw *ah) { -REG_WRITE (ah,PLL3 , (REG_READ (ah,PLL3 ) & ~(PLL3_DO_MEAS_MASK ))); -udelay (100 ); -REG_WRITE (ah,PLL3 , (REG_READ (ah,PLL3 ) |PLL3_DO_MEAS_MASK )); +REG_CLR_BIT (ah,PLL3 ,PLL3_DO_MEAS_MASK ); +udelay (100 ); +REG_SET_BIT (ah,PLL3 ,PLL3_DO_MEAS_MASK ); -while ((REG_READ (ah,PLL4 ) &PLL4_MEAS_DONE ) ==0 ) -udelay (100 ); +while ((REG_READ (ah,PLL4 ) &PLL4_MEAS_DONE ) ==0 ) +udelay (100 ); -return (REG_READ (ah,PLL3 ) &SQSUM_DVC_MASK ) >>3 ; +return (REG_READ (ah,PLL3 ) &SQSUM_DVC_MASK ) >>3 ; }EXPORT_SYMBOL (ar9003_get_pll_sqsum_dvc);
@@ -832,8 +832,7 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah) ah->misc_mode);if (ah->misc_mode !=0 ) -REG_WRITE (ah,AR_PCU_MISC , -REG_READ (ah,AR_PCU_MISC ) | ah->misc_mode); +REG_SET_BIT (ah,AR_PCU_MISC , ah->misc_mode);if (conf->channel && conf->channel->band ==IEEE80211_BAND_5GHZ ) sifstime =16 ;
@@ -901,23 +900,19 @@ u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan)static inline void ath9k_hw_set_dma (struct ath_hw *ah) {struct ath_common *common =ath9k_hw_common (ah); -u32 regval;ENABLE_REGWRITE_BUFFER (ah);/* * set AHB_MODE not to do cacheline prefetches */ -if (!AR_SREV_9300_20_OR_LATER (ah)) { - regval =REG_READ (ah,AR_AHB_MODE ); -REG_WRITE (ah,AR_AHB_MODE , regval |AR_AHB_PREFETCH_RD_EN ); - } +if (!AR_SREV_9300_20_OR_LATER (ah)) +REG_SET_BIT (ah,AR_AHB_MODE ,AR_AHB_PREFETCH_RD_EN );/* * let mac dma reads be in 128 byte chunks */ - regval =REG_READ (ah,AR_TXCFG ) & ~AR_TXCFG_DMASZ_MASK ; -REG_WRITE (ah,AR_TXCFG , regval |AR_TXCFG_DMASZ_128B ); +REG_RMW (ah,AR_TXCFG ,AR_TXCFG_DMASZ_128B ,AR_TXCFG_DMASZ_MASK );REGWRITE_BUFFER_FLUSH (ah);
@@ -934,8 +929,7 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah)/* * let mac dma writes be in 128 byte chunks */ - regval =REG_READ (ah,AR_RXCFG ) & ~AR_RXCFG_DMASZ_MASK ; -REG_WRITE (ah,AR_RXCFG , regval |AR_RXCFG_DMASZ_128B ); +REG_RMW (ah,AR_RXCFG ,AR_RXCFG_DMASZ_128B ,AR_RXCFG_DMASZ_MASK );/* * Setup receive FIFO threshold to hold off TX activities
@@ -974,30 +968,27 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah)static void ath9k_hw_set_operating_mode (struct ath_hw *ah,int opmode) { -u32 val; +u32 mask =AR_STA_ID1_STA_AP |AR_STA_ID1_ADHOC ; +u32 set =AR_STA_ID1_KSRCH_MODE ; - val =REG_READ (ah,AR_STA_ID1 ); - val &= ~(AR_STA_ID1_STA_AP |AR_STA_ID1_ADHOC );switch (opmode) { -case NL80211_IFTYPE_AP : -REG_WRITE (ah,AR_STA_ID1 , val |AR_STA_ID1_STA_AP - |AR_STA_ID1_KSRCH_MODE ); -REG_CLR_BIT (ah,AR_CFG ,AR_CFG_AP_ADHOC_INDICATION ); -break ;case NL80211_IFTYPE_ADHOC :case NL80211_IFTYPE_MESH_POINT : -REG_WRITE (ah,AR_STA_ID1 , val |AR_STA_ID1_ADHOC - |AR_STA_ID1_KSRCH_MODE ); + set |=AR_STA_ID1_ADHOC ;REG_SET_BIT (ah,AR_CFG ,AR_CFG_AP_ADHOC_INDICATION );break ; +case NL80211_IFTYPE_AP : + set |=AR_STA_ID1_STA_AP ; +/* fall through */ case NL80211_IFTYPE_STATION : -REG_WRITE (ah,AR_STA_ID1 , val |AR_STA_ID1_KSRCH_MODE ); +REG_CLR_BIT (ah,AR_CFG ,AR_CFG_AP_ADHOC_INDICATION );break ;default : -if (ah->is_monitoring) -REG_WRITE (ah,AR_STA_ID1 , val |AR_STA_ID1_KSRCH_MODE ); +if (!ah->is_monitoring) + set =0 ;break ; } +REG_RMW (ah,AR_STA_ID1 , set, mask); } void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
@@ -1023,10 +1014,8 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type)u32 tmpReg;if (AR_SREV_9100 (ah)) { -u32 val =REG_READ (ah,AR_RTC_DERIVED_CLK ); - val &= ~AR_RTC_DERIVED_CLK_PERIOD ; - val |=SM (1 ,AR_RTC_DERIVED_CLK_PERIOD ); -REG_WRITE (ah,AR_RTC_DERIVED_CLK , val); +REG_RMW_FIELD (ah,AR_RTC_DERIVED_CLK , +AR_RTC_DERIVED_CLK_PERIOD ,1 ); (void )REG_READ (ah,AR_RTC_DERIVED_CLK ); }
@@ -1451,8 +1440,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,ar9002_hw_enable_wep_aggregation (ah); } -REG_WRITE (ah,AR_STA_ID1 , -REG_READ (ah,AR_STA_ID1 ) |AR_STA_ID1_PRESERVE_SEQNUM ); +REG_SET_BIT (ah,AR_STA_ID1 ,AR_STA_ID1_PRESERVE_SEQNUM );ath9k_hw_set_dma (ah);
@@ -2204,11 +2192,9 @@ void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits)REG_WRITE (ah,AR_PHY_ERR , phybits);if (phybits) -REG_WRITE (ah,AR_RXCFG , -REG_READ (ah,AR_RXCFG ) |AR_RXCFG_ZLFDMA ); +REG_SET_BIT (ah,AR_RXCFG ,AR_RXCFG_ZLFDMA );else -REG_WRITE (ah,AR_RXCFG , -REG_READ (ah,AR_RXCFG ) & ~AR_RXCFG_ZLFDMA ); +REG_CLR_BIT (ah,AR_RXCFG ,AR_RXCFG_ZLFDMA );REGWRITE_BUFFER_FLUSH (ah); }
drivers/net/wireless/ath/ath9k/mac.c +30 -43
121 lines not on this page · raw message
Signature · 1 line
1.7.3.2
PATCH 4/10 ath9k_hw: turn a few big macros into functions
RF_BANK_SETUP, REG_WRITE_RF_ARRAY and REG_WRITE_ARRAY are way too big, so they shouldn't be inlined at every single callsite, especially since they can easily be turned into real functions.
--- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 38 +++++++++++++++++++++++--- drivers/net/wireless/ath/ath9k/hw.c | 14 ++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 14 +++------- drivers/net/wireless/ath/ath9k/phy.h | 16 ----------- 4 files changed, 51 insertions(+), 31 deletions(-)
drivers/net/wireless/ath/ath9k/ar5008_phy.c +33 -5
@@ -44,6 +44,34 @@ static const int m1ThreshExt_off = 127;static const int m2ThreshExt_off =127 ; +static void ar5008_rf_bank_setup (u32 *bank,struct ar5416IniArray *array, +int col) +{ +int i; + +for (i =0 ; i < array->ia_rows; i++) + bank[i] =INI_RA (array, i, col); +} + + +#define REG_WRITE_RF_ARRAY (iniarray, regData, regWr) \ + ar5008_write_rf_array(ah, iniarray, regData, &(regWr)) + +static void ar5008_write_rf_array (struct ath_hw *ah,struct ar5416IniArray *array, +u32 *data,unsigned int *writecnt) +{ +int r; + +ENABLE_REGWRITE_BUFFER (ah); + +for (r =0 ; r < array->ia_rows; r++) { +REG_WRITE (ah,INI_RA (array, r,0 ), data[r]); +DO_DELAY (*writecnt); + } + +REGWRITE_BUFFER_FLUSH (ah); +} +/** * ar5008_hw_phy_modify_rx_buffer() - perform analog swizzling of parameters * @rfbuf:
@@ -530,16 +558,16 @@ static bool ar5008_hw_set_rf_regs(struct ath_hw *ah, eepMinorRev = ah->eep_ops->get_eeprom (ah,EEP_MINOR_REV );/* Setup Bank 0 Write */ -RF_BANK_SETUP (ah->analogBank0Data, &ah->iniBank0,1 ); +ar5008_rf_bank_setup (ah->analogBank0Data, &ah->iniBank0,1 );/* Setup Bank 1 Write */ -RF_BANK_SETUP (ah->analogBank1Data, &ah->iniBank1,1 ); +ar5008_rf_bank_setup (ah->analogBank1Data, &ah->iniBank1,1 );/* Setup Bank 2 Write */ -RF_BANK_SETUP (ah->analogBank2Data, &ah->iniBank2,1 ); +ar5008_rf_bank_setup (ah->analogBank2Data, &ah->iniBank2,1 );/* Setup Bank 6 Write */ -RF_BANK_SETUP (ah->analogBank3Data, &ah->iniBank3, +ar5008_rf_bank_setup (ah->analogBank3Data, &ah->iniBank3, modesIndex); {int i;
@@ -569,7 +597,7 @@ static bool ar5008_hw_set_rf_regs(struct ath_hw *ah, }/* Setup Bank 7 Setup */ -RF_BANK_SETUP (ah->analogBank7Data, &ah->iniBank7,1 ); +ar5008_rf_bank_setup (ah->analogBank7Data, &ah->iniBank7,1 );/* Write Analog registers */ REG_WRITE_RF_ARRAY(&ah->iniBank0, ah->analogBank0Data,
drivers/net/wireless/ath/ath9k/hw.c +14 -0
@@ -130,6 +130,20 @@ bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout) }EXPORT_SYMBOL (ath9k_hw_wait); +void ath9k_hw_write_array (struct ath_hw *ah,struct ar5416IniArray *array, +int column,unsigned int *writecnt) +{ +int r; + +ENABLE_REGWRITE_BUFFER (ah); +for (r =0 ; r < array->ia_rows; r++) { +REG_WRITE (ah,INI_RA (array, r,0 ), +INI_RA (array, r, column)); +DO_DELAY (*writecnt); + } +REGWRITE_BUFFER_FLUSH (ah); +} +u32 ath9k_hw_reverse_bits (u32 val,u32 n) {u32 retval;
drivers/net/wireless/ath/ath9k/hw.h +4 -10
@@ -106,16 +106,8 @@udelay (1 ); \ } while (0) -#define REG_WRITE_ARRAY (iniarray, column, regWr) do { \ - int r; \ - ENABLE_REGWRITE_BUFFER(ah); \ - for (r = 0; r < ((iniarray)->ia_rows); r++) { \ - REG_WRITE(ah, INI_RA((iniarray), (r), 0), \ - INI_RA((iniarray), r, (column))); \ - DO_DELAY(regWr); \ - } \ - REGWRITE_BUFFER_FLUSH(ah); \ - } while (0) +#define REG_WRITE_ARRAY (iniarray, column, regWr) \ + ath9k_hw_write_array(ah, iniarray, column, &(regWr))#define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0#define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1
@@ -913,6 +905,8 @@ void ath9k_hw_antdiv_comb_conf_set(struct ath_hw *ah,/* General Operation */ bool ath9k_hw_wait (struct ath_hw *ah,u32 reg,u32 mask,u32 val,u32 timeout); +void ath9k_hw_write_array (struct ath_hw *ah,struct ar5416IniArray *array, +int column,unsigned int *writecnt);u32 ath9k_hw_reverse_bits (u32 val,u32 n);bool ath9k_get_channel_edges (struct ath_hw *ah,u16 flags,u16 *low,u16 *high); u16 ath9k_hw_computetxtime(struct ath_hw *ah,
drivers/net/wireless/ath/ath9k/phy.h +0 -16
@@ -38,27 +38,11 @@#define AR_PHY_CLC_Q0 0x0000ffd0#define AR_PHY_CLC_Q0_S 5 -#define REG_WRITE_RF_ARRAY (iniarray, regData, regWr) do { \ - int r; \ - ENABLE_REGWRITE_BUFFER(ah); \ - for (r = 0; r < ((iniarray)->ia_rows); r++) { \ - REG_WRITE(ah, INI_RA((iniarray), r, 0), (regData)[r]); \ - DO_DELAY(regWr); \ - } \ - REGWRITE_BUFFER_FLUSH(ah); \ - } while (0) -#define ANTSWAP_AB 0x0001#define REDUCE_CHAIN_0 0x00000050#define REDUCE_CHAIN_1 0x00000051#define AR_PHY_CHIP_ID 0x9818 -#define RF_BANK_SETUP (_bank, _iniarray, _col) do { \ - int i; \ - for (i = 0; i < (_iniarray)->ia_rows; i++) \ - (_bank)[i] = INI_RA((_iniarray), i, _col);; \ - } while (0) -#define AR_PHY_TIMING11_SPUR_FREQ_SD 0x3FF00000#define AR_PHY_TIMING11_SPUR_FREQ_SD_S 20
Signature · 1 line
1.7.3.2
PATCH 5/10 ath9k_hw: remove pCap->total_queues
The EEPROM contains a field that can restrict the number of hardware queues, however this is not only useless (all the known chips contain the same number of hardware queues), but also potentially dangerous in case of a misprogrammed EEPROM (could trigger driver crashes), so let's just ignore it completely.
--- drivers/net/wireless/ath/ath9k/hw.c | 8 +------ drivers/net/wireless/ath/ath9k/hw.h | 1 - drivers/net/wireless/ath/ath9k/mac.c | 38 ++++----------------------------- 3 files changed, 6 insertions(+), 41 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +1 -7
@@ -1437,7 +1437,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,REGWRITE_BUFFER_FLUSH (ah); ah->intr_txqs =0 ; -for (i =0 ; i < ah->caps.total_queues; i++) +for (i =0 ; i <ATH9K_NUM_TX_QUEUES ; i++)ath9k_hw_resettxqueue (ah, i);ath9k_hw_init_interrupt_masks (ah, ah->opmode);
@@ -1885,12 +1885,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)else pCap->hw_caps &= ~ATH9K_HW_CAP_HT ; -if (capField &AR_EEPROM_EEPCAP_MAXQCU ) - pCap->total_queues = -MS (capField,AR_EEPROM_EEPCAP_MAXQCU ); -else - pCap->total_queues =ATH9K_NUM_TX_QUEUES ; -if (capField &AR_EEPROM_EEPCAP_KC_ENTRIES ) pCap->keycache_size =1 <<MS (capField,AR_EEPROM_EEPCAP_KC_ENTRIES );
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -191,7 +191,6 @@ enum ath9k_hw_caps {struct ath9k_hw_capabilities {u32 hw_caps;/* ATH9K_HW_CAP_* from ath9k_hw_caps */ -u16 total_queues;u16 keycache_size;u16 low_5ghz_chan, high_5ghz_chan;u16 low_2ghz_chan, high_2ghz_chan;
drivers/net/wireless/ath/ath9k/mac.c +5 -33
@@ -209,15 +209,8 @@ bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q, {u32 cw;struct ath_common *common =ath9k_hw_common (ah); -struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath9k_tx_queue_info *qi; -if (q >= pCap->total_queues) { -ath_dbg (common,ATH_DBG_QUEUE , -"Set TXQ properties, invalid queue: %u\n" , q); -return false; - } - qi = &ah->txq[q];if (qi->tqi_type ==ATH9K_TX_QUEUE_INACTIVE ) { ath_dbg(common, ATH_DBG_QUEUE,
@@ -280,15 +273,8 @@ bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q, struct ath9k_tx_queue_info *qinfo) {struct ath_common *common =ath9k_hw_common (ah); -struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath9k_tx_queue_info *qi; -if (q >= pCap->total_queues) { -ath_dbg (common,ATH_DBG_QUEUE , -"Get TXQ properties, invalid queue: %u\n" , q); -return false; - } - qi = &ah->txq[q];if (qi->tqi_type ==ATH9K_TX_QUEUE_INACTIVE ) { ath_dbg(common, ATH_DBG_QUEUE,
@@ -320,28 +306,27 @@ int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type, {struct ath_common *common =ath9k_hw_common (ah);struct ath9k_tx_queue_info *qi; -struct ath9k_hw_capabilities *pCap = &ah->caps;int q;switch (type) {case ATH9K_TX_QUEUE_BEACON : - q = pCap->total_queues -1 ; + q =ATH9K_NUM_TX_QUEUES -1 ;break ;case ATH9K_TX_QUEUE_CAB : - q = pCap->total_queues -2 ; + q =ATH9K_NUM_TX_QUEUES -2 ;break ;case ATH9K_TX_QUEUE_PSPOLL : q =1 ;break ;case ATH9K_TX_QUEUE_UAPSD : - q = pCap->total_queues -3 ; + q =ATH9K_NUM_TX_QUEUES -3 ;break ;case ATH9K_TX_QUEUE_DATA : -for (q =0 ; q < pCap->total_queues; q++) +for (q =0 ; q <ATH9K_NUM_TX_QUEUES ; q++)if (ah->txq[q].tqi_type ==ATH9K_TX_QUEUE_INACTIVE )break ; -if (q == pCap->total_queues) { +if (q ==ATH9K_NUM_TX_QUEUES ) {ath_err (common,"No available TX queue\n" );return -1 ; }
@@ -382,15 +367,9 @@ EXPORT_SYMBOL(ath9k_hw_setuptxqueue);bool ath9k_hw_releasetxqueue (struct ath_hw *ah,u32 q) { -struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath_common *common =ath9k_hw_common (ah);struct ath9k_tx_queue_info *qi; -if (q >= pCap->total_queues) { -ath_dbg (common,ATH_DBG_QUEUE , -"Release TXQ, invalid queue: %u\n" , q); -return false; - } qi = &ah->txq[q];if (qi->tqi_type ==ATH9K_TX_QUEUE_INACTIVE ) { ath_dbg(common, ATH_DBG_QUEUE,
@@ -414,18 +393,11 @@ EXPORT_SYMBOL(ath9k_hw_releasetxqueue);bool ath9k_hw_resettxqueue (struct ath_hw *ah,u32 q) { -struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath_common *common =ath9k_hw_common (ah);struct ath9k_channel *chan = ah->curchan;struct ath9k_tx_queue_info *qi;u32 cwMin, chanCwMin, value; -if (q >= pCap->total_queues) { -ath_dbg (common,ATH_DBG_QUEUE , -"Reset TXQ, invalid queue: %u\n" , q); -return false; - } - qi = &ah->txq[q];if (qi->tqi_type ==ATH9K_TX_QUEUE_INACTIVE ) { ath_dbg(common, ATH_DBG_QUEUE,
Signature · 1 line
1.7.3.2
PATCH 6/10 ath9k_hw: remove ah->config.ht_enable
It is only used in one place, and the device id check that it's based on can be moved there as well.
--- drivers/net/wireless/ath/ath9k/hw.c | 7 +------ drivers/net/wireless/ath/ath9k/hw.h | 1 - 2 files changed, 1 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +1 -6
@@ -378,11 +378,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah) ah->config.spurchans[i][1 ] =AR_NO_SPUR ; } -if (ah->hw_version.devid !=AR2427_DEVID_PCIE ) - ah->config.ht_enable =1 ; -else - ah->config.ht_enable =0 ; -/* PAPRD needs some more work to be enabled */ ah->config.paprd_disable =1 ;
@@ -1880,7 +1875,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) common->crypt_caps |=ATH_CRYPT_CAP_CIPHER_AESCCM ; -if (ah->config.ht_enable) +if (ah->hw_version.devid !=AR2427_DEVID_PCIE ) pCap->hw_caps |=ATH9K_HW_CAP_HT ;else pCap->hw_caps &= ~ATH9K_HW_CAP_HT ;
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -222,7 +222,6 @@ struct ath9k_ops_config {u8 pcie_clock_req;u32 pcie_waen;u8 analog_shiftreg; -u8 ht_enable;u8 paprd_disable;u32 ofdm_trig_low;u32 ofdm_trig_high;
Signature · 1 line
1.7.3.2
PATCH 7/10 ath9k_hw: remove pCap->reg_cap
It is not used anywhere and seems pointless
--- drivers/net/wireless/ath/ath9k/hw.c | 17 ----------------- drivers/net/wireless/ath/ath9k/hw.h | 1 - 2 files changed, 0 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +0 -17
@@ -1932,23 +1932,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)else pCap->hw_caps |=ATH9K_HW_CAP_4KB_SPLITTRANS ; -if (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 | -AR_EEPROM_EEREGCAP_EN_KK_U2 | -AR_EEPROM_EEREGCAP_EN_KK_MIDBAND ; - }else { - pCap->reg_cap = -AR_EEPROM_EEREGCAP_EN_KK_NEW_11A | -AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN ; - } - -/* Advertise midband for AR5416 with FCC midband set in eeprom */ -if (regulatory->current_rd_ext & (1 <<REG_EXT_FCC_MIDBAND ) && -AR_SREV_5416 (ah)) - pCap->reg_cap |=AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND ; -if (AR_SREV_9280_20_OR_LATER (ah) && common->btcoex_enabled) { btcoex_hw->btactive_gpio =ATH_BTACTIVE_GPIO ; btcoex_hw->wlanactive_gpio =ATH_WLANACTIVE_GPIO ;
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -200,7 +200,6 @@ struct ath9k_hw_capabilities {u8 max_txchains;u8 max_rxchains;u16 tx_triglevel_max; -u16 reg_cap;u8 num_gpio_pins;u8 rx_hp_qdepth;u8 rx_lp_qdepth;
Signature · 1 line
1.7.3.2
PATCH 8/10 ath9k_hw: remove pCap->keycache_size
Similar to the number of tx queue, the number of keycache entries depends on the chip and shouldn't be messed with based on EEPROM data. Remove this field and stick to using AR_KEYTABLE_SIZE
--- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 8 +------- drivers/net/wireless/ath/ath9k/hw.c | 6 ------ drivers/net/wireless/ath/ath9k/hw.h | 1 - drivers/net/wireless/ath/ath9k/init.c | 8 +------- 4 files changed, 2 insertions(+), 21 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_init.c +1 -7
@@ -564,13 +564,7 @@ static void ath9k_init_crypto(struct ath9k_htc_priv *priv)int i =0 ;/* Get the hardware key cache size. */ - common->keymax = priv->ah->caps.keycache_size; -if (common->keymax >ATH_KEYMAX ) { -ath_dbg (common,ATH_DBG_ANY , -"Warning, using only %u entries in %u key cache\n" , -ATH_KEYMAX , common->keymax); - common->keymax =ATH_KEYMAX ; - } + common->keymax =AR_KEYTABLE_SIZE ;if (priv->ah->misc_mode &AR_PCU_MIC_NEW_LOC_ENA ) common->crypt_caps |=ATH_CRYPT_CAP_MIC_COMBINED ;
drivers/net/wireless/ath/ath9k/hw.c +0 -6
@@ -1880,12 +1880,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)else pCap->hw_caps &= ~ATH9K_HW_CAP_HT ; -if (capField &AR_EEPROM_EEPCAP_KC_ENTRIES ) - pCap->keycache_size = -1 <<MS (capField,AR_EEPROM_EEPCAP_KC_ENTRIES ); -else - pCap->keycache_size =AR_KEYTABLE_SIZE ; -if (AR_SREV_9285 (ah) ||AR_SREV_9271 (ah)) pCap->tx_triglevel_max =MAX_TX_FIFO_THRESHOLD >>1 ;else
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -191,7 +191,6 @@ enum ath9k_hw_caps {struct ath9k_hw_capabilities {u32 hw_caps;/* ATH9K_HW_CAP_* from ath9k_hw_caps */ -u16 keycache_size;u16 low_5ghz_chan, high_5ghz_chan;u16 low_2ghz_chan, high_2ghz_chan;u16 rts_aggr_limit;
drivers/net/wireless/ath/ath9k/init.c +1 -7
@@ -407,13 +407,7 @@ void ath9k_init_crypto(struct ath_softc *sc)int i =0 ;/* Get the hardware key cache size. */ - common->keymax = sc->sc_ah->caps.keycache_size; -if (common->keymax >ATH_KEYMAX ) { -ath_dbg (common,ATH_DBG_ANY , -"Warning, using only %u entries in %u key cache\n" , -ATH_KEYMAX , common->keymax); - common->keymax =ATH_KEYMAX ; - } + common->keymax =AR_KEYTABLE_SIZE ;/* * Reset the key cache since some parts do not
Signature · 1 line
1.7.3.2
PATCH 9/10 ath9k_hw: remove ATH9K_HW_CAP_ENHANCEDPM
It is not used anywhere
--- drivers/net/wireless/ath/ath9k/hw.c | 2 -- drivers/net/wireless/ath/ath9k/hw.h | 1 - 2 files changed, 0 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +0 -2
@@ -1903,8 +1903,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) pCap->rts_aggr_limit = (8 *1024 ); } - pCap->hw_caps |=ATH9K_HW_CAP_ENHANCEDPM ; -#if defined(CONFIG_RFKILL ) || defined(CONFIG_RFKILL_MODULE ) ah->rfsilent = ah->eep_ops->get_eeprom (ah,EEP_RF_SILENT );if (ah->rfsilent &EEP_RFSILENT_ENABLED ) {
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -174,7 +174,6 @@ enum ath9k_hw_caps {ATH9K_HW_CAP_HT =BIT (0 ),ATH9K_HW_CAP_RFSILENT =BIT (1 ),ATH9K_HW_CAP_CST =BIT (2 ), -ATH9K_HW_CAP_ENHANCEDPM =BIT (3 ),ATH9K_HW_CAP_AUTOSLEEP =BIT (4 ),ATH9K_HW_CAP_4KB_SPLITTRANS =BIT (5 ), ATH9K_HW_CAP_EDMA = BIT(6),
Signature · 1 line
1.7.3.2
PATCH 10/10 ath9k_hw: remove pCap->tx_triglevel_max
It has the same purpose (and value) as ah->config.max_txtrig_level
--- drivers/net/wireless/ath/ath9k/hw.c | 5 ----- drivers/net/wireless/ath/ath9k/hw.h | 1 - drivers/net/wireless/ath/ath9k/xmit.c | 2 +- 3 files changed, 1 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +0 -5
@@ -1880,11 +1880,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)else pCap->hw_caps &= ~ATH9K_HW_CAP_HT ; -if (AR_SREV_9285 (ah) ||AR_SREV_9271 (ah)) - pCap->tx_triglevel_max =MAX_TX_FIFO_THRESHOLD >>1 ; -else - pCap->tx_triglevel_max =MAX_TX_FIFO_THRESHOLD ; -if (AR_SREV_9271 (ah)) pCap->num_gpio_pins =AR9271_NUM_GPIO ;else if (AR_DEVID_7010 (ah))
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -197,7 +197,6 @@ struct ath9k_hw_capabilities {u8 rx_chainmask;u8 max_txchains;u8 max_rxchains; -u16 tx_triglevel_max;u8 num_gpio_pins;u8 rx_hp_qdepth;u8 rx_lp_qdepth;
drivers/net/wireless/ath/ath9k/xmit.c +1 -1
@@ -1980,7 +1980,7 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,if (ieee80211_is_data (hdr->frame_control) && (ts->ts_flags & (ATH9K_TX_DATA_UNDERRUN |ATH9K_TX_DELIM_UNDERRUN )) && - ah->tx_trig_level >= sc->sc_ah->caps.tx_triglevel_max) + ah->tx_trig_level >= sc->sc_ah->config.max_txtrig_level) tx_info->status.rates[tx_rateindex].count = hw->max_rate_tries; }
Signature · 1 line
1.7.3.2
Re: [PATCH 05/10] ath9k_hw: remove pCap->total_queues
In reply to Felix FietkauQuoted 5 lines · Felix Fietkau
The EEPROM contains a field that can restrict the number of hardware queues, however this is not only useless (all the known chips contain the same number of hardware queues), but also potentially dangerous in case of a misprogrammed EEPROM (could trigger driver crashes), so let's just ignore it completely.
I can't say if there will ever be h/w w/ different #'s of tx q's but I think you're better off just capping any value read from eeprom to guard against the very unlikely scenario of misprogramming.
-Sam
Re: [PATCH 05/10] ath9k_hw: remove pCap->total_queues
Quoted 10 lines · Sam Leffler
Quoted 5 lines · Felix Fietkau
The EEPROM contains a field that can restrict the number of hardware queues, however this is not only useless (all the known chips contain the same number of hardware queues), but also potentially dangerous in case of a misprogrammed EEPROM (could trigger driver crashes), so let's just ignore it completely.
I can't say if there will ever be h/w w/ different #'s of tx q's but I think you're better off just capping any value read from eeprom to guard against the very unlikely scenario of misprogramming.
I think when chips with fewer or more tx queues show up, we should make that depend on the SREV, not the EEPROM data.
- Felix