diff options
author | Bruno Randolf <br1@einfach.org> | 2008-05-08 13:15:40 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-14 16:29:49 -0400 |
commit | 566bfe5a8bcde13188a356f77666f8115813cf31 (patch) | |
tree | 785412c505e9efbd0fac477d71c8ca6945ffce04 /drivers/net/wireless/iwlwifi | |
parent | fac371d9f09f461dfe9fbbceb2a38e2e12164dda (diff) |
mac80211: use hardware flags for signal/noise units
trying to clean up the signal/noise code. the previous code in mac80211 had
confusing names for the related variables, did not have much definition of
what units of signal and noise were provided and used implicit mechanisms from
the wireless extensions.
this patch introduces hardware capability flags to let the hardware specify
clearly if it can provide signal and noise level values and which units it can
provide. this also anticipates possible new units like RCPI in the future.
for signal:
IEEE80211_HW_SIGNAL_UNSPEC - unspecified, unknown, hw specific
IEEE80211_HW_SIGNAL_DB - dB difference to unspecified reference point
IEEE80211_HW_SIGNAL_DBM - dBm, difference to 1mW
for noise we currently only have dBm:
IEEE80211_HW_NOISE_DBM - dBm, difference to 1mW
if IEEE80211_HW_SIGNAL_UNSPEC or IEEE80211_HW_SIGNAL_DB is used the driver has
to provide the maximum value (max_signal) it reports in order for applications
to make sense of the signal values.
i tried my best to find out for each driver what it can provide and update it
but i'm not sure (?) for some of them and used the more conservative guess in
doubt. this can be fixed easily after this patch has been merged by changing
the hardware flags of the driver.
DRIVER SIGNAL MAX NOISE QUAL
-----------------------------------------------------------------
adm8211 unspec(?) 100 n/a missing
at76_usb unspec(?) (?) unused missing
ath5k dBm dBm percent rssi
b43legacy dBm dBm percent jssi(?)
b43 dBm dBm percent jssi(?)
iwl-3945 dBm dBm percent snr+more
iwl-4965 dBm dBm percent snr+more
p54 unspec 127 n/a missing
rt2x00 dBm n/a percent rssi+tx/rx frame success
rt2400 dBm n/a
rt2500pci dBm n/a
rt2500usb dBm n/a
rt61pci dBm n/a
rt73usb dBm n/a
rtl8180 unspec(?) 65 n/a (?)
rtl8187 unspec(?) 65 (?) noise(?)
zd1211 dB(?) 100 n/a percent
drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD
Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.c | 16 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 15 |
4 files changed, 23 insertions, 38 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index 8464397f7816..d7beeff2642c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -520,7 +520,7 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv, | |||
520 | { | 520 | { |
521 | /* First cache any information we need before we overwrite | 521 | /* First cache any information we need before we overwrite |
522 | * the information provided in the skb from the hardware */ | 522 | * the information provided in the skb from the hardware */ |
523 | s8 signal = stats->ssi; | 523 | s8 signal = stats->signal; |
524 | s8 noise = 0; | 524 | s8 noise = 0; |
525 | int rate = stats->rate_idx; | 525 | int rate = stats->rate_idx; |
526 | u64 tsf = stats->mactime; | 526 | u64 tsf = stats->mactime; |
@@ -693,7 +693,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
693 | } | 693 | } |
694 | 694 | ||
695 | /* Convert 3945's rssi indicator to dBm */ | 695 | /* Convert 3945's rssi indicator to dBm */ |
696 | rx_status.ssi = rx_stats->rssi - IWL_RSSI_OFFSET; | 696 | rx_status.signal = rx_stats->rssi - IWL_RSSI_OFFSET; |
697 | 697 | ||
698 | /* Set default noise value to -127 */ | 698 | /* Set default noise value to -127 */ |
699 | if (priv->last_rx_noise == 0) | 699 | if (priv->last_rx_noise == 0) |
@@ -712,21 +712,21 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
712 | * Calculate rx_status.signal (quality indicator in %) based on SNR. */ | 712 | * Calculate rx_status.signal (quality indicator in %) based on SNR. */ |
713 | if (rx_stats_noise_diff) { | 713 | if (rx_stats_noise_diff) { |
714 | snr = rx_stats_sig_avg / rx_stats_noise_diff; | 714 | snr = rx_stats_sig_avg / rx_stats_noise_diff; |
715 | rx_status.noise = rx_status.ssi - | 715 | rx_status.noise = rx_status.signal - |
716 | iwl3945_calc_db_from_ratio(snr); | 716 | iwl3945_calc_db_from_ratio(snr); |
717 | rx_status.signal = iwl3945_calc_sig_qual(rx_status.ssi, | 717 | rx_status.qual = iwl3945_calc_sig_qual(rx_status.signal, |
718 | rx_status.noise); | 718 | rx_status.noise); |
719 | 719 | ||
720 | /* If noise info not available, calculate signal quality indicator (%) | 720 | /* If noise info not available, calculate signal quality indicator (%) |
721 | * using just the dBm signal level. */ | 721 | * using just the dBm signal level. */ |
722 | } else { | 722 | } else { |
723 | rx_status.noise = priv->last_rx_noise; | 723 | rx_status.noise = priv->last_rx_noise; |
724 | rx_status.signal = iwl3945_calc_sig_qual(rx_status.ssi, 0); | 724 | rx_status.qual = iwl3945_calc_sig_qual(rx_status.signal, 0); |
725 | } | 725 | } |
726 | 726 | ||
727 | 727 | ||
728 | IWL_DEBUG_STATS("Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n", | 728 | IWL_DEBUG_STATS("Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n", |
729 | rx_status.ssi, rx_status.noise, rx_status.signal, | 729 | rx_status.signal, rx_status.noise, rx_status.qual, |
730 | rx_stats_sig_avg, rx_stats_noise_diff); | 730 | rx_stats_sig_avg, rx_stats_noise_diff); |
731 | 731 | ||
732 | header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); | 732 | header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); |
@@ -736,8 +736,8 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
736 | IWL_DEBUG_STATS_LIMIT("[%c] %d RSSI:%d Signal:%u, Noise:%u, Rate:%u\n", | 736 | IWL_DEBUG_STATS_LIMIT("[%c] %d RSSI:%d Signal:%u, Noise:%u, Rate:%u\n", |
737 | network_packet ? '*' : ' ', | 737 | network_packet ? '*' : ' ', |
738 | le16_to_cpu(rx_hdr->channel), | 738 | le16_to_cpu(rx_hdr->channel), |
739 | rx_status.ssi, rx_status.ssi, | 739 | rx_status.signal, rx_status.signal, |
740 | rx_status.ssi, rx_status.rate_idx); | 740 | rx_status.noise, rx_status.rate_idx); |
741 | 741 | ||
742 | #ifdef CONFIG_IWL3945_DEBUG | 742 | #ifdef CONFIG_IWL3945_DEBUG |
743 | if (iwl3945_debug_level & (IWL_DL_RX)) | 743 | if (iwl3945_debug_level & (IWL_DL_RX)) |
@@ -748,7 +748,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
748 | if (network_packet) { | 748 | if (network_packet) { |
749 | priv->last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp); | 749 | priv->last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp); |
750 | priv->last_tsf = le64_to_cpu(rx_end->timestamp); | 750 | priv->last_tsf = le64_to_cpu(rx_end->timestamp); |
751 | priv->last_rx_rssi = rx_status.ssi; | 751 | priv->last_rx_rssi = rx_status.signal; |
752 | priv->last_rx_noise = rx_status.noise; | 752 | priv->last_rx_noise = rx_status.noise; |
753 | } | 753 | } |
754 | 754 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index b7036e011457..45cbd7789bd0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -2362,7 +2362,7 @@ static void iwl4965_add_radiotap(struct iwl_priv *priv, | |||
2362 | struct ieee80211_rx_status *stats, | 2362 | struct ieee80211_rx_status *stats, |
2363 | u32 ampdu_status) | 2363 | u32 ampdu_status) |
2364 | { | 2364 | { |
2365 | s8 signal = stats->ssi; | 2365 | s8 signal = stats->signal; |
2366 | s8 noise = 0; | 2366 | s8 noise = 0; |
2367 | int rate = stats->rate_idx; | 2367 | int rate = stats->rate_idx; |
2368 | u64 tsf = stats->mactime; | 2368 | u64 tsf = stats->mactime; |
@@ -2963,7 +2963,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
2963 | priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp); | 2963 | priv->ucode_beacon_time = le32_to_cpu(rx_start->beacon_time_stamp); |
2964 | 2964 | ||
2965 | /* Find max signal strength (dBm) among 3 antenna/receiver chains */ | 2965 | /* Find max signal strength (dBm) among 3 antenna/receiver chains */ |
2966 | rx_status.ssi = iwl4965_calc_rssi(priv, rx_start); | 2966 | rx_status.signal = iwl4965_calc_rssi(priv, rx_start); |
2967 | 2967 | ||
2968 | /* Meaningful noise values are available only from beacon statistics, | 2968 | /* Meaningful noise values are available only from beacon statistics, |
2969 | * which are gathered only when associated, and indicate noise | 2969 | * which are gathered only when associated, and indicate noise |
@@ -2972,11 +2972,11 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
2972 | if (iwl_is_associated(priv) && | 2972 | if (iwl_is_associated(priv) && |
2973 | !test_bit(STATUS_SCANNING, &priv->status)) { | 2973 | !test_bit(STATUS_SCANNING, &priv->status)) { |
2974 | rx_status.noise = priv->last_rx_noise; | 2974 | rx_status.noise = priv->last_rx_noise; |
2975 | rx_status.signal = iwl4965_calc_sig_qual(rx_status.ssi, | 2975 | rx_status.qual = iwl4965_calc_sig_qual(rx_status.signal, |
2976 | rx_status.noise); | 2976 | rx_status.noise); |
2977 | } else { | 2977 | } else { |
2978 | rx_status.noise = IWL_NOISE_MEAS_NOT_AVAILABLE; | 2978 | rx_status.noise = IWL_NOISE_MEAS_NOT_AVAILABLE; |
2979 | rx_status.signal = iwl4965_calc_sig_qual(rx_status.ssi, 0); | 2979 | rx_status.qual = iwl4965_calc_sig_qual(rx_status.signal, 0); |
2980 | } | 2980 | } |
2981 | 2981 | ||
2982 | /* Reset beacon noise level if not associated. */ | 2982 | /* Reset beacon noise level if not associated. */ |
@@ -2988,7 +2988,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
2988 | iwl4965_dbg_report_frame(priv, pkt, header, 1); | 2988 | iwl4965_dbg_report_frame(priv, pkt, header, 1); |
2989 | 2989 | ||
2990 | IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n", | 2990 | IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n", |
2991 | rx_status.ssi, rx_status.noise, rx_status.signal, | 2991 | rx_status.signal, rx_status.noise, rx_status.signal, |
2992 | (unsigned long long)rx_status.mactime); | 2992 | (unsigned long long)rx_status.mactime); |
2993 | 2993 | ||
2994 | 2994 | ||
@@ -3000,7 +3000,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
3000 | 3000 | ||
3001 | network_packet = iwl4965_is_network_packet(priv, header); | 3001 | network_packet = iwl4965_is_network_packet(priv, header); |
3002 | if (network_packet) { | 3002 | if (network_packet) { |
3003 | priv->last_rx_rssi = rx_status.ssi; | 3003 | priv->last_rx_rssi = rx_status.signal; |
3004 | priv->last_beacon_time = priv->ucode_beacon_time; | 3004 | priv->last_beacon_time = priv->ucode_beacon_time; |
3005 | priv->last_tsf = le64_to_cpu(rx_start->timestamp); | 3005 | priv->last_tsf = le64_to_cpu(rx_start->timestamp); |
3006 | } | 3006 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 27e56b89d940..d3cbad2bf877 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -746,18 +746,10 @@ static void iwlcore_init_hw(struct iwl_priv *priv) | |||
746 | struct ieee80211_hw *hw = priv->hw; | 746 | struct ieee80211_hw *hw = priv->hw; |
747 | hw->rate_control_algorithm = "iwl-4965-rs"; | 747 | hw->rate_control_algorithm = "iwl-4965-rs"; |
748 | 748 | ||
749 | /* Tell mac80211 and its clients (e.g. Wireless Extensions) | 749 | /* Tell mac80211 our characteristics */ |
750 | * the range of signal quality values that we'll provide. | 750 | hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | |
751 | * Negative values for level/noise indicate that we'll provide dBm. | 751 | IEEE80211_HW_SIGNAL_DBM | |
752 | * For WE, at least, non-0 values here *enable* display of values | 752 | IEEE80211_HW_NOISE_DBM; |
753 | * in app (iwconfig). */ | ||
754 | hw->max_rssi = -20; /* signal level, negative indicates dBm */ | ||
755 | hw->max_noise = -20; /* noise level, negative indicates dBm */ | ||
756 | hw->max_signal = 100; /* link quality indication (%) */ | ||
757 | |||
758 | /* Tell mac80211 our Tx characteristics */ | ||
759 | hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE; | ||
760 | |||
761 | /* Default value; 4 EDCA QOS priorities */ | 753 | /* Default value; 4 EDCA QOS priorities */ |
762 | hw->queues = 4; | 754 | hw->queues = 4; |
763 | #ifdef CONFIG_IWL4965_HT | 755 | #ifdef CONFIG_IWL4965_HT |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 4baa185ba500..c1234ff4fc98 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -8029,17 +8029,10 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
8029 | 8029 | ||
8030 | priv->ibss_beacon = NULL; | 8030 | priv->ibss_beacon = NULL; |
8031 | 8031 | ||
8032 | /* Tell mac80211 and its clients (e.g. Wireless Extensions) | 8032 | /* Tell mac80211 our characteristics */ |
8033 | * the range of signal quality values that we'll provide. | 8033 | hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | |
8034 | * Negative values for level/noise indicate that we'll provide dBm. | 8034 | IEEE80211_HW_SIGNAL_DBM | |
8035 | * For WE, at least, non-0 values here *enable* display of values | 8035 | IEEE80211_HW_NOISE_DBM; |
8036 | * in app (iwconfig). */ | ||
8037 | hw->max_rssi = -20; /* signal level, negative indicates dBm */ | ||
8038 | hw->max_noise = -20; /* noise level, negative indicates dBm */ | ||
8039 | hw->max_signal = 100; /* link quality indication (%) */ | ||
8040 | |||
8041 | /* Tell mac80211 our Tx characteristics */ | ||
8042 | hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE; | ||
8043 | 8036 | ||
8044 | /* 4 EDCA QOS priorities */ | 8037 | /* 4 EDCA QOS priorities */ |
8045 | hw->queues = 4; | 8038 | hw->queues = 4; |