hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/mac80211/rc80211_minstrel_ht_debugfs.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 */
85 #include <linux/netdevice.h>
96 #include <linux/types.h>
....@@ -14,6 +11,22 @@
1411 #include <net/mac80211.h>
1512 #include "rc80211_minstrel.h"
1613 #include "rc80211_minstrel_ht.h"
14
+
15
+static ssize_t
16
+minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
17
+{
18
+ struct minstrel_debugfs_info *ms;
19
+
20
+ ms = file->private_data;
21
+ return simple_read_from_buffer(buf, len, ppos, ms->buf, ms->len);
22
+}
23
+
24
+static int
25
+minstrel_stats_release(struct inode *inode, struct file *file)
26
+{
27
+ kfree(file->private_data);
28
+ return 0;
29
+}
1730
1831 static char *
1932 minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
....@@ -41,7 +54,7 @@
4154 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
4255 static const int bitrates[4] = { 10, 20, 55, 110 };
4356 int idx = i * MCS_GROUP_RATES + j;
44
- unsigned int prob_ewmsd;
57
+ unsigned int duration;
4558
4659 if (!(mi->supported[i] & BIT(j)))
4760 continue;
....@@ -79,21 +92,21 @@
7992 p += sprintf(p, " %3u ", idx);
8093
8194 /* tx_time[rate(i)] in usec */
82
- tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000);
95
+ duration = mg->duration[j];
96
+ duration <<= mg->shift;
97
+ tx_time = DIV_ROUND_CLOSEST(duration, 1000);
8398 p += sprintf(p, "%6u ", tx_time);
8499
85100 tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
86
- tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
87
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
88
- prob_ewmsd = minstrel_get_ewmsd10(mrs);
101
+ tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_avg);
102
+ eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000);
89103
90
- p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
104
+ p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u"
91105 " %3u %3u %-3u "
92106 "%9llu %-9llu\n",
93107 tp_max / 10, tp_max % 10,
94108 tp_avg / 10, tp_avg % 10,
95109 eprob / 10, eprob % 10,
96
- prob_ewmsd / 10, prob_ewmsd % 10,
97110 mrs->retry_count,
98111 mrs->last_success,
99112 mrs->last_attempts,
....@@ -130,9 +143,9 @@
130143
131144 p += sprintf(p, "\n");
132145 p += sprintf(p,
133
- " best ____________rate__________ ________statistics________ _____last____ ______sum-of________\n");
146
+ " best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n");
134147 p += sprintf(p,
135
- "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n");
148
+ "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n");
136149
137150 p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p);
138151 for (i = 0; i < MINSTREL_CCK_GROUP; i++)
....@@ -144,9 +157,10 @@
144157 "lookaround %d\n",
145158 max(0, (int) mi->total_packets - (int) mi->sample_packets),
146159 mi->sample_packets);
147
- p += sprintf(p, "Average # of aggregated frames per A-MPDU: %d.%d\n",
148
- MINSTREL_TRUNC(mi->avg_ampdu_len),
149
- MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
160
+ if (mi->avg_ampdu_len)
161
+ p += sprintf(p, "Average # of aggregated frames per A-MPDU: %d.%d\n",
162
+ MINSTREL_TRUNC(mi->avg_ampdu_len),
163
+ MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
150164 ms->len = p - ms->buf;
151165 WARN_ON(ms->len + sizeof(*ms) > 32768);
152166
....@@ -187,7 +201,7 @@
187201 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
188202 static const int bitrates[4] = { 10, 20, 55, 110 };
189203 int idx = i * MCS_GROUP_RATES + j;
190
- unsigned int prob_ewmsd;
204
+ unsigned int duration;
191205
192206 if (!(mi->supported[i] & BIT(j)))
193207 continue;
....@@ -222,20 +236,21 @@
222236 }
223237
224238 p += sprintf(p, "%u,", idx);
225
- tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000);
239
+
240
+ duration = mg->duration[j];
241
+ duration <<= mg->shift;
242
+ tx_time = DIV_ROUND_CLOSEST(duration, 1000);
226243 p += sprintf(p, "%u,", tx_time);
227244
228245 tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
229
- tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
230
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
231
- prob_ewmsd = minstrel_get_ewmsd10(mrs);
246
+ tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_avg);
247
+ eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000);
232248
233
- p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
249
+ p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,"
234250 "%u,%llu,%llu,",
235251 tp_max / 10, tp_max % 10,
236252 tp_avg / 10, tp_avg % 10,
237253 eprob / 10, eprob % 10,
238
- prob_ewmsd / 10, prob_ewmsd % 10,
239254 mrs->retry_count,
240255 mrs->last_success,
241256 mrs->last_attempts,
....@@ -303,17 +318,8 @@
303318 {
304319 struct minstrel_ht_sta_priv *msp = priv_sta;
305320
306
- msp->dbg_stats = debugfs_create_file("rc_stats", 0444, dir, msp,
307
- &minstrel_ht_stat_fops);
308
- msp->dbg_stats_csv = debugfs_create_file("rc_stats_csv", 0444, dir, msp,
309
- &minstrel_ht_stat_csv_fops);
310
-}
311
-
312
-void
313
-minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta)
314
-{
315
- struct minstrel_ht_sta_priv *msp = priv_sta;
316
-
317
- debugfs_remove(msp->dbg_stats);
318
- debugfs_remove(msp->dbg_stats_csv);
321
+ debugfs_create_file("rc_stats", 0444, dir, msp,
322
+ &minstrel_ht_stat_fops);
323
+ debugfs_create_file("rc_stats_csv", 0444, dir, msp,
324
+ &minstrel_ht_stat_csv_fops);
319325 }