developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From 4f2f27ccf6133c9f51f798a872387aa15337b923 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Mon, 27 May 2024 19:06:04 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 133/223] mtk: mt76: mt7996: add mlo related debugfs knob |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | |
| 6 | Add the following debugfs knob |
| 7 | Per-bss link info |
| 8 | - /sys/kernel/debug/ieee80211/phy0/<interface>/mt76_link_info |
| 9 | Per-station link info |
| 10 | - /sys/kernel/debug/ieee80211/phy0/<interface>/stations/<mac address>/mt76_link_info |
| 11 | |
| 12 | Add TX MSDU failed, retried counts, and PER to mt76_links_info DebugFS knob. |
| 13 | Remove MSDU statistics from link_sta_info DebugFS knob, since MSDUs are MLD-wise, instead of link-wise, handled. |
| 14 | |
| 15 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 16 | Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 17 | --- |
| 18 | mt7996/debugfs.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++- |
| 19 | mt7996/main.c | 1 + |
| 20 | mt7996/mt7996.h | 1 + |
| 21 | 3 files changed, 119 insertions(+), 1 deletion(-) |
| 22 | |
| 23 | diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 24 | index 9a62dfda..bafbcda1 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 25 | --- a/mt7996/debugfs.c |
| 26 | +++ b/mt7996/debugfs.c |
| 27 | @@ -1330,11 +1330,128 @@ mt7996_queues_show(struct seq_file *s, void *data) |
| 28 | |
| 29 | DEFINE_SHOW_ATTRIBUTE(mt7996_queues); |
| 30 | |
| 31 | +static int |
| 32 | +mt7996_sta_links_info_show(struct seq_file *s, void *data) |
| 33 | +{ |
| 34 | + struct ieee80211_sta *sta = s->private; |
| 35 | + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 36 | + u64 tx_cnt = 0, tx_fails = 0, tx_retries = 0, rx_cnt = 0; |
| 37 | + struct mt7996_dev *dev = msta->vif->dev; |
| 38 | + unsigned long valid_links; |
| 39 | + u8 link_id; |
| 40 | + |
| 41 | + seq_printf(s, "primary link, link ID = %d\n", msta->pri_link); |
| 42 | + seq_printf(s, "secondary link, link ID = %d\n", msta->sec_link); |
| 43 | + seq_printf(s, "valid links = 0x%x\n", sta->valid_links); |
| 44 | + |
| 45 | + mutex_lock(&dev->mt76.mutex); |
| 46 | + valid_links = sta->valid_links ?: BIT(0); |
| 47 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 48 | + struct mt7996_link_sta *mlink = |
| 49 | + mlink_dereference_protected(msta, link_id); |
| 50 | + struct mt76_wcid *wcid; |
| 51 | + |
| 52 | + if (!mlink) |
| 53 | + continue; |
| 54 | + |
| 55 | + wcid = &mlink->wcid; |
| 56 | + |
| 57 | + tx_cnt += wcid->stats.tx_packets; |
| 58 | + tx_fails += wcid->stats.tx_packets_failed; |
| 59 | + tx_retries += wcid->stats.tx_packets_retried; |
| 60 | + rx_cnt += wcid->stats.rx_packets; |
| 61 | + |
| 62 | + seq_printf(s, "link%d: wcid=%d, phy=%d, link_valid=%d\n", |
| 63 | + wcid->link_id, wcid->idx, wcid->phy_idx, wcid->link_valid); |
| 64 | + } |
| 65 | + mutex_unlock(&dev->mt76.mutex); |
| 66 | + |
| 67 | + /* PER may be imprecise, because MSDU total and failed counts |
| 68 | + * are updated at different times. |
| 69 | + */ |
| 70 | + seq_printf(s, "TX MSDU Count: %llu\n", tx_cnt); |
| 71 | + seq_printf(s, "TX MSDU Fails: %llu (PER: %llu.%llu%%)\n", tx_fails, |
| 72 | + tx_cnt ? tx_fails * 1000 / tx_cnt / 10 : 0, |
| 73 | + tx_cnt ? tx_fails * 1000 / tx_cnt % 10 : 0); |
| 74 | + seq_printf(s, "TX MSDU Retries: %llu\n", tx_retries); |
| 75 | + seq_printf(s, "RX MSDU Count: %llu\n", rx_cnt); |
| 76 | + |
| 77 | + return 0; |
| 78 | +} |
| 79 | +DEFINE_SHOW_ATTRIBUTE(mt7996_sta_links_info); |
| 80 | + |
| 81 | void mt7996_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 82 | struct ieee80211_sta *sta, struct dentry *dir) |
| 83 | { |
| 84 | debugfs_create_file("fixed_rate", 0600, dir, sta, &fops_fixed_rate); |
| 85 | debugfs_create_file("hw-queues", 0400, dir, sta, &mt7996_queues_fops); |
| 86 | + debugfs_create_file("mt76_links_info", 0400, dir, sta, |
| 87 | + &mt7996_sta_links_info_fops); |
| 88 | +} |
| 89 | + |
| 90 | +static int |
| 91 | +mt7996_vif_links_info_show(struct seq_file *s, void *data) |
| 92 | +{ |
| 93 | + struct ieee80211_vif *vif = s->private; |
| 94 | + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 95 | + struct mt7996_dev *dev = mvif->dev; |
| 96 | + struct mt7996_bss_conf *mconf; |
| 97 | + struct mt7996_link_sta *mlink; |
| 98 | + unsigned long valid_links; |
| 99 | + u8 link_id, i; |
| 100 | + |
| 101 | + static const char* width_to_bw[] = { |
| 102 | + [NL80211_CHAN_WIDTH_40] = "40", |
| 103 | + [NL80211_CHAN_WIDTH_80] = "80", |
| 104 | + [NL80211_CHAN_WIDTH_80P80] = "80+80", |
| 105 | + [NL80211_CHAN_WIDTH_160] = "160", |
| 106 | + [NL80211_CHAN_WIDTH_5] = "5", |
| 107 | + [NL80211_CHAN_WIDTH_10] = "10", |
| 108 | + [NL80211_CHAN_WIDTH_20] = "20", |
| 109 | + [NL80211_CHAN_WIDTH_20_NOHT] = "20_NOHT", |
| 110 | + [NL80211_CHAN_WIDTH_320] = "320", |
| 111 | + }; |
| 112 | + |
| 113 | + seq_printf(s, "master link id = %d\n", mvif->master_link_id); |
| 114 | + seq_printf(s, "group mld id = %d\n", mvif->group_mld_id); |
| 115 | + seq_printf(s, "mld remap id = %d\n", mvif->mld_remap_id); |
| 116 | + |
| 117 | + seq_printf(s, "valid links = 0x%x\n", vif->valid_links); |
| 118 | + for (i = 0; i < __MT_MAX_BAND; i++) |
| 119 | + seq_printf(s, "band%d_link_id = %d\n", i, mvif->band_to_link[i]); |
| 120 | + |
| 121 | + mutex_lock(&dev->mt76.mutex); |
| 122 | + valid_links = vif->valid_links ?: BIT(0); |
| 123 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 124 | + mconf = mconf_dereference_protected(mvif, link_id); |
| 125 | + mlink = mlink_dereference_protected(&mvif->sta, link_id); |
| 126 | + |
| 127 | + if (!mconf || !mlink) |
| 128 | + continue; |
| 129 | + |
| 130 | + seq_printf(s, "- link[%02d]: bss_idx = %d, wcid = %d\n", |
| 131 | + mconf->link_id, mconf->mt76.idx, mlink->wcid.idx); |
| 132 | + seq_printf(s, " omac_idx = %d, own_mld_id=%d\n", |
| 133 | + mconf->mt76.omac_idx, mconf->own_mld_id); |
| 134 | + |
| 135 | + if (!mconf->phy->chanctx) |
| 136 | + continue; |
| 137 | + |
| 138 | + seq_printf(s, " band_idx=%d, channel=%d, bw%s\n", |
| 139 | + mconf->mt76.band_idx, |
| 140 | + mconf->phy->chanctx->chandef.chan->hw_value, |
| 141 | + width_to_bw[mconf->phy->chanctx->chandef.width]); |
| 142 | + } |
| 143 | + mutex_unlock(&dev->mt76.mutex); |
| 144 | + |
| 145 | + return 0; |
| 146 | +} |
| 147 | +DEFINE_SHOW_ATTRIBUTE(mt7996_vif_links_info); |
| 148 | + |
| 149 | +void mt7996_vif_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 150 | +{ |
| 151 | + debugfs_create_file("mt76_links_info", 0400, vif->debugfs_dir, vif, |
| 152 | + &mt7996_vif_links_info_fops); |
| 153 | } |
| 154 | |
| 155 | static void |
| 156 | @@ -1473,7 +1590,6 @@ mt7996_link_sta_info_show(struct seq_file *file, void *data) |
| 157 | seq_printf(file, "Statistics:\n"); |
| 158 | seq_printf(file, "\tTX:\n"); |
| 159 | seq_printf(file, "\t\tBytes: %llu\n", stats->tx_bytes); |
| 160 | - seq_printf(file, "\t\tMSDU Count: %u\n", stats->tx_packets); |
| 161 | seq_printf(file, "\t\tMPDU Count: %u\n", stats->tx_mpdus); |
| 162 | seq_printf(file, "\t\tMPDU Fails: %u (PER: %u.%u%%)\n", stats->tx_failed, |
| 163 | stats->tx_mpdus ? stats->tx_failed * 1000 / stats->tx_mpdus / 10 : 0, |
| 164 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 165 | index f67e1b5d..915a9f4f 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 166 | --- a/mt7996/main.c |
| 167 | +++ b/mt7996/main.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 168 | @@ -2845,6 +2845,7 @@ const struct ieee80211_ops mt7996_ops = { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 169 | .sta_add_debugfs = mt7996_sta_add_debugfs, |
| 170 | .link_sta_add_debugfs = mt7996_link_sta_add_debugfs, |
| 171 | // .link_add_debugfs = mt7996_link_add_debugfs, |
| 172 | + .vif_add_debugfs = mt7996_vif_add_debugfs, |
| 173 | #endif |
| 174 | .set_radar_background = mt7996_set_radar_background, |
| 175 | #ifdef CONFIG_NET_MEDIATEK_SOC_WED |
| 176 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 177 | index 9f58a793..984ae79e 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 178 | --- a/mt7996/mt7996.h |
| 179 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 180 | @@ -1251,6 +1251,7 @@ int mt7996_mcu_set_eml_omn(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 181 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 182 | void mt7996_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 183 | struct ieee80211_sta *sta, struct dentry *dir); |
| 184 | +void mt7996_vif_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif); |
| 185 | void mt7996_link_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 186 | struct ieee80211_link_sta *link_sta, |
| 187 | struct dentry *dir); |
| 188 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 189 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 190 | |