2020-12-10 00:06:03 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
|
|
|
/*
|
2024-02-05 00:06:16 +02:00
|
|
|
* Copyright (C) 2012-2014, 2018-2024 Intel Corporation
|
2020-12-10 00:06:03 +02:00
|
|
|
* Copyright (C) 2013-2015 Intel Mobile Communications GmbH
|
|
|
|
* Copyright (C) 2017 Intel Deutschland GmbH
|
|
|
|
*/
|
2013-01-24 14:25:36 +01:00
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
2017-06-01 10:32:17 +02:00
|
|
|
#include "fw/notif-wait.h"
|
2013-01-24 14:25:36 +01:00
|
|
|
#include "iwl-trans.h"
|
|
|
|
#include "fw-api.h"
|
|
|
|
#include "time-event.h"
|
|
|
|
#include "mvm.h"
|
|
|
|
#include "iwl-io.h"
|
|
|
|
#include "iwl-prph.h"
|
|
|
|
|
2013-02-13 11:05:18 +02:00
|
|
|
/*
|
|
|
|
* For the high priority TE use a time event type that has similar priority to
|
|
|
|
* the FW's action scan priority.
|
2013-02-04 14:09:37 +02:00
|
|
|
*/
|
2013-02-13 11:05:18 +02:00
|
|
|
#define IWL_MVM_ROC_TE_TYPE_NORMAL TE_P2P_DEVICE_DISCOVERABLE
|
|
|
|
#define IWL_MVM_ROC_TE_TYPE_MGMT_TX TE_P2P_CLIENT_ASSOC
|
2013-02-04 14:09:37 +02:00
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_time_event_data *te_data)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&mvm->time_event_lock);
|
|
|
|
|
2018-12-24 10:59:13 +02:00
|
|
|
if (!te_data || !te_data->vif)
|
2013-01-24 14:25:36 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
list_del(&te_data->list);
|
2021-06-18 11:01:12 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the list is only used for AUX ROC events so make sure it is always
|
|
|
|
* initialized
|
|
|
|
*/
|
|
|
|
INIT_LIST_HEAD(&te_data->list);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
te_data->running = false;
|
|
|
|
te_data->uid = 0;
|
|
|
|
te_data->id = TE_MAX;
|
|
|
|
te_data->vif = NULL;
|
wifi: iwlwifi: make time_events MLO aware
As session protection API is moving to be per link instead of per mac,
move the time events to be per link too.
Since there is only one concurrent time event per mac, it feels
unnecessary to have the time_event as a member of iwl_mvm_link_info.
(That way we will have to iterate over all links each time we want to
clear a time event, and also we will need mac80211 to tell us the link
id when mgd_tx_complete() is called.)
So leave this as a member of iwl_mvm_vif, but add the link id to the
time_event structure.
The link id in time_event will only be maintained and used for:
1. When SESSION_PROTECTION_CMD is supported (before it, we don't have MLO)
2. For time_events of types SESSION_PROTECT_CONF_ASSOC,
SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV, and
SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION
(not for aux roc/ Hot Spot time_events).
For P2P, non-MLO connections, and pre-MLD API, deflink id, meaning 0,
will be used
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.21496bcacb18.I79d037325b4fae4c12a22d9477e53fc9c537ad46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-10-17 12:16:36 +03:00
|
|
|
te_data->link_id = -1;
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
2024-02-05 21:21:06 +02:00
|
|
|
static void iwl_mvm_cleanup_roc(struct iwl_mvm *mvm)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
2024-05-05 09:19:57 +03:00
|
|
|
struct ieee80211_vif *vif = mvm->p2p_device_vif;
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2014-07-16 21:11:12 +03:00
|
|
|
/*
|
2021-12-19 12:18:15 +02:00
|
|
|
* Clear the ROC_RUNNING status bit.
|
2014-07-16 21:11:12 +03:00
|
|
|
* This will cause the TX path to drop offchannel transmissions.
|
|
|
|
* That would also be done by mac80211, but it is racy, in particular
|
2024-02-05 21:21:06 +02:00
|
|
|
* in the case that the time event actually completed in the firmware.
|
|
|
|
*
|
|
|
|
* Also flush the offchannel queue -- this is called when the time
|
2015-03-31 12:24:05 +03:00
|
|
|
* event finishes or is canceled, so that frames queued for it
|
2013-01-24 14:25:36 +01:00
|
|
|
* won't get stuck on the queue and be transmitted in the next
|
|
|
|
* time event.
|
|
|
|
*/
|
2024-02-05 21:21:06 +02:00
|
|
|
if (test_and_clear_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) {
|
2017-11-13 17:26:09 +01:00
|
|
|
struct iwl_mvm_vif *mvmvif;
|
|
|
|
|
2024-02-05 21:21:06 +02:00
|
|
|
synchronize_net();
|
|
|
|
|
2017-11-13 17:26:09 +01:00
|
|
|
/*
|
|
|
|
* NB: access to this pointer would be racy, but the flush bit
|
|
|
|
* can only be set when we had a P2P-Device VIF, and we have a
|
|
|
|
* flush of this work in iwl_mvm_prepare_mac_removal() so it's
|
|
|
|
* not really racy.
|
|
|
|
*/
|
|
|
|
|
2024-05-05 09:19:57 +03:00
|
|
|
if (!WARN_ON(!vif)) {
|
2023-10-04 12:36:30 +03:00
|
|
|
mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
2023-10-11 13:07:28 +03:00
|
|
|
iwl_mvm_flush_sta(mvm, mvmvif->deflink.bcast_sta.sta_id,
|
|
|
|
mvmvif->deflink.bcast_sta.tfd_queue_msk);
|
2023-10-04 12:36:30 +03:00
|
|
|
|
|
|
|
if (mvm->mld_api_is_used) {
|
|
|
|
iwl_mvm_mld_rm_bcast_sta(mvm, vif,
|
|
|
|
&vif->bss_conf);
|
|
|
|
|
|
|
|
iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
|
|
|
|
LINK_CONTEXT_MODIFY_ACTIVE,
|
|
|
|
false);
|
|
|
|
} else {
|
|
|
|
iwl_mvm_rm_p2p_bcast_sta(mvm, vif);
|
|
|
|
iwl_mvm_binding_remove_vif(mvm, vif);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do not remove the PHY context as removing and adding
|
|
|
|
* a PHY context has timing overheads. Leaving it
|
|
|
|
* configured in FW would be useful in case the next ROC
|
|
|
|
* is with the same channel.
|
|
|
|
*/
|
2017-11-13 17:26:09 +01:00
|
|
|
}
|
2021-12-19 12:18:15 +02:00
|
|
|
}
|
|
|
|
|
2024-02-05 21:21:06 +02:00
|
|
|
/* Do the same for AUX ROC */
|
2021-12-19 12:18:15 +02:00
|
|
|
if (test_and_clear_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) {
|
2024-02-05 21:21:06 +02:00
|
|
|
synchronize_net();
|
|
|
|
|
2023-10-11 13:07:28 +03:00
|
|
|
iwl_mvm_flush_sta(mvm, mvm->aux_sta.sta_id,
|
|
|
|
mvm->aux_sta.tfd_queue_msk);
|
2021-12-19 12:18:15 +02:00
|
|
|
|
2023-03-28 10:58:47 +03:00
|
|
|
if (mvm->mld_api_is_used) {
|
|
|
|
iwl_mvm_mld_rm_aux_sta(mvm);
|
2024-05-05 09:19:57 +03:00
|
|
|
mutex_unlock(&mvm->mutex);
|
2024-02-05 21:21:06 +02:00
|
|
|
return;
|
2023-03-28 10:58:47 +03:00
|
|
|
}
|
|
|
|
|
2020-10-08 18:09:47 +03:00
|
|
|
/* In newer version of this command an aux station is added only
|
|
|
|
* in cases of dedicated tx queue and need to be removed in end
|
|
|
|
* of use */
|
2023-06-13 15:57:23 +03:00
|
|
|
if (iwl_mvm_has_new_station_api(mvm->fw))
|
2020-10-08 18:09:47 +03:00
|
|
|
iwl_mvm_rm_aux_sta(mvm);
|
2017-11-13 17:26:09 +01:00
|
|
|
}
|
2024-05-05 09:19:57 +03:00
|
|
|
|
|
|
|
mutex_unlock(&mvm->mutex);
|
|
|
|
if (vif)
|
|
|
|
iwl_mvm_esr_non_bss_link(mvm, vif, 0, false);
|
2024-02-05 21:21:06 +02:00
|
|
|
}
|
2020-10-08 18:09:45 +03:00
|
|
|
|
2024-02-05 21:21:06 +02:00
|
|
|
void iwl_mvm_roc_done_wk(struct work_struct *wk)
|
|
|
|
{
|
|
|
|
struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, roc_done_wk);
|
|
|
|
|
|
|
|
mutex_lock(&mvm->mutex);
|
2024-05-05 09:19:57 +03:00
|
|
|
/* Mutex is released inside */
|
2024-02-05 21:21:06 +02:00
|
|
|
iwl_mvm_cleanup_roc(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_mvm_roc_finished(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Of course, our status bit is just as racy as mac80211, so in
|
|
|
|
* addition, fire off the work struct which will drop all frames
|
|
|
|
* from the hardware queues that made it through the race. First
|
|
|
|
* it will of course synchronize the TX path to make sure that
|
|
|
|
* any *new* TX will be rejected.
|
|
|
|
*/
|
|
|
|
schedule_work(&mvm->roc_done_wk);
|
|
|
|
}
|
|
|
|
|
2014-05-04 11:48:12 +03:00
|
|
|
static void iwl_mvm_csa_noa_start(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
struct ieee80211_vif *csa_vif;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
|
|
|
|
csa_vif = rcu_dereference(mvm->csa_vif);
|
wifi: mac80211: move some future per-link data to bss_conf
To add MLD, reuse the bss_conf structure later for per-link
information, so move some things into it that are per link.
Most transformations were done with the following spatch:
@@
expression sdata;
identifier var = { chanctx_conf, mu_mimo_owner, csa_active, color_change_active, color_change_color };
@@
-sdata->vif.var
+sdata->vif.bss_conf.var
@@
struct ieee80211_vif *vif;
identifier var = { chanctx_conf, mu_mimo_owner, csa_active, color_change_active, color_change_color };
@@
-vif->var
+vif->bss_conf.var
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 13:26:44 +02:00
|
|
|
if (!csa_vif || !csa_vif->bss_conf.csa_active)
|
2014-05-04 11:48:12 +03:00
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "CSA NOA started\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CSA NoA is started but we still have beacons to
|
|
|
|
* transmit on the current channel.
|
|
|
|
* So we just do nothing here and the switch
|
|
|
|
* will be performed on the last TBTT.
|
|
|
|
*/
|
2024-02-16 20:16:20 +05:30
|
|
|
if (!ieee80211_beacon_cntdwn_is_complete(csa_vif, 0)) {
|
2014-05-04 11:48:12 +03:00
|
|
|
IWL_WARN(mvm, "CSA NOA started too early\n");
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
2024-01-30 19:39:18 +05:30
|
|
|
ieee80211_csa_finish(csa_vif, 0);
|
2014-05-04 11:48:12 +03:00
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
RCU_INIT_POINTER(mvm->csa_vif, NULL);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2013-07-25 18:39:30 +02:00
|
|
|
static bool iwl_mvm_te_check_disconnect(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
const char *errmsg)
|
|
|
|
{
|
2018-02-28 17:18:48 +02:00
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
|
2013-07-25 18:39:30 +02:00
|
|
|
if (vif->type != NL80211_IFTYPE_STATION)
|
|
|
|
return false;
|
2018-02-28 17:18:48 +02:00
|
|
|
|
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 (!mvmvif->csa_bcn_pending && vif->cfg.assoc &&
|
2018-02-28 17:18:48 +02:00
|
|
|
vif->bss_conf.dtim_period)
|
2013-07-25 18:39:30 +02:00
|
|
|
return false;
|
|
|
|
if (errmsg)
|
|
|
|
IWL_ERR(mvm, "%s\n", errmsg);
|
2015-03-30 10:55:57 +03:00
|
|
|
|
2021-03-30 16:24:49 +03:00
|
|
|
if (mvmvif->csa_bcn_pending) {
|
|
|
|
struct iwl_mvm_sta *mvmsta;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
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
|
|
|
mvmsta = iwl_mvm_sta_from_staid_rcu(mvm,
|
|
|
|
mvmvif->deflink.ap_sta_id);
|
2021-03-30 16:24:49 +03:00
|
|
|
if (!WARN_ON(!mvmsta))
|
|
|
|
iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false);
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
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) {
|
2021-08-05 14:21:55 +03:00
|
|
|
/*
|
|
|
|
* When not associated, this will be called from
|
|
|
|
* iwl_mvm_event_mlme_callback_ini()
|
|
|
|
*/
|
|
|
|
iwl_dbg_tlv_time_point(&mvm->fwrt,
|
|
|
|
IWL_FW_INI_TIME_POINT_ASSOC_FAILED,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2015-03-30 10:55:57 +03:00
|
|
|
iwl_mvm_connection_loss(mvm, vif, errmsg);
|
2013-07-25 18:39:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-10 11:10:14 +02:00
|
|
|
static void
|
|
|
|
iwl_mvm_te_handle_notify_csa(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_time_event_data *te_data,
|
|
|
|
struct iwl_time_event_notif *notif)
|
|
|
|
{
|
2015-03-10 14:44:00 +01:00
|
|
|
struct ieee80211_vif *vif = te_data->vif;
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
|
|
|
|
if (!notif->status)
|
2014-11-10 11:10:14 +02:00
|
|
|
IWL_DEBUG_TE(mvm, "CSA time event failed to start\n");
|
|
|
|
|
|
|
|
switch (te_data->vif->type) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
2015-03-10 14:44:00 +01:00
|
|
|
if (!notif->status)
|
|
|
|
mvmvif->csa_failed = true;
|
2014-11-10 11:10:14 +02:00
|
|
|
iwl_mvm_csa_noa_start(mvm);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
2015-03-10 14:44:00 +01:00
|
|
|
if (!notif->status) {
|
2015-03-30 10:55:57 +03:00
|
|
|
iwl_mvm_connection_loss(mvm, vif,
|
|
|
|
"CSA TE failed to start");
|
2015-03-10 14:44:00 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-11-10 11:10:14 +02:00
|
|
|
iwl_mvm_csa_client_absent(mvm, te_data->vif);
|
2019-04-10 15:31:28 +03:00
|
|
|
cancel_delayed_work(&mvmvif->csa_work);
|
2023-08-28 13:04:10 +03:00
|
|
|
ieee80211_chswitch_done(te_data->vif, true, 0);
|
2014-11-10 11:10:14 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* should never happen */
|
|
|
|
WARN_ON_ONCE(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we don't need it anymore */
|
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
|
|
|
}
|
|
|
|
|
2015-03-25 22:40:47 +02:00
|
|
|
static void iwl_mvm_te_check_trigger(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_time_event_notif *notif,
|
|
|
|
struct iwl_mvm_time_event_data *te_data)
|
|
|
|
{
|
|
|
|
struct iwl_fw_dbg_trigger_tlv *trig;
|
|
|
|
struct iwl_fw_dbg_trigger_time_event *te_trig;
|
|
|
|
int i;
|
|
|
|
|
2018-06-12 10:41:35 +03:00
|
|
|
trig = iwl_fw_dbg_trigger_on(&mvm->fwrt,
|
|
|
|
ieee80211_vif_to_wdev(te_data->vif),
|
|
|
|
FW_DBG_TRIGGER_TIME_EVENT);
|
|
|
|
if (!trig)
|
2015-03-25 22:40:47 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
te_trig = (void *)trig->data;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(te_trig->time_events); i++) {
|
|
|
|
u32 trig_te_id = le32_to_cpu(te_trig->time_events[i].id);
|
|
|
|
u32 trig_action_bitmap =
|
|
|
|
le32_to_cpu(te_trig->time_events[i].action_bitmap);
|
|
|
|
u32 trig_status_bitmap =
|
|
|
|
le32_to_cpu(te_trig->time_events[i].status_bitmap);
|
|
|
|
|
|
|
|
if (trig_te_id != te_data->id ||
|
|
|
|
!(trig_action_bitmap & le32_to_cpu(notif->action)) ||
|
|
|
|
!(trig_status_bitmap & BIT(le32_to_cpu(notif->status))))
|
|
|
|
continue;
|
|
|
|
|
2017-06-01 16:03:19 +02:00
|
|
|
iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
|
|
|
|
"Time event %d Action 0x%x received status: %d",
|
|
|
|
te_data->id,
|
|
|
|
le32_to_cpu(notif->action),
|
|
|
|
le32_to_cpu(notif->status));
|
2015-03-25 22:40:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/*
|
|
|
|
* Handles a FW notification for an event that is known to the driver.
|
|
|
|
*
|
|
|
|
* @mvm: the mvm component
|
|
|
|
* @te_data: the time event data
|
|
|
|
* @notif: the notification data corresponding the time event data.
|
|
|
|
*/
|
|
|
|
static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_time_event_data *te_data,
|
|
|
|
struct iwl_time_event_notif *notif)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "Handle time event notif - UID = 0x%x action %d\n",
|
|
|
|
le32_to_cpu(notif->unique_id),
|
|
|
|
le32_to_cpu(notif->action));
|
|
|
|
|
2015-03-25 22:40:47 +02:00
|
|
|
iwl_mvm_te_check_trigger(mvm, notif, te_data);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/*
|
|
|
|
* The FW sends the start/end time event notifications even for events
|
|
|
|
* that it fails to schedule. This is indicated in the status field of
|
|
|
|
* the notification. This happens in cases that the scheduler cannot
|
|
|
|
* find a schedule that can handle the event (for example requesting a
|
|
|
|
* P2P Device discoveribility, while there are other higher priority
|
|
|
|
* events in the system).
|
|
|
|
*/
|
2013-11-05 16:27:59 +02:00
|
|
|
if (!le32_to_cpu(notif->status)) {
|
2015-03-12 09:10:13 +01:00
|
|
|
const char *msg;
|
|
|
|
|
|
|
|
if (notif->action & cpu_to_le32(TE_V2_NOTIF_HOST_EVENT_START))
|
|
|
|
msg = "Time Event start notification failure";
|
|
|
|
else
|
|
|
|
msg = "Time Event end notification failure";
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "%s\n", msg);
|
|
|
|
|
|
|
|
if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, msg)) {
|
2013-07-25 18:39:30 +02:00
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-08-07 19:36:42 +03:00
|
|
|
if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_END) {
|
2013-01-24 14:25:36 +01:00
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"TE ended - current time %lu, estimated end %lu\n",
|
|
|
|
jiffies, te_data->end_jiffies);
|
|
|
|
|
2015-03-11 20:27:06 +01:00
|
|
|
switch (te_data->vif->type) {
|
|
|
|
case NL80211_IFTYPE_P2P_DEVICE:
|
2013-01-24 14:25:36 +01:00
|
|
|
ieee80211_remain_on_channel_expired(mvm->hw);
|
2024-02-05 21:21:06 +02:00
|
|
|
iwl_mvm_roc_finished(mvm);
|
2015-03-11 20:27:06 +01:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
2021-04-11 13:25:38 +03:00
|
|
|
/*
|
|
|
|
* If we are switching channel, don't disconnect
|
|
|
|
* if the time event is already done. Beacons can
|
|
|
|
* be delayed a bit after the switch.
|
|
|
|
*/
|
|
|
|
if (te_data->id == TE_CHANNEL_SWITCH_PERIOD) {
|
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"No beacon heard and the CS time event is over, don't disconnect\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-03-11 20:27:06 +01:00
|
|
|
/*
|
|
|
|
* By now, we should have finished association
|
|
|
|
* and know the dtim period.
|
|
|
|
*/
|
|
|
|
iwl_mvm_te_check_disconnect(mvm, te_data->vif,
|
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
|
|
|
!te_data->vif->cfg.assoc ?
|
2021-06-17 10:08:45 +03:00
|
|
|
"Not associated and the time event is over already..." :
|
2018-02-28 17:18:48 +02:00
|
|
|
"No beacon heard and the time event is over already...");
|
2015-03-11 20:27:06 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
2013-08-07 19:36:42 +03:00
|
|
|
} else if (le32_to_cpu(notif->action) & TE_V2_NOTIF_HOST_EVENT_START) {
|
2013-01-24 14:25:36 +01:00
|
|
|
te_data->running = true;
|
2013-07-25 21:45:17 +02:00
|
|
|
te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
|
|
|
|
set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
|
|
|
|
ieee80211_ready_on_channel(mvm->hw);
|
2014-11-10 11:10:14 +02:00
|
|
|
} else if (te_data->id == TE_CHANNEL_SWITCH_PERIOD) {
|
|
|
|
iwl_mvm_te_handle_notify_csa(mvm, te_data, notif);
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
IWL_WARN(mvm, "Got TE with unknown action\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-11 13:07:22 +03:00
|
|
|
void iwl_mvm_rx_roc_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_rx_cmd_buffer *rxb)
|
|
|
|
{
|
|
|
|
struct iwl_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct iwl_roc_notif *notif = (void *)pkt->data;
|
|
|
|
|
|
|
|
if (le32_to_cpu(notif->success) && le32_to_cpu(notif->started) &&
|
|
|
|
le32_to_cpu(notif->activity) == ROC_ACTIVITY_HOTSPOT) {
|
|
|
|
set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status);
|
|
|
|
ieee80211_ready_on_channel(mvm->hw);
|
|
|
|
} else {
|
|
|
|
iwl_mvm_roc_finished(mvm);
|
|
|
|
ieee80211_remain_on_channel_expired(mvm->hw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 21:11:12 +03:00
|
|
|
/*
|
|
|
|
* Handle A Aux ROC time event
|
|
|
|
*/
|
|
|
|
static int iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_time_event_notif *notif)
|
|
|
|
{
|
2022-12-05 10:35:42 +02:00
|
|
|
struct iwl_mvm_time_event_data *aux_roc_te = NULL, *te_data;
|
2014-07-16 21:11:12 +03:00
|
|
|
|
2022-12-05 10:35:42 +02:00
|
|
|
list_for_each_entry(te_data, &mvm->aux_roc_te_list, list) {
|
2014-07-16 21:11:12 +03:00
|
|
|
if (le32_to_cpu(notif->unique_id) == te_data->uid) {
|
2022-12-05 10:35:42 +02:00
|
|
|
aux_roc_te = te_data;
|
2014-07-16 21:11:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!aux_roc_te) /* Not a Aux ROC time event */
|
|
|
|
return -EINVAL;
|
|
|
|
|
2015-03-25 22:40:47 +02:00
|
|
|
iwl_mvm_te_check_trigger(mvm, notif, te_data);
|
|
|
|
|
2014-07-16 21:11:12 +03:00
|
|
|
IWL_DEBUG_TE(mvm,
|
2016-03-09 14:46:28 +02:00
|
|
|
"Aux ROC time event notification - UID = 0x%x action %d (error = %d)\n",
|
2014-07-16 21:11:12 +03:00
|
|
|
le32_to_cpu(notif->unique_id),
|
2016-03-09 14:46:28 +02:00
|
|
|
le32_to_cpu(notif->action), le32_to_cpu(notif->status));
|
2014-07-16 21:11:12 +03:00
|
|
|
|
2016-03-09 14:46:28 +02:00
|
|
|
if (!le32_to_cpu(notif->status) ||
|
|
|
|
le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_END) {
|
2014-07-16 21:11:12 +03:00
|
|
|
/* End TE, notify mac80211 */
|
|
|
|
ieee80211_remain_on_channel_expired(mvm->hw);
|
|
|
|
iwl_mvm_roc_finished(mvm); /* flush aux queue */
|
|
|
|
list_del(&te_data->list); /* remove from list */
|
|
|
|
te_data->running = false;
|
|
|
|
te_data->vif = NULL;
|
|
|
|
te_data->uid = 0;
|
2014-09-29 11:46:04 +03:00
|
|
|
te_data->id = TE_MAX;
|
2014-07-16 21:11:12 +03:00
|
|
|
} else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) {
|
|
|
|
set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status);
|
|
|
|
te_data->running = true;
|
|
|
|
ieee80211_ready_on_channel(mvm->hw); /* Start TE */
|
|
|
|
} else {
|
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"ERROR: Unknown Aux ROC Time Event (action = %d)\n",
|
|
|
|
le32_to_cpu(notif->action));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/*
|
|
|
|
* The Rx handler for time event notifications
|
|
|
|
*/
|
2015-06-23 21:22:09 +02:00
|
|
|
void iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_rx_cmd_buffer *rxb)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
|
|
|
struct iwl_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct iwl_time_event_notif *notif = (void *)pkt->data;
|
|
|
|
struct iwl_mvm_time_event_data *te_data, *tmp;
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "Time event notification - UID = 0x%x action %d\n",
|
|
|
|
le32_to_cpu(notif->unique_id),
|
|
|
|
le32_to_cpu(notif->action));
|
|
|
|
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
2014-07-16 21:11:12 +03:00
|
|
|
/* This time event is triggered for Aux ROC request */
|
|
|
|
if (!iwl_mvm_aux_roc_te_handle_notif(mvm, notif))
|
|
|
|
goto unlock;
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
list_for_each_entry_safe(te_data, tmp, &mvm->time_event_list, list) {
|
|
|
|
if (le32_to_cpu(notif->unique_id) == te_data->uid)
|
|
|
|
iwl_mvm_te_handle_notif(mvm, te_data, notif);
|
|
|
|
}
|
2014-07-16 21:11:12 +03:00
|
|
|
unlock:
|
2013-01-24 14:25:36 +01:00
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
}
|
|
|
|
|
2014-07-06 17:14:39 +03:00
|
|
|
static bool iwl_mvm_te_notif(struct iwl_notif_wait_data *notif_wait,
|
|
|
|
struct iwl_rx_packet *pkt, void *data)
|
|
|
|
{
|
|
|
|
struct iwl_mvm *mvm =
|
|
|
|
container_of(notif_wait, struct iwl_mvm, notif_wait);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = data;
|
|
|
|
struct iwl_time_event_notif *resp;
|
|
|
|
int resp_len = iwl_rx_packet_payload_len(pkt);
|
|
|
|
|
|
|
|
if (WARN_ON(pkt->hdr.cmd != TIME_EVENT_NOTIFICATION))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (WARN_ON_ONCE(resp_len != sizeof(*resp))) {
|
|
|
|
IWL_ERR(mvm, "Invalid TIME_EVENT_NOTIFICATION response\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
resp = (void *)pkt->data;
|
|
|
|
|
|
|
|
/* te_data->uid is already set in the TIME_EVENT_CMD response */
|
|
|
|
if (le32_to_cpu(resp->unique_id) != te_data->uid)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "TIME_EVENT_NOTIFICATION response - UID = 0x%x\n",
|
|
|
|
te_data->uid);
|
|
|
|
if (!resp->status)
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"TIME_EVENT_NOTIFICATION received but not executed\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
static bool iwl_mvm_time_event_response(struct iwl_notif_wait_data *notif_wait,
|
|
|
|
struct iwl_rx_packet *pkt, void *data)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
|
|
|
struct iwl_mvm *mvm =
|
|
|
|
container_of(notif_wait, struct iwl_mvm, notif_wait);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = data;
|
|
|
|
struct iwl_time_event_resp *resp;
|
2014-01-08 13:16:33 +01:00
|
|
|
int resp_len = iwl_rx_packet_payload_len(pkt);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
if (WARN_ON(pkt->hdr.cmd != TIME_EVENT_CMD))
|
|
|
|
return true;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2014-01-08 13:16:33 +01:00
|
|
|
if (WARN_ON_ONCE(resp_len != sizeof(*resp))) {
|
2013-01-29 15:28:17 +01:00
|
|
|
IWL_ERR(mvm, "Invalid TIME_EVENT_CMD response\n");
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
resp = (void *)pkt->data;
|
iwlwifi: mvm: fix time event command handling race
Occasionally, we would run into this warning:
iwlwifi 0000:02:00.0: U iwl_mvm_protect_session extend 0x2601: only 200 ms left
iwlwifi 0000:02:00.0: U iwl_mvm_remove_time_event Removing TE 0x2601
iwlwifi 0000:02:00.0: I iwl_pcie_enqueue_hcmd Sending command TIME_EVENT_CMD (#29), seq: 0x0925, 60 bytes at 37[5]:9
iwlwifi 0000:02:00.0: U iwl_pcie_send_hcmd_sync Attempting to send sync command TIME_EVENT_CMD
iwlwifi 0000:02:00.0: U iwl_pcie_send_hcmd_sync Setting HCMD_ACTIVE for command TIME_EVENT_CMD
iwlwifi 0000:02:00.0: I iwl_pcie_enqueue_hcmd Sending command TIME_EVENT_CMD (#29), seq: 0x0926, 60 bytes at 38[6]:9
iwlwifi 0000:02:00.0: U iwl_mvm_time_event_response TIME_EVENT_CMD response - UID = 0x2601
iwlwifi 0000:02:00.0: I iwl_pcie_hcmd_complete Clearing HCMD_ACTIVE for command TIME_EVENT_CMD
iwlwifi 0000:02:00.0: U iwl_mvm_rx_time_event_notif Time event notification - UID = 0x2701 action 1
wlan0: associate with 00:0a:b8:55:a8:30 (try 2/3)
------------[ cut here ]------------
WARNING: at drivers/net/wireless/iwlwifi/mvm/time-event.c:269 iwl_mvm_time_event_send_add+0x163/0x1a0 [iwlmvm]()
Modules linked in: [...]
Call Trace:
[<c1046e42>] warn_slowpath_common+0x72/0xa0
[<c1046e92>] warn_slowpath_null+0x22/0x30
[<f8cad913>] iwl_mvm_time_event_send_add+0x163/0x1a0 [iwlmvm]
[<f8cadead>] iwl_mvm_protect_session+0xcd/0x1c0 [iwlmvm]
[<f8ca2087>] iwl_mvm_mac_mgd_prepare_tx+0x67/0xa0 [iwlmvm]
[<f882a130>] ieee80211_sta_work+0x8f0/0x1070 [mac80211]
The reason is a problem with asynchronous vs. synchronous
commands, what happens here is the following:
* TE 0x2601 is removed, the TIME_EVENT_CMD for that is async
* a new TE (will be 0x2701) is created, the TIME_EVENT_CMD
for that is sync and also uses a notification wait for the
response (to avoid another race condition)
* the response for the TE 0x2601 removal comes from the
firmware, and is handled by the notification wait handler
that's really waiting for the second response, but can't
tell the difference, we therefore see the message
"TIME_EVENT_CMD response - UID = 0x2601" instead of
"TIME_EVENT_CMD response - UID = 0x2701".
Fix this issue by making the TE removal synchronous as well,
this means that we wait for the response to that command
first, before there's any chance of sending a new one.
Also, to detect such issues more easily in the future, add
a warning to the notification handler that detects them.
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2013-02-16 00:11:34 +01:00
|
|
|
|
|
|
|
/* we should never get a response to another TIME_EVENT_CMD here */
|
|
|
|
if (WARN_ON_ONCE(le32_to_cpu(resp->id) != te_data->id))
|
|
|
|
return false;
|
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
te_data->uid = le32_to_cpu(resp->unique_id);
|
|
|
|
IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n",
|
|
|
|
te_data->uid);
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
static int iwl_mvm_time_event_send_add(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct iwl_mvm_time_event_data *te_data,
|
2014-03-30 08:40:46 +03:00
|
|
|
struct iwl_time_event_cmd *te_cmd)
|
2013-01-29 15:28:17 +01:00
|
|
|
{
|
2015-07-13 14:50:47 +03:00
|
|
|
static const u16 time_event_response[] = { TIME_EVENT_CMD };
|
2013-01-29 15:28:17 +01:00
|
|
|
struct iwl_notification_wait wait_time_event;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2013-02-15 23:54:10 +01:00
|
|
|
IWL_DEBUG_TE(mvm, "Add new TE, duration %d TU\n",
|
|
|
|
le32_to_cpu(te_cmd->duration));
|
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
if (WARN_ON(te_data->id != TE_MAX)) {
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
te_data->vif = vif;
|
|
|
|
te_data->duration = le32_to_cpu(te_cmd->duration);
|
|
|
|
te_data->id = le32_to_cpu(te_cmd->id);
|
|
|
|
list_add_tail(&te_data->list, &mvm->time_event_list);
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use a notification wait, which really just processes the
|
|
|
|
* command response and doesn't wait for anything, in order
|
|
|
|
* to be able to process the response and get the UID inside
|
|
|
|
* the RX path. Using CMD_WANT_SKB doesn't work because it
|
|
|
|
* stores the buffer and then wakes up this thread, by which
|
|
|
|
* time another notification (that the time event started)
|
|
|
|
* might already be processed unsuccessfully.
|
|
|
|
*/
|
|
|
|
iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
|
|
|
|
time_event_response,
|
|
|
|
ARRAY_SIZE(time_event_response),
|
|
|
|
iwl_mvm_time_event_response, te_data);
|
|
|
|
|
2014-05-12 11:36:41 +03:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, 0,
|
2014-03-30 08:40:46 +03:00
|
|
|
sizeof(*te_cmd), te_cmd);
|
2013-01-29 15:28:17 +01:00
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Couldn't send TIME_EVENT_CMD: %d\n", ret);
|
|
|
|
iwl_remove_notification(&mvm->notif_wait, &wait_time_event);
|
|
|
|
goto out_clear_te;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
/* No need to wait for anything, so just pass 1 (0 isn't valid) */
|
|
|
|
ret = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1);
|
|
|
|
/* should never fail */
|
|
|
|
WARN_ON_ONCE(ret);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
out_clear_te:
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
}
|
|
|
|
return ret;
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void iwl_mvm_protect_session(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
2013-05-03 11:16:15 +02:00
|
|
|
u32 duration, u32 min_duration,
|
2014-07-06 17:14:39 +03:00
|
|
|
u32 max_delay, bool wait_for_notif)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
|
2015-07-13 14:50:47 +03:00
|
|
|
const u16 te_notif_response[] = { TIME_EVENT_NOTIFICATION };
|
2014-07-06 17:14:39 +03:00
|
|
|
struct iwl_notification_wait wait_te_notif;
|
2014-03-30 08:40:46 +03:00
|
|
|
struct iwl_time_event_cmd time_cmd = {};
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
if (te_data->running &&
|
2013-07-25 21:45:17 +02:00
|
|
|
time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
|
2013-01-24 14:25:36 +01:00
|
|
|
IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
|
|
|
|
jiffies_to_msecs(te_data->end_jiffies - jiffies));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (te_data->running) {
|
|
|
|
IWL_DEBUG_TE(mvm, "extend 0x%x: only %u ms left\n",
|
|
|
|
te_data->uid,
|
|
|
|
jiffies_to_msecs(te_data->end_jiffies - jiffies));
|
|
|
|
/*
|
|
|
|
* we don't have enough time
|
|
|
|
* cancel the current TE and issue a new one
|
|
|
|
* Of course it would be better to remove the old one only
|
|
|
|
* when the new one is added, but we don't care if we are off
|
|
|
|
* channel for a bit. All we need to do, is not to return
|
|
|
|
* before we actually begin to be on the channel.
|
|
|
|
*/
|
|
|
|
iwl_mvm_stop_session_protection(mvm, vif);
|
|
|
|
}
|
|
|
|
|
|
|
|
time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
|
|
|
|
time_cmd.id_and_color =
|
|
|
|
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
|
|
|
|
time_cmd.id = cpu_to_le32(TE_BSS_STA_AGGRESSIVE_ASSOC);
|
|
|
|
|
2015-06-24 10:25:26 +03:00
|
|
|
time_cmd.apply_time = cpu_to_le32(0);
|
2013-01-29 15:28:17 +01:00
|
|
|
|
2013-08-07 19:36:42 +03:00
|
|
|
time_cmd.max_frags = TE_V2_FRAG_NONE;
|
2013-05-03 11:16:15 +02:00
|
|
|
time_cmd.max_delay = cpu_to_le32(max_delay);
|
2013-01-24 14:25:36 +01:00
|
|
|
/* TODO: why do we need to interval = bi if it is not periodic? */
|
|
|
|
time_cmd.interval = cpu_to_le32(1);
|
|
|
|
time_cmd.duration = cpu_to_le32(duration);
|
2013-08-07 19:36:42 +03:00
|
|
|
time_cmd.repeat = 1;
|
|
|
|
time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
|
2014-02-16 15:36:00 +02:00
|
|
|
TE_V2_NOTIF_HOST_EVENT_END |
|
2018-01-04 17:39:08 +02:00
|
|
|
TE_V2_START_IMMEDIATELY);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2014-07-06 17:14:39 +03:00
|
|
|
if (!wait_for_notif) {
|
|
|
|
iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create notification_wait for the TIME_EVENT_NOTIFICATION to use
|
|
|
|
* right after we send the time event
|
|
|
|
*/
|
|
|
|
iwl_init_notification_wait(&mvm->notif_wait, &wait_te_notif,
|
|
|
|
te_notif_response,
|
|
|
|
ARRAY_SIZE(te_notif_response),
|
|
|
|
iwl_mvm_te_notif, te_data);
|
|
|
|
|
|
|
|
/* If TE was sent OK - wait for the notification that started */
|
|
|
|
if (iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd)) {
|
|
|
|
IWL_ERR(mvm, "Failed to add TE to protect session\n");
|
|
|
|
iwl_remove_notification(&mvm->notif_wait, &wait_te_notif);
|
|
|
|
} else if (iwl_wait_notification(&mvm->notif_wait, &wait_te_notif,
|
|
|
|
TU_TO_JIFFIES(max_delay))) {
|
|
|
|
IWL_ERR(mvm, "Failed to protect session until TE\n");
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
2023-10-17 12:16:37 +03:00
|
|
|
/* Determine whether mac or link id should be used, and validate the link id */
|
|
|
|
static int iwl_mvm_get_session_prot_id(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
2024-01-23 20:08:16 +02:00
|
|
|
s8 link_id)
|
2023-10-17 12:16:37 +03:00
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
int ver = iwl_fw_lookup_cmd_ver(mvm->fw,
|
|
|
|
WIDE_ID(MAC_CONF_GROUP,
|
|
|
|
SESSION_PROTECTION_CMD), 1);
|
|
|
|
|
|
|
|
if (ver < 2)
|
|
|
|
return mvmvif->id;
|
|
|
|
|
|
|
|
if (WARN(link_id < 0 || !mvmvif->link[link_id],
|
|
|
|
"Invalid link ID for session protection: %u\n", link_id))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2024-02-05 21:21:05 +02:00
|
|
|
if (WARN(!mvmvif->link[link_id]->active,
|
2023-10-17 12:16:37 +03:00
|
|
|
"Session Protection on an inactive link: %u\n", link_id))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return mvmvif->link[link_id]->fw_link_id;
|
|
|
|
}
|
|
|
|
|
2020-11-07 10:50:08 +02:00
|
|
|
static void iwl_mvm_cancel_session_protection(struct iwl_mvm *mvm,
|
2023-10-17 12:16:37 +03:00
|
|
|
struct ieee80211_vif *vif,
|
2024-01-23 20:08:16 +02:00
|
|
|
u32 id, s8 link_id)
|
2020-11-07 10:50:08 +02:00
|
|
|
{
|
2023-10-17 12:16:37 +03:00
|
|
|
int mac_link_id = iwl_mvm_get_session_prot_id(mvm, vif, link_id);
|
2020-11-07 10:50:08 +02:00
|
|
|
struct iwl_mvm_session_prot_cmd cmd = {
|
2023-10-17 12:16:37 +03:00
|
|
|
.id_and_color = cpu_to_le32(mac_link_id),
|
2020-11-07 10:50:08 +02:00
|
|
|
.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE),
|
2021-06-18 11:01:12 +03:00
|
|
|
.conf_id = cpu_to_le32(id),
|
2020-11-07 10:50:08 +02:00
|
|
|
};
|
|
|
|
int ret;
|
|
|
|
|
2023-10-17 12:16:37 +03:00
|
|
|
if (mac_link_id < 0)
|
|
|
|
return;
|
|
|
|
|
2022-01-28 15:34:23 +02:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm,
|
|
|
|
WIDE_ID(MAC_CONF_GROUP, SESSION_PROTECTION_CMD),
|
2020-11-07 10:50:08 +02:00
|
|
|
0, sizeof(cmd), &cmd);
|
|
|
|
if (ret)
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"Couldn't send the SESSION_PROTECTION_CMD: %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2014-11-16 10:25:12 +02:00
|
|
|
static bool __iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_time_event_data *te_data,
|
|
|
|
u32 *uid)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
2014-11-16 10:25:12 +02:00
|
|
|
u32 id;
|
2023-10-17 12:16:37 +03:00
|
|
|
struct ieee80211_vif *vif = te_data->vif;
|
2021-09-07 14:32:14 +03:00
|
|
|
struct iwl_mvm_vif *mvmvif;
|
2021-06-18 11:01:12 +03:00
|
|
|
enum nl80211_iftype iftype;
|
2024-01-23 20:08:16 +02:00
|
|
|
s8 link_id;
|
2021-06-18 11:01:12 +03:00
|
|
|
|
2023-10-17 12:16:37 +03:00
|
|
|
if (!vif)
|
2021-06-18 11:01:12 +03:00
|
|
|
return false;
|
|
|
|
|
2021-09-07 14:32:14 +03:00
|
|
|
mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
|
2021-06-18 11:01:12 +03:00
|
|
|
iftype = te_data->vif->type;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* It is possible that by the time we got to this point the time
|
|
|
|
* event was already removed.
|
|
|
|
*/
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
/* Save time event uid before clearing its data */
|
2014-11-16 10:25:12 +02:00
|
|
|
*uid = te_data->uid;
|
2013-01-24 14:25:36 +01:00
|
|
|
id = te_data->id;
|
2023-10-17 12:16:37 +03:00
|
|
|
link_id = te_data->link_id;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The clear_data function handles time events that were already removed
|
|
|
|
*/
|
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
2021-12-19 13:28:31 +02:00
|
|
|
/* When session protection is used, the te_data->id field
|
2020-11-07 10:50:08 +02:00
|
|
|
* is reused to save session protection's configuration.
|
2021-12-19 13:28:31 +02:00
|
|
|
* For AUX ROC, HOT_SPOT_CMD is used and the te_data->id field is set
|
|
|
|
* to HOT_SPOT_CMD.
|
2013-01-24 14:25:36 +01:00
|
|
|
*/
|
2020-11-07 10:50:08 +02:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa,
|
2021-12-19 13:28:31 +02:00
|
|
|
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD) &&
|
|
|
|
id != HOT_SPOT_CMD) {
|
2020-11-07 10:50:08 +02:00
|
|
|
if (mvmvif && id < SESSION_PROTECT_CONF_MAX_ID) {
|
|
|
|
/* Session protection is still ongoing. Cancel it */
|
2023-10-17 12:16:37 +03:00
|
|
|
iwl_mvm_cancel_session_protection(mvm, vif, id,
|
|
|
|
link_id);
|
2021-06-18 11:01:12 +03:00
|
|
|
if (iftype == NL80211_IFTYPE_P2P_DEVICE) {
|
2024-02-05 21:21:06 +02:00
|
|
|
iwl_mvm_roc_finished(mvm);
|
2020-11-07 10:50:08 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-16 10:25:12 +02:00
|
|
|
return false;
|
2020-11-07 10:50:08 +02:00
|
|
|
} else {
|
|
|
|
/* It is possible that by the time we try to remove it, the
|
|
|
|
* time event has already ended and removed. In such a case
|
|
|
|
* there is no need to send a removal command.
|
|
|
|
*/
|
|
|
|
if (id == TE_MAX) {
|
|
|
|
IWL_DEBUG_TE(mvm, "TE 0x%x has already ended\n", *uid);
|
|
|
|
return false;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
2014-11-16 10:25:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Explicit request to remove a aux roc time event. The removal of a time
|
|
|
|
* event needs to be synchronized with the flow of a time event's end
|
|
|
|
* notification, which also removes the time event from the op mode
|
|
|
|
* data structures.
|
|
|
|
*/
|
|
|
|
static void iwl_mvm_remove_aux_roc_te(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_vif *mvmvif,
|
|
|
|
struct iwl_mvm_time_event_data *te_data)
|
|
|
|
{
|
|
|
|
struct iwl_hs20_roc_req aux_cmd = {};
|
2018-11-18 18:01:43 +02:00
|
|
|
u16 len = sizeof(aux_cmd) - iwl_mvm_chan_info_padding(mvm);
|
|
|
|
|
2014-11-16 10:25:12 +02:00
|
|
|
u32 uid;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!__iwl_mvm_remove_time_event(mvm, te_data, &uid))
|
|
|
|
return;
|
|
|
|
|
|
|
|
aux_cmd.event_unique_id = cpu_to_le32(uid);
|
|
|
|
aux_cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
|
|
|
|
aux_cmd.id_and_color =
|
|
|
|
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
|
|
|
|
IWL_DEBUG_TE(mvm, "Removing BSS AUX ROC TE 0x%x\n",
|
|
|
|
le32_to_cpu(aux_cmd.event_unique_id));
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0,
|
2018-11-18 18:01:43 +02:00
|
|
|
len, &aux_cmd);
|
2014-11-16 10:25:12 +02:00
|
|
|
|
|
|
|
if (WARN_ON(ret))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Explicit request to remove a time event. The removal of a time event needs to
|
|
|
|
* be synchronized with the flow of a time event's end notification, which also
|
|
|
|
* removes the time event from the op mode data structures.
|
|
|
|
*/
|
|
|
|
void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_vif *mvmvif,
|
|
|
|
struct iwl_mvm_time_event_data *te_data)
|
|
|
|
{
|
|
|
|
struct iwl_time_event_cmd time_cmd = {};
|
|
|
|
u32 uid;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!__iwl_mvm_remove_time_event(mvm, te_data, &uid))
|
|
|
|
return;
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/* When we remove a TE, the UID is to be set in the id field */
|
|
|
|
time_cmd.id = cpu_to_le32(uid);
|
|
|
|
time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
|
|
|
|
time_cmd.id_and_color =
|
|
|
|
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "Removing TE 0x%x\n", le32_to_cpu(time_cmd.id));
|
2014-05-12 11:36:41 +03:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, 0,
|
2014-03-30 08:40:46 +03:00
|
|
|
sizeof(time_cmd), &time_cmd);
|
2021-04-11 13:25:39 +03:00
|
|
|
if (ret)
|
|
|
|
IWL_ERR(mvm, "Couldn't remove the time event\n");
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
|
2017-08-02 12:13:20 +03:00
|
|
|
u32 id;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
2017-08-02 12:13:20 +03:00
|
|
|
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
id = te_data->id;
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
2021-06-18 11:01:12 +03:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) {
|
|
|
|
if (id != SESSION_PROTECT_CONF_ASSOC) {
|
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"don't remove session protection id=%u\n",
|
|
|
|
id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (id != TE_BSS_STA_AGGRESSIVE_ASSOC) {
|
2017-08-02 12:13:20 +03:00
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"don't remove TE with id=%u (not session protection)\n",
|
|
|
|
id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_rx_cmd_buffer *rxb)
|
|
|
|
{
|
|
|
|
struct iwl_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct iwl_mvm_session_prot_notif *notif = (void *)pkt->data;
|
2023-10-17 12:16:38 +03:00
|
|
|
unsigned int ver =
|
2024-03-11 08:28:01 +02:00
|
|
|
iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
|
|
|
|
SESSION_PROTECTION_NOTIF, 2);
|
2023-10-17 12:16:38 +03:00
|
|
|
int id = le32_to_cpu(notif->mac_link_id);
|
2019-07-11 21:44:42 +03:00
|
|
|
struct ieee80211_vif *vif;
|
2020-11-07 10:50:08 +02:00
|
|
|
struct iwl_mvm_vif *mvmvif;
|
2023-10-17 12:16:38 +03:00
|
|
|
unsigned int notif_link_id;
|
2019-07-11 21:44:42 +03:00
|
|
|
|
|
|
|
rcu_read_lock();
|
2023-10-17 12:16:38 +03:00
|
|
|
|
|
|
|
if (ver <= 2) {
|
|
|
|
vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
|
|
|
|
} else {
|
|
|
|
struct ieee80211_bss_conf *link_conf =
|
|
|
|
iwl_mvm_rcu_fw_link_id_to_link_conf(mvm, id, true);
|
|
|
|
|
|
|
|
if (!link_conf)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
notif_link_id = link_conf->link_id;
|
|
|
|
vif = link_conf->vif;
|
|
|
|
}
|
2019-07-11 21:44:42 +03:00
|
|
|
|
|
|
|
if (!vif)
|
|
|
|
goto out_unlock;
|
|
|
|
|
2020-11-07 10:50:08 +02:00
|
|
|
mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
|
2023-10-17 12:16:38 +03:00
|
|
|
if (WARN(ver > 2 && mvmvif->time_event_data.link_id >= 0 &&
|
|
|
|
mvmvif->time_event_data.link_id != notif_link_id,
|
2024-01-29 21:21:52 +02:00
|
|
|
"SESSION_PROTECTION_NOTIF was received for link %u, while the current time event is on link %u\n",
|
2023-10-17 12:16:38 +03:00
|
|
|
notif_link_id, mvmvif->time_event_data.link_id))
|
|
|
|
goto out_unlock;
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
/* The vif is not a P2P_DEVICE, maintain its time_event_data */
|
|
|
|
if (vif->type != NL80211_IFTYPE_P2P_DEVICE) {
|
|
|
|
struct iwl_mvm_time_event_data *te_data =
|
|
|
|
&mvmvif->time_event_data;
|
|
|
|
|
|
|
|
if (!le32_to_cpu(notif->status)) {
|
|
|
|
iwl_mvm_te_check_disconnect(mvm, vif,
|
|
|
|
"Session protection failure");
|
2020-03-06 15:16:21 +02:00
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
2019-07-11 21:44:42 +03:00
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
2020-03-06 15:16:21 +02:00
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
2019-07-11 21:44:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (le32_to_cpu(notif->start)) {
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
te_data->running = le32_to_cpu(notif->start);
|
|
|
|
te_data->end_jiffies =
|
|
|
|
TU_TO_EXP_TIME(te_data->duration);
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* By now, we should have finished association
|
|
|
|
* and know the dtim period.
|
|
|
|
*/
|
|
|
|
iwl_mvm_te_check_disconnect(mvm, vif,
|
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
|
|
|
!vif->cfg.assoc ?
|
2021-06-17 10:08:45 +03:00
|
|
|
"Not associated and the session protection is over already..." :
|
2019-07-11 21:44:42 +03:00
|
|
|
"No beacon heard and the session protection is over already...");
|
2020-03-06 15:16:21 +02:00
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
2019-07-11 21:44:42 +03:00
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
2020-03-06 15:16:21 +02:00
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
2019-07-11 21:44:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!le32_to_cpu(notif->status) || !le32_to_cpu(notif->start)) {
|
|
|
|
/* End TE, notify mac80211 */
|
2020-11-07 10:50:08 +02:00
|
|
|
mvmvif->time_event_data.id = SESSION_PROTECT_CONF_MAX_ID;
|
2024-02-05 00:06:16 +02:00
|
|
|
mvmvif->time_event_data.link_id = -1;
|
2024-02-05 21:21:06 +02:00
|
|
|
iwl_mvm_roc_finished(mvm);
|
2023-10-04 12:36:30 +03:00
|
|
|
ieee80211_remain_on_channel_expired(mvm->hw);
|
2019-07-11 21:44:42 +03:00
|
|
|
} else if (le32_to_cpu(notif->start)) {
|
2020-11-07 10:50:08 +02:00
|
|
|
if (WARN_ON(mvmvif->time_event_data.id !=
|
|
|
|
le32_to_cpu(notif->conf_id)))
|
|
|
|
goto out_unlock;
|
2019-07-11 21:44:42 +03:00
|
|
|
set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
|
|
|
|
ieee80211_ready_on_channel(mvm->hw); /* Start TE */
|
|
|
|
}
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2024-02-01 16:17:41 +02:00
|
|
|
#define AUX_ROC_MIN_DURATION MSEC_TO_TU(100)
|
|
|
|
#define AUX_ROC_MIN_DELAY MSEC_TO_TU(200)
|
|
|
|
#define AUX_ROC_MAX_DELAY MSEC_TO_TU(600)
|
|
|
|
#define AUX_ROC_SAFETY_BUFFER MSEC_TO_TU(20)
|
|
|
|
#define AUX_ROC_MIN_SAFETY_BUFFER MSEC_TO_TU(10)
|
|
|
|
|
|
|
|
void iwl_mvm_roc_duration_and_delay(struct ieee80211_vif *vif,
|
|
|
|
u32 duration_ms,
|
|
|
|
u32 *duration_tu,
|
|
|
|
u32 *delay)
|
|
|
|
{
|
|
|
|
u32 dtim_interval = vif->bss_conf.dtim_period *
|
|
|
|
vif->bss_conf.beacon_int;
|
|
|
|
|
|
|
|
*delay = AUX_ROC_MIN_DELAY;
|
|
|
|
*duration_tu = MSEC_TO_TU(duration_ms);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are associated we want the delay time to be at least one
|
|
|
|
* dtim interval so that the FW can wait until after the DTIM and
|
|
|
|
* then start the time event, this will potentially allow us to
|
|
|
|
* remain off-channel for the max duration.
|
|
|
|
* Since we want to use almost a whole dtim interval we would also
|
|
|
|
* like the delay to be for 2-3 dtim intervals, in case there are
|
|
|
|
* other time events with higher priority.
|
|
|
|
*/
|
|
|
|
if (vif->cfg.assoc) {
|
|
|
|
*delay = min_t(u32, dtim_interval * 3, AUX_ROC_MAX_DELAY);
|
|
|
|
/* We cannot remain off-channel longer than the DTIM interval */
|
|
|
|
if (dtim_interval <= *duration_tu) {
|
|
|
|
*duration_tu = dtim_interval - AUX_ROC_SAFETY_BUFFER;
|
|
|
|
if (*duration_tu <= AUX_ROC_MIN_DURATION)
|
|
|
|
*duration_tu = dtim_interval -
|
|
|
|
AUX_ROC_MIN_SAFETY_BUFFER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_mvm_roc_add_cmd(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_channel *channel,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
int duration, u32 activity)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u32 duration_tu, delay;
|
|
|
|
struct iwl_roc_req roc_req = {
|
|
|
|
.action = cpu_to_le32(FW_CTXT_ACTION_ADD),
|
|
|
|
.activity = cpu_to_le32(activity),
|
|
|
|
.sta_id = cpu_to_le32(mvm->aux_sta.sta_id),
|
|
|
|
};
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
/* Set the channel info data */
|
|
|
|
iwl_mvm_set_chan_info(mvm, &roc_req.channel_info,
|
|
|
|
channel->hw_value,
|
|
|
|
iwl_mvm_phy_band_from_nl80211(channel->band),
|
|
|
|
IWL_PHY_CHANNEL_MODE20, 0);
|
|
|
|
|
|
|
|
iwl_mvm_roc_duration_and_delay(vif, duration, &duration_tu,
|
|
|
|
&delay);
|
|
|
|
roc_req.duration = cpu_to_le32(duration_tu);
|
|
|
|
roc_req.max_delay = cpu_to_le32(delay);
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"\t(requested = %ums, max_delay = %ums)\n",
|
|
|
|
duration, delay);
|
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"Requesting to remain on channel %u for %utu\n",
|
|
|
|
channel->hw_value, duration_tu);
|
|
|
|
|
|
|
|
/* Set the node address */
|
|
|
|
memcpy(roc_req.node_addr, vif->addr, ETH_ALEN);
|
|
|
|
|
|
|
|
res = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(MAC_CONF_GROUP, ROC_CMD),
|
|
|
|
0, sizeof(roc_req), &roc_req);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
static int
|
|
|
|
iwl_mvm_start_p2p_roc_session_protection(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
int duration,
|
|
|
|
enum ieee80211_roc_type type)
|
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_session_prot_cmd cmd = {
|
|
|
|
.id_and_color =
|
2023-10-17 12:16:37 +03:00
|
|
|
cpu_to_le32(iwl_mvm_get_session_prot_id(mvm, vif, 0)),
|
2019-07-11 21:44:42 +03:00
|
|
|
.action = cpu_to_le32(FW_CTXT_ACTION_ADD),
|
|
|
|
.duration_tu = cpu_to_le32(MSEC_TO_TU(duration)),
|
|
|
|
};
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2020-11-07 10:50:08 +02:00
|
|
|
/* The time_event_data.id field is reused to save session
|
|
|
|
* protection's configuration.
|
|
|
|
*/
|
wifi: iwlwifi: make time_events MLO aware
As session protection API is moving to be per link instead of per mac,
move the time events to be per link too.
Since there is only one concurrent time event per mac, it feels
unnecessary to have the time_event as a member of iwl_mvm_link_info.
(That way we will have to iterate over all links each time we want to
clear a time event, and also we will need mac80211 to tell us the link
id when mgd_tx_complete() is called.)
So leave this as a member of iwl_mvm_vif, but add the link id to the
time_event structure.
The link id in time_event will only be maintained and used for:
1. When SESSION_PROTECTION_CMD is supported (before it, we don't have MLO)
2. For time_events of types SESSION_PROTECT_CONF_ASSOC,
SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV, and
SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION
(not for aux roc/ Hot Spot time_events).
For P2P, non-MLO connections, and pre-MLD API, deflink id, meaning 0,
will be used
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.21496bcacb18.I79d037325b4fae4c12a22d9477e53fc9c537ad46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-10-17 12:16:36 +03:00
|
|
|
|
|
|
|
mvmvif->time_event_data.link_id = 0;
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
switch (type) {
|
|
|
|
case IEEE80211_ROC_TYPE_NORMAL:
|
2020-11-07 10:50:08 +02:00
|
|
|
mvmvif->time_event_data.id =
|
|
|
|
SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV;
|
2019-07-11 21:44:42 +03:00
|
|
|
break;
|
|
|
|
case IEEE80211_ROC_TYPE_MGMT_TX:
|
2020-11-07 10:50:08 +02:00
|
|
|
mvmvif->time_event_data.id =
|
|
|
|
SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION;
|
2019-07-11 21:44:42 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "Got an invalid ROC type\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-11-07 10:50:08 +02:00
|
|
|
cmd.conf_id = cpu_to_le32(mvmvif->time_event_data.id);
|
2022-01-28 15:34:23 +02:00
|
|
|
return iwl_mvm_send_cmd_pdu(mvm,
|
|
|
|
WIDE_ID(MAC_CONF_GROUP, SESSION_PROTECTION_CMD),
|
2019-07-11 21:44:42 +03:00
|
|
|
0, sizeof(cmd), &cmd);
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
|
2013-02-13 11:05:18 +02:00
|
|
|
int duration, enum ieee80211_roc_type type)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
|
2014-03-30 08:40:46 +03:00
|
|
|
struct iwl_time_event_cmd time_cmd = {};
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
if (te_data->running) {
|
|
|
|
IWL_WARN(mvm, "P2P_DEVICE remain on channel already running\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD))
|
|
|
|
return iwl_mvm_start_p2p_roc_session_protection(mvm, vif,
|
|
|
|
duration,
|
|
|
|
type);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
|
|
|
|
time_cmd.id_and_color =
|
|
|
|
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
|
2013-02-13 11:05:18 +02:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case IEEE80211_ROC_TYPE_NORMAL:
|
|
|
|
time_cmd.id = cpu_to_le32(IWL_MVM_ROC_TE_TYPE_NORMAL);
|
|
|
|
break;
|
|
|
|
case IEEE80211_ROC_TYPE_MGMT_TX:
|
|
|
|
time_cmd.id = cpu_to_le32(IWL_MVM_ROC_TE_TYPE_MGMT_TX);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "Got an invalid ROC type\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
time_cmd.apply_time = cpu_to_le32(0);
|
|
|
|
time_cmd.interval = cpu_to_le32(1);
|
|
|
|
|
|
|
|
/*
|
2013-02-13 11:05:18 +02:00
|
|
|
* The P2P Device TEs can have lower priority than other events
|
2013-01-24 14:25:36 +01:00
|
|
|
* that are being scheduled by the driver/fw, and thus it might not be
|
2013-02-13 11:05:18 +02:00
|
|
|
* scheduled. To improve the chances of it being scheduled, allow them
|
|
|
|
* to be fragmented, and in addition allow them to be delayed.
|
2013-01-24 14:25:36 +01:00
|
|
|
*/
|
2013-08-07 19:36:42 +03:00
|
|
|
time_cmd.max_frags = min(MSEC_TO_TU(duration)/50, TE_V2_FRAG_ENDLESS);
|
2013-01-24 14:25:36 +01:00
|
|
|
time_cmd.max_delay = cpu_to_le32(MSEC_TO_TU(duration/2));
|
|
|
|
time_cmd.duration = cpu_to_le32(MSEC_TO_TU(duration));
|
2013-08-07 19:36:42 +03:00
|
|
|
time_cmd.repeat = 1;
|
|
|
|
time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
|
2014-02-16 15:36:00 +02:00
|
|
|
TE_V2_NOTIF_HOST_EVENT_END |
|
2018-01-04 17:39:08 +02:00
|
|
|
TE_V2_START_IMMEDIATELY);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-01-29 15:28:17 +01:00
|
|
|
return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd);
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
2015-12-09 16:33:20 +02:00
|
|
|
static struct iwl_mvm_time_event_data *iwl_mvm_get_roc_te(struct iwl_mvm *mvm)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
|
|
|
struct iwl_mvm_time_event_data *te_data;
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2014-11-16 10:25:12 +02:00
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/*
|
|
|
|
* Iterate over the list of time events and find the time event that is
|
|
|
|
* associated with a P2P_DEVICE interface.
|
|
|
|
* This assumes that a P2P_DEVICE interface can have only a single time
|
|
|
|
* event at any given time and this time event coresponds to a ROC
|
|
|
|
* request
|
|
|
|
*/
|
|
|
|
list_for_each_entry(te_data, &mvm->time_event_list, list) {
|
2015-12-09 16:33:20 +02:00
|
|
|
if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE)
|
|
|
|
goto out;
|
2014-11-16 10:25:12 +02:00
|
|
|
}
|
|
|
|
|
2015-06-01 23:38:23 +02:00
|
|
|
/* There can only be at most one AUX ROC time event, we just use the
|
|
|
|
* list to simplify/unify code. Remove it if it exists.
|
2014-11-16 10:25:12 +02:00
|
|
|
*/
|
2015-06-01 23:38:23 +02:00
|
|
|
te_data = list_first_entry_or_null(&mvm->aux_roc_te_list,
|
|
|
|
struct iwl_mvm_time_event_data,
|
|
|
|
list);
|
2015-12-09 16:33:20 +02:00
|
|
|
out:
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
return te_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void iwl_mvm_cleanup_roc_te(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
struct iwl_mvm_time_event_data *te_data;
|
|
|
|
u32 uid;
|
|
|
|
|
|
|
|
te_data = iwl_mvm_get_roc_te(mvm);
|
2015-06-01 23:38:23 +02:00
|
|
|
if (te_data)
|
2015-12-09 16:33:20 +02:00
|
|
|
__iwl_mvm_remove_time_event(mvm, te_data, &uid);
|
|
|
|
}
|
2014-11-16 10:25:12 +02:00
|
|
|
|
2023-10-11 13:07:22 +03:00
|
|
|
static void iwl_mvm_roc_rm_cmd(struct iwl_mvm *mvm, u32 activity)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct iwl_roc_req roc_cmd = {
|
|
|
|
.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE),
|
|
|
|
.activity = cpu_to_le32(activity),
|
|
|
|
};
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm,
|
|
|
|
WIDE_ID(MAC_CONF_GROUP, ROC_CMD),
|
|
|
|
0, sizeof(roc_cmd), &roc_cmd);
|
|
|
|
WARN_ON(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_mvm_roc_station_remove(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_mvm_vif *mvmvif)
|
|
|
|
{
|
|
|
|
u32 cmd_id = WIDE_ID(MAC_CONF_GROUP, ROC_CMD);
|
|
|
|
u8 fw_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
|
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
|
|
|
|
|
|
|
if (fw_ver == IWL_FW_CMD_VER_UNKNOWN)
|
|
|
|
iwl_mvm_remove_aux_roc_te(mvm, mvmvif,
|
|
|
|
&mvmvif->hs_time_event_data);
|
|
|
|
else if (fw_ver == 3)
|
|
|
|
iwl_mvm_roc_rm_cmd(mvm, ROC_ACTIVITY_HOTSPOT);
|
|
|
|
else
|
|
|
|
IWL_ERR(mvm, "ROC command version %d mismatch!\n", fw_ver);
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
|
2015-12-09 16:33:20 +02:00
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif;
|
|
|
|
struct iwl_mvm_time_event_data *te_data;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2024-05-05 09:19:57 +03:00
|
|
|
mutex_lock(&mvm->mutex);
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) {
|
|
|
|
mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
2024-02-05 21:21:08 +02:00
|
|
|
te_data = &mvmvif->time_event_data;
|
|
|
|
|
|
|
|
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
|
|
|
|
if (te_data->id >= SESSION_PROTECT_CONF_MAX_ID) {
|
|
|
|
IWL_DEBUG_TE(mvm,
|
|
|
|
"No remain on channel event\n");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-11 21:44:42 +03:00
|
|
|
|
2023-10-17 12:16:37 +03:00
|
|
|
iwl_mvm_cancel_session_protection(mvm, vif,
|
2024-02-05 21:21:08 +02:00
|
|
|
te_data->id,
|
|
|
|
te_data->link_id);
|
|
|
|
} else {
|
2023-10-11 13:07:22 +03:00
|
|
|
iwl_mvm_roc_station_remove(mvm, mvmvif);
|
2024-02-05 21:21:08 +02:00
|
|
|
}
|
2024-02-05 21:21:06 +02:00
|
|
|
goto cleanup_roc;
|
2019-07-11 21:44:42 +03:00
|
|
|
}
|
|
|
|
|
2015-12-09 16:33:20 +02:00
|
|
|
te_data = iwl_mvm_get_roc_te(mvm);
|
|
|
|
if (!te_data) {
|
2014-11-16 10:25:12 +02:00
|
|
|
IWL_WARN(mvm, "No remain on channel event\n");
|
2013-01-24 14:25:36 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-09 16:33:20 +02:00
|
|
|
mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
|
|
|
|
|
2024-02-05 21:21:06 +02:00
|
|
|
if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE)
|
2014-11-16 10:25:12 +02:00
|
|
|
iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
|
2024-02-05 21:21:06 +02:00
|
|
|
else
|
2014-11-16 10:25:12 +02:00
|
|
|
iwl_mvm_remove_aux_roc_te(mvm, mvmvif, te_data);
|
2024-02-05 21:21:06 +02:00
|
|
|
|
|
|
|
cleanup_roc:
|
|
|
|
/*
|
|
|
|
* In case we get here before the ROC event started,
|
|
|
|
* (so the status bit isn't set) set it here so iwl_mvm_cleanup_roc will
|
|
|
|
* cleanup things properly
|
|
|
|
*/
|
|
|
|
set_bit(vif->type == NL80211_IFTYPE_P2P_DEVICE ?
|
|
|
|
IWL_MVM_STATUS_ROC_RUNNING : IWL_MVM_STATUS_ROC_AUX_RUNNING,
|
|
|
|
&mvm->status);
|
2024-05-05 09:19:57 +03:00
|
|
|
|
|
|
|
/* Mutex is released inside this function */
|
2024-02-05 21:21:06 +02:00
|
|
|
iwl_mvm_cleanup_roc(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
2014-05-04 11:48:12 +03:00
|
|
|
|
2020-10-08 18:12:40 +03:00
|
|
|
void iwl_mvm_remove_csa_period(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
|
|
|
|
u32 id;
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
id = te_data->id;
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
if (id != TE_CHANNEL_SWITCH_PERIOD)
|
|
|
|
return;
|
|
|
|
|
|
|
|
iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
|
|
|
|
}
|
|
|
|
|
2014-08-26 16:14:10 +03:00
|
|
|
int iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
u32 duration, u32 apply_time)
|
2014-05-04 11:48:12 +03:00
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
|
|
|
|
struct iwl_time_event_cmd time_cmd = {};
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
if (te_data->running) {
|
2017-08-02 12:13:20 +03:00
|
|
|
u32 id;
|
|
|
|
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
id = te_data->id;
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
if (id == TE_CHANNEL_SWITCH_PERIOD) {
|
|
|
|
IWL_DEBUG_TE(mvm, "CS period is already scheduled\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the session protection time event to allow the
|
|
|
|
* channel switch. If we got here, we just heard a beacon so
|
|
|
|
* the session protection is not needed anymore anyway.
|
|
|
|
*/
|
|
|
|
iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
|
2014-05-04 11:48:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
|
|
|
|
time_cmd.id_and_color =
|
|
|
|
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
|
2014-08-26 16:14:10 +03:00
|
|
|
time_cmd.id = cpu_to_le32(TE_CHANNEL_SWITCH_PERIOD);
|
2014-05-04 11:48:12 +03:00
|
|
|
time_cmd.apply_time = cpu_to_le32(apply_time);
|
|
|
|
time_cmd.max_frags = TE_V2_FRAG_NONE;
|
|
|
|
time_cmd.duration = cpu_to_le32(duration);
|
|
|
|
time_cmd.repeat = 1;
|
|
|
|
time_cmd.interval = cpu_to_le32(1);
|
|
|
|
time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START |
|
|
|
|
TE_V2_ABSENCE);
|
2018-01-04 17:39:08 +02:00
|
|
|
if (!apply_time)
|
|
|
|
time_cmd.policy |= cpu_to_le16(TE_V2_START_IMMEDIATELY);
|
2014-05-04 11:48:12 +03:00
|
|
|
|
|
|
|
return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd);
|
|
|
|
}
|
2019-07-11 21:44:42 +03:00
|
|
|
|
2020-01-31 15:45:29 +02:00
|
|
|
static bool iwl_mvm_session_prot_notif(struct iwl_notif_wait_data *notif_wait,
|
|
|
|
struct iwl_rx_packet *pkt, void *data)
|
|
|
|
{
|
|
|
|
struct iwl_mvm *mvm =
|
|
|
|
container_of(notif_wait, struct iwl_mvm, notif_wait);
|
|
|
|
struct iwl_mvm_session_prot_notif *resp;
|
|
|
|
int resp_len = iwl_rx_packet_payload_len(pkt);
|
|
|
|
|
|
|
|
if (WARN_ON(pkt->hdr.cmd != SESSION_PROTECTION_NOTIF ||
|
|
|
|
pkt->hdr.group_id != MAC_CONF_GROUP))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (WARN_ON_ONCE(resp_len != sizeof(*resp))) {
|
|
|
|
IWL_ERR(mvm, "Invalid SESSION_PROTECTION_NOTIF response\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
resp = (void *)pkt->data;
|
|
|
|
|
|
|
|
if (!resp->status)
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"TIME_EVENT_NOTIFICATION received but not executed\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
void iwl_mvm_schedule_session_protection(struct iwl_mvm *mvm,
|
|
|
|
struct ieee80211_vif *vif,
|
2020-01-31 15:45:29 +02:00
|
|
|
u32 duration, u32 min_duration,
|
wifi: iwlwifi: make time_events MLO aware
As session protection API is moving to be per link instead of per mac,
move the time events to be per link too.
Since there is only one concurrent time event per mac, it feels
unnecessary to have the time_event as a member of iwl_mvm_link_info.
(That way we will have to iterate over all links each time we want to
clear a time event, and also we will need mac80211 to tell us the link
id when mgd_tx_complete() is called.)
So leave this as a member of iwl_mvm_vif, but add the link id to the
time_event structure.
The link id in time_event will only be maintained and used for:
1. When SESSION_PROTECTION_CMD is supported (before it, we don't have MLO)
2. For time_events of types SESSION_PROTECT_CONF_ASSOC,
SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV, and
SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION
(not for aux roc/ Hot Spot time_events).
For P2P, non-MLO connections, and pre-MLD API, deflink id, meaning 0,
will be used
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.21496bcacb18.I79d037325b4fae4c12a22d9477e53fc9c537ad46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-10-17 12:16:36 +03:00
|
|
|
bool wait_for_notif,
|
|
|
|
unsigned int link_id)
|
2019-07-11 21:44:42 +03:00
|
|
|
{
|
|
|
|
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
|
|
|
|
struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
|
2022-01-28 15:34:23 +02:00
|
|
|
const u16 notif[] = { WIDE_ID(MAC_CONF_GROUP, SESSION_PROTECTION_NOTIF) };
|
2020-01-31 15:45:29 +02:00
|
|
|
struct iwl_notification_wait wait_notif;
|
2024-01-23 20:08:16 +02:00
|
|
|
int mac_link_id = iwl_mvm_get_session_prot_id(mvm, vif, (s8)link_id);
|
2019-07-11 21:44:42 +03:00
|
|
|
struct iwl_mvm_session_prot_cmd cmd = {
|
2023-10-17 12:16:37 +03:00
|
|
|
.id_and_color = cpu_to_le32(mac_link_id),
|
2019-07-11 21:44:42 +03:00
|
|
|
.action = cpu_to_le32(FW_CTXT_ACTION_ADD),
|
2021-12-04 13:10:47 +02:00
|
|
|
.conf_id = cpu_to_le32(SESSION_PROTECT_CONF_ASSOC),
|
2019-07-11 21:44:42 +03:00
|
|
|
.duration_tu = cpu_to_le32(MSEC_TO_TU(duration)),
|
|
|
|
};
|
|
|
|
|
2023-10-17 12:16:37 +03:00
|
|
|
if (mac_link_id < 0)
|
|
|
|
return;
|
|
|
|
|
2019-07-11 21:44:42 +03:00
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
wifi: iwlwifi: make time_events MLO aware
As session protection API is moving to be per link instead of per mac,
move the time events to be per link too.
Since there is only one concurrent time event per mac, it feels
unnecessary to have the time_event as a member of iwl_mvm_link_info.
(That way we will have to iterate over all links each time we want to
clear a time event, and also we will need mac80211 to tell us the link
id when mgd_tx_complete() is called.)
So leave this as a member of iwl_mvm_vif, but add the link id to the
time_event structure.
The link id in time_event will only be maintained and used for:
1. When SESSION_PROTECTION_CMD is supported (before it, we don't have MLO)
2. For time_events of types SESSION_PROTECT_CONF_ASSOC,
SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV, and
SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION
(not for aux roc/ Hot Spot time_events).
For P2P, non-MLO connections, and pre-MLD API, deflink id, meaning 0,
will be used
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.21496bcacb18.I79d037325b4fae4c12a22d9477e53fc9c537ad46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-10-17 12:16:36 +03:00
|
|
|
if (te_data->running && te_data->link_id == link_id &&
|
2019-07-11 21:44:42 +03:00
|
|
|
time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
|
|
|
|
IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
|
|
|
|
jiffies_to_msecs(te_data->end_jiffies - jiffies));
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
2021-12-04 13:10:47 +02:00
|
|
|
/*
|
|
|
|
* The time_event_data.id field is reused to save session
|
|
|
|
* protection's configuration.
|
|
|
|
*/
|
|
|
|
te_data->id = le32_to_cpu(cmd.conf_id);
|
2019-07-11 21:44:42 +03:00
|
|
|
te_data->duration = le32_to_cpu(cmd.duration_tu);
|
2021-06-18 11:01:12 +03:00
|
|
|
te_data->vif = vif;
|
wifi: iwlwifi: make time_events MLO aware
As session protection API is moving to be per link instead of per mac,
move the time events to be per link too.
Since there is only one concurrent time event per mac, it feels
unnecessary to have the time_event as a member of iwl_mvm_link_info.
(That way we will have to iterate over all links each time we want to
clear a time event, and also we will need mac80211 to tell us the link
id when mgd_tx_complete() is called.)
So leave this as a member of iwl_mvm_vif, but add the link id to the
time_event structure.
The link id in time_event will only be maintained and used for:
1. When SESSION_PROTECTION_CMD is supported (before it, we don't have MLO)
2. For time_events of types SESSION_PROTECT_CONF_ASSOC,
SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV, and
SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION
(not for aux roc/ Hot Spot time_events).
For P2P, non-MLO connections, and pre-MLD API, deflink id, meaning 0,
will be used
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.21496bcacb18.I79d037325b4fae4c12a22d9477e53fc9c537ad46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-10-17 12:16:36 +03:00
|
|
|
te_data->link_id = link_id;
|
2019-07-11 21:44:42 +03:00
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
|
|
|
|
|
|
|
IWL_DEBUG_TE(mvm, "Add new session protection, duration %d TU\n",
|
|
|
|
le32_to_cpu(cmd.duration_tu));
|
|
|
|
|
2020-01-31 15:45:29 +02:00
|
|
|
if (!wait_for_notif) {
|
|
|
|
if (iwl_mvm_send_cmd_pdu(mvm,
|
2022-01-28 15:34:23 +02:00
|
|
|
WIDE_ID(MAC_CONF_GROUP, SESSION_PROTECTION_CMD),
|
2020-01-31 15:45:29 +02:00
|
|
|
0, sizeof(cmd), &cmd)) {
|
2023-10-17 12:16:37 +03:00
|
|
|
goto send_cmd_err;
|
2020-01-31 15:45:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iwl_init_notification_wait(&mvm->notif_wait, &wait_notif,
|
|
|
|
notif, ARRAY_SIZE(notif),
|
|
|
|
iwl_mvm_session_prot_notif, NULL);
|
|
|
|
|
|
|
|
if (iwl_mvm_send_cmd_pdu(mvm,
|
2022-01-28 15:34:23 +02:00
|
|
|
WIDE_ID(MAC_CONF_GROUP, SESSION_PROTECTION_CMD),
|
2020-01-31 15:45:29 +02:00
|
|
|
0, sizeof(cmd), &cmd)) {
|
|
|
|
iwl_remove_notification(&mvm->notif_wait, &wait_notif);
|
2023-10-17 12:16:37 +03:00
|
|
|
goto send_cmd_err;
|
2020-01-31 15:45:29 +02:00
|
|
|
} else if (iwl_wait_notification(&mvm->notif_wait, &wait_notif,
|
|
|
|
TU_TO_JIFFIES(100))) {
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"Failed to protect session until session protection\n");
|
2019-07-11 21:44:42 +03:00
|
|
|
}
|
2023-10-17 12:16:37 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
send_cmd_err:
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"Couldn't send the SESSION_PROTECTION_CMD\n");
|
|
|
|
spin_lock_bh(&mvm->time_event_lock);
|
|
|
|
iwl_mvm_te_clear_data(mvm, te_data);
|
|
|
|
spin_unlock_bh(&mvm->time_event_lock);
|
2019-07-11 21:44:42 +03:00
|
|
|
}
|