2020-12-09 22:06:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
|
|
|
/*
|
2024-06-17 07:19:40 +00:00
|
|
|
* Copyright (C) 2012-2014, 2018-2024 Intel Corporation
|
2020-12-09 22:06:03 +00:00
|
|
|
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH
|
|
|
|
* Copyright (C) 2017 Intel Deutschland GmbH
|
|
|
|
*/
|
2013-01-24 13:25:36 +00:00
|
|
|
#include <net/mac80211.h>
|
|
|
|
#include "fw-api.h"
|
|
|
|
#include "mvm.h"
|
|
|
|
|
2015-03-31 09:24:05 +00:00
|
|
|
/* Maps the driver specific channel width definition to the fw values */
|
2024-06-17 07:19:22 +00:00
|
|
|
u8 iwl_mvm_get_channel_width(const struct cfg80211_chan_def *chandef)
|
2013-01-24 13:25:36 +00:00
|
|
|
{
|
|
|
|
switch (chandef->width) {
|
|
|
|
case NL80211_CHAN_WIDTH_20_NOHT:
|
|
|
|
case NL80211_CHAN_WIDTH_20:
|
2023-05-09 06:16:06 +00:00
|
|
|
return IWL_PHY_CHANNEL_MODE20;
|
2013-01-24 13:25:36 +00:00
|
|
|
case NL80211_CHAN_WIDTH_40:
|
2023-05-09 06:16:06 +00:00
|
|
|
return IWL_PHY_CHANNEL_MODE40;
|
2013-01-24 13:25:36 +00:00
|
|
|
case NL80211_CHAN_WIDTH_80:
|
2023-05-09 06:16:06 +00:00
|
|
|
return IWL_PHY_CHANNEL_MODE80;
|
2013-01-24 13:25:36 +00:00
|
|
|
case NL80211_CHAN_WIDTH_160:
|
2023-05-09 06:16:06 +00:00
|
|
|
return IWL_PHY_CHANNEL_MODE160;
|
|
|
|
case NL80211_CHAN_WIDTH_320:
|
|
|
|
return IWL_PHY_CHANNEL_MODE320;
|
2013-01-24 13:25:36 +00:00
|
|
|
default:
|
|
|
|
WARN(1, "Invalid channel width=%u", chandef->width);
|
2023-05-09 06:16:06 +00:00
|
|
|
return IWL_PHY_CHANNEL_MODE20;
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maps the driver specific control channel position (relative to the center
|
|
|
|
* freq) definitions to the the fw values
|
|
|
|
*/
|
2024-06-17 07:19:22 +00:00
|
|
|
u8 iwl_mvm_get_ctrl_pos(const struct cfg80211_chan_def *chandef)
|
2013-01-24 13:25:36 +00:00
|
|
|
{
|
2023-05-09 06:16:06 +00:00
|
|
|
int offs = chandef->chan->center_freq - chandef->center_freq1;
|
|
|
|
int abs_offs = abs(offs);
|
|
|
|
u8 ret;
|
|
|
|
|
|
|
|
if (offs == 0) {
|
2013-01-24 13:25:36 +00:00
|
|
|
/*
|
|
|
|
* The FW is expected to check the control channel position only
|
|
|
|
* when in HT/VHT and the channel width is not 20MHz. Return
|
|
|
|
* this value as the default one.
|
|
|
|
*/
|
2023-05-09 06:16:06 +00:00
|
|
|
return 0;
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
2023-05-09 06:16:06 +00:00
|
|
|
|
|
|
|
/* this results in a value 0-7, i.e. fitting into 0b0111 */
|
|
|
|
ret = (abs_offs - 10) / 20;
|
|
|
|
/*
|
|
|
|
* But we need the value to be in 0b1011 because 0b0100 is
|
|
|
|
* IWL_PHY_CTRL_POS_ABOVE, so shift bit 2 up to land in
|
|
|
|
* IWL_PHY_CTRL_POS_OFFS_EXT (0b1000)
|
|
|
|
*/
|
|
|
|
ret = (ret & IWL_PHY_CTRL_POS_OFFS_MSK) |
|
|
|
|
((ret & BIT(2)) << 1);
|
|
|
|
/* and add the above bit */
|
|
|
|
ret |= (offs > 0) * IWL_PHY_CTRL_POS_ABOVE;
|
|
|
|
|
|
|
|
return ret;
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Construct the generic fields of the PHY context command
|
|
|
|
*/
|
|
|
|
static void iwl_mvm_phy_ctxt_cmd_hdr(struct iwl_mvm_phy_ctxt *ctxt,
|
|
|
|
struct iwl_phy_context_cmd *cmd,
|
2020-09-30 13:31:23 +00:00
|
|
|
u32 action)
|
2013-01-24 13:25:36 +00:00
|
|
|
{
|
|
|
|
cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(ctxt->id,
|
|
|
|
ctxt->color));
|
|
|
|
cmd->action = cpu_to_le32(action);
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:31:23 +00:00
|
|
|
static void iwl_mvm_phy_ctxt_set_rxchain(struct iwl_mvm *mvm,
|
2021-06-17 07:08:43 +00:00
|
|
|
struct iwl_mvm_phy_ctxt *ctxt,
|
2020-09-30 13:31:23 +00:00
|
|
|
__le32 *rxchain_info,
|
|
|
|
u8 chains_static,
|
|
|
|
u8 chains_dynamic)
|
2013-01-24 13:25:36 +00:00
|
|
|
{
|
2013-03-09 18:38:19 +00:00
|
|
|
u8 active_cnt, idle_cnt;
|
2013-01-24 13:25:36 +00:00
|
|
|
|
|
|
|
/* Set rx the chains */
|
|
|
|
idle_cnt = chains_static;
|
|
|
|
active_cnt = chains_dynamic;
|
|
|
|
|
2014-05-12 09:14:51 +00:00
|
|
|
/* In scenarios where we only ever use a single-stream rates,
|
|
|
|
* i.e. legacy 11b/g/a associations, single-stream APs or even
|
|
|
|
* static SMPS, enable both chains to get diversity, improving
|
|
|
|
* the case where we're far enough from the AP that attenuation
|
|
|
|
* between the two antennas is sufficiently different to impact
|
|
|
|
* performance.
|
|
|
|
*/
|
2021-06-17 07:08:43 +00:00
|
|
|
if (active_cnt == 1 && iwl_mvm_rx_diversity_allowed(mvm, ctxt)) {
|
2014-05-12 09:14:51 +00:00
|
|
|
idle_cnt = 2;
|
|
|
|
active_cnt = 2;
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:31:23 +00:00
|
|
|
*rxchain_info = cpu_to_le32(iwl_mvm_get_valid_rx_ant(mvm) <<
|
2013-01-24 13:25:36 +00:00
|
|
|
PHY_RX_CHAIN_VALID_POS);
|
2020-09-30 13:31:23 +00:00
|
|
|
*rxchain_info |= cpu_to_le32(idle_cnt << PHY_RX_CHAIN_CNT_POS);
|
|
|
|
*rxchain_info |= cpu_to_le32(active_cnt <<
|
2013-01-24 13:25:36 +00:00
|
|
|
PHY_RX_CHAIN_MIMO_CNT_POS);
|
2015-03-07 17:35:37 +00:00
|
|
|
#ifdef CONFIG_IWLWIFI_DEBUGFS
|
2015-02-08 08:56:43 +00:00
|
|
|
if (unlikely(mvm->dbgfs_rx_phyinfo))
|
2020-09-30 13:31:23 +00:00
|
|
|
*rxchain_info = cpu_to_le32(mvm->dbgfs_rx_phyinfo);
|
2015-03-07 17:35:37 +00:00
|
|
|
#endif
|
2020-09-30 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the phy configuration to the PHY context command
|
|
|
|
*/
|
|
|
|
static void iwl_mvm_phy_ctxt_cmd_data_v1(struct iwl_mvm *mvm,
|
2021-06-17 07:08:43 +00:00
|
|
|
struct iwl_mvm_phy_ctxt *ctxt,
|
2020-09-30 13:31:23 +00:00
|
|
|
struct iwl_phy_context_cmd_v1 *cmd,
|
2024-06-17 07:19:22 +00:00
|
|
|
const struct cfg80211_chan_def *chandef,
|
2020-09-30 13:31:23 +00:00
|
|
|
u8 chains_static, u8 chains_dynamic)
|
|
|
|
{
|
|
|
|
struct iwl_phy_context_cmd_tail *tail =
|
|
|
|
iwl_mvm_chan_info_cmd_tail(mvm, &cmd->ci);
|
|
|
|
|
|
|
|
/* Set the channel info data */
|
|
|
|
iwl_mvm_set_chan_info_chandef(mvm, &cmd->ci, chandef);
|
|
|
|
|
2021-06-17 07:08:43 +00:00
|
|
|
iwl_mvm_phy_ctxt_set_rxchain(mvm, ctxt, &tail->rxchain_info,
|
2020-09-30 13:31:23 +00:00
|
|
|
chains_static, chains_dynamic);
|
2013-01-24 13:25:36 +00:00
|
|
|
|
2018-11-18 16:01:43 +00:00
|
|
|
tail->txchain_info = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm));
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
|
|
|
|
2020-09-30 13:31:23 +00:00
|
|
|
/*
|
|
|
|
* Add the phy configuration to the PHY context command
|
|
|
|
*/
|
|
|
|
static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm,
|
2021-06-17 07:08:43 +00:00
|
|
|
struct iwl_mvm_phy_ctxt *ctxt,
|
2020-09-30 13:31:23 +00:00
|
|
|
struct iwl_phy_context_cmd *cmd,
|
2024-06-17 07:19:22 +00:00
|
|
|
const struct cfg80211_chan_def *chandef,
|
2020-09-30 13:31:23 +00:00
|
|
|
u8 chains_static, u8 chains_dynamic)
|
|
|
|
{
|
2023-11-27 14:01:31 +00:00
|
|
|
cmd->lmac_id = cpu_to_le32(iwl_mvm_get_lmac_id(mvm,
|
2020-10-08 15:09:46 +00:00
|
|
|
chandef->chan->band));
|
2020-09-30 13:31:23 +00:00
|
|
|
|
|
|
|
/* Set the channel info data */
|
|
|
|
iwl_mvm_set_chan_info_chandef(mvm, &cmd->ci, chandef);
|
|
|
|
|
2022-05-31 12:49:40 +00:00
|
|
|
/* we only support RLC command version 2 */
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Bugzilla: https://bugzilla.redhat.com/2059999
commit 971cbe50e6362a69fb2ef2d20eca1432624452cc
Author: Johannes Berg <johannes.berg@intel.com>
Date: Fri Jan 28 15:34:25 2022 +0200
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 12:50:46 +00:00
|
|
|
if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(DATA_PATH_GROUP, RLC_CONFIG_CMD), 0) < 2)
|
2022-05-31 12:49:40 +00:00
|
|
|
iwl_mvm_phy_ctxt_set_rxchain(mvm, ctxt, &cmd->rxchain_info,
|
|
|
|
chains_static, chains_dynamic);
|
|
|
|
}
|
|
|
|
|
2023-11-27 14:01:36 +00:00
|
|
|
int iwl_mvm_phy_send_rlc(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
|
|
|
|
u8 chains_static, u8 chains_dynamic)
|
2022-05-31 12:49:40 +00:00
|
|
|
{
|
|
|
|
struct iwl_rlc_config_cmd cmd = {
|
|
|
|
.phy_id = cpu_to_le32(ctxt->id),
|
|
|
|
};
|
|
|
|
|
wifi: iwlwifi: mvm: Offload RLC/SMPS functionality to firmware
JIRA: https://issues.redhat.com/browse/RHEL-67113
commit b2a7c91bf93865a34e04707ef600c1c363d79125
Author: Daniel Gabay <daniel.gabay@intel.com>
Date: Thu Aug 8 23:22:37 2024 +0300
wifi: iwlwifi: mvm: Offload RLC/SMPS functionality to firmware
Currently, the driver handles SMPS decisions by tracking AP
capabilities, BT coexistence changes, sending necessary SMPS
frames to the AP, and updating firmware with RX chain info
using the RLC_CONFIG_CMD.
Starting with version 3 of the RLC_CONFIG_CMD, the firmware
takes over this responsibility. It now tracks SMPS, sends
frames, and configures the RLC.
In this patch:
1. Stop sending RLC_CONFIG_CMD when firmware supports RLC
offload (version 3), as rlc.rx_chain_info is not needed by
firmware, and no other field in the cmd is used.
2. Prevent the driver from forwarding any SMPS requests to
mac80211, i.e., the driver should not transmit SMPS frames
to the AP as firmware handles that.
3. Set NL80211_FEATURE_DYNAMIC_SMPS and NL80211_FEATURE_STATIC_SMPS
conditionally based on RLC version.
Signed-off-by: Daniel Gabay <daniel.gabay@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20240808232017.45da23be1f65.I0d46db82dd990a82e8a66876fe2f5310bc9513be@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-11-22 09:57:59 +00:00
|
|
|
/* From version 3, RLC is offloaded to firmware, so the driver no
|
|
|
|
* longer needs to send cmd.rlc, note that we are not using any
|
|
|
|
* other fields in the command - don't send it.
|
|
|
|
*/
|
|
|
|
if (iwl_mvm_has_rlc_offload(mvm) || ctxt->rlc_disabled)
|
2023-11-27 14:01:36 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(DATA_PATH_GROUP,
|
|
|
|
RLC_CONFIG_CMD), 0) < 2)
|
2022-05-31 12:49:40 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_DRIVER_FORCE !=
|
|
|
|
PHY_RX_CHAIN_DRIVER_FORCE_MSK);
|
|
|
|
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_VALID !=
|
|
|
|
PHY_RX_CHAIN_VALID_MSK);
|
|
|
|
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_FORCE !=
|
|
|
|
PHY_RX_CHAIN_FORCE_SEL_MSK);
|
|
|
|
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_FORCE_MIMO !=
|
|
|
|
PHY_RX_CHAIN_FORCE_MIMO_SEL_MSK);
|
|
|
|
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_COUNT != PHY_RX_CHAIN_CNT_MSK);
|
|
|
|
BUILD_BUG_ON(IWL_RLC_CHAIN_INFO_MIMO_COUNT !=
|
|
|
|
PHY_RX_CHAIN_MIMO_CNT_MSK);
|
|
|
|
|
|
|
|
iwl_mvm_phy_ctxt_set_rxchain(mvm, ctxt, &cmd.rlc.rx_chain_info,
|
2020-09-30 13:31:23 +00:00
|
|
|
chains_static, chains_dynamic);
|
2022-05-31 12:49:40 +00:00
|
|
|
|
2024-02-01 14:29:53 +00:00
|
|
|
IWL_DEBUG_FW(mvm, "Send RLC command: phy=%d, rx_chain_info=0x%x\n",
|
|
|
|
ctxt->id, cmd.rlc.rx_chain_info);
|
|
|
|
|
2022-05-31 12:49:40 +00:00
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(RLC_CONFIG_CMD,
|
|
|
|
DATA_PATH_GROUP, 2),
|
|
|
|
0, sizeof(cmd), &cmd);
|
2020-09-30 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 13:25:36 +00:00
|
|
|
/*
|
|
|
|
* Send a command to apply the current phy configuration. The command is send
|
|
|
|
* only if something in the configuration changed: in case that this is the
|
|
|
|
* first time that the phy configuration is applied or in case that the phy
|
|
|
|
* configuration changed from the previous apply.
|
|
|
|
*/
|
|
|
|
static int iwl_mvm_phy_ctxt_apply(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_phy_ctxt *ctxt,
|
2024-06-17 07:19:22 +00:00
|
|
|
const struct cfg80211_chan_def *chandef,
|
2024-06-17 07:19:40 +00:00
|
|
|
const struct cfg80211_chan_def *ap,
|
2013-01-24 13:25:36 +00:00
|
|
|
u8 chains_static, u8 chains_dynamic,
|
2020-09-30 13:31:23 +00:00
|
|
|
u32 action)
|
2013-01-24 13:25:36 +00:00
|
|
|
{
|
|
|
|
int ret;
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Bugzilla: https://bugzilla.redhat.com/2059999
commit 971cbe50e6362a69fb2ef2d20eca1432624452cc
Author: Johannes Berg <johannes.berg@intel.com>
Date: Fri Jan 28 15:34:25 2022 +0200
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 12:50:46 +00:00
|
|
|
int ver = iwl_fw_lookup_cmd_ver(mvm->fw, PHY_CONTEXT_CMD, 1);
|
2020-09-30 13:31:23 +00:00
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
if (ver < 5 || !ap || !ap->chan)
|
|
|
|
ap = NULL;
|
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
if (ver >= 3 && ver <= 6) {
|
2020-09-30 13:31:23 +00:00
|
|
|
struct iwl_phy_context_cmd cmd = {};
|
2013-01-24 13:25:36 +00:00
|
|
|
|
2020-09-30 13:31:23 +00:00
|
|
|
/* Set the command header fields */
|
|
|
|
iwl_mvm_phy_ctxt_cmd_hdr(ctxt, &cmd, action);
|
|
|
|
|
|
|
|
/* Set the command data */
|
2021-06-17 07:08:43 +00:00
|
|
|
iwl_mvm_phy_ctxt_cmd_data(mvm, ctxt, &cmd, chandef,
|
2020-09-30 13:31:23 +00:00
|
|
|
chains_static,
|
|
|
|
chains_dynamic);
|
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
if (ap) {
|
2024-06-17 07:19:40 +00:00
|
|
|
cmd.sbb_bandwidth = iwl_mvm_get_channel_width(ap);
|
|
|
|
cmd.sbb_ctrl_channel_loc = iwl_mvm_get_ctrl_pos(ap);
|
2024-06-17 07:19:40 +00:00
|
|
|
}
|
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
if (ver == 6)
|
|
|
|
cmd.puncture_mask = cpu_to_le16(chandef->punctured);
|
|
|
|
|
2020-09-30 13:31:23 +00:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD,
|
|
|
|
0, sizeof(cmd), &cmd);
|
|
|
|
} else if (ver < 3) {
|
|
|
|
struct iwl_phy_context_cmd_v1 cmd = {};
|
|
|
|
u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm);
|
|
|
|
|
|
|
|
/* Set the command header fields */
|
|
|
|
iwl_mvm_phy_ctxt_cmd_hdr(ctxt,
|
|
|
|
(struct iwl_phy_context_cmd *)&cmd,
|
|
|
|
action);
|
|
|
|
|
|
|
|
/* Set the command data */
|
2021-06-17 07:08:43 +00:00
|
|
|
iwl_mvm_phy_ctxt_cmd_data_v1(mvm, ctxt, &cmd, chandef,
|
2020-09-30 13:31:23 +00:00
|
|
|
chains_static,
|
|
|
|
chains_dynamic);
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD,
|
|
|
|
0, len, &cmd);
|
|
|
|
} else {
|
|
|
|
IWL_ERR(mvm, "PHY ctxt cmd error ver %d not supported\n", ver);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2013-01-24 13:25:36 +00:00
|
|
|
|
|
|
|
|
2022-05-31 12:49:40 +00:00
|
|
|
if (ret) {
|
2013-01-24 13:25:36 +00:00
|
|
|
IWL_ERR(mvm, "PHY ctxt cmd error. ret=%d\n", ret);
|
2022-05-31 12:49:40 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action != FW_CTXT_ACTION_REMOVE)
|
|
|
|
return iwl_mvm_phy_send_rlc(mvm, ctxt, chains_static,
|
|
|
|
chains_dynamic);
|
|
|
|
|
|
|
|
return 0;
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a command to add a PHY context based on the current HW configuration.
|
|
|
|
*/
|
|
|
|
int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
|
2024-06-17 07:19:22 +00:00
|
|
|
const struct cfg80211_chan_def *chandef,
|
2024-06-17 07:19:40 +00:00
|
|
|
const struct cfg80211_chan_def *ap,
|
2013-01-24 13:25:36 +00:00
|
|
|
u8 chains_static, u8 chains_dynamic)
|
|
|
|
{
|
2024-02-01 14:29:49 +00:00
|
|
|
int ret;
|
|
|
|
|
2013-05-14 11:53:45 +00:00
|
|
|
WARN_ON(!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
|
|
|
|
ctxt->ref);
|
2013-01-24 13:25:36 +00:00
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2013-03-21 08:23:52 +00:00
|
|
|
ctxt->channel = chandef->chan;
|
2022-05-31 12:49:40 +00:00
|
|
|
ctxt->width = chandef->width;
|
|
|
|
ctxt->center_freq1 = chandef->center_freq1;
|
2013-01-24 13:25:36 +00:00
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
ret = iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, ap,
|
2024-02-01 14:29:49 +00:00
|
|
|
chains_static, chains_dynamic,
|
|
|
|
FW_CTXT_ACTION_ADD);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ctxt->ref++;
|
|
|
|
|
|
|
|
return 0;
|
2013-03-21 08:23:52 +00:00
|
|
|
}
|
2013-01-24 13:25:36 +00:00
|
|
|
|
2013-03-21 08:23:52 +00:00
|
|
|
/*
|
|
|
|
* Update the number of references to the given PHY context. This is valid only
|
|
|
|
* in case the PHY context was already created, i.e., its reference count > 0.
|
|
|
|
*/
|
|
|
|
void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
2024-02-01 14:29:49 +00:00
|
|
|
|
|
|
|
/* If we were taking the first ref, we should have
|
|
|
|
* called iwl_mvm_phy_ctxt_add.
|
|
|
|
*/
|
|
|
|
WARN_ON(!ctxt->ref);
|
2013-03-21 08:23:52 +00:00
|
|
|
ctxt->ref++;
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a command to modify the PHY context based on the current HW
|
|
|
|
* configuration. Note that the function does not check that the configuration
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
|
2024-06-17 07:19:22 +00:00
|
|
|
const struct cfg80211_chan_def *chandef,
|
2024-06-17 07:19:40 +00:00
|
|
|
const struct cfg80211_chan_def *ap,
|
2013-01-24 13:25:36 +00:00
|
|
|
u8 chains_static, u8 chains_dynamic)
|
|
|
|
{
|
2017-06-02 13:15:53 +00:00
|
|
|
enum iwl_ctxt_action action = FW_CTXT_ACTION_MODIFY;
|
2017-02-07 16:37:40 +00:00
|
|
|
|
2013-01-24 13:25:36 +00:00
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2024-02-01 14:29:49 +00:00
|
|
|
if (WARN_ON_ONCE(!ctxt->ref))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(DATA_PATH_GROUP,
|
|
|
|
RLC_CONFIG_CMD), 0) >= 2 &&
|
2022-05-31 12:49:40 +00:00
|
|
|
ctxt->channel == chandef->chan &&
|
|
|
|
ctxt->width == chandef->width &&
|
|
|
|
ctxt->center_freq1 == chandef->center_freq1)
|
|
|
|
return iwl_mvm_phy_send_rlc(mvm, ctxt, chains_static,
|
|
|
|
chains_dynamic);
|
|
|
|
|
2017-05-26 11:11:44 +00:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_BINDING_CDB_SUPPORT) &&
|
2017-02-07 16:37:40 +00:00
|
|
|
ctxt->channel->band != chandef->chan->band) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* ... remove it here ...*/
|
2024-06-17 07:19:40 +00:00
|
|
|
ret = iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, NULL,
|
2017-02-07 16:37:40 +00:00
|
|
|
chains_static, chains_dynamic,
|
2020-09-30 13:31:23 +00:00
|
|
|
FW_CTXT_ACTION_REMOVE);
|
2017-02-07 16:37:40 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* ... and proceed to add it again */
|
|
|
|
action = FW_CTXT_ACTION_ADD;
|
|
|
|
}
|
|
|
|
|
2013-01-24 13:25:36 +00:00
|
|
|
ctxt->channel = chandef->chan;
|
2017-09-14 12:45:44 +00:00
|
|
|
ctxt->width = chandef->width;
|
2022-05-31 12:49:40 +00:00
|
|
|
ctxt->center_freq1 = chandef->center_freq1;
|
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, ap,
|
2013-01-24 13:25:36 +00:00
|
|
|
chains_static, chains_dynamic,
|
2020-09-30 13:31:23 +00:00
|
|
|
action);
|
2013-01-24 13:25:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-21 08:23:52 +00:00
|
|
|
void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt)
|
|
|
|
{
|
2024-02-01 14:29:49 +00:00
|
|
|
struct cfg80211_chan_def chandef;
|
2013-03-21 08:23:52 +00:00
|
|
|
lockdep_assert_held(&mvm->mutex);
|
2013-05-08 13:55:31 +00:00
|
|
|
|
|
|
|
if (WARN_ON_ONCE(!ctxt))
|
|
|
|
return;
|
|
|
|
|
2013-03-21 08:23:52 +00:00
|
|
|
ctxt->ref--;
|
2018-03-04 18:06:29 +00:00
|
|
|
|
2024-02-01 14:29:49 +00:00
|
|
|
if (ctxt->ref)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfg80211_chandef_create(&chandef, ctxt->channel, NL80211_CHAN_NO_HT);
|
|
|
|
|
2024-06-17 07:19:40 +00:00
|
|
|
iwl_mvm_phy_ctxt_apply(mvm, ctxt, &chandef, NULL, 1, 1,
|
2024-02-01 14:29:49 +00:00
|
|
|
FW_CTXT_ACTION_REMOVE);
|
2013-03-21 08:23:52 +00:00
|
|
|
}
|
2014-05-15 08:44:40 +00:00
|
|
|
|
|
|
|
static void iwl_mvm_binding_iterator(void *_data, u8 *mac,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
unsigned long *data = _data;
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
|
wifi: iwlwifi: mvm: vif preparation for MLO
Bugzilla: https://bugzilla.redhat.com/2196821
commit 650cadb730105f1894b6c8afacc57a368dd18b91
Author: Gregory Greenman <gregory.greenman@intel.com>
Date: Tue Mar 28 10:58:41 2023 +0300
wifi: iwlwifi: mvm: vif preparation for MLO
In MLO, some fields of iwl_mvm_vif should be defined in the
context of a link. Define a separate structure for these fields and
add a deflink object to hold it as part of iwl_mvm_vif. Non-MLO legacy
code will use only deflink object while MLO related code will use the
corresponding link from the link array.
It follows the strategy applied in mac80211 for introducing MLO
changes.
The below spatch takes care of updating all driver code to access
fields separated into MLD specific data structure via deflink (need
to convert all references to the fields listed in var to deflink.var
and also to take care of calls like iwl_mvm_vif_from_mac80211(vif)->field).
@iwl_mld_vif@
struct iwl_mvm_vif *v;
struct ieee80211_vif *vv;
identifier fn;
identifier var = {bssid, ap_sta_id, bcast_sta, mcast_sta,
beacon_stats, smps_requests, probe_resp_data,
he_ru_2mhz_block, cab_queue, phy_ctxt,
queue_params};
@@
(
v->
- var
+ deflink.var
|
fn(vv)->
- var
+ deflink.var
)
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230328104948.4896576f0a9f.Ifaf0187c96b9fe52b24bd629331165831a877691@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 11:15:07 +00:00
|
|
|
if (!mvmvif->deflink.phy_ctxt)
|
2014-05-15 08:44:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (vif->type == NL80211_IFTYPE_STATION ||
|
|
|
|
vif->type == NL80211_IFTYPE_AP)
|
wifi: iwlwifi: mvm: vif preparation for MLO
Bugzilla: https://bugzilla.redhat.com/2196821
commit 650cadb730105f1894b6c8afacc57a368dd18b91
Author: Gregory Greenman <gregory.greenman@intel.com>
Date: Tue Mar 28 10:58:41 2023 +0300
wifi: iwlwifi: mvm: vif preparation for MLO
In MLO, some fields of iwl_mvm_vif should be defined in the
context of a link. Define a separate structure for these fields and
add a deflink object to hold it as part of iwl_mvm_vif. Non-MLO legacy
code will use only deflink object while MLO related code will use the
corresponding link from the link array.
It follows the strategy applied in mac80211 for introducing MLO
changes.
The below spatch takes care of updating all driver code to access
fields separated into MLD specific data structure via deflink (need
to convert all references to the fields listed in var to deflink.var
and also to take care of calls like iwl_mvm_vif_from_mac80211(vif)->field).
@iwl_mld_vif@
struct iwl_mvm_vif *v;
struct ieee80211_vif *vv;
identifier fn;
identifier var = {bssid, ap_sta_id, bcast_sta, mcast_sta,
beacon_stats, smps_requests, probe_resp_data,
he_ru_2mhz_block, cab_queue, phy_ctxt,
queue_params};
@@
(
v->
- var
+ deflink.var
|
fn(vv)->
- var
+ deflink.var
)
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230328104948.4896576f0a9f.Ifaf0187c96b9fe52b24bd629331165831a877691@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 11:15:07 +00:00
|
|
|
__set_bit(mvmvif->deflink.phy_ctxt->id, data);
|
2014-05-15 08:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
unsigned long phy_ctxt_counter = 0;
|
|
|
|
|
|
|
|
ieee80211_iterate_active_interfaces_atomic(mvm->hw,
|
|
|
|
IEEE80211_IFACE_ITER_NORMAL,
|
|
|
|
iwl_mvm_binding_iterator,
|
|
|
|
&phy_ctxt_counter);
|
|
|
|
|
|
|
|
return hweight8(phy_ctxt_counter);
|
|
|
|
}
|