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.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
33 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 *****************************************************************************/
64 #ifndef __time_event_h__
65 #define __time_event_h__
72 * DOC: Time Events - what is it?
74 * Time Events are a fw feature that allows the driver to control the presence
75 * of the device on the channel. Since the fw supports multiple channels
76 * concurrently, the fw may choose to jump to another channel at any time.
77 * In order to make sure that the fw is on a specific channel at a certain time
78 * and for a certain duration, the driver needs to issue a time event.
80 * The simplest example is for BSS association. The driver issues a time event,
81 * waits for it to start, and only then tells mac80211 that we can start the
82 * association. This way, we make sure that the association will be done
83 * smoothly and won't be interrupted by channel switch decided within the fw.
87 * DOC: The flow against the fw
89 * When the driver needs to make sure we are in a certain channel, at a certain
90 * time and for a certain duration, it sends a Time Event. The flow against the
92 * 1) Driver sends a TIME_EVENT_CMD to the fw
93 * 2) Driver gets the response for that command. This response contains the
94 * Unique ID (UID) of the event.
95 * 3) The fw sends notification when the event starts.
97 * Of course the API provides various options that allow to cover parameters
99 * What is the duration of the event?
100 * What is the start time of the event?
101 * Is there an end-time for the event?
102 * How much can the event be delayed?
103 * Can the event be split?
104 * If yes what is the maximal number of chunks?
109 * DOC: Abstraction to the driver
111 * In order to simplify the use of time events to the rest of the driver,
112 * we abstract the use of time events. This component provides the functions
113 * needed by the driver.
116 #define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 500
117 #define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
120 * iwl_mvm_protect_session - start / extend the session protection.
121 * @mvm: the mvm component
122 * @vif: the virtual interface for which the session is issued
123 * @duration: the duration of the session in TU.
124 * @min_duration: will start a new session if the current session will end
125 * in less than min_duration.
126 * @max_delay: maximum delay before starting the time event (in TU)
127 * @wait_for_notif: true if it is required that a time event notification be
128 * waited for (that the time event has been scheduled before returning)
130 * This function can be used to start a session protection which means that the
131 * fw will stay on the channel for %duration_ms milliseconds. This function
132 * can block (sleep) until the session starts. This function can also be used
133 * to extend a currently running session.
134 * This function is meant to be used for BSS association for example, where we
135 * want to make sure that the fw stays on the channel during the association.
137 void iwl_mvm_protect_session(struct iwl_mvm *mvm,
138 struct ieee80211_vif *vif,
139 u32 duration, u32 min_duration,
140 u32 max_delay, bool wait_for_notif);
143 * iwl_mvm_stop_session_protection - cancel the session protection.
144 * @mvm: the mvm component
145 * @vif: the virtual interface for which the session is issued
147 * This functions cancels the session protection which is an act of good
148 * citizenship. If it is not needed any more it should be cancelled because
149 * the other bindings wait for the medium during that time.
150 * This funtions doesn't sleep.
152 void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
153 struct ieee80211_vif *vif);
156 * iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION.
158 int iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
159 struct iwl_rx_cmd_buffer *rxb,
160 struct iwl_device_cmd *cmd);
163 * iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionlity
164 * @mvm: the mvm component
165 * @vif: the virtual interface for which the roc is requested. It is assumed
166 * that the vif type is NL80211_IFTYPE_P2P_DEVICE
167 * @duration: the requested duration in millisecond for the fw to be on the
168 * channel that is bound to the vif.
169 * @type: the remain on channel request type
171 * This function can be used to issue a remain on channel session,
172 * which means that the fw will stay in the channel for the request %duration
173 * milliseconds. The function is async, meaning that it only issues the ROC
174 * request but does not wait for it to start. Once the FW is ready to serve the
175 * ROC request, it will issue a notification to the driver that it is on the
176 * requested channel. Once the FW completes the ROC request it will issue
177 * another notification to the driver.
179 int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
180 int duration, enum ieee80211_roc_type type);
183 * iwl_mvm_stop_p2p_roc - stop remain on channel for p2p device functionlity
184 * @mvm: the mvm component
186 * This function can be used to cancel an ongoing ROC session.
187 * The function is async, it will instruct the FW to stop serving the ROC
188 * session, but will not wait for the actual stopping of the session.
190 void iwl_mvm_stop_p2p_roc(struct iwl_mvm *mvm);
193 * iwl_mvm_remove_time_event - general function to clean up of time event
194 * @mvm: the mvm component
195 * @vif: the vif to which the time event belongs
196 * @te_data: the time event data that corresponds to that time event
198 * This function can be used to cancel a time event regardless its type.
199 * It is useful for cleaning up time events running before removing an
202 void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
203 struct iwl_mvm_vif *mvmvif,
204 struct iwl_mvm_time_event_data *te_data);
207 * iwl_mvm_te_clear_data - remove time event from list
208 * @mvm: the mvm component
209 * @te_data: the time event data to remove
211 * This function is mostly internal, it is made available here only
212 * for firmware restart purposes.
214 void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
215 struct iwl_mvm_time_event_data *te_data);
217 void iwl_mvm_roc_done_wk(struct work_struct *wk);
220 * iwl_mvm_schedule_csa_noa - request NoA for channel switch
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_noa(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;
248 #endif /* __time_event_h__ */