public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-wireless@vger.kernel.org, John Linville <linville@tuxdriver.com>
Subject: [PATCH] cfg80211/mac80211: fill qual.qual value/adjust max_qual.qual
Date: Wed, 18 Feb 2009 18:27:22 +0100	[thread overview]
Message-ID: <1234978042.4023.32.camel@johannes.local> (raw)
In-Reply-To: <1234896777.4678.7.camel@californication> (sfid-20090217_195251_321967_5E2E0AB8)

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>
---
 net/mac80211/wext.c |   18 ++++++++++++++++--
 net/wireless/scan.c |   15 ++++++++++++---
 2 files changed, 28 insertions(+), 5 deletions(-)

--- wireless-testing.orig/net/mac80211/wext.c	2009-02-18 18:13:49.000000000 +0100
+++ wireless-testing/net/mac80211/wext.c	2009-02-18 18:15:08.000000000 +0100
@@ -200,10 +200,24 @@ static int ieee80211_ioctl_giwrange(stru
 	else
 		range->max_qual.noise = 0;
 
-	range->max_qual.qual = 100;
 	range->max_qual.updated = ieee80211_get_wstats_flags(local);
 
-	range->avg_qual.qual = 50;
+	if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
+		/*
+		 * cfg80211 assumes -110 to -40 dBm and clamps to that range
+		 * for qual.qual, so tell userspace this is what we give it
+		 * but take into account that we have to start from 0.
+		 */
+		range->max_qual.qual = 70;
+		range->avg_qual.qual = 35;
+	} else {
+		/*
+		 * cfg80211 just uses the level value for qual too, and it
+		 * requires the level value to be 0 .. 100.
+		 */
+		range->max_qual.qual = 100;
+		range->avg_qual.qual = 50;
+	}
 	/* not always true but better than nothing */
 	range->avg_qual.level = range->max_qual.level / 2;
 	range->avg_qual.noise = range->max_qual.noise / 2;
--- wireless-testing.orig/net/wireless/scan.c	2009-02-18 18:08:20.000000000 +0100
+++ wireless-testing/net/wireless/scan.c	2009-02-18 18:13:44.000000000 +0100
@@ -614,7 +614,7 @@ ieee80211_bss(struct iw_request_info *in
 	struct iw_event iwe;
 	u8 *buf, *cfg, *p;
 	u8 *ie = bss->pub.information_elements;
-	int rem = bss->pub.len_information_elements, i;
+	int rem = bss->pub.len_information_elements, i, sig;
 	bool ismesh = false;
 
 	memset(&iwe, 0, sizeof(iwe));
@@ -643,14 +643,23 @@ ieee80211_bss(struct iw_request_info *in
 		iwe.cmd = IWEVQUAL;
 		iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED |
 				     IW_QUAL_NOISE_INVALID |
-				     IW_QUAL_QUAL_INVALID;
+				     IW_QUAL_QUAL_UPDATED;
 		switch (bss->pub.signal_type) {
 		case CFG80211_SIGNAL_TYPE_MBM:
-			iwe.u.qual.level = bss->pub.signal / 100;
+			sig = bss->pub.signal / 100;
+			iwe.u.qual.level = sig;
 			iwe.u.qual.updated |= IW_QUAL_DBM;
+			if (sig < -110)		/* rather bad */
+				sig = -110;
+			else if (sig > -40)	/* perfect */
+				sig = -40;
+			/* will give a range of 0 .. 70 */
+			iwe.u.qual.qual = sig + 110;
 			break;
 		case CFG80211_SIGNAL_TYPE_UNSPEC:
 			iwe.u.qual.level = bss->pub.signal;
+			/* will give range 0 .. 100 */
+			iwe.u.qual.qual = bss->pub.signal;
 			break;
 		default:
 			/* not reached */



  parent reply	other threads:[~2009-02-18 17:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17 18:52 Missing link quality with wireless-testing Marcel Holtmann
2009-02-17 19:43 ` Johannes Berg
2009-02-17 20:24   ` Marcel Holtmann
2009-02-17 20:55     ` Johannes Berg
2009-02-17 21:09       ` Marcel Holtmann
2009-02-17 23:25         ` Dan Williams
2009-02-18  4:57           ` Marcel Holtmann
2009-02-18  7:31             ` Jouni Malinen
2009-02-18  8:06               ` Marcel Holtmann
2009-02-18  8:25                 ` Jouni Malinen
2009-02-18 12:18                   ` Dan Williams
2009-02-18 12:33                     ` Jouni Malinen
2009-02-18 12:48                       ` Dan Williams
2009-02-18 13:20                         ` Dan Williams
2009-02-18 14:01                         ` Jouni Malinen
2009-02-18 14:25                         ` Johannes Berg
2009-02-18 13:37                     ` Johannes Berg
2009-02-18 15:13                       ` Dan Williams
2009-02-18 16:48                         ` Johannes Berg
2009-02-18 17:27 ` Johannes Berg [this message]
2009-02-18 17:29   ` [PATCH] cfg80211/mac80211: fill qual.qual value/adjust max_qual.qual Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1234978042.4023.32.camel@johannes.local \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox