0001
0002
0003
0004
0005
0006 #ifndef __RC_MINSTREL_HT_H
0007 #define __RC_MINSTREL_HT_H
0008
0009 #include <linux/bitfield.h>
0010
0011
0012 #define MAX_THR_RATES 4
0013 #define SAMPLE_COLUMNS 10
0014
0015
0016 #define MINSTREL_SCALE 12
0017 #define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
0018 #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
0019
0020 #define EWMA_LEVEL 96
0021 #define EWMA_DIV 128
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \
0033 MINSTREL_AVG_COEFF2 - \
0034 MINSTREL_AVG_COEFF3)
0035 #define MINSTREL_AVG_COEFF2 0x00001499
0036 #define MINSTREL_AVG_COEFF3 -0x0000092e
0037
0038
0039
0040
0041
0042 #define MINSTREL_MAX_STREAMS 4
0043 #define MINSTREL_HT_STREAM_GROUPS 4
0044 #define MINSTREL_VHT_STREAM_GROUPS 6
0045
0046 #define MINSTREL_HT_GROUPS_NB (MINSTREL_MAX_STREAMS * \
0047 MINSTREL_HT_STREAM_GROUPS)
0048 #define MINSTREL_VHT_GROUPS_NB (MINSTREL_MAX_STREAMS * \
0049 MINSTREL_VHT_STREAM_GROUPS)
0050 #define MINSTREL_LEGACY_GROUPS_NB 2
0051 #define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB + \
0052 MINSTREL_VHT_GROUPS_NB + \
0053 MINSTREL_LEGACY_GROUPS_NB)
0054
0055 #define MINSTREL_HT_GROUP_0 0
0056 #define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
0057 #define MINSTREL_OFDM_GROUP (MINSTREL_CCK_GROUP + 1)
0058 #define MINSTREL_VHT_GROUP_0 (MINSTREL_OFDM_GROUP + 1)
0059
0060 #define MCS_GROUP_RATES 10
0061
0062 #define MI_RATE_IDX_MASK GENMASK(3, 0)
0063 #define MI_RATE_GROUP_MASK GENMASK(15, 4)
0064
0065 #define MI_RATE(_group, _idx) \
0066 (FIELD_PREP(MI_RATE_GROUP_MASK, _group) | \
0067 FIELD_PREP(MI_RATE_IDX_MASK, _idx))
0068
0069 #define MI_RATE_IDX(_rate) FIELD_GET(MI_RATE_IDX_MASK, _rate)
0070 #define MI_RATE_GROUP(_rate) FIELD_GET(MI_RATE_GROUP_MASK, _rate)
0071
0072 #define MINSTREL_SAMPLE_RATES 5
0073 #define MINSTREL_SAMPLE_INTERVAL (HZ / 50)
0074
0075 struct minstrel_priv {
0076 struct ieee80211_hw *hw;
0077 bool has_mrr;
0078 unsigned int cw_min;
0079 unsigned int cw_max;
0080 unsigned int max_retry;
0081 unsigned int segment_size;
0082 unsigned int update_interval;
0083
0084 u8 cck_rates[4];
0085 u8 ofdm_rates[NUM_NL80211_BANDS][8];
0086
0087 #ifdef CONFIG_MAC80211_DEBUGFS
0088
0089
0090
0091
0092
0093
0094 u32 fixed_rate_idx;
0095 #endif
0096 };
0097
0098
0099 struct mcs_group {
0100 u16 flags;
0101 u8 streams;
0102 u8 shift;
0103 u8 bw;
0104 u16 duration[MCS_GROUP_RATES];
0105 };
0106
0107 extern const s16 minstrel_cck_bitrates[4];
0108 extern const s16 minstrel_ofdm_bitrates[8];
0109 extern const struct mcs_group minstrel_mcs_groups[];
0110
0111 struct minstrel_rate_stats {
0112
0113 u16 attempts, last_attempts;
0114 u16 success, last_success;
0115
0116
0117 u32 att_hist, succ_hist;
0118
0119
0120 u16 prob_avg;
0121 u16 prob_avg_1;
0122
0123
0124 u8 retry_count;
0125 u8 retry_count_rtscts;
0126
0127 bool retry_updated;
0128 };
0129
0130 enum minstrel_sample_type {
0131 MINSTREL_SAMPLE_TYPE_INC,
0132 MINSTREL_SAMPLE_TYPE_JUMP,
0133 MINSTREL_SAMPLE_TYPE_SLOW,
0134 __MINSTREL_SAMPLE_TYPE_MAX
0135 };
0136
0137 struct minstrel_mcs_group_data {
0138 u8 index;
0139 u8 column;
0140
0141
0142 u16 max_group_tp_rate[MAX_THR_RATES];
0143 u16 max_group_prob_rate;
0144
0145
0146 struct minstrel_rate_stats rates[MCS_GROUP_RATES];
0147 };
0148
0149 struct minstrel_sample_category {
0150 u8 sample_group;
0151 u16 sample_rates[MINSTREL_SAMPLE_RATES];
0152 u16 cur_sample_rates[MINSTREL_SAMPLE_RATES];
0153 };
0154
0155 struct minstrel_ht_sta {
0156 struct ieee80211_sta *sta;
0157
0158
0159 unsigned int ampdu_len;
0160 unsigned int ampdu_packets;
0161
0162
0163 unsigned int avg_ampdu_len;
0164
0165
0166 u16 max_tp_rate[MAX_THR_RATES];
0167 u16 max_prob_rate;
0168
0169
0170 unsigned long last_stats_update;
0171
0172
0173 unsigned int overhead;
0174 unsigned int overhead_rtscts;
0175 unsigned int overhead_legacy;
0176 unsigned int overhead_legacy_rtscts;
0177
0178 unsigned int total_packets;
0179 unsigned int sample_packets;
0180
0181
0182 u32 tx_flags;
0183 bool use_short_preamble;
0184 u8 band;
0185
0186 u8 sample_seq;
0187 u16 sample_rate;
0188
0189 unsigned long sample_time;
0190 struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX];
0191
0192
0193 u16 supported[MINSTREL_GROUPS_NB];
0194
0195
0196 struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
0197 };
0198
0199 void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
0200 int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
0201 int prob_avg);
0202
0203 #endif