On Sun, Jun 26, 2022 at 07:48:46PM +1000, Jonathan Gray wrote:
> sta.rssi is later used which is 'Fields valid for ver >= 4'
> but it seems with the earlier zeroing the use here should be fine?

Thanks! I missed that.

Testing suggests it makes more sense to keep the RSSI value which
was discovered during the scan phase.

With the new patch below ifconfig shows -51dBm.
With the previous patch ifconfig showed -70dBm for the same AP (with
client/AP location unchanged).

diff /usr/src
commit - 9badb9ad8932c12f4ece484255eb2703a2518c17
path + /usr/src
blob - 0c9c948115a0c115a43bd365ad4e389ba694c4a8
file + sys/dev/ic/bwfm.c
--- sys/dev/ic/bwfm.c
+++ sys/dev/ic/bwfm.c
@@ -703,22 +703,24 @@ bwfm_update_node(void *arg, struct ieee80211_node *ni)
        if (!IEEE80211_ADDR_EQ(ni->ni_macaddr, sta.ea))
                return;
 
-       if (le16toh(sta.ver) < 4)
+       if (le16toh(sta.ver) < 3)
                return;
 
        flags = le32toh(sta.flags);
        if ((flags & BWFM_STA_SCBSTATS) == 0)
                return;
 
-       rssi = 0;
-       for (i = 0; i < BWFM_ANT_MAX; i++) {
-               if (sta.rssi[i] >= 0)
-                       continue;
-               if (rssi == 0 || sta.rssi[i] > rssi)
-                       rssi = sta.rssi[i];
+       if (le16toh(sta.ver) >= 4) {
+               rssi = 0;
+               for (i = 0; i < BWFM_ANT_MAX; i++) {
+                       if (sta.rssi[i] >= 0)
+                               continue;
+                       if (rssi == 0 || sta.rssi[i] > rssi)
+                               rssi = sta.rssi[i];
+               }
+               if (rssi)
+                       ni->ni_rssi = rssi;
        }
-       if (rssi)
-               ni->ni_rssi = rssi;
 
        txrate = le32toh(sta.tx_rate); /* in kbit/s */
        if (txrate == 0xffffffff) /* Seen this happening during association. */

Reply via email to