mt792x_debugfs.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // SPDX-License-Identifier: ISC
  2. /* Copyright (C) 2023 MediaTek Inc. */
  3. #include "mt792x.h"
  4. static void
  5. mt792x_ampdu_stat_read_phy(struct mt792x_phy *phy,
  6. struct seq_file *file)
  7. {
  8. struct mt792x_dev *dev = file->private;
  9. int bound[15], range[4], i;
  10. if (!phy)
  11. return;
  12. mt792x_mac_update_mib_stats(phy);
  13. /* Tx ampdu stat */
  14. for (i = 0; i < ARRAY_SIZE(range); i++)
  15. range[i] = mt76_rr(dev, MT_MIB_ARNG(0, i));
  16. for (i = 0; i < ARRAY_SIZE(bound); i++)
  17. bound[i] = MT_MIB_ARNCR_RANGE(range[i / 4], i % 4) + 1;
  18. seq_puts(file, "\nPhy0\n");
  19. seq_printf(file, "Length: %8d | ", bound[0]);
  20. for (i = 0; i < ARRAY_SIZE(bound) - 1; i++)
  21. seq_printf(file, "%3d %3d | ", bound[i] + 1, bound[i + 1]);
  22. seq_puts(file, "\nCount: ");
  23. for (i = 0; i < ARRAY_SIZE(bound); i++)
  24. seq_printf(file, "%8d | ", phy->mt76->aggr_stats[i]);
  25. seq_puts(file, "\n");
  26. seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt);
  27. }
  28. int mt792x_tx_stats_show(struct seq_file *file, void *data)
  29. {
  30. struct mt792x_dev *dev = file->private;
  31. struct mt792x_phy *phy = &dev->phy;
  32. struct mt76_mib_stats *mib = &phy->mib;
  33. int i;
  34. mt792x_mutex_acquire(dev);
  35. mt792x_ampdu_stat_read_phy(phy, file);
  36. seq_puts(file, "Tx MSDU stat:\n");
  37. for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
  38. seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ",
  39. i + 1, mib->tx_amsdu[i]);
  40. if (mib->tx_amsdu_cnt)
  41. seq_printf(file, "(%3d%%)\n",
  42. mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt);
  43. else
  44. seq_puts(file, "\n");
  45. }
  46. mt792x_mutex_release(dev);
  47. return 0;
  48. }
  49. EXPORT_SYMBOL_GPL(mt792x_tx_stats_show);
  50. int mt792x_queues_acq(struct seq_file *s, void *data)
  51. {
  52. struct mt792x_dev *dev = dev_get_drvdata(s->private);
  53. int i;
  54. mt792x_mutex_acquire(dev);
  55. for (i = 0; i < 4; i++) {
  56. u32 ctrl, val, qlen = 0;
  57. int j;
  58. val = mt76_rr(dev, MT_PLE_AC_QEMPTY(i));
  59. ctrl = BIT(31) | BIT(11) | (i << 24);
  60. for (j = 0; j < 32; j++) {
  61. if (val & BIT(j))
  62. continue;
  63. mt76_wr(dev, MT_PLE_FL_Q0_CTRL, ctrl | j);
  64. qlen += mt76_get_field(dev, MT_PLE_FL_Q3_CTRL,
  65. GENMASK(11, 0));
  66. }
  67. seq_printf(s, "AC%d: queued=%d\n", i, qlen);
  68. }
  69. mt792x_mutex_release(dev);
  70. return 0;
  71. }
  72. EXPORT_SYMBOL_GPL(mt792x_queues_acq);
  73. int mt792x_queues_read(struct seq_file *s, void *data)
  74. {
  75. struct mt792x_dev *dev = dev_get_drvdata(s->private);
  76. struct {
  77. struct mt76_queue *q;
  78. char *queue;
  79. } queue_map[] = {
  80. { dev->mphy.q_tx[MT_TXQ_BE], "WFDMA0" },
  81. { dev->mt76.q_mcu[MT_MCUQ_WM], "MCUWM" },
  82. { dev->mt76.q_mcu[MT_MCUQ_FWDL], "MCUFWQ" },
  83. };
  84. int i;
  85. for (i = 0; i < ARRAY_SIZE(queue_map); i++) {
  86. struct mt76_queue *q = queue_map[i].q;
  87. if (!q)
  88. continue;
  89. seq_printf(s,
  90. "%s: queued=%d head=%d tail=%d\n",
  91. queue_map[i].queue, q->queued, q->head,
  92. q->tail);
  93. }
  94. return 0;
  95. }
  96. EXPORT_SYMBOL_GPL(mt792x_queues_read);
  97. int mt792x_pm_stats(struct seq_file *s, void *data)
  98. {
  99. struct mt792x_dev *dev = dev_get_drvdata(s->private);
  100. struct mt76_connac_pm *pm = &dev->pm;
  101. unsigned long awake_time = pm->stats.awake_time;
  102. unsigned long doze_time = pm->stats.doze_time;
  103. if (!test_bit(MT76_STATE_PM, &dev->mphy.state))
  104. awake_time += jiffies - pm->stats.last_wake_event;
  105. else
  106. doze_time += jiffies - pm->stats.last_doze_event;
  107. seq_printf(s, "awake time: %14u\ndoze time: %15u\n",
  108. jiffies_to_msecs(awake_time),
  109. jiffies_to_msecs(doze_time));
  110. seq_printf(s, "low power wakes: %9d\n", pm->stats.lp_wake);
  111. return 0;
  112. }
  113. EXPORT_SYMBOL_GPL(mt792x_pm_stats);
  114. int mt792x_pm_idle_timeout_set(void *data, u64 val)
  115. {
  116. struct mt792x_dev *dev = data;
  117. dev->pm.idle_timeout = msecs_to_jiffies(val);
  118. return 0;
  119. }
  120. EXPORT_SYMBOL_GPL(mt792x_pm_idle_timeout_set);
  121. int mt792x_pm_idle_timeout_get(void *data, u64 *val)
  122. {
  123. struct mt792x_dev *dev = data;
  124. *val = jiffies_to_msecs(dev->pm.idle_timeout);
  125. return 0;
  126. }
  127. EXPORT_SYMBOL_GPL(mt792x_pm_idle_timeout_get);