1 // SPDX-License-Identifier: ISC
2 /* Copyright (C) 2023 MediaTek Inc. */
7 mt792x_ampdu_stat_read_phy(struct mt792x_phy
*phy
,
10 struct mt792x_dev
*dev
= file
->private;
11 int bound
[15], range
[4], i
;
16 mt792x_mac_update_mib_stats(phy
);
19 for (i
= 0; i
< ARRAY_SIZE(range
); i
++)
20 range
[i
] = mt76_rr(dev
, MT_MIB_ARNG(0, i
));
22 for (i
= 0; i
< ARRAY_SIZE(bound
); i
++)
23 bound
[i
] = MT_MIB_ARNCR_RANGE(range
[i
/ 4], i
% 4) + 1;
25 seq_puts(file
, "\nPhy0\n");
27 seq_printf(file
, "Length: %8d | ", bound
[0]);
28 for (i
= 0; i
< ARRAY_SIZE(bound
) - 1; i
++)
29 seq_printf(file
, "%3d %3d | ", bound
[i
] + 1, bound
[i
+ 1]);
31 seq_puts(file
, "\nCount: ");
32 for (i
= 0; i
< ARRAY_SIZE(bound
); i
++)
33 seq_printf(file
, "%8d | ", phy
->mt76
->aggr_stats
[i
]);
36 seq_printf(file
, "BA miss count: %d\n", phy
->mib
.ba_miss_cnt
);
39 int mt792x_tx_stats_show(struct seq_file
*file
, void *data
)
41 struct mt792x_dev
*dev
= file
->private;
42 struct mt792x_phy
*phy
= &dev
->phy
;
43 struct mt76_mib_stats
*mib
= &phy
->mib
;
46 mt792x_mutex_acquire(dev
);
48 mt792x_ampdu_stat_read_phy(phy
, file
);
50 seq_puts(file
, "Tx MSDU stat:\n");
51 for (i
= 0; i
< ARRAY_SIZE(mib
->tx_amsdu
); i
++) {
52 seq_printf(file
, "AMSDU pack count of %d MSDU in TXD: %8d ",
53 i
+ 1, mib
->tx_amsdu
[i
]);
54 if (mib
->tx_amsdu_cnt
)
55 seq_printf(file
, "(%3d%%)\n",
56 mib
->tx_amsdu
[i
] * 100 / mib
->tx_amsdu_cnt
);
61 mt792x_mutex_release(dev
);
65 EXPORT_SYMBOL_GPL(mt792x_tx_stats_show
);
67 int mt792x_queues_acq(struct seq_file
*s
, void *data
)
69 struct mt792x_dev
*dev
= dev_get_drvdata(s
->private);
72 mt792x_mutex_acquire(dev
);
74 for (i
= 0; i
< 4; i
++) {
75 u32 ctrl
, val
, qlen
= 0;
78 val
= mt76_rr(dev
, MT_PLE_AC_QEMPTY(i
));
79 ctrl
= BIT(31) | BIT(11) | (i
<< 24);
81 for (j
= 0; j
< 32; j
++) {
85 mt76_wr(dev
, MT_PLE_FL_Q0_CTRL
, ctrl
| j
);
86 qlen
+= mt76_get_field(dev
, MT_PLE_FL_Q3_CTRL
,
89 seq_printf(s
, "AC%d: queued=%d\n", i
, qlen
);
92 mt792x_mutex_release(dev
);
96 EXPORT_SYMBOL_GPL(mt792x_queues_acq
);
98 int mt792x_queues_read(struct seq_file
*s
, void *data
)
100 struct mt792x_dev
*dev
= dev_get_drvdata(s
->private);
102 struct mt76_queue
*q
;
105 { dev
->mphy
.q_tx
[MT_TXQ_BE
], "WFDMA0" },
106 { dev
->mt76
.q_mcu
[MT_MCUQ_WM
], "MCUWM" },
107 { dev
->mt76
.q_mcu
[MT_MCUQ_FWDL
], "MCUFWQ" },
111 for (i
= 0; i
< ARRAY_SIZE(queue_map
); i
++) {
112 struct mt76_queue
*q
= queue_map
[i
].q
;
118 "%s: queued=%d head=%d tail=%d\n",
119 queue_map
[i
].queue
, q
->queued
, q
->head
,
125 EXPORT_SYMBOL_GPL(mt792x_queues_read
);
127 int mt792x_pm_stats(struct seq_file
*s
, void *data
)
129 struct mt792x_dev
*dev
= dev_get_drvdata(s
->private);
130 struct mt76_connac_pm
*pm
= &dev
->pm
;
132 unsigned long awake_time
= pm
->stats
.awake_time
;
133 unsigned long doze_time
= pm
->stats
.doze_time
;
135 if (!test_bit(MT76_STATE_PM
, &dev
->mphy
.state
))
136 awake_time
+= jiffies
- pm
->stats
.last_wake_event
;
138 doze_time
+= jiffies
- pm
->stats
.last_doze_event
;
140 seq_printf(s
, "awake time: %14u\ndoze time: %15u\n",
141 jiffies_to_msecs(awake_time
),
142 jiffies_to_msecs(doze_time
));
144 seq_printf(s
, "low power wakes: %9d\n", pm
->stats
.lp_wake
);
148 EXPORT_SYMBOL_GPL(mt792x_pm_stats
);
150 int mt792x_pm_idle_timeout_set(void *data
, u64 val
)
152 struct mt792x_dev
*dev
= data
;
154 dev
->pm
.idle_timeout
= msecs_to_jiffies(val
);
158 EXPORT_SYMBOL_GPL(mt792x_pm_idle_timeout_set
);
160 int mt792x_pm_idle_timeout_get(void *data
, u64
*val
)
162 struct mt792x_dev
*dev
= data
;
164 *val
= jiffies_to_msecs(dev
->pm
.idle_timeout
);
168 EXPORT_SYMBOL_GPL(mt792x_pm_idle_timeout_get
);