time-event.h 9.7 KB

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