Lines Matching refs:mi
241 minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
303 minstrel_ht_get_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
322 if ((mi->supported[group] & BIT(idx + 4)) &&
326 return &mi->groups[group].rates[idx];
330 minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
332 return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
336 minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi)
338 if (!mi->avg_ampdu_len)
341 return MINSTREL_TRUNC(mi->avg_ampdu_len);
349 minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
359 nsecs = 1000 * mi->overhead / minstrel_ht_avg_ampdu_len(mi);
384 minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
393 cur_prob = mi->groups[cur_group].rates[cur_idx].prob_avg;
394 cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx, cur_prob);
399 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
400 tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx,
420 minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
431 mg = &mi->groups[index / MCS_GROUP_RATES];
434 tmp_group = mi->max_prob_rate / MCS_GROUP_RATES;
435 tmp_idx = mi->max_prob_rate % MCS_GROUP_RATES;
436 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
437 tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
441 max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES;
448 max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_avg;
451 cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx,
454 mi->max_prob_rate = index;
456 max_gpr_tp_avg = minstrel_ht_get_tp_avg(mi, max_gpr_group,
463 mi->max_prob_rate = index;
477 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
486 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
487 tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
491 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
492 tmp_mcs_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
496 minstrel_ht_sort_best_tp_rates(mi, tmp_cck_tp_rate[i],
508 minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi)
514 tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] /
517 mg = &mi->groups[group];
518 if (!mi->supported[group] || group == MINSTREL_CCK_GROUP)
522 tmp_prob = mi->groups[group].rates[tmp_idx].prob_avg;
524 if (tmp_tp < minstrel_ht_get_tp_avg(mi, group, tmp_idx, tmp_prob) &&
526 mi->max_prob_rate = mg->max_group_prob_rate;
527 tmp_tp = minstrel_ht_get_tp_avg(mi, group,
543 minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group,
559 minstrel_ht_find_probe_rates(struct minstrel_ht_sta *mi, u16 *rates, int *n_rates,
566 tp_group = &minstrel_mcs_groups[mi->max_tp_rate[0] / MCS_GROUP_RATES];
567 tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES;
569 max_dur = minstrel_get_duration(mi->max_tp_rate[0]);
574 u16 supported = mi->supported[g];
580 if (!minstrel_ht_probe_group(mi, tp_group, tp_idx, group))
593 if (idx == mi->max_tp_rate[0])
604 struct minstrel_ht_sta *mi)
626 mrs = minstrel_get_ratestats(mi, mi->max_tp_rate[0]);
628 minstrel_ht_find_probe_rates(mi, rates, &n_rates, faster_rate);
630 minstrel_ht_find_probe_rates(mi, rates, &n_rates, false);
634 int g_idx = mi->max_tp_rate[0] / MCS_GROUP_RATES;
635 u16 supported = mi->supported[g_idx];
637 supported >>= mi->max_tp_rate[0] % MCS_GROUP_RATES;
642 probe_rate = mi->max_tp_rate[0] + i;
657 mi->sample_rate = probe_rate;
658 mi->sample_mode = MINSTREL_SAMPLE_ACTIVE;
671 minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
680 mi->sample_mode = MINSTREL_SAMPLE_IDLE;
683 mi->total_packets_cur = mi->total_packets -
684 mi->total_packets_last;
685 mi->total_packets_last = mi->total_packets;
689 if (mi->total_packets_cur < SAMPLE_SWITCH_THR && mp->sample_switch != 1)
692 if (mi->ampdu_packets > 0) {
694 mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
695 MINSTREL_FRAC(mi->ampdu_len, mi->ampdu_packets),
698 mi->avg_ampdu_len = 0;
699 mi->ampdu_len = 0;
700 mi->ampdu_packets = 0;
703 mi->sample_slow = 0;
704 mi->sample_count = 0;
708 if (mi->supported[MINSTREL_CCK_GROUP])
712 if (mi->supported[MINSTREL_VHT_GROUP_0])
723 mg = &mi->groups[group];
724 if (!mi->supported[group])
727 mi->sample_count++;
734 if (!(mi->supported[group] & BIT(i)))
744 if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0)
749 minstrel_ht_sort_best_tp_rates(mi, index,
752 minstrel_ht_sort_best_tp_rates(mi, index,
757 minstrel_ht_sort_best_tp_rates(mi, index,
761 minstrel_ht_set_best_prob_rate(mi, index);
769 minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate, tmp_cck_tp_rate);
770 memcpy(mi->max_tp_rate, tmp_mcs_tp_rate, sizeof(mi->max_tp_rate));
773 minstrel_ht_prob_rate_reduce_streams(mi);
776 mi->sample_count *= 8;
778 mi->sample_count /= 2;
781 minstrel_ht_rate_sample_switch(mp, mi);
787 mi->max_tp_rate[i] = mp->fixed_rate_idx;
788 mi->max_prob_rate = mp->fixed_rate_idx;
789 mi->sample_mode = MINSTREL_SAMPLE_IDLE;
794 mi->last_stats_update = jiffies;
817 minstrel_set_next_sample_idx(struct minstrel_ht_sta *mi)
822 mi->sample_group++;
823 mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups);
824 mg = &mi->groups[mi->sample_group];
826 if (!mi->supported[mi->sample_group])
839 minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary)
847 if (!mi->supported[group])
855 *idx = mi->groups[group].max_group_tp_rate[0];
857 *idx = mi->groups[group].max_group_tp_rate[1];
891 struct minstrel_ht_sta *mi = &msp->ht;
916 mi->ampdu_packets++;
917 mi->ampdu_len += info->status.ampdu_len;
919 if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
920 int avg_ampdu_len = minstrel_ht_avg_ampdu_len(mi);
922 mi->sample_wait = 16 + 2 * avg_ampdu_len;
923 mi->sample_tries = 1;
924 mi->sample_count--;
928 mi->sample_packets += info->status.ampdu_len;
930 if (mi->sample_mode != MINSTREL_SAMPLE_IDLE)
931 rate_sample = minstrel_get_ratestats(mi, mi->sample_rate);
938 rate = minstrel_ht_get_stats(mp, mi, &ar[i]);
948 switch (mi->sample_mode) {
952 mi->total_packets_cur < SAMPLE_SWITCH_THR))
960 mi->sample_mode = MINSTREL_SAMPLE_PENDING;
969 minstrel_ht_update_stats(mp, mi, false);
979 rate = minstrel_get_ratestats(mi, mi->max_tp_rate[0]);
982 minstrel_downgrade_rate(mi, &mi->max_tp_rate[0], true);
986 rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate[1]);
989 minstrel_downgrade_rate(mi, &mi->max_tp_rate[1], false);
994 if (time_after(jiffies, mi->last_stats_update + update_interval)) {
996 minstrel_ht_update_stats(mp, mi, true);
1000 minstrel_ht_update_rates(mp, mi);
1004 minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
1012 unsigned int ampdu_len = minstrel_ht_avg_ampdu_len(mi);
1015 mrs = minstrel_get_ratestats(mi, index);
1035 overhead = mi->overhead;
1036 overhead_rtscts = mi->overhead_rtscts;
1061 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
1069 mrs = minstrel_get_ratestats(mi, index);
1071 minstrel_calc_retransmit(mp, mi, index);
1096 (mi->sta->smps_mode == IEEE80211_SMPS_DYNAMIC &&
1107 minstrel_ht_get_prob_avg(struct minstrel_ht_sta *mi, int rate)
1111 return mi->groups[group].rates[rate].prob_avg;
1115 minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi)
1117 int group = mi->max_prob_rate / MCS_GROUP_RATES;
1119 int rate = mi->max_prob_rate % MCS_GROUP_RATES;
1123 if (mi->groups[group].rates[rate].prob_avg < MINSTREL_FRAC(50, 100))
1146 (minstrel_ht_get_prob_avg(mi, mi->max_tp_rate[0]) <
1156 if (!mi->sta->vht_cap.vht_supported)
1164 minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
1167 u16 first_rate = mi->max_tp_rate[0];
1170 if (mi->sample_mode == MINSTREL_SAMPLE_ACTIVE)
1171 first_rate = mi->sample_rate;
1178 minstrel_ht_set_rate(mp, mi, rates, i++, first_rate);
1182 minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[1]);
1186 minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate);
1189 mi->sta->max_rc_amsdu_len = minstrel_ht_get_max_amsdu_len(mi);
1191 rate_control_set_rates(mp->hw, mi->sta, rates);
1195 minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
1204 (mi->total_packets_cur >= SAMPLE_SWITCH_THR ||
1208 if (mi->sample_wait > 0) {
1209 mi->sample_wait--;
1213 if (!mi->sample_tries)
1216 sample_group = mi->sample_group;
1217 mg = &mi->groups[sample_group];
1219 minstrel_set_next_sample_idx(mi);
1221 if (!(mi->supported[sample_group] & BIT(sample_idx)))
1228 if (minstrel_get_duration(mi->max_tp_rate[0]) >
1229 minstrel_get_duration(mi->max_tp_rate[1])) {
1230 tp_rate1 = mi->max_tp_rate[1];
1231 tp_rate2 = mi->max_tp_rate[0];
1233 tp_rate1 = mi->max_tp_rate[0];
1234 tp_rate2 = mi->max_tp_rate[1];
1242 if (sample_idx == mi->max_tp_rate[0] || sample_idx == mi->max_prob_rate)
1252 minstrel_get_duration(mi->max_prob_rate) * 3 < sample_dur)
1280 sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
1284 if (mi->sample_slow++ > 2)
1287 mi->sample_tries--;
1300 struct minstrel_ht_sta *mi = &msp->ht;
1308 mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP)
1311 info->flags |= mi->tx_flags;
1323 sample_idx = minstrel_get_sample_rate(mp, mi);
1325 mi->total_packets++;
1328 if (mi->total_packets == ~0) {
1329 mi->total_packets = 0;
1330 mi->sample_packets = 0;
1360 minstrel_ht_update_cck(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
1372 mi->cck_supported = 0;
1373 mi->cck_supported_short = 0;
1378 mi->cck_supported |= BIT(i);
1380 mi->cck_supported_short |= BIT(i);
1383 mi->supported[MINSTREL_CCK_GROUP] = mi->cck_supported;
1393 struct minstrel_ht_sta *mi = &msp->ht;
1416 memset(mi, 0, sizeof(*mi));
1418 mi->sta = sta;
1419 mi->last_stats_update = jiffies;
1422 mi->overhead = ieee80211_frame_duration(sband->band, 0, 60, 1, 1, 0);
1423 mi->overhead += ack_dur;
1424 mi->overhead_rtscts = mi->overhead + 2 * ack_dur;
1426 mi->avg_ampdu_len = MINSTREL_FRAC(1, 1);
1430 mi->sample_count = 16;
1431 mi->sample_wait = 0;
1433 mi->sample_count = 8;
1434 mi->sample_wait = 8;
1436 mi->sample_tries = 4;
1450 mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
1452 mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
1454 for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
1458 mi->supported[i] = 0;
1460 minstrel_ht_update_cck(mp, mi, sband, sta);
1489 mi->supported[i] = mcs->rx_mask[nss - 1];
1490 if (mi->supported[i])
1516 mi->supported[i] = minstrel_get_valid_vht_rates(bw, nss,
1519 if (mi->supported[i])
1526 mi->supported[MINSTREL_CCK_GROUP] |= mi->cck_supported_short << 4;
1529 minstrel_ht_update_stats(mp, mi, true);
1530 minstrel_ht_update_rates(mp, mi);
1707 struct minstrel_ht_sta *mi = &msp->ht;
1713 i = mi->max_tp_rate[0] / MCS_GROUP_RATES;
1714 j = mi->max_tp_rate[0] % MCS_GROUP_RATES;
1715 prob = mi->groups[i].rates[j].prob_avg;
1718 tp_avg = minstrel_ht_get_tp_avg(mi, i, j, prob) * 10;