Path: blob/main/sys/contrib/dev/iwlwifi/mvm/time-event.h
48287 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2012-2014, 2019-2020, 2023, 2025 Intel Corporation3* Copyright (C) 2013-2014 Intel Mobile Communications GmbH4*/5#ifndef __time_event_h__6#define __time_event_h__78#include "fw-api.h"910#include "mvm.h"1112/**13* DOC: Time Events - what is it?14*15* Time Events are a fw feature that allows the driver to control the presence16* of the device on the channel. Since the fw supports multiple channels17* concurrently, the fw may choose to jump to another channel at any time.18* In order to make sure that the fw is on a specific channel at a certain time19* and for a certain duration, the driver needs to issue a time event.20*21* The simplest example is for BSS association. The driver issues a time event,22* waits for it to start, and only then tells mac80211 that we can start the23* association. This way, we make sure that the association will be done24* smoothly and won't be interrupted by channel switch decided within the fw.25*/2627/**28* DOC: The flow against the fw29*30* When the driver needs to make sure we are in a certain channel, at a certain31* time and for a certain duration, it sends a Time Event. The flow against the32* fw goes like this:33* 1) Driver sends a TIME_EVENT_CMD to the fw34* 2) Driver gets the response for that command. This response contains the35* Unique ID (UID) of the event.36* 3) The fw sends notification when the event starts.37*38* Of course the API provides various options that allow to cover parameters39* of the flow.40* What is the duration of the event?41* What is the start time of the event?42* Is there an end-time for the event?43* How much can the event be delayed?44* Can the event be split?45* If yes what is the maximal number of chunks?46* etc...47*/4849/**50* DOC: Abstraction to the driver51*52* In order to simplify the use of time events to the rest of the driver,53* we abstract the use of time events. This component provides the functions54* needed by the driver.55*/5657#define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 60058#define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 4005960/**61* iwl_mvm_protect_session - start / extend the session protection.62* @mvm: the mvm component63* @vif: the virtual interface for which the session is issued64* @duration: the duration of the session in TU.65* @min_duration: will start a new session if the current session will end66* in less than min_duration.67* @max_delay: maximum delay before starting the time event (in TU)68* @wait_for_notif: true if it is required that a time event notification be69* waited for (that the time event has been scheduled before returning)70*71* This function can be used to start a session protection which means that the72* fw will stay on the channel for %duration_ms milliseconds. This function73* can block (sleep) until the session starts. This function can also be used74* to extend a currently running session.75* This function is meant to be used for BSS association for example, where we76* want to make sure that the fw stays on the channel during the association.77*/78void iwl_mvm_protect_session(struct iwl_mvm *mvm,79struct ieee80211_vif *vif,80u32 duration, u32 min_duration,81u32 max_delay, bool wait_for_notif);8283/**84* iwl_mvm_stop_session_protection - cancel the session protection.85* @mvm: the mvm component86* @vif: the virtual interface for which the session is issued87*88* This functions cancels the session protection which is an act of good89* citizenship. If it is not needed any more it should be canceled because90* the other bindings wait for the medium during that time.91* This funtions doesn't sleep.92*/93void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,94struct ieee80211_vif *vif);9596/*97* iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION.98*/99void iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,100struct iwl_rx_cmd_buffer *rxb);101102/**103* iwl_mvm_rx_roc_notif - handles %DISCOVERY_ROC_NTF.104* @mvm: the mvm component105* @rxb: RX buffer106*/107void iwl_mvm_rx_roc_notif(struct iwl_mvm *mvm,108struct iwl_rx_cmd_buffer *rxb);109110/**111* iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionality112* @mvm: the mvm component113* @vif: the virtual interface for which the roc is requested. It is assumed114* that the vif type is NL80211_IFTYPE_P2P_DEVICE115* @duration: the requested duration in millisecond for the fw to be on the116* channel that is bound to the vif.117* @type: the remain on channel request type118*119* This function can be used to issue a remain on channel session,120* which means that the fw will stay in the channel for the request %duration121* milliseconds. The function is async, meaning that it only issues the ROC122* request but does not wait for it to start. Once the FW is ready to serve the123* ROC request, it will issue a notification to the driver that it is on the124* requested channel. Once the FW completes the ROC request it will issue125* another notification to the driver.126*127* Return: negative error code or 0 on success128*/129int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,130int duration, enum ieee80211_roc_type type);131132/**133* iwl_mvm_stop_roc - stop remain on channel functionality134* @mvm: the mvm component135* @vif: the virtual interface for which the roc is stopped136*137* This function can be used to cancel an ongoing ROC session.138* The function is async, it will instruct the FW to stop serving the ROC139* session, but will not wait for the actual stopping of the session.140*/141void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);142143/**144* iwl_mvm_remove_time_event - general function to clean up of time event145* @mvm: the mvm component146* @mvmvif: the vif to which the time event belongs147* @te_data: the time event data that corresponds to that time event148*149* This function can be used to cancel a time event regardless its type.150* It is useful for cleaning up time events running before removing an151* interface.152*/153void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,154struct iwl_mvm_vif *mvmvif,155struct iwl_mvm_time_event_data *te_data);156157/**158* iwl_mvm_te_clear_data - remove time event from list159* @mvm: the mvm component160* @te_data: the time event data to remove161*162* This function is mostly internal, it is made available here only163* for firmware restart purposes.164*/165void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,166struct iwl_mvm_time_event_data *te_data);167168void iwl_mvm_cleanup_roc_te(struct iwl_mvm *mvm);169void iwl_mvm_roc_done_wk(struct work_struct *wk);170171void iwl_mvm_remove_csa_period(struct iwl_mvm *mvm,172struct ieee80211_vif *vif);173174/**175* iwl_mvm_schedule_csa_period - request channel switch absence period176* @mvm: the mvm component177* @vif: the virtual interface for which the channel switch is issued178* @duration: the duration of the NoA in TU.179* @apply_time: NoA start time in GP2.180*181* This function is used to schedule NoA time event and is used to perform182* the channel switch flow.183*184* Return: negative error code or 0 on success185*/186int iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm,187struct ieee80211_vif *vif,188u32 duration, u32 apply_time);189190/**191* iwl_mvm_te_scheduled - check if the fw received the TE cmd192* @te_data: the time event data that corresponds to that time event193*194* Return: %true if this TE is added to the fw, %false otherwise195*/196static inline bool197iwl_mvm_te_scheduled(struct iwl_mvm_time_event_data *te_data)198{199if (!te_data)200return false;201202return !!te_data->uid;203}204205/**206* iwl_mvm_schedule_session_protection - schedule a session protection207* @mvm: the mvm component208* @vif: the virtual interface for which the protection issued209* @duration: the requested duration of the protection210* @min_duration: the minimum duration of the protection211* @wait_for_notif: if true, will block until the start of the protection212* @link_id: The link to schedule a session protection for213*/214void iwl_mvm_schedule_session_protection(struct iwl_mvm *mvm,215struct ieee80211_vif *vif,216u32 duration, u32 min_duration,217bool wait_for_notif,218unsigned int link_id);219220/**221* iwl_mvm_rx_session_protect_notif - handles %SESSION_PROTECTION_NOTIF222* @mvm: the mvm component223* @rxb: the RX buffer containing the notification224*/225void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm,226struct iwl_rx_cmd_buffer *rxb);227228#endif /* __time_event_h__ */229230231