1
2
3#include "mt7603.h"
4
5static int
6mt7603_reset_read(struct seq_file *s, void *data)
7{
8 struct mt7603_dev *dev = dev_get_drvdata(s->private);
9 static const char * const reset_cause_str[] = {
10 [RESET_CAUSE_TX_HANG] = "TX hang",
11 [RESET_CAUSE_TX_BUSY] = "TX DMA busy stuck",
12 [RESET_CAUSE_RX_BUSY] = "RX DMA busy stuck",
13 [RESET_CAUSE_RX_PSE_BUSY] = "RX PSE busy stuck",
14 [RESET_CAUSE_BEACON_STUCK] = "Beacon stuck",
15 [RESET_CAUSE_MCU_HANG] = "MCU hang",
16 [RESET_CAUSE_RESET_FAILED] = "PSE reset failed",
17 };
18 int i;
19
20 for (i = 0; i < ARRAY_SIZE(reset_cause_str); i++) {
21 if (!reset_cause_str[i])
22 continue;
23
24 seq_printf(s, "%20s: %u\n", reset_cause_str[i],
25 dev->reset_cause[i]);
26 }
27
28 return 0;
29}
30
31static int
32mt7603_radio_read(struct seq_file *s, void *data)
33{
34 struct mt7603_dev *dev = dev_get_drvdata(s->private);
35
36 seq_printf(s, "Sensitivity: %d\n", dev->sensitivity);
37 seq_printf(s, "False CCA: ofdm=%d cck=%d\n",
38 dev->false_cca_ofdm, dev->false_cca_cck);
39
40 return 0;
41}
42
43static int
44mt7603_edcca_set(void *data, u64 val)
45{
46 struct mt7603_dev *dev = data;
47
48 mutex_lock(&dev->mt76.mutex);
49
50 dev->ed_monitor_enabled = !!val;
51 dev->ed_monitor = dev->ed_monitor_enabled &&
52 dev->mt76.region == NL80211_DFS_ETSI;
53 mt7603_init_edcca(dev);
54
55 mutex_unlock(&dev->mt76.mutex);
56
57 return 0;
58}
59
60static int
61mt7603_edcca_get(void *data, u64 *val)
62{
63 struct mt7603_dev *dev = data;
64
65 *val = dev->ed_monitor_enabled;
66 return 0;
67}
68
69DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt7603_edcca_get,
70 mt7603_edcca_set, "%lld\n");
71
72static int
73mt7603_ampdu_stat_read(struct seq_file *file, void *data)
74{
75 struct mt7603_dev *dev = file->private;
76 int bound[3], i, range;
77
78 range = mt76_rr(dev, MT_AGG_ASRCR);
79 for (i = 0; i < ARRAY_SIZE(bound); i++)
80 bound[i] = MT_AGG_ASRCR_RANGE(range, i) + 1;
81
82 seq_printf(file, "Length: %8d | ", bound[0]);
83 for (i = 0; i < ARRAY_SIZE(bound) - 1; i++)
84 seq_printf(file, "%3d -%3d | ",
85 bound[i], bound[i + 1]);
86 seq_puts(file, "\nCount: ");
87 for (i = 0; i < ARRAY_SIZE(bound); i++)
88 seq_printf(file, "%8d | ", dev->mt76.aggr_stats[i]);
89 seq_puts(file, "\n");
90
91 return 0;
92}
93
94static int
95mt7603_ampdu_stat_open(struct inode *inode, struct file *f)
96{
97 return single_open(f, mt7603_ampdu_stat_read, inode->i_private);
98}
99
100static const struct file_operations fops_ampdu_stat = {
101 .open = mt7603_ampdu_stat_open,
102 .read = seq_read,
103 .llseek = seq_lseek,
104 .release = single_release,
105};
106
107void mt7603_init_debugfs(struct mt7603_dev *dev)
108{
109 struct dentry *dir;
110
111 dir = mt76_register_debugfs(&dev->mt76);
112 if (!dir)
113 return;
114
115 debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat);
116 debugfs_create_devm_seqfile(dev->mt76.dev, "xmit-queues", dir,
117 mt76_queues_read);
118 debugfs_create_file("edcca", 0600, dir, dev, &fops_edcca);
119 debugfs_create_u32("reset_test", 0600, dir, &dev->reset_test);
120 debugfs_create_devm_seqfile(dev->mt76.dev, "reset", dir,
121 mt7603_reset_read);
122 debugfs_create_devm_seqfile(dev->mt76.dev, "radio", dir,
123 mt7603_radio_read);
124 debugfs_create_u8("sensitivity_limit", 0600, dir,
125 &dev->sensitivity_limit);
126 debugfs_create_bool("dynamic_sensitivity", 0600, dir,
127 &dev->dynamic_sensitivity);
128}
129