Lines Matching +full:assoc +full:- +full:select

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
5 * Copyright (C) 2019 - 2020, 2022 - 2023 Intel Corporation
21 #define RS_NAME "iwl-agn-rs"
47 /*ANT_NONE -> */ ANT_NONE,
48 /*ANT_A -> */ ANT_B,
49 /*ANT_B -> */ ANT_C,
50 /*ANT_AB -> */ ANT_BC,
51 /*ANT_C -> */ ANT_A,
52 /*ANT_AC -> */ ANT_AB,
53 /*ANT_BC -> */ ANT_AC,
54 /*ANT_ABC -> */ ANT_ABC,
109 idx = idx - IWL_RATE_MIMO3_6M_PLCP; in iwl_hwrate_to_plcp_idx()
111 idx = idx - IWL_RATE_MIMO2_6M_PLCP; in iwl_hwrate_to_plcp_idx()
210 window->data = 0; in rs_rate_scale_clear_window()
211 window->success_counter = 0; in rs_rate_scale_clear_window()
212 window->success_ratio = IWL_INVALID_VALUE; in rs_rate_scale_clear_window()
213 window->counter = 0; in rs_rate_scale_clear_window()
214 window->average_tpt = IWL_INVALID_VALUE; in rs_rate_scale_clear_window()
215 window->stamp = 0; in rs_rate_scale_clear_window()
230 u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; in rs_tl_rm_old_stats()
232 while (tl->queue_count && in rs_tl_rm_old_stats()
233 (tl->time_stamp < oldest_time)) { in rs_tl_rm_old_stats()
234 tl->total -= tl->packet_count[tl->head]; in rs_tl_rm_old_stats()
235 tl->packet_count[tl->head] = 0; in rs_tl_rm_old_stats()
236 tl->time_stamp += TID_QUEUE_CELL_SPACING; in rs_tl_rm_old_stats()
237 tl->queue_count--; in rs_tl_rm_old_stats()
238 tl->head++; in rs_tl_rm_old_stats()
239 if (tl->head >= TID_QUEUE_MAX_SIZE) in rs_tl_rm_old_stats()
240 tl->head = 0; in rs_tl_rm_old_stats()
257 if (ieee80211_is_data_qos(hdr->frame_control)) { in rs_tl_add_packet()
266 tl = &lq_data->load[tid]; in rs_tl_add_packet()
268 curr_time -= curr_time % TID_ROUND_VALUE; in rs_tl_add_packet()
271 if (!(tl->queue_count)) { in rs_tl_add_packet()
272 tl->total = 1; in rs_tl_add_packet()
273 tl->time_stamp = curr_time; in rs_tl_add_packet()
274 tl->queue_count = 1; in rs_tl_add_packet()
275 tl->head = 0; in rs_tl_add_packet()
276 tl->packet_count[0] = 1; in rs_tl_add_packet()
280 time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); in rs_tl_add_packet()
288 index = (tl->head + index) % TID_QUEUE_MAX_SIZE; in rs_tl_add_packet()
289 tl->packet_count[index] = tl->packet_count[index] + 1; in rs_tl_add_packet()
290 tl->total = tl->total + 1; in rs_tl_add_packet()
292 if ((index + 1) > tl->queue_count) in rs_tl_add_packet()
293 tl->queue_count = index + 1; in rs_tl_add_packet()
310 struct iwl_rxon_context *ctx = sta_priv->ctx; in rs_program_fix_rate()
312 lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ in rs_program_fix_rate()
313 lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ in rs_program_fix_rate()
314 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ in rs_program_fix_rate()
315 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ in rs_program_fix_rate()
318 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); in rs_program_fix_rate()
320 if (lq_sta->dbg_fixed_rate) { in rs_program_fix_rate()
321 rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); in rs_program_fix_rate()
322 iwl_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, in rs_program_fix_rate()
341 tl = &(lq_data->load[tid]); in rs_tl_get_load()
343 curr_time -= curr_time % TID_ROUND_VALUE; in rs_tl_get_load()
345 if (!(tl->queue_count)) in rs_tl_get_load()
348 time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); in rs_tl_get_load()
361 int ret = -EAGAIN; in rs_tl_turn_on_agg_for_tid()
367 if (priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) { in rs_tl_turn_on_agg_for_tid()
370 priv->bt_traffic_load); in rs_tl_turn_on_agg_for_tid()
377 sta->addr, tid); in rs_tl_turn_on_agg_for_tid()
379 if (ret == -EAGAIN) { in rs_tl_turn_on_agg_for_tid()
416 if (tbl->expected_tpt) in get_expected_tpt()
417 return tbl->expected_tpt[rs_index]; in get_expected_tpt()
422 * rs_collect_tx_data - Update the success/failure sliding window
425 * at this rate. window->data contains the bitmask of successful
432 static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1)); in rs_collect_tx_data()
436 return -EINVAL; in rs_collect_tx_data()
438 /* Select window for current tx bit rate */ in rs_collect_tx_data()
439 window = &(tbl->win[scale_index]); in rs_collect_tx_data()
453 if (window->counter >= IWL_RATE_MAX_WINDOW) { in rs_collect_tx_data()
456 window->counter = IWL_RATE_MAX_WINDOW - 1; in rs_collect_tx_data()
458 if (window->data & mask) { in rs_collect_tx_data()
459 window->data &= ~mask; in rs_collect_tx_data()
460 window->success_counter--; in rs_collect_tx_data()
464 /* Increment frames-attempted counter */ in rs_collect_tx_data()
465 window->counter++; in rs_collect_tx_data()
468 window->data <<= 1; in rs_collect_tx_data()
472 window->success_counter++; in rs_collect_tx_data()
473 window->data |= 0x1; in rs_collect_tx_data()
474 successes--; in rs_collect_tx_data()
477 attempts--; in rs_collect_tx_data()
480 /* Calculate current success ratio, avoid divide-by-0! */ in rs_collect_tx_data()
481 if (window->counter > 0) in rs_collect_tx_data()
482 window->success_ratio = 128 * (100 * window->success_counter) in rs_collect_tx_data()
483 / window->counter; in rs_collect_tx_data()
485 window->success_ratio = IWL_INVALID_VALUE; in rs_collect_tx_data()
487 fail_count = window->counter - window->success_counter; in rs_collect_tx_data()
491 (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) in rs_collect_tx_data()
492 window->average_tpt = (window->success_ratio * tpt + 64) / 128; in rs_collect_tx_data()
494 window->average_tpt = IWL_INVALID_VALUE; in rs_collect_tx_data()
497 window->stamp = jiffies; in rs_collect_tx_data()
512 if (is_legacy(tbl->lq_type)) { in rate_n_flags_from_tbl()
517 } else if (is_Ht(tbl->lq_type)) { in rate_n_flags_from_tbl()
524 if (is_siso(tbl->lq_type)) in rate_n_flags_from_tbl()
526 else if (is_mimo2(tbl->lq_type)) in rate_n_flags_from_tbl()
531 IWL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); in rate_n_flags_from_tbl()
534 rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & in rate_n_flags_from_tbl()
537 if (is_Ht(tbl->lq_type)) { in rate_n_flags_from_tbl()
538 if (tbl->is_ht40) { in rate_n_flags_from_tbl()
539 if (tbl->is_dup) in rate_n_flags_from_tbl()
544 if (tbl->is_SGI) in rate_n_flags_from_tbl()
549 if (is_siso(tbl->lq_type) && tbl->is_SGI) { in rate_n_flags_from_tbl()
575 *rate_idx = -1; in rs_get_tbl_info_from_mcs()
576 return -EINVAL; in rs_get_tbl_info_from_mcs()
578 tbl->is_SGI = 0; /* default legacy setup */ in rs_get_tbl_info_from_mcs()
579 tbl->is_ht40 = 0; in rs_get_tbl_info_from_mcs()
580 tbl->is_dup = 0; in rs_get_tbl_info_from_mcs()
581 tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); in rs_get_tbl_info_from_mcs()
582 tbl->lq_type = LQ_NONE; in rs_get_tbl_info_from_mcs()
583 tbl->max_search = IWL_MAX_SEARCH; in rs_get_tbl_info_from_mcs()
589 tbl->lq_type = LQ_A; in rs_get_tbl_info_from_mcs()
591 tbl->lq_type = LQ_G; in rs_get_tbl_info_from_mcs()
596 tbl->is_SGI = 1; in rs_get_tbl_info_from_mcs()
600 tbl->is_ht40 = 1; in rs_get_tbl_info_from_mcs()
603 tbl->is_dup = 1; in rs_get_tbl_info_from_mcs()
610 tbl->lq_type = LQ_SISO; /*else NONE*/ in rs_get_tbl_info_from_mcs()
614 tbl->lq_type = LQ_MIMO2; in rs_get_tbl_info_from_mcs()
618 tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH; in rs_get_tbl_info_from_mcs()
619 tbl->lq_type = LQ_MIMO3; in rs_get_tbl_info_from_mcs()
633 if (!tbl->ant_type || tbl->ant_type > ANT_ABC) in rs_toggle_antenna()
636 if (!rs_is_valid_ant(valid_ant, tbl->ant_type)) in rs_toggle_antenna()
639 new_ant_type = ant_toggle_lookup[tbl->ant_type]; in rs_toggle_antenna()
641 while ((new_ant_type != tbl->ant_type) && in rs_toggle_antenna()
645 if (new_ant_type == tbl->ant_type) in rs_toggle_antenna()
648 tbl->ant_type = new_ant_type; in rs_toggle_antenna()
655 * Green-field mode is valid if the station supports it and
656 * there are no non-GF stations present in the BSS.
671 * rs_get_supported_rates - get the available rates
682 return lq_sta->active_legacy_rate; in rs_get_supported_rates()
685 return lq_sta->active_siso_rate; in rs_get_supported_rates()
687 return lq_sta->active_mimo2_rate; in rs_get_supported_rates()
689 return lq_sta->active_mimo3_rate; in rs_get_supported_rates()
706 i = index - 1; in rs_get_adjacent_rate()
710 for (; i >= 0; i--, mask >>= 1) { in rs_get_adjacent_rate()
760 u8 is_green = lq_sta->is_green; in rs_get_lower_rate()
761 struct iwl_priv *priv = lq_sta->drv; in rs_get_lower_rate()
766 if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { in rs_get_lower_rate()
769 if (lq_sta->band == NL80211_BAND_5GHZ) in rs_get_lower_rate()
770 tbl->lq_type = LQ_A; in rs_get_lower_rate()
772 tbl->lq_type = LQ_G; in rs_get_lower_rate()
774 if (num_of_ant(tbl->ant_type) > 1) in rs_get_lower_rate()
775 tbl->ant_type = in rs_get_lower_rate()
776 first_antenna(priv->nvm_data->valid_tx_ant); in rs_get_lower_rate()
778 tbl->is_ht40 = 0; in rs_get_lower_rate()
779 tbl->is_SGI = 0; in rs_get_lower_rate()
780 tbl->max_search = IWL_MAX_SEARCH; in rs_get_lower_rate()
783 rate_mask = rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); in rs_get_lower_rate()
786 if (is_legacy(tbl->lq_type)) { in rs_get_lower_rate()
788 if (lq_sta->band == NL80211_BAND_5GHZ) in rs_get_lower_rate()
790 (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); in rs_get_lower_rate()
792 rate_mask = (u16)(rate_mask & lq_sta->supp_rates); in rs_get_lower_rate()
801 high_low = rs_get_adjacent_rate(lq_sta->drv, scale_index, rate_mask, in rs_get_lower_rate()
802 tbl->lq_type); in rs_get_lower_rate()
809 return rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); in rs_get_lower_rate()
818 return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && in table_type_matches()
819 (a->is_SGI == b->is_SGI); in table_type_matches()
826 bool full_concurrent = priv->bt_full_concurrent; in rs_bt_update_lq()
828 if ((priv->bt_traffic_load != priv->last_bt_traffic_load) || in rs_bt_update_lq()
829 (priv->bt_full_concurrent != full_concurrent)) { in rs_bt_update_lq()
830 priv->bt_full_concurrent = full_concurrent; in rs_bt_update_lq()
831 priv->last_bt_traffic_load = priv->bt_traffic_load; in rs_bt_update_lq()
834 tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_bt_update_lq()
835 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); in rs_bt_update_lq()
836 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); in rs_bt_update_lq()
838 queue_work(priv->workqueue, &priv->bt_full_concurrency); in rs_bt_update_lq()
854 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in rs_tx_status()
862 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; in rs_tx_status()
863 struct iwl_rxon_context *ctx = sta_priv->ctx; in rs_tx_status()
867 /* Treat uninitialized rate scaling data same as non-existing. */ in rs_tx_status()
871 } else if (!lq_sta->drv) { in rs_tx_status()
876 if (!ieee80211_is_data(hdr->frame_control) || in rs_tx_status()
877 info->flags & IEEE80211_TX_CTL_NO_ACK) in rs_tx_status()
881 if ((info->flags & IEEE80211_TX_CTL_AMPDU) && in rs_tx_status()
882 !(info->flags & IEEE80211_TX_STAT_AMPDU)) in rs_tx_status()
893 table = &lq_sta->lq; in rs_tx_status()
894 tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); in rs_tx_status()
895 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); in rs_tx_status()
896 if (priv->band == NL80211_BAND_5GHZ) in rs_tx_status()
897 rs_index -= IWL_FIRST_OFDM_RATE; in rs_tx_status()
898 mac_flags = info->status.rates[0].flags; in rs_tx_status()
899 mac_index = info->status.rates[0].idx; in rs_tx_status()
903 if (mac_index >= (IWL_RATE_9M_INDEX - IWL_FIRST_OFDM_RATE)) in rs_tx_status()
906 * mac80211 HT index is always zero-indexed; we need to move in rs_tx_status()
909 if (priv->band == NL80211_BAND_2GHZ) in rs_tx_status()
917 (tbl_type.ant_type != info->status.antenna) || in rs_tx_status()
923 * Since rates mis-match, the last LQ command may have failed. in rs_tx_status()
924 * After IWL_MISSED_RATE_MAX mis-matches, resync the uCode with in rs_tx_status()
927 lq_sta->missed_rate_counter++; in rs_tx_status()
928 if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { in rs_tx_status()
929 lq_sta->missed_rate_counter = 0; in rs_tx_status()
930 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); in rs_tx_status()
936 lq_sta->missed_rate_counter = 0; in rs_tx_status()
940 &(lq_sta->lq_info[lq_sta->active_tbl]))) { in rs_tx_status()
941 curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_tx_status()
942 other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); in rs_tx_status()
944 &lq_sta->lq_info[1 - lq_sta->active_tbl])) { in rs_tx_status()
945 curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); in rs_tx_status()
946 other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_tx_status()
949 tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_tx_status()
950 IWL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", in rs_tx_status()
951 tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); in rs_tx_status()
952 tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); in rs_tx_status()
953 IWL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", in rs_tx_status()
954 tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); in rs_tx_status()
955 IWL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", in rs_tx_status()
958 * no matching table found, let's by-pass the data collection in rs_tx_status()
972 if (info->flags & IEEE80211_TX_STAT_AMPDU) { in rs_tx_status()
973 tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); in rs_tx_status()
974 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, in rs_tx_status()
977 info->status.ampdu_len, in rs_tx_status()
978 info->status.ampdu_ack_len); in rs_tx_status()
981 if (lq_sta->stay_in_tbl) { in rs_tx_status()
982 lq_sta->total_success += info->status.ampdu_ack_len; in rs_tx_status()
983 lq_sta->total_failed += (info->status.ampdu_len - in rs_tx_status()
984 info->status.ampdu_ack_len); in rs_tx_status()
990 retries = info->status.rates[0].count - 1; in rs_tx_status()
995 legacy_success = !!(info->flags & IEEE80211_TX_STAT_ACK); in rs_tx_status()
998 tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); in rs_tx_status()
999 rs_get_tbl_info_from_mcs(tx_rate, priv->band, in rs_tx_status()
1016 if (lq_sta->stay_in_tbl) { in rs_tx_status()
1017 lq_sta->total_success += legacy_success; in rs_tx_status()
1018 lq_sta->total_failed += retries + (1 - legacy_success); in rs_tx_status()
1022 lq_sta->last_rate_n_flags = tx_rate; in rs_tx_status()
1025 if (sta && sta->deflink.supp_rates[sband->band]) in rs_tx_status()
1028 if (priv->lib->bt_params && priv->lib->bt_params->advanced_bt_coexist) in rs_tx_status()
1035 * Set frame tx success limits according to legacy vs. high-throughput,
1044 lq_sta->stay_in_tbl = 1; /* only place this gets set */ in rs_set_stay_in_table()
1046 lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; in rs_set_stay_in_table()
1047 lq_sta->max_failure_limit = IWL_LEGACY_FAILURE_LIMIT; in rs_set_stay_in_table()
1048 lq_sta->max_success_limit = IWL_LEGACY_SUCCESS_LIMIT; in rs_set_stay_in_table()
1050 lq_sta->table_count_limit = IWL_NONE_LEGACY_TABLE_COUNT; in rs_set_stay_in_table()
1051 lq_sta->max_failure_limit = IWL_NONE_LEGACY_FAILURE_LIMIT; in rs_set_stay_in_table()
1052 lq_sta->max_success_limit = IWL_NONE_LEGACY_SUCCESS_LIMIT; in rs_set_stay_in_table()
1054 lq_sta->table_count = 0; in rs_set_stay_in_table()
1055 lq_sta->total_failed = 0; in rs_set_stay_in_table()
1056 lq_sta->total_success = 0; in rs_set_stay_in_table()
1057 lq_sta->flush_timer = jiffies; in rs_set_stay_in_table()
1058 lq_sta->action_counter = 0; in rs_set_stay_in_table()
1071 if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { in rs_set_expected_tpt_table()
1072 tbl->expected_tpt = expected_tpt_legacy; in rs_set_expected_tpt_table()
1077 if (is_legacy(tbl->lq_type)) { in rs_set_expected_tpt_table()
1078 tbl->expected_tpt = expected_tpt_legacy; in rs_set_expected_tpt_table()
1085 if (is_siso(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) in rs_set_expected_tpt_table()
1087 else if (is_siso(tbl->lq_type)) in rs_set_expected_tpt_table()
1089 else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) in rs_set_expected_tpt_table()
1091 else if (is_mimo2(tbl->lq_type)) in rs_set_expected_tpt_table()
1093 else if (is_mimo3(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) in rs_set_expected_tpt_table()
1095 else /* if (is_mimo3(tbl->lq_type)) <-- must be true */ in rs_set_expected_tpt_table()
1098 if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ in rs_set_expected_tpt_table()
1099 tbl->expected_tpt = ht_tbl_pointer[0]; in rs_set_expected_tpt_table()
1100 else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ in rs_set_expected_tpt_table()
1101 tbl->expected_tpt = ht_tbl_pointer[1]; in rs_set_expected_tpt_table()
1102 else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ in rs_set_expected_tpt_table()
1103 tbl->expected_tpt = ht_tbl_pointer[2]; in rs_set_expected_tpt_table()
1105 tbl->expected_tpt = ht_tbl_pointer[3]; in rs_set_expected_tpt_table()
1109 * Find starting rate for new "search" high-throughput mode of modulation.
1127 &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_get_best_rate()
1128 s32 active_sr = active_tbl->win[index].success_ratio; in rs_get_best_rate()
1129 s32 active_tpt = active_tbl->expected_tpt[index]; in rs_get_best_rate()
1131 const u16 *tpt_tbl = tbl->expected_tpt; in rs_get_best_rate()
1141 tbl->lq_type); in rs_get_best_rate()
1161 if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && in rs_get_best_rate()
1221 s8 is_green = lq_sta->is_green; in rs_switch_to_mimo2()
1222 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; in rs_switch_to_mimo2()
1223 struct iwl_rxon_context *ctx = sta_priv->ctx; in rs_switch_to_mimo2()
1225 if (!conf_is_ht(conf) || !sta->deflink.ht_cap.ht_supported) in rs_switch_to_mimo2()
1226 return -1; in rs_switch_to_mimo2()
1228 if (sta->deflink.smps_mode == IEEE80211_SMPS_STATIC) in rs_switch_to_mimo2()
1229 return -1; in rs_switch_to_mimo2()
1232 if (priv->hw_params.tx_chains_num < 2) in rs_switch_to_mimo2()
1233 return -1; in rs_switch_to_mimo2()
1237 tbl->lq_type = LQ_MIMO2; in rs_switch_to_mimo2()
1238 tbl->is_dup = lq_sta->is_dup; in rs_switch_to_mimo2()
1239 tbl->action = 0; in rs_switch_to_mimo2()
1240 tbl->max_search = IWL_MAX_SEARCH; in rs_switch_to_mimo2()
1241 rate_mask = lq_sta->active_mimo2_rate; in rs_switch_to_mimo2()
1244 tbl->is_ht40 = 1; in rs_switch_to_mimo2()
1246 tbl->is_ht40 = 0; in rs_switch_to_mimo2()
1256 return -1; in rs_switch_to_mimo2()
1258 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); in rs_switch_to_mimo2()
1261 tbl->current_rate, is_green); in rs_switch_to_mimo2()
1276 s8 is_green = lq_sta->is_green; in rs_switch_to_mimo3()
1277 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; in rs_switch_to_mimo3()
1278 struct iwl_rxon_context *ctx = sta_priv->ctx; in rs_switch_to_mimo3()
1280 if (!conf_is_ht(conf) || !sta->deflink.ht_cap.ht_supported) in rs_switch_to_mimo3()
1281 return -1; in rs_switch_to_mimo3()
1283 if (sta->deflink.smps_mode == IEEE80211_SMPS_STATIC) in rs_switch_to_mimo3()
1284 return -1; in rs_switch_to_mimo3()
1287 if (priv->hw_params.tx_chains_num < 3) in rs_switch_to_mimo3()
1288 return -1; in rs_switch_to_mimo3()
1292 tbl->lq_type = LQ_MIMO3; in rs_switch_to_mimo3()
1293 tbl->is_dup = lq_sta->is_dup; in rs_switch_to_mimo3()
1294 tbl->action = 0; in rs_switch_to_mimo3()
1295 tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH; in rs_switch_to_mimo3()
1296 rate_mask = lq_sta->active_mimo3_rate; in rs_switch_to_mimo3()
1299 tbl->is_ht40 = 1; in rs_switch_to_mimo3()
1301 tbl->is_ht40 = 0; in rs_switch_to_mimo3()
1312 return -1; in rs_switch_to_mimo3()
1314 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); in rs_switch_to_mimo3()
1317 tbl->current_rate, is_green); in rs_switch_to_mimo3()
1331 u8 is_green = lq_sta->is_green; in rs_switch_to_siso()
1333 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; in rs_switch_to_siso()
1334 struct iwl_rxon_context *ctx = sta_priv->ctx; in rs_switch_to_siso()
1336 if (!conf_is_ht(conf) || !sta->deflink.ht_cap.ht_supported) in rs_switch_to_siso()
1337 return -1; in rs_switch_to_siso()
1341 tbl->is_dup = lq_sta->is_dup; in rs_switch_to_siso()
1342 tbl->lq_type = LQ_SISO; in rs_switch_to_siso()
1343 tbl->action = 0; in rs_switch_to_siso()
1344 tbl->max_search = IWL_MAX_SEARCH; in rs_switch_to_siso()
1345 rate_mask = lq_sta->active_siso_rate; in rs_switch_to_siso()
1348 tbl->is_ht40 = 1; in rs_switch_to_siso()
1350 tbl->is_ht40 = 0; in rs_switch_to_siso()
1353 tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ in rs_switch_to_siso()
1362 return -1; in rs_switch_to_siso()
1364 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); in rs_switch_to_siso()
1366 tbl->current_rate, is_green); in rs_switch_to_siso()
1379 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_move_legacy_other()
1381 &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); in rs_move_legacy_other()
1382 struct iwl_rate_scale_data *window = &(tbl->win[index]); in rs_move_legacy_other()
1383 u32 sz = (sizeof(struct iwl_scale_tbl_info) - in rs_move_legacy_other()
1386 u8 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_move_legacy_other()
1387 u8 tx_chains_num = priv->hw_params.tx_chains_num; in rs_move_legacy_other()
1391 switch (priv->bt_traffic_load) { in rs_move_legacy_other()
1397 if (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2) in rs_move_legacy_other()
1398 tbl->action = IWL_LEGACY_SWITCH_SISO; in rs_move_legacy_other()
1404 first_antenna(priv->nvm_data->valid_tx_ant); in rs_move_legacy_other()
1405 if (tbl->action >= IWL_LEGACY_SWITCH_ANTENNA2 && in rs_move_legacy_other()
1406 tbl->action != IWL_LEGACY_SWITCH_SISO) in rs_move_legacy_other()
1407 tbl->action = IWL_LEGACY_SWITCH_SISO; in rs_move_legacy_other()
1410 IWL_ERR(priv, "Invalid BT load %d\n", priv->bt_traffic_load); in rs_move_legacy_other()
1416 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; in rs_move_legacy_other()
1418 tbl->action > IWL_LEGACY_SWITCH_SISO) in rs_move_legacy_other()
1419 tbl->action = IWL_LEGACY_SWITCH_SISO; in rs_move_legacy_other()
1422 if (priv->bt_full_concurrent) { in rs_move_legacy_other()
1424 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; in rs_move_legacy_other()
1425 else if (tbl->action >= IWL_LEGACY_SWITCH_ANTENNA2) in rs_move_legacy_other()
1426 tbl->action = IWL_LEGACY_SWITCH_SISO; in rs_move_legacy_other()
1428 first_antenna(priv->nvm_data->valid_tx_ant); in rs_move_legacy_other()
1431 start_action = tbl->action; in rs_move_legacy_other()
1433 lq_sta->action_counter++; in rs_move_legacy_other()
1434 switch (tbl->action) { in rs_move_legacy_other()
1439 if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 && in rs_move_legacy_other()
1441 (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 && in rs_move_legacy_other()
1446 if (window->success_ratio >= IWL_RS_GOOD_RATIO && in rs_move_legacy_other()
1447 !priv->bt_full_concurrent && in rs_move_legacy_other()
1448 priv->bt_traffic_load == in rs_move_legacy_other()
1456 &search_tbl->current_rate, search_tbl)) { in rs_move_legacy_other()
1467 search_tbl->is_SGI = 0; in rs_move_legacy_other()
1471 lq_sta->action_counter = 0; in rs_move_legacy_other()
1483 search_tbl->is_SGI = 0; in rs_move_legacy_other()
1485 if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AB) in rs_move_legacy_other()
1486 search_tbl->ant_type = ANT_AB; in rs_move_legacy_other()
1487 else if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AC) in rs_move_legacy_other()
1488 search_tbl->ant_type = ANT_AC; in rs_move_legacy_other()
1490 search_tbl->ant_type = ANT_BC; in rs_move_legacy_other()
1492 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_legacy_other()
1498 lq_sta->action_counter = 0; in rs_move_legacy_other()
1508 search_tbl->is_SGI = 0; in rs_move_legacy_other()
1510 search_tbl->ant_type = ANT_ABC; in rs_move_legacy_other()
1512 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_legacy_other()
1518 lq_sta->action_counter = 0; in rs_move_legacy_other()
1523 tbl->action++; in rs_move_legacy_other()
1524 if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) in rs_move_legacy_other()
1525 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; in rs_move_legacy_other()
1527 if (tbl->action == start_action) in rs_move_legacy_other()
1531 search_tbl->lq_type = LQ_NONE; in rs_move_legacy_other()
1535 lq_sta->search_better_tbl = 1; in rs_move_legacy_other()
1536 tbl->action++; in rs_move_legacy_other()
1537 if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) in rs_move_legacy_other()
1538 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; in rs_move_legacy_other()
1540 search_tbl->action = tbl->action; in rs_move_legacy_other()
1551 u8 is_green = lq_sta->is_green; in rs_move_siso_to_other()
1552 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_move_siso_to_other()
1554 &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); in rs_move_siso_to_other()
1555 struct iwl_rate_scale_data *window = &(tbl->win[index]); in rs_move_siso_to_other()
1556 struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in rs_move_siso_to_other()
1557 u32 sz = (sizeof(struct iwl_scale_tbl_info) - in rs_move_siso_to_other()
1560 u8 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_move_siso_to_other()
1561 u8 tx_chains_num = priv->hw_params.tx_chains_num; in rs_move_siso_to_other()
1565 switch (priv->bt_traffic_load) { in rs_move_siso_to_other()
1571 if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) in rs_move_siso_to_other()
1572 tbl->action = IWL_SISO_SWITCH_MIMO2_AB; in rs_move_siso_to_other()
1578 first_antenna(priv->nvm_data->valid_tx_ant); in rs_move_siso_to_other()
1579 if (tbl->action != IWL_SISO_SWITCH_ANTENNA1) in rs_move_siso_to_other()
1580 tbl->action = IWL_SISO_SWITCH_ANTENNA1; in rs_move_siso_to_other()
1583 IWL_ERR(priv, "Invalid BT load %d\n", priv->bt_traffic_load); in rs_move_siso_to_other()
1588 tbl->action > IWL_SISO_SWITCH_ANTENNA2) { in rs_move_siso_to_other()
1590 tbl->action = IWL_SISO_SWITCH_ANTENNA1; in rs_move_siso_to_other()
1594 if (priv->bt_full_concurrent) { in rs_move_siso_to_other()
1596 first_antenna(priv->nvm_data->valid_tx_ant); in rs_move_siso_to_other()
1597 if (tbl->action >= IWL_LEGACY_SWITCH_ANTENNA2) in rs_move_siso_to_other()
1598 tbl->action = IWL_SISO_SWITCH_ANTENNA1; in rs_move_siso_to_other()
1601 start_action = tbl->action; in rs_move_siso_to_other()
1603 lq_sta->action_counter++; in rs_move_siso_to_other()
1604 switch (tbl->action) { in rs_move_siso_to_other()
1608 if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && in rs_move_siso_to_other()
1610 (tbl->action == IWL_SISO_SWITCH_ANTENNA2 && in rs_move_siso_to_other()
1614 if (window->success_ratio >= IWL_RS_GOOD_RATIO && in rs_move_siso_to_other()
1615 !priv->bt_full_concurrent && in rs_move_siso_to_other()
1616 priv->bt_traffic_load == in rs_move_siso_to_other()
1622 &search_tbl->current_rate, search_tbl)) { in rs_move_siso_to_other()
1632 search_tbl->is_SGI = 0; in rs_move_siso_to_other()
1634 if (tbl->action == IWL_SISO_SWITCH_MIMO2_AB) in rs_move_siso_to_other()
1635 search_tbl->ant_type = ANT_AB; in rs_move_siso_to_other()
1636 else if (tbl->action == IWL_SISO_SWITCH_MIMO2_AC) in rs_move_siso_to_other()
1637 search_tbl->ant_type = ANT_AC; in rs_move_siso_to_other()
1639 search_tbl->ant_type = ANT_BC; in rs_move_siso_to_other()
1641 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_siso_to_other()
1650 if (!tbl->is_ht40 && !(ht_cap->cap & in rs_move_siso_to_other()
1653 if (tbl->is_ht40 && !(ht_cap->cap & in rs_move_siso_to_other()
1661 if (!tbl->is_SGI) in rs_move_siso_to_other()
1667 search_tbl->is_SGI = !tbl->is_SGI; in rs_move_siso_to_other()
1669 if (tbl->is_SGI) { in rs_move_siso_to_other()
1670 s32 tpt = lq_sta->last_tpt / 100; in rs_move_siso_to_other()
1671 if (tpt >= search_tbl->expected_tpt[index]) in rs_move_siso_to_other()
1674 search_tbl->current_rate = in rs_move_siso_to_other()
1682 search_tbl->is_SGI = 0; in rs_move_siso_to_other()
1683 search_tbl->ant_type = ANT_ABC; in rs_move_siso_to_other()
1685 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_siso_to_other()
1694 tbl->action++; in rs_move_siso_to_other()
1695 if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) in rs_move_siso_to_other()
1696 tbl->action = IWL_SISO_SWITCH_ANTENNA1; in rs_move_siso_to_other()
1698 if (tbl->action == start_action) in rs_move_siso_to_other()
1701 search_tbl->lq_type = LQ_NONE; in rs_move_siso_to_other()
1705 lq_sta->search_better_tbl = 1; in rs_move_siso_to_other()
1706 tbl->action++; in rs_move_siso_to_other()
1707 if (tbl->action > IWL_SISO_SWITCH_MIMO3_ABC) in rs_move_siso_to_other()
1708 tbl->action = IWL_SISO_SWITCH_ANTENNA1; in rs_move_siso_to_other()
1710 search_tbl->action = tbl->action; in rs_move_siso_to_other()
1721 s8 is_green = lq_sta->is_green; in rs_move_mimo2_to_other()
1722 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_move_mimo2_to_other()
1724 &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); in rs_move_mimo2_to_other()
1725 struct iwl_rate_scale_data *window = &(tbl->win[index]); in rs_move_mimo2_to_other()
1726 struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in rs_move_mimo2_to_other()
1727 u32 sz = (sizeof(struct iwl_scale_tbl_info) - in rs_move_mimo2_to_other()
1730 u8 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_move_mimo2_to_other()
1731 u8 tx_chains_num = priv->hw_params.tx_chains_num; in rs_move_mimo2_to_other()
1735 switch (priv->bt_traffic_load) { in rs_move_mimo2_to_other()
1742 if (tbl->action != IWL_MIMO2_SWITCH_SISO_A) in rs_move_mimo2_to_other()
1743 tbl->action = IWL_MIMO2_SWITCH_SISO_A; in rs_move_mimo2_to_other()
1747 if (tbl->action == IWL_MIMO2_SWITCH_SISO_B || in rs_move_mimo2_to_other()
1748 tbl->action == IWL_MIMO2_SWITCH_SISO_C) in rs_move_mimo2_to_other()
1749 tbl->action = IWL_MIMO2_SWITCH_SISO_A; in rs_move_mimo2_to_other()
1752 IWL_ERR(priv, "Invalid BT load %d\n", priv->bt_traffic_load); in rs_move_mimo2_to_other()
1757 (tbl->action < IWL_MIMO2_SWITCH_SISO_A || in rs_move_mimo2_to_other()
1758 tbl->action > IWL_MIMO2_SWITCH_SISO_C)) { in rs_move_mimo2_to_other()
1760 tbl->action = IWL_MIMO2_SWITCH_SISO_A; in rs_move_mimo2_to_other()
1764 if (priv->bt_full_concurrent && in rs_move_mimo2_to_other()
1765 (tbl->action < IWL_MIMO2_SWITCH_SISO_A || in rs_move_mimo2_to_other()
1766 tbl->action > IWL_MIMO2_SWITCH_SISO_C)) in rs_move_mimo2_to_other()
1767 tbl->action = IWL_MIMO2_SWITCH_SISO_A; in rs_move_mimo2_to_other()
1769 start_action = tbl->action; in rs_move_mimo2_to_other()
1771 lq_sta->action_counter++; in rs_move_mimo2_to_other()
1772 switch (tbl->action) { in rs_move_mimo2_to_other()
1780 if (window->success_ratio >= IWL_RS_GOOD_RATIO) in rs_move_mimo2_to_other()
1785 &search_tbl->current_rate, search_tbl)) { in rs_move_mimo2_to_other()
1798 if (tbl->action == IWL_MIMO2_SWITCH_SISO_A) in rs_move_mimo2_to_other()
1799 search_tbl->ant_type = ANT_A; in rs_move_mimo2_to_other()
1800 else if (tbl->action == IWL_MIMO2_SWITCH_SISO_B) in rs_move_mimo2_to_other()
1801 search_tbl->ant_type = ANT_B; in rs_move_mimo2_to_other()
1803 search_tbl->ant_type = ANT_C; in rs_move_mimo2_to_other()
1805 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_mimo2_to_other()
1816 if (!tbl->is_ht40 && !(ht_cap->cap & in rs_move_mimo2_to_other()
1819 if (tbl->is_ht40 && !(ht_cap->cap & in rs_move_mimo2_to_other()
1827 search_tbl->is_SGI = !tbl->is_SGI; in rs_move_mimo2_to_other()
1835 if (tbl->is_SGI) { in rs_move_mimo2_to_other()
1836 s32 tpt = lq_sta->last_tpt / 100; in rs_move_mimo2_to_other()
1837 if (tpt >= search_tbl->expected_tpt[index]) in rs_move_mimo2_to_other()
1840 search_tbl->current_rate = in rs_move_mimo2_to_other()
1849 search_tbl->is_SGI = 0; in rs_move_mimo2_to_other()
1850 search_tbl->ant_type = ANT_ABC; in rs_move_mimo2_to_other()
1852 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_mimo2_to_other()
1862 tbl->action++; in rs_move_mimo2_to_other()
1863 if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC) in rs_move_mimo2_to_other()
1864 tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; in rs_move_mimo2_to_other()
1866 if (tbl->action == start_action) in rs_move_mimo2_to_other()
1869 search_tbl->lq_type = LQ_NONE; in rs_move_mimo2_to_other()
1872 lq_sta->search_better_tbl = 1; in rs_move_mimo2_to_other()
1873 tbl->action++; in rs_move_mimo2_to_other()
1874 if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC) in rs_move_mimo2_to_other()
1875 tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; in rs_move_mimo2_to_other()
1877 search_tbl->action = tbl->action; in rs_move_mimo2_to_other()
1889 s8 is_green = lq_sta->is_green; in rs_move_mimo3_to_other()
1890 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_move_mimo3_to_other()
1892 &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); in rs_move_mimo3_to_other()
1893 struct iwl_rate_scale_data *window = &(tbl->win[index]); in rs_move_mimo3_to_other()
1894 struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in rs_move_mimo3_to_other()
1895 u32 sz = (sizeof(struct iwl_scale_tbl_info) - in rs_move_mimo3_to_other()
1898 u8 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_move_mimo3_to_other()
1899 u8 tx_chains_num = priv->hw_params.tx_chains_num; in rs_move_mimo3_to_other()
1903 switch (priv->bt_traffic_load) { in rs_move_mimo3_to_other()
1910 if (tbl->action != IWL_MIMO3_SWITCH_SISO_A) in rs_move_mimo3_to_other()
1911 tbl->action = IWL_MIMO3_SWITCH_SISO_A; in rs_move_mimo3_to_other()
1915 if (tbl->action == IWL_MIMO3_SWITCH_SISO_B || in rs_move_mimo3_to_other()
1916 tbl->action == IWL_MIMO3_SWITCH_SISO_C) in rs_move_mimo3_to_other()
1917 tbl->action = IWL_MIMO3_SWITCH_SISO_A; in rs_move_mimo3_to_other()
1920 IWL_ERR(priv, "Invalid BT load %d\n", priv->bt_traffic_load); in rs_move_mimo3_to_other()
1925 (tbl->action < IWL_MIMO3_SWITCH_SISO_A || in rs_move_mimo3_to_other()
1926 tbl->action > IWL_MIMO3_SWITCH_SISO_C)) { in rs_move_mimo3_to_other()
1928 tbl->action = IWL_MIMO3_SWITCH_SISO_A; in rs_move_mimo3_to_other()
1932 if (priv->bt_full_concurrent && in rs_move_mimo3_to_other()
1933 (tbl->action < IWL_MIMO3_SWITCH_SISO_A || in rs_move_mimo3_to_other()
1934 tbl->action > IWL_MIMO3_SWITCH_SISO_C)) in rs_move_mimo3_to_other()
1935 tbl->action = IWL_MIMO3_SWITCH_SISO_A; in rs_move_mimo3_to_other()
1937 start_action = tbl->action; in rs_move_mimo3_to_other()
1939 lq_sta->action_counter++; in rs_move_mimo3_to_other()
1940 switch (tbl->action) { in rs_move_mimo3_to_other()
1948 if (window->success_ratio >= IWL_RS_GOOD_RATIO) in rs_move_mimo3_to_other()
1953 &search_tbl->current_rate, search_tbl)) in rs_move_mimo3_to_other()
1964 if (tbl->action == IWL_MIMO3_SWITCH_SISO_A) in rs_move_mimo3_to_other()
1965 search_tbl->ant_type = ANT_A; in rs_move_mimo3_to_other()
1966 else if (tbl->action == IWL_MIMO3_SWITCH_SISO_B) in rs_move_mimo3_to_other()
1967 search_tbl->ant_type = ANT_B; in rs_move_mimo3_to_other()
1969 search_tbl->ant_type = ANT_C; in rs_move_mimo3_to_other()
1971 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_mimo3_to_other()
1987 search_tbl->is_SGI = 0; in rs_move_mimo3_to_other()
1988 if (tbl->action == IWL_MIMO3_SWITCH_MIMO2_AB) in rs_move_mimo3_to_other()
1989 search_tbl->ant_type = ANT_AB; in rs_move_mimo3_to_other()
1990 else if (tbl->action == IWL_MIMO3_SWITCH_MIMO2_AC) in rs_move_mimo3_to_other()
1991 search_tbl->ant_type = ANT_AC; in rs_move_mimo3_to_other()
1993 search_tbl->ant_type = ANT_BC; in rs_move_mimo3_to_other()
1995 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) in rs_move_mimo3_to_other()
2006 if (!tbl->is_ht40 && !(ht_cap->cap & in rs_move_mimo3_to_other()
2009 if (tbl->is_ht40 && !(ht_cap->cap & in rs_move_mimo3_to_other()
2017 search_tbl->is_SGI = !tbl->is_SGI; in rs_move_mimo3_to_other()
2025 if (tbl->is_SGI) { in rs_move_mimo3_to_other()
2026 s32 tpt = lq_sta->last_tpt / 100; in rs_move_mimo3_to_other()
2027 if (tpt >= search_tbl->expected_tpt[index]) in rs_move_mimo3_to_other()
2030 search_tbl->current_rate = in rs_move_mimo3_to_other()
2036 tbl->action++; in rs_move_mimo3_to_other()
2037 if (tbl->action > IWL_MIMO3_SWITCH_GI) in rs_move_mimo3_to_other()
2038 tbl->action = IWL_MIMO3_SWITCH_ANTENNA1; in rs_move_mimo3_to_other()
2040 if (tbl->action == start_action) in rs_move_mimo3_to_other()
2043 search_tbl->lq_type = LQ_NONE; in rs_move_mimo3_to_other()
2046 lq_sta->search_better_tbl = 1; in rs_move_mimo3_to_other()
2047 tbl->action++; in rs_move_mimo3_to_other()
2048 if (tbl->action > IWL_MIMO3_SWITCH_GI) in rs_move_mimo3_to_other()
2049 tbl->action = IWL_MIMO3_SWITCH_ANTENNA1; in rs_move_mimo3_to_other()
2051 search_tbl->action = tbl->action; in rs_move_mimo3_to_other()
2069 priv = lq_sta->drv; in rs_stay_in_table()
2070 active_tbl = lq_sta->active_tbl; in rs_stay_in_table()
2072 tbl = &(lq_sta->lq_info[active_tbl]); in rs_stay_in_table()
2075 if (lq_sta->stay_in_tbl) { in rs_stay_in_table()
2078 if (lq_sta->flush_timer) in rs_stay_in_table()
2081 (unsigned long)(lq_sta->flush_timer + in rs_stay_in_table()
2093 (lq_sta->total_failed > lq_sta->max_failure_limit) || in rs_stay_in_table()
2094 (lq_sta->total_success > lq_sta->max_success_limit) || in rs_stay_in_table()
2095 ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) in rs_stay_in_table()
2098 lq_sta->total_failed, in rs_stay_in_table()
2099 lq_sta->total_success, in rs_stay_in_table()
2103 lq_sta->stay_in_tbl = 0; /* only place reset */ in rs_stay_in_table()
2104 lq_sta->total_failed = 0; in rs_stay_in_table()
2105 lq_sta->total_success = 0; in rs_stay_in_table()
2106 lq_sta->flush_timer = 0; in rs_stay_in_table()
2111 * history bitmaps and rate-specific stats for all rates in in rs_stay_in_table()
2115 lq_sta->table_count++; in rs_stay_in_table()
2116 if (lq_sta->table_count >= in rs_stay_in_table()
2117 lq_sta->table_count_limit) { in rs_stay_in_table()
2118 lq_sta->table_count = 0; in rs_stay_in_table()
2123 &(tbl->win[i])); in rs_stay_in_table()
2130 if (!lq_sta->stay_in_tbl) { in rs_stay_in_table()
2132 rs_rate_scale_clear_window(&(tbl->win[i])); in rs_stay_in_table()
2151 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); in rs_update_rate_tbl()
2162 struct ieee80211_hw *hw = priv->hw; in rs_rate_scale_perform()
2163 struct ieee80211_conf *conf = &hw->conf; in rs_rate_scale_perform()
2165 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in rs_rate_scale_perform()
2187 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; in rs_rate_scale_perform()
2188 struct iwl_rxon_context *ctx = sta_priv->ctx; in rs_rate_scale_perform()
2194 if (!ieee80211_is_data(hdr->frame_control) || in rs_rate_scale_perform()
2195 info->flags & IEEE80211_TX_CTL_NO_ACK) in rs_rate_scale_perform()
2198 lq_sta->supp_rates = sta->deflink.supp_rates[lq_sta->band]; in rs_rate_scale_perform()
2202 (lq_sta->tx_agg_tid_en & (1 << tid))) { in rs_rate_scale_perform()
2203 tid_data = &priv->tid_data[lq_sta->lq.sta_id][tid]; in rs_rate_scale_perform()
2204 if (tid_data->agg.state == IWL_AGG_OFF) in rs_rate_scale_perform()
2205 lq_sta->is_agg = 0; in rs_rate_scale_perform()
2207 lq_sta->is_agg = 1; in rs_rate_scale_perform()
2209 lq_sta->is_agg = 0; in rs_rate_scale_perform()
2212 * Select rate-scale / modulation-mode table to work with in in rs_rate_scale_perform()
2216 if (!lq_sta->search_better_tbl) in rs_rate_scale_perform()
2217 active_tbl = lq_sta->active_tbl; in rs_rate_scale_perform()
2219 active_tbl = 1 - lq_sta->active_tbl; in rs_rate_scale_perform()
2221 tbl = &(lq_sta->lq_info[active_tbl]); in rs_rate_scale_perform()
2222 if (is_legacy(tbl->lq_type)) in rs_rate_scale_perform()
2223 lq_sta->is_green = 0; in rs_rate_scale_perform()
2225 lq_sta->is_green = rs_use_green(sta); in rs_rate_scale_perform()
2226 is_green = lq_sta->is_green; in rs_rate_scale_perform()
2229 index = lq_sta->last_txrate_idx; in rs_rate_scale_perform()
2232 tbl->lq_type); in rs_rate_scale_perform()
2235 rate_mask = rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); in rs_rate_scale_perform()
2240 if (is_legacy(tbl->lq_type)) { in rs_rate_scale_perform()
2241 if (lq_sta->band == NL80211_BAND_5GHZ) in rs_rate_scale_perform()
2244 (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); in rs_rate_scale_perform()
2247 lq_sta->supp_rates); in rs_rate_scale_perform()
2257 if (lq_sta->search_better_tbl) { in rs_rate_scale_perform()
2259 tbl->lq_type = LQ_NONE; in rs_rate_scale_perform()
2260 lq_sta->search_better_tbl = 0; in rs_rate_scale_perform()
2261 tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_rate_scale_perform()
2263 index = iwl_hwrate_to_plcp_idx(tbl->current_rate); in rs_rate_scale_perform()
2271 if (!tbl->expected_tpt) { in rs_rate_scale_perform()
2272 IWL_ERR(priv, "tbl->expected_tpt is NULL\n"); in rs_rate_scale_perform()
2277 if ((lq_sta->max_rate_idx != -1) && in rs_rate_scale_perform()
2278 (lq_sta->max_rate_idx < index)) { in rs_rate_scale_perform()
2279 index = lq_sta->max_rate_idx; in rs_rate_scale_perform()
2281 window = &(tbl->win[index]); in rs_rate_scale_perform()
2285 window = &(tbl->win[index]); in rs_rate_scale_perform()
2294 fail_count = window->counter - window->success_counter; in rs_rate_scale_perform()
2296 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) { in rs_rate_scale_perform()
2299 window->success_counter, window->counter, index); in rs_rate_scale_perform()
2302 window->average_tpt = IWL_INVALID_VALUE; in rs_rate_scale_perform()
2312 if (window->average_tpt != ((window->success_ratio * in rs_rate_scale_perform()
2313 tbl->expected_tpt[index] + 64) / 128)) { in rs_rate_scale_perform()
2315 window->average_tpt = ((window->success_ratio * in rs_rate_scale_perform()
2316 tbl->expected_tpt[index] + 64) / 128); in rs_rate_scale_perform()
2320 if (lq_sta->search_better_tbl && in rs_rate_scale_perform()
2325 if (window->average_tpt > lq_sta->last_tpt) { in rs_rate_scale_perform()
2328 "suc=%d cur-tpt=%d old-tpt=%d\n", in rs_rate_scale_perform()
2329 window->success_ratio, in rs_rate_scale_perform()
2330 window->average_tpt, in rs_rate_scale_perform()
2331 lq_sta->last_tpt); in rs_rate_scale_perform()
2333 if (!is_legacy(tbl->lq_type)) in rs_rate_scale_perform()
2334 lq_sta->enable_counter = 1; in rs_rate_scale_perform()
2337 lq_sta->active_tbl = active_tbl; in rs_rate_scale_perform()
2338 current_tpt = window->average_tpt; in rs_rate_scale_perform()
2344 "suc=%d cur-tpt=%d old-tpt=%d\n", in rs_rate_scale_perform()
2345 window->success_ratio, in rs_rate_scale_perform()
2346 window->average_tpt, in rs_rate_scale_perform()
2347 lq_sta->last_tpt); in rs_rate_scale_perform()
2350 tbl->lq_type = LQ_NONE; in rs_rate_scale_perform()
2353 active_tbl = lq_sta->active_tbl; in rs_rate_scale_perform()
2354 tbl = &(lq_sta->lq_info[active_tbl]); in rs_rate_scale_perform()
2357 index = iwl_hwrate_to_plcp_idx(tbl->current_rate); in rs_rate_scale_perform()
2358 current_tpt = lq_sta->last_tpt; in rs_rate_scale_perform()
2366 lq_sta->search_better_tbl = 0; in rs_rate_scale_perform()
2374 tbl->lq_type); in rs_rate_scale_perform()
2379 if ((lq_sta->max_rate_idx != -1) && in rs_rate_scale_perform()
2380 (lq_sta->max_rate_idx < high)) in rs_rate_scale_perform()
2383 sr = window->success_ratio; in rs_rate_scale_perform()
2386 current_tpt = window->average_tpt; in rs_rate_scale_perform()
2388 low_tpt = tbl->win[low].average_tpt; in rs_rate_scale_perform()
2390 high_tpt = tbl->win[high].average_tpt; in rs_rate_scale_perform()
2397 scale_action = -1; in rs_rate_scale_perform()
2436 scale_action = -1; in rs_rate_scale_perform()
2445 if ((scale_action == -1) && (low != IWL_RATE_INVALID) && in rs_rate_scale_perform()
2447 (current_tpt > (100 * tbl->expected_tpt[low])))) in rs_rate_scale_perform()
2449 if (!iwl_ht_enabled(priv) && !is_legacy(tbl->lq_type)) in rs_rate_scale_perform()
2450 scale_action = -1; in rs_rate_scale_perform()
2452 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) in rs_rate_scale_perform()
2453 scale_action = -1; in rs_rate_scale_perform()
2455 if ((priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) && in rs_rate_scale_perform()
2456 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) { in rs_rate_scale_perform()
2457 if (lq_sta->last_bt_traffic > priv->bt_traffic_load) { in rs_rate_scale_perform()
2463 } else if (lq_sta->last_bt_traffic <= priv->bt_traffic_load) { in rs_rate_scale_perform()
2464 scale_action = -1; in rs_rate_scale_perform()
2467 lq_sta->last_bt_traffic = priv->bt_traffic_load; in rs_rate_scale_perform()
2469 if ((priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) && in rs_rate_scale_perform()
2470 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) { in rs_rate_scale_perform()
2477 case -1: in rs_rate_scale_perform()
2501 index, scale_action, low, high, tbl->lq_type); in rs_rate_scale_perform()
2519 if (!update_lq && !done_search && !lq_sta->stay_in_tbl && window->counter) { in rs_rate_scale_perform()
2521 lq_sta->last_tpt = current_tpt; in rs_rate_scale_perform()
2523 /* Select a new "search" modulation mode to try. in rs_rate_scale_perform()
2525 if (is_legacy(tbl->lq_type)) in rs_rate_scale_perform()
2527 else if (is_siso(tbl->lq_type)) in rs_rate_scale_perform()
2529 else if (is_mimo2(tbl->lq_type)) in rs_rate_scale_perform()
2535 if (lq_sta->search_better_tbl) { in rs_rate_scale_perform()
2537 tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); in rs_rate_scale_perform()
2539 rs_rate_scale_clear_window(&(tbl->win[i])); in rs_rate_scale_perform()
2542 index = iwl_hwrate_to_plcp_idx(tbl->current_rate); in rs_rate_scale_perform()
2545 tbl->current_rate, index); in rs_rate_scale_perform()
2546 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); in rs_rate_scale_perform()
2547 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); in rs_rate_scale_perform()
2552 if (done_search && !lq_sta->stay_in_tbl) { in rs_rate_scale_perform()
2553 /* If the "active" (non-search) mode was legacy, in rs_rate_scale_perform()
2558 tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_rate_scale_perform()
2559 if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && in rs_rate_scale_perform()
2560 lq_sta->action_counter > tbl1->max_search) { in rs_rate_scale_perform()
2568 if (lq_sta->enable_counter && in rs_rate_scale_perform()
2569 (lq_sta->action_counter >= tbl1->max_search) && in rs_rate_scale_perform()
2571 if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && in rs_rate_scale_perform()
2572 (lq_sta->tx_agg_tid_en & (1 << tid)) && in rs_rate_scale_perform()
2574 u8 sta_id = lq_sta->lq.sta_id; in rs_rate_scale_perform()
2575 tid_data = &priv->tid_data[sta_id][tid]; in rs_rate_scale_perform()
2576 if (tid_data->agg.state == IWL_AGG_OFF) { in rs_rate_scale_perform()
2589 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); in rs_rate_scale_perform()
2590 lq_sta->last_txrate_idx = index; in rs_rate_scale_perform()
2594 * rs_initialize_lq - Initialize a station's hardware rate table
2600 * if the driver's iwl-agn-rs rate scaling algorithm is used, instead of
2624 sta_priv = (void *)sta->drv_priv; in rs_initialize_lq()
2625 ctx = sta_priv->ctx; in rs_initialize_lq()
2627 i = lq_sta->last_txrate_idx; in rs_initialize_lq()
2629 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_initialize_lq()
2631 if (!lq_sta->search_better_tbl) in rs_initialize_lq()
2632 active_tbl = lq_sta->active_tbl; in rs_initialize_lq()
2634 active_tbl = 1 - lq_sta->active_tbl; in rs_initialize_lq()
2636 tbl = &(lq_sta->lq_info[active_tbl]); in rs_initialize_lq()
2642 tbl->ant_type = first_antenna(valid_tx_ant); in rs_initialize_lq()
2643 rate |= tbl->ant_type << RATE_MCS_ANT_POS; in rs_initialize_lq()
2648 rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); in rs_initialize_lq()
2649 if (!rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) in rs_initialize_lq()
2653 tbl->current_rate = rate; in rs_initialize_lq()
2656 priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; in rs_initialize_lq()
2657 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, 0, true); in rs_initialize_lq()
2664 struct sk_buff *skb = txrc->skb; in rs_get_rate()
2665 struct ieee80211_supported_band *sband = txrc->sband; in rs_get_rate()
2676 lq_sta->max_rate_idx = fls(txrc->rate_idx_mask) - 1; in rs_get_rate()
2677 if (sband->band == NL80211_BAND_5GHZ && lq_sta->max_rate_idx != -1) in rs_get_rate()
2678 lq_sta->max_rate_idx += IWL_FIRST_OFDM_RATE; in rs_get_rate()
2679 if (lq_sta->max_rate_idx < 0 || lq_sta->max_rate_idx >= IWL_RATE_COUNT) in rs_get_rate()
2680 lq_sta->max_rate_idx = -1; in rs_get_rate()
2682 if (!lq_sta->drv) { in rs_get_rate()
2688 rate_idx = lq_sta->last_txrate_idx; in rs_get_rate()
2690 if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { in rs_get_rate()
2691 rate_idx -= IWL_FIRST_OFDM_RATE; in rs_get_rate()
2693 rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; in rs_get_rate()
2694 if (rs_extract_rate(lq_sta->last_rate_n_flags) >= in rs_get_rate()
2697 else if (rs_extract_rate(lq_sta->last_rate_n_flags) >= in rs_get_rate()
2700 info->control.rates[0].flags = IEEE80211_TX_RC_MCS; in rs_get_rate()
2701 if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) in rs_get_rate()
2702 info->control.rates[0].flags |= IEEE80211_TX_RC_SHORT_GI; in rs_get_rate()
2703 if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) in rs_get_rate()
2704 info->control.rates[0].flags |= IEEE80211_TX_RC_DUP_DATA; in rs_get_rate()
2705 if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) in rs_get_rate()
2706 info->control.rates[0].flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; in rs_get_rate()
2707 if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) in rs_get_rate()
2708 info->control.rates[0].flags |= IEEE80211_TX_RC_GREEN_FIELD; in rs_get_rate()
2712 ((sband->band == NL80211_BAND_5GHZ) && in rs_get_rate()
2716 else if (sband->band == NL80211_BAND_5GHZ) in rs_get_rate()
2717 rate_idx -= IWL_FIRST_OFDM_RATE; in rs_get_rate()
2718 info->control.rates[0].flags = 0; in rs_get_rate()
2720 info->control.rates[0].idx = rate_idx; in rs_get_rate()
2721 info->control.rates[0].count = 1; in rs_get_rate()
2727 struct iwl_station_priv *sta_priv = (struct iwl_station_priv *) sta->drv_priv; in rs_alloc_sta()
2734 return &sta_priv->lq_sta; in rs_alloc_sta()
2743 struct ieee80211_hw *hw = priv->hw; in iwl_rs_rate_init()
2744 struct ieee80211_conf *conf = &priv->hw->conf; in iwl_rs_rate_init()
2745 struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in iwl_rs_rate_init()
2751 sta_priv = (struct iwl_station_priv *) sta->drv_priv; in iwl_rs_rate_init()
2752 lq_sta = &sta_priv->lq_sta; in iwl_rs_rate_init()
2753 sband = hw->wiphy->bands[conf->chandef.chan->band]; in iwl_rs_rate_init()
2755 lq_sta->lq.sta_id = sta_id; in iwl_rs_rate_init()
2759 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); in iwl_rs_rate_init()
2761 lq_sta->flush_timer = 0; in iwl_rs_rate_init()
2762 lq_sta->supp_rates = sta->deflink.supp_rates[sband->band]; in iwl_rs_rate_init()
2769 * after assoc.. */ in iwl_rs_rate_init()
2771 lq_sta->is_dup = 0; in iwl_rs_rate_init()
2772 lq_sta->max_rate_idx = -1; in iwl_rs_rate_init()
2773 lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; in iwl_rs_rate_init()
2774 lq_sta->is_green = rs_use_green(sta); in iwl_rs_rate_init()
2775 lq_sta->band = sband->band; in iwl_rs_rate_init()
2779 supp = sta->deflink.supp_rates[sband->band]; in iwl_rs_rate_init()
2780 lq_sta->active_legacy_rate = 0; in iwl_rs_rate_init()
2782 lq_sta->active_legacy_rate |= BIT(sband->bitrates[i].hw_value); in iwl_rs_rate_init()
2785 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), in iwl_rs_rate_init()
2788 lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; in iwl_rs_rate_init()
2789 lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; in iwl_rs_rate_init()
2790 lq_sta->active_siso_rate &= ~((u16)0x2); in iwl_rs_rate_init()
2791 lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE; in iwl_rs_rate_init()
2794 lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; in iwl_rs_rate_init()
2795 lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; in iwl_rs_rate_init()
2796 lq_sta->active_mimo2_rate &= ~((u16)0x2); in iwl_rs_rate_init()
2797 lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; in iwl_rs_rate_init()
2799 lq_sta->active_mimo3_rate = ht_cap->mcs.rx_mask[2] << 1; in iwl_rs_rate_init()
2800 lq_sta->active_mimo3_rate |= ht_cap->mcs.rx_mask[2] & 0x1; in iwl_rs_rate_init()
2801 lq_sta->active_mimo3_rate &= ~((u16)0x2); in iwl_rs_rate_init()
2802 lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; in iwl_rs_rate_init()
2804 IWL_DEBUG_RATE(priv, "SISO-RATE=%X MIMO2-RATE=%X MIMO3-RATE=%X\n", in iwl_rs_rate_init()
2805 lq_sta->active_siso_rate, in iwl_rs_rate_init()
2806 lq_sta->active_mimo2_rate, in iwl_rs_rate_init()
2807 lq_sta->active_mimo3_rate); in iwl_rs_rate_init()
2810 lq_sta->lq.general_params.single_stream_ant_msk = in iwl_rs_rate_init()
2811 first_antenna(priv->nvm_data->valid_tx_ant); in iwl_rs_rate_init()
2812 lq_sta->lq.general_params.dual_stream_ant_msk = in iwl_rs_rate_init()
2813 priv->nvm_data->valid_tx_ant & in iwl_rs_rate_init()
2814 ~first_antenna(priv->nvm_data->valid_tx_ant); in iwl_rs_rate_init()
2815 if (!lq_sta->lq.general_params.dual_stream_ant_msk) { in iwl_rs_rate_init()
2816 lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; in iwl_rs_rate_init()
2817 } else if (num_of_ant(priv->nvm_data->valid_tx_ant) == 2) { in iwl_rs_rate_init()
2818 lq_sta->lq.general_params.dual_stream_ant_msk = in iwl_rs_rate_init()
2819 priv->nvm_data->valid_tx_ant; in iwl_rs_rate_init()
2823 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; in iwl_rs_rate_init()
2824 lq_sta->drv = priv; in iwl_rs_rate_init()
2827 lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); in iwl_rs_rate_init()
2828 if (sband->band == NL80211_BAND_5GHZ) in iwl_rs_rate_init()
2829 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; in iwl_rs_rate_init()
2830 lq_sta->is_agg = 0; in iwl_rs_rate_init()
2832 lq_sta->dbg_fixed_rate = 0; in iwl_rs_rate_init()
2850 struct iwl_link_quality_cmd *lq_cmd = &lq_sta->lq; in rs_fill_link_cmd()
2856 rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, in rs_fill_link_cmd()
2859 if (priv && priv->bt_full_concurrent) { in rs_fill_link_cmd()
2862 first_antenna(priv->nvm_data->valid_tx_ant); in rs_fill_link_cmd()
2871 LINK_QUAL_AGG_DISABLE_START_DEF - 1); in rs_fill_link_cmd()
2874 lq_cmd->general_params.mimo_delimiter = in rs_fill_link_cmd()
2878 lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); in rs_fill_link_cmd()
2881 lq_cmd->general_params.single_stream_ant_msk = in rs_fill_link_cmd()
2884 lq_cmd->general_params.dual_stream_ant_msk = in rs_fill_link_cmd()
2889 repeat_rate--; in rs_fill_link_cmd()
2891 if (priv->bt_full_concurrent) in rs_fill_link_cmd()
2894 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_fill_link_cmd()
2916 lq_cmd->rs_table[index].rate_n_flags = in rs_fill_link_cmd()
2918 repeat_rate--; in rs_fill_link_cmd()
2922 rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, in rs_fill_link_cmd()
2925 if (priv && priv->bt_full_concurrent) { in rs_fill_link_cmd()
2928 first_antenna(priv->nvm_data->valid_tx_ant); in rs_fill_link_cmd()
2935 lq_cmd->general_params.mimo_delimiter = index; in rs_fill_link_cmd()
2963 lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); in rs_fill_link_cmd()
2966 repeat_rate--; in rs_fill_link_cmd()
2969 lq_cmd->agg_params.agg_frame_cnt_limit = in rs_fill_link_cmd()
2970 sta_priv->max_agg_bufsize ?: LINK_QUAL_AGG_FRAME_LIMIT_DEF; in rs_fill_link_cmd()
2971 lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; in rs_fill_link_cmd()
2973 lq_cmd->agg_params.agg_time_limit = in rs_fill_link_cmd()
2979 if (priv && priv->lib->bt_params && in rs_fill_link_cmd()
2980 priv->lib->bt_params->agg_time_limit && in rs_fill_link_cmd()
2981 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) in rs_fill_link_cmd()
2982 lq_cmd->agg_params.agg_time_limit = in rs_fill_link_cmd()
2983 cpu_to_le16(priv->lib->bt_params->agg_time_limit); in rs_fill_link_cmd()
2988 return hw->priv; in rs_alloc()
3014 priv = lq_sta->drv; in rs_dbgfs_set_mcs()
3015 valid_tx_ant = priv->nvm_data->valid_tx_ant; in rs_dbgfs_set_mcs()
3016 if (lq_sta->dbg_fixed_rate) { in rs_dbgfs_set_mcs()
3018 ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) in rs_dbgfs_set_mcs()
3021 *rate_n_flags = lq_sta->dbg_fixed_rate; in rs_dbgfs_set_mcs()
3024 lq_sta->dbg_fixed_rate = 0; in rs_dbgfs_set_mcs()
3038 struct iwl_lq_sta *lq_sta = file->private_data; in rs_sta_dbgfs_scale_table_write()
3045 priv = lq_sta->drv; in rs_sta_dbgfs_scale_table_write()
3047 buf_size = min(count, sizeof(buf) - 1); in rs_sta_dbgfs_scale_table_write()
3049 return -EFAULT; in rs_sta_dbgfs_scale_table_write()
3052 lq_sta->dbg_fixed_rate = parsed_rate; in rs_sta_dbgfs_scale_table_write()
3054 lq_sta->dbg_fixed_rate = 0; in rs_sta_dbgfs_scale_table_write()
3087 struct iwl_lq_sta *lq_sta = file->private_data; in rs_sta_dbgfs_scale_table_read()
3089 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); in rs_sta_dbgfs_scale_table_read()
3091 priv = lq_sta->drv; in rs_sta_dbgfs_scale_table_read()
3094 return -ENOMEM; in rs_sta_dbgfs_scale_table_read()
3096 desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); in rs_sta_dbgfs_scale_table_read()
3098 lq_sta->total_failed, lq_sta->total_success, in rs_sta_dbgfs_scale_table_read()
3099 lq_sta->active_legacy_rate); in rs_sta_dbgfs_scale_table_read()
3101 lq_sta->dbg_fixed_rate); in rs_sta_dbgfs_scale_table_read()
3103 (priv->nvm_data->valid_tx_ant & ANT_A) ? "ANT_A," : "", in rs_sta_dbgfs_scale_table_read()
3104 (priv->nvm_data->valid_tx_ant & ANT_B) ? "ANT_B," : "", in rs_sta_dbgfs_scale_table_read()
3105 (priv->nvm_data->valid_tx_ant & ANT_C) ? "ANT_C" : ""); in rs_sta_dbgfs_scale_table_read()
3107 (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); in rs_sta_dbgfs_scale_table_read()
3108 if (is_Ht(tbl->lq_type)) { in rs_sta_dbgfs_scale_table_read()
3110 (is_siso(tbl->lq_type)) ? "SISO" : in rs_sta_dbgfs_scale_table_read()
3111 ((is_mimo2(tbl->lq_type)) ? "MIMO2" : "MIMO3")); in rs_sta_dbgfs_scale_table_read()
3113 (tbl->is_ht40) ? "40MHz" : "20MHz"); in rs_sta_dbgfs_scale_table_read()
3115 (tbl->is_SGI) ? "SGI" : "", in rs_sta_dbgfs_scale_table_read()
3116 (lq_sta->is_green) ? "GF enabled" : "", in rs_sta_dbgfs_scale_table_read()
3117 (lq_sta->is_agg) ? "AGG on" : ""); in rs_sta_dbgfs_scale_table_read()
3120 lq_sta->last_rate_n_flags); in rs_sta_dbgfs_scale_table_read()
3122 "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", in rs_sta_dbgfs_scale_table_read()
3123 lq_sta->lq.general_params.flags, in rs_sta_dbgfs_scale_table_read()
3124 lq_sta->lq.general_params.mimo_delimiter, in rs_sta_dbgfs_scale_table_read()
3125 lq_sta->lq.general_params.single_stream_ant_msk, in rs_sta_dbgfs_scale_table_read()
3126 lq_sta->lq.general_params.dual_stream_ant_msk); in rs_sta_dbgfs_scale_table_read()
3130 le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), in rs_sta_dbgfs_scale_table_read()
3131 lq_sta->lq.agg_params.agg_dis_start_th, in rs_sta_dbgfs_scale_table_read()
3132 lq_sta->lq.agg_params.agg_frame_cnt_limit); in rs_sta_dbgfs_scale_table_read()
3136 lq_sta->lq.general_params.start_rate_index[0], in rs_sta_dbgfs_scale_table_read()
3137 lq_sta->lq.general_params.start_rate_index[1], in rs_sta_dbgfs_scale_table_read()
3138 lq_sta->lq.general_params.start_rate_index[2], in rs_sta_dbgfs_scale_table_read()
3139 lq_sta->lq.general_params.start_rate_index[3]); in rs_sta_dbgfs_scale_table_read()
3143 le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); in rs_sta_dbgfs_scale_table_read()
3146 i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); in rs_sta_dbgfs_scale_table_read()
3147 } else if (is_legacy(tbl->lq_type)) { in rs_sta_dbgfs_scale_table_read()
3149 i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), in rs_sta_dbgfs_scale_table_read()
3153 i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), in rs_sta_dbgfs_scale_table_read()
3177 struct iwl_lq_sta *lq_sta = file->private_data; in rs_sta_dbgfs_stats_table_read()
3181 return -ENOMEM; in rs_sta_dbgfs_stats_table_read()
3187 lq_sta->active_tbl == i ? "*" : "x", in rs_sta_dbgfs_stats_table_read()
3188 lq_sta->lq_info[i].lq_type, in rs_sta_dbgfs_stats_table_read()
3189 lq_sta->lq_info[i].is_SGI, in rs_sta_dbgfs_stats_table_read()
3190 lq_sta->lq_info[i].is_ht40, in rs_sta_dbgfs_stats_table_read()
3191 lq_sta->lq_info[i].is_dup, in rs_sta_dbgfs_stats_table_read()
3192 lq_sta->is_green, in rs_sta_dbgfs_stats_table_read()
3193 lq_sta->lq_info[i].current_rate); in rs_sta_dbgfs_stats_table_read()
3197 lq_sta->lq_info[i].win[j].counter, in rs_sta_dbgfs_stats_table_read()
3198 lq_sta->lq_info[i].win[j].success_counter, in rs_sta_dbgfs_stats_table_read()
3199 lq_sta->lq_info[i].win[j].success_ratio); in rs_sta_dbgfs_stats_table_read()
3216 struct iwl_lq_sta *lq_sta = file->private_data; in rs_sta_dbgfs_rate_scale_data_read()
3217 struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; in rs_sta_dbgfs_rate_scale_data_read()
3221 if (is_Ht(tbl->lq_type)) in rs_sta_dbgfs_rate_scale_data_read()
3224 tbl->expected_tpt[lq_sta->last_txrate_idx]); in rs_sta_dbgfs_rate_scale_data_read()
3228 iwl_rates[lq_sta->last_txrate_idx].ieee >> 1); in rs_sta_dbgfs_rate_scale_data_read()
3251 &lq_sta->tx_agg_tid_en); in rs_add_debugfs()