diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-4965-rs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965-rs.c | 101 |
1 files changed, 37 insertions, 64 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c index 2227ee4ad1af..b557faa6ff08 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c | |||
@@ -202,8 +202,6 @@ static int rs_send_lq_cmd(struct iwl_priv *priv, | |||
202 | #ifdef CONFIG_IWLWIFI_DEBUG | 202 | #ifdef CONFIG_IWLWIFI_DEBUG |
203 | int i; | 203 | int i; |
204 | #endif | 204 | #endif |
205 | int rc = -1; | ||
206 | |||
207 | struct iwl_host_cmd cmd = { | 205 | struct iwl_host_cmd cmd = { |
208 | .id = REPLY_TX_LINK_QUALITY_CMD, | 206 | .id = REPLY_TX_LINK_QUALITY_CMD, |
209 | .len = sizeof(struct iwl_link_quality_cmd), | 207 | .len = sizeof(struct iwl_link_quality_cmd), |
@@ -213,7 +211,7 @@ static int rs_send_lq_cmd(struct iwl_priv *priv, | |||
213 | 211 | ||
214 | if ((lq->sta_id == 0xFF) && | 212 | if ((lq->sta_id == 0xFF) && |
215 | (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) | 213 | (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) |
216 | return rc; | 214 | return -EINVAL; |
217 | 215 | ||
218 | if (lq->sta_id == 0xFF) | 216 | if (lq->sta_id == 0xFF) |
219 | lq->sta_id = IWL_AP_ID; | 217 | lq->sta_id = IWL_AP_ID; |
@@ -233,12 +231,12 @@ static int rs_send_lq_cmd(struct iwl_priv *priv, | |||
233 | 231 | ||
234 | if (iwl_is_associated(priv) && priv->assoc_station_added && | 232 | if (iwl_is_associated(priv) && priv->assoc_station_added && |
235 | priv->lq_mngr.lq_ready) | 233 | priv->lq_mngr.lq_ready) |
236 | rc = iwl_send_cmd(priv, &cmd); | 234 | return iwl_send_cmd(priv, &cmd); |
237 | 235 | ||
238 | return rc; | 236 | return 0; |
239 | } | 237 | } |
240 | 238 | ||
241 | static int rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) | 239 | static void rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) |
242 | { | 240 | { |
243 | window->data = 0; | 241 | window->data = 0; |
244 | window->success_counter = 0; | 242 | window->success_counter = 0; |
@@ -246,24 +244,18 @@ static int rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) | |||
246 | window->counter = 0; | 244 | window->counter = 0; |
247 | window->average_tpt = IWL_INVALID_VALUE; | 245 | window->average_tpt = IWL_INVALID_VALUE; |
248 | window->stamp = 0; | 246 | window->stamp = 0; |
249 | |||
250 | return 0; | ||
251 | } | 247 | } |
252 | 248 | ||
253 | static int rs_collect_tx_data(struct iwl_rate_scale_data *windows, | 249 | static int rs_collect_tx_data(struct iwl_rate_scale_data *windows, |
254 | int scale_index, s32 tpt, u32 status) | 250 | int scale_index, s32 tpt, u32 status) |
255 | { | 251 | { |
256 | int rc = 0; | ||
257 | struct iwl_rate_scale_data *window = NULL; | 252 | struct iwl_rate_scale_data *window = NULL; |
258 | u64 mask; | 253 | u64 mask; |
259 | u8 win_size = IWL_RATE_MAX_WINDOW; | 254 | u8 win_size = IWL_RATE_MAX_WINDOW; |
260 | s32 fail_count; | 255 | s32 fail_count; |
261 | 256 | ||
262 | if (scale_index < 0) | 257 | if (scale_index < 0 || scale_index >= IWL_RATE_COUNT) |
263 | return -1; | 258 | return -EINVAL; |
264 | |||
265 | if (scale_index >= IWL_RATE_COUNT) | ||
266 | return -1; | ||
267 | 259 | ||
268 | window = &(windows[scale_index]); | 260 | window = &(windows[scale_index]); |
269 | 261 | ||
@@ -302,15 +294,13 @@ static int rs_collect_tx_data(struct iwl_rate_scale_data *windows, | |||
302 | 294 | ||
303 | window->stamp = jiffies; | 295 | window->stamp = jiffies; |
304 | 296 | ||
305 | return rc; | 297 | return 0; |
306 | } | 298 | } |
307 | 299 | ||
308 | int static rs_mcs_from_tbl(struct iwl_rate *mcs_rate, | 300 | static void rs_mcs_from_tbl(struct iwl_rate *mcs_rate, |
309 | struct iwl_scale_tbl_info *tbl, | 301 | struct iwl_scale_tbl_info *tbl, |
310 | int index, u8 use_green) | 302 | int index, u8 use_green) |
311 | { | 303 | { |
312 | int rc = 0; | ||
313 | |||
314 | if (is_legacy(tbl->lq_type)) { | 304 | if (is_legacy(tbl->lq_type)) { |
315 | mcs_rate->rate_n_flags = iwl_rates[index].plcp; | 305 | mcs_rate->rate_n_flags = iwl_rates[index].plcp; |
316 | if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) | 306 | if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) |
@@ -343,7 +333,7 @@ int static rs_mcs_from_tbl(struct iwl_rate *mcs_rate, | |||
343 | } | 333 | } |
344 | 334 | ||
345 | if (is_legacy(tbl->lq_type)) | 335 | if (is_legacy(tbl->lq_type)) |
346 | return rc; | 336 | return; |
347 | 337 | ||
348 | if (tbl->is_fat) { | 338 | if (tbl->is_fat) { |
349 | if (tbl->is_dup) | 339 | if (tbl->is_dup) |
@@ -359,7 +349,6 @@ int static rs_mcs_from_tbl(struct iwl_rate *mcs_rate, | |||
359 | if (is_siso(tbl->lq_type)) | 349 | if (is_siso(tbl->lq_type)) |
360 | mcs_rate->rate_n_flags &= ~RATE_MCS_SGI_MSK; | 350 | mcs_rate->rate_n_flags &= ~RATE_MCS_SGI_MSK; |
361 | } | 351 | } |
362 | return rc; | ||
363 | } | 352 | } |
364 | 353 | ||
365 | static int rs_get_tbl_info_from_mcs(const struct iwl_rate *mcs_rate, | 354 | static int rs_get_tbl_info_from_mcs(const struct iwl_rate *mcs_rate, |
@@ -373,7 +362,7 @@ static int rs_get_tbl_info_from_mcs(const struct iwl_rate *mcs_rate, | |||
373 | 362 | ||
374 | if (index == IWL_RATE_INVALID) { | 363 | if (index == IWL_RATE_INVALID) { |
375 | *rate_idx = -1; | 364 | *rate_idx = -1; |
376 | return -1; | 365 | return -EINVAL; |
377 | } | 366 | } |
378 | tbl->is_SGI = 0; | 367 | tbl->is_SGI = 0; |
379 | tbl->is_fat = 0; | 368 | tbl->is_fat = 0; |
@@ -453,18 +442,16 @@ static inline void rs_toggle_antenna(struct iwl_rate *new_rate, | |||
453 | } | 442 | } |
454 | } | 443 | } |
455 | 444 | ||
456 | static inline s8 rs_use_green(struct iwl_priv *priv) | 445 | static inline u8 rs_use_green(struct iwl_priv *priv) |
457 | { | 446 | { |
458 | s8 rc = 0; | ||
459 | #ifdef CONFIG_IWLWIFI_HT | 447 | #ifdef CONFIG_IWLWIFI_HT |
460 | if (!priv->is_ht_enabled || !priv->current_assoc_ht.is_ht) | 448 | if (!priv->is_ht_enabled || !priv->current_assoc_ht.is_ht) |
461 | return 0; | 449 | return 0; |
462 | 450 | ||
463 | if ((priv->current_assoc_ht.is_green_field) && | 451 | return ((priv->current_assoc_ht.is_green_field) && |
464 | !(priv->current_assoc_ht.operating_mode & 0x4)) | 452 | !(priv->current_assoc_ht.operating_mode & 0x4)); |
465 | rc = 1; | ||
466 | #endif /*CONFIG_IWLWIFI_HT */ | 453 | #endif /*CONFIG_IWLWIFI_HT */ |
467 | return rc; | 454 | return 0; |
468 | } | 455 | } |
469 | 456 | ||
470 | /** | 457 | /** |
@@ -548,7 +535,7 @@ static u16 rs_get_adjacent_rate(u8 index, u16 rate_mask, int rate_type) | |||
548 | return (high << 8) | low; | 535 | return (high << 8) | low; |
549 | } | 536 | } |
550 | 537 | ||
551 | static int rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data, | 538 | static void rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data, |
552 | struct iwl_scale_tbl_info *tbl, u8 scale_index, | 539 | struct iwl_scale_tbl_info *tbl, u8 scale_index, |
553 | u8 ht_possible, struct iwl_rate *mcs_rate) | 540 | u8 ht_possible, struct iwl_rate *mcs_rate) |
554 | { | 541 | { |
@@ -589,10 +576,9 @@ static int rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data, | |||
589 | } | 576 | } |
590 | 577 | ||
591 | /* if we did switched from HT to legacy check current rate */ | 578 | /* if we did switched from HT to legacy check current rate */ |
592 | if ((switch_to_legacy) && | 579 | if (switch_to_legacy && (rate_mask & (1 << scale_index))) { |
593 | (rate_mask & (1 << scale_index))) { | ||
594 | rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green); | 580 | rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green); |
595 | return 0; | 581 | return; |
596 | } | 582 | } |
597 | 583 | ||
598 | high_low = rs_get_adjacent_rate(scale_index, rate_mask, tbl->lq_type); | 584 | high_low = rs_get_adjacent_rate(scale_index, rate_mask, tbl->lq_type); |
@@ -602,8 +588,6 @@ static int rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data, | |||
602 | rs_mcs_from_tbl(mcs_rate, tbl, low, is_green); | 588 | rs_mcs_from_tbl(mcs_rate, tbl, low, is_green); |
603 | else | 589 | else |
604 | rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green); | 590 | rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green); |
605 | |||
606 | return 0; | ||
607 | } | 591 | } |
608 | 592 | ||
609 | static void rs_tx_status(void *priv_rate, | 593 | static void rs_tx_status(void *priv_rate, |
@@ -775,12 +759,8 @@ static u8 rs_is_ant_connected(u8 valid_antenna, | |||
775 | return ((valid_antenna & 0x2) ? 1:0); | 759 | return ((valid_antenna & 0x2) ? 1:0); |
776 | else if (antenna_type == ANT_MAIN) | 760 | else if (antenna_type == ANT_MAIN) |
777 | return ((valid_antenna & 0x1) ? 1:0); | 761 | return ((valid_antenna & 0x1) ? 1:0); |
778 | else if (antenna_type == ANT_BOTH) { | 762 | else if (antenna_type == ANT_BOTH) |
779 | if ((valid_antenna & 0x3) == 0x3) | 763 | return ((valid_antenna & 0x3) == 0x3); |
780 | return 1; | ||
781 | else | ||
782 | return 0; | ||
783 | } | ||
784 | 764 | ||
785 | return 1; | 765 | return 1; |
786 | } | 766 | } |
@@ -789,9 +769,9 @@ static u8 rs_is_other_ant_connected(u8 valid_antenna, | |||
789 | enum iwl_antenna_type antenna_type) | 769 | enum iwl_antenna_type antenna_type) |
790 | { | 770 | { |
791 | if (antenna_type == ANT_AUX) | 771 | if (antenna_type == ANT_AUX) |
792 | return (rs_is_ant_connected(valid_antenna, ANT_MAIN)); | 772 | return rs_is_ant_connected(valid_antenna, ANT_MAIN); |
793 | else | 773 | else |
794 | return (rs_is_ant_connected(valid_antenna, ANT_AUX)); | 774 | return rs_is_ant_connected(valid_antenna, ANT_AUX); |
795 | 775 | ||
796 | return 0; | 776 | return 0; |
797 | } | 777 | } |
@@ -912,7 +892,6 @@ static int rs_switch_to_mimo(struct iwl_priv *priv, | |||
912 | struct iwl_rate_scale_priv *lq_data, | 892 | struct iwl_rate_scale_priv *lq_data, |
913 | struct iwl_scale_tbl_info *tbl, int index) | 893 | struct iwl_scale_tbl_info *tbl, int index) |
914 | { | 894 | { |
915 | int rc = -1; | ||
916 | #ifdef CONFIG_IWLWIFI_HT | 895 | #ifdef CONFIG_IWLWIFI_HT |
917 | u16 rate_mask; | 896 | u16 rate_mask; |
918 | s32 rate; | 897 | s32 rate; |
@@ -932,7 +911,6 @@ static int rs_switch_to_mimo(struct iwl_priv *priv, | |||
932 | if (!rs_is_both_ant_supp(lq_data->antenna)) | 911 | if (!rs_is_both_ant_supp(lq_data->antenna)) |
933 | return -1; | 912 | return -1; |
934 | 913 | ||
935 | rc = 0; | ||
936 | tbl->is_dup = lq_data->is_dup; | 914 | tbl->is_dup = lq_data->is_dup; |
937 | tbl->action = 0; | 915 | tbl->action = 0; |
938 | if (priv->current_channel_width == IWL_CHANNEL_WIDTH_40MHZ) | 916 | if (priv->current_channel_width == IWL_CHANNEL_WIDTH_40MHZ) |
@@ -963,14 +941,13 @@ static int rs_switch_to_mimo(struct iwl_priv *priv, | |||
963 | tbl->current_rate.rate_n_flags, is_green); | 941 | tbl->current_rate.rate_n_flags, is_green); |
964 | 942 | ||
965 | #endif /*CONFIG_IWLWIFI_HT */ | 943 | #endif /*CONFIG_IWLWIFI_HT */ |
966 | return rc; | 944 | return 0; |
967 | } | 945 | } |
968 | 946 | ||
969 | static int rs_switch_to_siso(struct iwl_priv *priv, | 947 | static int rs_switch_to_siso(struct iwl_priv *priv, |
970 | struct iwl_rate_scale_priv *lq_data, | 948 | struct iwl_rate_scale_priv *lq_data, |
971 | struct iwl_scale_tbl_info *tbl, int index) | 949 | struct iwl_scale_tbl_info *tbl, int index) |
972 | { | 950 | { |
973 | int rc = -1; | ||
974 | #ifdef CONFIG_IWLWIFI_HT | 951 | #ifdef CONFIG_IWLWIFI_HT |
975 | u16 rate_mask; | 952 | u16 rate_mask; |
976 | u8 is_green = lq_data->is_green; | 953 | u8 is_green = lq_data->is_green; |
@@ -980,7 +957,6 @@ static int rs_switch_to_siso(struct iwl_priv *priv, | |||
980 | if (!priv->is_ht_enabled || !priv->current_assoc_ht.is_ht) | 957 | if (!priv->is_ht_enabled || !priv->current_assoc_ht.is_ht) |
981 | return -1; | 958 | return -1; |
982 | 959 | ||
983 | rc = 0; | ||
984 | tbl->is_dup = lq_data->is_dup; | 960 | tbl->is_dup = lq_data->is_dup; |
985 | tbl->lq_type = LQ_SISO; | 961 | tbl->lq_type = LQ_SISO; |
986 | tbl->action = 0; | 962 | tbl->action = 0; |
@@ -1019,14 +995,14 @@ static int rs_switch_to_siso(struct iwl_priv *priv, | |||
1019 | tbl->current_rate.rate_n_flags, is_green); | 995 | tbl->current_rate.rate_n_flags, is_green); |
1020 | 996 | ||
1021 | #endif /*CONFIG_IWLWIFI_HT */ | 997 | #endif /*CONFIG_IWLWIFI_HT */ |
1022 | return rc; | 998 | return 0; |
1023 | } | 999 | } |
1024 | 1000 | ||
1025 | static int rs_move_legacy_other(struct iwl_priv *priv, | 1001 | static int rs_move_legacy_other(struct iwl_priv *priv, |
1026 | struct iwl_rate_scale_priv *lq_data, | 1002 | struct iwl_rate_scale_priv *lq_data, |
1027 | int index) | 1003 | int index) |
1028 | { | 1004 | { |
1029 | int rc = 0; | 1005 | int ret = 0; |
1030 | struct iwl_scale_tbl_info *tbl = | 1006 | struct iwl_scale_tbl_info *tbl = |
1031 | &(lq_data->lq_info[lq_data->active_tbl]); | 1007 | &(lq_data->lq_info[lq_data->active_tbl]); |
1032 | struct iwl_scale_tbl_info *search_tbl = | 1008 | struct iwl_scale_tbl_info *search_tbl = |
@@ -1063,14 +1039,13 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1063 | search_tbl->lq_type = LQ_SISO; | 1039 | search_tbl->lq_type = LQ_SISO; |
1064 | search_tbl->is_SGI = 0; | 1040 | search_tbl->is_SGI = 0; |
1065 | search_tbl->is_fat = 0; | 1041 | search_tbl->is_fat = 0; |
1066 | rc = rs_switch_to_siso(priv, lq_data, search_tbl, | 1042 | ret = rs_switch_to_siso(priv, lq_data, search_tbl, |
1067 | index); | 1043 | index); |
1068 | if (!rc) { | 1044 | if (!ret) { |
1069 | lq_data->search_better_tbl = 1; | 1045 | lq_data->search_better_tbl = 1; |
1070 | lq_data->action_counter = 0; | 1046 | lq_data->action_counter = 0; |
1071 | } | ||
1072 | if (!rc) | ||
1073 | goto out; | 1047 | goto out; |
1048 | } | ||
1074 | 1049 | ||
1075 | break; | 1050 | break; |
1076 | case IWL_LEGACY_SWITCH_MIMO: | 1051 | case IWL_LEGACY_SWITCH_MIMO: |
@@ -1080,14 +1055,13 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1080 | search_tbl->is_SGI = 0; | 1055 | search_tbl->is_SGI = 0; |
1081 | search_tbl->is_fat = 0; | 1056 | search_tbl->is_fat = 0; |
1082 | search_tbl->antenna_type = ANT_BOTH; | 1057 | search_tbl->antenna_type = ANT_BOTH; |
1083 | rc = rs_switch_to_mimo(priv, lq_data, search_tbl, | 1058 | ret = rs_switch_to_mimo(priv, lq_data, search_tbl, |
1084 | index); | 1059 | index); |
1085 | if (!rc) { | 1060 | if (!ret) { |
1086 | lq_data->search_better_tbl = 1; | 1061 | lq_data->search_better_tbl = 1; |
1087 | lq_data->action_counter = 0; | 1062 | lq_data->action_counter = 0; |
1088 | } | ||
1089 | if (!rc) | ||
1090 | goto out; | 1063 | goto out; |
1064 | } | ||
1091 | break; | 1065 | break; |
1092 | } | 1066 | } |
1093 | tbl->action++; | 1067 | tbl->action++; |
@@ -1112,7 +1086,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1112 | struct iwl_rate_scale_priv *lq_data, | 1086 | struct iwl_rate_scale_priv *lq_data, |
1113 | int index) | 1087 | int index) |
1114 | { | 1088 | { |
1115 | int rc = -1; | 1089 | int ret; |
1116 | u8 is_green = lq_data->is_green; | 1090 | u8 is_green = lq_data->is_green; |
1117 | struct iwl_scale_tbl_info *tbl = | 1091 | struct iwl_scale_tbl_info *tbl = |
1118 | &(lq_data->lq_info[lq_data->active_tbl]); | 1092 | &(lq_data->lq_info[lq_data->active_tbl]); |
@@ -1150,13 +1124,12 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1150 | search_tbl->is_SGI = 0; | 1124 | search_tbl->is_SGI = 0; |
1151 | search_tbl->is_fat = 0; | 1125 | search_tbl->is_fat = 0; |
1152 | search_tbl->antenna_type = ANT_BOTH; | 1126 | search_tbl->antenna_type = ANT_BOTH; |
1153 | rc = rs_switch_to_mimo(priv, lq_data, search_tbl, | 1127 | ret = rs_switch_to_mimo(priv, lq_data, search_tbl, |
1154 | index); | 1128 | index); |
1155 | if (!rc) | 1129 | if (!ret) { |
1156 | lq_data->search_better_tbl = 1; | 1130 | lq_data->search_better_tbl = 1; |
1157 | |||
1158 | if (!rc) | ||
1159 | goto out; | 1131 | goto out; |
1132 | } | ||
1160 | break; | 1133 | break; |
1161 | case IWL_SISO_SWITCH_GI: | 1134 | case IWL_SISO_SWITCH_GI: |
1162 | IWL_DEBUG_HT("LQ: SISO SWITCH TO GI\n"); | 1135 | IWL_DEBUG_HT("LQ: SISO SWITCH TO GI\n"); |
@@ -1203,7 +1176,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1203 | struct iwl_rate_scale_priv *lq_data, | 1176 | struct iwl_rate_scale_priv *lq_data, |
1204 | int index) | 1177 | int index) |
1205 | { | 1178 | { |
1206 | int rc = -1; | 1179 | int ret; |
1207 | s8 is_green = lq_data->is_green; | 1180 | s8 is_green = lq_data->is_green; |
1208 | struct iwl_scale_tbl_info *tbl = | 1181 | struct iwl_scale_tbl_info *tbl = |
1209 | &(lq_data->lq_info[lq_data->active_tbl]); | 1182 | &(lq_data->lq_info[lq_data->active_tbl]); |
@@ -1228,9 +1201,9 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1228 | else | 1201 | else |
1229 | search_tbl->antenna_type = ANT_AUX; | 1202 | search_tbl->antenna_type = ANT_AUX; |
1230 | 1203 | ||
1231 | rc = rs_switch_to_siso(priv, lq_data, search_tbl, | 1204 | ret = rs_switch_to_siso(priv, lq_data, search_tbl, |
1232 | index); | 1205 | index); |
1233 | if (!rc) { | 1206 | if (!ret) { |
1234 | lq_data->search_better_tbl = 1; | 1207 | lq_data->search_better_tbl = 1; |
1235 | goto out; | 1208 | goto out; |
1236 | } | 1209 | } |