.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
7 | 4 | */ |
---|
8 | 5 | #include <linux/netdevice.h> |
---|
9 | 6 | #include <linux/types.h> |
---|
.. | .. |
---|
14 | 11 | #include <net/mac80211.h> |
---|
15 | 12 | #include "rc80211_minstrel.h" |
---|
16 | 13 | #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 | +} |
---|
17 | 30 | |
---|
18 | 31 | static char * |
---|
19 | 32 | minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) |
---|
.. | .. |
---|
41 | 54 | struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; |
---|
42 | 55 | static const int bitrates[4] = { 10, 20, 55, 110 }; |
---|
43 | 56 | int idx = i * MCS_GROUP_RATES + j; |
---|
44 | | - unsigned int prob_ewmsd; |
---|
| 57 | + unsigned int duration; |
---|
45 | 58 | |
---|
46 | 59 | if (!(mi->supported[i] & BIT(j))) |
---|
47 | 60 | continue; |
---|
.. | .. |
---|
79 | 92 | p += sprintf(p, " %3u ", idx); |
---|
80 | 93 | |
---|
81 | 94 | /* 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); |
---|
83 | 98 | p += sprintf(p, "%6u ", tx_time); |
---|
84 | 99 | |
---|
85 | 100 | 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); |
---|
89 | 103 | |
---|
90 | | - p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u" |
---|
| 104 | + p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u" |
---|
91 | 105 | " %3u %3u %-3u " |
---|
92 | 106 | "%9llu %-9llu\n", |
---|
93 | 107 | tp_max / 10, tp_max % 10, |
---|
94 | 108 | tp_avg / 10, tp_avg % 10, |
---|
95 | 109 | eprob / 10, eprob % 10, |
---|
96 | | - prob_ewmsd / 10, prob_ewmsd % 10, |
---|
97 | 110 | mrs->retry_count, |
---|
98 | 111 | mrs->last_success, |
---|
99 | 112 | mrs->last_attempts, |
---|
.. | .. |
---|
130 | 143 | |
---|
131 | 144 | p += sprintf(p, "\n"); |
---|
132 | 145 | p += sprintf(p, |
---|
133 | | - " best ____________rate__________ ________statistics________ _____last____ ______sum-of________\n"); |
---|
| 146 | + " best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n"); |
---|
134 | 147 | 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"); |
---|
136 | 149 | |
---|
137 | 150 | p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p); |
---|
138 | 151 | for (i = 0; i < MINSTREL_CCK_GROUP; i++) |
---|
.. | .. |
---|
144 | 157 | "lookaround %d\n", |
---|
145 | 158 | max(0, (int) mi->total_packets - (int) mi->sample_packets), |
---|
146 | 159 | 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); |
---|
150 | 164 | ms->len = p - ms->buf; |
---|
151 | 165 | WARN_ON(ms->len + sizeof(*ms) > 32768); |
---|
152 | 166 | |
---|
.. | .. |
---|
187 | 201 | struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; |
---|
188 | 202 | static const int bitrates[4] = { 10, 20, 55, 110 }; |
---|
189 | 203 | int idx = i * MCS_GROUP_RATES + j; |
---|
190 | | - unsigned int prob_ewmsd; |
---|
| 204 | + unsigned int duration; |
---|
191 | 205 | |
---|
192 | 206 | if (!(mi->supported[i] & BIT(j))) |
---|
193 | 207 | continue; |
---|
.. | .. |
---|
222 | 236 | } |
---|
223 | 237 | |
---|
224 | 238 | 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); |
---|
226 | 243 | p += sprintf(p, "%u,", tx_time); |
---|
227 | 244 | |
---|
228 | 245 | 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); |
---|
232 | 248 | |
---|
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," |
---|
234 | 250 | "%u,%llu,%llu,", |
---|
235 | 251 | tp_max / 10, tp_max % 10, |
---|
236 | 252 | tp_avg / 10, tp_avg % 10, |
---|
237 | 253 | eprob / 10, eprob % 10, |
---|
238 | | - prob_ewmsd / 10, prob_ewmsd % 10, |
---|
239 | 254 | mrs->retry_count, |
---|
240 | 255 | mrs->last_success, |
---|
241 | 256 | mrs->last_attempts, |
---|
.. | .. |
---|
303 | 318 | { |
---|
304 | 319 | struct minstrel_ht_sta_priv *msp = priv_sta; |
---|
305 | 320 | |
---|
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); |
---|
319 | 325 | } |
---|