Path: blob/master/net/mac80211/rc80211_minstrel_ht_debugfs.c
15109 views
/*1* Copyright (C) 2010 Felix Fietkau <[email protected]>2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License version 2 as5* published by the Free Software Foundation.6*/7#include <linux/netdevice.h>8#include <linux/types.h>9#include <linux/skbuff.h>10#include <linux/debugfs.h>11#include <linux/ieee80211.h>12#include <net/mac80211.h>13#include "rc80211_minstrel.h"14#include "rc80211_minstrel_ht.h"1516static int17minstrel_ht_stats_open(struct inode *inode, struct file *file)18{19struct minstrel_ht_sta_priv *msp = inode->i_private;20struct minstrel_ht_sta *mi = &msp->ht;21struct minstrel_debugfs_info *ms;22unsigned int i, j, tp, prob, eprob;23char *p;24int ret;2526if (!msp->is_ht) {27inode->i_private = &msp->legacy;28ret = minstrel_stats_open(inode, file);29inode->i_private = msp;30return ret;31}3233ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL);34if (!ms)35return -ENOMEM;3637file->private_data = ms;38p = ms->buf;39p += sprintf(p, "type rate throughput ewma prob this prob "40"this succ/attempt success attempts\n");41for (i = 0; i < MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS; i++) {42char htmode = '2';43char gimode = 'L';4445if (!mi->groups[i].supported)46continue;4748if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)49htmode = '4';50if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI)51gimode = 'S';5253for (j = 0; j < MCS_GROUP_RATES; j++) {54struct minstrel_rate_stats *mr = &mi->groups[i].rates[j];55int idx = i * MCS_GROUP_RATES + j;5657if (!(mi->groups[i].supported & BIT(j)))58continue;5960p += sprintf(p, "HT%c0/%cGI ", htmode, gimode);6162*(p++) = (idx == mi->max_tp_rate) ? 'T' : ' ';63*(p++) = (idx == mi->max_tp_rate2) ? 't' : ' ';64*(p++) = (idx == mi->max_prob_rate) ? 'P' : ' ';65p += sprintf(p, "MCS%-2u", (minstrel_mcs_groups[i].streams - 1) *66MCS_GROUP_RATES + j);6768tp = mr->cur_tp / 10;69prob = MINSTREL_TRUNC(mr->cur_prob * 1000);70eprob = MINSTREL_TRUNC(mr->probability * 1000);7172p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "73"%3u(%3u) %8llu %8llu\n",74tp / 10, tp % 10,75eprob / 10, eprob % 10,76prob / 10, prob % 10,77mr->last_success,78mr->last_attempts,79(unsigned long long)mr->succ_hist,80(unsigned long long)mr->att_hist);81}82}83p += sprintf(p, "\nTotal packet count:: ideal %d "84"lookaround %d\n",85max(0, (int) mi->total_packets - (int) mi->sample_packets),86mi->sample_packets);87p += sprintf(p, "Average A-MPDU length: %d.%d\n",88MINSTREL_TRUNC(mi->avg_ampdu_len),89MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);90ms->len = p - ms->buf;9192return nonseekable_open(inode, file);93}9495static const struct file_operations minstrel_ht_stat_fops = {96.owner = THIS_MODULE,97.open = minstrel_ht_stats_open,98.read = minstrel_stats_read,99.release = minstrel_stats_release,100.llseek = no_llseek,101};102103void104minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)105{106struct minstrel_ht_sta_priv *msp = priv_sta;107108msp->dbg_stats = debugfs_create_file("rc_stats", S_IRUGO, dir, msp,109&minstrel_ht_stat_fops);110}111112void113minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta)114{115struct minstrel_ht_sta_priv *msp = priv_sta;116117debugfs_remove(msp->dbg_stats);118}119120121