hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/wireless/mediatek/mt76/debugfs.c
....@@ -1,17 +1,6 @@
1
+// SPDX-License-Identifier: ISC
12 /*
23 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
154 */
165 #include "mt76.h"
176
....@@ -20,7 +9,7 @@
209 {
2110 struct mt76_dev *dev = data;
2211
23
- dev->bus->wr(dev, dev->debugfs_reg, val);
12
+ __mt76_wr(dev, dev->debugfs_reg, val);
2413 return 0;
2514 }
2615
....@@ -29,30 +18,75 @@
2918 {
3019 struct mt76_dev *dev = data;
3120
32
- *val = dev->bus->rr(dev, dev->debugfs_reg);
21
+ *val = __mt76_rr(dev, dev->debugfs_reg);
3322 return 0;
3423 }
3524
3625 DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt76_reg_get, mt76_reg_set,
3726 "0x%08llx\n");
3827
39
-static int
40
-mt76_queues_read(struct seq_file *s, void *data)
28
+int mt76_queues_read(struct seq_file *s, void *data)
4129 {
4230 struct mt76_dev *dev = dev_get_drvdata(s->private);
4331 int i;
4432
4533 for (i = 0; i < ARRAY_SIZE(dev->q_tx); i++) {
46
- struct mt76_queue *q = &dev->q_tx[i];
34
+ struct mt76_queue *q = dev->q_tx[i];
4735
48
- if (!q->ndesc)
36
+ if (!q)
4937 continue;
5038
5139 seq_printf(s,
52
- "%d: queued=%d head=%d tail=%d swq_queued=%d\n",
53
- i, q->queued, q->head, q->tail, q->swq_queued);
40
+ "%d: queued=%d head=%d tail=%d\n",
41
+ i, q->queued, q->head, q->tail);
5442 }
5543
44
+ return 0;
45
+}
46
+EXPORT_SYMBOL_GPL(mt76_queues_read);
47
+
48
+static int mt76_rx_queues_read(struct seq_file *s, void *data)
49
+{
50
+ struct mt76_dev *dev = dev_get_drvdata(s->private);
51
+ int i, queued;
52
+
53
+ mt76_for_each_q_rx(dev, i) {
54
+ struct mt76_queue *q = &dev->q_rx[i];
55
+
56
+ queued = mt76_is_usb(dev) ? q->ndesc - q->queued : q->queued;
57
+ seq_printf(s, "%d: queued=%d head=%d tail=%d\n",
58
+ i, queued, q->head, q->tail);
59
+ }
60
+
61
+ return 0;
62
+}
63
+
64
+void mt76_seq_puts_array(struct seq_file *file, const char *str,
65
+ s8 *val, int len)
66
+{
67
+ int i;
68
+
69
+ seq_printf(file, "%10s:", str);
70
+ for (i = 0; i < len; i++)
71
+ seq_printf(file, " %2d", val[i]);
72
+ seq_puts(file, "\n");
73
+}
74
+EXPORT_SYMBOL_GPL(mt76_seq_puts_array);
75
+
76
+static int mt76_read_rate_txpower(struct seq_file *s, void *data)
77
+{
78
+ struct mt76_dev *dev = dev_get_drvdata(s->private);
79
+
80
+ mt76_seq_puts_array(s, "CCK", dev->rate_power.cck,
81
+ ARRAY_SIZE(dev->rate_power.cck));
82
+ mt76_seq_puts_array(s, "OFDM", dev->rate_power.ofdm,
83
+ ARRAY_SIZE(dev->rate_power.ofdm));
84
+ mt76_seq_puts_array(s, "STBC", dev->rate_power.stbc,
85
+ ARRAY_SIZE(dev->rate_power.stbc));
86
+ mt76_seq_puts_array(s, "HT", dev->rate_power.ht,
87
+ ARRAY_SIZE(dev->rate_power.ht));
88
+ mt76_seq_puts_array(s, "VHT", dev->rate_power.vht,
89
+ ARRAY_SIZE(dev->rate_power.vht));
5690 return 0;
5791 }
5892
....@@ -71,7 +105,10 @@
71105 debugfs_create_blob("eeprom", 0400, dir, &dev->eeprom);
72106 if (dev->otp.data)
73107 debugfs_create_blob("otp", 0400, dir, &dev->otp);
74
- debugfs_create_devm_seqfile(dev->dev, "queues", dir, mt76_queues_read);
108
+ debugfs_create_devm_seqfile(dev->dev, "rate_txpower", dir,
109
+ mt76_read_rate_txpower);
110
+ debugfs_create_devm_seqfile(dev->dev, "rx-queues", dir,
111
+ mt76_rx_queues_read);
75112
76113 return dir;
77114 }