blob: 8ed1049f6d78e97775bb4175c0e04a32149b6161 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 4a9819d5ac8cef5b85c089698467053713619f86 Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Wed, 19 Jun 2024 12:04:46 +0800
4Subject: [PATCH 158/199] mtk: mt76: mt7996: rework debug prints
5
6Trim debug messages, and move some of them (especially mcu cmd) into
7tracing log.
8
9Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
10---
11 mt76_connac_mcu.c | 1 -
12 mt7996/mac.c | 3 ---
13 mt7996/main.c | 66 ++++++++++++++++++++++++++++-------------------
14 mt7996/mcu.c | 36 +++++++++++++-------------
15 mt7996/mt7996.h | 10 ++++++-
16 5 files changed, 67 insertions(+), 49 deletions(-)
17
18diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
19index 8d1036e1..ab7cf4a6 100644
20--- a/mt76_connac_mcu.c
21+++ b/mt76_connac_mcu.c
22@@ -432,7 +432,6 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
23 }
24
25 memcpy(basic->peer_addr, link_sta->addr, ETH_ALEN);
26- pr_info("%s: link %u addr [%pM]\n", __func__, link_sta->link_id, basic->peer_addr);
27 basic->qos = link_sta->sta->wme;
28 }
29 EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_basic_tlv);
30diff --git a/mt7996/mac.c b/mt7996/mac.c
31index a0406700..960b02dd 100644
32--- a/mt7996/mac.c
33+++ b/mt7996/mac.c
34@@ -2930,9 +2930,6 @@ void mt7996_scan_work(struct work_struct *work)
35 return;
36 }
37
38- wiphy_info(hw->wiphy, "hw scan %d MHz\n",
39- req->channels[phy->scan_chan_idx]->center_freq);
40-
41 phy->scan_chan = req->channels[phy->scan_chan_idx++];
42
43 if (!req->n_ssids ||
44diff --git a/mt7996/main.c b/mt7996/main.c
45index b59f72d0..cff2c527 100644
46--- a/mt7996/main.c
47+++ b/mt7996/main.c
48@@ -297,6 +297,9 @@ static void mt7996_remove_bss_conf(struct ieee80211_vif *vif,
49 if (!mlink || !mconf)
50 return;
51
52+ mt76_vif_dbg(vif, "band=%u, bss_idx=%u, link_id=%u, wcid=%u\n",
53+ mconf->phy->mt76->band_idx, mconf->mt76.idx, mconf->link_id, mlink->wcid.idx);
54+
55 phy = mconf->phy;
56 dev = phy->dev;
57 mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, false, false);
58@@ -448,8 +451,8 @@ static int mt7996_add_bss_conf(struct mt7996_phy *phy,
59 rcu_assign_pointer(mvif->link[link_id], mconf);
60 rcu_assign_pointer(mvif->sta.link[link_id], mlink);
61
62- mlo_dbg(phy, "bss_idx=%u, link_id=%u, wcid=%u\n",
63- mconf->mt76.idx, mconf->link_id, mlink->wcid.idx);
64+ mt76_vif_dbg(vif, "band=%u, bss_idx=%u, link_id=%u, wcid=%u\n",
65+ phy->mt76->band_idx, mconf->mt76.idx, mconf->link_id, mlink->wcid.idx);
66
67 return 0;
68 error:
69@@ -636,10 +639,11 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
70 add = vif->valid_links ?: BIT(0);
71 }
72
73- mlo_dbg(mt7996_hw_phy(hw), "cipher = 0x%x, icv_len = %u, iv_len = %u, hw_key_idx = %u, keyidx = %d, flags = 0x%x, link_id = %d, keylen = %u\n",
74- key->cipher, key->icv_len, key->iv_len, key->hw_key_idx, key->keyidx, key->flags, key->link_id, key->keylen);
75- // print_hex_dump(KERN_INFO , "", DUMP_PREFIX_OFFSET, 16, 1, key->key, key->keylen, false);
76- mlo_dbg(mt7996_hw_phy(hw), "add=%lx, valid_links=%x, active_links=%x\n", add, vif->valid_links, vif->active_links);
77+ if (sta)
78+ mt76_trace(vif, "keyidx=%d, link_bitmap=0x%lx (STA %pM)\n",
79+ key->keyidx, add, sta->addr);
80+ else
81+ mt76_trace(vif, "keyidx=%d, link_bitmap=0x%lx\n", key->keyidx, add);
82
83 mutex_lock(&dev->mt76.mutex);
84
85@@ -1216,7 +1220,8 @@ static int mt7996_add_link_sta(struct mt7996_dev *dev,
86 rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid);
87 mt76_wcid_init(&mlink->wcid);
88
89- mlo_dbg(mconf->phy, "wcid=%u, link_id=%u, link_addr=%pM, pri_link=%u, sec_link=%u\n", mlink->wcid.idx, link_id, link_sta->addr, msta->pri_link, msta->sec_link);
90+ mt76_vif_dbg(conf->vif, "STA %pM, wcid=%u, link_id=%u (%pM), pri_link=%u, sec_link=%u\n",
91+ sta->addr, mlink->wcid.idx, link_id, link_sta->addr, msta->pri_link, msta->sec_link);
92 }
93
94 if (!assoc)
95@@ -1255,7 +1260,7 @@ mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
96 if (!ieee80211_vif_is_mld(vif) || rem == sta->valid_links)
97 cancel_delayed_work(&mvif->beacon_mon_work);
98
99- mlo_dbg(mt7996_hw_phy(mvif->hw), "rem=%lu\n", rem);
100+ mt76_vif_dbg(vif, "removed_links=0x%lx\n", rem);
101 for_each_set_bit(link_id, &rem, IEEE80211_MLD_MAX_NUM_LINKS) {
102 struct mt7996_bss_conf *mconf =
103 mconf_dereference_protected(mvif, link_id);
104@@ -1282,7 +1287,7 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
105 unsigned int link_id;
106 int i, ret;
107
108- mlo_dbg(mt7996_hw_phy(mvif->hw), "add=%lu, assoc=%d\n", add, assoc);
109+ mt76_vif_dbg(vif, "added_links=0x%lx, assoc=%d\n", add, assoc);
110 for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
111 struct mt7996_bss_conf *mconf =
112 mconf_dereference_protected(mvif, link_id);
113@@ -1291,6 +1296,9 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
114 struct ieee80211_link_sta *link_sta =
115 link_sta_dereference_protected(sta, link_id);
116
117+ if (!mconf || !conf || !link_sta)
118+ continue;
119+
120 ret = mt7996_add_link_sta(dev, conf, mconf, link_sta, assoc);
121 if (ret)
122 goto error;
123@@ -1457,13 +1465,13 @@ static void mt7996_tx(struct ieee80211_hw *hw,
124 rcu_dereference(sta->link[link_id]);
125
126 if (!link_sta) {
127- mlo_dbg(mt7996_hw_phy(mvif->hw), "request TX on invalid link_id=%u, use primary link (id=%u) instead.\n",
128- link_id, msta->pri_link);
129+ mt76_vif_dbg(vif, "request TX on invalid link_id=%u, use primary link (id=%u) instead.\n",
130+ link_id, msta->pri_link);
131 link_id = msta->pri_link;
132 link_sta = rcu_dereference(sta->link[link_id]);
133
134 if (!link_sta) {
135- mlo_dbg(mt7996_hw_phy(mvif->hw), "primary link became invalid, give up the TX\n");
136+ mt76_vif_dbg(vif, "primary link became invalid, give up the TX\n");
137 goto unlock;
138 }
139 }
140@@ -2495,6 +2503,7 @@ mt7996_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
141 struct mt7996_bss_conf *mconf;
142 int ret;
143
144+ mt76_vif_dbg(vif, "trigger scan on mt76 band %u\n", phy->mt76->band_idx);
145 mutex_lock(&phy->dev->mt76.mutex);
146 if (WARN_ON(phy->scan_req || phy->scan_chan)) {
147 mutex_unlock(&phy->dev->mt76.mutex);
148@@ -2624,7 +2633,7 @@ mt7996_add_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf)
149 struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
150 int ret;
151
152- wiphy_info(hw->wiphy, "%s: add %u\n", __func__, conf->def.chan->hw_value);
153+ mt76_dbg(hw, "add %u on mt76 band %d\n", conf->def.chan->hw_value, phy->mt76->band_idx);
154 mutex_lock(&phy->dev->mt76.mutex);
155
156 if (ctx->assigned) {
157@@ -2663,7 +2672,7 @@ mt7996_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co
158 struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
159 struct mt7996_phy *phy = ctx->phy;
160
161- wiphy_info(hw->wiphy, "%s: remove %u\n", __func__, conf->def.chan->hw_value);
162+ mt76_dbg(hw, "remove %u\n", conf->def.chan->hw_value);
163 cancel_delayed_work_sync(&phy->scan_work);
164 cancel_delayed_work_sync(&phy->mt76->mac_work);
165
166@@ -2683,13 +2692,14 @@ mt7996_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co
167 struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
168 struct mt7996_phy *phy = ctx->phy;
169
170- wiphy_info(hw->wiphy, "%s: change %u, 0x%x\n", __func__, conf->def.chan->hw_value, changed);
171 if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH ||
172 changed & IEEE80211_CHANCTX_CHANGE_RADAR) {
173 ctx->chandef = conf->def;
174 phy->mt76->radar_enabled = conf->radar_enabled;
175
176 mt7996_set_channel(phy, &ctx->chandef);
177+
178+ mt76_dbg(hw, "change to %u, 0x%x\n", conf->def.chan->hw_value, changed);
179 }
180 }
181
182@@ -2705,9 +2715,8 @@ mt7996_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
183 u8 link_id = link_conf->link_id;
184 int ret;
185
186- wiphy_info(hw->wiphy, "Assign VIF (addr: %pM, type: %d, link_id: %d) to channel context: %d MHz\n",
187- vif->addr, vif->type, link_conf->link_id,
188- conf->def.chan->center_freq);
189+ mt76_vif_dbg(vif, "assign link_id %u to %d MHz\n", link_conf->link_id,
190+ conf->def.chan->center_freq);
191
192 mutex_lock(&phy->dev->mt76.mutex);
193
194@@ -2747,9 +2756,8 @@ mt7996_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
195 struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
196 struct mt7996_phy *phy = ctx->phy;
197
198- wiphy_info(hw->wiphy, "Remove VIF (addr: %pM, type: %d, link_id: %d) from channel context: %d MHz\n",
199- vif->addr, vif->type, link_conf->link_id,
200- conf->def.chan->center_freq);
201+ mt76_vif_dbg(vif, "remove link %u from %d MHz\n",
202+ link_conf->link_id, conf->def.chan->center_freq);
203 cancel_delayed_work_sync(&phy->scan_work);
204
205 mutex_lock(&phy->dev->mt76.mutex);
206@@ -2778,9 +2786,15 @@ mt7996_switch_vif_chanctx(struct ieee80211_hw *hw,
207 if (vifs[i].old_ctx == vifs[i].new_ctx)
208 continue;
209
210- wiphy_info(hw->wiphy, "%s: old=%d, new=%d\n",
211- __func__, vifs[i].old_ctx->def.chan->hw_value,
212- vifs[i].new_ctx->def.chan->hw_value);
213+ mt76_vif_dbg(vifs[i].vif,
214+ "chan=%d->%d, width=%d->%d, punct_bitmap=0x%04x->0x%04x, link=%u\n",
215+ vifs[i].old_ctx->def.chan->hw_value,
216+ vifs[i].new_ctx->def.chan->hw_value,
217+ vifs[i].old_ctx->def.width,
218+ vifs[i].new_ctx->def.width,
219+ vifs[i].old_ctx->def.punctured,
220+ vifs[i].new_ctx->def.punctured,
221+ vifs[i].link_conf->link_id);
222
223 mutex_lock(&dev->mt76.mutex);
224
225@@ -2830,7 +2844,7 @@ mt7996_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
226 unsigned int link_id;
227 int ret = 0;
228
229- mlo_dbg(phy, "old=%u, new=%u\n", old_links, new_links);
230+ mt76_vif_dbg(vif, "old=0x%x, new=0x%x\n", old_links, new_links);
231 if (old_links == new_links)
232 return 0;
233
234@@ -2876,7 +2890,7 @@ mt7996_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
235 unsigned long rem = old_links & ~new_links;
236 int ret = 0;
237
238- mlo_dbg(mt7996_hw_phy(hw), "old=%u, new=%u\n", old_links, new_links);
239+ mt76_vif_dbg(vif, "STA %pM old=0x%x, new=0x%x\n", sta->addr, old_links, new_links);
240 mutex_lock(&dev->mt76.mutex);
241
242 if (rem)
243diff --git a/mt7996/mcu.c b/mt7996/mcu.c
244index 6af45467..f848e3b7 100644
245--- a/mt7996/mcu.c
246+++ b/mt7996/mcu.c
247@@ -382,7 +382,6 @@ mt7996_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
248 if (!link_conf || !link_conf->csa_active || vif->type == NL80211_IFTYPE_STATION)
249 return;
250
251- pr_info("%s: link_id=%d\n", __func__, link_id);
252 mvif->cs_ready_links = 0;
253 mvif->cs_link_id = IEEE80211_LINK_UNSPECIFIED;
254 ieee80211_csa_finish(vif, link_id);
255@@ -1508,8 +1507,8 @@ mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
256 }
257
258 mld->own_mld_id = mconf->own_mld_id;
259- pr_info("%s: group_mld_id=%d own_mld_id=%d remap_idx=%d mld->addr[%pM]\n",
260- __func__, mld->group_mld_id, mld->own_mld_id, mld->remap_idx, mld->mac_addr);
261+ mt76_trace(vif, "group_mld_id=%d, own_mld_id=%d, remap_idx=%d, mld->addr[%pM]\n",
262+ mld->group_mld_id, mld->own_mld_id, mld->remap_idx, mld->mac_addr);
263 }
264
265 static void
266@@ -1662,8 +1661,8 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
267
268 memcpy(bss->bssid, conf->bssid, ETH_ALEN);
269
270- mlo_dbg(mconf->phy, "omac_idx=%d band_idx=%d wmm_idx=%d bss->bssid=%pM enable=%d\n",
271- bss->omac_idx, bss->band_idx, bss->wmm_idx, bss->bssid, enable);
272+ mt76_trace(vif, "band=%d, omac=%d, wmm_idx=%d, bssid=%pM, link=%d, en=%d\n",
273+ bss->band_idx, bss->omac_idx, bss->wmm_idx, bss->bssid, conf->link_id, enable);
274
275 bss->bcn_interval = cpu_to_le16(conf->beacon_int);
276 bss->dtim_period = conf->dtim_period;
277@@ -1802,8 +1801,6 @@ mt7996_mcu_sta_tx_cap(struct mt7996_dev *dev, struct mt76_vif *mvif,
278 tx_cap = (struct sta_rec_tx_cap *)tlv;
279 tx_cap->ampdu_limit_en = true;
280
281- dev_info(dev->mt76.dev, "%s: limit wcid %d ampdu to 512\n", __func__, wcid->idx);
282-
283 return mt76_mcu_skb_send_msg(&dev->mt76, skb,
284 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
285 }
286@@ -2961,8 +2958,8 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
287 /* starec basic */
288 mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, conf, link_sta,
289 enable, newly);
290- mlo_dbg(mconf->phy, "link=%u, newly=%d, en=%d\n",
291- mlink->wcid.link_id, newly, enable);
292+ mt76_trace(vif, "link=%u, wcid=%u, newly=%d, en=%d\n",
293+ mlink->wcid.link_id, mlink->wcid.idx, newly, enable);
294
295 if (!enable)
296 goto out;
297@@ -3022,6 +3019,8 @@ mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
298 struct tlv *tlv;
299 unsigned long valid_links = sta->valid_links;
300 unsigned int link_id;
301+ struct ieee80211_vif *vif = container_of((void *)msta->vif, struct ieee80211_vif,
302+ drv_priv);
303
304 mlink = mlink_dereference_protected(msta, msta->pri_link);
305 if (!mlink)
306@@ -3045,15 +3044,16 @@ mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
307 mld_setup->link_num = hweight16(sta->valid_links);
308
309 mld_setup_link = (struct mld_setup_link *)mld_setup->link_info;
310- mlo_dbg(mt7996_hw_phy(mlink->sta->vif->hw), "pri_link(%u) primary_id(%d) seconed_id(%d) wcid(%d), link_num(%d), mld_addr[%pM]\n",
311- msta->pri_link, mld_setup->primary_id, mld_setup->seconed_id, mld_setup->setup_wcid, mld_setup->link_num, mld_setup->mld_addr);
312+ mt76_trace(vif, "STA %pM pri_link=%u, pri_wcid=%u, sec_link=%u, sec_wcid=%u\n",
313+ sta->addr, msta->pri_link, le16_to_cpu(mld_setup->primary_id),
314+ msta->sec_link, le16_to_cpu(mld_setup->seconed_id));
315 for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) {
316 mlink = mlink_dereference_protected(msta, link_id);
317 mconf = mconf_dereference_protected(msta->vif, link_id);
318
319 mld_setup_link->wcid = cpu_to_le16(mlink->wcid.idx);
320 mld_setup_link->bss_idx = mconf->mt76.idx;
321- mlo_dbg(mt7996_hw_phy(mlink->sta->vif->hw), "link_id(%d) wcid(%d) bss_idx(%d)\n",
322+ mt76_trace(vif, "link_id(%d) wcid(%d) bss_idx(%d)\n",
323 link_id, mld_setup_link->wcid, mld_setup_link->bss_idx);
324 mld_setup_link++;
325 }
326@@ -3319,8 +3319,8 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
327 return mt7996_mcu_muar_config(phy, conf, mconf, false, enable);
328
329 memcpy(data.tlv.omac_addr, conf->addr, ETH_ALEN);
330- mlo_dbg(phy, "omac=%u, band=%u, addr=%pM, en=%d\n",
331- data.hdr.omac_idx,data.hdr.band_idx, data.tlv.omac_addr, enable);
332+ mt76_trace(conf->vif, "band=%u, omac=%u, addr=%pM, en=%d\n",
333+ data.hdr.band_idx, data.hdr.omac_idx, data.tlv.omac_addr, enable);
334 return mt76_mcu_send_msg(&dev->mt76, MCU_WMWA_UNI_CMD(DEV_INFO_UPDATE),
335 &data, sizeof(data), true);
336 }
337@@ -6533,10 +6533,10 @@ int mt7996_mcu_set_eml_omn(struct ieee80211_hw *hw,
338 }
339 }
340
341- mlo_dbg(mconf->phy, "link:%u, wcid:%d, control:%x, mode:%d, bmp:%x\n",
342- mlink->wcid.link_id, mlink->wcid.idx, eml_omn->control,
343- !!(eml_omn->control & EML_OMN_CONTROL_EMLSR_MODE),
344- eml_op->bitmap);
345+ mt76_vif_dbg(vif, "link:%u, wcid:%d, control:%x, mode:%d, bmp:%x\n",
346+ mlink->wcid.link_id, mlink->wcid.idx, eml_omn->control,
347+ !!(eml_omn->control & EML_OMN_CONTROL_EMLSR_MODE),
348+ eml_op->bitmap);
349
350 return mt76_mcu_skb_send_msg(&dev->mt76, skb,
351 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
352diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
353index 05bdc437..612e849c 100644
354--- a/mt7996/mt7996.h
355+++ b/mt7996/mt7996.h
356@@ -982,7 +982,15 @@ mt7996_get_link_wcid(struct mt7996_dev *dev, u16 idx, u8 band_idx)
357 return &mlink->wcid;
358 }
359
360-#define mlo_dbg(phy, fmt, ...) wiphy_info(phy->mt76->hw->wiphy, "%s: " fmt, __func__, ##__VA_ARGS__)
361+#define mt76_dbg(hw, fmt, ...) wiphy_info(hw->wiphy, "%s: " fmt, __func__, ##__VA_ARGS__)
362+#define mt76_vif_dbg(vif, fmt, ...) \
363+ pr_info("%s: %s: " fmt, \
364+ ieee80211_vif_to_wdev(vif)->netdev->name, \
365+ __func__, ##__VA_ARGS__)
366+#define mt76_trace(vif, fmt, ...) \
367+ trace_printk("(%s) " fmt, \
368+ ieee80211_vif_to_wdev(vif)->netdev->name, \
369+ ##__VA_ARGS__)
370
371 extern const struct ieee80211_ops mt7996_ops;
372 extern struct pci_driver mt7996_pci_driver;
373--
3742.18.0
375