| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2012-2014, 2019-2020, 2023, 2025 Intel Corporation |
| 4 |
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH |
| 5 |
*/ |
| 6 |
#ifndef __time_event_h__ |
| 7 |
#define __time_event_h__ |
| 8 |
|
| 9 |
#include "fw-api.h" |
| 10 |
|
| 11 |
#include "mvm.h" |
| 12 |
|
| 13 |
/** |
| 14 |
* DOC: Time Events - what is it? |
| 15 |
* |
| 16 |
* Time Events are a fw feature that allows the driver to control the presence |
| 17 |
* of the device on the channel. Since the fw supports multiple channels |
| 18 |
* concurrently, the fw may choose to jump to another channel at any time. |
| 19 |
* In order to make sure that the fw is on a specific channel at a certain time |
| 20 |
* and for a certain duration, the driver needs to issue a time event. |
| 21 |
* |
| 22 |
* The simplest example is for BSS association. The driver issues a time event, |
| 23 |
* waits for it to start, and only then tells mac80211 that we can start the |
| 24 |
* association. This way, we make sure that the association will be done |
| 25 |
* smoothly and won't be interrupted by channel switch decided within the fw. |
| 26 |
*/ |
| 27 |
|
| 28 |
/** |
| 29 |
* DOC: The flow against the fw |
| 30 |
* |
| 31 |
* When the driver needs to make sure we are in a certain channel, at a certain |
| 32 |
* time and for a certain duration, it sends a Time Event. The flow against the |
| 33 |
* fw goes like this: |
| 34 |
* 1) Driver sends a TIME_EVENT_CMD to the fw |
| 35 |
* 2) Driver gets the response for that command. This response contains the |
| 36 |
* Unique ID (UID) of the event. |
| 37 |
* 3) The fw sends notification when the event starts. |
| 38 |
* |
| 39 |
* Of course the API provides various options that allow to cover parameters |
| 40 |
* of the flow. |
| 41 |
* What is the duration of the event? |
| 42 |
* What is the start time of the event? |
| 43 |
* Is there an end-time for the event? |
| 44 |
* How much can the event be delayed? |
| 45 |
* Can the event be split? |
| 46 |
* If yes what is the maximal number of chunks? |
| 47 |
* etc... |
| 48 |
*/ |
| 49 |
|
| 50 |
/** |
| 51 |
* DOC: Abstraction to the driver |
| 52 |
* |
| 53 |
* In order to simplify the use of time events to the rest of the driver, |
| 54 |
* we abstract the use of time events. This component provides the functions |
| 55 |
* needed by the driver. |
| 56 |
*/ |
| 57 |
|
| 58 |
#define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 600 |
| 59 |
#define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400 |
| 60 |
|
| 61 |
/** |
| 62 |
* iwl_mvm_protect_session - start / extend the session protection. |
| 63 |
* @mvm: the mvm component |
| 64 |
* @vif: the virtual interface for which the session is issued |
| 65 |
* @duration: the duration of the session in TU. |
| 66 |
* @min_duration: will start a new session if the current session will end |
| 67 |
* in less than min_duration. |
| 68 |
* @max_delay: maximum delay before starting the time event (in TU) |
| 69 |
* @wait_for_notif: true if it is required that a time event notification be |
| 70 |
* waited for (that the time event has been scheduled before returning) |
| 71 |
* |
| 72 |
* This function can be used to start a session protection which means that the |
| 73 |
* fw will stay on the channel for %duration_ms milliseconds. This function |
| 74 |
* can block (sleep) until the session starts. This function can also be used |
| 75 |
* to extend a currently running session. |
| 76 |
* This function is meant to be used for BSS association for example, where we |
| 77 |
* want to make sure that the fw stays on the channel during the association. |
| 78 |
*/ |
| 79 |
void iwl_mvm_protect_session(struct iwl_mvm *mvm, |
| 80 |
struct ieee80211_vif *vif, |
| 81 |
u32 duration, u32 min_duration, |
| 82 |
u32 max_delay, bool wait_for_notif); |
| 83 |
|
| 84 |
/** |
| 85 |
* iwl_mvm_stop_session_protection - cancel the session protection. |
| 86 |
* @mvm: the mvm component |
| 87 |
* @vif: the virtual interface for which the session is issued |
| 88 |
* |
| 89 |
* This functions cancels the session protection which is an act of good |
| 90 |
* citizenship. If it is not needed any more it should be canceled because |
| 91 |
* the other bindings wait for the medium during that time. |
| 92 |
* This funtions doesn't sleep. |
| 93 |
*/ |
| 94 |
void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm, |
| 95 |
struct ieee80211_vif *vif); |
| 96 |
|
| 97 |
/* |
| 98 |
* iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION. |
| 99 |
*/ |
| 100 |
void iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm, |
| 101 |
struct iwl_rx_cmd_buffer *rxb); |
| 102 |
|
| 103 |
/** |
| 104 |
* iwl_mvm_rx_roc_notif - handles %DISCOVERY_ROC_NTF. |
| 105 |
* @mvm: the mvm component |
| 106 |
* @rxb: RX buffer |
| 107 |
*/ |
| 108 |
void iwl_mvm_rx_roc_notif(struct iwl_mvm *mvm, |
| 109 |
struct iwl_rx_cmd_buffer *rxb); |
| 110 |
|
| 111 |
/** |
| 112 |
* iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionality |
| 113 |
* @mvm: the mvm component |
| 114 |
* @vif: the virtual interface for which the roc is requested. It is assumed |
| 115 |
* that the vif type is NL80211_IFTYPE_P2P_DEVICE |
| 116 |
* @duration: the requested duration in millisecond for the fw to be on the |
| 117 |
* channel that is bound to the vif. |
| 118 |
* @type: the remain on channel request type |
| 119 |
* |
| 120 |
* This function can be used to issue a remain on channel session, |
| 121 |
* which means that the fw will stay in the channel for the request %duration |
| 122 |
* milliseconds. The function is async, meaning that it only issues the ROC |
| 123 |
* request but does not wait for it to start. Once the FW is ready to serve the |
| 124 |
* ROC request, it will issue a notification to the driver that it is on the |
| 125 |
* requested channel. Once the FW completes the ROC request it will issue |
| 126 |
* another notification to the driver. |
| 127 |
* |
| 128 |
* Return: negative error code or 0 on success |
| 129 |
*/ |
| 130 |
int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 131 |
int duration, enum ieee80211_roc_type type); |
| 132 |
|
| 133 |
/** |
| 134 |
* iwl_mvm_stop_roc - stop remain on channel functionality |
| 135 |
* @mvm: the mvm component |
| 136 |
* @vif: the virtual interface for which the roc is stopped |
| 137 |
* |
| 138 |
* This function can be used to cancel an ongoing ROC session. |
| 139 |
* The function is async, it will instruct the FW to stop serving the ROC |
| 140 |
* session, but will not wait for the actual stopping of the session. |
| 141 |
*/ |
| 142 |
void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif); |
| 143 |
|
| 144 |
/** |
| 145 |
* iwl_mvm_remove_time_event - general function to clean up of time event |
| 146 |
* @mvm: the mvm component |
| 147 |
* @mvmvif: the vif to which the time event belongs |
| 148 |
* @te_data: the time event data that corresponds to that time event |
| 149 |
* |
| 150 |
* This function can be used to cancel a time event regardless its type. |
| 151 |
* It is useful for cleaning up time events running before removing an |
| 152 |
* interface. |
| 153 |
*/ |
| 154 |
void iwl_mvm_remove_time_event(struct iwl_mvm *mvm, |
| 155 |
struct iwl_mvm_vif *mvmvif, |
| 156 |
struct iwl_mvm_time_event_data *te_data); |
| 157 |
|
| 158 |
/** |
| 159 |
* iwl_mvm_te_clear_data - remove time event from list |
| 160 |
* @mvm: the mvm component |
| 161 |
* @te_data: the time event data to remove |
| 162 |
* |
| 163 |
* This function is mostly internal, it is made available here only |
| 164 |
* for firmware restart purposes. |
| 165 |
*/ |
| 166 |
void iwl_mvm_te_clear_data(struct iwl_mvm *mvm, |
| 167 |
struct iwl_mvm_time_event_data *te_data); |
| 168 |
|
| 169 |
void iwl_mvm_cleanup_roc_te(struct iwl_mvm *mvm); |
| 170 |
void iwl_mvm_roc_done_wk(struct work_struct *wk); |
| 171 |
|
| 172 |
void iwl_mvm_remove_csa_period(struct iwl_mvm *mvm, |
| 173 |
struct ieee80211_vif *vif); |
| 174 |
|
| 175 |
/** |
| 176 |
* iwl_mvm_schedule_csa_period - request channel switch absence period |
| 177 |
* @mvm: the mvm component |
| 178 |
* @vif: the virtual interface for which the channel switch is issued |
| 179 |
* @duration: the duration of the NoA in TU. |
| 180 |
* @apply_time: NoA start time in GP2. |
| 181 |
* |
| 182 |
* This function is used to schedule NoA time event and is used to perform |
| 183 |
* the channel switch flow. |
| 184 |
* |
| 185 |
* Return: negative error code or 0 on success |
| 186 |
*/ |
| 187 |
int iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm, |
| 188 |
struct ieee80211_vif *vif, |
| 189 |
u32 duration, u32 apply_time); |
| 190 |
|
| 191 |
/** |
| 192 |
* iwl_mvm_te_scheduled - check if the fw received the TE cmd |
| 193 |
* @te_data: the time event data that corresponds to that time event |
| 194 |
* |
| 195 |
* Return: %true if this TE is added to the fw, %false otherwise |
| 196 |
*/ |
| 197 |
static inline bool |
| 198 |
iwl_mvm_te_scheduled(struct iwl_mvm_time_event_data *te_data) |
| 199 |
{ |
| 200 |
if (!te_data) |
| 201 |
return false; |
| 202 |
|
| 203 |
return !!te_data->uid; |
| 204 |
} |
| 205 |
|
| 206 |
/** |
| 207 |
* iwl_mvm_schedule_session_protection - schedule a session protection |
| 208 |
* @mvm: the mvm component |
| 209 |
* @vif: the virtual interface for which the protection issued |
| 210 |
* @duration: the requested duration of the protection |
| 211 |
* @min_duration: the minimum duration of the protection |
| 212 |
* @wait_for_notif: if true, will block until the start of the protection |
| 213 |
*/ |
| 214 |
void iwl_mvm_schedule_session_protection(struct iwl_mvm *mvm, |
| 215 |
struct ieee80211_vif *vif, |
| 216 |
u32 duration, u32 min_duration, |
| 217 |
bool wait_for_notif); |
| 218 |
|
| 219 |
/** |
| 220 |
* iwl_mvm_rx_session_protect_notif - handles %SESSION_PROTECTION_NOTIF |
| 221 |
* @mvm: the mvm component |
| 222 |
* @rxb: the RX buffer containing the notification |
| 223 |
*/ |
| 224 |
void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm, |
| 225 |
struct iwl_rx_cmd_buffer *rxb); |
| 226 |
|
| 227 |
#endif /* __time_event_h__ */ |