rt2x00: Rssi detection
Subsystems (3)
PATCH 8/26 rt2x00: Rssi detection
Correctly detect the maxssi settings from the EEPROM where available, and correct the dummy values that had been added in the initial patch to support noise and signal measurement.MAX_RX_SSI is a value that is different on each chipset, so it should be a driver specific define.
Signed-off-by Ivo van Doorn <[email protected]>
---
drivers/net/wireless/d80211/rt2x00/rt2400pci.c +9 -7
@@ -1550,13 +1550,15 @@ rt2x00dev->rx_params.ssi =rt2x00_get_field32 (word2,RXD_W2_RSSI ); -/* FIXME: The following set of assignments supply additional data for wireless statistics. The -necessary quantities are (1) the "noise" value in dBm, and (2) the "signal" value in dBm. -The present code supplies dummy values for these quantities. */ - - rt2x00dev->rx_params.noise =-85 ;/* FIXME */ - rt2x00dev->rx_params.signal = - rt2x00dev->rx_params.ssi -RT2X00_RX_MAX_SSI ;/* FIXME */ +/* +* The following set of assignments supply +* additional data for wireless statistics. The +* necessary quantities are (1) the "noise" value +* in dBm, and (2) the "signal" value in dBm. +*/ + rt2x00dev->rx_params.noise =0 ; + rt2x00dev->rx_params.signal = rt2x00dev->rx_params.ssi + - rt2x00dev->hw->maxssi;__ieee80211_rx (rt2x00dev->hw, skb, &rt2x00dev->rx_params);
drivers/net/wireless/d80211/rt2x00/rt2400pci.h +5 -0
@@ -39,6 +39,11 @@#define RF2421 0x0001/* +* Max RSSI value, required for RSSI <-> dBm conversion. +*/ +#define MAX_RX_SSI 100 + +/* * Register layout information. */ #define CSR_REG_BASE 0x0000
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +19 -7
@@ -1707,13 +1707,16 @@ rt2x00dev->rx_params.ssi =rt2x00_get_field32 (word2,RXD_W2_RSSI ); -/* FIXME: The following set of assignments supply additional data for wireless statistics. The -necessary quantities are (1) the "noise" value in dBm, and (2) the "signal" value in dBm. -The present code supplies dummy values for these quantities. */ - - rt2x00dev->rx_params.noise =-85 ;/* FIXME */ - rt2x00dev->rx_params.signal = - rt2x00dev->rx_params.ssi -RT2X00_RX_MAX_SSI ;/* FIXME */ +/* +* The following set of assignments supply +* additional data for wireless statistics. The +* necessary quantities are (1) the "noise" value +* in dBm, and (2) the "signal" value in dBm. +*/ + rt2x00dev->rx_params.noise = +rt2x00_get_link_noise (&rt2x00dev->link); + rt2x00dev->rx_params.signal = rt2x00dev->rx_params.ssi + - rt2x00dev->hw->maxssi;__ieee80211_rx (rt2x00dev->hw, skb, &rt2x00dev->rx_params);
@@ -2588,6 +2591,15 @@if (rt2x00_get_field16 (eeprom,EEPROM_NIC_DYN_BBP_TUNE ))SET_FLAG (rt2x00dev,CONFIG_DISABLE_LINK_TUNING ); +/* +* Read the RSSI <-> dBm offset information. +*/ +rt2x00_eeprom_read (rt2x00dev,EEPROM_CALIBRATE_OFFSET , &eeprom); + rt2x00dev->hw->maxssi = +rt2x00_get_field16 (eeprom,EEPROM_CALIBRATE_OFFSET_RSSI ); +if (rt2x00dev->hw->maxssi ==0x00 || rt2x00dev->hw->maxssi ==0xff ) + rt2x00dev->hw->maxssi =MAX_RX_SSI ; +return 0 ; }
drivers/net/wireless/d80211/rt2x00/rt2500pci.h +11 -0
@@ -50,6 +50,11 @@#define RT2560_VERSION_D 4/* +* Max RSSI value, required for RSSI <-> dBm conversion. +*/ +#define MAX_RX_SSI 120 + +/* * Register layout information. */ #define CSR_REG_BASE 0x0000
@@ -1001,6 +1006,12 @@#define EEPROM_TXPOWER_2 FIELD16(0xff00)/* +* RSSI <-> dBm offset calibration +*/ +#define EEPROM_CALIBRATE_OFFSET 0x3e +#define EEPROM_CALIBRATE_OFFSET_RSSI FIELD16(0x00ff) + +/* * DMA descriptor defines. */ #define TXD_DESC_SIZE ( 11 * sizeof(struct data_desc) )
drivers/net/wireless/d80211/rt2x00/rt2500usb.c +19 -7
@@ -1657,13 +1657,16 @@ rt2x00dev->rx_params.ssi =rt2x00_get_field32 (word1,RXD_W1_RSSI ); -/* FIXME: The following set of assignments supply additional data for wireless statistics. The -necessary quantities are (1) the "noise" value in dBm, and (2) the "signal" value in dBm. -The present code supplies dummy values for these quantities. */ - - rt2x00dev->rx_params.noise =-85 ;/* FIXME */ - rt2x00dev->rx_params.signal = - rt2x00dev->rx_params.ssi -RT2X00_RX_MAX_SSI ;/* FIXME */ +/* +* The following set of assignments supply +* additional data for wireless statistics. The +* necessary quantities are (1) the "noise" value +* in dBm, and (2) the "signal" value in dBm. +*/ + rt2x00dev->rx_params.noise = +rt2x00_get_link_noise (&rt2x00dev->link); + rt2x00dev->rx_params.signal = rt2x00dev->rx_params.ssi + - rt2x00dev->hw->maxssi;__ieee80211_rx (rt2x00dev->hw, skb, &rt2x00dev->rx_params);
@@ -2397,6 +2400,15 @@if (rt2x00_get_field16 (eeprom,EEPROM_NIC_DYN_BBP_TUNE ))SET_FLAG (rt2x00dev,CONFIG_DISABLE_LINK_TUNING ); +/* +* Read the RSSI <-> dBm offset information. +*/ +rt2x00_eeprom_read (rt2x00dev,EEPROM_CALIBRATE_OFFSET , &eeprom); + rt2x00dev->hw->maxssi = +rt2x00_get_field16 (eeprom,EEPROM_CALIBRATE_OFFSET_RSSI ); +if (rt2x00dev->hw->maxssi ==0x00 || rt2x00dev->hw->maxssi ==0xff ) + rt2x00dev->hw->maxssi =MAX_RX_SSI ; +return 0 ; }
drivers/net/wireless/d80211/rt2x00/rt2500usb.h +11 -0
@@ -43,6 +43,11 @@#define RF5222 0x0010/* +* Max RSSI value, required for RSSI <-> dBm conversion. +*/ +#define MAX_RX_SSI 120 + +/* * Register layout information. */ #define CSR_REG_BASE 0x0400
@@ -556,6 +561,12 @@#define EEPROM_TXPOWER_2 FIELD16(0xff00)/* +* RSSI <-> dBm offset calibration +*/ +#define EEPROM_CALIBRATE_OFFSET 0x36 +#define EEPROM_CALIBRATE_OFFSET_RSSI FIELD16(0x00ff) + +/* * DMA descriptor defines. */ #define TXD_DESC_SIZE ( 5 * sizeof(struct data_desc) )
drivers/net/wireless/d80211/rt2x00/rt2x00.h +0 -2
@@ -851,8 +851,6 @@#define CONFIG_DOUBLE_ANTENNA 0x00010000#define CONFIG_DISABLE_BBP_TUNING 0x00020000 -#define RT2X00_RX_MAX_SSI 100 -/* * Chipset identification. */
drivers/net/wireless/d80211/rt2x00/rt61pci.c +10 -7
@@ -2158,13 +2158,16 @@ rt2x00dev->rx_params.ssi =rt2x00_get_field32 (word1,RXD_W1_RSSI ); -/* FIXME: The following set of assignments supply additional data for wireless statistics. The -necessary quantities are (1) the "noise" value in dBm, and (2) the "signal" value in dBm. -The present code supplies dummy values for these quantities. */ - - rt2x00dev->rx_params.noise =-85 ;/* FIXME */ - rt2x00dev->rx_params.signal = - rt2x00dev->rx_params.ssi -RT2X00_RX_MAX_SSI ;/* FIXME */ +/* +* The following set of assignments supply +* additional data for wireless statistics. The +* necessary quantities are (1) the "noise" value +* in dBm, and (2) the "signal" value in dBm. +*/ + rt2x00dev->rx_params.noise = +rt2x00_get_link_noise (&rt2x00dev->link); + rt2x00dev->rx_params.signal = rt2x00dev->rx_params.ssi + - rt2x00dev->hw->maxssi;__ieee80211_rx (rt2x00dev->hw, skb, &rt2x00dev->rx_params);
drivers/net/wireless/d80211/rt2x00/rt61pci.h +5 -0
@@ -43,6 +43,11 @@#define RF2529 0x0004/* +* Max RSSI value, required for RSSI <-> dBm conversion. +*/ +#define MAX_RX_SSI 120 + +/* * Register layout information. */ #define CSR_REG_BASE 0x3000
drivers/net/wireless/d80211/rt2x00/rt73usb.c +10 -7
@@ -1932,13 +1932,16 @@ rt2x00dev->rx_params.ssi =rt2x00_get_field32 (word1,RXD_W1_RSSI ); -/* FIXME: The following set of assignments supply additional data for wireless statistics. The -necessary quantities are (1) the "noise" value in dBm, and (2) the "signal" value in dBm. -The present code supplies dummy values for these quantities. */ - - rt2x00dev->rx_params.noise =-85 ;/* FIXME */ - rt2x00dev->rx_params.signal = - rt2x00dev->rx_params.ssi -RT2X00_RX_MAX_SSI ;/* FIXME */ +/* +* The following set of assignments supply +* additional data for wireless statistics. The +* necessary quantities are (1) the "noise" value +* in dBm, and (2) the "signal" value in dBm. +*/ + rt2x00dev->rx_params.noise = +rt2x00_get_link_noise (&rt2x00dev->link); + rt2x00dev->rx_params.signal = rt2x00dev->rx_params.ssi + - rt2x00dev->hw->maxssi;__ieee80211_rx (rt2x00dev->hw, skb, &rt2x00dev->rx_params);
drivers/net/wireless/d80211/rt2x00/rt73usb.h +5 -0
@@ -41,6 +41,11 @@#define RF2527 0x0004/* +* Max RSSI value, required for RSSI <-> dBm conversion. +*/ +#define MAX_RX_SSI 120 + +/* * Register layout information. */ #define CSR_REG_BASE 0x3000