Skip to content

Commit fb84b5c

Browse files
jmberg-intelMiriam-Rachel
authored andcommitted
wifi: iwlwifi: mvm: fix driver-set TX rates on old devices
On old devices such as 7265D, rates are still encoded in version 1 format, which doesn't use the CCK/OFDM rate index (0-3/0-7) but rather their PLCP value (e.g. 10 for 1 Mbps CCK rate.) While introducing v3 rates, I changed the driver from internally handling v1 rates and converting to v2, to internally handling v3 and converting to v1 or v2 according to the firmware. I accordingly changed the code in iwl_mvm_mac80211_idx_to_hwrate() to no longer have different values for different APIs. This was correct. However, I later reverted this part of the change, because it was reported that I had broken beacon rates, causing a FW assert/crash. This caused TX_CMD rates to be set incorrectly, potentially causing a warning when reported back from the device as having been used. Fix this (hopefully correctly now) by handling beacon rates in the TX_CMD that's embedded in the beacon template command separately. Restore iwl_mvm_mac80211_idx_to_hwrate() to return only the rate index, not PLCP value, fixing the real TX_CMD. Cc: stable@vger.kernel.org Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://patch.msgid.link/20260515151351.7407e293dff7.I4ea1a17f8fe99c933d3f3e30d077cf4246125c3e@changeid Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
1 parent d733ed4 commit fb84b5c

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
22
/*
3-
* Copyright (C) 2012-2014, 2018-2025 Intel Corporation
3+
* Copyright (C) 2012-2014, 2018-2026 Intel Corporation
44
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH
55
* Copyright (C) 2015-2017 Intel Deutschland GmbH
66
*/
@@ -927,13 +927,18 @@ u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
927927

928928
u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw, u8 rate_idx)
929929
{
930-
u16 flags = iwl_mvm_mac80211_idx_to_hwrate(fw, rate_idx);
931930
bool is_new_rate = iwl_fw_lookup_cmd_ver(fw, BEACON_TEMPLATE_CMD, 0) > 10;
931+
u16 flags = 0;
932932

933933
if (rate_idx <= IWL_LAST_CCK_RATE)
934934
flags |= is_new_rate ? IWL_MAC_BEACON_CCK
935935
: IWL_MAC_BEACON_CCK_V1;
936936

937+
if (iwl_fw_lookup_cmd_ver(fw, TX_CMD, 0) > 8)
938+
flags |= iwl_mvm_mac80211_idx_to_hwrate(fw, rate_idx);
939+
else
940+
flags |= iwl_fw_rate_idx_to_plcp(rate_idx);
941+
937942
return flags;
938943
}
939944

@@ -962,6 +967,7 @@ static void iwl_mvm_mac_ctxt_set_tx(struct iwl_mvm *mvm,
962967
{
963968
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
964969
struct ieee80211_tx_info *info;
970+
u32 rate_n_flags = 0;
965971
u8 rate;
966972
u32 tx_flags;
967973

@@ -981,18 +987,21 @@ static void iwl_mvm_mac_ctxt_set_tx(struct iwl_mvm *mvm,
981987
IWL_UCODE_TLV_CAPA_BEACON_ANT_SELECTION)) {
982988
iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
983989

984-
tx_params->rate_n_flags =
985-
cpu_to_le32(BIT(mvm->mgmt_last_antenna_idx) <<
986-
RATE_MCS_ANT_POS);
990+
rate_n_flags |= BIT(mvm->mgmt_last_antenna_idx) <<
991+
RATE_MCS_ANT_POS;
987992
}
988993

989994
rate = iwl_mvm_mac_ctxt_get_beacon_rate(mvm, info, vif);
990995

991-
tx_params->rate_n_flags |=
992-
cpu_to_le32(iwl_mvm_mac80211_idx_to_hwrate(mvm->fw, rate));
993-
if (rate == IWL_FIRST_CCK_RATE)
994-
tx_params->rate_n_flags |= cpu_to_le32(RATE_MCS_CCK_MSK_V1);
996+
if (rate < IWL_FIRST_OFDM_RATE)
997+
rate_n_flags |= RATE_MCS_MOD_TYPE_CCK;
998+
else
999+
rate_n_flags |= RATE_MCS_MOD_TYPE_LEGACY_OFDM;
1000+
1001+
rate_n_flags |= iwl_mvm_mac80211_idx_to_hwrate(mvm->fw, rate);
9951002

1003+
tx_params->rate_n_flags = iwl_mvm_v3_rate_to_fw(rate_n_flags,
1004+
mvm->fw_rates_ver);
9961005
}
9971006

9981007
int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,

drivers/net/wireless/intel/iwlwifi/mvm/utils.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
22
/*
3-
* Copyright (C) 2012-2014, 2018-2025 Intel Corporation
3+
* Copyright (C) 2012-2014, 2018-2026 Intel Corporation
44
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH
55
* Copyright (C) 2015-2017 Intel Deutschland GmbH
66
*/
@@ -159,15 +159,9 @@ int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
159159

160160
u8 iwl_mvm_mac80211_idx_to_hwrate(const struct iwl_fw *fw, int rate_idx)
161161
{
162-
if (iwl_fw_lookup_cmd_ver(fw, TX_CMD, 0) > 8)
163-
/* In the new rate legacy rates are indexed:
164-
* 0 - 3 for CCK and 0 - 7 for OFDM.
165-
*/
166-
return (rate_idx >= IWL_FIRST_OFDM_RATE ?
167-
rate_idx - IWL_FIRST_OFDM_RATE :
168-
rate_idx);
169-
170-
return iwl_fw_rate_idx_to_plcp(rate_idx);
162+
return rate_idx >= IWL_FIRST_OFDM_RATE ?
163+
rate_idx - IWL_FIRST_OFDM_RATE :
164+
rate_idx;
171165
}
172166

173167
u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac)

0 commit comments

Comments
 (0)