git: e674ddec0b41 - main - iwlwifi: add FreeBSD specific debugging

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 17 Aug 2022 16:20:41 UTC
The branch main has been updated by bz:

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

commit e674ddec0b4138274539587fe9336b577ff1242a
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-08-17 16:11:47 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-08-17 16:11:47 +0000

    iwlwifi: add FreeBSD specific debugging
    
    "Invalid TXQ id" and "Queue <n> is stuck <x> <y>" are two errors seen
    more commonly by FreeBSD users.  Try to gather some extra data the
    "easy way" adding more error logging for these situations in the hope
    to find a clue or at least do more targetd debugging in the future.
    Note that for one of the errors the Linux Intel driver has a TODO to
    print register data.  If that will show up in future versions of the
    driver this may also help.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/contrib/dev/iwlwifi/mvm/tx.c   |  5 +++++
 sys/contrib/dev/iwlwifi/queue/tx.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/sys/contrib/dev/iwlwifi/mvm/tx.c b/sys/contrib/dev/iwlwifi/mvm/tx.c
index 8125bb76f59e..303d9b1e5a02 100644
--- a/sys/contrib/dev/iwlwifi/mvm/tx.c
+++ b/sys/contrib/dev/iwlwifi/mvm/tx.c
@@ -1139,6 +1139,11 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
 	WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM);
 
 	if (WARN_ONCE(txq_id == IWL_MVM_INVALID_QUEUE, "Invalid TXQ id")) {
+#if defined(__FreeBSD__)
+		IWL_ERR(mvm, "fc %#06x sta_id %u tid %u txq_id %u mvm %p "
+		    "skb %p { len %u } info %p sta %p\n", fc, mvmsta->sta_id,
+		    tid, txq_id, mvm, skb, skb->len, info, sta);
+#endif
 		iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
 		spin_unlock(&mvmsta->lock);
 		return -1;
diff --git a/sys/contrib/dev/iwlwifi/queue/tx.c b/sys/contrib/dev/iwlwifi/queue/tx.c
index 3f6bda96bfb5..eb290a4fd06a 100644
--- a/sys/contrib/dev/iwlwifi/queue/tx.c
+++ b/sys/contrib/dev/iwlwifi/queue/tx.c
@@ -988,6 +988,19 @@ void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq)
 	if (trans->trans_cfg->use_tfh) {
 		IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id,
 			txq->read_ptr, txq->write_ptr);
+#if defined(__FreeBSD__)
+		/*
+		 * Dump some more queue and timer information to rule
+		 * out a LinuxKPI issues and gather some extra data.
+		 */
+		IWL_ERR(trans, "  need_update %d frozen %d ampdu %d "
+		   "now %ju stuck_timer.expires %ju "
+		   "frozen_expiry_remainder %ju wd_timeout %ju\n",
+		    txq->need_update, txq->frozen, txq->ampdu,
+		    (uintmax_t)jiffies, (uintmax_t)txq->stuck_timer.expires,
+		    (uintmax_t)txq->frozen_expiry_remainder,
+		    (uintmax_t)txq->wd_timeout);
+#endif
 		/* TODO: access new SCD registers and dump them */
 		return;
 	}