47 #include <linux/netdevice.h>
48 #include <linux/types.h>
51 #include <linux/random.h>
53 #include <linux/slab.h>
58 #define SAMPLE_COLUMNS 10
59 #define SAMPLE_TBL(_mi, _idx, _col) \
60 _mi->sample_table[(_idx * SAMPLE_COLUMNS) + _col]
67 for (i = rix; i >= 0; i--)
68 if (mi->
r[i].rix == rix)
76 u32 max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
77 u32 max_prob = 0, index_max_prob = 0;
83 for (i = 0; i < mi->
n_rates; i++) {
123 for (i = 0; i < mi->
n_rates; i++) {
125 if (max_tp < mr->
cur_tp) {
136 for (i = 0; i < mi->
n_rates; i++) {
139 if (i == index_max_tp)
142 if (max_tp < mr->cur_tp) {
169 ndx = rix_to_ndx(mi, ar[i].
idx);
173 mi->
r[ndx].attempts += ar[
i].
count;
175 if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].
idx < 0))
176 mi->
r[ndx].success += success;
187 static inline unsigned int
204 unsigned int sample_ndx;
225 unsigned int ndx, sample_ndx = 0;
227 bool sample_slower =
false;
240 minstrel_update_stats(mp, mi);
260 }
else if (delta > mi->
n_rates * 2) {
273 sample_ndx = minstrel_get_next_sample(mi);
274 msr = &mi->
r[sample_ndx];
277 mi->
r[ndx].perfect_tx_time);
279 if (!sample_slower) {
304 if (!mrr && sample && (mi->
r[ndx].probability > 17100))
307 ar[0].
idx = mi->
r[ndx].rix;
308 ar[0].
count = minstrel_get_retry_count(&mi->
r[ndx], info);
321 mrr_ndx[0] = sample_ndx;
329 for (i = 1; i < 4; i++) {
330 ar[
i].
idx = mi->
r[mrr_ndx[i - 1]].rix;
331 ar[
i].
count = mi->
r[mrr_ndx[i - 1]].adjusted_retry_count;
352 unsigned int i, col, new_idx;
353 unsigned int n_srates = mi->
n_rates - 1;
361 for (i = 0; i < n_srates; i++) {
363 new_idx = (i + rnd[i & 7]) % n_srates;
366 new_idx = (new_idx + 1) % n_srates;
384 unsigned int i,
n = 0;
385 unsigned int t_slot = 9;
387 mi->
lowest_rix = rate_lowest_index(sband, sta);
395 unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0;
396 unsigned int tx_time_single;
397 unsigned int cw = mp->
cw_min;
399 if (!rate_supported(sta, sband->
band, i))
402 memset(mr, 0,
sizeof(*mr));
406 calc_rate_durations(sband->
band, mr, &sband->
bitrates[i]);
420 tx_time_single += (t_slot * cw) >> 1;
423 tx_time += tx_time_single;
424 tx_time_cts += tx_time_single + mi->
sp_ack_dur;
425 tx_time_rtscts += tx_time_single + 2 * mi->
sp_ack_dur;
426 if ((tx_time_cts < mp->segment_size) &&
429 if ((tx_time_rtscts < mp->segment_size) &&
432 }
while ((tx_time < mp->segment_size) &&
445 init_sample_table(mi);
463 sband = hw->
wiphy->bands[
i];
487 minstrel_free_sta(
void *priv,
struct ieee80211_sta *sta,
void *priv_sta)
535 #ifdef CONFIG_MAC80211_DEBUGFS
536 mp->fixed_rate_idx = (
u32) -1;
545 minstrel_free(
void *priv)
547 #ifdef CONFIG_MAC80211_DEBUGFS
555 .tx_status = minstrel_tx_status,
556 .get_rate = minstrel_get_rate,
557 .rate_init = minstrel_rate_init,
558 .alloc = minstrel_alloc,
559 .free = minstrel_free,
560 .alloc_sta = minstrel_alloc_sta,
561 .free_sta = minstrel_free_sta,
562 #ifdef CONFIG_MAC80211_DEBUGFS