git: 04efa18f83d1 - main - net80211: add debugging information

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 26 Dec 2021 17:35:18 UTC
The branch main has been updated by bz:

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

commit 04efa18f83d12dca2b69dd4cdb626f92e5ce64f0
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2021-12-26 17:25:57 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2021-12-26 17:25:57 +0000

    net80211: add debugging information
    
    Add more STATE / DEBUG probes and enhance the output of one in order
    to track state changes triggered by "ack" (or not).
    This helped to narrow down causes from drivers or the LinuxKPI 802.11
    compat framework which kept us in a scan -> auth -> scan loop.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/net80211/ieee80211_node.c   |  3 +++
 sys/net80211/ieee80211_output.c | 18 +++++++++++++++++-
 sys/net80211/ieee80211_proto.c  |  4 ++--
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index 95bed7821d16..80694c650ed4 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -895,6 +895,9 @@ ieee80211_sta_join1(struct ieee80211_node *selbs)
 			 * us to try to re-authenticate if we are operating
 			 * as a station.
 			 */
+			IEEE80211_DPRINTF(vap, IEEE80211_MSG_AUTH,
+			    "%s %p<%s> -> AUTH, FC0_SUBTYPE_DEAUTH\n",
+			    __func__, selbs, ether_sprintf(selbs->ni_macaddr));
 			ieee80211_new_state(vap, IEEE80211_S_AUTH,
 				IEEE80211_FC0_SUBTYPE_DEAUTH);
 		}
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 9b1898df7b10..66d659af0866 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -3378,6 +3378,12 @@ ieee80211_tx_mgt_timeout(void *arg)
 {
 	struct ieee80211vap *vap = arg;
 
+	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
+	    "vap %p mode %s state %s flags %#x & %#x\n", vap,
+	    ieee80211_opmode_name[vap->iv_opmode],
+	    ieee80211_state_name[vap->iv_state],
+	    vap->iv_ic->ic_flags, IEEE80211_F_SCAN);
+
 	IEEE80211_LOCK(vap->iv_ic);
 	if (vap->iv_state != IEEE80211_S_INIT &&
 	    (vap->iv_ic->ic_flags & IEEE80211_F_SCAN) == 0) {
@@ -3423,6 +3429,11 @@ ieee80211_tx_mgt_cb(struct ieee80211_node *ni, void *arg, int status)
 	 * XXX what happens if !acked but response shows up before callback?
 	 */
 	if (vap->iv_state == ostate) {
+		IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
+		    "ni %p mode %s state %s ostate %d arg %p status %d\n", ni,
+		    ieee80211_opmode_name[vap->iv_opmode],
+		    ieee80211_state_name[vap->iv_state], ostate, arg, status);
+
 		callout_reset(&vap->iv_mgtsend,
 			status == 0 ? IEEE80211_TRANS_WAIT*hz : 0,
 			ieee80211_tx_mgt_timeout, vap);
@@ -4170,8 +4181,13 @@ ieee80211_tx_complete(struct ieee80211_node *ni, struct mbuf *m, int status)
 				if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
 		} else
 			if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
-		if (m->m_flags & M_TXCB)
+		if (m->m_flags & M_TXCB) {
+			IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
+			   "ni %p vap %p mode %s state %s m %p status %d\n", ni, ni->ni_vap,
+			   ieee80211_opmode_name[ni->ni_vap->iv_opmode],
+			   ieee80211_state_name[ni->ni_vap->iv_state], m, status);
 			ieee80211_process_callback(ni, m, status);
+		}
 		ieee80211_free_node(ni);
 	}
 	m_freem(m);
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index ad27275d8cfb..98a04e5251f0 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -2654,8 +2654,8 @@ ieee80211_new_state_locked(struct ieee80211vap *vap,
 	}
 	ostate = vap->iv_state;
 	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
-	    "%s: %s -> %s (nrunning %d nscanning %d)\n", __func__,
-	    ieee80211_state_name[ostate], ieee80211_state_name[nstate],
+	    "%s: %s -> %s (arg %d) (nrunning %d nscanning %d)\n", __func__,
+	    ieee80211_state_name[ostate], ieee80211_state_name[nstate], arg,
 	    nrunning, nscanning);
 	switch (nstate) {
 	case IEEE80211_S_SCAN: