iwlwifi: mvm: fix signal reporting for < 3 antennas
authorAvri Altman <avri.altman@intel.com>
Thu, 1 Aug 2013 04:19:27 +0000 (07:19 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 6 Aug 2013 08:32:38 +0000 (10:32 +0200)
When fewer than three antennas are connected (as is
always the case for the current devices), the signal
strength reporting was wrong; fix it.

Signed-off-by: Avri Altman <avri.altman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/iwlwifi/mvm/rx.c

index 5057fd3bcb50da6bea1629fce9b38d0c33d96e72..ee6547d2228782835fb8d4fe5050973bc3df52a7 100644 (file)
@@ -167,6 +167,9 @@ static void iwl_mvm_calc_rssi(struct iwl_mvm *mvm,
 
 /*
  * iwl_mvm_get_signal_strength - use new rx PHY INFO API
+ * values are reported by the fw as positive values - need to negate
+ * to obtain their dBM.  Account for missing antennas by replacing 0
+ * values by -256dBm: practically 0 power and a non-feasible 8 bit value.
  */
 static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,
                                        struct iwl_rx_phy_info *phy_info,
@@ -177,12 +180,15 @@ static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,
 
        val =
            le32_to_cpu(phy_info->non_cfg_phy[IWL_RX_INFO_ENERGY_ANT_ABC_IDX]);
-       energy_a = -((val & IWL_RX_INFO_ENERGY_ANT_A_MSK) >>
-                                               IWL_RX_INFO_ENERGY_ANT_A_POS);
-       energy_b = -((val & IWL_RX_INFO_ENERGY_ANT_B_MSK) >>
-                                               IWL_RX_INFO_ENERGY_ANT_B_POS);
-       energy_c = -((val & IWL_RX_INFO_ENERGY_ANT_C_MSK) >>
-                                               IWL_RX_INFO_ENERGY_ANT_C_POS);
+       energy_a = (val & IWL_RX_INFO_ENERGY_ANT_A_MSK) >>
+                                               IWL_RX_INFO_ENERGY_ANT_A_POS;
+       energy_a = energy_a ? -energy_a : -256;
+       energy_b = (val & IWL_RX_INFO_ENERGY_ANT_B_MSK) >>
+                                               IWL_RX_INFO_ENERGY_ANT_B_POS;
+       energy_b = energy_b ? -energy_b : -256;
+       energy_c = (val & IWL_RX_INFO_ENERGY_ANT_C_MSK) >>
+                                               IWL_RX_INFO_ENERGY_ANT_C_POS;
+       energy_c = energy_c ? -energy_c : -256;
        max_energy = max(energy_a, energy_b);
        max_energy = max(max_energy, energy_c);