Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
0002 /*
0003  * Copyright (C) 2012-2014, 2019-2020 Intel Corporation
0004  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
0005  */
0006 #ifndef __time_event_h__
0007 #define __time_event_h__
0008 
0009 #include "fw-api.h"
0010 
0011 #include "mvm.h"
0012 
0013 /**
0014  * DOC: Time Events - what is it?
0015  *
0016  * Time Events are a fw feature that allows the driver to control the presence
0017  * of the device on the channel. Since the fw supports multiple channels
0018  * concurrently, the fw may choose to jump to another channel at any time.
0019  * In order to make sure that the fw is on a specific channel at a certain time
0020  * and for a certain duration, the driver needs to issue a time event.
0021  *
0022  * The simplest example is for BSS association. The driver issues a time event,
0023  * waits for it to start, and only then tells mac80211 that we can start the
0024  * association. This way, we make sure that the association will be done
0025  * smoothly and won't be interrupted by channel switch decided within the fw.
0026  */
0027 
0028  /**
0029  * DOC: The flow against the fw
0030  *
0031  * When the driver needs to make sure we are in a certain channel, at a certain
0032  * time and for a certain duration, it sends a Time Event. The flow against the
0033  * fw goes like this:
0034  *  1) Driver sends a TIME_EVENT_CMD to the fw
0035  *  2) Driver gets the response for that command. This response contains the
0036  *     Unique ID (UID) of the event.
0037  *  3) The fw sends notification when the event starts.
0038  *
0039  * Of course the API provides various options that allow to cover parameters
0040  * of the flow.
0041  *  What is the duration of the event?
0042  *  What is the start time of the event?
0043  *  Is there an end-time for the event?
0044  *  How much can the event be delayed?
0045  *  Can the event be split?
0046  *  If yes what is the maximal number of chunks?
0047  *  etc...
0048  */
0049 
0050 /**
0051  * DOC: Abstraction to the driver
0052  *
0053  * In order to simplify the use of time events to the rest of the driver,
0054  * we abstract the use of time events. This component provides the functions
0055  * needed by the driver.
0056  */
0057 
0058 #define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 600
0059 #define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
0060 
0061 /**
0062  * iwl_mvm_protect_session - start / extend the session protection.
0063  * @mvm: the mvm component
0064  * @vif: the virtual interface for which the session is issued
0065  * @duration: the duration of the session in TU.
0066  * @min_duration: will start a new session if the current session will end
0067  *  in less than min_duration.
0068  * @max_delay: maximum delay before starting the time event (in TU)
0069  * @wait_for_notif: true if it is required that a time event notification be
0070  *  waited for (that the time event has been scheduled before returning)
0071  *
0072  * This function can be used to start a session protection which means that the
0073  * fw will stay on the channel for %duration_ms milliseconds. This function
0074  * can block (sleep) until the session starts. This function can also be used
0075  * to extend a currently running session.
0076  * This function is meant to be used for BSS association for example, where we
0077  * want to make sure that the fw stays on the channel during the association.
0078  */
0079 void iwl_mvm_protect_session(struct iwl_mvm *mvm,
0080                  struct ieee80211_vif *vif,
0081                  u32 duration, u32 min_duration,
0082                  u32 max_delay, bool wait_for_notif);
0083 
0084 /**
0085  * iwl_mvm_stop_session_protection - cancel the session protection.
0086  * @mvm: the mvm component
0087  * @vif: the virtual interface for which the session is issued
0088  *
0089  * This functions cancels the session protection which is an act of good
0090  * citizenship. If it is not needed any more it should be canceled because
0091  * the other bindings wait for the medium during that time.
0092  * This funtions doesn't sleep.
0093  */
0094 void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
0095                       struct ieee80211_vif *vif);
0096 
0097 /*
0098  * iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION.
0099  */
0100 void iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
0101                  struct iwl_rx_cmd_buffer *rxb);
0102 
0103 /**
0104  * iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionality
0105  * @mvm: the mvm component
0106  * @vif: the virtual interface for which the roc is requested. It is assumed
0107  * that the vif type is NL80211_IFTYPE_P2P_DEVICE
0108  * @duration: the requested duration in millisecond for the fw to be on the
0109  * channel that is bound to the vif.
0110  * @type: the remain on channel request type
0111  *
0112  * This function can be used to issue a remain on channel session,
0113  * which means that the fw will stay in the channel for the request %duration
0114  * milliseconds. The function is async, meaning that it only issues the ROC
0115  * request but does not wait for it to start. Once the FW is ready to serve the
0116  * ROC request, it will issue a notification to the driver that it is on the
0117  * requested channel. Once the FW completes the ROC request it will issue
0118  * another notification to the driver.
0119  */
0120 int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
0121               int duration, enum ieee80211_roc_type type);
0122 
0123 /**
0124  * iwl_mvm_stop_roc - stop remain on channel functionality
0125  * @mvm: the mvm component
0126  * @vif: the virtual interface for which the roc is stopped
0127  *
0128  * This function can be used to cancel an ongoing ROC session.
0129  * The function is async, it will instruct the FW to stop serving the ROC
0130  * session, but will not wait for the actual stopping of the session.
0131  */
0132 void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
0133 
0134 /**
0135  * iwl_mvm_remove_time_event - general function to clean up of time event
0136  * @mvm: the mvm component
0137  * @vif: the vif to which the time event belongs
0138  * @te_data: the time event data that corresponds to that time event
0139  *
0140  * This function can be used to cancel a time event regardless its type.
0141  * It is useful for cleaning up time events running before removing an
0142  * interface.
0143  */
0144 void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
0145                    struct iwl_mvm_vif *mvmvif,
0146                    struct iwl_mvm_time_event_data *te_data);
0147 
0148 /**
0149  * iwl_mvm_te_clear_data - remove time event from list
0150  * @mvm: the mvm component
0151  * @te_data: the time event data to remove
0152  *
0153  * This function is mostly internal, it is made available here only
0154  * for firmware restart purposes.
0155  */
0156 void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
0157                struct iwl_mvm_time_event_data *te_data);
0158 
0159 void iwl_mvm_cleanup_roc_te(struct iwl_mvm *mvm);
0160 void iwl_mvm_roc_done_wk(struct work_struct *wk);
0161 
0162 void iwl_mvm_remove_csa_period(struct iwl_mvm *mvm,
0163                    struct ieee80211_vif *vif);
0164 
0165 /**
0166  * iwl_mvm_schedule_csa_period - request channel switch absence period
0167  * @mvm: the mvm component
0168  * @vif: the virtual interface for which the channel switch is issued
0169  * @duration: the duration of the NoA in TU.
0170  * @apply_time: NoA start time in GP2.
0171  *
0172  * This function is used to schedule NoA time event and is used to perform
0173  * the channel switch flow.
0174  */
0175 int iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm,
0176                 struct ieee80211_vif *vif,
0177                 u32 duration, u32 apply_time);
0178 
0179 /**
0180  * iwl_mvm_te_scheduled - check if the fw received the TE cmd
0181  * @te_data: the time event data that corresponds to that time event
0182  *
0183  * This function returns true iff this TE is added to the fw.
0184  */
0185 static inline bool
0186 iwl_mvm_te_scheduled(struct iwl_mvm_time_event_data *te_data)
0187 {
0188     if (!te_data)
0189         return false;
0190 
0191     return !!te_data->uid;
0192 }
0193 
0194 /**
0195  * iwl_mvm_schedule_session_protection - schedule a session protection
0196  * @mvm: the mvm component
0197  * @vif: the virtual interface for which the protection issued
0198  * @duration: the duration of the protection
0199  * @wait_for_notif: if true, will block until the start of the protection
0200  */
0201 void iwl_mvm_schedule_session_protection(struct iwl_mvm *mvm,
0202                      struct ieee80211_vif *vif,
0203                      u32 duration, u32 min_duration,
0204                      bool wait_for_notif);
0205 
0206 /**
0207  * iwl_mvm_rx_session_protect_notif - handles %SESSION_PROTECTION_NOTIF
0208  */
0209 void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm,
0210                       struct iwl_rx_cmd_buffer *rxb);
0211 
0212 #endif /* __time_event_h__ */