2020-12-10 00:06:03 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
|
|
|
/*
|
2024-02-06 18:02:07 +02:00
|
|
|
* Copyright (C) 2013-2014, 2018-2019, 2022-2024 Intel Corporation
|
2020-12-10 00:06:03 +02:00
|
|
|
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH
|
|
|
|
*/
|
2013-10-06 13:03:32 +02:00
|
|
|
#include "mvm.h"
|
|
|
|
|
|
|
|
/* For counting bound interfaces */
|
|
|
|
struct iwl_mvm_active_iface_iterator_data {
|
|
|
|
struct ieee80211_vif *ignore_vif;
|
2023-04-17 11:41:32 +03:00
|
|
|
struct ieee80211_sta *sta_vif_ap_sta;
|
2013-10-06 13:03:32 +02:00
|
|
|
enum iwl_sf_state sta_vif_state;
|
2018-10-21 16:04:58 +03:00
|
|
|
u32 num_active_macs;
|
2013-10-06 13:03:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Count bound interfaces which are not p2p, besides data->ignore_vif.
|
|
|
|
* data->station_vif will point to one bound vif of type station, if exists.
|
|
|
|
*/
|
|
|
|
static void iwl_mvm_bound_iface_iterator(void *_data, u8 *mac,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct iwl_mvm_active_iface_iterator_data *data = _data;
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
|
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>
2023-03-28 10:58:41 +03:00
|
|
|
if (vif == data->ignore_vif || !mvmvif->deflink.phy_ctxt ||
|
2013-10-06 13:03:32 +02:00
|
|
|
vif->type == NL80211_IFTYPE_P2P_DEVICE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
data->num_active_macs++;
|
|
|
|
|
|
|
|
if (vif->type == NL80211_IFTYPE_STATION) {
|
2023-04-17 11:41:32 +03:00
|
|
|
data->sta_vif_ap_sta = mvmvif->ap_sta;
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
if (vif->cfg.assoc)
|
2013-10-06 13:03:32 +02:00
|
|
|
data->sta_vif_state = SF_FULL_ON;
|
|
|
|
else
|
|
|
|
data->sta_vif_state = SF_INIT_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Aging and idle timeouts for the different possible scenarios
|
2015-02-08 13:58:50 +02:00
|
|
|
* in default configuration
|
|
|
|
*/
|
|
|
|
static const
|
|
|
|
__le32 sf_full_timeout_def[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = {
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_SINGLE_UNICAST_AGING_TIMER_DEF),
|
|
|
|
cpu_to_le32(SF_SINGLE_UNICAST_IDLE_TIMER_DEF)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_AGG_UNICAST_AGING_TIMER_DEF),
|
|
|
|
cpu_to_le32(SF_AGG_UNICAST_IDLE_TIMER_DEF)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_MCAST_AGING_TIMER_DEF),
|
|
|
|
cpu_to_le32(SF_MCAST_IDLE_TIMER_DEF)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_BA_AGING_TIMER_DEF),
|
|
|
|
cpu_to_le32(SF_BA_IDLE_TIMER_DEF)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_TX_RE_AGING_TIMER_DEF),
|
|
|
|
cpu_to_le32(SF_TX_RE_IDLE_TIMER_DEF)
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Aging and idle timeouts for the different possible scenarios
|
|
|
|
* in single BSS MAC configuration.
|
2013-10-06 13:03:32 +02:00
|
|
|
*/
|
|
|
|
static const __le32 sf_full_timeout[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = {
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_SINGLE_UNICAST_AGING_TIMER),
|
|
|
|
cpu_to_le32(SF_SINGLE_UNICAST_IDLE_TIMER)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_AGG_UNICAST_AGING_TIMER),
|
|
|
|
cpu_to_le32(SF_AGG_UNICAST_IDLE_TIMER)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_MCAST_AGING_TIMER),
|
|
|
|
cpu_to_le32(SF_MCAST_IDLE_TIMER)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_BA_AGING_TIMER),
|
|
|
|
cpu_to_le32(SF_BA_IDLE_TIMER)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
cpu_to_le32(SF_TX_RE_AGING_TIMER),
|
|
|
|
cpu_to_le32(SF_TX_RE_IDLE_TIMER)
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-02-08 13:58:50 +02:00
|
|
|
static void iwl_mvm_fill_sf_command(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_sf_cfg_cmd *sf_cmd,
|
2013-10-06 13:03:32 +02:00
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
int i, j, watermark;
|
2023-03-28 10:58:56 +03:00
|
|
|
u8 max_rx_nss = 0;
|
|
|
|
bool is_legacy = true;
|
|
|
|
struct ieee80211_link_sta *link_sta;
|
|
|
|
unsigned int link_id;
|
2013-10-06 13:03:32 +02:00
|
|
|
|
|
|
|
sf_cmd->watermark[SF_LONG_DELAY_ON] = cpu_to_le32(SF_W_MARK_SCAN);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are in association flow - check antenna configuration
|
|
|
|
* capabilities of the AP station, and choose the watermark accordingly.
|
|
|
|
*/
|
|
|
|
if (sta) {
|
2023-03-28 10:58:56 +03:00
|
|
|
/* find the maximal NSS number among all links (if relevant) */
|
|
|
|
rcu_read_lock();
|
|
|
|
for (link_id = 0; link_id < ARRAY_SIZE(sta->link); link_id++) {
|
|
|
|
link_sta = rcu_dereference(sta->link[link_id]);
|
|
|
|
if (!link_sta)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (link_sta->ht_cap.ht_supported ||
|
|
|
|
link_sta->vht_cap.vht_supported ||
|
|
|
|
link_sta->eht_cap.has_eht ||
|
|
|
|
link_sta->he_cap.has_he) {
|
|
|
|
is_legacy = false;
|
|
|
|
max_rx_nss = max(max_rx_nss, link_sta->rx_nss);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
if (!is_legacy) {
|
|
|
|
switch (max_rx_nss) {
|
2013-10-06 13:03:32 +02:00
|
|
|
case 1:
|
|
|
|
watermark = SF_W_MARK_SISO;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
watermark = SF_W_MARK_MIMO2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
watermark = SF_W_MARK_MIMO3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
watermark = SF_W_MARK_LEGACY;
|
|
|
|
}
|
|
|
|
/* default watermark value for unassociated mode. */
|
|
|
|
} else {
|
|
|
|
watermark = SF_W_MARK_MIMO2;
|
|
|
|
}
|
|
|
|
sf_cmd->watermark[SF_FULL_ON] = cpu_to_le32(watermark);
|
|
|
|
|
|
|
|
for (i = 0; i < SF_NUM_SCENARIO; i++) {
|
|
|
|
for (j = 0; j < SF_NUM_TIMEOUT_TYPES; j++) {
|
|
|
|
sf_cmd->long_delay_timeouts[i][j] =
|
|
|
|
cpu_to_le32(SF_LONG_DELAY_AGING_TIMER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-07 16:55:20 +02:00
|
|
|
if (sta) {
|
2015-02-08 13:58:50 +02:00
|
|
|
BUILD_BUG_ON(sizeof(sf_full_timeout) !=
|
|
|
|
sizeof(__le32) * SF_NUM_SCENARIO *
|
|
|
|
SF_NUM_TIMEOUT_TYPES);
|
|
|
|
|
|
|
|
memcpy(sf_cmd->full_on_timeouts, sf_full_timeout,
|
|
|
|
sizeof(sf_full_timeout));
|
|
|
|
} else {
|
|
|
|
BUILD_BUG_ON(sizeof(sf_full_timeout_def) !=
|
|
|
|
sizeof(__le32) * SF_NUM_SCENARIO *
|
|
|
|
SF_NUM_TIMEOUT_TYPES);
|
|
|
|
|
|
|
|
memcpy(sf_cmd->full_on_timeouts, sf_full_timeout_def,
|
|
|
|
sizeof(sf_full_timeout_def));
|
|
|
|
}
|
2013-10-06 13:03:32 +02:00
|
|
|
}
|
|
|
|
|
2023-04-17 11:41:32 +03:00
|
|
|
static int iwl_mvm_sf_config(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
|
2013-10-06 13:03:32 +02:00
|
|
|
enum iwl_sf_state new_state)
|
|
|
|
{
|
|
|
|
struct iwl_sf_cfg_cmd sf_cmd = {
|
2016-06-07 15:05:26 +03:00
|
|
|
.state = cpu_to_le32(new_state),
|
2013-10-06 13:03:32 +02:00
|
|
|
};
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If an associated AP sta changed its antenna configuration, the state
|
|
|
|
* will remain FULL_ON but SF parameters need to be reconsidered.
|
|
|
|
*/
|
|
|
|
if (new_state != SF_FULL_ON && mvm->sf_state == new_state)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (new_state) {
|
|
|
|
case SF_UNINIT:
|
2016-03-07 16:55:20 +02:00
|
|
|
iwl_mvm_fill_sf_command(mvm, &sf_cmd, NULL);
|
2013-10-06 13:03:32 +02:00
|
|
|
break;
|
|
|
|
case SF_FULL_ON:
|
2023-04-17 11:41:32 +03:00
|
|
|
if (!sta) {
|
2013-10-06 13:03:32 +02:00
|
|
|
IWL_ERR(mvm,
|
|
|
|
"No station: Cannot switch SF to FULL_ON\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-02-08 13:58:50 +02:00
|
|
|
iwl_mvm_fill_sf_command(mvm, &sf_cmd, sta);
|
2013-10-06 13:03:32 +02:00
|
|
|
break;
|
|
|
|
case SF_INIT_OFF:
|
2015-02-08 13:58:50 +02:00
|
|
|
iwl_mvm_fill_sf_command(mvm, &sf_cmd, NULL);
|
2013-10-06 13:03:32 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "Invalid state: %d. not sending Smart Fifo cmd\n",
|
|
|
|
new_state);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_SF_CFG_CMD, CMD_ASYNC,
|
|
|
|
sizeof(sf_cmd), &sf_cmd);
|
|
|
|
if (!ret)
|
|
|
|
mvm->sf_state = new_state;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update Smart fifo:
|
|
|
|
* Count bound interfaces that are not to be removed, ignoring p2p devices,
|
|
|
|
* and set new state accordingly.
|
|
|
|
*/
|
|
|
|
int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *changed_vif,
|
|
|
|
bool remove_vif)
|
|
|
|
{
|
|
|
|
enum iwl_sf_state new_state;
|
|
|
|
struct iwl_mvm_vif *mvmvif = NULL;
|
|
|
|
struct iwl_mvm_active_iface_iterator_data data = {
|
|
|
|
.ignore_vif = changed_vif,
|
|
|
|
.sta_vif_state = SF_UNINIT,
|
|
|
|
};
|
2023-04-17 11:41:32 +03:00
|
|
|
struct ieee80211_sta *sta = NULL;
|
2013-10-06 13:03:32 +02:00
|
|
|
|
2024-02-06 18:02:07 +02:00
|
|
|
if (fw_has_api(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_API_SMART_FIFO_OFFLOAD))
|
|
|
|
return 0;
|
2013-10-06 13:03:32 +02:00
|
|
|
/*
|
|
|
|
* Ignore the call if we are in HW Restart flow, or if the handled
|
|
|
|
* vif is a p2p device.
|
|
|
|
*/
|
|
|
|
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) ||
|
|
|
|
(changed_vif && changed_vif->type == NL80211_IFTYPE_P2P_DEVICE))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ieee80211_iterate_active_interfaces_atomic(mvm->hw,
|
|
|
|
IEEE80211_IFACE_ITER_NORMAL,
|
|
|
|
iwl_mvm_bound_iface_iterator,
|
|
|
|
&data);
|
|
|
|
|
|
|
|
/* If changed_vif exists and is not to be removed, add to the count */
|
|
|
|
if (changed_vif && !remove_vif)
|
|
|
|
data.num_active_macs++;
|
|
|
|
|
|
|
|
switch (data.num_active_macs) {
|
|
|
|
case 0:
|
|
|
|
/* If there are no active macs - change state to SF_INIT_OFF */
|
|
|
|
new_state = SF_INIT_OFF;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (remove_vif) {
|
|
|
|
/* The one active mac left is of type station
|
|
|
|
* and we filled the relevant data during iteration
|
|
|
|
*/
|
|
|
|
new_state = data.sta_vif_state;
|
2023-04-17 11:41:32 +03:00
|
|
|
sta = data.sta_vif_ap_sta;
|
2013-10-06 13:03:32 +02:00
|
|
|
} else {
|
|
|
|
if (WARN_ON(!changed_vif))
|
|
|
|
return -EINVAL;
|
|
|
|
if (changed_vif->type != NL80211_IFTYPE_STATION) {
|
|
|
|
new_state = SF_UNINIT;
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
} else if (changed_vif->cfg.assoc &&
|
2014-03-19 18:36:39 +01:00
|
|
|
changed_vif->bss_conf.dtim_period) {
|
2013-10-06 13:03:32 +02:00
|
|
|
mvmvif = iwl_mvm_vif_from_mac80211(changed_vif);
|
2023-04-17 11:41:32 +03:00
|
|
|
sta = mvmvif->ap_sta;
|
2013-10-06 13:03:32 +02:00
|
|
|
new_state = SF_FULL_ON;
|
|
|
|
} else {
|
|
|
|
new_state = SF_INIT_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* If there are multiple active macs - change to SF_UNINIT */
|
|
|
|
new_state = SF_UNINIT;
|
|
|
|
}
|
2023-03-28 10:58:56 +03:00
|
|
|
|
2023-04-17 11:41:32 +03:00
|
|
|
return iwl_mvm_sf_config(mvm, sta, new_state);
|
2013-10-06 13:03:32 +02:00
|
|
|
}
|