time-event.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 - 2013 Intel Corporation. All rights reserved.
  9. *
  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.
  13. *
  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.
  18. *
  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,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called LICENSE.GPL.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  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
  45. * distribution.
  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.
  49. *
  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.
  61. *
  62. *****************************************************************************/
  63. #ifndef __time_event_h__
  64. #define __time_event_h__
  65. #include "fw-api.h"
  66. #include "mvm.h"
  67. /**
  68. * DOC: Time Events - what is it?
  69. *
  70. * Time Events are a fw feature that allows the driver to control the presence
  71. * of the device on the channel. Since the fw supports multiple channels
  72. * concurrently, the fw may choose to jump to another channel at any time.
  73. * In order to make sure that the fw is on a specific channel at a certain time
  74. * and for a certain duration, the driver needs to issue a time event.
  75. *
  76. * The simplest example is for BSS association. The driver issues a time event,
  77. * waits for it to start, and only then tells mac80211 that we can start the
  78. * association. This way, we make sure that the association will be done
  79. * smoothly and won't be interrupted by channel switch decided within the fw.
  80. */
  81. /**
  82. * DOC: The flow against the fw
  83. *
  84. * When the driver needs to make sure we are in a certain channel, at a certain
  85. * time and for a certain duration, it sends a Time Event. The flow against the
  86. * fw goes like this:
  87. * 1) Driver sends a TIME_EVENT_CMD to the fw
  88. * 2) Driver gets the response for that command. This response contains the
  89. * Unique ID (UID) of the event.
  90. * 3) The fw sends notification when the event starts.
  91. *
  92. * Of course the API provides various options that allow to cover parameters
  93. * of the flow.
  94. * What is the duration of the event?
  95. * What is the start time of the event?
  96. * Is there an end-time for the event?
  97. * How much can the event be delayed?
  98. * Can the event be split?
  99. * If yes what is the maximal number of chunks?
  100. * etc...
  101. */
  102. /**
  103. * DOC: Abstraction to the driver
  104. *
  105. * In order to simplify the use of time events to the rest of the driver,
  106. * we abstract the use of time events. This component provides the functions
  107. * needed by the driver.
  108. */
  109. #define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 500
  110. #define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
  111. /**
  112. * iwl_mvm_protect_session - start / extend the session protection.
  113. * @mvm: the mvm component
  114. * @vif: the virtual interface for which the session is issued
  115. * @duration: the duration of the session in TU.
  116. * @min_duration: will start a new session if the current session will end
  117. * in less than min_duration.
  118. *
  119. * This function can be used to start a session protection which means that the
  120. * fw will stay on the channel for %duration_ms milliseconds. This function
  121. * will block (sleep) until the session starts. This function can also be used
  122. * to extend a currently running session.
  123. * This function is meant to be used for BSS association for example, where we
  124. * want to make sure that the fw stays on the channel during the association.
  125. */
  126. void iwl_mvm_protect_session(struct iwl_mvm *mvm,
  127. struct ieee80211_vif *vif,
  128. u32 duration, u32 min_duration);
  129. /**
  130. * iwl_mvm_stop_session_protection - cancel the session protection.
  131. * @mvm: the mvm component
  132. * @vif: the virtual interface for which the session is issued
  133. *
  134. * This functions cancels the session protection which is an act of good
  135. * citizenship. If it is not needed any more it should be cancelled because
  136. * the other bindings wait for the medium during that time.
  137. * This funtions doesn't sleep.
  138. */
  139. void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
  140. struct ieee80211_vif *vif);
  141. /*
  142. * iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION.
  143. */
  144. int iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
  145. struct iwl_rx_cmd_buffer *rxb,
  146. struct iwl_device_cmd *cmd);
  147. /**
  148. * iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionlity
  149. * @mvm: the mvm component
  150. * @vif: the virtual interface for which the roc is requested. It is assumed
  151. * that the vif type is NL80211_IFTYPE_P2P_DEVICE
  152. * @duration: the requested duration in millisecond for the fw to be on the
  153. * channel that is bound to the vif.
  154. *
  155. * This function can be used to issue a remain on channel session,
  156. * which means that the fw will stay in the channel for the request %duration
  157. * milliseconds. The function is async, meaning that it only issues the ROC
  158. * request but does not wait for it to start. Once the FW is ready to serve the
  159. * ROC request, it will issue a notification to the driver that it is on the
  160. * requested channel. Once the FW completes the ROC request it will issue
  161. * another notification to the driver.
  162. */
  163. int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  164. int duration);
  165. /**
  166. * iwl_mvm_stop_p2p_roc - stop remain on channel for p2p device functionlity
  167. * @mvm: the mvm component
  168. *
  169. * This function can be used to cancel an ongoing ROC session.
  170. * The function is async, it will instruct the FW to stop serving the ROC
  171. * session, but will not wait for the actual stopping of the session.
  172. */
  173. void iwl_mvm_stop_p2p_roc(struct iwl_mvm *mvm);
  174. /**
  175. * iwl_mvm_remove_time_event - general function to clean up of time event
  176. * @mvm: the mvm component
  177. * @vif: the vif to which the time event belongs
  178. * @te_data: the time event data that corresponds to that time event
  179. *
  180. * This function can be used to cancel a time event regardless its type.
  181. * It is useful for cleaning up time events running before removing an
  182. * interface.
  183. */
  184. void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
  185. struct iwl_mvm_vif *mvmvif,
  186. struct iwl_mvm_time_event_data *te_data);
  187. /**
  188. * iwl_mvm_te_clear_data - remove time event from list
  189. * @mvm: the mvm component
  190. * @te_data: the time event data to remove
  191. *
  192. * This function is mostly internal, it is made available here only
  193. * for firmware restart purposes.
  194. */
  195. void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
  196. struct iwl_mvm_time_event_data *te_data);
  197. void iwl_mvm_roc_done_wk(struct work_struct *wk);
  198. #endif /* __time_event_h__ */