]> err.no Git - linux-2.6/commitdiff
[PATCH] ieee80211 quality scaling algorithm extension handler
authorJames Ketrenos <jketreno@linux.intel.com>
Tue, 13 Sep 2005 22:27:19 +0000 (17:27 -0500)
committerJeff Garzik <jgarzik@pobox.com>
Fri, 16 Sep 2005 07:06:32 +0000 (03:06 -0400)
Incorporated Bill Moss' quality scaling algorithm into default wireless
extension handler.

Signed-off-by: James Ketrenos <jketreno@linux.intel.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
include/net/ieee80211.h
net/ieee80211/ieee80211_wx.c

index dc36b1be6745ac7c8b2e8e28810b9b99bc49de66..ce966b7ff563f582d0db9b985b29167cffb7e1f9 100644 (file)
@@ -719,6 +719,9 @@ struct ieee80211_device {
        int freq_band;  /* 2.4Ghz, 5.2Ghz, Mixed */
        int abg_ture;   /* ABG flag              */
 
+       int perfect_rssi;
+       int worst_rssi;
+
        /* Callback functions */
        void (*set_security)(struct net_device *dev,
                             struct ieee80211_security *sec);
index 94882f39b0728f9ec92c11f7545f9755bdd10c90..04f0897b065364a153fd1211d81b0feec09bc775 100644 (file)
@@ -140,18 +140,38 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
                start = iwe_stream_add_point(start, stop, &iwe, custom);
 
        /* Add quality statistics */
-       /* TODO: Fix these values... */
        iwe.cmd = IWEVQUAL;
-       iwe.u.qual.qual = network->stats.signal;
-       iwe.u.qual.level = network->stats.rssi;
-       iwe.u.qual.noise = network->stats.noise;
-       iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK;
-       if (!(network->stats.mask & IEEE80211_STATMASK_RSSI))
-               iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID;
-       if (!(network->stats.mask & IEEE80211_STATMASK_NOISE))
+       iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
+           IW_QUAL_NOISE_UPDATED;
+
+       if (!(network->stats.mask & IEEE80211_STATMASK_RSSI)) {
+               iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID |
+                   IW_QUAL_LEVEL_INVALID;
+               iwe.u.qual.qual = 0;
+               iwe.u.qual.level = 0;
+       } else {
+               iwe.u.qual.level = network->stats.rssi;
+               iwe.u.qual.qual =
+                   (100 *
+                    (ieee->perfect_rssi - ieee->worst_rssi) *
+                    (ieee->perfect_rssi - ieee->worst_rssi) -
+                    (ieee->perfect_rssi - network->stats.rssi) *
+                    (15 * (ieee->perfect_rssi - ieee->worst_rssi) +
+                     62 * (ieee->perfect_rssi - network->stats.rssi))) /
+                   ((ieee->perfect_rssi - ieee->worst_rssi) *
+                    (ieee->perfect_rssi - ieee->worst_rssi));
+               if (iwe.u.qual.qual > 100)
+                       iwe.u.qual.qual = 100;
+               else if (iwe.u.qual.qual < 1)
+                       iwe.u.qual.qual = 0;
+       }
+
+       if (!(network->stats.mask & IEEE80211_STATMASK_NOISE)) {
                iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
-       if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL))
-               iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
+               iwe.u.qual.noise = 0;
+       } else {
+               iwe.u.qual.noise = network->stats.noise;
+       }
 
        start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);