diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn-rs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 210 |
1 files changed, 128 insertions, 82 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 27f50471aed..04b42c8a770 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. | 3 | * Copyright(c) 2005 - 2009 Intel Corporation. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of version 2 of the GNU General Public License as | 6 | * under the terms of version 2 of the GNU General Public License as |
@@ -49,6 +49,8 @@ | |||
49 | #define IWL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ | 49 | #define IWL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ |
50 | #define IWL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ | 50 | #define IWL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ |
51 | 51 | ||
52 | /* max allowed rate miss before sync LQ cmd */ | ||
53 | #define IWL_MISSED_RATE_MAX 15 | ||
52 | /* max time to accum history 2 seconds */ | 54 | /* max time to accum history 2 seconds */ |
53 | #define IWL_RATE_SCALE_FLUSH_INTVL (2*HZ) | 55 | #define IWL_RATE_SCALE_FLUSH_INTVL (2*HZ) |
54 | 56 | ||
@@ -148,6 +150,8 @@ struct iwl_lq_sta { | |||
148 | u16 active_mimo2_rate; | 150 | u16 active_mimo2_rate; |
149 | u16 active_mimo3_rate; | 151 | u16 active_mimo3_rate; |
150 | u16 active_rate_basic; | 152 | u16 active_rate_basic; |
153 | s8 max_rate_idx; /* Max rate set by user */ | ||
154 | u8 missed_rate_counter; | ||
151 | 155 | ||
152 | struct iwl_link_quality_cmd lq; | 156 | struct iwl_link_quality_cmd lq; |
153 | struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ | 157 | struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ |
@@ -356,7 +360,7 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, | |||
356 | struct ieee80211_sta *sta) | 360 | struct ieee80211_sta *sta) |
357 | { | 361 | { |
358 | if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { | 362 | if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { |
359 | IWL_DEBUG_HT("Starting Tx agg: STA: %pM tid: %d\n", | 363 | IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", |
360 | sta->addr, tid); | 364 | sta->addr, tid); |
361 | ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); | 365 | ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); |
362 | } | 366 | } |
@@ -463,8 +467,9 @@ static int rs_collect_tx_data(struct iwl_rate_scale_data *windows, | |||
463 | * Fill uCode API rate_n_flags field, based on "search" or "active" table. | 467 | * Fill uCode API rate_n_flags field, based on "search" or "active" table. |
464 | */ | 468 | */ |
465 | /* FIXME:RS:remove this function and put the flags statically in the table */ | 469 | /* FIXME:RS:remove this function and put the flags statically in the table */ |
466 | static u32 rate_n_flags_from_tbl(struct iwl_scale_tbl_info *tbl, | 470 | static u32 rate_n_flags_from_tbl(struct iwl_priv *priv, |
467 | int index, u8 use_green) | 471 | struct iwl_scale_tbl_info *tbl, |
472 | int index, u8 use_green) | ||
468 | { | 473 | { |
469 | u32 rate_n_flags = 0; | 474 | u32 rate_n_flags = 0; |
470 | 475 | ||
@@ -475,7 +480,7 @@ static u32 rate_n_flags_from_tbl(struct iwl_scale_tbl_info *tbl, | |||
475 | 480 | ||
476 | } else if (is_Ht(tbl->lq_type)) { | 481 | } else if (is_Ht(tbl->lq_type)) { |
477 | if (index > IWL_LAST_OFDM_RATE) { | 482 | if (index > IWL_LAST_OFDM_RATE) { |
478 | IWL_ERROR("invalid HT rate index %d\n", index); | 483 | IWL_ERR(priv, "Invalid HT rate index %d\n", index); |
479 | index = IWL_LAST_OFDM_RATE; | 484 | index = IWL_LAST_OFDM_RATE; |
480 | } | 485 | } |
481 | rate_n_flags = RATE_MCS_HT_MSK; | 486 | rate_n_flags = RATE_MCS_HT_MSK; |
@@ -487,7 +492,7 @@ static u32 rate_n_flags_from_tbl(struct iwl_scale_tbl_info *tbl, | |||
487 | else | 492 | else |
488 | rate_n_flags |= iwl_rates[index].plcp_mimo3; | 493 | rate_n_flags |= iwl_rates[index].plcp_mimo3; |
489 | } else { | 494 | } else { |
490 | IWL_ERROR("Invalid tbl->lq_type %d\n", tbl->lq_type); | 495 | IWL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); |
491 | } | 496 | } |
492 | 497 | ||
493 | rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & | 498 | rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & |
@@ -507,7 +512,7 @@ static u32 rate_n_flags_from_tbl(struct iwl_scale_tbl_info *tbl, | |||
507 | rate_n_flags |= RATE_MCS_GF_MSK; | 512 | rate_n_flags |= RATE_MCS_GF_MSK; |
508 | if (is_siso(tbl->lq_type) && tbl->is_SGI) { | 513 | if (is_siso(tbl->lq_type) && tbl->is_SGI) { |
509 | rate_n_flags &= ~RATE_MCS_SGI_MSK; | 514 | rate_n_flags &= ~RATE_MCS_SGI_MSK; |
510 | IWL_ERROR("GF was set with SGI:SISO\n"); | 515 | IWL_ERR(priv, "GF was set with SGI:SISO\n"); |
511 | } | 516 | } |
512 | } | 517 | } |
513 | } | 518 | } |
@@ -688,7 +693,7 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, | |||
688 | break; | 693 | break; |
689 | if (rate_mask & (1 << low)) | 694 | if (rate_mask & (1 << low)) |
690 | break; | 695 | break; |
691 | IWL_DEBUG_RATE("Skipping masked lower rate: %d\n", low); | 696 | IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); |
692 | } | 697 | } |
693 | 698 | ||
694 | high = index; | 699 | high = index; |
@@ -698,7 +703,7 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, | |||
698 | break; | 703 | break; |
699 | if (rate_mask & (1 << high)) | 704 | if (rate_mask & (1 << high)) |
700 | break; | 705 | break; |
701 | IWL_DEBUG_RATE("Skipping masked higher rate: %d\n", high); | 706 | IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); |
702 | } | 707 | } |
703 | 708 | ||
704 | return (high << 8) | low; | 709 | return (high << 8) | low; |
@@ -758,7 +763,7 @@ static u32 rs_get_lower_rate(struct iwl_lq_sta *lq_sta, | |||
758 | low = scale_index; | 763 | low = scale_index; |
759 | 764 | ||
760 | out: | 765 | out: |
761 | return rate_n_flags_from_tbl(tbl, low, is_green); | 766 | return rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); |
762 | } | 767 | } |
763 | 768 | ||
764 | /* | 769 | /* |
@@ -785,7 +790,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, | |||
785 | u8 active_index = 0; | 790 | u8 active_index = 0; |
786 | s32 tpt = 0; | 791 | s32 tpt = 0; |
787 | 792 | ||
788 | IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n"); | 793 | IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); |
789 | 794 | ||
790 | if (!ieee80211_is_data(hdr->frame_control) || | 795 | if (!ieee80211_is_data(hdr->frame_control) || |
791 | is_multicast_ether_addr(hdr->addr1)) | 796 | is_multicast_ether_addr(hdr->addr1)) |
@@ -835,14 +840,19 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, | |||
835 | (!!(tx_rate & RATE_MCS_GF_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)) || | 840 | (!!(tx_rate & RATE_MCS_GF_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)) || |
836 | (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != | 841 | (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != |
837 | hw->wiphy->bands[info->band]->bitrates[info->status.rates[0].idx].bitrate)) { | 842 | hw->wiphy->bands[info->band]->bitrates[info->status.rates[0].idx].bitrate)) { |
838 | IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate); | 843 | IWL_DEBUG_RATE(priv, "initial rate does not match 0x%x\n", tx_rate); |
839 | /* the last LQ command could failed so the LQ in ucode not | 844 | /* the last LQ command could failed so the LQ in ucode not |
840 | * the same in driver sync up | 845 | * the same in driver sync up |
841 | */ | 846 | */ |
842 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 847 | lq_sta->missed_rate_counter++; |
848 | if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { | ||
849 | lq_sta->missed_rate_counter = 0; | ||
850 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | ||
851 | } | ||
843 | goto out; | 852 | goto out; |
844 | } | 853 | } |
845 | 854 | ||
855 | lq_sta->missed_rate_counter = 0; | ||
846 | /* Update frame history window with "failure" for each Tx retry. */ | 856 | /* Update frame history window with "failure" for each Tx retry. */ |
847 | while (retries) { | 857 | while (retries) { |
848 | /* Look up the rate and other info used for each tx attempt. | 858 | /* Look up the rate and other info used for each tx attempt. |
@@ -961,7 +971,7 @@ out: | |||
961 | static void rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, | 971 | static void rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, |
962 | struct iwl_lq_sta *lq_sta) | 972 | struct iwl_lq_sta *lq_sta) |
963 | { | 973 | { |
964 | IWL_DEBUG_RATE("we are staying in the same table\n"); | 974 | IWL_DEBUG_RATE(priv, "we are staying in the same table\n"); |
965 | lq_sta->stay_in_tbl = 1; /* only place this gets set */ | 975 | lq_sta->stay_in_tbl = 1; /* only place this gets set */ |
966 | if (is_legacy) { | 976 | if (is_legacy) { |
967 | lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; | 977 | lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; |
@@ -1129,7 +1139,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv, | |||
1129 | s32 rate; | 1139 | s32 rate; |
1130 | s8 is_green = lq_sta->is_green; | 1140 | s8 is_green = lq_sta->is_green; |
1131 | 1141 | ||
1132 | if (!conf->ht.enabled || !sta->ht_cap.ht_supported) | 1142 | if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) |
1133 | return -1; | 1143 | return -1; |
1134 | 1144 | ||
1135 | if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) | 1145 | if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) |
@@ -1140,7 +1150,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv, | |||
1140 | if (priv->hw_params.tx_chains_num < 2) | 1150 | if (priv->hw_params.tx_chains_num < 2) |
1141 | return -1; | 1151 | return -1; |
1142 | 1152 | ||
1143 | IWL_DEBUG_RATE("LQ: try to switch to MIMO2\n"); | 1153 | IWL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); |
1144 | 1154 | ||
1145 | tbl->lq_type = LQ_MIMO2; | 1155 | tbl->lq_type = LQ_MIMO2; |
1146 | tbl->is_dup = lq_sta->is_dup; | 1156 | tbl->is_dup = lq_sta->is_dup; |
@@ -1169,16 +1179,16 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv, | |||
1169 | 1179 | ||
1170 | rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); | 1180 | rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); |
1171 | 1181 | ||
1172 | IWL_DEBUG_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); | 1182 | IWL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); |
1173 | 1183 | ||
1174 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { | 1184 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { |
1175 | IWL_DEBUG_RATE("Can't switch with index %d rate mask %x\n", | 1185 | IWL_DEBUG_RATE(priv, "Can't switch with index %d rate mask %x\n", |
1176 | rate, rate_mask); | 1186 | rate, rate_mask); |
1177 | return -1; | 1187 | return -1; |
1178 | } | 1188 | } |
1179 | tbl->current_rate = rate_n_flags_from_tbl(tbl, rate, is_green); | 1189 | tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); |
1180 | 1190 | ||
1181 | IWL_DEBUG_RATE("LQ: Switch to new mcs %X index is green %X\n", | 1191 | IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", |
1182 | tbl->current_rate, is_green); | 1192 | tbl->current_rate, is_green); |
1183 | return 0; | 1193 | return 0; |
1184 | } | 1194 | } |
@@ -1196,10 +1206,10 @@ static int rs_switch_to_siso(struct iwl_priv *priv, | |||
1196 | u8 is_green = lq_sta->is_green; | 1206 | u8 is_green = lq_sta->is_green; |
1197 | s32 rate; | 1207 | s32 rate; |
1198 | 1208 | ||
1199 | if (!conf->ht.enabled || !sta->ht_cap.ht_supported) | 1209 | if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) |
1200 | return -1; | 1210 | return -1; |
1201 | 1211 | ||
1202 | IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); | 1212 | IWL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); |
1203 | 1213 | ||
1204 | tbl->is_dup = lq_sta->is_dup; | 1214 | tbl->is_dup = lq_sta->is_dup; |
1205 | tbl->lq_type = LQ_SISO; | 1215 | tbl->lq_type = LQ_SISO; |
@@ -1230,14 +1240,14 @@ static int rs_switch_to_siso(struct iwl_priv *priv, | |||
1230 | rs_set_expected_tpt_table(lq_sta, tbl); | 1240 | rs_set_expected_tpt_table(lq_sta, tbl); |
1231 | rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); | 1241 | rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); |
1232 | 1242 | ||
1233 | IWL_DEBUG_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); | 1243 | IWL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); |
1234 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { | 1244 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { |
1235 | IWL_DEBUG_RATE("can not switch with index %d rate mask %x\n", | 1245 | IWL_DEBUG_RATE(priv, "can not switch with index %d rate mask %x\n", |
1236 | rate, rate_mask); | 1246 | rate, rate_mask); |
1237 | return -1; | 1247 | return -1; |
1238 | } | 1248 | } |
1239 | tbl->current_rate = rate_n_flags_from_tbl(tbl, rate, is_green); | 1249 | tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); |
1240 | IWL_DEBUG_RATE("LQ: Switch to new mcs %X index is green %X\n", | 1250 | IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", |
1241 | tbl->current_rate, is_green); | 1251 | tbl->current_rate, is_green); |
1242 | return 0; | 1252 | return 0; |
1243 | } | 1253 | } |
@@ -1266,7 +1276,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1266 | switch (tbl->action) { | 1276 | switch (tbl->action) { |
1267 | case IWL_LEGACY_SWITCH_ANTENNA1: | 1277 | case IWL_LEGACY_SWITCH_ANTENNA1: |
1268 | case IWL_LEGACY_SWITCH_ANTENNA2: | 1278 | case IWL_LEGACY_SWITCH_ANTENNA2: |
1269 | IWL_DEBUG_RATE("LQ: Legacy toggle Antenna\n"); | 1279 | IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); |
1270 | 1280 | ||
1271 | lq_sta->action_counter++; | 1281 | lq_sta->action_counter++; |
1272 | 1282 | ||
@@ -1290,7 +1300,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1290 | } | 1300 | } |
1291 | break; | 1301 | break; |
1292 | case IWL_LEGACY_SWITCH_SISO: | 1302 | case IWL_LEGACY_SWITCH_SISO: |
1293 | IWL_DEBUG_RATE("LQ: Legacy switch to SISO\n"); | 1303 | IWL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); |
1294 | 1304 | ||
1295 | /* Set up search table to try SISO */ | 1305 | /* Set up search table to try SISO */ |
1296 | memcpy(search_tbl, tbl, sz); | 1306 | memcpy(search_tbl, tbl, sz); |
@@ -1306,7 +1316,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1306 | case IWL_LEGACY_SWITCH_MIMO2_AB: | 1316 | case IWL_LEGACY_SWITCH_MIMO2_AB: |
1307 | case IWL_LEGACY_SWITCH_MIMO2_AC: | 1317 | case IWL_LEGACY_SWITCH_MIMO2_AC: |
1308 | case IWL_LEGACY_SWITCH_MIMO2_BC: | 1318 | case IWL_LEGACY_SWITCH_MIMO2_BC: |
1309 | IWL_DEBUG_RATE("LQ: Legacy switch to MIMO2\n"); | 1319 | IWL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); |
1310 | 1320 | ||
1311 | /* Set up search table to try MIMO */ | 1321 | /* Set up search table to try MIMO */ |
1312 | memcpy(search_tbl, tbl, sz); | 1322 | memcpy(search_tbl, tbl, sz); |
@@ -1375,7 +1385,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1375 | switch (tbl->action) { | 1385 | switch (tbl->action) { |
1376 | case IWL_SISO_SWITCH_ANTENNA1: | 1386 | case IWL_SISO_SWITCH_ANTENNA1: |
1377 | case IWL_SISO_SWITCH_ANTENNA2: | 1387 | case IWL_SISO_SWITCH_ANTENNA2: |
1378 | IWL_DEBUG_RATE("LQ: SISO toggle Antenna\n"); | 1388 | IWL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); |
1379 | 1389 | ||
1380 | if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && | 1390 | if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && |
1381 | tx_chains_num <= 1) || | 1391 | tx_chains_num <= 1) || |
@@ -1394,7 +1404,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1394 | case IWL_SISO_SWITCH_MIMO2_AB: | 1404 | case IWL_SISO_SWITCH_MIMO2_AB: |
1395 | case IWL_SISO_SWITCH_MIMO2_AC: | 1405 | case IWL_SISO_SWITCH_MIMO2_AC: |
1396 | case IWL_SISO_SWITCH_MIMO2_BC: | 1406 | case IWL_SISO_SWITCH_MIMO2_BC: |
1397 | IWL_DEBUG_RATE("LQ: SISO switch to MIMO2\n"); | 1407 | IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); |
1398 | memcpy(search_tbl, tbl, sz); | 1408 | memcpy(search_tbl, tbl, sz); |
1399 | search_tbl->is_SGI = 0; | 1409 | search_tbl->is_SGI = 0; |
1400 | 1410 | ||
@@ -1423,14 +1433,15 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1423 | HT_SHORT_GI_40MHZ)) | 1433 | HT_SHORT_GI_40MHZ)) |
1424 | break; | 1434 | break; |
1425 | 1435 | ||
1426 | IWL_DEBUG_RATE("LQ: SISO toggle SGI/NGI\n"); | 1436 | IWL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); |
1427 | 1437 | ||
1428 | memcpy(search_tbl, tbl, sz); | 1438 | memcpy(search_tbl, tbl, sz); |
1429 | if (is_green) { | 1439 | if (is_green) { |
1430 | if (!tbl->is_SGI) | 1440 | if (!tbl->is_SGI) |
1431 | break; | 1441 | break; |
1432 | else | 1442 | else |
1433 | IWL_ERROR("SGI was set in GF+SISO\n"); | 1443 | IWL_ERR(priv, |
1444 | "SGI was set in GF+SISO\n"); | ||
1434 | } | 1445 | } |
1435 | search_tbl->is_SGI = !tbl->is_SGI; | 1446 | search_tbl->is_SGI = !tbl->is_SGI; |
1436 | rs_set_expected_tpt_table(lq_sta, search_tbl); | 1447 | rs_set_expected_tpt_table(lq_sta, search_tbl); |
@@ -1439,8 +1450,9 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1439 | if (tpt >= search_tbl->expected_tpt[index]) | 1450 | if (tpt >= search_tbl->expected_tpt[index]) |
1440 | break; | 1451 | break; |
1441 | } | 1452 | } |
1442 | search_tbl->current_rate = rate_n_flags_from_tbl( | 1453 | search_tbl->current_rate = |
1443 | search_tbl, index, is_green); | 1454 | rate_n_flags_from_tbl(priv, search_tbl, |
1455 | index, is_green); | ||
1444 | goto out; | 1456 | goto out; |
1445 | } | 1457 | } |
1446 | tbl->action++; | 1458 | tbl->action++; |
@@ -1486,7 +1498,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1486 | switch (tbl->action) { | 1498 | switch (tbl->action) { |
1487 | case IWL_MIMO2_SWITCH_ANTENNA1: | 1499 | case IWL_MIMO2_SWITCH_ANTENNA1: |
1488 | case IWL_MIMO2_SWITCH_ANTENNA2: | 1500 | case IWL_MIMO2_SWITCH_ANTENNA2: |
1489 | IWL_DEBUG_RATE("LQ: MIMO toggle Antennas\n"); | 1501 | IWL_DEBUG_RATE(priv, "LQ: MIMO toggle Antennas\n"); |
1490 | 1502 | ||
1491 | if (tx_chains_num <= 2) | 1503 | if (tx_chains_num <= 2) |
1492 | break; | 1504 | break; |
@@ -1502,7 +1514,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1502 | case IWL_MIMO2_SWITCH_SISO_A: | 1514 | case IWL_MIMO2_SWITCH_SISO_A: |
1503 | case IWL_MIMO2_SWITCH_SISO_B: | 1515 | case IWL_MIMO2_SWITCH_SISO_B: |
1504 | case IWL_MIMO2_SWITCH_SISO_C: | 1516 | case IWL_MIMO2_SWITCH_SISO_C: |
1505 | IWL_DEBUG_RATE("LQ: MIMO2 switch to SISO\n"); | 1517 | IWL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); |
1506 | 1518 | ||
1507 | /* Set up new search table for SISO */ | 1519 | /* Set up new search table for SISO */ |
1508 | memcpy(search_tbl, tbl, sz); | 1520 | memcpy(search_tbl, tbl, sz); |
@@ -1534,7 +1546,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1534 | HT_SHORT_GI_40MHZ)) | 1546 | HT_SHORT_GI_40MHZ)) |
1535 | break; | 1547 | break; |
1536 | 1548 | ||
1537 | IWL_DEBUG_RATE("LQ: MIMO toggle SGI/NGI\n"); | 1549 | IWL_DEBUG_RATE(priv, "LQ: MIMO toggle SGI/NGI\n"); |
1538 | 1550 | ||
1539 | /* Set up new search table for MIMO */ | 1551 | /* Set up new search table for MIMO */ |
1540 | memcpy(search_tbl, tbl, sz); | 1552 | memcpy(search_tbl, tbl, sz); |
@@ -1551,8 +1563,9 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1551 | if (tpt >= search_tbl->expected_tpt[index]) | 1563 | if (tpt >= search_tbl->expected_tpt[index]) |
1552 | break; | 1564 | break; |
1553 | } | 1565 | } |
1554 | search_tbl->current_rate = rate_n_flags_from_tbl( | 1566 | search_tbl->current_rate = |
1555 | search_tbl, index, is_green); | 1567 | rate_n_flags_from_tbl(priv, search_tbl, |
1568 | index, is_green); | ||
1556 | goto out; | 1569 | goto out; |
1557 | 1570 | ||
1558 | } | 1571 | } |
@@ -1616,7 +1629,7 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta) | |||
1616 | (lq_sta->total_success > lq_sta->max_success_limit) || | 1629 | (lq_sta->total_success > lq_sta->max_success_limit) || |
1617 | ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) | 1630 | ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) |
1618 | && (flush_interval_passed))) { | 1631 | && (flush_interval_passed))) { |
1619 | IWL_DEBUG_RATE("LQ: stay is expired %d %d %d\n:", | 1632 | IWL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", |
1620 | lq_sta->total_failed, | 1633 | lq_sta->total_failed, |
1621 | lq_sta->total_success, | 1634 | lq_sta->total_success, |
1622 | flush_interval_passed); | 1635 | flush_interval_passed); |
@@ -1639,7 +1652,7 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta) | |||
1639 | lq_sta->table_count_limit) { | 1652 | lq_sta->table_count_limit) { |
1640 | lq_sta->table_count = 0; | 1653 | lq_sta->table_count = 0; |
1641 | 1654 | ||
1642 | IWL_DEBUG_RATE("LQ: stay in table clear win\n"); | 1655 | IWL_DEBUG_RATE(priv, "LQ: stay in table clear win\n"); |
1643 | for (i = 0; i < IWL_RATE_COUNT; i++) | 1656 | for (i = 0; i < IWL_RATE_COUNT; i++) |
1644 | rs_rate_scale_clear_window( | 1657 | rs_rate_scale_clear_window( |
1645 | &(tbl->win[i])); | 1658 | &(tbl->win[i])); |
@@ -1688,7 +1701,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1688 | s32 sr; | 1701 | s32 sr; |
1689 | u8 tid = MAX_TID_COUNT; | 1702 | u8 tid = MAX_TID_COUNT; |
1690 | 1703 | ||
1691 | IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); | 1704 | IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); |
1692 | 1705 | ||
1693 | /* Send management frames and broadcast/multicast data using | 1706 | /* Send management frames and broadcast/multicast data using |
1694 | * lowest rate. */ | 1707 | * lowest rate. */ |
@@ -1720,13 +1733,13 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1720 | /* current tx rate */ | 1733 | /* current tx rate */ |
1721 | index = lq_sta->last_txrate_idx; | 1734 | index = lq_sta->last_txrate_idx; |
1722 | 1735 | ||
1723 | IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, | 1736 | IWL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, |
1724 | tbl->lq_type); | 1737 | tbl->lq_type); |
1725 | 1738 | ||
1726 | /* rates available for this association, and for modulation mode */ | 1739 | /* rates available for this association, and for modulation mode */ |
1727 | rate_mask = rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); | 1740 | rate_mask = rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); |
1728 | 1741 | ||
1729 | IWL_DEBUG_RATE("mask 0x%04X \n", rate_mask); | 1742 | IWL_DEBUG_RATE(priv, "mask 0x%04X \n", rate_mask); |
1730 | 1743 | ||
1731 | /* mask with station rate restriction */ | 1744 | /* mask with station rate restriction */ |
1732 | if (is_legacy(tbl->lq_type)) { | 1745 | if (is_legacy(tbl->lq_type)) { |
@@ -1745,16 +1758,25 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1745 | rate_scale_index_msk = rate_mask; | 1758 | rate_scale_index_msk = rate_mask; |
1746 | 1759 | ||
1747 | if (!((1 << index) & rate_scale_index_msk)) { | 1760 | if (!((1 << index) & rate_scale_index_msk)) { |
1748 | IWL_ERROR("Current Rate is not valid\n"); | 1761 | IWL_ERR(priv, "Current Rate is not valid\n"); |
1749 | return; | 1762 | return; |
1750 | } | 1763 | } |
1751 | 1764 | ||
1752 | /* Get expected throughput table and history window for current rate */ | 1765 | /* Get expected throughput table and history window for current rate */ |
1753 | if (!tbl->expected_tpt) { | 1766 | if (!tbl->expected_tpt) { |
1754 | IWL_ERROR("tbl->expected_tpt is NULL\n"); | 1767 | IWL_ERR(priv, "tbl->expected_tpt is NULL\n"); |
1755 | return; | 1768 | return; |
1756 | } | 1769 | } |
1757 | 1770 | ||
1771 | /* force user max rate if set by user */ | ||
1772 | if ((lq_sta->max_rate_idx != -1) && | ||
1773 | (lq_sta->max_rate_idx < index)) { | ||
1774 | index = lq_sta->max_rate_idx; | ||
1775 | update_lq = 1; | ||
1776 | window = &(tbl->win[index]); | ||
1777 | goto lq_update; | ||
1778 | } | ||
1779 | |||
1758 | window = &(tbl->win[index]); | 1780 | window = &(tbl->win[index]); |
1759 | 1781 | ||
1760 | /* | 1782 | /* |
@@ -1767,7 +1789,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1767 | fail_count = window->counter - window->success_counter; | 1789 | fail_count = window->counter - window->success_counter; |
1768 | if ((fail_count < IWL_RATE_MIN_FAILURE_TH) && | 1790 | if ((fail_count < IWL_RATE_MIN_FAILURE_TH) && |
1769 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) { | 1791 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) { |
1770 | IWL_DEBUG_RATE("LQ: still below TH. succ=%d total=%d " | 1792 | IWL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " |
1771 | "for index %d\n", | 1793 | "for index %d\n", |
1772 | window->success_counter, window->counter, index); | 1794 | window->success_counter, window->counter, index); |
1773 | 1795 | ||
@@ -1795,7 +1817,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1795 | * continuing to use the setup that we've been trying. */ | 1817 | * continuing to use the setup that we've been trying. */ |
1796 | if (window->average_tpt > lq_sta->last_tpt) { | 1818 | if (window->average_tpt > lq_sta->last_tpt) { |
1797 | 1819 | ||
1798 | IWL_DEBUG_RATE("LQ: SWITCHING TO NEW TABLE " | 1820 | IWL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " |
1799 | "suc=%d cur-tpt=%d old-tpt=%d\n", | 1821 | "suc=%d cur-tpt=%d old-tpt=%d\n", |
1800 | window->success_ratio, | 1822 | window->success_ratio, |
1801 | window->average_tpt, | 1823 | window->average_tpt, |
@@ -1811,7 +1833,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1811 | /* Else poor success; go back to mode in "active" table */ | 1833 | /* Else poor success; go back to mode in "active" table */ |
1812 | } else { | 1834 | } else { |
1813 | 1835 | ||
1814 | IWL_DEBUG_RATE("LQ: GOING BACK TO THE OLD TABLE " | 1836 | IWL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " |
1815 | "suc=%d cur-tpt=%d old-tpt=%d\n", | 1837 | "suc=%d cur-tpt=%d old-tpt=%d\n", |
1816 | window->success_ratio, | 1838 | window->success_ratio, |
1817 | window->average_tpt, | 1839 | window->average_tpt, |
@@ -1846,6 +1868,11 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1846 | low = high_low & 0xff; | 1868 | low = high_low & 0xff; |
1847 | high = (high_low >> 8) & 0xff; | 1869 | high = (high_low >> 8) & 0xff; |
1848 | 1870 | ||
1871 | /* If user set max rate, dont allow higher than user constrain */ | ||
1872 | if ((lq_sta->max_rate_idx != -1) && | ||
1873 | (lq_sta->max_rate_idx < high)) | ||
1874 | high = IWL_RATE_INVALID; | ||
1875 | |||
1849 | sr = window->success_ratio; | 1876 | sr = window->success_ratio; |
1850 | 1877 | ||
1851 | /* Collect measured throughputs for current and adjacent rates */ | 1878 | /* Collect measured throughputs for current and adjacent rates */ |
@@ -1859,7 +1886,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1859 | 1886 | ||
1860 | /* Too many failures, decrease rate */ | 1887 | /* Too many failures, decrease rate */ |
1861 | if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) { | 1888 | if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) { |
1862 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); | 1889 | IWL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); |
1863 | scale_action = -1; | 1890 | scale_action = -1; |
1864 | 1891 | ||
1865 | /* No throughput measured yet for adjacent rates; try increase. */ | 1892 | /* No throughput measured yet for adjacent rates; try increase. */ |
@@ -1890,8 +1917,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1890 | sr >= IWL_RATE_INCREASE_TH) { | 1917 | sr >= IWL_RATE_INCREASE_TH) { |
1891 | scale_action = 1; | 1918 | scale_action = 1; |
1892 | } else { | 1919 | } else { |
1893 | IWL_DEBUG_RATE | 1920 | IWL_DEBUG_RATE(priv, |
1894 | ("decrease rate because of high tpt\n"); | 1921 | "decrease rate because of high tpt\n"); |
1895 | scale_action = -1; | 1922 | scale_action = -1; |
1896 | } | 1923 | } |
1897 | 1924 | ||
@@ -1899,8 +1926,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1899 | } else if (low_tpt != IWL_INVALID_VALUE) { | 1926 | } else if (low_tpt != IWL_INVALID_VALUE) { |
1900 | /* Lower rate has better throughput */ | 1927 | /* Lower rate has better throughput */ |
1901 | if (low_tpt > current_tpt) { | 1928 | if (low_tpt > current_tpt) { |
1902 | IWL_DEBUG_RATE | 1929 | IWL_DEBUG_RATE(priv, |
1903 | ("decrease rate because of low tpt\n"); | 1930 | "decrease rate because of low tpt\n"); |
1904 | scale_action = -1; | 1931 | scale_action = -1; |
1905 | } else if (sr >= IWL_RATE_INCREASE_TH) { | 1932 | } else if (sr >= IWL_RATE_INCREASE_TH) { |
1906 | scale_action = 1; | 1933 | scale_action = 1; |
@@ -1937,14 +1964,14 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1937 | break; | 1964 | break; |
1938 | } | 1965 | } |
1939 | 1966 | ||
1940 | IWL_DEBUG_RATE("choose rate scale index %d action %d low %d " | 1967 | IWL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " |
1941 | "high %d type %d\n", | 1968 | "high %d type %d\n", |
1942 | index, scale_action, low, high, tbl->lq_type); | 1969 | index, scale_action, low, high, tbl->lq_type); |
1943 | 1970 | ||
1944 | lq_update: | 1971 | lq_update: |
1945 | /* Replace uCode's rate table for the destination station. */ | 1972 | /* Replace uCode's rate table for the destination station. */ |
1946 | if (update_lq) { | 1973 | if (update_lq) { |
1947 | rate = rate_n_flags_from_tbl(tbl, index, is_green); | 1974 | rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); |
1948 | rs_fill_link_cmd(priv, lq_sta, rate); | 1975 | rs_fill_link_cmd(priv, lq_sta, rate); |
1949 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 1976 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); |
1950 | } | 1977 | } |
@@ -1981,7 +2008,7 @@ lq_update: | |||
1981 | /* Use new "search" start rate */ | 2008 | /* Use new "search" start rate */ |
1982 | index = iwl_hwrate_to_plcp_idx(tbl->current_rate); | 2009 | index = iwl_hwrate_to_plcp_idx(tbl->current_rate); |
1983 | 2010 | ||
1984 | IWL_DEBUG_RATE("Switch current mcs: %X index: %d\n", | 2011 | IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", |
1985 | tbl->current_rate, index); | 2012 | tbl->current_rate, index); |
1986 | rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); | 2013 | rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); |
1987 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 2014 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); |
@@ -1993,10 +2020,10 @@ lq_update: | |||
1993 | * stay with best antenna legacy modulation for a while | 2020 | * stay with best antenna legacy modulation for a while |
1994 | * before next round of mode comparisons. */ | 2021 | * before next round of mode comparisons. */ |
1995 | tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); | 2022 | tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); |
1996 | if (is_legacy(tbl1->lq_type) && !conf->ht.enabled && | 2023 | if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && |
1997 | lq_sta->action_counter >= 1) { | 2024 | lq_sta->action_counter >= 1) { |
1998 | lq_sta->action_counter = 0; | 2025 | lq_sta->action_counter = 0; |
1999 | IWL_DEBUG_RATE("LQ: STAY in legacy table\n"); | 2026 | IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); |
2000 | rs_set_stay_in_table(priv, 1, lq_sta); | 2027 | rs_set_stay_in_table(priv, 1, lq_sta); |
2001 | } | 2028 | } |
2002 | 2029 | ||
@@ -2008,7 +2035,7 @@ lq_update: | |||
2008 | if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && | 2035 | if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && |
2009 | (lq_sta->tx_agg_tid_en & (1 << tid)) && | 2036 | (lq_sta->tx_agg_tid_en & (1 << tid)) && |
2010 | (tid != MAX_TID_COUNT)) { | 2037 | (tid != MAX_TID_COUNT)) { |
2011 | IWL_DEBUG_RATE("try to aggregate tid %d\n", tid); | 2038 | IWL_DEBUG_RATE(priv, "try to aggregate tid %d\n", tid); |
2012 | rs_tl_turn_on_agg(priv, tid, lq_sta, sta); | 2039 | rs_tl_turn_on_agg(priv, tid, lq_sta, sta); |
2013 | } | 2040 | } |
2014 | lq_sta->action_counter = 0; | 2041 | lq_sta->action_counter = 0; |
@@ -2028,7 +2055,7 @@ lq_update: | |||
2028 | } | 2055 | } |
2029 | 2056 | ||
2030 | out: | 2057 | out: |
2031 | tbl->current_rate = rate_n_flags_from_tbl(tbl, index, is_green); | 2058 | tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); |
2032 | i = index; | 2059 | i = index; |
2033 | lq_sta->last_txrate_idx = i; | 2060 | lq_sta->last_txrate_idx = i; |
2034 | 2061 | ||
@@ -2081,7 +2108,7 @@ static void rs_initialize_lq(struct iwl_priv *priv, | |||
2081 | if (!rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) | 2108 | if (!rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) |
2082 | rs_toggle_antenna(valid_tx_ant, &rate, tbl); | 2109 | rs_toggle_antenna(valid_tx_ant, &rate, tbl); |
2083 | 2110 | ||
2084 | rate = rate_n_flags_from_tbl(tbl, rate_idx, use_green); | 2111 | rate = rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); |
2085 | tbl->current_rate = rate; | 2112 | tbl->current_rate = rate; |
2086 | rs_set_expected_tpt_table(lq_sta, tbl); | 2113 | rs_set_expected_tpt_table(lq_sta, tbl); |
2087 | rs_fill_link_cmd(NULL, lq_sta, rate); | 2114 | rs_fill_link_cmd(NULL, lq_sta, rate); |
@@ -2104,7 +2131,18 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, | |||
2104 | int rate_idx; | 2131 | int rate_idx; |
2105 | u64 mask_bit = 0; | 2132 | u64 mask_bit = 0; |
2106 | 2133 | ||
2107 | IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); | 2134 | IWL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); |
2135 | |||
2136 | /* Get max rate if user set max rate */ | ||
2137 | if (lq_sta) { | ||
2138 | lq_sta->max_rate_idx = txrc->max_rate_idx; | ||
2139 | if ((sband->band == IEEE80211_BAND_5GHZ) && | ||
2140 | (lq_sta->max_rate_idx != -1)) | ||
2141 | lq_sta->max_rate_idx += IWL_FIRST_OFDM_RATE; | ||
2142 | if ((lq_sta->max_rate_idx < 0) || | ||
2143 | (lq_sta->max_rate_idx >= IWL_RATE_COUNT)) | ||
2144 | lq_sta->max_rate_idx = -1; | ||
2145 | } | ||
2108 | 2146 | ||
2109 | if (sta) | 2147 | if (sta) |
2110 | mask_bit = sta->supp_rates[sband->band]; | 2148 | mask_bit = sta->supp_rates[sband->band]; |
@@ -2129,7 +2167,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, | |||
2129 | u8 sta_id = iwl_find_station(priv, hdr->addr1); | 2167 | u8 sta_id = iwl_find_station(priv, hdr->addr1); |
2130 | 2168 | ||
2131 | if (sta_id == IWL_INVALID_STATION) { | 2169 | if (sta_id == IWL_INVALID_STATION) { |
2132 | IWL_DEBUG_RATE("LQ: ADD station %pM\n", | 2170 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", |
2133 | hdr->addr1); | 2171 | hdr->addr1); |
2134 | sta_id = iwl_add_station_flags(priv, hdr->addr1, | 2172 | sta_id = iwl_add_station_flags(priv, hdr->addr1, |
2135 | 0, CMD_ASYNC, NULL); | 2173 | 0, CMD_ASYNC, NULL); |
@@ -2158,7 +2196,7 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, | |||
2158 | int i, j; | 2196 | int i, j; |
2159 | 2197 | ||
2160 | priv = (struct iwl_priv *)priv_rate; | 2198 | priv = (struct iwl_priv *)priv_rate; |
2161 | IWL_DEBUG_RATE("create station rate scale window\n"); | 2199 | IWL_DEBUG_RATE(priv, "create station rate scale window\n"); |
2162 | 2200 | ||
2163 | lq_sta = kzalloc(sizeof(struct iwl_lq_sta), gfp); | 2201 | lq_sta = kzalloc(sizeof(struct iwl_lq_sta), gfp); |
2164 | 2202 | ||
@@ -2182,6 +2220,8 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2182 | struct ieee80211_conf *conf = &priv->hw->conf; | 2220 | struct ieee80211_conf *conf = &priv->hw->conf; |
2183 | struct iwl_lq_sta *lq_sta = priv_sta; | 2221 | struct iwl_lq_sta *lq_sta = priv_sta; |
2184 | u16 mask_bit = 0; | 2222 | u16 mask_bit = 0; |
2223 | int count; | ||
2224 | int start_rate = 0; | ||
2185 | 2225 | ||
2186 | lq_sta->flush_timer = 0; | 2226 | lq_sta->flush_timer = 0; |
2187 | lq_sta->supp_rates = sta->supp_rates[sband->band]; | 2227 | lq_sta->supp_rates = sta->supp_rates[sband->band]; |
@@ -2189,7 +2229,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2189 | for (i = 0; i < IWL_RATE_COUNT; i++) | 2229 | for (i = 0; i < IWL_RATE_COUNT; i++) |
2190 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); | 2230 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); |
2191 | 2231 | ||
2192 | IWL_DEBUG_RATE("LQ: *** rate scale station global init ***\n"); | 2232 | IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init ***\n"); |
2193 | /* TODO: what is a good starting rate for STA? About middle? Maybe not | 2233 | /* TODO: what is a good starting rate for STA? About middle? Maybe not |
2194 | * the lowest or the highest rate.. Could consider using RSSI from | 2234 | * the lowest or the highest rate.. Could consider using RSSI from |
2195 | * previous packets? Need to have IEEE 802.1X auth succeed immediately | 2235 | * previous packets? Need to have IEEE 802.1X auth succeed immediately |
@@ -2200,10 +2240,10 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2200 | u8 sta_id = iwl_find_station(priv, sta->addr); | 2240 | u8 sta_id = iwl_find_station(priv, sta->addr); |
2201 | 2241 | ||
2202 | /* for IBSS the call are from tasklet */ | 2242 | /* for IBSS the call are from tasklet */ |
2203 | IWL_DEBUG_RATE("LQ: ADD station %pM\n", sta->addr); | 2243 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr); |
2204 | 2244 | ||
2205 | if (sta_id == IWL_INVALID_STATION) { | 2245 | if (sta_id == IWL_INVALID_STATION) { |
2206 | IWL_DEBUG_RATE("LQ: ADD station %pM\n", sta->addr); | 2246 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr); |
2207 | sta_id = iwl_add_station_flags(priv, sta->addr, | 2247 | sta_id = iwl_add_station_flags(priv, sta->addr, |
2208 | 0, CMD_ASYNC, NULL); | 2248 | 0, CMD_ASYNC, NULL); |
2209 | } | 2249 | } |
@@ -2216,6 +2256,8 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2216 | } | 2256 | } |
2217 | 2257 | ||
2218 | lq_sta->is_dup = 0; | 2258 | lq_sta->is_dup = 0; |
2259 | lq_sta->max_rate_idx = -1; | ||
2260 | lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; | ||
2219 | lq_sta->is_green = rs_use_green(priv, conf); | 2261 | lq_sta->is_green = rs_use_green(priv, conf); |
2220 | lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); | 2262 | lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); |
2221 | lq_sta->active_rate_basic = priv->active_rate_basic; | 2263 | lq_sta->active_rate_basic = priv->active_rate_basic; |
@@ -2240,7 +2282,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2240 | lq_sta->active_mimo3_rate &= ~((u16)0x2); | 2282 | lq_sta->active_mimo3_rate &= ~((u16)0x2); |
2241 | lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; | 2283 | lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; |
2242 | 2284 | ||
2243 | IWL_DEBUG_RATE("SISO-RATE=%X MIMO2-RATE=%X MIMO3-RATE=%X\n", | 2285 | IWL_DEBUG_RATE(priv, "SISO-RATE=%X MIMO2-RATE=%X MIMO3-RATE=%X\n", |
2244 | lq_sta->active_siso_rate, | 2286 | lq_sta->active_siso_rate, |
2245 | lq_sta->active_mimo2_rate, | 2287 | lq_sta->active_mimo2_rate, |
2246 | lq_sta->active_mimo3_rate); | 2288 | lq_sta->active_mimo3_rate); |
@@ -2254,16 +2296,20 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2254 | lq_sta->drv = priv; | 2296 | lq_sta->drv = priv; |
2255 | 2297 | ||
2256 | /* Find highest tx rate supported by hardware and destination station */ | 2298 | /* Find highest tx rate supported by hardware and destination station */ |
2257 | mask_bit = sta->supp_rates[sband->band] & lq_sta->active_legacy_rate; | 2299 | mask_bit = sta->supp_rates[sband->band]; |
2258 | lq_sta->last_txrate_idx = 3; | 2300 | count = sband->n_bitrates; |
2259 | for (i = 0; i < sband->n_bitrates; i++) | 2301 | if (sband->band == IEEE80211_BAND_5GHZ) { |
2302 | count += IWL_FIRST_OFDM_RATE; | ||
2303 | start_rate = IWL_FIRST_OFDM_RATE; | ||
2304 | mask_bit <<= IWL_FIRST_OFDM_RATE; | ||
2305 | } | ||
2306 | |||
2307 | mask_bit = mask_bit & lq_sta->active_legacy_rate; | ||
2308 | lq_sta->last_txrate_idx = 4; | ||
2309 | for (i = start_rate; i < count; i++) | ||
2260 | if (mask_bit & BIT(i)) | 2310 | if (mask_bit & BIT(i)) |
2261 | lq_sta->last_txrate_idx = i; | 2311 | lq_sta->last_txrate_idx = i; |
2262 | 2312 | ||
2263 | /* For MODE_IEEE80211A, skip over cck rates in global rate table */ | ||
2264 | if (sband->band == IEEE80211_BAND_5GHZ) | ||
2265 | lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; | ||
2266 | |||
2267 | rs_initialize_lq(priv, conf, sta, lq_sta); | 2313 | rs_initialize_lq(priv, conf, sta, lq_sta); |
2268 | } | 2314 | } |
2269 | 2315 | ||
@@ -2402,9 +2448,9 @@ static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta, | |||
2402 | struct iwl_lq_sta *lq_sta = priv_sta; | 2448 | struct iwl_lq_sta *lq_sta = priv_sta; |
2403 | struct iwl_priv *priv __maybe_unused = priv_r; | 2449 | struct iwl_priv *priv __maybe_unused = priv_r; |
2404 | 2450 | ||
2405 | IWL_DEBUG_RATE("enter\n"); | 2451 | IWL_DEBUG_RATE(priv, "enter\n"); |
2406 | kfree(lq_sta); | 2452 | kfree(lq_sta); |
2407 | IWL_DEBUG_RATE("leave\n"); | 2453 | IWL_DEBUG_RATE(priv, "leave\n"); |
2408 | } | 2454 | } |
2409 | 2455 | ||
2410 | 2456 | ||
@@ -2429,9 +2475,9 @@ static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, | |||
2429 | else | 2475 | else |
2430 | *rate_n_flags = 0x820A; | 2476 | *rate_n_flags = 0x820A; |
2431 | } | 2477 | } |
2432 | IWL_DEBUG_RATE("Fixed rate ON\n"); | 2478 | IWL_DEBUG_RATE(priv, "Fixed rate ON\n"); |
2433 | } else { | 2479 | } else { |
2434 | IWL_DEBUG_RATE("Fixed rate OFF\n"); | 2480 | IWL_DEBUG_RATE(priv, "Fixed rate OFF\n"); |
2435 | } | 2481 | } |
2436 | } | 2482 | } |
2437 | 2483 | ||
@@ -2460,7 +2506,7 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file, | |||
2460 | lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | 2506 | lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
2461 | lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | 2507 | lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
2462 | 2508 | ||
2463 | IWL_DEBUG_RATE("sta_id %d rate 0x%X\n", | 2509 | IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", |
2464 | lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); | 2510 | lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); |
2465 | 2511 | ||
2466 | if (lq_sta->dbg_fixed_rate) { | 2512 | if (lq_sta->dbg_fixed_rate) { |