diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-rx.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-rx.c | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index f5c87e72660a..6f36b6e79f5e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -650,47 +650,6 @@ void iwl_reply_statistics(struct iwl_priv *priv, | |||
650 | } | 650 | } |
651 | EXPORT_SYMBOL(iwl_reply_statistics); | 651 | EXPORT_SYMBOL(iwl_reply_statistics); |
652 | 652 | ||
653 | #define PERFECT_RSSI (-20) /* dBm */ | ||
654 | #define WORST_RSSI (-95) /* dBm */ | ||
655 | #define RSSI_RANGE (PERFECT_RSSI - WORST_RSSI) | ||
656 | |||
657 | /* Calculate an indication of rx signal quality (a percentage, not dBm!). | ||
658 | * See http://www.ces.clemson.edu/linux/signal_quality.shtml for info | ||
659 | * about formulas used below. */ | ||
660 | static int iwl_calc_sig_qual(int rssi_dbm, int noise_dbm) | ||
661 | { | ||
662 | int sig_qual; | ||
663 | int degradation = PERFECT_RSSI - rssi_dbm; | ||
664 | |||
665 | /* If we get a noise measurement, use signal-to-noise ratio (SNR) | ||
666 | * as indicator; formula is (signal dbm - noise dbm). | ||
667 | * SNR at or above 40 is a great signal (100%). | ||
668 | * Below that, scale to fit SNR of 0 - 40 dB within 0 - 100% indicator. | ||
669 | * Weakest usable signal is usually 10 - 15 dB SNR. */ | ||
670 | if (noise_dbm) { | ||
671 | if (rssi_dbm - noise_dbm >= 40) | ||
672 | return 100; | ||
673 | else if (rssi_dbm < noise_dbm) | ||
674 | return 0; | ||
675 | sig_qual = ((rssi_dbm - noise_dbm) * 5) / 2; | ||
676 | |||
677 | /* Else use just the signal level. | ||
678 | * This formula is a least squares fit of data points collected and | ||
679 | * compared with a reference system that had a percentage (%) display | ||
680 | * for signal quality. */ | ||
681 | } else | ||
682 | sig_qual = (100 * (RSSI_RANGE * RSSI_RANGE) - degradation * | ||
683 | (15 * RSSI_RANGE + 62 * degradation)) / | ||
684 | (RSSI_RANGE * RSSI_RANGE); | ||
685 | |||
686 | if (sig_qual > 100) | ||
687 | sig_qual = 100; | ||
688 | else if (sig_qual < 1) | ||
689 | sig_qual = 0; | ||
690 | |||
691 | return sig_qual; | ||
692 | } | ||
693 | |||
694 | /* Calc max signal level (dBm) among 3 possible receivers */ | 653 | /* Calc max signal level (dBm) among 3 possible receivers */ |
695 | static inline int iwl_calc_rssi(struct iwl_priv *priv, | 654 | static inline int iwl_calc_rssi(struct iwl_priv *priv, |
696 | struct iwl_rx_phy_res *rx_resp) | 655 | struct iwl_rx_phy_res *rx_resp) |
@@ -1101,11 +1060,8 @@ void iwl_rx_reply_rx(struct iwl_priv *priv, | |||
1101 | if (iwl_is_associated(priv) && | 1060 | if (iwl_is_associated(priv) && |
1102 | !test_bit(STATUS_SCANNING, &priv->status)) { | 1061 | !test_bit(STATUS_SCANNING, &priv->status)) { |
1103 | rx_status.noise = priv->last_rx_noise; | 1062 | rx_status.noise = priv->last_rx_noise; |
1104 | rx_status.qual = iwl_calc_sig_qual(rx_status.signal, | ||
1105 | rx_status.noise); | ||
1106 | } else { | 1063 | } else { |
1107 | rx_status.noise = IWL_NOISE_MEAS_NOT_AVAILABLE; | 1064 | rx_status.noise = IWL_NOISE_MEAS_NOT_AVAILABLE; |
1108 | rx_status.qual = iwl_calc_sig_qual(rx_status.signal, 0); | ||
1109 | } | 1065 | } |
1110 | 1066 | ||
1111 | /* Reset beacon noise level if not associated. */ | 1067 | /* Reset beacon noise level if not associated. */ |
@@ -1118,8 +1074,8 @@ void iwl_rx_reply_rx(struct iwl_priv *priv, | |||
1118 | iwl_dbg_report_frame(priv, phy_res, len, header, 1); | 1074 | iwl_dbg_report_frame(priv, phy_res, len, header, 1); |
1119 | #endif | 1075 | #endif |
1120 | iwl_dbg_log_rx_data_frame(priv, len, header); | 1076 | iwl_dbg_log_rx_data_frame(priv, len, header); |
1121 | IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, noise %d, qual %d, TSF %llu\n", | 1077 | IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, noise %d, TSF %llu\n", |
1122 | rx_status.signal, rx_status.noise, rx_status.qual, | 1078 | rx_status.signal, rx_status.noise, |
1123 | (unsigned long long)rx_status.mactime); | 1079 | (unsigned long long)rx_status.mactime); |
1124 | 1080 | ||
1125 | /* | 1081 | /* |