git: a4c17ecf962d - main - LinuxKPI: 802.11: introduce a debug flag for scan/beacon logging

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 29 Aug 2025 13:19:04 UTC
The branch main has been updated by bz:

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

commit a4c17ecf962d573b339a3c1e963ed0d041716720
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-08-28 21:41:41 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-08-29 13:18:43 +0000

    LinuxKPI: 802.11: introduce a debug flag for scan/beacon logging
    
    Split the scan logging up into scan and scan/beacon in order to
    not log every beacon if we are trying to debug the scan machinery
    but not the actual results.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 8 ++++----
 sys/compat/linuxkpi/common/src/linux_80211.h | 6 ++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index ad3e6c043c94..cf0aca4493aa 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -7348,7 +7348,7 @@ lkpi_rx_log_beacon(struct mbuf *m, struct lkpi_hw *lhw,
 	}
 
 	/* We print skb, skb->data, m as we are seeing 'ghost beacons'. */
-	TRACE_SCAN(lhw->ic, "Beacon: scan_flags %b, band %s freq %u chan %-4d "
+	TRACE_SCAN_BEACON(lhw->ic, "Beacon: scan_flags %b, band %s freq %u chan %-4d "
 	    "len %d { %#06x %#06x %6D %6D %6D %#06x %ju %u %#06x SSID '%s' }",
 	    lhw->scan_flags, LKPI_LHW_SCAN_BITS,
 	    lkpi_nl80211_band_name(rx_status->band), rx_status->freq,
@@ -7421,11 +7421,11 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
 	 * We use the mbuf here as otherwise the variable part might
 	 * be in skb frags.
 	 */
-	if (is_beacon && ((linuxkpi_debug_80211 & D80211_SCAN) != 0))
+	if (is_beacon && ((linuxkpi_debug_80211 & D80211_SCAN_BEACON) != 0))
 		lkpi_rx_log_beacon(m, lhw, rx_status);
 
 	if (is_beacon && (linuxkpi_debug_80211 & D80211_TRACE_RX_BEACONS) == 0 &&
-	   (linuxkpi_debug_80211 & D80211_SCAN) == 0)
+	   (linuxkpi_debug_80211 & D80211_SCAN_BEACON) == 0)
 		goto no_trace_beacons;
 
 	if (linuxkpi_debug_80211 & D80211_TRACE_RX)
@@ -7441,7 +7441,7 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
 
 	/* Implement a dump_rxcb() !!! */
 	if ((linuxkpi_debug_80211 & D80211_TRACE_RX) != 0 ||
-	    (linuxkpi_debug_80211 & D80211_SCAN) != 0)
+	    (linuxkpi_debug_80211 & D80211_SCAN_BEACON) != 0)
 		printf("TRACE-RX: %s: RXCB: %ju %ju %u, %b, %u, %#0x, %#0x, "
 		    "%u band %u, %u { %d %d %d %d }, %d, %#x %#x %#x %#x %u %u %u\n",
 			__func__,
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h
index 2b93eab03c27..0dfcd7646c34 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.h
+++ b/sys/compat/linuxkpi/common/src/linux_80211.h
@@ -60,6 +60,7 @@
 #define	D80211_TRACE		0x00000010
 #define	D80211_TRACEOK		0x00000020
 #define	D80211_SCAN		0x00000040
+#define	D80211_SCAN_BEACON	0x00000080
 #define	D80211_TRACE_TX		0x00000100
 #define	D80211_TRACE_TX_DUMP	0x00000200
 #define	D80211_TRACE_RX		0x00001000
@@ -81,8 +82,13 @@
     if (linuxkpi_debug_80211 & D80211_SCAN)				\
 	printf("%s:%d: %s SCAN " fmt "\n",				\
 	    __func__, __LINE__, ic->ic_name, ##__VA_ARGS__)
+#define	TRACE_SCAN_BEACON(ic, fmt, ...)					\
+    if (linuxkpi_debug_80211 & D80211_SCAN_BEACON)			\
+	printf("%s:%d: %s SCAN " fmt "\n",				\
+	    __func__, __LINE__, ic->ic_name, ##__VA_ARGS__)
 #else
 #define	TRACE_SCAN(...)		do {} while (0)
+#define	TRACE_SCAN_BEACON(...)	do {} while (0)
 #endif
 
 #define	IMPROVE_TXQ(...)						\