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 00009 #ifndef __RC_MINSTREL_HT_H 00010 #define __RC_MINSTREL_HT_H 00011 00012 /* 00013 * The number of streams can be changed to 2 to reduce code 00014 * size and memory footprint. 00015 */ 00016 #define MINSTREL_MAX_STREAMS 3 00017 #define MINSTREL_STREAM_GROUPS 4 00018 00019 /* scaled fraction values */ 00020 #define MINSTREL_SCALE 16 00021 #define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) 00022 #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) 00023 00024 #define MCS_GROUP_RATES 8 00025 00026 struct mcs_group { 00027 u32 flags; 00028 unsigned int streams; 00029 unsigned int duration[MCS_GROUP_RATES]; 00030 }; 00031 00032 extern const struct mcs_group minstrel_mcs_groups[]; 00033 00034 struct minstrel_rate_stats { 00035 /* current / last sampling period attempts/success counters */ 00036 unsigned int attempts, last_attempts; 00037 unsigned int success, last_success; 00038 00039 /* total attempts/success counters */ 00040 u64 att_hist, succ_hist; 00041 00042 /* current throughput */ 00043 unsigned int cur_tp; 00044 00045 /* packet delivery probabilities */ 00046 unsigned int cur_prob, probability; 00047 00048 /* maximum retry counts */ 00049 unsigned int retry_count; 00050 unsigned int retry_count_rtscts; 00051 00052 bool retry_updated; 00053 u8 sample_skipped; 00054 }; 00055 00056 struct minstrel_mcs_group_data { 00057 u8 index; 00058 u8 column; 00059 00060 /* bitfield of supported MCS rates of this group */ 00061 u8 supported; 00062 00063 /* selected primary rates */ 00064 unsigned int max_tp_rate; 00065 unsigned int max_tp_rate2; 00066 unsigned int max_prob_rate; 00067 00068 /* MCS rate statistics */ 00069 struct minstrel_rate_stats rates[MCS_GROUP_RATES]; 00070 }; 00071 00072 struct minstrel_ht_sta { 00073 /* ampdu length (average, per sampling interval) */ 00074 unsigned int ampdu_len; 00075 unsigned int ampdu_packets; 00076 00077 /* ampdu length (EWMA) */ 00078 unsigned int avg_ampdu_len; 00079 00080 /* best throughput rate */ 00081 unsigned int max_tp_rate; 00082 00083 /* second best throughput rate */ 00084 unsigned int max_tp_rate2; 00085 00086 /* best probability rate */ 00087 unsigned int max_prob_rate; 00088 00089 /* time of last status update */ 00090 unsigned long stats_update; 00091 00092 /* overhead time in usec for each frame */ 00093 unsigned int overhead; 00094 unsigned int overhead_rtscts; 00095 00096 unsigned int total_packets; 00097 unsigned int sample_packets; 00098 00099 /* tx flags to add for frames for this sta */ 00100 u32 tx_flags; 00101 00102 u8 sample_wait; 00103 u8 sample_tries; 00104 u8 sample_count; 00105 u8 sample_slow; 00106 00107 /* current MCS group to be sampled */ 00108 u8 sample_group; 00109 00110 /* MCS rate group info and statistics */ 00111 struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS]; 00112 }; 00113 00114 struct minstrel_ht_sta_priv { 00115 union { 00116 struct minstrel_ht_sta ht; 00117 struct minstrel_sta_info legacy; 00118 }; 00119 #ifdef CONFIG_MAC80211_DEBUGFS 00120 struct dentry *dbg_stats; 00121 #endif 00122 void *ratelist; 00123 void *sample_table; 00124 bool is_ht; 00125 }; 00126 00127 void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); 00128 void minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta); 00129 00130 #endif