git: d201e4e84919 - main - wtap: use typed rssi and noise floor values

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 15 May 2026 21:59:45 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=d201e4e8491901d1de6bcaeb581a0bf958bf86f2

commit d201e4e8491901d1de6bcaeb581a0bf958bf86f2
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-05-13 21:14:39 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-05-15 21:59:07 +0000

    wtap: use typed rssi and noise floor values
    
    Adjust the rssi and nf arguments to typed int8_t and adjust the maths
    for rssi to be consistant with what net80211 expects.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Reviewed by:    lwhsu, adrian
    Differential Revision: https://reviews.freebsd.org/D57020
---
 sys/dev/wtap/if_wtap.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c
index dd332c538c8f..376b63e38f2b 100644
--- a/sys/dev/wtap/if_wtap.c
+++ b/sys/dev/wtap/if_wtap.c
@@ -495,6 +495,7 @@ wtap_rx_proc(void *arg, int npending)
 	struct mbuf *m;
 	struct ieee80211_node *ni;
 	struct wtap_buf *bf;
+	int8_t rssi, nf;
 
 #if 0
 	DWTAP_PRINTF("%s\n", __func__);
@@ -528,6 +529,15 @@ wtap_rx_proc(void *arg, int npending)
 		ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
 #endif
 
+		/*
+		 * Use arbitrary but sane values, and do the correct conversion
+		 * for net80211 using 0.5 dBm values relative to the noise floor.
+		 */
+		nf = -95;
+		rssi = 42;
+		rssi -= nf;
+		rssi *= 2;
+
 		/*
 		 * Locate the node for sender, track state, and then
 		 * pass the (referenced) node up to the 802.11 layer
@@ -540,10 +550,10 @@ wtap_rx_proc(void *arg, int npending)
 			/*
 			 * Sending station is known, dispatch directly.
 			 */
-			ieee80211_input(ni, m, 1<<7, 10);
+			ieee80211_input(ni, m, rssi, nf);
 			ieee80211_free_node(ni);
 		} else {
-			ieee80211_input_all(ic, m, 1<<7, 10);
+			ieee80211_input_all(ic, m, rssi, nf);
 		}
 		
 		/* The mbufs are freed by the Net80211 stack */