]>
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 | |
76055413 | 10 | mt76x02_ampdu_stat_read(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 | ||
34 | static int | |
76055413 | 35 | mt76x02_ampdu_stat_open(struct inode *inode, struct file *f) |
7bc04215 | 36 | { |
76055413 | 37 | return single_open(f, mt76x02_ampdu_stat_read, inode->i_private); |
7bc04215 FF |
38 | } |
39 | ||
7bc04215 FF |
40 | static int read_txpower(struct seq_file *file, void *data) |
41 | { | |
e40803f2 | 42 | struct mt76x02_dev *dev = dev_get_drvdata(file->private); |
7bc04215 FF |
43 | |
44 | seq_printf(file, "Target power: %d\n", dev->target_power); | |
45 | ||
8f410a8b LB |
46 | mt76_seq_puts_array(file, "Delta", dev->target_power_delta, |
47 | ARRAY_SIZE(dev->target_power_delta)); | |
7bc04215 FF |
48 | return 0; |
49 | } | |
50 | ||
51 | static const struct file_operations fops_ampdu_stat = { | |
76055413 | 52 | .open = mt76x02_ampdu_stat_open, |
7bc04215 FF |
53 | .read = seq_read, |
54 | .llseek = seq_lseek, | |
55 | .release = single_release, | |
56 | }; | |
57 | ||
58 | static int | |
76055413 | 59 | mt76x02_dfs_stat_read(struct seq_file *file, void *data) |
7bc04215 | 60 | { |
e40803f2 LB |
61 | struct mt76x02_dev *dev = file->private; |
62 | struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd; | |
7bc04215 | 63 | int i; |
7bc04215 | 64 | |
4a07ed51 LB |
65 | seq_printf(file, "allocated sequences:\t%d\n", |
66 | dfs_pd->seq_stats.seq_pool_len); | |
67 | seq_printf(file, "used sequences:\t\t%d\n", | |
68 | dfs_pd->seq_stats.seq_len); | |
69 | seq_puts(file, "\n"); | |
70 | ||
7bc04215 FF |
71 | for (i = 0; i < MT_DFS_NUM_ENGINES; i++) { |
72 | seq_printf(file, "engine: %d\n", i); | |
73 | seq_printf(file, " hw pattern detected:\t%d\n", | |
74 | dfs_pd->stats[i].hw_pattern); | |
75 | seq_printf(file, " hw pulse discarded:\t%d\n", | |
76 | dfs_pd->stats[i].hw_pulse_discarded); | |
4a07ed51 LB |
77 | seq_printf(file, " sw pattern detected:\t%d\n", |
78 | dfs_pd->stats[i].sw_pattern); | |
7bc04215 FF |
79 | } |
80 | ||
81 | return 0; | |
82 | } | |
83 | ||
84 | static int | |
76055413 | 85 | mt76x02_dfs_stat_open(struct inode *inode, struct file *f) |
7bc04215 | 86 | { |
76055413 | 87 | return single_open(f, mt76x02_dfs_stat_read, inode->i_private); |
7bc04215 FF |
88 | } |
89 | ||
90 | static const struct file_operations fops_dfs_stat = { | |
76055413 | 91 | .open = mt76x02_dfs_stat_open, |
7bc04215 FF |
92 | .read = seq_read, |
93 | .llseek = seq_lseek, | |
94 | .release = single_release, | |
95 | }; | |
96 | ||
108ec4da FF |
97 | static int read_agc(struct seq_file *file, void *data) |
98 | { | |
e40803f2 | 99 | struct mt76x02_dev *dev = dev_get_drvdata(file->private); |
108ec4da FF |
100 | |
101 | seq_printf(file, "avg_rssi: %d\n", dev->cal.avg_rssi_all); | |
102 | seq_printf(file, "low_gain: %d\n", dev->cal.low_gain); | |
103 | seq_printf(file, "false_cca: %d\n", dev->cal.false_cca); | |
104 | seq_printf(file, "agc_gain_adjust: %d\n", dev->cal.agc_gain_adjust); | |
105 | ||
106 | return 0; | |
107 | } | |
108 | ||
643749d4 FF |
109 | static int |
110 | mt76_edcca_set(void *data, u64 val) | |
111 | { | |
112 | struct mt76x02_dev *dev = data; | |
d8b8890d | 113 | enum nl80211_dfs_regions region = dev->mt76.region; |
643749d4 | 114 | |
8aac454d LB |
115 | mutex_lock(&dev->mt76.mutex); |
116 | ||
643749d4 FF |
117 | dev->ed_monitor_enabled = !!val; |
118 | dev->ed_monitor = dev->ed_monitor_enabled && | |
119 | region == NL80211_DFS_ETSI; | |
a78f1547 | 120 | mt76x02_edcca_init(dev); |
643749d4 | 121 | |
8aac454d LB |
122 | mutex_unlock(&dev->mt76.mutex); |
123 | ||
643749d4 FF |
124 | return 0; |
125 | } | |
126 | ||
127 | static int | |
128 | mt76_edcca_get(void *data, u64 *val) | |
129 | { | |
130 | struct mt76x02_dev *dev = data; | |
131 | ||
132 | *val = dev->ed_monitor_enabled; | |
133 | return 0; | |
134 | } | |
135 | ||
136 | DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt76_edcca_get, mt76_edcca_set, | |
137 | "%lld\n"); | |
138 | ||
76055413 | 139 | void mt76x02_init_debugfs(struct mt76x02_dev *dev) |
7bc04215 FF |
140 | { |
141 | struct dentry *dir; | |
142 | ||
143 | dir = mt76_register_debugfs(&dev->mt76); | |
144 | if (!dir) | |
145 | return; | |
146 | ||
0b82a8e8 LB |
147 | debugfs_create_devm_seqfile(dev->mt76.dev, "queues", dir, |
148 | mt76_queues_read); | |
2ef00c53 JP |
149 | debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp); |
150 | debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc); | |
7bc04215 | 151 | |
4a8c99c7 | 152 | debugfs_create_file("edcca", 0600, dir, dev, &fops_edcca); |
2ef00c53 JP |
153 | debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat); |
154 | debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat); | |
7bc04215 FF |
155 | debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, |
156 | read_txpower); | |
108ec4da FF |
157 | |
158 | debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc); | |
c1e0d2be LB |
159 | |
160 | debugfs_create_u32("tx_hang_reset", 0400, dir, &dev->tx_hang_reset); | |
7bc04215 | 161 | } |
76055413 | 162 | EXPORT_SYMBOL_GPL(mt76x02_init_debugfs); |