linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Kalle Valo <kalle.valo@iki.fi>, Dan Williams <dcbw@redhat.com>,
	John Linville <linville@tuxdriver.com>,
	wireless <linux-wireless@vger.kernel.org>
Subject: Re: Signal quality strange since commit 708c57cf1709fb95
Date: Fri, 27 Feb 2009 18:45:54 +0100	[thread overview]
Message-ID: <1235756754.7426.77.camel@johannes.local> (raw)
In-Reply-To: <1235459626.4320.3.camel@johannes.local> (sfid-20090224_081432_459157_E571CC87)

On Mon, 2009-02-23 at 23:13 -0800, Johannes Berg wrote:

> > >> No, I just wondered if it was intentional that it was changed to /70. It appears
> > >> that it was, therefore, at least 3 drivers must be changed as they are
> > >> calculating on the basis of /100. For example, my b43 is showing an iwconfig
> > >> Link Quality of 93/70 while the KNM applet is showing 50%.
> > > 
> > > Well that _is_ a bug, since this shouldn't have required driver changes!
> > > I'll take a look into why that might be happening.
> > 
> > Drivers b43, b43legacy, rtl8187, and p54usb all assume a Link Quality scaled to
> > 100, which was the behavior before the commit in the subject. I don't quite
> > understand why as the old code had this fragment:
> 
> Ahh. I see now, you're talking wireless_stats and I'm thinking scan
> results. Yeah, I see what's going on, I'll fix it tomorrow.

Ok so tomorrow wasn't it, but I think I've fixed it. I didn't test it
because I'm sitting on an airplane from Portland to DC right now.

Since I'll be gone for a week once you read this email, I would
appreciate if you could submit this patch if it works (or if it doesn't
and you can fix it), adding appropriate tested-by tags, and maybe adding
some more of the information that you had to the commit log.

johannes


From: Johannes Berg <johannes@sipsolutions.net>

Fix mac80211 quality repoorting for wireless stats.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reported-by: Larry Finger <larry.finger@lwfinger.net>
---
 net/mac80211/wext.c |   58 ++++++++++++++++++++++++++++++++++------------------
 1 file changed, 39 insertions(+), 19 deletions(-)

--- wireless-testing.orig/net/mac80211/wext.c	2009-02-27 18:28:24.000000000 +0100
+++ wireless-testing/net/mac80211/wext.c	2009-02-27 18:45:17.000000000 +0100
@@ -886,21 +886,6 @@ static int ieee80211_ioctl_siwauth(struc
 	return ret;
 }
 
-static u8 ieee80211_get_wstats_flags(struct ieee80211_local *local)
-{
-	u8 wstats_flags = 0;
-
-	wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
-					   IEEE80211_HW_SIGNAL_DBM) ?
-				IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
-	wstats_flags |= local->hw.flags & IEEE80211_HW_NOISE_DBM ?
-				IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
-	if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
-		wstats_flags |= IW_QUAL_DBM;
-
-	return wstats_flags;
-}
-
 /* Get wireless statistics.  Called by /proc/net/wireless and by SIOCGIWSTATS */
 static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
 {
@@ -922,10 +907,45 @@ static struct iw_statistics *ieee80211_g
 		wstats->qual.noise = 0;
 		wstats->qual.updated = IW_QUAL_ALL_INVALID;
 	} else {
-		wstats->qual.level = sta->last_signal;
-		wstats->qual.qual = sta->last_qual;
-		wstats->qual.noise = sta->last_noise;
-		wstats->qual.updated = ieee80211_get_wstats_flags(local);
+		wstats->qual.updated = 0;
+		/*
+		 * mirror what cfg80211 does for iwrange/scan results,
+		 * otherwise userspace gets confused.
+		 */
+		if (local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
+				       IEEE80211_HW_SIGNAL_DBM)) {
+			wstats->qual.updated |= IW_QUAL_LEVEL_UPDATED;
+			wstats->qual.updated |= IW_QUAL_QUAL_UPDATED;
+		} else {
+			wstats->qual.updated |= IW_QUAL_LEVEL_INVALID;
+			wstats->qual.updated |= IW_QUAL_QUAL_INVALID;
+		}
+
+		if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) {
+			wstats->qual.level = sta->last_signal;
+			wstats->qual.qual = sta->last_signal;
+		} else if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
+			int sig = sta->last_signal;
+
+			wstats->qual.updated |= IW_QUAL_DBM;
+			wstats->qual.level = sig;
+			if (sig < -110)
+				sig = -110;
+			else if (sig > -40)
+				sig = -40;
+			wstats->qual.qual = sig + 110;
+		}
+
+		if (local->hw.flags & IEEE80211_HW_NOISE_DBM) {
+			/*
+			 * This assumes that if driver reports noise, it also
+			 * reports signal in dBm.
+			 */
+			wstats->qual.noise = sta->last_noise;
+			wstats->qual.updated |= IW_QUAL_NOISE_UPDATED;
+		} else {
+			wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
+		}
 	}
 
 	rcu_read_unlock();



  reply	other threads:[~2009-02-27 21:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-21 15:09 Signal quality strange since commit 708c57cf1709fb95 Larry Finger
2009-02-21 18:44 ` Dan Williams
2009-02-21 20:04   ` Larry Finger
2009-02-22  6:39     ` Kalle Valo
2009-02-22 15:30       ` Dan Williams
2009-02-24  2:10       ` Johannes Berg
2009-02-24  4:18         ` Larry Finger
2009-02-24  5:16           ` Johannes Berg
2009-02-24  7:07             ` Larry Finger
2009-02-24  7:13               ` Johannes Berg
2009-02-27 17:45                 ` Johannes Berg [this message]
2009-02-27 21:24                   ` Larry Finger
2009-02-27 21:48                     ` Johannes Berg
2009-02-22 15:32     ` Dan Williams

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=1235756754.7426.77.camel@johannes.local \
    --to=johannes@sipsolutions.net \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dcbw@redhat.com \
    --cc=kalle.valo@iki.fi \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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;
as well as URLs for NNTP newsgroup(s).