cregit-Linux how code gets into the kernel

Release 4.8 net/mac80211/rc80211_minstrel_ht.c

Directory: net/mac80211
/*
 * Copyright (C) 2010-2013 Felix Fietkau <nbd@openwrt.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/debugfs.h>
#include <linux/random.h>
#include <linux/moduleparam.h>
#include <linux/ieee80211.h>
#include <net/mac80211.h>
#include "rate.h"
#include "rc80211_minstrel.h"
#include "rc80211_minstrel_ht.h"


#define AVG_AMPDU_SIZE	16

#define AVG_PKT_SIZE	1200

/* Number of bits for an average sized packet */

#define MCS_NBITS ((AVG_PKT_SIZE * AVG_AMPDU_SIZE) << 3)

/* Number of symbols for a packet with (bps) bits per symbol */

#define MCS_NSYMS(bps) DIV_ROUND_UP(MCS_NBITS, (bps))

/* Transmission time (nanoseconds) for a packet containing (syms) symbols */

#define MCS_SYMBOL_TIME(sgi, syms)					\
	(sgi ?                                                          \
          ((syms) * 18000 + 4000) / 5 :	/* syms * 3.6 us */		\
          ((syms) * 1000) << 2		/* syms * 4 us */		\
        )

/* Transmit duration for the raw data part of an average sized packet */

#define MCS_DURATION(streams, sgi, bps) \
	(MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps))) / AVG_AMPDU_SIZE)


#define BW_20			0

#define BW_40			1

#define BW_80			2

/*
 * Define group sort order: HT40 -> SGI -> #streams
 */

#define GROUP_IDX(_streams, _sgi, _ht40)	\
	MINSTREL_HT_GROUP_0 +                   \
        MINSTREL_MAX_STREAMS * 2 * _ht40 +      \
        MINSTREL_MAX_STREAMS * _sgi +   \
        _streams - 1

/* MCS rate information for an MCS group */

#define MCS_GROUP(_streams, _sgi, _ht40)				\
	[GROUP_IDX(_streams, _sgi, _ht40)] = {                          \
        .streams = _streams,                                            \
        .flags =                                                        \
                IEEE80211_TX_RC_MCS |                                   \
                (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) |                 \
                (_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),             \
        .duration = {                                                   \
                MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26),          \
                MCS_DURATION(_streams, _sgi, _ht40 ? 108 : 52),         \
                MCS_DURATION(_streams, _sgi, _ht40 ? 162 : 78),         \
                MCS_DURATION(_streams, _sgi, _ht40 ? 216 : 104),        \
                MCS_DURATION(_streams, _sgi, _ht40 ? 324 : 156),        \
                MCS_DURATION(_streams, _sgi, _ht40 ? 432 : 208),        \
                MCS_DURATION(_streams, _sgi, _ht40 ? 486 : 234),        \
                MCS_DURATION(_streams, _sgi, _ht40 ? 540 : 260)         \
        }                                                               \
}


#define VHT_GROUP_IDX(_streams, _sgi, _bw)				\
	(MINSTREL_VHT_GROUP_0 +                                         \
         MINSTREL_MAX_STREAMS * 2 * (_bw) +                             \
         MINSTREL_MAX_STREAMS * (_sgi) +                                \
         (_streams) - 1)


#define BW2VBPS(_bw, r3, r2, r1)					\
	(_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)


#define VHT_GROUP(_streams, _sgi, _bw)					\
	[VHT_GROUP_IDX(_streams, _sgi, _bw)] = {                        \
        .streams = _streams,                                            \
        .flags =                                                        \
                IEEE80211_TX_RC_VHT_MCS |                               \
                (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) |                 \
                (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :          \
                 _bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),      \
        .duration = {                                                   \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw,  117,  54,  26)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw,  234, 108,  52)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw,  351, 162,  78)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw,  468, 216, 104)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw,  702, 324, 156)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw,  936, 432, 208)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw, 1053, 486, 234)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw, 1170, 540, 260)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw, 1404, 648, 312)),             \
                MCS_DURATION(_streams, _sgi,                            \
                             BW2VBPS(_bw, 1560, 720, 346))              \
        }                                                               \
}


#define CCK_DURATION(_bitrate, _short, _len)		\
	(1000 * (10 /* SIFS */ +                       \
         (_short ? 72 + 24 : 144 + 48) +                \
         (8 * (_len + 4) * 10) / (_bitrate)))


#define CCK_ACK_DURATION(_bitrate, _short)			\
	(CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) +   \
         CCK_DURATION(_bitrate, _short, AVG_PKT_SIZE))


#define CCK_DURATION_LIST(_short)			\
	CCK_ACK_DURATION(10, _short),                   \
        CCK_ACK_DURATION(20, _short),                   \
        CCK_ACK_DURATION(55, _short),                   \
        CCK_ACK_DURATION(110, _short)


#define CCK_GROUP					\
	[MINSTREL_CCK_GROUP] = {                        \
                .streams = 0,                           \
                .flags = 0,                             \
                .duration = {                           \
                        CCK_DURATION_LIST(false),       \
                        CCK_DURATION_LIST(true)         \
                }                                       \
        }

#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT

static bool minstrel_vht_only = true;
module_param(minstrel_vht_only, bool, 0644);
MODULE_PARM_DESC(minstrel_vht_only,
		 "Use only VHT rates when VHT is supported by sta.");
#endif

/*
 * To enable sufficiently targeted rate sampling, MCS rates are divided into
 * groups, based on the number of streams and flags (HT40, SGI) that they
 * use.
 *
 * Sortorder has to be fixed for GROUP_IDX macro to be applicable:
 * BW -> SGI -> #streams
 */

const struct mcs_group minstrel_mcs_groups[] = {
	MCS_GROUP(1, 0, BW_20),
	MCS_GROUP(2, 0, BW_20),
#if MINSTREL_MAX_STREAMS >= 3
	MCS_GROUP(3, 0, BW_20),
#endif

	MCS_GROUP(1, 1, BW_20),
	MCS_GROUP(2, 1, BW_20),
#if MINSTREL_MAX_STREAMS >= 3
	MCS_GROUP(3, 1, BW_20),
#endif

	MCS_GROUP(1, 0, BW_40),
	MCS_GROUP(2, 0, BW_40),
#if MINSTREL_MAX_STREAMS >= 3
	MCS_GROUP(3, 0, BW_40),
#endif

	MCS_GROUP(1, 1, BW_40),
	MCS_GROUP(2, 1, BW_40),
#if MINSTREL_MAX_STREAMS >= 3
	MCS_GROUP(3, 1, BW_40),
#endif

	CCK_GROUP,

#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
	VHT_GROUP(1, 0, BW_20),
	VHT_GROUP(2, 0, BW_20),
#if MINSTREL_MAX_STREAMS >= 3
	VHT_GROUP(3, 0, BW_20),
#endif

	VHT_GROUP(1, 1, BW_20),
	VHT_GROUP(2, 1, BW_20),
#if MINSTREL_MAX_STREAMS >= 3
	VHT_GROUP(3, 1, BW_20),
#endif

	VHT_GROUP(1, 0, BW_40),
	VHT_GROUP(2, 0, BW_40),
#if MINSTREL_MAX_STREAMS >= 3
	VHT_GROUP(3, 0, BW_40),
#endif

	VHT_GROUP(1, 1, BW_40),
	VHT_GROUP(2, 1, BW_40),
#if MINSTREL_MAX_STREAMS >= 3
	VHT_GROUP(3, 1, BW_40),
#endif

	VHT_GROUP(1, 0, BW_80),
	VHT_GROUP(2, 0, BW_80),
#if MINSTREL_MAX_STREAMS >= 3
	VHT_GROUP(3, 0, BW_80),
#endif

	VHT_GROUP(1, 1, BW_80),
	VHT_GROUP(2, 1, BW_80),
#if MINSTREL_MAX_STREAMS >= 3
	VHT_GROUP(3, 1, BW_80),
#endif
#endif
};


static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;

static void
minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);

/*
 * Some VHT MCSes are invalid (when Ndbps / Nes is not an integer)
 * e.g for MCS9@20MHzx1Nss: Ndbps=8x52*(5/6) Nes=1
 *
 * Returns the valid mcs map for struct minstrel_mcs_group_data.supported
 */

static u16 minstrel_get_valid_vht_rates(int bw, int nss, __le16 mcs_map) { u16 mask = 0; if (bw == BW_20) { if (nss != 3 && nss != 6) mask = BIT(9); } else if (bw == BW_80) { if (nss == 3 || nss == 7) mask = BIT(6); else if (nss == 6) mask = BIT(9); } else { WARN_ON(bw != BW_40); } switch ((le16_to_cpu(mcs_map) >> (2 * (nss - 1))) & 3) { case IEEE80211_VHT_MCS_SUPPORT_0_7: mask |= 0x300; break; case IEEE80211_VHT_MCS_SUPPORT_0_8: mask |= 0x200; break; case IEEE80211_VHT_MCS_SUPPORT_0_9: break; default: mask = 0x3ff; } return 0x3ff & ~mask; }

Contributors

PersonTokensPropCommitsCommitProp
karl beldankarl beldan149100.00%1100.00%
Total149100.00%1100.00%

/* * Look up an MCS group index based on mac80211 rate information */
static int minstrel_ht_get_group_idx(struct ieee80211_tx_rate *rate) { return GROUP_IDX((rate->idx / 8) + 1, !!(rate->flags & IEEE80211_TX_RC_SHORT_GI), !!(rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)); }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau2555.56%125.00%
helmut schaahelmut schaa1431.11%125.00%
karl beldankarl beldan613.33%250.00%
Total45100.00%4100.00%


static int minstrel_vht_get_group_idx(struct ieee80211_tx_rate *rate) { return VHT_GROUP_IDX(ieee80211_rate_get_vht_nss(rate), !!(rate->flags & IEEE80211_TX_RC_SHORT_GI), !!(rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + 2*!!(rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)); }

Contributors

PersonTokensPropCommitsCommitProp
karl beldankarl beldan4892.31%150.00%
felix fietkaufelix fietkau47.69%150.00%
Total52100.00%2100.00%


static struct minstrel_rate_stats * minstrel_ht_get_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, struct ieee80211_tx_rate *rate) { int group, idx; if (rate->flags & IEEE80211_TX_RC_MCS) { group = minstrel_ht_get_group_idx(rate); idx = rate->idx % 8; } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { group = minstrel_vht_get_group_idx(rate); idx = ieee80211_rate_get_vht_mcs(rate); } else { group = MINSTREL_CCK_GROUP; for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++) if (rate->idx == mp->cck_rates[idx]) break; /* short preamble */ if (!(mi->groups[group].supported & BIT(idx))) idx += 4; } return &mi->groups[group].rates[idx]; }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau12983.23%250.00%
karl beldankarl beldan2616.77%250.00%
Total155100.00%4100.00%


static inline struct minstrel_rate_stats * minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index) { return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES]; }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau35100.00%2100.00%
Total35100.00%2100.00%

/* * Return current throughput based on the average A-MPDU length, taking into * account the expected number of retransmissions and their expected length */
int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, int prob_ewma) { unsigned int nsecs = 0; /* do not account throughput if sucess prob is below 10% */ if (prob_ewma < MINSTREL_FRAC(10, 100)) return 0; if (group != MINSTREL_CCK_GROUP) nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); nsecs += minstrel_mcs_groups[group].duration[rate]; /* * For the throughput calculation, limit the probability value to 90% to * account for collision related packet error rate fluctuation * (prob is scaled - see MINSTREL_FRAC above) */ if (prob_ewma > MINSTREL_FRAC(90, 100)) return MINSTREL_TRUNC(100000 * ((MINSTREL_FRAC(90, 100) * 1000) / nsecs)); else return MINSTREL_TRUNC(100000 * ((prob_ewma * 1000) / nsecs)); }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau7258.54%457.14%
thomas huehnthomas huehn5141.46%342.86%
Total123100.00%7100.00%

/* * Find & sort topmost throughput rates * * If multiple rates provide equal throughput the sorting is based on their * current success probability. Higher success probability is preferred among * MCS groups, CCK rates do not provide aggregation and are therefore at last. */
static void minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index, u16 *tp_list) { int cur_group, cur_idx, cur_tp_avg, cur_prob; int tmp_group, tmp_idx, tmp_tp_avg, tmp_prob; int j = MAX_THR_RATES; cur_group = index / MCS_GROUP_RATES; cur_idx = index % MCS_GROUP_RATES; cur_prob = mi->groups[cur_group].rates[cur_idx].prob_ewma; cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx, cur_prob); do { tmp_group = tp_list[j - 1] / MCS_GROUP_RATES; tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES; tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma; tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); if (cur_tp_avg < tmp_tp_avg || (cur_tp_avg == tmp_tp_avg && cur_prob <= tmp_prob)) break; j--; } while (j > 0); if (j < MAX_THR_RATES - 1) { memmove(&tp_list[j + 1], &tp_list[j], (sizeof(*tp_list) * (MAX_THR_RATES - (j + 1)))); } if (j < MAX_THR_RATES) tp_list[j] = index; }

Contributors

PersonTokensPropCommitsCommitProp
thomas huehnthomas huehn16273.30%444.44%
felix fietkaufelix fietkau4922.17%222.22%
karl beldankarl beldan104.52%333.33%
Total221100.00%9100.00%

/* * Find and set the topmost probability rate per sta and per group */
static void minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index) { struct minstrel_mcs_group_data *mg; struct minstrel_rate_stats *mrs; int tmp_group, tmp_idx, tmp_tp_avg, tmp_prob; int max_tp_group, cur_tp_avg, cur_group, cur_idx; int max_gpr_group, max_gpr_idx; int max_gpr_tp_avg, max_gpr_prob; cur_group = index / MCS_GROUP_RATES; cur_idx = index % MCS_GROUP_RATES; mg = &mi->groups[index / MCS_GROUP_RATES]; mrs = &mg->rates[index % MCS_GROUP_RATES]; tmp_group = mi->max_prob_rate / MCS_GROUP_RATES; tmp_idx = mi->max_prob_rate % MCS_GROUP_RATES; tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma; tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */ max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES; if((index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) && (max_tp_group != MINSTREL_CCK_GROUP)) return; max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES; max_gpr_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_ewma; if (mrs->prob_ewma > MINSTREL_FRAC(75, 100)) { cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx, mrs->prob_ewma); if (cur_tp_avg > tmp_tp_avg) mi->max_prob_rate = index; max_gpr_tp_avg = minstrel_ht_get_tp_avg(mi, max_gpr_group, max_gpr_idx, max_gpr_prob); if (cur_tp_avg > max_gpr_tp_avg) mg->max_group_prob_rate = index; } else { if (mrs->prob_ewma > tmp_prob) mi->max_prob_rate = index; if (mrs->prob_ewma > max_gpr_prob) mg->max_group_prob_rate = index; } }

Contributors

PersonTokensPropCommitsCommitProp
thomas huehnthomas huehn20670.55%444.44%
felix fietkaufelix fietkau3511.99%111.11%
konstantin khlebnikovkonstantin khlebnikov3311.30%111.11%
karl beldankarl beldan175.82%222.22%
lei minglei ming10.34%111.11%
Total292100.00%9100.00%

/* * Assign new rate set per sta and use CCK rates only if the fastest * rate (max_tp_rate[0]) is from CCK group. This prohibits such sorted * rate sets where MCS and CCK rates are mixed, because CCK rates can * not use aggregation. */
static void minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi, u16 tmp_mcs_tp_rate[MAX_THR_RATES], u16 tmp_cck_tp_rate[MAX_THR_RATES]) { unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp, tmp_prob; int i; tmp_group = tmp_cck_tp_rate[0] / MCS_GROUP_RATES; tmp_idx = tmp_cck_tp_rate[0] % MCS_GROUP_RATES; tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma; tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); tmp_group = tmp_mcs_tp_rate[0] / MCS_GROUP_RATES; tmp_idx = tmp_mcs_tp_rate[0] % MCS_GROUP_RATES; tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma; tmp_mcs_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob); if (tmp_cck_tp > tmp_mcs_tp) { for(i = 0; i < MAX_THR_RATES; i++) { minstrel_ht_sort_best_tp_rates(mi, tmp_cck_tp_rate[i], tmp_mcs_tp_rate); } } }

Contributors

PersonTokensPropCommitsCommitProp
thomas huehnthomas huehn15492.22%360.00%
felix fietkaufelix fietkau116.59%120.00%
karl beldankarl beldan21.20%120.00%
Total167100.00%5100.00%

/* * Try to increase robustness of max_prob rate by decrease number of * streams if possible. */
static inline void minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi) { struct minstrel_mcs_group_data *mg; int tmp_max_streams, group, tmp_idx, tmp_prob; int tmp_tp = 0; tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] / MCS_GROUP_RATES].streams; for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { mg = &mi->groups[group]; if (!mg->supported || group == MINSTREL_CCK_GROUP) continue; tmp_idx = mg->max_group_prob_rate % MCS_GROUP_RATES; tmp_prob = mi->groups[group].rates[tmp_idx].prob_ewma; if (tmp_tp < minstrel_ht_get_tp_avg(mi, group, tmp_idx, tmp_prob) && (minstrel_mcs_groups[group].streams < tmp_max_streams)) { mi->max_prob_rate = mg->max_group_prob_rate; tmp_tp = minstrel_ht_get_tp_avg(mi, group, tmp_idx, tmp_prob); } } }

Contributors

PersonTokensPropCommitsCommitProp
thomas huehnthomas huehn10465.00%360.00%
felix fietkaufelix fietkau5635.00%240.00%
Total160100.00%5100.00%

/* * Update rate statistics and select new primary rates * * Rules for rate selection: * - max_prob_rate must use only one stream, as a tradeoff between delivery * probability and throughput during strong fluctuations * - as long as the max prob rate has a probability of more than 75%, pick * higher throughput rates, even if the probablity is a bit lower */
static void minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) { struct minstrel_mcs_group_data *mg; struct minstrel_rate_stats *mrs; int group, i, j, cur_prob; u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES]; u16 tmp_cck_tp_rate[MAX_THR_RATES], index; if (mi->ampdu_packets > 0) { mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len, MINSTREL_FRAC(mi->ampdu_len, mi->ampdu_packets), EWMA_LEVEL); mi->ampdu_len = 0; mi->ampdu_packets = 0; } mi->sample_slow = 0; mi->sample_count = 0; /* Initialize global rate indexes */ for(j = 0; j < MAX_THR_RATES; j++){ tmp_mcs_tp_rate[j] = 0; tmp_cck_tp_rate[j] = 0; } /* Find best rate sets within all MCS groups*/ for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { mg = &mi->groups[group]; if (!mg->supported) continue; mi->sample_count++; /* (re)Initialize group rate indexes */ for(j = 0; j < MAX_THR_RATES; j++) tmp_group_tp_rate[j] = group; for (i = 0; i < MCS_GROUP_RATES; i++) { if (!(mg->supported & BIT(i))) continue; index = MCS_GROUP_RATES * group + i; mrs = &mg->rates[i]; mrs->retry_updated = false; minstrel_calc_rate_stats(mrs); cur_prob = mrs->prob_ewma; if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0) continue; /* Find max throughput rate set */ if (group != MINSTREL_CCK_GROUP) { minstrel_ht_sort_best_tp_rates(mi, index, tmp_mcs_tp_rate); } else if (group == MINSTREL_CCK_GROUP) { minstrel_ht_sort_best_tp_rates(mi, index, tmp_cck_tp_rate); } /* Find max throughput rate set within a group */ minstrel_ht_sort_best_tp_rates(mi, index, tmp_group_tp_rate); /* Find max probability rate per group and global */ minstrel_ht_set_best_prob_rate(mi, index); } memcpy(mg->max_group_tp_rate, tmp_group_tp_rate, sizeof(mg->max_group_tp_rate)); } /* Assign new rate set per sta */ minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate, tmp_cck_tp_rate); memcpy(mi->max_tp_rate, tmp_mcs_tp_rate, sizeof(mi->max_tp_rate)); /* Try to increase robustness of max_prob_rate*/ minstrel_ht_prob_rate_reduce_streams(mi); /* try to sample all available rates during each interval */ mi->sample_count *= 8; #ifdef CONFIG_MAC80211_DEBUGFS /* use fixed index if set */ if (mp->fixed_rate_idx != -1) { for (i = 0; i < 4; i++) mi->max_tp_rate[i] = mp->fixed_rate_idx; mi->max_prob_rate = mp->fixed_rate_idx; } #endif /* Reset update timer */ mi->last_stats_update = jiffies; }

Contributors

PersonTokensPropCommitsCommitProp
thomas huehnthomas huehn34376.05%541.67%
felix fietkaufelix fietkau6714.86%325.00%
lorenzo bianconilorenzo bianconi378.20%216.67%
karl beldankarl beldan20.44%18.33%
lei minglei ming20.44%18.33%
Total451100.00%12100.00%


static bool minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct ieee80211_tx_rate *rate) { if (rate->idx < 0) return false; if (!rate->count) return false; if (rate->flags & IEEE80211_TX_RC_MCS || rate->flags & IEEE80211_TX_RC_VHT_MCS) return true; return rate->idx == mp->cck_rates[0] || rate->idx == mp->cck_rates[1] || rate->idx == mp->cck_rates[2] || rate->idx == mp->cck_rates[3]; }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau8888.89%250.00%
karl beldankarl beldan66.06%125.00%
helmut schaahelmut schaa55.05%125.00%
Total99100.00%4100.00%


static void minstrel_set_next_sample_idx(struct minstrel_ht_sta *mi) { struct minstrel_mcs_group_data *mg; for (;;) { mi->sample_group++; mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups); mg = &mi->groups[mi->sample_group]; if (!mg->supported) continue; if (++mg->index >= MCS_GROUP_RATES) { mg->index = 0; if (++mg->column >= ARRAY_SIZE(sample_table)) mg->column = 0; } break; } }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau9298.92%150.00%
thomas huehnthomas huehn11.08%150.00%
Total93100.00%2100.00%


static void minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary) { int group, orig_group; orig_group = group = *idx / MCS_GROUP_RATES; while (group > 0) { group--; if (!mi->groups[group].supported) continue; if (minstrel_mcs_groups[group].streams > minstrel_mcs_groups[orig_group].streams) continue; if (primary) *idx = mi->groups[group].max_group_tp_rate[0]; else *idx = mi->groups[group].max_group_tp_rate[1]; break; } }

Contributors

PersonTokensPropCommitsCommitProp
felix fietkaufelix fietkau10091.74%133.33%
thomas huehnthomas huehn87.34%133.33%
karl beldankarl beldan10.92%133.33%
Total109100.00%3100.00%


static void minstrel_aggr_check(struct ieee80211_sta *pubsta, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct sta_info *sta = container_of(pubsta