1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 1 Feb 2021 10:47:58 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: add debugfs monitoring/controlling
6 This allows user space to monitor tx status and take over rate control
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 create mode 100644 net/mac80211/rc80211_minstrel_ht_api.c
15 @@ -49,6 +49,7 @@ LIB80211_DEBUG=
19 +MAC80211_RC_MINSTREL_DEBUGFS_API=
20 MAC80211_RC_DEFAULT_MINSTREL=
23 --- a/net/mac80211/Kconfig
24 +++ b/net/mac80211/Kconfig
25 @@ -29,6 +29,15 @@ config MAC80211_RC_MINSTREL
27 This option enables the 'minstrel' TX rate control algorithm
29 +config MAC80211_RC_MINSTREL_DEBUGFS_API
30 + bool "Minstrel debugfs userspace control API"
31 + depends on MAC80211_RC_MINSTREL
32 + depends on MAC80211_DEBUGFS
35 + This option creates debugfs files that allow user space to observe
36 + and/or control minstrel rate selection behavior
39 prompt "Default rate control algorithm"
40 depends on MAC80211_HAS_RC
41 --- a/net/mac80211/Makefile
42 +++ b/net/mac80211/Makefile
43 @@ -61,6 +61,9 @@ rc80211_minstrel-y := \
44 rc80211_minstrel-$(CPTCFG_MAC80211_DEBUGFS) += \
45 rc80211_minstrel_ht_debugfs.o
47 +rc80211_minstrel-$(CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API) += \
48 + rc80211_minstrel_ht_api.o
50 mac80211-$(CPTCFG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
53 --- a/net/mac80211/rc80211_minstrel_ht.c
54 +++ b/net/mac80211/rc80211_minstrel_ht.c
55 @@ -276,7 +276,8 @@ static const u8 minstrel_sample_seq[] =
59 -minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
60 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
64 * Some VHT MCSes are invalid (when Ndbps / Nes is not an integer)
65 @@ -346,7 +347,7 @@ minstrel_vht_get_group_idx(struct ieee80
67 static struct minstrel_rate_stats *
68 minstrel_ht_get_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
69 - struct ieee80211_tx_rate *rate)
70 + struct ieee80211_tx_rate *rate, u16 *dest_idx)
74 @@ -381,6 +382,7 @@ minstrel_ht_get_stats(struct minstrel_pr
78 + *dest_idx = MI_RATE(group, idx);
79 return &mi->groups[group].rates[idx];
82 @@ -1024,6 +1026,8 @@ minstrel_ht_update_stats(struct minstrel
83 tp_rate = tmp_legacy_tp_rate;
85 for (i = MCS_GROUP_RATES - 1; i >= 0; i--) {
88 if (!(mi->supported[group] & BIT(i)))
91 @@ -1031,7 +1035,11 @@ minstrel_ht_update_stats(struct minstrel
94 mrs->retry_updated = false;
95 + changed = mrs->attempts > 0;
96 minstrel_ht_calc_rate_stats(mp, mrs);
98 + minstrel_ht_report_rate_update(mp, mi, index,
102 last_prob = max(last_prob, mrs->prob_avg);
103 @@ -1080,7 +1088,8 @@ minstrel_ht_update_stats(struct minstrel
105 mi->max_prob_rate = tmp_max_prob_rate;
107 - minstrel_ht_refill_sample_rates(mi);
108 + if (!minstrel_ht_manual_mode(mp))
109 + minstrel_ht_refill_sample_rates(mi);
111 #ifdef CPTCFG_MAC80211_DEBUGFS
112 /* use fixed index if set */
113 @@ -1177,6 +1186,7 @@ minstrel_ht_tx_status(void *priv, struct
114 struct minstrel_priv *mp = priv;
115 u32 update_interval = mp->update_interval;
116 bool last, update = false;
117 + u16 rate_list[IEEE80211_TX_MAX_RATES] = {};
120 /* This packet was aggregated but doesn't carry status info */
121 @@ -1208,13 +1218,15 @@ minstrel_ht_tx_status(void *priv, struct
122 last = (i == IEEE80211_TX_MAX_RATES - 1) ||
123 !minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]);
125 - rate = minstrel_ht_get_stats(mp, mi, &ar[i]);
126 + rate = minstrel_ht_get_stats(mp, mi, &ar[i], &rate_list[i]);
128 rate->success += info->status.ampdu_ack_len;
130 rate->attempts += ar[i].count * info->status.ampdu_len;
133 + minstrel_ht_report_tx_status(mp, mi, info, rate_list, i);
135 if (mp->hw->max_rates > 1) {
137 * check for sudden death of spatial multiplexing,
138 @@ -1236,7 +1248,7 @@ minstrel_ht_tx_status(void *priv, struct
142 - minstrel_ht_update_rates(mp, mi);
143 + minstrel_ht_update_rates(mp, mi, false);
147 @@ -1299,7 +1311,7 @@ minstrel_calc_retransmit(struct minstrel
153 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
154 struct ieee80211_sta_rates *ratetbl, int offset, int index)
156 @@ -1408,11 +1420,15 @@ minstrel_ht_get_max_amsdu_len(struct min
160 -minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
161 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
164 struct ieee80211_sta_rates *rates;
167 + if (minstrel_ht_manual_mode(mp) && !force)
170 rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
173 @@ -1439,7 +1455,7 @@ minstrel_ht_get_sample_rate(struct minst
177 - if (mp->hw->max_rates > 1) {
178 + if (mp->hw->max_rates > 1 && !minstrel_ht_manual_mode(mp)) {
179 seq = mi->sample_seq;
180 mi->sample_seq = (seq + 1) % ARRAY_SIZE(minstrel_sample_seq);
181 seq = minstrel_sample_seq[seq];
182 @@ -1689,7 +1705,9 @@ minstrel_ht_update_caps(void *priv, stru
184 /* create an initial rate table with the lowest supported rates */
185 minstrel_ht_update_stats(mp, mi);
186 - minstrel_ht_update_rates(mp, mi);
187 + minstrel_ht_update_rates(mp, mi, true);
189 + minstrel_ht_sta_update(mp, mi);
193 @@ -1725,12 +1743,18 @@ minstrel_ht_alloc_sta(void *priv, struct
194 max_rates = sband->n_bitrates;
197 - return kzalloc(sizeof(*mi), gfp);
198 + mi = kzalloc(sizeof(*mi), gfp);
199 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
200 + INIT_LIST_HEAD(&mi->list);
207 minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
209 + minstrel_ht_sta_remove(priv, priv_sta);
213 @@ -1841,12 +1865,14 @@ static void minstrel_ht_add_debugfs(stru
214 mp->fixed_rate_idx = (u32) -1;
215 debugfs_create_u32("fixed_rate_idx", S_IRUGO | S_IWUGO, debugfsdir,
216 &mp->fixed_rate_idx);
217 + minstrel_ht_add_debugfs_api(hw, priv, debugfsdir);
222 minstrel_ht_free(void *priv)
224 + minstrel_ht_remove_debugfs_api(priv);
228 --- a/net/mac80211/rc80211_minstrel_ht.h
229 +++ b/net/mac80211/rc80211_minstrel_ht.h
231 #define MINSTREL_SAMPLE_RATES 5 /* rates per sample type */
232 #define MINSTREL_SAMPLE_INTERVAL (HZ / 50)
234 +#define MINSTREL_MONITOR_STA BIT(0)
235 +#define MINSTREL_MONITOR_TXS BIT(1)
236 +#define MINSTREL_MONITOR_STATS BIT(2)
238 struct minstrel_priv {
239 struct ieee80211_hw *hw;
241 @@ -93,6 +97,13 @@ struct minstrel_priv {
245 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
246 + struct rchan *relay_ev;
247 + struct list_head stations;
255 @@ -153,6 +164,9 @@ struct minstrel_sample_category {
258 struct minstrel_ht_sta {
259 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
260 + struct list_head list;
262 struct ieee80211_sta *sta;
264 /* ampdu length (average, per sampling interval) */
265 @@ -197,6 +211,80 @@ struct minstrel_ht_sta {
268 void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
270 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
271 +void minstrel_ht_sta_update(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
272 +void minstrel_ht_sta_remove(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
273 +void __minstrel_ht_report_tx_status(struct minstrel_priv *mp,
274 + struct minstrel_ht_sta *mi,
275 + struct ieee80211_tx_info *info,
276 + u16 *rate_list, int n_rates);
277 +void __minstrel_ht_report_rate_update(struct minstrel_priv *mp,
278 + struct minstrel_ht_sta *mi, u16 rate,
279 + struct minstrel_rate_stats *mrs);
280 +void minstrel_ht_add_debugfs_api(struct ieee80211_hw *hw, void *priv,
281 + struct dentry *dir);
282 +void minstrel_ht_remove_debugfs_api(void *priv);
285 +minstrel_ht_sta_update(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
289 +minstrel_ht_sta_remove(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
293 +minstrel_ht_add_debugfs_api(struct ieee80211_hw *hw, void *priv,
294 + struct dentry *dir)
298 +minstrel_ht_remove_debugfs_api(void *priv)
304 +minstrel_ht_report_tx_status(struct minstrel_priv *mp,
305 + struct minstrel_ht_sta *mi,
306 + struct ieee80211_tx_info *info,
307 + u16 *rate_list, int n_rates)
309 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
310 + if (!(mp->monitor & MINSTREL_MONITOR_TXS))
313 + __minstrel_ht_report_tx_status(mp, mi, info, rate_list, n_rates);
318 +minstrel_ht_report_rate_update(struct minstrel_priv *mp,
319 + struct minstrel_ht_sta *mi, u16 rate,
320 + struct minstrel_rate_stats *mrs)
322 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
323 + if (!(mp->monitor & MINSTREL_MONITOR_STATS))
326 + __minstrel_ht_report_rate_update(mp, mi, rate, mrs);
331 +minstrel_ht_manual_mode(struct minstrel_priv *mp)
333 +#ifdef CPTCFG_MAC80211_RC_MINSTREL_DEBUGFS_API
340 +void minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
341 + struct ieee80211_sta_rates *ratetbl, int offset,
343 int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
347 +++ b/net/mac80211/rc80211_minstrel_ht_api.c
349 +// SPDX-License-Identifier: GPL-2.0-only
351 + * Copyright (C) 2021 Felix Fietkau <nbd@nbd.name>
353 +#include <linux/kernel.h>
354 +#include <linux/debugfs.h>
355 +#include <linux/relay.h>
356 +#include <net/mac80211.h>
357 +#include "rc80211_minstrel_ht.h"
365 +minstrel_ht_print_rate_durations(struct seq_file *s, int group)
367 + const struct mcs_group *g = &minstrel_mcs_groups[group];
371 + if (g->flags & IEEE80211_TX_RC_VHT_MCS)
376 + seq_printf(s, "%x", g->duration[0] << g->shift);
377 + for (i = 1; i < n_rates; i++)
378 + seq_printf(s, ",%x", g->duration[i] << g->shift);
382 +minstrel_ht_read_api_info(struct seq_file *s, void *data)
386 + seq_printf(s, "#group;index;offset;type;nss;bw;gi;airtime\n");
387 + seq_printf(s, "#sta;action;macaddr;overhead_mcs;overhead_legacy;supported\n");
388 + seq_printf(s, "#txs;macaddr;num_frames;num_acked;probe;rates;counts\n");
389 + seq_printf(s, "#stats;macaddr;rate;avg_prob;avg_tp;cur_success;cur_attempts;hist_success;hist_attempts\n");
390 + seq_printf(s, "#rates;macaddr;rates;counts\n");
391 + seq_printf(s, "#probe;macaddr;rate\n");
392 + for (i = 0; i < MINSTREL_GROUPS_NB; i++) {
393 + const struct mcs_group *g = &minstrel_mcs_groups[i];
396 + if (i == MINSTREL_CCK_GROUP)
398 + else if (i == MINSTREL_OFDM_GROUP)
400 + else if (g->flags & IEEE80211_TX_RC_VHT_MCS)
405 + seq_printf(s, "group;%x;%x;%s;%x;%x;%x;",
406 + i, (u32) MI_RATE(i, 0), type, g->streams, g->bw,
407 + !!(g->flags & IEEE80211_TX_RC_SHORT_GI));
408 + minstrel_ht_print_rate_durations(s, i);
409 + seq_printf(s, "\n");
415 +static struct dentry *
416 +create_buf_file_cb(const char *filename, struct dentry *parent, umode_t mode,
417 + struct rchan_buf *buf, int *is_global)
421 + f = debugfs_create_file("api_event", mode, parent, buf,
422 + &relay_file_operations);
432 +remove_buf_file_cb(struct dentry *f)
439 +static struct rchan_callbacks relay_ev_cb = {
440 + .create_buf_file = create_buf_file_cb,
441 + .remove_buf_file = remove_buf_file_cb,
445 +minstrel_ht_dump_sta(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
448 + char info[64 + MINSTREL_GROUPS_NB * 4];
452 + ofs += scnprintf(info + ofs, sizeof(info) - ofs, "%llx;sta;%s;%pM;%x;%x;",
453 + (unsigned long long)ktime_get_boottime_ns(),
454 + type, mi->sta->addr, mi->overhead, mi->overhead_legacy);
456 + ofs += scnprintf(info + ofs, sizeof(info) - ofs, "%x",
458 + for (i = 1; i < MINSTREL_GROUPS_NB; i++)
459 + ofs += scnprintf(info + ofs, sizeof(info) - ofs, ",%x",
462 + ofs += scnprintf(info + ofs, sizeof(info) - ofs, "\n");
463 + relay_write(mp->relay_ev, info, ofs);
464 + relay_flush(mp->relay_ev);
468 +__minstrel_ht_dump_stations(struct minstrel_priv *mp, const char *type)
470 + struct minstrel_ht_sta *mi;
472 + list_for_each_entry(mi, &mp->stations, list)
473 + minstrel_ht_dump_sta(mp, mi, type);
477 +minstrel_ht_dump_stations(struct minstrel_priv *mp)
479 + spin_lock_bh(&mp->lock);
480 + __minstrel_ht_dump_stations(mp, "dump");
481 + spin_unlock_bh(&mp->lock);
485 +minstrel_ht_api_start(struct minstrel_priv *mp, char *params)
490 + spin_lock_bh(&mp->lock);
492 + while ((cur = strsep(¶ms, ";")) != NULL) {
496 + if (!strcmp(cur, "txs"))
497 + mask |= MINSTREL_MONITOR_TXS;
498 + else if (!strcmp(cur, "sta"))
499 + mask |= MINSTREL_MONITOR_STA;
500 + else if (!strcmp(cur, "stats"))
501 + mask |= MINSTREL_MONITOR_STATS;
505 + mask = MINSTREL_MONITOR_TXS;
508 + __minstrel_ht_dump_stations(mp, "add");
509 + mp->monitor = mask | MINSTREL_MONITOR_STA;
511 + spin_unlock_bh(&mp->lock);
515 +minstrel_ht_api_stop(struct minstrel_priv *mp)
517 + spin_lock_bh(&mp->lock);
519 + relay_reset(mp->relay_ev);
520 + spin_unlock_bh(&mp->lock);
524 +minstrel_ht_reset_sample_table(struct minstrel_ht_sta *mi)
526 + memset(mi->sample[MINSTREL_SAMPLE_TYPE_INC].sample_rates, 0,
527 + sizeof(mi->sample[MINSTREL_SAMPLE_TYPE_INC].sample_rates));
531 +minstrel_ht_api_set_manual(struct minstrel_priv *mp, bool manual)
533 + struct minstrel_ht_sta *mi;
535 + mp->manual = manual;
537 + spin_lock_bh(&mp->lock);
538 + list_for_each_entry(mi, &mp->stations, list)
539 + minstrel_ht_reset_sample_table(mi);
540 + spin_unlock_bh(&mp->lock);
543 +static struct minstrel_ht_sta *
544 +minstrel_ht_api_get_sta(struct minstrel_priv *mp, const u8 *macaddr)
546 + struct minstrel_ht_sta *mi;
548 + list_for_each_entry(mi, &mp->stations, list) {
549 + if (!memcmp(mi->sta->addr, macaddr, ETH_ALEN))
557 +minstrel_ht_get_args(char **dest, int dest_size, char *str, char *sep)
561 + for (i = 0, n = 0; i < dest_size; i++) {
567 + dest[i] = strsep(&str, sep);
576 +minstrel_ht_valid_rate(struct minstrel_ht_sta *mi, u32 rate)
580 + group = MI_RATE_GROUP(rate);
581 + if (group >= MINSTREL_GROUPS_NB)
584 + idx = MI_RATE_IDX(rate);
586 + return !!(mi->supported[group] & BIT(idx));
590 +minstrel_ht_rate_from_str(struct minstrel_ht_sta *mi, const char *str)
594 + if (kstrtouint(str, 16, &rate))
597 + if (!minstrel_ht_valid_rate(mi, rate))
604 +minstrel_ht_set_probe_rate(struct minstrel_ht_sta *mi, const char *rate_str)
612 + rate = minstrel_ht_rate_from_str(mi, rate_str);
616 + sample_rates = mi->sample[MINSTREL_SAMPLE_TYPE_INC].sample_rates;
617 + for (i = 0; i < MINSTREL_SAMPLE_RATES; i++) {
618 + if (sample_rates[i])
621 + sample_rates[i] = rate;
622 + mi->sample_time = jiffies;
630 +minstrel_ht_set_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
631 + char *rate_str, char *count_str)
633 + struct ieee80211_sta_rates *ratetbl;
634 + unsigned int count;
635 + char *countlist[4];
643 + if (!rate_str || !count_str)
646 + ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
650 + n_rates = minstrel_ht_get_args(ratelist, ARRAY_SIZE(ratelist),
652 + n_count = minstrel_ht_get_args(countlist, ARRAY_SIZE(countlist),
654 + for (i = 0; i < min(n_rates, n_count); i++) {
655 + rate = minstrel_ht_rate_from_str(mi, ratelist[i]);
659 + if (kstrtouint(countlist[0], 16, &count))
662 + minstrel_ht_set_rate(mp, mi, ratetbl, i, rate);
663 + ratetbl->rate[i].count = count;
664 + ratetbl->rate[i].count_rts = count;
665 + ratetbl->rate[i].count_cts = count;
668 + rate_control_set_rates(mp->hw, mi->sta, ratetbl);
678 +minstrel_ht_api_sta_cmd(struct minstrel_priv *mp, enum sta_cmd cmd,
681 + struct minstrel_ht_sta *mi;
682 + uint8_t macaddr[ETH_ALEN];
687 + spin_lock_bh(&mp->lock);
691 + n_args = minstrel_ht_get_args(args, ARRAY_SIZE(args), arg_str, ";");
695 + if (!mac_pton(args[0], macaddr))
698 + mi = minstrel_ht_api_get_sta(mp, macaddr);
705 + case STA_CMD_PROBE:
706 + ret = minstrel_ht_set_probe_rate(mi, args[1]);
708 + case STA_CMD_RATES:
709 + ret = minstrel_ht_set_rates(mp, mi, args[1], args[2]);
714 + spin_unlock_bh(&mp->lock);
720 +minstrel_ht_control_write(struct file *file, const char __user *userbuf,
721 + size_t count, loff_t *ppos)
723 + struct minstrel_priv *mp = file->private_data;
726 + size_t len = count;
729 + if (len > sizeof(buf) - 1)
732 + if (copy_from_user(buf, userbuf, len))
735 + if (count > 0 && buf[len - 1] == '\n')
743 + cur = strsep(&pos, ";");
746 + if (!strcmp(cur, "dump"))
747 + minstrel_ht_dump_stations(mp);
748 + else if (!strcmp(cur, "start"))
749 + minstrel_ht_api_start(mp, pos);
750 + else if (!strcmp(cur, "stop"))
751 + minstrel_ht_api_stop(mp);
752 + else if (!strcmp(cur, "manual"))
753 + minstrel_ht_api_set_manual(mp, true);
754 + else if (!strcmp(cur, "auto"))
755 + minstrel_ht_api_set_manual(mp, false);
756 + else if (!strcmp(cur, "rates"))
757 + err = minstrel_ht_api_sta_cmd(mp, STA_CMD_RATES, pos);
758 + else if (!strcmp(cur, "probe"))
759 + err = minstrel_ht_api_sta_cmd(mp, STA_CMD_PROBE, pos);
769 +static const struct file_operations fops_control = {
770 + .open = simple_open,
771 + .llseek = generic_file_llseek,
772 + .write = minstrel_ht_control_write,
775 +void minstrel_ht_sta_update(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
777 + bool add = list_empty(&mi->list);
779 + spin_lock_bh(&mp->lock);
781 + list_add(&mi->list, &mp->stations);
783 + minstrel_ht_dump_sta(mp, mi, add ? "add" : "update");
784 + spin_unlock_bh(&mp->lock);
787 +void minstrel_ht_sta_remove(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
792 + spin_lock_bh(&mp->lock);
793 + list_del_init(&mi->list);
798 + ofs = scnprintf(info, sizeof(info), "%llx;sta;remove;%pM;;;\n",
799 + (unsigned long long)ktime_get_boottime_ns(),
801 + relay_write(mp->relay_ev, info, ofs);
802 + relay_flush(mp->relay_ev);
805 + spin_unlock_bh(&mp->lock);
808 +void __minstrel_ht_report_tx_status(struct minstrel_priv *mp,
809 + struct minstrel_ht_sta *mi,
810 + struct ieee80211_tx_info *info,
814 + char txs[64 + IEEE80211_TX_MAX_RATES * 8];
821 + ofs += scnprintf(txs, sizeof(txs), "%llx;txs;%pM;%x;%x;%x;",
822 + (unsigned long long)ktime_get_boottime_ns(),
824 + info->status.ampdu_len,
825 + info->status.ampdu_ack_len,
826 + !!(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE));
828 + ofs += scnprintf(txs + ofs, sizeof(txs) - ofs, "%x",
830 + for (i = 1; i < n_rates; i++)
831 + ofs += scnprintf(txs + ofs, sizeof(txs) - ofs, ",%x",
834 + ofs += scnprintf(txs + ofs, sizeof(txs) - ofs, ";%x",
835 + info->status.rates[0].count);
836 + for (i = 1; i < n_rates; i++)
837 + ofs += scnprintf(txs + ofs, sizeof(txs) - ofs, ",%x",
838 + info->status.rates[i].count);
839 + ofs += scnprintf(txs + ofs, sizeof(txs) - ofs, "\n");
840 + relay_write(mp->relay_ev, txs, ofs);
841 + relay_flush(mp->relay_ev);
844 +void __minstrel_ht_report_rate_update(struct minstrel_priv *mp,
845 + struct minstrel_ht_sta *mi, u16 rate,
846 + struct minstrel_rate_stats *mrs)
852 + tp = minstrel_ht_get_tp_avg(mi, MI_RATE_GROUP(rate), MI_RATE_IDX(rate),
855 + ofs = scnprintf(stat, sizeof(stat),
856 + "%llx;stats;%pM;%x;%x;%x;%x;%x;%x;%x\n",
857 + (unsigned long long)ktime_get_boottime_ns(),
858 + mi->sta->addr, rate,
859 + MINSTREL_TRUNC(mrs->prob_avg * 1000), tp,
861 + mrs->last_attempts,
862 + mrs->succ_hist, mrs->att_hist);
864 + relay_write(mp->relay_ev, stat, ofs);
865 + relay_flush(mp->relay_ev);
868 +void minstrel_ht_add_debugfs_api(struct ieee80211_hw *hw, void *priv,
869 + struct dentry *dir)
871 + struct minstrel_priv *mp = priv;
873 + spin_lock_init(&mp->lock);
874 + INIT_LIST_HEAD(&mp->stations);
875 + mp->relay_ev = relay_open("api_event", dir, 256, 512, &relay_ev_cb,
877 + debugfs_create_devm_seqfile(&hw->wiphy->dev, "api_info",
878 + dir, minstrel_ht_read_api_info);
879 + debugfs_create_file("api_control", 0200, dir, mp, &fops_control);
882 +void minstrel_ht_remove_debugfs_api(void *priv)
884 + struct minstrel_priv *mp = priv;
887 + relay_close(mp->relay_ev);