debugfs.c (78562b2cafc61a0c08dc949eacb942ac756aae37) | debugfs.c (975e122ddb7cd6f67bff974d2ea00c5568d2014c) |
---|---|
1// SPDX-License-Identifier: ISC 2/* Copyright (C) 2020 MediaTek Inc. */ 3 4#include "mt7921.h" 5 6static int 7mt7921_reg_set(void *data, u64 val) 8{ | 1// SPDX-License-Identifier: ISC 2/* Copyright (C) 2020 MediaTek Inc. */ 3 4#include "mt7921.h" 5 6static int 7mt7921_reg_set(void *data, u64 val) 8{ |
9 struct mt7921_dev *dev = data; | 9 struct mt792x_dev *dev = data; |
10 11 mt7921_mutex_acquire(dev); 12 mt76_wr(dev, dev->mt76.debugfs_reg, val); 13 mt7921_mutex_release(dev); 14 15 return 0; 16} 17 18static int 19mt7921_reg_get(void *data, u64 *val) 20{ | 10 11 mt7921_mutex_acquire(dev); 12 mt76_wr(dev, dev->mt76.debugfs_reg, val); 13 mt7921_mutex_release(dev); 14 15 return 0; 16} 17 18static int 19mt7921_reg_get(void *data, u64 *val) 20{ |
21 struct mt7921_dev *dev = data; | 21 struct mt792x_dev *dev = data; |
22 23 mt7921_mutex_acquire(dev); 24 *val = mt76_rr(dev, dev->mt76.debugfs_reg); 25 mt7921_mutex_release(dev); 26 27 return 0; 28} 29 30DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt7921_reg_get, mt7921_reg_set, 31 "0x%08llx\n"); 32static int 33mt7921_fw_debug_set(void *data, u64 val) 34{ | 22 23 mt7921_mutex_acquire(dev); 24 *val = mt76_rr(dev, dev->mt76.debugfs_reg); 25 mt7921_mutex_release(dev); 26 27 return 0; 28} 29 30DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt7921_reg_get, mt7921_reg_set, 31 "0x%08llx\n"); 32static int 33mt7921_fw_debug_set(void *data, u64 val) 34{ |
35 struct mt7921_dev *dev = data; | 35 struct mt792x_dev *dev = data; |
36 37 mt7921_mutex_acquire(dev); 38 39 dev->fw_debug = (u8)val; 40 mt7921_mcu_fw_log_2_host(dev, dev->fw_debug); 41 42 mt7921_mutex_release(dev); 43 44 return 0; 45} 46 47static int 48mt7921_fw_debug_get(void *data, u64 *val) 49{ | 36 37 mt7921_mutex_acquire(dev); 38 39 dev->fw_debug = (u8)val; 40 mt7921_mcu_fw_log_2_host(dev, dev->fw_debug); 41 42 mt7921_mutex_release(dev); 43 44 return 0; 45} 46 47static int 48mt7921_fw_debug_get(void *data, u64 *val) 49{ |
50 struct mt7921_dev *dev = data; | 50 struct mt792x_dev *dev = data; |
51 52 *val = dev->fw_debug; 53 54 return 0; 55} 56 57DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7921_fw_debug_get, 58 mt7921_fw_debug_set, "%lld\n"); 59 60static void 61mt7921_ampdu_stat_read_phy(struct mt792x_phy *phy, 62 struct seq_file *file) 63{ | 51 52 *val = dev->fw_debug; 53 54 return 0; 55} 56 57DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7921_fw_debug_get, 58 mt7921_fw_debug_set, "%lld\n"); 59 60static void 61mt7921_ampdu_stat_read_phy(struct mt792x_phy *phy, 62 struct seq_file *file) 63{ |
64 struct mt7921_dev *dev = file->private; | 64 struct mt792x_dev *dev = file->private; |
65 int bound[15], range[4], i; 66 67 if (!phy) 68 return; 69 70 mt7921_mac_update_mib_stats(phy); 71 72 /* Tx ampdu stat */ --- 15 unchanged lines hidden (view full) --- 88 seq_puts(file, "\n"); 89 90 seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt); 91} 92 93static int 94mt7921_tx_stats_show(struct seq_file *file, void *data) 95{ | 65 int bound[15], range[4], i; 66 67 if (!phy) 68 return; 69 70 mt7921_mac_update_mib_stats(phy); 71 72 /* Tx ampdu stat */ --- 15 unchanged lines hidden (view full) --- 88 seq_puts(file, "\n"); 89 90 seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt); 91} 92 93static int 94mt7921_tx_stats_show(struct seq_file *file, void *data) 95{ |
96 struct mt7921_dev *dev = file->private; | 96 struct mt792x_dev *dev = file->private; |
97 struct mt792x_phy *phy = &dev->phy; 98 struct mt76_mib_stats *mib = &phy->mib; 99 int i; 100 101 mt7921_mutex_acquire(dev); 102 103 mt7921_ampdu_stat_read_phy(phy, file); 104 --- 13 unchanged lines hidden (view full) --- 118 return 0; 119} 120 121DEFINE_SHOW_ATTRIBUTE(mt7921_tx_stats); 122 123static int 124mt7921_queues_acq(struct seq_file *s, void *data) 125{ | 97 struct mt792x_phy *phy = &dev->phy; 98 struct mt76_mib_stats *mib = &phy->mib; 99 int i; 100 101 mt7921_mutex_acquire(dev); 102 103 mt7921_ampdu_stat_read_phy(phy, file); 104 --- 13 unchanged lines hidden (view full) --- 118 return 0; 119} 120 121DEFINE_SHOW_ATTRIBUTE(mt7921_tx_stats); 122 123static int 124mt7921_queues_acq(struct seq_file *s, void *data) 125{ |
126 struct mt7921_dev *dev = dev_get_drvdata(s->private); | 126 struct mt792x_dev *dev = dev_get_drvdata(s->private); |
127 int i; 128 129 mt7921_mutex_acquire(dev); 130 131 for (i = 0; i < 4; i++) { 132 u32 ctrl, val, qlen = 0; 133 int j; 134 --- 14 unchanged lines hidden (view full) --- 149 mt7921_mutex_release(dev); 150 151 return 0; 152} 153 154static int 155mt7921_queues_read(struct seq_file *s, void *data) 156{ | 127 int i; 128 129 mt7921_mutex_acquire(dev); 130 131 for (i = 0; i < 4; i++) { 132 u32 ctrl, val, qlen = 0; 133 int j; 134 --- 14 unchanged lines hidden (view full) --- 149 mt7921_mutex_release(dev); 150 151 return 0; 152} 153 154static int 155mt7921_queues_read(struct seq_file *s, void *data) 156{ |
157 struct mt7921_dev *dev = dev_get_drvdata(s->private); | 157 struct mt792x_dev *dev = dev_get_drvdata(s->private); |
158 struct { 159 struct mt76_queue *q; 160 char *queue; 161 } queue_map[] = { 162 { dev->mphy.q_tx[MT_TXQ_BE], "WFDMA0" }, 163 { dev->mt76.q_mcu[MT_MCUQ_WM], "MCUWM" }, 164 { dev->mt76.q_mcu[MT_MCUQ_FWDL], "MCUFWQ" }, 165 }; --- 40 unchanged lines hidden (view full) --- 206 mt7921_seq_puts_array(s, #prefix " (tmac)", \ 207 txpwr.data[TXPWR_MAC].rate, \ 208 ARRAY_SIZE(txpwr.data[TXPWR_MAC].rate)); \ 209}) 210 211static int 212mt7921_txpwr(struct seq_file *s, void *data) 213{ | 158 struct { 159 struct mt76_queue *q; 160 char *queue; 161 } queue_map[] = { 162 { dev->mphy.q_tx[MT_TXQ_BE], "WFDMA0" }, 163 { dev->mt76.q_mcu[MT_MCUQ_WM], "MCUWM" }, 164 { dev->mt76.q_mcu[MT_MCUQ_FWDL], "MCUFWQ" }, 165 }; --- 40 unchanged lines hidden (view full) --- 206 mt7921_seq_puts_array(s, #prefix " (tmac)", \ 207 txpwr.data[TXPWR_MAC].rate, \ 208 ARRAY_SIZE(txpwr.data[TXPWR_MAC].rate)); \ 209}) 210 211static int 212mt7921_txpwr(struct seq_file *s, void *data) 213{ |
214 struct mt7921_dev *dev = dev_get_drvdata(s->private); | 214 struct mt792x_dev *dev = dev_get_drvdata(s->private); |
215 struct mt7921_txpwr txpwr; 216 int ret; 217 218 mt7921_mutex_acquire(dev); 219 ret = mt7921_get_txpwr_info(dev, &txpwr); 220 mt7921_mutex_release(dev); 221 222 if (ret) --- 35 unchanged lines hidden (view full) --- 258 mt7921_print_txpwr_entry(HE996x2, he996x2); 259 260 return 0; 261} 262 263static int 264mt7921_pm_set(void *data, u64 val) 265{ | 215 struct mt7921_txpwr txpwr; 216 int ret; 217 218 mt7921_mutex_acquire(dev); 219 ret = mt7921_get_txpwr_info(dev, &txpwr); 220 mt7921_mutex_release(dev); 221 222 if (ret) --- 35 unchanged lines hidden (view full) --- 258 mt7921_print_txpwr_entry(HE996x2, he996x2); 259 260 return 0; 261} 262 263static int 264mt7921_pm_set(void *data, u64 val) 265{ |
266 struct mt7921_dev *dev = data; | 266 struct mt792x_dev *dev = data; |
267 struct mt76_connac_pm *pm = &dev->pm; 268 269 if (mt76_is_usb(&dev->mt76)) 270 return -EOPNOTSUPP; 271 272 mutex_lock(&dev->mt76.mutex); 273 274 if (val == pm->enable_user) --- 16 unchanged lines hidden (view full) --- 291 mutex_unlock(&dev->mt76.mutex); 292 293 return 0; 294} 295 296static int 297mt7921_pm_get(void *data, u64 *val) 298{ | 267 struct mt76_connac_pm *pm = &dev->pm; 268 269 if (mt76_is_usb(&dev->mt76)) 270 return -EOPNOTSUPP; 271 272 mutex_lock(&dev->mt76.mutex); 273 274 if (val == pm->enable_user) --- 16 unchanged lines hidden (view full) --- 291 mutex_unlock(&dev->mt76.mutex); 292 293 return 0; 294} 295 296static int 297mt7921_pm_get(void *data, u64 *val) 298{ |
299 struct mt7921_dev *dev = data; | 299 struct mt792x_dev *dev = data; |
300 301 *val = dev->pm.enable_user; 302 303 return 0; 304} 305 306DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7921_pm_get, mt7921_pm_set, "%lld\n"); 307 308static int 309mt7921_deep_sleep_set(void *data, u64 val) 310{ | 300 301 *val = dev->pm.enable_user; 302 303 return 0; 304} 305 306DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7921_pm_get, mt7921_pm_set, "%lld\n"); 307 308static int 309mt7921_deep_sleep_set(void *data, u64 val) 310{ |
311 struct mt7921_dev *dev = data; | 311 struct mt792x_dev *dev = data; |
312 struct mt76_connac_pm *pm = &dev->pm; 313 bool monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR); 314 bool enable = !!val; 315 316 if (mt76_is_usb(&dev->mt76)) 317 return -EOPNOTSUPP; 318 319 mt7921_mutex_acquire(dev); --- 7 unchanged lines hidden (view full) --- 327 mt7921_mutex_release(dev); 328 329 return 0; 330} 331 332static int 333mt7921_deep_sleep_get(void *data, u64 *val) 334{ | 312 struct mt76_connac_pm *pm = &dev->pm; 313 bool monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR); 314 bool enable = !!val; 315 316 if (mt76_is_usb(&dev->mt76)) 317 return -EOPNOTSUPP; 318 319 mt7921_mutex_acquire(dev); --- 7 unchanged lines hidden (view full) --- 327 mt7921_mutex_release(dev); 328 329 return 0; 330} 331 332static int 333mt7921_deep_sleep_get(void *data, u64 *val) 334{ |
335 struct mt7921_dev *dev = data; | 335 struct mt792x_dev *dev = data; |
336 337 *val = dev->pm.ds_enable_user; 338 339 return 0; 340} 341 342DEFINE_DEBUGFS_ATTRIBUTE(fops_ds, mt7921_deep_sleep_get, 343 mt7921_deep_sleep_set, "%lld\n"); 344 345static int 346mt7921_pm_stats(struct seq_file *s, void *data) 347{ | 336 337 *val = dev->pm.ds_enable_user; 338 339 return 0; 340} 341 342DEFINE_DEBUGFS_ATTRIBUTE(fops_ds, mt7921_deep_sleep_get, 343 mt7921_deep_sleep_set, "%lld\n"); 344 345static int 346mt7921_pm_stats(struct seq_file *s, void *data) 347{ |
348 struct mt7921_dev *dev = dev_get_drvdata(s->private); | 348 struct mt792x_dev *dev = dev_get_drvdata(s->private); |
349 struct mt76_connac_pm *pm = &dev->pm; 350 351 unsigned long awake_time = pm->stats.awake_time; 352 unsigned long doze_time = pm->stats.doze_time; 353 354 if (!test_bit(MT76_STATE_PM, &dev->mphy.state)) 355 awake_time += jiffies - pm->stats.last_wake_event; 356 else --- 6 unchanged lines hidden (view full) --- 363 seq_printf(s, "low power wakes: %9d\n", pm->stats.lp_wake); 364 365 return 0; 366} 367 368static int 369mt7921_pm_idle_timeout_set(void *data, u64 val) 370{ | 349 struct mt76_connac_pm *pm = &dev->pm; 350 351 unsigned long awake_time = pm->stats.awake_time; 352 unsigned long doze_time = pm->stats.doze_time; 353 354 if (!test_bit(MT76_STATE_PM, &dev->mphy.state)) 355 awake_time += jiffies - pm->stats.last_wake_event; 356 else --- 6 unchanged lines hidden (view full) --- 363 seq_printf(s, "low power wakes: %9d\n", pm->stats.lp_wake); 364 365 return 0; 366} 367 368static int 369mt7921_pm_idle_timeout_set(void *data, u64 val) 370{ |
371 struct mt7921_dev *dev = data; | 371 struct mt792x_dev *dev = data; |
372 373 dev->pm.idle_timeout = msecs_to_jiffies(val); 374 375 return 0; 376} 377 378static int 379mt7921_pm_idle_timeout_get(void *data, u64 *val) 380{ | 372 373 dev->pm.idle_timeout = msecs_to_jiffies(val); 374 375 return 0; 376} 377 378static int 379mt7921_pm_idle_timeout_get(void *data, u64 *val) 380{ |
381 struct mt7921_dev *dev = data; | 381 struct mt792x_dev *dev = data; |
382 383 *val = jiffies_to_msecs(dev->pm.idle_timeout); 384 385 return 0; 386} 387 388DEFINE_DEBUGFS_ATTRIBUTE(fops_pm_idle_timeout, mt7921_pm_idle_timeout_get, 389 mt7921_pm_idle_timeout_set, "%lld\n"); 390 391static int mt7921_chip_reset(void *data, u64 val) 392{ | 382 383 *val = jiffies_to_msecs(dev->pm.idle_timeout); 384 385 return 0; 386} 387 388DEFINE_DEBUGFS_ATTRIBUTE(fops_pm_idle_timeout, mt7921_pm_idle_timeout_get, 389 mt7921_pm_idle_timeout_set, "%lld\n"); 390 391static int mt7921_chip_reset(void *data, u64 val) 392{ |
393 struct mt7921_dev *dev = data; | 393 struct mt792x_dev *dev = data; |
394 int ret = 0; 395 396 switch (val) { 397 case 1: 398 /* Reset wifisys directly. */ 399 mt7921_reset(&dev->mt76); 400 break; 401 default: --- 7 unchanged lines hidden (view full) --- 409 return ret; 410} 411 412DEFINE_DEBUGFS_ATTRIBUTE(fops_reset, NULL, mt7921_chip_reset, "%lld\n"); 413 414static int 415mt7921s_sched_quota_read(struct seq_file *s, void *data) 416{ | 394 int ret = 0; 395 396 switch (val) { 397 case 1: 398 /* Reset wifisys directly. */ 399 mt7921_reset(&dev->mt76); 400 break; 401 default: --- 7 unchanged lines hidden (view full) --- 409 return ret; 410} 411 412DEFINE_DEBUGFS_ATTRIBUTE(fops_reset, NULL, mt7921_chip_reset, "%lld\n"); 413 414static int 415mt7921s_sched_quota_read(struct seq_file *s, void *data) 416{ |
417 struct mt7921_dev *dev = dev_get_drvdata(s->private); | 417 struct mt792x_dev *dev = dev_get_drvdata(s->private); |
418 struct mt76_sdio *sdio = &dev->mt76.sdio; 419 420 seq_printf(s, "pse_data_quota\t%d\n", sdio->sched.pse_data_quota); 421 seq_printf(s, "ple_data_quota\t%d\n", sdio->sched.ple_data_quota); 422 seq_printf(s, "pse_mcu_quota\t%d\n", sdio->sched.pse_mcu_quota); 423 seq_printf(s, "sched_deficit\t%d\n", sdio->sched.deficit); 424 425 return 0; 426} 427 | 418 struct mt76_sdio *sdio = &dev->mt76.sdio; 419 420 seq_printf(s, "pse_data_quota\t%d\n", sdio->sched.pse_data_quota); 421 seq_printf(s, "ple_data_quota\t%d\n", sdio->sched.ple_data_quota); 422 seq_printf(s, "pse_mcu_quota\t%d\n", sdio->sched.pse_mcu_quota); 423 seq_printf(s, "sched_deficit\t%d\n", sdio->sched.deficit); 424 425 return 0; 426} 427 |
428int mt7921_init_debugfs(struct mt7921_dev *dev) | 428int mt7921_init_debugfs(struct mt792x_dev *dev) |
429{ 430 struct dentry *dir; 431 432 dir = mt76_register_debugfs_fops(&dev->mphy, &fops_regval); 433 if (!dir) 434 return -ENOMEM; 435 436 if (mt76_is_mmio(&dev->mt76)) --- 24 unchanged lines hidden --- | 429{ 430 struct dentry *dir; 431 432 dir = mt76_register_debugfs_fops(&dev->mphy, &fops_regval); 433 if (!dir) 434 return -ENOMEM; 435 436 if (mt76_is_mmio(&dev->mt76)) --- 24 unchanged lines hidden --- |