Re: athn/ar5008: fix rssi reporting

2017-11-27 Thread Kevin Lo
On Mon, Nov 27, 2017 at 09:39:03PM +0100, Stefan Sperling wrote:
> 
> This makes athn(4) report similar RSSI values as iwn(4) does,
> instead of bugos positive dBm values. The driver forgot about
> adding the default noisefloor to measured RSSI values.
> 
> The same is already done in the USB athn(4) driver.
> 
> It looks like noisefloor calibration is not yet enabled in this driver.
> If that was fixed later, we could read the actual noisefloor from hardware.
> Enabling noisefloor calibration might also address other known issues.

ok kevlo@

> Index: ar5008.c
> ===
> RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
> retrieving revision 1.45
> diff -u -p -r1.45 ar5008.c
> --- ar5008.c  17 Jul 2017 14:25:29 -  1.45
> +++ ar5008.c  27 Nov 2017 20:24:20 -
> @@ -925,6 +925,7 @@ ar5008_rx_process(struct athn_softc *sc)
>   /* Send the frame to the 802.11 layer. */
>   rxi.rxi_flags = 0;  /* XXX */
>   rxi.rxi_rssi = MS(ds->ds_status4, AR_RXS4_RSSI_COMBINED);
> + rxi.rxi_rssi += AR_DEFAULT_NOISE_FLOOR;
>   rxi.rxi_tstamp = ds->ds_status2;
>   ieee80211_input(ifp, m, ni, );
>  
> @@ -1927,7 +1928,7 @@ ar5008_bb_load_noisefloor(struct athn_so
>  
>   /* Restore noisefloor values to initial (max) values. */
>   for (i = 0; i < AR_MAX_CHAINS; i++)
> - nf[i] = nf_ext[i] = -50 * 2;
> + nf[i] = nf_ext[i] = AR_DEFAULT_NOISE_FLOOR;
>   ar5008_write_noisefloor(sc, nf, nf_ext);
>  }
>  
> Index: athnreg.h
> ===
> RCS file: /cvs/src/sys/dev/ic/athnreg.h,v
> retrieving revision 1.20
> diff -u -p -r1.20 athnreg.h
> --- athnreg.h 19 May 2017 11:42:48 -  1.20
> +++ athnreg.h 27 Nov 2017 20:13:48 -
> @@ -1449,6 +1449,8 @@
>  #define AR_CTL_2GHT407
>  #define AR_CTL_5GHT408
>  
> +#define AR_DEFAULT_NOISE_FLOOR (-95)
> +
>  /*
>   * Macros to access registers.
>   */
> 
> 



athn/ar5008: fix rssi reporting

2017-11-27 Thread Stefan Sperling
This makes athn(4) report similar RSSI values as iwn(4) does,
instead of bugos positive dBm values. The driver forgot about
adding the default noisefloor to measured RSSI values.

The same is already done in the USB athn(4) driver.

It looks like noisefloor calibration is not yet enabled in this driver.
If that was fixed later, we could read the actual noisefloor from hardware.
Enabling noisefloor calibration might also address other known issues.

Index: ar5008.c
===
RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
retrieving revision 1.45
diff -u -p -r1.45 ar5008.c
--- ar5008.c17 Jul 2017 14:25:29 -  1.45
+++ ar5008.c27 Nov 2017 20:24:20 -
@@ -925,6 +925,7 @@ ar5008_rx_process(struct athn_softc *sc)
/* Send the frame to the 802.11 layer. */
rxi.rxi_flags = 0;  /* XXX */
rxi.rxi_rssi = MS(ds->ds_status4, AR_RXS4_RSSI_COMBINED);
+   rxi.rxi_rssi += AR_DEFAULT_NOISE_FLOOR;
rxi.rxi_tstamp = ds->ds_status2;
ieee80211_input(ifp, m, ni, );
 
@@ -1927,7 +1928,7 @@ ar5008_bb_load_noisefloor(struct athn_so
 
/* Restore noisefloor values to initial (max) values. */
for (i = 0; i < AR_MAX_CHAINS; i++)
-   nf[i] = nf_ext[i] = -50 * 2;
+   nf[i] = nf_ext[i] = AR_DEFAULT_NOISE_FLOOR;
ar5008_write_noisefloor(sc, nf, nf_ext);
 }
 
Index: athnreg.h
===
RCS file: /cvs/src/sys/dev/ic/athnreg.h,v
retrieving revision 1.20
diff -u -p -r1.20 athnreg.h
--- athnreg.h   19 May 2017 11:42:48 -  1.20
+++ athnreg.h   27 Nov 2017 20:13:48 -
@@ -1449,6 +1449,8 @@
 #define AR_CTL_2GHT40  7
 #define AR_CTL_5GHT40  8
 
+#define AR_DEFAULT_NOISE_FLOOR (-95)
+
 /*
  * Macros to access registers.
  */