wifi: iwlwifi: mvm: Fix setting the rate for non station cases
authorIlan Peer <ilan.peer@intel.com>
Fri, 14 Apr 2023 10:12:05 +0000 (13:12 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 14 Apr 2023 11:16:18 +0000 (13:16 +0200)
The setting of the rate used for non station cases did not take into
consideration the interface type etc., thus when probe responses
are transmitted on P2P Device interface etc. CCK rates were used
which is not allowed.

Modify the code so the non station case would consider the
interface type etc. For HWs/FWs that do not support rate control,
preserve the previous behavior, i.e., take the rate from the
skb metadata and adjust as needed.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230414130637.fa0e4d42205d.Iab4784560c77b965fec070d4d0a1ec84171d94ff@changeid
Signed-off-by: Johannes Berg <johannes.berg@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/tx.c

index 962d8c286fd88f47ee2dc26db611d39b54819da8..20db9fc2e61a111fc5e2e1ac0a39c1fccd0eed55 100644 (file)
@@ -870,9 +870,9 @@ static u32 iwl_mvm_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size)
        return ie - beacon;
 }
 
-static u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
-                                          struct ieee80211_tx_info *info,
-                                          struct ieee80211_vif *vif)
+u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
+                                   struct ieee80211_tx_info *info,
+                                   struct ieee80211_vif *vif)
 {
        struct ieee80211_supported_band *sband;
        unsigned long basic = vif->bss_conf.basic_rates;
@@ -892,7 +892,9 @@ static u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
                }
        }
 
-       if (info->band == NL80211_BAND_2GHZ && !vif->p2p) {
+       if (info->band == NL80211_BAND_2GHZ && !vif->p2p &&
+           vif->type != NL80211_IFTYPE_P2P_DEVICE &&
+           !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE)) {
                if (lowest_cck != IWL_RATE_COUNT)
                        rate = lowest_cck;
                else if (lowest_ofdm != IWL_RATE_COUNT)
index a4f8b5a04c64bafc4fe86e401c7da1171dff0bd3..7a8b4be8dcf23aff3c643e62539b064054a47264 100644 (file)
@@ -1786,6 +1786,9 @@ int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,
 u8 iwl_mvm_mac_ctxt_get_beacon_rate(struct iwl_mvm *mvm,
                                    struct ieee80211_tx_info *info,
                                    struct ieee80211_vif *vif);
+u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
+                                   struct ieee80211_tx_info *info,
+                                   struct ieee80211_vif *vif);
 u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw,
                                      u8 rate_idx);
 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
index 478442e16d431fe62cade917c08179e6e28346d0..8bdc98daca5c776d5d664477d80a7bf7d0ee0038 100644 (file)
@@ -329,23 +329,23 @@ static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm,
                          sta ? iwl_mvm_sta_from_mac80211(sta)->sta_state : -1);
 
                rate_idx = info->control.rates[0].idx;
+
+               /* For non 2 GHZ band, remap mac80211 rate indices into driver
+                * indices.
+                */
+               if (info->band != NL80211_BAND_2GHZ ||
+                   (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
+                       rate_idx += IWL_FIRST_OFDM_RATE;
+
+               /* For 2.4 GHZ band, check that there is no need to remap */
+               BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
        }
 
        /* if the rate isn't a well known legacy rate, take the lowest one */
        if (rate_idx < 0 || rate_idx >= IWL_RATE_COUNT_LEGACY)
-               rate_idx = rate_lowest_index(
-                               &mvm->nvm_data->bands[info->band], sta);
-
-       /*
-        * For non 2 GHZ band, remap mac80211 rate
-        * indices into driver indices
-        */
-       if (info->band != NL80211_BAND_2GHZ ||
-           (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
-               rate_idx += IWL_FIRST_OFDM_RATE;
-
-       /* For 2.4 GHZ band, check that there is no need to remap */
-       BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
+               rate_idx = iwl_mvm_mac_ctxt_get_lowest_rate(mvm,
+                                                           info,
+                                                           info->control.vif);
 
        /* Get PLCP rate for tx_cmd->rate_n_flags */
        rate_plcp = iwl_mvm_mac80211_idx_to_hwrate(mvm->fw, rate_idx);