diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-calib.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-calib.c | 102 |
1 files changed, 70 insertions, 32 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c index c4b565a2de94..8b516c5ff0bb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-calib.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * GPL LICENSE SUMMARY | 6 | * GPL LICENSE SUMMARY |
7 | * | 7 | * |
8 | * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved. | 8 | * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of version 2 of the GNU General Public License as | 11 | * it under the terms of version 2 of the GNU General Public License as |
@@ -30,7 +30,7 @@ | |||
30 | * | 30 | * |
31 | * BSD LICENSE | 31 | * BSD LICENSE |
32 | * | 32 | * |
33 | * Copyright(c) 2005 - 2009 Intel Corporation. All rights reserved. | 33 | * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved. |
34 | * All rights reserved. | 34 | * All rights reserved. |
35 | * | 35 | * |
36 | * Redistribution and use in source and binary forms, with or without | 36 | * Redistribution and use in source and binary forms, with or without |
@@ -60,6 +60,7 @@ | |||
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
61 | *****************************************************************************/ | 61 | *****************************************************************************/ |
62 | 62 | ||
63 | #include <linux/slab.h> | ||
63 | #include <net/mac80211.h> | 64 | #include <net/mac80211.h> |
64 | 65 | ||
65 | #include "iwl-dev.h" | 66 | #include "iwl-dev.h" |
@@ -132,6 +133,7 @@ void iwl_calib_free_results(struct iwl_priv *priv) | |||
132 | priv->calib_results[i].buf_len = 0; | 133 | priv->calib_results[i].buf_len = 0; |
133 | } | 134 | } |
134 | } | 135 | } |
136 | EXPORT_SYMBOL(iwl_calib_free_results); | ||
135 | 137 | ||
136 | /***************************************************************************** | 138 | /***************************************************************************** |
137 | * RUNTIME calibrations framework | 139 | * RUNTIME calibrations framework |
@@ -413,7 +415,6 @@ static int iwl_sens_auto_corr_ofdm(struct iwl_priv *priv, | |||
413 | /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ | 415 | /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ |
414 | static int iwl_sensitivity_write(struct iwl_priv *priv) | 416 | static int iwl_sensitivity_write(struct iwl_priv *priv) |
415 | { | 417 | { |
416 | int ret = 0; | ||
417 | struct iwl_sensitivity_cmd cmd ; | 418 | struct iwl_sensitivity_cmd cmd ; |
418 | struct iwl_sensitivity_data *data = NULL; | 419 | struct iwl_sensitivity_data *data = NULL; |
419 | struct iwl_host_cmd cmd_out = { | 420 | struct iwl_host_cmd cmd_out = { |
@@ -447,11 +448,11 @@ static int iwl_sensitivity_write(struct iwl_priv *priv) | |||
447 | cpu_to_le16((u16)data->nrg_th_ofdm); | 448 | cpu_to_le16((u16)data->nrg_th_ofdm); |
448 | 449 | ||
449 | cmd.table[HD_BARKER_CORR_TH_ADD_MIN_INDEX] = | 450 | cmd.table[HD_BARKER_CORR_TH_ADD_MIN_INDEX] = |
450 | cpu_to_le16(190); | 451 | cpu_to_le16(data->barker_corr_th_min); |
451 | cmd.table[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] = | 452 | cmd.table[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] = |
452 | cpu_to_le16(390); | 453 | cpu_to_le16(data->barker_corr_th_min_mrc); |
453 | cmd.table[HD_OFDM_ENERGY_TH_IN_INDEX] = | 454 | cmd.table[HD_OFDM_ENERGY_TH_IN_INDEX] = |
454 | cpu_to_le16(62); | 455 | cpu_to_le16(data->nrg_th_cca); |
455 | 456 | ||
456 | IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", | 457 | IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", |
457 | data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, | 458 | data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, |
@@ -476,11 +477,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv) | |||
476 | memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), | 477 | memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), |
477 | sizeof(u16)*HD_TABLE_SIZE); | 478 | sizeof(u16)*HD_TABLE_SIZE); |
478 | 479 | ||
479 | ret = iwl_send_cmd(priv, &cmd_out); | 480 | return iwl_send_cmd(priv, &cmd_out); |
480 | if (ret) | ||
481 | IWL_ERR(priv, "SENSITIVITY_CMD failed\n"); | ||
482 | |||
483 | return ret; | ||
484 | } | 481 | } |
485 | 482 | ||
486 | void iwl_init_sensitivity(struct iwl_priv *priv) | 483 | void iwl_init_sensitivity(struct iwl_priv *priv) |
@@ -516,7 +513,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv) | |||
516 | for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) | 513 | for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) |
517 | data->nrg_silence_rssi[i] = 0; | 514 | data->nrg_silence_rssi[i] = 0; |
518 | 515 | ||
519 | data->auto_corr_ofdm = 90; | 516 | data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; |
520 | data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; | 517 | data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; |
521 | data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; | 518 | data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; |
522 | data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; | 519 | data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; |
@@ -524,6 +521,9 @@ void iwl_init_sensitivity(struct iwl_priv *priv) | |||
524 | data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; | 521 | data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; |
525 | data->nrg_th_cck = ranges->nrg_th_cck; | 522 | data->nrg_th_cck = ranges->nrg_th_cck; |
526 | data->nrg_th_ofdm = ranges->nrg_th_ofdm; | 523 | data->nrg_th_ofdm = ranges->nrg_th_ofdm; |
524 | data->barker_corr_th_min = ranges->barker_corr_th_min; | ||
525 | data->barker_corr_th_min_mrc = ranges->barker_corr_th_min_mrc; | ||
526 | data->nrg_th_cca = ranges->nrg_th_cca; | ||
527 | 527 | ||
528 | data->last_bad_plcp_cnt_ofdm = 0; | 528 | data->last_bad_plcp_cnt_ofdm = 0; |
529 | data->last_fa_cnt_ofdm = 0; | 529 | data->last_fa_cnt_ofdm = 0; |
@@ -643,6 +643,15 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv, | |||
643 | } | 643 | } |
644 | EXPORT_SYMBOL(iwl_sensitivity_calibration); | 644 | EXPORT_SYMBOL(iwl_sensitivity_calibration); |
645 | 645 | ||
646 | static inline u8 find_first_chain(u8 mask) | ||
647 | { | ||
648 | if (mask & ANT_A) | ||
649 | return CHAIN_A; | ||
650 | if (mask & ANT_B) | ||
651 | return CHAIN_B; | ||
652 | return CHAIN_C; | ||
653 | } | ||
654 | |||
646 | /* | 655 | /* |
647 | * Accumulate 20 beacons of signal and noise statistics for each of | 656 | * Accumulate 20 beacons of signal and noise statistics for each of |
648 | * 3 receivers/antennas/rx-chains, then figure out: | 657 | * 3 receivers/antennas/rx-chains, then figure out: |
@@ -675,14 +684,17 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
675 | u8 num_tx_chains; | 684 | u8 num_tx_chains; |
676 | unsigned long flags; | 685 | unsigned long flags; |
677 | struct statistics_rx_non_phy *rx_info = &(stat_resp->rx.general); | 686 | struct statistics_rx_non_phy *rx_info = &(stat_resp->rx.general); |
687 | u8 first_chain; | ||
678 | 688 | ||
679 | if (priv->disable_chain_noise_cal) | 689 | if (priv->disable_chain_noise_cal) |
680 | return; | 690 | return; |
681 | 691 | ||
682 | data = &(priv->chain_noise_data); | 692 | data = &(priv->chain_noise_data); |
683 | 693 | ||
684 | /* Accumulate just the first 20 beacons after the first association, | 694 | /* |
685 | * then we're done forever. */ | 695 | * Accumulate just the first "chain_noise_num_beacons" after |
696 | * the first association, then we're done forever. | ||
697 | */ | ||
686 | if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) { | 698 | if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) { |
687 | if (data->state == IWL_CHAIN_NOISE_ALIVE) | 699 | if (data->state == IWL_CHAIN_NOISE_ALIVE) |
688 | IWL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); | 700 | IWL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); |
@@ -710,7 +722,10 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
710 | return; | 722 | return; |
711 | } | 723 | } |
712 | 724 | ||
713 | /* Accumulate beacon statistics values across 20 beacons */ | 725 | /* |
726 | * Accumulate beacon statistics values across | ||
727 | * "chain_noise_num_beacons" | ||
728 | */ | ||
714 | chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & | 729 | chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & |
715 | IN_BAND_FILTER; | 730 | IN_BAND_FILTER; |
716 | chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & | 731 | chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & |
@@ -741,16 +756,19 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
741 | IWL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", | 756 | IWL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", |
742 | chain_noise_a, chain_noise_b, chain_noise_c); | 757 | chain_noise_a, chain_noise_b, chain_noise_c); |
743 | 758 | ||
744 | /* If this is the 20th beacon, determine: | 759 | /* If this is the "chain_noise_num_beacons", determine: |
745 | * 1) Disconnected antennas (using signal strengths) | 760 | * 1) Disconnected antennas (using signal strengths) |
746 | * 2) Differential gain (using silence noise) to balance receivers */ | 761 | * 2) Differential gain (using silence noise) to balance receivers */ |
747 | if (data->beacon_count != CAL_NUM_OF_BEACONS) | 762 | if (data->beacon_count != priv->cfg->chain_noise_num_beacons) |
748 | return; | 763 | return; |
749 | 764 | ||
750 | /* Analyze signal for disconnected antenna */ | 765 | /* Analyze signal for disconnected antenna */ |
751 | average_sig[0] = (data->chain_signal_a) / CAL_NUM_OF_BEACONS; | 766 | average_sig[0] = |
752 | average_sig[1] = (data->chain_signal_b) / CAL_NUM_OF_BEACONS; | 767 | (data->chain_signal_a) / priv->cfg->chain_noise_num_beacons; |
753 | average_sig[2] = (data->chain_signal_c) / CAL_NUM_OF_BEACONS; | 768 | average_sig[1] = |
769 | (data->chain_signal_b) / priv->cfg->chain_noise_num_beacons; | ||
770 | average_sig[2] = | ||
771 | (data->chain_signal_c) / priv->cfg->chain_noise_num_beacons; | ||
754 | 772 | ||
755 | if (average_sig[0] >= average_sig[1]) { | 773 | if (average_sig[0] >= average_sig[1]) { |
756 | max_average_sig = average_sig[0]; | 774 | max_average_sig = average_sig[0]; |
@@ -790,6 +808,18 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
790 | } | 808 | } |
791 | } | 809 | } |
792 | 810 | ||
811 | /* | ||
812 | * The above algorithm sometimes fails when the ucode | ||
813 | * reports 0 for all chains. It's not clear why that | ||
814 | * happens to start with, but it is then causing trouble | ||
815 | * because this can make us enable more chains than the | ||
816 | * hardware really has. | ||
817 | * | ||
818 | * To be safe, simply mask out any chains that we know | ||
819 | * are not on the device. | ||
820 | */ | ||
821 | active_chains &= priv->hw_params.valid_rx_ant; | ||
822 | |||
793 | num_tx_chains = 0; | 823 | num_tx_chains = 0; |
794 | for (i = 0; i < NUM_RX_CHAINS; i++) { | 824 | for (i = 0; i < NUM_RX_CHAINS; i++) { |
795 | /* loops on all the bits of | 825 | /* loops on all the bits of |
@@ -803,13 +833,17 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
803 | /* there is a Tx antenna connected */ | 833 | /* there is a Tx antenna connected */ |
804 | break; | 834 | break; |
805 | if (num_tx_chains == priv->hw_params.tx_chains_num && | 835 | if (num_tx_chains == priv->hw_params.tx_chains_num && |
806 | data->disconn_array[i]) { | 836 | data->disconn_array[i]) { |
807 | /* This is the last TX antenna and is also | 837 | /* |
808 | * disconnected connect it anyway */ | 838 | * If all chains are disconnected |
809 | data->disconn_array[i] = 0; | 839 | * connect the first valid tx chain |
810 | active_chains |= ant_msk; | 840 | */ |
811 | IWL_DEBUG_CALIB(priv, "All Tx chains are disconnected W/A - " | 841 | first_chain = |
812 | "declare %d as connected\n", i); | 842 | find_first_chain(priv->cfg->valid_tx_ant); |
843 | data->disconn_array[first_chain] = 0; | ||
844 | active_chains |= BIT(first_chain); | ||
845 | IWL_DEBUG_CALIB(priv, "All Tx chains are disconnected W/A - declare %d as connected\n", | ||
846 | first_chain); | ||
813 | break; | 847 | break; |
814 | } | 848 | } |
815 | } | 849 | } |
@@ -820,9 +854,12 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
820 | active_chains); | 854 | active_chains); |
821 | 855 | ||
822 | /* Analyze noise for rx balance */ | 856 | /* Analyze noise for rx balance */ |
823 | average_noise[0] = ((data->chain_noise_a)/CAL_NUM_OF_BEACONS); | 857 | average_noise[0] = |
824 | average_noise[1] = ((data->chain_noise_b)/CAL_NUM_OF_BEACONS); | 858 | ((data->chain_noise_a) / priv->cfg->chain_noise_num_beacons); |
825 | average_noise[2] = ((data->chain_noise_c)/CAL_NUM_OF_BEACONS); | 859 | average_noise[1] = |
860 | ((data->chain_noise_b) / priv->cfg->chain_noise_num_beacons); | ||
861 | average_noise[2] = | ||
862 | ((data->chain_noise_c) / priv->cfg->chain_noise_num_beacons); | ||
826 | 863 | ||
827 | for (i = 0; i < NUM_RX_CHAINS; i++) { | 864 | for (i = 0; i < NUM_RX_CHAINS; i++) { |
828 | if (!(data->disconn_array[i]) && | 865 | if (!(data->disconn_array[i]) && |
@@ -843,7 +880,8 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
843 | 880 | ||
844 | if (priv->cfg->ops->utils->gain_computation) | 881 | if (priv->cfg->ops->utils->gain_computation) |
845 | priv->cfg->ops->utils->gain_computation(priv, average_noise, | 882 | priv->cfg->ops->utils->gain_computation(priv, average_noise, |
846 | min_average_noise_antenna_i, min_average_noise); | 883 | min_average_noise_antenna_i, min_average_noise, |
884 | find_first_chain(priv->cfg->valid_rx_ant)); | ||
847 | 885 | ||
848 | /* Some power changes may have been made during the calibration. | 886 | /* Some power changes may have been made during the calibration. |
849 | * Update and commit the RXON | 887 | * Update and commit the RXON |
@@ -870,7 +908,7 @@ void iwl_reset_run_time_calib(struct iwl_priv *priv) | |||
870 | 908 | ||
871 | /* Ask for statistics now, the uCode will send notification | 909 | /* Ask for statistics now, the uCode will send notification |
872 | * periodically after association */ | 910 | * periodically after association */ |
873 | iwl_send_statistics_request(priv, CMD_ASYNC); | 911 | iwl_send_statistics_request(priv, CMD_ASYNC, true); |
874 | } | 912 | } |
875 | EXPORT_SYMBOL(iwl_reset_run_time_calib); | 913 | EXPORT_SYMBOL(iwl_reset_run_time_calib); |
876 | 914 | ||