aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-02-27 17:33:55 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-03-05 14:39:35 -0500
commit24776cfd5559d3171054d3a7ea76d5febc54b03d (patch)
treed36c10070b18c9303b79e5bf6aee536d4c25cb45 /net/mac80211
parente79c1ba84c68de9161d541bd2bcc8ea65c89955c (diff)
mac80211: Fix quality reporting for wireless stats
Since "mac80211/cfg80211: move iwrange handler to cfg80211", the results for link quality from "iwlist scan" and "iwconfig" commands have been very different. The results are now consistent. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reported- and tested-by: Larry Finger <larry.finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/wext.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index f6924fc065d3..935c63ed3dfa 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -886,21 +886,6 @@ static int ieee80211_ioctl_siwauth(struct net_device *dev,
886 return ret; 886 return ret;
887} 887}
888 888
889static u8 ieee80211_get_wstats_flags(struct ieee80211_local *local)
890{
891 u8 wstats_flags = 0;
892
893 wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
894 IEEE80211_HW_SIGNAL_DBM) ?
895 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
896 wstats_flags |= local->hw.flags & IEEE80211_HW_NOISE_DBM ?
897 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
898 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
899 wstats_flags |= IW_QUAL_DBM;
900
901 return wstats_flags;
902}
903
904/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ 889/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
905static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev) 890static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
906{ 891{
@@ -922,10 +907,45 @@ static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev
922 wstats->qual.noise = 0; 907 wstats->qual.noise = 0;
923 wstats->qual.updated = IW_QUAL_ALL_INVALID; 908 wstats->qual.updated = IW_QUAL_ALL_INVALID;
924 } else { 909 } else {
925 wstats->qual.level = sta->last_signal; 910 wstats->qual.updated = 0;
926 wstats->qual.qual = sta->last_qual; 911 /*
927 wstats->qual.noise = sta->last_noise; 912 * mirror what cfg80211 does for iwrange/scan results,
928 wstats->qual.updated = ieee80211_get_wstats_flags(local); 913 * otherwise userspace gets confused.
914 */
915 if (local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
916 IEEE80211_HW_SIGNAL_DBM)) {
917 wstats->qual.updated |= IW_QUAL_LEVEL_UPDATED;
918 wstats->qual.updated |= IW_QUAL_QUAL_UPDATED;
919 } else {
920 wstats->qual.updated |= IW_QUAL_LEVEL_INVALID;
921 wstats->qual.updated |= IW_QUAL_QUAL_INVALID;
922 }
923
924 if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) {
925 wstats->qual.level = sta->last_signal;
926 wstats->qual.qual = sta->last_signal;
927 } else if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
928 int sig = sta->last_signal;
929
930 wstats->qual.updated |= IW_QUAL_DBM;
931 wstats->qual.level = sig;
932 if (sig < -110)
933 sig = -110;
934 else if (sig > -40)
935 sig = -40;
936 wstats->qual.qual = sig + 110;
937 }
938
939 if (local->hw.flags & IEEE80211_HW_NOISE_DBM) {
940 /*
941 * This assumes that if driver reports noise, it also
942 * reports signal in dBm.
943 */
944 wstats->qual.noise = sta->last_noise;
945 wstats->qual.updated |= IW_QUAL_NOISE_UPDATED;
946 } else {
947 wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
948 }
929 } 949 }
930 950
931 rcu_read_unlock(); 951 rcu_read_unlock();