From administrator@Prakkezator.VEHosting.nl  Tue Aug 14 10:51:01 2012
Return-Path: <administrator@Prakkezator.VEHosting.nl>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1D9C5106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 14 Aug 2012 10:51:01 +0000 (UTC)
	(envelope-from administrator@Prakkezator.VEHosting.nl)
Received: from Bliksem.VEHosting.nl (Bliksem6.VEHosting.nl [IPv6:2001:1af8:2100:b020::141])
	by mx1.freebsd.org (Postfix) with ESMTP id A017E8FC0A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 14 Aug 2012 10:51:00 +0000 (UTC)
Received: from vitsch.nl (localhost [127.0.0.1])
	by Bliksem.VEHosting.nl (8.13.8/8.13.8) with SMTP id q7EAowaR075132;
	Tue, 14 Aug 2012 12:50:58 +0200 (CEST)
	(envelope-from administrator@Prakkezator.VEHosting.nl)
Received: from Prakkezator.VEHosting.nl (localhost [127.0.0.1])
	by Prakkezator.VEHosting.nl (8.14.2/8.14.2) with ESMTP id q7EAn4Xt000911;
	Tue, 14 Aug 2012 12:49:04 +0200 (CEST)
	(envelope-from administrator@Prakkezator.VEHosting.nl)
Received: (from root@localhost)
	by Prakkezator.VEHosting.nl (8.14.2/8.14.2/Submit) id q7EAn4aH000910;
	Tue, 14 Aug 2012 12:49:04 +0200 (CEST)
	(envelope-from administrator)
Message-Id: <201208141049.q7EAn4aH000910@Prakkezator.VEHosting.nl>
Date: Tue, 14 Aug 2012 12:49:04 +0200 (CEST)
From: Daan Vreeken <Daan@vitsch.nl>
Reply-To: Daan Vreeken <Daan@vitsch.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Daan Vreeken <Daan@vitsch.nl>
Subject: [PATCH] Add roaming support to wpa_supplicant
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         170631
>Category:       bin
>Synopsis:       [PATCH] Add roaming support to wpa_supplicant(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 14 11:00:21 UTC 2012
>Closed-Date:    Thu Jun 13 21:13:33 UTC 2013
>Last-Modified:  Thu Jun 13 21:13:33 UTC 2013
>Originator:     Daan Vreeken
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
Vitsch Electronics - http://VitschVPN.nl/
>Environment:
System:
 FreeBSD Devel13.Vitsch.LAN 10.0-CURRENT FreeBSD 10.0-CURRENT #0: Sat Jan 28 21:31:14 CET 2012 root@Compile2:/usr/src/sys/amd64/compile/Multimedia amd64

	
>Description:
 The wpa_supplicant application has the ability to do roaming based on the
 received signal strength indication (RSSI), but currently this is broken in
 FreeBSD.
 At this moment wpa_supplicant will always report a level of 0dBm for all
 detected wireless networks.

	
>How-To-Repeat:
	
 Run wpa_supplicant with the '-d' option set and with a configuration file
 that allows it to connect to at least two Access Points that are in the
 vicinity of the receiver.
 Note that wpa_supplicant will always report a level of '0' for all networks.

>Fix:
 The wpa_supplicant's FreeBSD driver interface only sets 'result->qual' and
 'result->noise', but not 'result->level' in wpa_driver_bsd_add_scan_entry(),
 while the latter is used when sorting AP's based on their signal strength.

 The attached patch fixes this by calculating 'result->level' according to
 it's definition in net80211/ieee80211_node.h .
 The patch also fixes a spelling error in ieee80211_var.h .
 If the patch somehow gets mangled in the email, it can also be downloaded
 from:
	http://www.Vitsch.nl/pub_diffs/

 After applying the patch, wpa_supplicant will now successfully attempt to
 roam when background scanning is enabled and there is an AP with a higher
 signal strength.

 Sponsored by: Vitsch Electronics


--- patch_wpa_supplicant_rssi_fix_2012_08_14.diff begins here ---
Index: usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
===================================================================
--- usr.sbin/wpa/wpa_supplicant/driver_freebsd.c	(revision 238968)
+++ usr.sbin/wpa/wpa_supplicant/driver_freebsd.c	(working copy)
@@ -693,6 +693,11 @@
         result->caps = sr->isr_capinfo;
         result->qual = sr->isr_rssi;
         result->noise = sr->isr_noise;
+        /*
+         * the rssi value reported by the kernel is in 0.5dB steps relative to
+         * the reported noise floor. see ieee80211_node.h for details.
+         */
+        result->level = sr->isr_rssi / 2 + sr->isr_noise;
 
         pos = (u8 *)(result + 1);
 
Index: sys/net80211/ieee80211_var.h
===================================================================
--- sys/net80211/ieee80211_var.h	(revision 238968)
+++ sys/net80211/ieee80211_var.h	(working copy)
@@ -55,7 +55,7 @@
 #include <net80211/ieee80211_radiotap.h>
 #include <net80211/ieee80211_scan.h>
 
-#define	IEEE80211_TXPOWER_MAX	100	/* .5 dbM (XXX units?) */
+#define	IEEE80211_TXPOWER_MAX	100	/* .5 dBm (XXX units?) */
 #define	IEEE80211_TXPOWER_MIN	0	/* kill radio */
 
 #define	IEEE80211_DTIM_DEFAULT	1	/* default DTIM period */
--- patch_wpa_supplicant_rssi_fix_2012_08_14.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sat May 11 20:57:19 UTC 2013 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=170631 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/170631: commit references a PR
Date: Sat, 11 May 2013 20:55:23 +0000 (UTC)

 Author: eadler
 Date: Sat May 11 20:55:14 2013
 New Revision: 250528
 URL: http://svnweb.freebsd.org/changeset/base/250528
 
 Log:
   Teach wpa_supplicant to properly compute wireless signal strength.
   
   PR:		bin/170631
   Submitted by:	Daan Vreeken <Daan@vitsch.nl>
   Reviewed by:	adrian
 
 Modified:
   head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
 
 Modified: head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
 ==============================================================================
 --- head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c	Sat May 11 20:51:00 2013	(r250527)
 +++ head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c	Sat May 11 20:55:14 2013	(r250528)
 @@ -693,6 +693,11 @@ wpa_driver_bsd_add_scan_entry(struct wpa
          result->caps = sr->isr_capinfo;
          result->qual = sr->isr_rssi;
          result->noise = sr->isr_noise;
 +        /*
 +         * the rssi value reported by the kernel is in 0.5dB steps relative to
 +         * the reported noise floor. see ieee80211_node.h for details.
 +         */
 +        result->level = sr->isr_rssi / 2 + sr->isr_noise;
  
          pos = (u8 *)(result + 1);
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/170631: commit references a PR
Date: Fri, 17 May 2013 00:14:43 +0000 (UTC)

 Author: eadler
 Date: Fri May 17 00:14:36 2013
 New Revision: 250727
 URL: http://svnweb.freebsd.org/changeset/base/250727
 
 Log:
   MFC r250528:
   	Teach wpa_supplicant to properly compute wireless signal strength.
   
   PR:		bin/170631
 
 Modified:
   stable/9/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
 Directory Properties:
   stable/9/usr.sbin/wpa/   (props changed)
   stable/9/usr.sbin/wpa/wpa_supplicant/   (props changed)
 
 Modified: stable/9/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
 ==============================================================================
 --- stable/9/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c	Thu May 16 23:30:11 2013	(r250726)
 +++ stable/9/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c	Fri May 17 00:14:36 2013	(r250727)
 @@ -693,6 +693,11 @@ wpa_driver_bsd_add_scan_entry(struct wpa
          result->caps = sr->isr_capinfo;
          result->qual = sr->isr_rssi;
          result->noise = sr->isr_noise;
 +        /*
 +         * the rssi value reported by the kernel is in 0.5dB steps relative to
 +         * the reported noise floor. see ieee80211_node.h for details.
 +         */
 +        result->level = sr->isr_rssi / 2 + sr->isr_noise;
  
          pos = (u8 *)(result + 1);
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: eadler 
State-Changed-When: Thu Jun 13 21:13:32 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=170631 
>Unformatted:
