00001 /* 00002 * Copyright (C) 2008 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_H 00010 #define __RC_MINSTREL_H 00011 00012 struct minstrel_rate { 00013 int bitrate; 00014 int rix; 00015 00016 unsigned int perfect_tx_time; 00017 unsigned int ack_time; 00018 00019 int sample_limit; 00020 unsigned int retry_count; 00021 unsigned int retry_count_cts; 00022 unsigned int retry_count_rtscts; 00023 unsigned int adjusted_retry_count; 00024 00025 u32 success; 00026 u32 attempts; 00027 u32 last_attempts; 00028 u32 last_success; 00029 00030 /* parts per thousand */ 00031 u32 cur_prob; 00032 u32 probability; 00033 00034 /* per-rate throughput */ 00035 u32 cur_tp; 00036 00037 u64 succ_hist; 00038 u64 att_hist; 00039 }; 00040 00041 struct minstrel_sta_info { 00042 unsigned long stats_update; 00043 unsigned int sp_ack_dur; 00044 unsigned int rate_avg; 00045 00046 unsigned int lowest_rix; 00047 00048 unsigned int max_tp_rate; 00049 unsigned int max_tp_rate2; 00050 unsigned int max_prob_rate; 00051 unsigned int packet_count; 00052 unsigned int sample_count; 00053 int sample_deferred; 00054 00055 unsigned int sample_idx; 00056 unsigned int sample_column; 00057 00058 int n_rates; 00059 struct minstrel_rate *r; 00060 bool prev_sample; 00061 00062 /* sampling table */ 00063 u8 *sample_table; 00064 00065 #ifdef CONFIG_MAC80211_DEBUGFS 00066 struct dentry *dbg_stats; 00067 #endif 00068 }; 00069 00070 struct minstrel_priv { 00071 struct ieee80211_hw *hw; 00072 bool has_mrr; 00073 unsigned int cw_min; 00074 unsigned int cw_max; 00075 unsigned int max_retry; 00076 unsigned int ewma_level; 00077 unsigned int segment_size; 00078 unsigned int update_interval; 00079 unsigned int lookaround_rate; 00080 unsigned int lookaround_rate_mrr; 00081 00082 #ifdef CONFIG_MAC80211_DEBUGFS 00083 /* 00084 * enable fixed rate processing per RC 00085 * - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx 00086 * - write -1 to enable RC processing again 00087 * - setting will be applied on next update 00088 */ 00089 u32 fixed_rate_idx; 00090 struct dentry *dbg_fixed_rate; 00091 #endif 00092 00093 }; 00094 00095 struct minstrel_debugfs_info { 00096 size_t len; 00097 char buf[]; 00098 }; 00099 00100 extern struct rate_control_ops mac80211_minstrel; 00101 void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); 00102 void minstrel_remove_sta_debugfs(void *priv, void *priv_sta); 00103 00104 /* debugfs */ 00105 int minstrel_stats_open(struct inode *inode, struct file *file); 00106 ssize_t minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos); 00107 int minstrel_stats_release(struct inode *inode, struct file *file); 00108 00109 #endif