blob: 3d2e8b6159bb1fd42e0ea0e5132c29e1e4ac9e0f [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
2 *
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.
5 *
6 * GPL LICENSE SUMMARY
7 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +02009 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Johannes Berg8ca151b2013-01-24 14:25:36 +010010 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23 * USA
24 *
25 * The full GNU General Public License is included in this distribution
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020026 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010027 *
28 * Contact Information:
Emmanuel Grumbachd01c5362015-11-17 15:39:56 +020029 * Intel Linux Wireless <linuxwifi@intel.com>
Johannes Berg8ca151b2013-01-24 14:25:36 +010030 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020034 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +020035 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Johannes Berg8ca151b2013-01-24 14:25:36 +010036 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 *
42 * * Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in
46 * the documentation and/or other materials provided with the
47 * distribution.
48 * * Neither the name Intel Corporation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 *
64 *****************************************************************************/
65
66#ifndef __time_event_h__
67#define __time_event_h__
68
69#include "fw-api.h"
70
71#include "mvm.h"
72
73/**
74 * DOC: Time Events - what is it?
75 *
76 * Time Events are a fw feature that allows the driver to control the presence
77 * of the device on the channel. Since the fw supports multiple channels
78 * concurrently, the fw may choose to jump to another channel at any time.
79 * In order to make sure that the fw is on a specific channel at a certain time
80 * and for a certain duration, the driver needs to issue a time event.
81 *
82 * The simplest example is for BSS association. The driver issues a time event,
83 * waits for it to start, and only then tells mac80211 that we can start the
84 * association. This way, we make sure that the association will be done
85 * smoothly and won't be interrupted by channel switch decided within the fw.
86 */
87
88 /**
89 * DOC: The flow against the fw
90 *
91 * When the driver needs to make sure we are in a certain channel, at a certain
92 * time and for a certain duration, it sends a Time Event. The flow against the
93 * fw goes like this:
94 * 1) Driver sends a TIME_EVENT_CMD to the fw
95 * 2) Driver gets the response for that command. This response contains the
96 * Unique ID (UID) of the event.
97 * 3) The fw sends notification when the event starts.
98 *
99 * Of course the API provides various options that allow to cover parameters
100 * of the flow.
101 * What is the duration of the event?
102 * What is the start time of the event?
103 * Is there an end-time for the event?
104 * How much can the event be delayed?
105 * Can the event be split?
106 * If yes what is the maximal number of chunks?
107 * etc...
108 */
109
110/**
111 * DOC: Abstraction to the driver
112 *
113 * In order to simplify the use of time events to the rest of the driver,
114 * we abstract the use of time events. This component provides the functions
115 * needed by the driver.
116 */
117
Sara Sharon7c70fee2016-02-02 11:55:53 +0200118#define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 600
Johannes Berg8ca151b2013-01-24 14:25:36 +0100119#define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
120
121/**
122 * iwl_mvm_protect_session - start / extend the session protection.
123 * @mvm: the mvm component
124 * @vif: the virtual interface for which the session is issued
125 * @duration: the duration of the session in TU.
126 * @min_duration: will start a new session if the current session will end
127 * in less than min_duration.
Johannes Berg016d27e2013-05-03 11:16:15 +0200128 * @max_delay: maximum delay before starting the time event (in TU)
Liad Kaufmand20d37b2014-07-06 17:14:39 +0300129 * @wait_for_notif: true if it is required that a time event notification be
130 * waited for (that the time event has been scheduled before returning)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100131 *
132 * This function can be used to start a session protection which means that the
133 * fw will stay on the channel for %duration_ms milliseconds. This function
Liad Kaufmand20d37b2014-07-06 17:14:39 +0300134 * can block (sleep) until the session starts. This function can also be used
Johannes Berg8ca151b2013-01-24 14:25:36 +0100135 * to extend a currently running session.
136 * This function is meant to be used for BSS association for example, where we
137 * want to make sure that the fw stays on the channel during the association.
138 */
139void iwl_mvm_protect_session(struct iwl_mvm *mvm,
140 struct ieee80211_vif *vif,
Johannes Berg016d27e2013-05-03 11:16:15 +0200141 u32 duration, u32 min_duration,
Liad Kaufmand20d37b2014-07-06 17:14:39 +0300142 u32 max_delay, bool wait_for_notif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100143
144/**
145 * iwl_mvm_stop_session_protection - cancel the session protection.
146 * @mvm: the mvm component
147 * @vif: the virtual interface for which the session is issued
148 *
149 * This functions cancels the session protection which is an act of good
Sara Sharon0d365ae2015-03-31 12:24:05 +0300150 * citizenship. If it is not needed any more it should be canceled because
Johannes Berg8ca151b2013-01-24 14:25:36 +0100151 * the other bindings wait for the medium during that time.
152 * This funtions doesn't sleep.
153 */
154void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
155 struct ieee80211_vif *vif);
156
157/*
158 * iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION.
159 */
Johannes Berg04168412015-06-23 21:22:09 +0200160void iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
161 struct iwl_rx_cmd_buffer *rxb);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100162
163/**
Sara Sharon0d365ae2015-03-31 12:24:05 +0300164 * iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionality
Johannes Berg8ca151b2013-01-24 14:25:36 +0100165 * @mvm: the mvm component
166 * @vif: the virtual interface for which the roc is requested. It is assumed
167 * that the vif type is NL80211_IFTYPE_P2P_DEVICE
168 * @duration: the requested duration in millisecond for the fw to be on the
169 * channel that is bound to the vif.
Ilan Peere635c792013-02-13 11:05:18 +0200170 * @type: the remain on channel request type
Johannes Berg8ca151b2013-01-24 14:25:36 +0100171 *
172 * This function can be used to issue a remain on channel session,
173 * which means that the fw will stay in the channel for the request %duration
174 * milliseconds. The function is async, meaning that it only issues the ROC
175 * request but does not wait for it to start. Once the FW is ready to serve the
176 * ROC request, it will issue a notification to the driver that it is on the
177 * requested channel. Once the FW completes the ROC request it will issue
178 * another notification to the driver.
179 */
180int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
Ilan Peere635c792013-02-13 11:05:18 +0200181 int duration, enum ieee80211_roc_type type);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100182
183/**
Matti Gottliebbf5da872014-11-16 10:25:12 +0200184 * iwl_mvm_stop_roc - stop remain on channel functionality
Johannes Berg8ca151b2013-01-24 14:25:36 +0100185 * @mvm: the mvm component
186 *
187 * This function can be used to cancel an ongoing ROC session.
188 * The function is async, it will instruct the FW to stop serving the ROC
189 * session, but will not wait for the actual stopping of the session.
190 */
Matti Gottliebbf5da872014-11-16 10:25:12 +0200191void iwl_mvm_stop_roc(struct iwl_mvm *mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100192
193/**
194 * iwl_mvm_remove_time_event - general function to clean up of time event
195 * @mvm: the mvm component
196 * @vif: the vif to which the time event belongs
197 * @te_data: the time event data that corresponds to that time event
198 *
199 * This function can be used to cancel a time event regardless its type.
200 * It is useful for cleaning up time events running before removing an
201 * interface.
202 */
203void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
204 struct iwl_mvm_vif *mvmvif,
205 struct iwl_mvm_time_event_data *te_data);
206
207/**
208 * iwl_mvm_te_clear_data - remove time event from list
209 * @mvm: the mvm component
210 * @te_data: the time event data to remove
211 *
212 * This function is mostly internal, it is made available here only
213 * for firmware restart purposes.
214 */
215void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
216 struct iwl_mvm_time_event_data *te_data);
217
Eliad Peller305d2362015-12-09 16:33:20 +0200218void iwl_mvm_cleanup_roc_te(struct iwl_mvm *mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100219void iwl_mvm_roc_done_wk(struct work_struct *wk);
220
Andrei Otcheretianski7f0a7c62014-05-04 11:48:12 +0300221/**
Luciano Coelhof991e172014-08-26 16:14:10 +0300222 * iwl_mvm_schedule_csa_period - request channel switch absence period
Andrei Otcheretianski7f0a7c62014-05-04 11:48:12 +0300223 * @mvm: the mvm component
224 * @vif: the virtual interface for which the channel switch is issued
225 * @duration: the duration of the NoA in TU.
226 * @apply_time: NoA start time in GP2.
227 *
228 * This function is used to schedule NoA time event and is used to perform
229 * the channel switch flow.
230 */
Luciano Coelhof991e172014-08-26 16:14:10 +0300231int iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm,
232 struct ieee80211_vif *vif,
233 u32 duration, u32 apply_time);
Andrei Otcheretianski7f0a7c62014-05-04 11:48:12 +0300234
235/**
236 * iwl_mvm_te_scheduled - check if the fw received the TE cmd
237 * @te_data: the time event data that corresponds to that time event
238 *
239 * This function returns true iff this TE is added to the fw.
240 */
241static inline bool
242iwl_mvm_te_scheduled(struct iwl_mvm_time_event_data *te_data)
243{
244 if (!te_data)
245 return false;
246
247 return !!te_data->uid;
248}
249
Johannes Berg8ca151b2013-01-24 14:25:36 +0100250#endif /* __time_event_h__ */