aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-02-18 12:27:22 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-02-27 14:52:40 -0500
commita77b855245541823b49999a27245ad7428879096 (patch)
tree29e80ea3f90a22309b55ea1823eda5700ebc4b49 /net
parentcb3a8eec0e66edfe8db7d3b3bf19d25745bae3c3 (diff)
cfg80211/mac80211: fill qual.qual value/adjust max_qual.qual
Due to various bugs in the software stack we end up having to fill qual.qual; level should be used, but wpa_supplicant doesn't properly ignore qual.qual, NM should use qual.level regardless of that because qual.qual is 0 but doesn't handle IW_QUAL_DBM right now. So fill qual.qual with the qual.level value clamped to -110..-40 dBm or just the regular 'unspecified' signal level. This requires a mac80211 change to properly announce the max_qual.qual and avg_qual.qual values. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/wext.c18
-rw-r--r--net/wireless/scan.c15
2 files changed, 28 insertions, 5 deletions
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index 8a76a979bc92..a8d4b6171916 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -200,10 +200,24 @@ static int ieee80211_ioctl_giwrange(struct net_device *dev,
200 else 200 else
201 range->max_qual.noise = 0; 201 range->max_qual.noise = 0;
202 202
203 range->max_qual.qual = 100;
204 range->max_qual.updated = ieee80211_get_wstats_flags(local); 203 range->max_qual.updated = ieee80211_get_wstats_flags(local);
205 204
206 range->avg_qual.qual = 50; 205 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
206 /*
207 * cfg80211 assumes -110 to -40 dBm and clamps to that range
208 * for qual.qual, so tell userspace this is what we give it
209 * but take into account that we have to start from 0.
210 */
211 range->max_qual.qual = 70;
212 range->avg_qual.qual = 35;
213 } else {
214 /*
215 * cfg80211 just uses the level value for qual too, and it
216 * requires the level value to be 0 .. 100.
217 */
218 range->max_qual.qual = 100;
219 range->avg_qual.qual = 50;
220 }
207 /* not always true but better than nothing */ 221 /* not always true but better than nothing */
208 range->avg_qual.level = range->max_qual.level / 2; 222 range->avg_qual.level = range->max_qual.level / 2;
209 range->avg_qual.noise = range->max_qual.noise / 2; 223 range->avg_qual.noise = range->max_qual.noise / 2;
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 9fad1631d6cb..01c136d98c5b 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -614,7 +614,7 @@ ieee80211_bss(struct iw_request_info *info,
614 struct iw_event iwe; 614 struct iw_event iwe;
615 u8 *buf, *cfg, *p; 615 u8 *buf, *cfg, *p;
616 u8 *ie = bss->pub.information_elements; 616 u8 *ie = bss->pub.information_elements;
617 int rem = bss->pub.len_information_elements, i; 617 int rem = bss->pub.len_information_elements, i, sig;
618 bool ismesh = false; 618 bool ismesh = false;
619 619
620 memset(&iwe, 0, sizeof(iwe)); 620 memset(&iwe, 0, sizeof(iwe));
@@ -643,14 +643,23 @@ ieee80211_bss(struct iw_request_info *info,
643 iwe.cmd = IWEVQUAL; 643 iwe.cmd = IWEVQUAL;
644 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED | 644 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED |
645 IW_QUAL_NOISE_INVALID | 645 IW_QUAL_NOISE_INVALID |
646 IW_QUAL_QUAL_INVALID; 646 IW_QUAL_QUAL_UPDATED;
647 switch (bss->pub.signal_type) { 647 switch (bss->pub.signal_type) {
648 case CFG80211_SIGNAL_TYPE_MBM: 648 case CFG80211_SIGNAL_TYPE_MBM:
649 iwe.u.qual.level = bss->pub.signal / 100; 649 sig = bss->pub.signal / 100;
650 iwe.u.qual.level = sig;
650 iwe.u.qual.updated |= IW_QUAL_DBM; 651 iwe.u.qual.updated |= IW_QUAL_DBM;
652 if (sig < -110) /* rather bad */
653 sig = -110;
654 else if (sig > -40) /* perfect */
655 sig = -40;
656 /* will give a range of 0 .. 70 */
657 iwe.u.qual.qual = sig + 110;
651 break; 658 break;
652 case CFG80211_SIGNAL_TYPE_UNSPEC: 659 case CFG80211_SIGNAL_TYPE_UNSPEC:
653 iwe.u.qual.level = bss->pub.signal; 660 iwe.u.qual.level = bss->pub.signal;
661 /* will give range 0 .. 100 */
662 iwe.u.qual.qual = bss->pub.signal;
654 break; 663 break;
655 default: 664 default:
656 /* not reached */ 665 /* not reached */