Commit | Line | Data |
---|---|---|
0e3d6777 | 1 | // SPDX-License-Identifier: ISC |
7bc04215 FF |
2 | /* |
3 | * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> | |
7bc04215 FF |
4 | */ |
5 | ||
6 | #include <linux/debugfs.h> | |
76055413 | 7 | #include "mt76x02.h" |
7bc04215 FF |
8 | |
9 | static int | |
1820388b | 10 | mt76x02_ampdu_stat_show(struct seq_file *file, void *data) |
7bc04215 | 11 | { |
e40803f2 | 12 | struct mt76x02_dev *dev = file->private; |
7bc04215 FF |
13 | int i, j; |
14 | ||
15 | for (i = 0; i < 4; i++) { | |
16 | seq_puts(file, "Length: "); | |
17 | for (j = 0; j < 8; j++) | |
18 | seq_printf(file, "%8d | ", i * 8 + j + 1); | |
19 | seq_puts(file, "\n"); | |
20 | seq_puts(file, "Count: "); | |
21 | for (j = 0; j < 8; j++) | |
d7b47bbd LB |
22 | seq_printf(file, "%8d | ", |
23 | dev->mt76.aggr_stats[i * 8 + j]); | |
7bc04215 FF |
24 | seq_puts(file, "\n"); |
25 | seq_puts(file, "--------"); | |
26 | for (j = 0; j < 8; j++) | |
27 | seq_puts(file, "-----------"); | |
28 | seq_puts(file, "\n"); | |
29 | } | |
30 | ||
31 | return 0; | |
32 | } | |
33 | ||
1820388b | 34 | DEFINE_SHOW_ATTRIBUTE(mt76x02_ampdu_stat); |
7bc04215 | 35 | |
7bc04215 FF |
36 | static int read_txpower(struct seq_file *file, void *data) |
37 | { | |
e40803f2 | 38 | struct mt76x02_dev *dev = dev_get_drvdata(file->private); |
7bc04215 FF |
39 | |
40 | seq_printf(file, "Target power: %d\n", dev->target_power); | |
41 | ||
8f410a8b LB |
42 | mt76_seq_puts_array(file, "Delta", dev->target_power_delta, |
43 | ARRAY_SIZE(dev->target_power_delta)); | |
7bc04215 FF |
44 | return 0; |
45 | } | |
46 | ||
7bc04215 | 47 | static int |
1820388b | 48 | mt76x02_dfs_stat_show(struct seq_file *file, void *data) |
7bc04215 | 49 | { |
e40803f2 LB |
50 | struct mt76x02_dev *dev = file->private; |
51 | struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd; | |
7bc04215 | 52 | int i; |
7bc04215 | 53 | |
4a07ed51 LB |
54 | seq_printf(file, "allocated sequences:\t%d\n", |
55 | dfs_pd->seq_stats.seq_pool_len); | |
56 | seq_printf(file, "used sequences:\t\t%d\n", | |
57 | dfs_pd->seq_stats.seq_len); | |
58 | seq_puts(file, "\n"); | |
59 | ||
7bc04215 FF |
60 | for (i = 0; i < MT_DFS_NUM_ENGINES; i++) { |
61 | seq_printf(file, "engine: %d\n", i); | |
62 | seq_printf(file, " hw pattern detected:\t%d\n", | |
63 | dfs_pd->stats[i].hw_pattern); | |
64 | seq_printf(file, " hw pulse discarded:\t%d\n", | |
65 | dfs_pd->stats[i].hw_pulse_discarded); | |
4a07ed51 LB |
66 | seq_printf(file, " sw pattern detected:\t%d\n", |
67 | dfs_pd->stats[i].sw_pattern); | |
7bc04215 FF |
68 | } |
69 | ||
70 | return 0; | |
71 | } | |
72 | ||
1820388b | 73 | DEFINE_SHOW_ATTRIBUTE(mt76x02_dfs_stat); |
7bc04215 | 74 | |
108ec4da FF |
75 | static int read_agc(struct seq_file *file, void *data) |
76 | { | |
e40803f2 | 77 | struct mt76x02_dev *dev = dev_get_drvdata(file->private); |
108ec4da FF |
78 | |
79 | seq_printf(file, "avg_rssi: %d\n", dev->cal.avg_rssi_all); | |
80 | seq_printf(file, "low_gain: %d\n", dev->cal.low_gain); | |
81 | seq_printf(file, "false_cca: %d\n", dev->cal.false_cca); | |
82 | seq_printf(file, "agc_gain_adjust: %d\n", dev->cal.agc_gain_adjust); | |
83 | ||
84 | return 0; | |
85 | } | |
86 | ||
643749d4 FF |
87 | static int |
88 | mt76_edcca_set(void *data, u64 val) | |
89 | { | |
90 | struct mt76x02_dev *dev = data; | |
d8b8890d | 91 | enum nl80211_dfs_regions region = dev->mt76.region; |
643749d4 | 92 | |
8aac454d LB |
93 | mutex_lock(&dev->mt76.mutex); |
94 | ||
643749d4 FF |
95 | dev->ed_monitor_enabled = !!val; |
96 | dev->ed_monitor = dev->ed_monitor_enabled && | |
97 | region == NL80211_DFS_ETSI; | |
a78f1547 | 98 | mt76x02_edcca_init(dev); |
643749d4 | 99 | |
8aac454d LB |
100 | mutex_unlock(&dev->mt76.mutex); |
101 | ||
643749d4 FF |
102 | return 0; |
103 | } | |
104 | ||
105 | static int | |
106 | mt76_edcca_get(void *data, u64 *val) | |
107 | { | |
108 | struct mt76x02_dev *dev = data; | |
109 | ||
110 | *val = dev->ed_monitor_enabled; | |
111 | return 0; | |
112 | } | |
113 | ||
114 | DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt76_edcca_get, mt76_edcca_set, | |
115 | "%lld\n"); | |
116 | ||
b376d963 FF |
117 | static int mt76x02_read_rate_txpower(struct seq_file *s, void *data) |
118 | { | |
119 | struct mt76x02_dev *dev = dev_get_drvdata(s->private); | |
120 | ||
121 | mt76_seq_puts_array(s, "CCK", dev->rate_power.cck, | |
122 | ARRAY_SIZE(dev->rate_power.cck)); | |
123 | mt76_seq_puts_array(s, "OFDM", dev->rate_power.ofdm, | |
124 | ARRAY_SIZE(dev->rate_power.ofdm)); | |
b376d963 FF |
125 | mt76_seq_puts_array(s, "HT", dev->rate_power.ht, |
126 | ARRAY_SIZE(dev->rate_power.ht)); | |
127 | mt76_seq_puts_array(s, "VHT", dev->rate_power.vht, | |
128 | ARRAY_SIZE(dev->rate_power.vht)); | |
129 | return 0; | |
130 | } | |
131 | ||
76055413 | 132 | void mt76x02_init_debugfs(struct mt76x02_dev *dev) |
7bc04215 FF |
133 | { |
134 | struct dentry *dir; | |
135 | ||
136 | dir = mt76_register_debugfs(&dev->mt76); | |
137 | if (!dir) | |
138 | return; | |
139 | ||
6ea62c50 | 140 | debugfs_create_devm_seqfile(dev->mt76.dev, "xmit-queues", dir, |
0b82a8e8 | 141 | mt76_queues_read); |
2ef00c53 JP |
142 | debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp); |
143 | debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc); | |
7bc04215 | 144 | |
4a8c99c7 | 145 | debugfs_create_file("edcca", 0600, dir, dev, &fops_edcca); |
1820388b QM |
146 | debugfs_create_file("ampdu_stat", 0400, dir, dev, &mt76x02_ampdu_stat_fops); |
147 | debugfs_create_file("dfs_stats", 0400, dir, dev, &mt76x02_dfs_stat_fops); | |
7bc04215 FF |
148 | debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, |
149 | read_txpower); | |
108ec4da | 150 | |
b376d963 FF |
151 | debugfs_create_devm_seqfile(dev->mt76.dev, "rate_txpower", dir, |
152 | mt76x02_read_rate_txpower); | |
108ec4da | 153 | debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc); |
c1e0d2be LB |
154 | |
155 | debugfs_create_u32("tx_hang_reset", 0400, dir, &dev->tx_hang_reset); | |
7bc04215 | 156 | } |
76055413 | 157 | EXPORT_SYMBOL_GPL(mt76x02_init_debugfs); |