rt2x00: Add Signal reporting
PATCH 23/24 rt2x00: Add Signal reporting
Quoted 1 line
From
d758fee7beeab36775c33c111228d68035653796Mon Sep 17 00:00:00 2001
From: Ivo van Doorn <[email protected]>
Date: Tue, 31 Jul 2007 19:59:20 +0200
Subject: [PATCH 23/24] rt2x00: Add Signal reporting
This will add Signal reporting to rt2x00.
The calculation is based on the legacy drivers ChannelQuality value which was used for Roaming support but itself was never exported to userspace.
Some minor modifications were made against the legacy driver version, so is the weight of the RSSI reduced and the weight of TX increased. Some minor optimizations to the calculation have also been made.
The signal value is build up as follows:
20% avg_rssi (Converted into a percentage against the maximum value) 40% TX success percentage
40% RX success percentage
--- drivers/net/wireless/rt2400pci.c | 15 +++++---- drivers/net/wireless/rt2400pci.h | 1 + drivers/net/wireless/rt2500pci.c | 15 +++++---- drivers/net/wireless/rt2500pci.h | 1 + drivers/net/wireless/rt2500usb.c | 15 +++++---- drivers/net/wireless/rt2500usb.h | 1 + drivers/net/wireless/rt2x00.h | 38 ++++++++++++++++++----- drivers/net/wireless/rt2x00dev.c | 62 ++++++++++++++++++++++++++++++++++++- drivers/net/wireless/rt61pci.c | 15 +++++---- drivers/net/wireless/rt61pci.h | 1 + drivers/net/wireless/rt73usb.c | 15 +++++---- drivers/net/wireless/rt73usb.h | 1 + 12 files changed, 135 insertions(+), 45 deletions(-)
drivers/net/wireless/rt2400pci.c +8 -7
@@ -626,6 +626,7 @@ static void rt2400pci_disable_led(struct rt2x00_dev *rt2x00dev)*/ static void rt2400pci_link_stats (struct rt2x00_dev *rt2x00dev) { +int fcs;u32 reg;u8 bbp;
@@ -633,8 +634,9 @@ static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev)* Update FCS error count from register. */ rt2x00pci_register_read (rt2x00dev,CNT0 , ®); - rt2x00dev->low_level_stats.dot11FCSErrorCount += -rt2x00_get_field32 (reg,CNT0_FCS_ERROR ); + fcs =rt2x00_get_field32 (reg,CNT0_FCS_ERROR ); + rt2x00dev->link.rx_failed += fcs; + rt2x00dev->low_level_stats.dot11FCSErrorCount += fcs;/* * Update False CCA count from register.
@@ -1203,13 +1205,11 @@ static int rt2400pci_fill_rxdone(struct data_entry *entry,rt2x00_desc_read (rxd,0 , &word0);rt2x00_desc_read (rxd,2 , &word2); -/* -* TODO: Don't we need to keep statistics -* updated about these errors? -*/ if (rt2x00_get_field32 (word0,RXD_W0_CRC_ERROR ) || -rt2x00_get_field32 (word0,RXD_W0_PHYSICAL_ERROR )) +rt2x00_get_field32 (word0,RXD_W0_PHYSICAL_ERROR )) { + entry->ring->rt2x00dev->link.rx_failed++;return -EINVAL ; + }/* * Obtain the status about this packet.
@@ -1452,6 +1452,7 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)IEEE80211_HW_MONITOR_DURING_OPER |IEEE80211_HW_NO_PROBE_FILTERING ; rt2x00dev->hw->extra_tx_headroom =0 ; + rt2x00dev->hw->max_signal =MAX_SIGNAL ; rt2x00dev->hw->max_rssi =MAX_RX_SSI ; rt2x00dev->hw->queues =2 ;
drivers/net/wireless/rt2400pci.h +1 -0
@@ -37,6 +37,7 @@* Signal information. * Defaul offset is required for RSSI <-> dBm conversion. */ +#define MAX_SIGNAL 100#define MAX_RX_SSI -1#define DEFAULT_RSSI_OFFSET 100
drivers/net/wireless/rt2500pci.c +8 -7
@@ -727,14 +727,16 @@ static void rt2500pci_disable_led(struct rt2x00_dev *rt2x00dev)*/ static void rt2500pci_link_stats (struct rt2x00_dev *rt2x00dev) { +int fcs;u32 reg;/* * Update FCS error count from register. */ rt2x00pci_register_read (rt2x00dev,CNT0 , ®); - rt2x00dev->low_level_stats.dot11FCSErrorCount += -rt2x00_get_field32 (reg,CNT0_FCS_ERROR ); + fcs =rt2x00_get_field32 (reg,CNT0_FCS_ERROR ); + rt2x00dev->link.rx_failed += fcs; + rt2x00dev->low_level_stats.dot11FCSErrorCount += fcs;/* * Update False CCA count from register.
@@ -1381,14 +1383,12 @@ static int rt2500pci_fill_rxdone(struct data_entry *entry,rt2x00_desc_read (rxd,0 , &word0);rt2x00_desc_read (rxd,2 , &word2); -/* -* TODO: Don't we need to keep statistics -* updated about these errors? -*/ if (rt2x00_get_field32 (word0,RXD_W0_CRC_ERROR ) ||rt2x00_get_field32 (word0,RXD_W0_PHYSICAL_ERROR ) || -rt2x00_get_field32 (word0,RXD_W0_ICV_ERROR )) +rt2x00_get_field32 (word0,RXD_W0_ICV_ERROR )) { + entry->ring->rt2x00dev->link.rx_failed++;return -EINVAL ; + } *signal =rt2x00_get_field32 (word2,RXD_W2_SIGNAL ); *rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
@@ -1697,6 +1697,7 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)IEEE80211_HW_MONITOR_DURING_OPER |IEEE80211_HW_NO_PROBE_FILTERING ; rt2x00dev->hw->extra_tx_headroom =0 ; + rt2x00dev->hw->max_signal =MAX_SIGNAL ; rt2x00dev->hw->max_rssi =MAX_RX_SSI ; rt2x00dev->hw->queues =2 ;
drivers/net/wireless/rt2500pci.h +1 -0
@@ -48,6 +48,7 @@* Signal information. * Defaul offset is required for RSSI <-> dBm conversion. */ +#define MAX_SIGNAL 100#define MAX_RX_SSI -1#define DEFAULT_RSSI_OFFSET 121
drivers/net/wireless/rt2500usb.c +8 -7
@@ -682,14 +682,16 @@ static void rt2500usb_disable_led(struct rt2x00_dev *rt2x00dev)*/ static void rt2500usb_link_stats (struct rt2x00_dev *rt2x00dev) { +int fcs;u16 reg;/* * Update FCS error count from register. */ rt2500usb_register_read (rt2x00dev,STA_CSR0 , ®); - rt2x00dev->low_level_stats.dot11FCSErrorCount += -rt2x00_get_field16 (reg,STA_CSR0_FCS_ERROR ); + fcs =rt2x00_get_field16 (reg,STA_CSR0_FCS_ERROR ); + rt2x00dev->link.rx_failed += fcs; + rt2x00dev->low_level_stats.dot11FCSErrorCount += fcs;/* * Update False CCA count from register.
@@ -1181,14 +1183,12 @@ static int rt2500usb_fill_rxdone(struct data_entry *entry,rt2x00_desc_read (rxd,0 , &word0);rt2x00_desc_read (rxd,1 , &word1); -/* -* TODO: Don't we need to keep statistics -* updated about these errors? -*/ if (rt2x00_get_field32 (word0,RXD_W0_CRC_ERROR ) ||rt2x00_get_field32 (word0,RXD_W0_PHYSICAL_ERROR ) || -rt2x00_get_field32 (word0,RXD_W0_CIPHER_ERROR )) +rt2x00_get_field32 (word0,RXD_W0_CIPHER_ERROR )) { + entry->ring->rt2x00dev->link.rx_failed++;return -EINVAL ; + }/* * Obtain the status about this packet.
@@ -1427,6 +1427,7 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)IEEE80211_HW_MONITOR_DURING_OPER |IEEE80211_HW_NO_PROBE_FILTERING ; rt2x00dev->hw->extra_tx_headroom =TXD_DESC_SIZE ; + rt2x00dev->hw->max_signal =MAX_SIGNAL ; rt2x00dev->hw->max_rssi =MAX_RX_SSI ; rt2x00dev->hw->queues =2 ;
drivers/net/wireless/rt2500usb.h +1 -0
@@ -48,6 +48,7 @@* Signal information. * Defaul offset is required for RSSI <-> dBm conversion. */ +#define MAX_SIGNAL 100#define MAX_RX_SSI -1#define DEFAULT_RSSI_OFFSET 120
drivers/net/wireless/rt2x00.h +30 -8
@@ -192,7 +192,7 @@ struct link {u32 count;/* -* Misc statistics. +* Statistics required for Link tuning. * For the average RSSI value we use the "Walking average" approach. * When adding RSSI to the average value the following calculation * is needed:
@@ -214,6 +214,31 @@ struct link {int false_cca;/* +* Statistics required for Signal quality calculation. +* For calculating the Signal quality we have to determine +* the total number of success and failed RX and TX frames. +* After that we also use the average RSSI value to help +* determining the signal quality. +* For the calculation we will use the following algorithm: +* +* rssi_percentage = (avg_rssi * 100) / rssi_offset +* rx_percentage = (rx_success * 100) / rx_total +* tx_percentage = (tx_success * 100) / tx_total +* avg_signal = ((WEIGHT_RSSI * avg_rssi) + +* (WEIGHT_TX * tx_percentage) + +* (WEIGHT_RX * rx_percentage)) / 100 +* +* This value should then be checked to not be greated then 100. +*/ +int rx_success; +int rx_failed; +int tx_success; +int tx_failed; +#define WEIGHT_RSSI 20 +#define WEIGHT_RX 40 +#define WEIGHT_TX 40 + +/* * Work structure for scheduling periodic link tuning. */ struct delayed_work work;
@@ -231,16 +256,13 @@ static inline void rt2x00_update_link_rssi(struct link *link, int rssi) }/* -* When the avg_rssi is unset (which means no frames -* have been received), we need to return the default -* value which needs to be less than -80 so the device -* will select the maximum sensitivity. +* When the avg_rssi is unset or no frames have been received), +* we need to return the default value which needs to be less +* than -80 so the device will select the maximum sensitivity. */ static inline int rt2x00_get_link_rssi (struct link *link) { -int rssi = link->avg_rssi; - link->avg_rssi =0 ; -return rssi ? rssi :-128 ; +return (link->avg_rssi && link->rx_success) ? link->avg_rssi :-128 ; }/*
drivers/net/wireless/rt2x00dev.c +60 -2
101 lines not on this page · raw message
drivers/net/wireless/rt61pci.c +8 -7
@@ -939,14 +939,16 @@ static void rt61pci_activity_led(struct rt2x00_dev *rt2x00dev, int rssi)*/ static void rt61pci_link_stats (struct rt2x00_dev *rt2x00dev) { +int fcs;u32 reg;/* * Update FCS error count from register. */ rt2x00pci_register_read (rt2x00dev,STA_CSR0 , ®); - rt2x00dev->low_level_stats.dot11FCSErrorCount += -rt2x00_get_field32 (reg,STA_CSR0_FCS_ERROR ); + fcs =rt2x00_get_field32 (reg,STA_CSR0_FCS_ERROR ); + rt2x00dev->link.rx_failed += fcs; + rt2x00dev->low_level_stats.dot11FCSErrorCount += fcs;/* * Update False CCA count from register.
@@ -1797,13 +1799,11 @@ static int rt61pci_fill_rxdone(struct data_entry *entry,rt2x00_desc_read (rxd,0 , &word0);rt2x00_desc_read (rxd,1 , &word1); -/* -* TODO: Don't we need to keep statistics -* updated about these errors? -*/ if (rt2x00_get_field32 (word0,RXD_W0_CRC_ERROR ) || -rt2x00_get_field32 (word0,RXD_W0_CIPHER_ERROR )) +rt2x00_get_field32 (word0,RXD_W0_CIPHER_ERROR )) { + entry->ring->rt2x00dev->link.rx_failed++;return -EINVAL ; + }/* * Obtain the status about this packet.
@@ -2221,6 +2221,7 @@ static void rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)IEEE80211_HW_MONITOR_DURING_OPER |IEEE80211_HW_NO_PROBE_FILTERING ; rt2x00dev->hw->extra_tx_headroom =0 ; + rt2x00dev->hw->max_signal =MAX_SIGNAL ; rt2x00dev->hw->max_rssi =MAX_RX_SSI ; rt2x00dev->hw->queues =5 ;
drivers/net/wireless/rt61pci.h +1 -0
@@ -39,6 +39,7 @@* Signal information. * Defaul offset is required for RSSI <-> dBm conversion. */ +#define MAX_SIGNAL 100#define MAX_RX_SSI -1#define DEFAULT_RSSI_OFFSET 120
drivers/net/wireless/rt73usb.c +8 -7
@@ -828,14 +828,16 @@ static void rt73usb_activity_led(struct rt2x00_dev *rt2x00dev, int rssi)*/ static void rt73usb_link_stats (struct rt2x00_dev *rt2x00dev) { +int fcs;u32 reg;/* * Update FCS error count from register. */ rt73usb_register_read (rt2x00dev,STA_CSR0 , ®); - rt2x00dev->low_level_stats.dot11FCSErrorCount += -rt2x00_get_field32 (reg,STA_CSR0_FCS_ERROR ); + fcs =rt2x00_get_field32 (reg,STA_CSR0_FCS_ERROR ); + rt2x00dev->link.rx_failed += fcs; + rt2x00dev->low_level_stats.dot11FCSErrorCount += fcs;/* * Update False CCA count from register.
@@ -1432,13 +1434,11 @@ static int rt73usb_fill_rxdone(struct data_entry *entry,rt2x00_desc_read (rxd,0 , &word0);rt2x00_desc_read (rxd,1 , &word1); -/* -* TODO: Don't we need to keep statistics -* updated about these errors? -*/ if (rt2x00_get_field32 (word0,RXD_W0_CRC_ERROR ) || -rt2x00_get_field32 (word0,RXD_W0_CIPHER_ERROR )) +rt2x00_get_field32 (word0,RXD_W0_CIPHER_ERROR )) { + entry->ring->rt2x00dev->link.rx_failed++;return -EINVAL ; + }/* * Obtain the status about this packet.
@@ -1687,6 +1687,7 @@ static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)IEEE80211_HW_MONITOR_DURING_OPER |IEEE80211_HW_NO_PROBE_FILTERING ; rt2x00dev->hw->extra_tx_headroom =TXD_DESC_SIZE ; + rt2x00dev->hw->max_signal =MAX_SIGNAL ; rt2x00dev->hw->max_rssi =MAX_RX_SSI ; rt2x00dev->hw->queues =5 ;
drivers/net/wireless/rt73usb.h +1 -0
@@ -39,6 +39,7 @@* Signal information. * Defaul offset is required for RSSI <-> dBm conversion. */ +#define MAX_SIGNAL 100#define MAX_RX_SSI -1#define DEFAULT_RSSI_OFFSET 120
Signature · 1 line
1.5.2.4