iwlwifi: mvm: switch management tx antenna only on tx failure
authorAvraham Stern <avraham.stern@intel.com>
Thu, 5 Jul 2018 14:34:03 +0000 (17:34 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Sun, 11 Nov 2018 09:06:16 +0000 (11:06 +0200)
Switch the antenna used for management tx only if previous tx failed.
If previous tx succeeded, there is no reason to switch antennas.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/mvm/scan.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c

index 6486cfb33f403d478680aca1ae489a843e81e24e..b9c45a40e251cec1d1876905fca649367053af02 100644 (file)
@@ -965,11 +965,8 @@ static void iwl_mvm_mac_ctxt_set_tx(struct iwl_mvm *mvm,
        tx->tx_flags = cpu_to_le32(tx_flags);
 
        if (!fw_has_capa(&mvm->fw->ucode_capa,
-                        IWL_UCODE_TLV_CAPA_BEACON_ANT_SELECTION)) {
-               mvm->mgmt_last_antenna_idx =
-                       iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm),
-                                            mvm->mgmt_last_antenna_idx);
-       }
+                        IWL_UCODE_TLV_CAPA_BEACON_ANT_SELECTION))
+               iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
 
        tx->rate_n_flags =
                cpu_to_le32(BIT(mvm->mgmt_last_antenna_idx) <<
index 03fdc8b1892df9955d6cf8672c11e2a9d3c948dd..707bc7d1f37fb585c8ab14973b1a11a92c7f9e01 100644 (file)
@@ -1522,6 +1522,11 @@ static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm)
               mvm->fw->valid_rx_ant;
 }
 
+static inline void iwl_mvm_toggle_tx_ant(struct iwl_mvm *mvm, u8 *ant)
+{
+       *ant = iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), *ant);
+}
+
 static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm)
 {
        u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN |
index 758aa1f75ca1e34df307f195278fb54db186427d..0d5b55ed8dda80e8a9f4261f2245d198c6d025d6 100644 (file)
@@ -845,6 +845,8 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
 
        iwl_mvm_tof_init(mvm);
 
+       iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
+
        return op_mode;
 
  out_unregister:
index cfb784fea77bbce100b64c03765c826ce7c271a1..cb376e869144c65e824702c5f58663e14f02954f 100644 (file)
@@ -205,9 +205,7 @@ iwl_mvm_scan_rate_n_flags(struct iwl_mvm *mvm, enum nl80211_band band,
 {
        u32 tx_ant;
 
-       mvm->scan_last_antenna_idx =
-               iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm),
-                                    mvm->scan_last_antenna_idx);
+       iwl_mvm_toggle_tx_ant(mvm, &mvm->scan_last_antenna_idx);
        tx_ant = BIT(mvm->scan_last_antenna_idx) << RATE_MCS_ANT_POS;
 
        if (band == NL80211_BAND_2GHZ && !no_cck)
index 320453f51ec72c3456b7d972aa6be8daa27c5bdf..ac4fa03639423a0b38ebf18315789bb05b75d01d 100644 (file)
@@ -381,10 +381,6 @@ void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
                        cpu_to_le32(TX_CMD_FLG_ACK | TX_CMD_FLG_BAR);
        }
 
-       mvm->mgmt_last_antenna_idx =
-               iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm),
-                                    mvm->mgmt_last_antenna_idx);
-
        /* Set the rate in the TX cmd */
        tx_cmd->rate_n_flags = cpu_to_le32(iwl_mvm_get_tx_rate(mvm, info, sta));
 }
@@ -1501,6 +1497,10 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
                        break;
                }
 
+               if ((status & TX_STATUS_MSK) != TX_STATUS_SUCCESS &&
+                   ieee80211_is_mgmt(hdr->frame_control))
+                       iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
+
                /*
                 * If we are freeing multiple frames, mark all the frames
                 * but the first one as acked, since they were acknowledged