1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10 * Copyright (C) 2019 Intel Corporation
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * The full GNU General Public License is included in this distribution
22 * in the file called COPYING.
24 * Contact Information:
25 * Intel Linux Wireless <linuxwifi@intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
32 * Copyright (C) 2019 Intel Corporation
33 * All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
39 * * Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * * Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in
43 * the documentation and/or other materials provided with the
45 * * Neither the name Intel Corporation nor the names of its
46 * contributors may be used to endorse or promote products derived
47 * from this software without specific prior written permission.
49 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
52 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *****************************************************************************/
63 #ifndef __time_event_h__
64 #define __time_event_h__
71 * DOC: Time Events - what is it?
73 * Time Events are a fw feature that allows the driver to control the presence
74 * of the device on the channel. Since the fw supports multiple channels
75 * concurrently, the fw may choose to jump to another channel at any time.
76 * In order to make sure that the fw is on a specific channel at a certain time
77 * and for a certain duration, the driver needs to issue a time event.
79 * The simplest example is for BSS association. The driver issues a time event,
80 * waits for it to start, and only then tells mac80211 that we can start the
81 * association. This way, we make sure that the association will be done
82 * smoothly and won't be interrupted by channel switch decided within the fw.
86 * DOC: The flow against the fw
88 * When the driver needs to make sure we are in a certain channel, at a certain
89 * time and for a certain duration, it sends a Time Event. The flow against the
91 * 1) Driver sends a TIME_EVENT_CMD to the fw
92 * 2) Driver gets the response for that command. This response contains the
93 * Unique ID (UID) of the event.
94 * 3) The fw sends notification when the event starts.
96 * Of course the API provides various options that allow to cover parameters
98 * What is the duration of the event?
99 * What is the start time of the event?
100 * Is there an end-time for the event?
101 * How much can the event be delayed?
102 * Can the event be split?
103 * If yes what is the maximal number of chunks?
108 * DOC: Abstraction to the driver
110 * In order to simplify the use of time events to the rest of the driver,
111 * we abstract the use of time events. This component provides the functions
112 * needed by the driver.
115 #define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 600
116 #define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
119 * iwl_mvm_protect_session - start / extend the session protection.
120 * @mvm: the mvm component
121 * @vif: the virtual interface for which the session is issued
122 * @duration: the duration of the session in TU.
123 * @min_duration: will start a new session if the current session will end
124 * in less than min_duration.
125 * @max_delay: maximum delay before starting the time event (in TU)
126 * @wait_for_notif: true if it is required that a time event notification be
127 * waited for (that the time event has been scheduled before returning)
129 * This function can be used to start a session protection which means that the
130 * fw will stay on the channel for %duration_ms milliseconds. This function
131 * can block (sleep) until the session starts. This function can also be used
132 * to extend a currently running session.
133 * This function is meant to be used for BSS association for example, where we
134 * want to make sure that the fw stays on the channel during the association.
136 void iwl_mvm_protect_session(struct iwl_mvm
*mvm
,
137 struct ieee80211_vif
*vif
,
138 u32 duration
, u32 min_duration
,
139 u32 max_delay
, bool wait_for_notif
);
142 * iwl_mvm_stop_session_protection - cancel the session protection.
143 * @mvm: the mvm component
144 * @vif: the virtual interface for which the session is issued
146 * This functions cancels the session protection which is an act of good
147 * citizenship. If it is not needed any more it should be canceled because
148 * the other bindings wait for the medium during that time.
149 * This funtions doesn't sleep.
151 void iwl_mvm_stop_session_protection(struct iwl_mvm
*mvm
,
152 struct ieee80211_vif
*vif
);
155 * iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION.
157 void iwl_mvm_rx_time_event_notif(struct iwl_mvm
*mvm
,
158 struct iwl_rx_cmd_buffer
*rxb
);
161 * iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionality
162 * @mvm: the mvm component
163 * @vif: the virtual interface for which the roc is requested. It is assumed
164 * that the vif type is NL80211_IFTYPE_P2P_DEVICE
165 * @duration: the requested duration in millisecond for the fw to be on the
166 * channel that is bound to the vif.
167 * @type: the remain on channel request type
169 * This function can be used to issue a remain on channel session,
170 * which means that the fw will stay in the channel for the request %duration
171 * milliseconds. The function is async, meaning that it only issues the ROC
172 * request but does not wait for it to start. Once the FW is ready to serve the
173 * ROC request, it will issue a notification to the driver that it is on the
174 * requested channel. Once the FW completes the ROC request it will issue
175 * another notification to the driver.
177 int iwl_mvm_start_p2p_roc(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
178 int duration
, enum ieee80211_roc_type type
);
181 * iwl_mvm_stop_roc - stop remain on channel functionality
182 * @mvm: the mvm component
183 * @vif: the virtual interface for which the roc is stopped
185 * This function can be used to cancel an ongoing ROC session.
186 * The function is async, it will instruct the FW to stop serving the ROC
187 * session, but will not wait for the actual stopping of the session.
189 void iwl_mvm_stop_roc(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
);
192 * iwl_mvm_remove_time_event - general function to clean up of time event
193 * @mvm: the mvm component
194 * @vif: the vif to which the time event belongs
195 * @te_data: the time event data that corresponds to that time event
197 * This function can be used to cancel a time event regardless its type.
198 * It is useful for cleaning up time events running before removing an
201 void iwl_mvm_remove_time_event(struct iwl_mvm
*mvm
,
202 struct iwl_mvm_vif
*mvmvif
,
203 struct iwl_mvm_time_event_data
*te_data
);
206 * iwl_mvm_te_clear_data - remove time event from list
207 * @mvm: the mvm component
208 * @te_data: the time event data to remove
210 * This function is mostly internal, it is made available here only
211 * for firmware restart purposes.
213 void iwl_mvm_te_clear_data(struct iwl_mvm
*mvm
,
214 struct iwl_mvm_time_event_data
*te_data
);
216 void iwl_mvm_cleanup_roc_te(struct iwl_mvm
*mvm
);
217 void iwl_mvm_roc_done_wk(struct work_struct
*wk
);
220 * iwl_mvm_schedule_csa_period - request channel switch absence period
221 * @mvm: the mvm component
222 * @vif: the virtual interface for which the channel switch is issued
223 * @duration: the duration of the NoA in TU.
224 * @apply_time: NoA start time in GP2.
226 * This function is used to schedule NoA time event and is used to perform
227 * the channel switch flow.
229 int iwl_mvm_schedule_csa_period(struct iwl_mvm
*mvm
,
230 struct ieee80211_vif
*vif
,
231 u32 duration
, u32 apply_time
);
234 * iwl_mvm_te_scheduled - check if the fw received the TE cmd
235 * @te_data: the time event data that corresponds to that time event
237 * This function returns true iff this TE is added to the fw.
240 iwl_mvm_te_scheduled(struct iwl_mvm_time_event_data
*te_data
)
245 return !!te_data
->uid
;
249 * iwl_mvm_schedule_session_protection - schedule a session protection
250 * @mvm: the mvm component
251 * @vif: the virtual interface for which the protection issued
252 * @duration: the duration of the protection
253 * @wait_for_notif: if true, will block until the start of the protection
255 void iwl_mvm_schedule_session_protection(struct iwl_mvm
*mvm
,
256 struct ieee80211_vif
*vif
,
257 u32 duration
, u32 min_duration
,
258 bool wait_for_notif
);
261 * iwl_mvm_rx_session_protect_notif - handles %SESSION_PROTECTION_NOTIF
263 void iwl_mvm_rx_session_protect_notif(struct iwl_mvm
*mvm
,
264 struct iwl_rx_cmd_buffer
*rxb
);
266 #endif /* __time_event_h__ */