rc80211_minstrel_ht_debugfs.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 2 as
00006  * published by the Free Software Foundation.
00007  */
00008 #include <linux/netdevice.h>
00009 #include <linux/types.h>
00010 #include <linux/skbuff.h>
00011 #include <linux/debugfs.h>
00012 #include <linux/ieee80211.h>
00013 #include <linux/export.h>
00014 #include <net/mac80211.h>
00015 #include "rc80211_minstrel.h"
00016 #include "rc80211_minstrel_ht.h"
00017 
00018 static int
00019 minstrel_ht_stats_open(struct inode *inode, struct file *file)
00020 {
00021         struct minstrel_ht_sta_priv *msp = inode->i_private;
00022         struct minstrel_ht_sta *mi = &msp->ht;
00023         struct minstrel_debugfs_info *ms;
00024         unsigned int i, j, tp, prob, eprob;
00025         char *p;
00026         int ret;
00027 
00028         if (!msp->is_ht) {
00029                 inode->i_private = &msp->legacy;
00030                 ret = minstrel_stats_open(inode, file);
00031                 inode->i_private = msp;
00032                 return ret;
00033         }
00034 
00035         ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL);
00036         if (!ms)
00037                 return -ENOMEM;
00038 
00039         file->private_data = ms;
00040         p = ms->buf;
00041         p += sprintf(p, "type      rate     throughput  ewma prob   this prob  "
00042                         "this succ/attempt   success    attempts\n");
00043         for (i = 0; i < MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS; i++) {
00044                 char htmode = '2';
00045                 char gimode = 'L';
00046 
00047                 if (!mi->groups[i].supported)
00048                         continue;
00049 
00050                 if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
00051                         htmode = '4';
00052                 if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI)
00053                         gimode = 'S';
00054 
00055                 for (j = 0; j < MCS_GROUP_RATES; j++) {
00056                         struct minstrel_rate_stats *mr = &mi->groups[i].rates[j];
00057                         int idx = i * MCS_GROUP_RATES + j;
00058 
00059                         if (!(mi->groups[i].supported & BIT(j)))
00060                                 continue;
00061 
00062                         p += sprintf(p, "HT%c0/%cGI ", htmode, gimode);
00063 
00064                         *(p++) = (idx == mi->max_tp_rate) ? 'T' : ' ';
00065                         *(p++) = (idx == mi->max_tp_rate2) ? 't' : ' ';
00066                         *(p++) = (idx == mi->max_prob_rate) ? 'P' : ' ';
00067                         p += sprintf(p, "MCS%-2u", (minstrel_mcs_groups[i].streams - 1) *
00068                                         MCS_GROUP_RATES + j);
00069 
00070                         tp = mr->cur_tp / 10;
00071                         prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
00072                         eprob = MINSTREL_TRUNC(mr->probability * 1000);
00073 
00074                         p += sprintf(p, "  %6u.%1u   %6u.%1u   %6u.%1u        "
00075                                         "%3u(%3u)   %8llu    %8llu\n",
00076                                         tp / 10, tp % 10,
00077                                         eprob / 10, eprob % 10,
00078                                         prob / 10, prob % 10,
00079                                         mr->last_success,
00080                                         mr->last_attempts,
00081                                         (unsigned long long)mr->succ_hist,
00082                                         (unsigned long long)mr->att_hist);
00083                 }
00084         }
00085         p += sprintf(p, "\nTotal packet count::    ideal %d      "
00086                         "lookaround %d\n",
00087                         max(0, (int) mi->total_packets - (int) mi->sample_packets),
00088                         mi->sample_packets);
00089         p += sprintf(p, "Average A-MPDU length: %d.%d\n",
00090                 MINSTREL_TRUNC(mi->avg_ampdu_len),
00091                 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
00092         ms->len = p - ms->buf;
00093 
00094         return nonseekable_open(inode, file);
00095 }
00096 
00097 static const struct file_operations minstrel_ht_stat_fops = {
00098         .owner = THIS_MODULE,
00099         .open = minstrel_ht_stats_open,
00100         .read = minstrel_stats_read,
00101         .release = minstrel_stats_release,
00102         .llseek = no_llseek,
00103 };
00104 
00105 void
00106 minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
00107 {
00108         struct minstrel_ht_sta_priv *msp = priv_sta;
00109 
00110         msp->dbg_stats = debugfs_create_file("rc_stats", S_IRUGO, dir, msp,
00111                         &minstrel_ht_stat_fops);
00112 }
00113 
00114 void
00115 minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta)
00116 {
00117         struct minstrel_ht_sta_priv *msp = priv_sta;
00118 
00119         debugfs_remove(msp->dbg_stats);
00120 }


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:55