Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include <linux/netdevice.h>
00048 #include <linux/types.h>
00049 #include <linux/skbuff.h>
00050 #include <linux/debugfs.h>
00051 #include <linux/ieee80211.h>
00052 #include <linux/slab.h>
00053 #include <linux/export.h>
00054 #include <net/mac80211.h>
00055 #include "rc80211_minstrel.h"
00056
00057 int
00058 minstrel_stats_open(struct inode *inode, struct file *file)
00059 {
00060 struct minstrel_sta_info *mi = inode->i_private;
00061 struct minstrel_debugfs_info *ms;
00062 unsigned int i, tp, prob, eprob;
00063 char *p;
00064
00065 ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL);
00066 if (!ms)
00067 return -ENOMEM;
00068
00069 file->private_data = ms;
00070 p = ms->buf;
00071 p += sprintf(p, "rate throughput ewma prob this prob "
00072 "this succ/attempt success attempts\n");
00073 for (i = 0; i < mi->n_rates; i++) {
00074 struct minstrel_rate *mr = &mi->r[i];
00075
00076 *(p++) = (i == mi->max_tp_rate) ? 'T' : ' ';
00077 *(p++) = (i == mi->max_tp_rate2) ? 't' : ' ';
00078 *(p++) = (i == mi->max_prob_rate) ? 'P' : ' ';
00079 p += sprintf(p, "%3u%s", mr->bitrate / 2,
00080 (mr->bitrate & 1 ? ".5" : " "));
00081
00082 tp = mr->cur_tp / ((18000 << 10) / 96);
00083 prob = mr->cur_prob / 18;
00084 eprob = mr->probability / 18;
00085
00086 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
00087 "%3u(%3u) %8llu %8llu\n",
00088 tp / 10, tp % 10,
00089 eprob / 10, eprob % 10,
00090 prob / 10, prob % 10,
00091 mr->last_success,
00092 mr->last_attempts,
00093 (unsigned long long)mr->succ_hist,
00094 (unsigned long long)mr->att_hist);
00095 }
00096 p += sprintf(p, "\nTotal packet count:: ideal %d "
00097 "lookaround %d\n\n",
00098 mi->packet_count - mi->sample_count,
00099 mi->sample_count);
00100 ms->len = p - ms->buf;
00101
00102 return 0;
00103 }
00104
00105 ssize_t
00106 minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
00107 {
00108 struct minstrel_debugfs_info *ms;
00109
00110 ms = file->private_data;
00111 return simple_read_from_buffer(buf, len, ppos, ms->buf, ms->len);
00112 }
00113
00114 int
00115 minstrel_stats_release(struct inode *inode, struct file *file)
00116 {
00117 kfree(file->private_data);
00118 return 0;
00119 }
00120
00121 static const struct file_operations minstrel_stat_fops = {
00122 .owner = THIS_MODULE,
00123 .open = minstrel_stats_open,
00124 .read = minstrel_stats_read,
00125 .release = minstrel_stats_release,
00126 .llseek = default_llseek,
00127 };
00128
00129 void
00130 minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
00131 {
00132 struct minstrel_sta_info *mi = priv_sta;
00133
00134 mi->dbg_stats = debugfs_create_file("rc_stats", S_IRUGO, dir, mi,
00135 &minstrel_stat_fops);
00136 }
00137
00138 void
00139 minstrel_remove_sta_debugfs(void *priv, void *priv_sta)
00140 {
00141 struct minstrel_sta_info *mi = priv_sta;
00142
00143 debugfs_remove(mi->dbg_stats);
00144 }