From a60e1442ba0356780a9da9cf266fd7eeb906e1de Mon Sep 17 00:00:00 2001 From: xue yunfei Date: Tue, 30 Dec 2025 20:02:59 +0800 Subject: [PATCH] debug ampdu sleep --- net/mac80211/agg-rx.c | 72 ++++++++++++++++++++++++++++++++++++++----- net/mac80211/util.c | 24 +++++++++++++++ 2 files changed, 88 insertions(+), 8 deletions(-) diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index 49ec9bfb6..dd64652b9 100644 --- a/net/mac80211/agg-rx.c +++ b/net/mac80211/agg-rx.c @@ -74,34 +74,87 @@ void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, tid_rx = rcu_dereference_protected(sta->ampdu_mlme.tid_rx[tid], lockdep_is_held(&sta->ampdu_mlme.mtx)); - if (!test_bit(tid, sta->ampdu_mlme.agg_session_valid)) + printk(KERN_INFO "mac80211: Rx BA session stop requested for %pM tid %u %s reason: %d tx: %d\n", + sta->sta.addr, tid, + initiator == WLAN_BACK_RECIPIENT ? "recipient" : "initiator", + (int)reason, tx); + + if (!test_bit(tid, sta->ampdu_mlme.agg_session_valid)) { + printk(KERN_INFO "mac80211: Rx BA session for %pM tid %u is not valid, skip\n", + sta->sta.addr, tid); return; + } RCU_INIT_POINTER(sta->ampdu_mlme.tid_rx[tid], NULL); __clear_bit(tid, sta->ampdu_mlme.agg_session_valid); - ht_dbg(sta->sdata, - "Rx BA session stop requested for %pM tid %u %s reason: %d\n", - sta->sta.addr, tid, - initiator == WLAN_BACK_RECIPIENT ? "recipient" : "initiator", - (int)reason); + printk(KERN_INFO "mac80211: Rx BA session cleared for %pM tid %u, tid_rx: %p\n", + sta->sta.addr, tid, tid_rx); +#if 0 + /* Don't stop hardware RX BA during suspend, stop it in reconfig instead */ + /* Check WLAN_STA_BLOCK_BA flag which is set during suspend */ + if (!test_sta_flag(sta, WLAN_STA_BLOCK_BA)) { + printk(KERN_INFO "mac80211: Stopping hardware RX BA for %pM tid %u\n", + sta->sta.addr, tid); + if (drv_ampdu_action(local, sta->sdata, ¶ms)) + sdata_info(sta->sdata, + "HW problem - can not stop rx aggregation for %pM tid %d\n", + sta->sta.addr, tid); + else + printk(KERN_INFO "mac80211: Hardware RX BA stopped successfully for %pM tid %u\n", + sta->sta.addr, tid); + } else { + printk(KERN_INFO "mac80211: Skipping hardware RX BA stop for %pM tid %u (WLAN_STA_BLOCK_BA set)\n", + sta->sta.addr, tid); + } +#else + printk(KERN_INFO "mac80211: Stopping hardware RX BA for %pM tid %u\n", + sta->sta.addr, tid); if (drv_ampdu_action(local, sta->sdata, ¶ms)) sdata_info(sta->sdata, "HW problem - can not stop rx aggregation for %pM tid %d\n", sta->sta.addr, tid); + else + printk(KERN_INFO "mac80211: Hardware RX BA stopped successfully for %pM tid %u\n", + sta->sta.addr, tid); +#endif /* check if this is a self generated aggregation halt */ - if (initiator == WLAN_BACK_RECIPIENT && tx) +#if 1 + /* Don't send DELBA during suspend/resume to keep BA sessions alive */ + /* Check WLAN_STA_BLOCK_BA flag which is set during suspend */ + if (initiator == WLAN_BACK_RECIPIENT && tx && + !test_sta_flag(sta, WLAN_STA_BLOCK_BA)) { + printk(KERN_INFO "mac80211: Sending DELBA for %pM tid %u reason: %d\n", + sta->sta.addr, tid, reason); + ieee80211_send_delba(sta->sdata, sta->sta.addr, + tid, WLAN_BACK_RECIPIENT, reason); + } else if (initiator == WLAN_BACK_RECIPIENT && tx) { + printk(KERN_INFO "mac80211: Skipping DELBA for %pM tid %u (WLAN_STA_BLOCK_BA set)\n", + sta->sta.addr, tid); + } +#else + if (initiator == WLAN_BACK_RECIPIENT && tx) { + printk(KERN_INFO "mac80211: Sending DELBA for %pM tid %u reason: %d\n", + sta->sta.addr, tid, reason); ieee80211_send_delba(sta->sdata, sta->sta.addr, tid, WLAN_BACK_RECIPIENT, reason); + } +#endif /* * return here in case tid_rx is not assigned - which will happen if * IEEE80211_HW_SUPPORTS_REORDERING_BUFFER is set. */ - if (!tid_rx) + if (!tid_rx) { + printk(KERN_INFO "mac80211: Rx BA session stop complete for %pM tid %u (no tid_rx, hardware managed)\n", + sta->sta.addr, tid); return; + } + + printk(KERN_INFO "mac80211: Cleaning up software RX BA resources for %pM tid %u\n", + sta->sta.addr, tid); del_timer_sync(&tid_rx->session_timer); @@ -112,6 +165,9 @@ void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, del_timer_sync(&tid_rx->reorder_timer); call_rcu(&tid_rx->rcu_head, ieee80211_free_tid_rx); + + printk(KERN_INFO "mac80211: Rx BA session stop complete for %pM tid %u\n", + sta->sta.addr, tid); } void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 6223af1c3..349979a13 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -2537,6 +2537,30 @@ int ieee80211_reconfig(struct ieee80211_local *local) ieee80211_sta_restart(sdata); } +#if 0 + /* After full recovery, tear down all BA sessions completely */ + if (ieee80211_hw_check(hw, AMPDU_AGGREGATION) && suspended) { + printk(KERN_INFO "mac80211: After full recovery, tearing down all BA sessions completely\n"); + mutex_lock(&local->sta_mtx); + list_for_each_entry(sta, &local->sta_list, list) { + /* Completely tear down all BA sessions after recovery */ + printk(KERN_INFO "mac80211: Tearing down all BA sessions for STA %pM\n", + sta->sta.addr); + ieee80211_sta_tear_down_BA_sessions(sta, + AGG_STOP_LOCAL_REQUEST); + printk(KERN_INFO "mac80211: BA sessions torn down for STA %pM\n", + sta->sta.addr); + } + mutex_unlock(&local->sta_mtx); + printk(KERN_INFO "mac80211: All BA sessions torn down after recovery\n"); + } else { + if (!ieee80211_hw_check(hw, AMPDU_AGGREGATION)) + printk(KERN_INFO "mac80211: Skipping BA teardown (AMPDU_AGGREGATION not supported)\n"); + if (!suspended) + printk(KERN_INFO "mac80211: Skipping BA teardown (not from suspend recovery)\n"); + } +#endif + mod_timer(&local->sta_cleanup, jiffies + 1); #else WARN_ON(1); -- 2.43.0