Commit 12bacfc2 authored by Miri Korenblit's avatar Miri Korenblit Committed by Johannes Berg

wifi: iwlwifi: handle eSR transitions

There several transitions to handle in eSR mode:
* SMPS should be disabled when in eSR mode
* indicate to the fw whether the new added link should use the
  listen lmac or the main lmac
* RLC is offloaded when in eSR mode; adjust RLC command accordingly
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230615094410.fb6409f44aca.I502460dec15e0b76035ad3cd809afa4ac16e9fe1@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 823a9708
...@@ -89,6 +89,8 @@ int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -89,6 +89,8 @@ int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
if (vif->type == NL80211_IFTYPE_ADHOC && link_conf->bssid) if (vif->type == NL80211_IFTYPE_ADHOC && link_conf->bssid)
memcpy(cmd.ibss_bssid_addr, link_conf->bssid, ETH_ALEN); memcpy(cmd.ibss_bssid_addr, link_conf->bssid, ETH_ALEN);
cmd.listen_lmac = cpu_to_le32(link_info->listen_lmac);
return iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_ADD); return iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_ADD);
} }
...@@ -149,10 +151,6 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -149,10 +151,6 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
if (vif->type == NL80211_IFTYPE_ADHOC && link_conf->bssid) if (vif->type == NL80211_IFTYPE_ADHOC && link_conf->bssid)
memcpy(cmd.ibss_bssid_addr, link_conf->bssid, ETH_ALEN); memcpy(cmd.ibss_bssid_addr, link_conf->bssid, ETH_ALEN);
/* TODO: set a value to cmd.listen_lmac when system requiremens
* will define it
*/
iwl_mvm_set_fw_basic_rates(mvm, vif, link_conf, iwl_mvm_set_fw_basic_rates(mvm, vif, link_conf,
&cmd.cck_rates, &cmd.ofdm_rates); &cmd.cck_rates, &cmd.ofdm_rates);
...@@ -228,6 +226,7 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -228,6 +226,7 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
cmd.flags = cpu_to_le32(flags); cmd.flags = cpu_to_le32(flags);
cmd.flags_mask = cpu_to_le32(flags_mask); cmd.flags_mask = cpu_to_le32(flags_mask);
cmd.spec_link_id = link_conf->link_id; cmd.spec_link_id = link_conf->link_id;
cmd.listen_lmac = cpu_to_le32(link_info->listen_lmac);
ret = iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_MODIFY); ret = iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_MODIFY);
if (!ret && (changes & LINK_CONTEXT_MODIFY_ACTIVE)) if (!ret && (changes & LINK_CONTEXT_MODIFY_ACTIVE))
......
...@@ -215,6 +215,53 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw, ...@@ -215,6 +215,53 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw,
mutex_unlock(&mvm->mutex); mutex_unlock(&mvm->mutex);
} }
static unsigned int iwl_mvm_mld_count_active_links(struct ieee80211_vif *vif)
{
unsigned int n_active = 0;
int i;
for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
struct ieee80211_bss_conf *link_conf;
link_conf = link_conf_dereference_protected(vif, i);
if (link_conf &&
rcu_access_pointer(link_conf->chanctx_conf))
n_active++;
}
return n_active;
}
static int iwl_mvm_esr_mode_active(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
int link_id, ret = 0;
mvmvif->esr_active = true;
/* Disable SMPS overrideing by user */
vif->driver_flags |= IEEE80211_VIF_DISABLE_SMPS_OVERRIDE;
iwl_mvm_update_smps_on_active_links(mvm, vif, IWL_MVM_SMPS_REQ_FW,
IEEE80211_SMPS_OFF);
for_each_mvm_vif_valid_link(mvmvif, link_id) {
struct iwl_mvm_vif_link_info *link = mvmvif->link[link_id];
if (!link->phy_ctxt)
continue;
ret = iwl_mvm_phy_send_rlc(mvm, link->phy_ctxt, 2, 2);
if (ret)
break;
link->phy_ctxt->rlc_disabled = true;
}
return ret;
}
static int static int
__iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm, __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
...@@ -224,10 +271,18 @@ __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm, ...@@ -224,10 +271,18 @@ __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
{ {
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
unsigned int n_active = iwl_mvm_mld_count_active_links(vif);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
unsigned int link_id = link_conf->link_id; unsigned int link_id = link_conf->link_id;
int ret; int ret;
/* if the assigned one was not counted yet, count it now */
if (!rcu_access_pointer(link_conf->chanctx_conf))
n_active++;
if (n_active > iwl_mvm_max_active_links(mvm, vif))
return -EOPNOTSUPP;
if (WARN_ON_ONCE(!mvmvif->link[link_id])) if (WARN_ON_ONCE(!mvmvif->link[link_id]))
return -EINVAL; return -EINVAL;
...@@ -243,6 +298,15 @@ __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm, ...@@ -243,6 +298,15 @@ __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
} }
} }
if (iwl_mvm_is_esr_supported(mvm->fwrt.trans) && n_active > 1) {
mvmvif->link[link_id]->listen_lmac = true;
ret = iwl_mvm_esr_mode_active(mvm, vif);
if (ret) {
IWL_ERR(mvm, "failed to activate ESR mode (%d)\n", ret);
return ret;
}
}
mvmvif->link[link_id]->phy_ctxt = phy_ctxt; mvmvif->link[link_id]->phy_ctxt = phy_ctxt;
if (switching_chanctx) { if (switching_chanctx) {
...@@ -326,14 +390,62 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw, ...@@ -326,14 +390,62 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw,
return ret; return ret;
} }
static int iwl_mvm_esr_mode_inactive(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct ieee80211_bss_conf *link_conf;
int link_id, ret = 0;
mvmvif->esr_active = false;
vif->driver_flags &= ~IEEE80211_VIF_DISABLE_SMPS_OVERRIDE;
iwl_mvm_update_smps_on_active_links(mvm, vif, IWL_MVM_SMPS_REQ_FW,
IEEE80211_SMPS_AUTOMATIC);
for_each_vif_active_link(vif, link_conf, link_id) {
struct ieee80211_chanctx_conf *chanctx_conf;
struct iwl_mvm_phy_ctxt *phy_ctxt;
u8 static_chains, dynamic_chains;
mvmvif->link[link_id]->listen_lmac = false;
rcu_read_lock();
chanctx_conf = rcu_dereference(link_conf->chanctx_conf);
phy_ctxt = mvmvif->link[link_id]->phy_ctxt;
if (!chanctx_conf || !phy_ctxt) {
rcu_read_unlock();
continue;
}
phy_ctxt->rlc_disabled = false;
static_chains = chanctx_conf->rx_chains_static;
dynamic_chains = chanctx_conf->rx_chains_dynamic;
rcu_read_unlock();
ret = iwl_mvm_phy_send_rlc(mvm, phy_ctxt, static_chains,
dynamic_chains);
if (ret)
break;
}
return ret;
}
static void static void
__iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm, __iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf, struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx, struct ieee80211_chanctx_conf *ctx,
bool switching_chanctx) bool switching_chanctx)
{ {
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
unsigned int n_active = iwl_mvm_mld_count_active_links(vif);
unsigned int link_id = link_conf->link_id; unsigned int link_id = link_conf->link_id;
/* shouldn't happen, but verify link_id is valid before accessing */ /* shouldn't happen, but verify link_id is valid before accessing */
...@@ -352,6 +464,14 @@ __iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm, ...@@ -352,6 +464,14 @@ __iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm,
mvmvif->ap_ibss_active = false; mvmvif->ap_ibss_active = false;
} }
if (iwl_mvm_is_esr_supported(mvm->fwrt.trans) && n_active > 1) {
int ret = iwl_mvm_esr_mode_inactive(mvm, vif);
if (ret)
IWL_ERR(mvm, "failed to deactivate ESR mode (%d)\n",
ret);
}
if (vif->type == NL80211_IFTYPE_MONITOR) if (vif->type == NL80211_IFTYPE_MONITOR)
iwl_mvm_mld_rm_snif_sta(mvm, vif); iwl_mvm_mld_rm_snif_sta(mvm, vif);
...@@ -894,31 +1014,16 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw, ...@@ -894,31 +1014,16 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]) struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS])
{ {
struct iwl_mvm_vif_link_info *new_link[IEEE80211_MLD_MAX_NUM_LINKS] = {}; struct iwl_mvm_vif_link_info *new_link[IEEE80211_MLD_MAX_NUM_LINKS] = {};
unsigned int n_active = iwl_mvm_mld_count_active_links(vif);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
u16 removed = old_links & ~new_links; u16 removed = old_links & ~new_links;
u16 added = new_links & ~old_links; u16 added = new_links & ~old_links;
int err, i; int err, i;
if (hweight16(new_links) > 1) { if (hweight16(new_links) > 1 &&
unsigned int n_active = 0; n_active > iwl_mvm_max_active_links(mvm, vif))
for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
struct ieee80211_bss_conf *link_conf;
link_conf = link_conf_dereference_protected(vif, i);
if (link_conf &&
rcu_access_pointer(link_conf->chanctx_conf))
n_active++;
}
if (vif->type == NL80211_IFTYPE_AP) {
if (n_active > mvm->fw->ucode_capa.num_beacons)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} else if (n_active > iwl_mvm_max_active_links(mvm)) {
return -EOPNOTSUPP;
}
}
for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) { for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
int r; int r;
...@@ -962,9 +1067,7 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw, ...@@ -962,9 +1067,7 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw,
goto out_err; goto out_err;
kfree(mvmvif->link[i]); kfree(mvmvif->link[i]);
mvmvif->link[i] = NULL; mvmvif->link[i] = NULL;
} } else if (added & BIT(i)) {
if (added & BIT(i)) {
struct ieee80211_bss_conf *link_conf; struct ieee80211_bss_conf *link_conf;
link_conf = link_conf_dereference_protected(vif, i); link_conf = link_conf_dereference_protected(vif, i);
...@@ -981,6 +1084,9 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw, ...@@ -981,6 +1084,9 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw,
} }
} }
if (err)
goto out_err;
err = 0; err = 0;
if (new_links == 0) { if (new_links == 0) {
mvmvif->link[0] = &mvmvif->deflink; mvmvif->link[0] = &mvmvif->deflink;
......
...@@ -104,6 +104,7 @@ struct iwl_mvm_phy_ctxt { ...@@ -104,6 +104,7 @@ struct iwl_mvm_phy_ctxt {
/* track for RLC config command */ /* track for RLC config command */
u32 center_freq1; u32 center_freq1;
bool rlc_disabled;
}; };
struct iwl_mvm_time_event_data { struct iwl_mvm_time_event_data {
...@@ -301,6 +302,7 @@ struct iwl_probe_resp_data { ...@@ -301,6 +302,7 @@ struct iwl_probe_resp_data {
* @queue_params: QoS params for this MAC * @queue_params: QoS params for this MAC
* @mgmt_queue: queue number for unbufferable management frames * @mgmt_queue: queue number for unbufferable management frames
* @igtk: the current IGTK programmed into the firmware * @igtk: the current IGTK programmed into the firmware
* @listen_lmac: indicates this link is allocated to the listen LMAC
*/ */
struct iwl_mvm_vif_link_info { struct iwl_mvm_vif_link_info {
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
...@@ -322,6 +324,7 @@ struct iwl_mvm_vif_link_info { ...@@ -322,6 +324,7 @@ struct iwl_mvm_vif_link_info {
bool he_ru_2mhz_block; bool he_ru_2mhz_block;
bool active; bool active;
bool listen_lmac;
u16 cab_queue; u16 cab_queue;
/* Assigned while mac80211 has the link in a channel context, /* Assigned while mac80211 has the link in a channel context,
...@@ -373,6 +376,7 @@ struct iwl_mvm_vif { ...@@ -373,6 +376,7 @@ struct iwl_mvm_vif {
bool ap_ibss_active; bool ap_ibss_active;
bool pm_enabled; bool pm_enabled;
bool monitor_active; bool monitor_active;
bool esr_active;
u8 low_latency: 6; u8 low_latency: 6;
u8 low_latency_actual: 1; u8 low_latency_actual: 1;
...@@ -1554,10 +1558,14 @@ static inline bool iwl_mvm_is_esr_supported(struct iwl_trans *trans) ...@@ -1554,10 +1558,14 @@ static inline bool iwl_mvm_is_esr_supported(struct iwl_trans *trans)
return false; return false;
} }
static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm) static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{ {
struct iwl_trans *trans = mvm->fwrt.trans; struct iwl_trans *trans = mvm->fwrt.trans;
if (vif->type == NL80211_IFTYPE_AP)
return mvm->fw->ucode_capa.num_beacons;
if (iwl_mvm_is_esr_supported(trans) || if (iwl_mvm_is_esr_supported(trans) ||
(CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM && (CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM &&
CSR_HW_RFID_IS_CDB(trans->hw_rf_id))) CSR_HW_RFID_IS_CDB(trans->hw_rf_id)))
...@@ -1777,6 +1785,8 @@ void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, ...@@ -1777,6 +1785,8 @@ void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm); int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef); u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef);
u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef); u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef);
int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
u8 chains_static, u8 chains_dynamic);
/* MAC (virtual interface) programming */ /* MAC (virtual interface) programming */
......
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/* /*
* Copyright (C) 2012-2014, 2018-2022 Intel Corporation * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
* Copyright (C) 2017 Intel Deutschland GmbH * Copyright (C) 2017 Intel Deutschland GmbH
*/ */
...@@ -163,15 +163,18 @@ static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm, ...@@ -163,15 +163,18 @@ static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm,
chains_static, chains_dynamic); chains_static, chains_dynamic);
} }
static int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
struct iwl_mvm_phy_ctxt *ctxt,
u8 chains_static, u8 chains_dynamic) u8 chains_static, u8 chains_dynamic)
{ {
struct iwl_rlc_config_cmd cmd = { struct iwl_rlc_config_cmd cmd = {
.phy_id = cpu_to_le32(ctxt->id), .phy_id = cpu_to_le32(ctxt->id),
}; };
if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(DATA_PATH_GROUP, RLC_CONFIG_CMD), 0) < 2) if (ctxt->rlc_disabled)
return 0;
if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(DATA_PATH_GROUP,
RLC_CONFIG_CMD), 0) < 2)
return 0; return 0;
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_DRIVER_FORCE != BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_DRIVER_FORCE !=
......
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/* /*
* Copyright (C) 2012-2014, 2018-2022 Intel Corporation * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
* Copyright (C) 2015-2017 Intel Deutschland GmbH * Copyright (C) 2015-2017 Intel Deutschland GmbH
*/ */
...@@ -312,6 +312,10 @@ void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -312,6 +312,10 @@ void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
smps_mode = IEEE80211_SMPS_DYNAMIC; smps_mode = IEEE80211_SMPS_DYNAMIC;
} }
/* SMPS is disabled in eSR */
if (mvmvif->esr_active)
smps_mode = IEEE80211_SMPS_OFF;
ieee80211_request_smps(vif, link_id, smps_mode); ieee80211_request_smps(vif, link_id, smps_mode);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment