time-event.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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 - 2015 Intel Mobile Communications GmbH
  10. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  11. *
  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.
  15. *
  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.
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called COPYING.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <linuxwifi@intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. * BSD LICENSE
  29. *
  30. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  31. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  32. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  33. * All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. *
  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
  44. * distribution.
  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.
  48. *
  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.
  60. *
  61. *****************************************************************************/
  62. #ifndef __iwl_fw_api_time_event_h__
  63. #define __iwl_fw_api_time_event_h__
  64. #include "fw/api/phy-ctxt.h"
  65. /* Time Event types, according to MAC type */
  66. enum iwl_time_event_type {
  67. /* BSS Station Events */
  68. TE_BSS_STA_AGGRESSIVE_ASSOC,
  69. TE_BSS_STA_ASSOC,
  70. TE_BSS_EAP_DHCP_PROT,
  71. TE_BSS_QUIET_PERIOD,
  72. /* P2P Device Events */
  73. TE_P2P_DEVICE_DISCOVERABLE,
  74. TE_P2P_DEVICE_LISTEN,
  75. TE_P2P_DEVICE_ACTION_SCAN,
  76. TE_P2P_DEVICE_FULL_SCAN,
  77. /* P2P Client Events */
  78. TE_P2P_CLIENT_AGGRESSIVE_ASSOC,
  79. TE_P2P_CLIENT_ASSOC,
  80. TE_P2P_CLIENT_QUIET_PERIOD,
  81. /* P2P GO Events */
  82. TE_P2P_GO_ASSOC_PROT,
  83. TE_P2P_GO_REPETITIVET_NOA,
  84. TE_P2P_GO_CT_WINDOW,
  85. /* WiDi Sync Events */
  86. TE_WIDI_TX_SYNC,
  87. /* Channel Switch NoA */
  88. TE_CHANNEL_SWITCH_PERIOD,
  89. TE_MAX
  90. }; /* MAC_EVENT_TYPE_API_E_VER_1 */
  91. /* Time event - defines for command API v1 */
  92. /*
  93. * @TE_V1_FRAG_NONE: fragmentation of the time event is NOT allowed.
  94. * @TE_V1_FRAG_SINGLE: fragmentation of the time event is allowed, but only
  95. * the first fragment is scheduled.
  96. * @TE_V1_FRAG_DUAL: fragmentation of the time event is allowed, but only
  97. * the first 2 fragments are scheduled.
  98. * @TE_V1_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
  99. * number of fragments are valid.
  100. *
  101. * Other than the constant defined above, specifying a fragmentation value 'x'
  102. * means that the event can be fragmented but only the first 'x' will be
  103. * scheduled.
  104. */
  105. enum {
  106. TE_V1_FRAG_NONE = 0,
  107. TE_V1_FRAG_SINGLE = 1,
  108. TE_V1_FRAG_DUAL = 2,
  109. TE_V1_FRAG_ENDLESS = 0xffffffff
  110. };
  111. /* If a Time Event can be fragmented, this is the max number of fragments */
  112. #define TE_V1_FRAG_MAX_MSK 0x0fffffff
  113. /* Repeat the time event endlessly (until removed) */
  114. #define TE_V1_REPEAT_ENDLESS 0xffffffff
  115. /* If a Time Event has bounded repetitions, this is the maximal value */
  116. #define TE_V1_REPEAT_MAX_MSK_V1 0x0fffffff
  117. /* Time Event dependencies: none, on another TE, or in a specific time */
  118. enum {
  119. TE_V1_INDEPENDENT = 0,
  120. TE_V1_DEP_OTHER = BIT(0),
  121. TE_V1_DEP_TSF = BIT(1),
  122. TE_V1_EVENT_SOCIOPATHIC = BIT(2),
  123. }; /* MAC_EVENT_DEPENDENCY_POLICY_API_E_VER_2 */
  124. /*
  125. * @TE_V1_NOTIF_NONE: no notifications
  126. * @TE_V1_NOTIF_HOST_EVENT_START: request/receive notification on event start
  127. * @TE_V1_NOTIF_HOST_EVENT_END:request/receive notification on event end
  128. * @TE_V1_NOTIF_INTERNAL_EVENT_START: internal FW use
  129. * @TE_V1_NOTIF_INTERNAL_EVENT_END: internal FW use.
  130. * @TE_V1_NOTIF_HOST_FRAG_START: request/receive notification on frag start
  131. * @TE_V1_NOTIF_HOST_FRAG_END:request/receive notification on frag end
  132. * @TE_V1_NOTIF_INTERNAL_FRAG_START: internal FW use.
  133. * @TE_V1_NOTIF_INTERNAL_FRAG_END: internal FW use.
  134. *
  135. * Supported Time event notifications configuration.
  136. * A notification (both event and fragment) includes a status indicating weather
  137. * the FW was able to schedule the event or not. For fragment start/end
  138. * notification the status is always success. There is no start/end fragment
  139. * notification for monolithic events.
  140. */
  141. enum {
  142. TE_V1_NOTIF_NONE = 0,
  143. TE_V1_NOTIF_HOST_EVENT_START = BIT(0),
  144. TE_V1_NOTIF_HOST_EVENT_END = BIT(1),
  145. TE_V1_NOTIF_INTERNAL_EVENT_START = BIT(2),
  146. TE_V1_NOTIF_INTERNAL_EVENT_END = BIT(3),
  147. TE_V1_NOTIF_HOST_FRAG_START = BIT(4),
  148. TE_V1_NOTIF_HOST_FRAG_END = BIT(5),
  149. TE_V1_NOTIF_INTERNAL_FRAG_START = BIT(6),
  150. TE_V1_NOTIF_INTERNAL_FRAG_END = BIT(7),
  151. }; /* MAC_EVENT_ACTION_API_E_VER_2 */
  152. /* Time event - defines for command API */
  153. /*
  154. * @TE_V2_FRAG_NONE: fragmentation of the time event is NOT allowed.
  155. * @TE_V2_FRAG_SINGLE: fragmentation of the time event is allowed, but only
  156. * the first fragment is scheduled.
  157. * @TE_V2_FRAG_DUAL: fragmentation of the time event is allowed, but only
  158. * the first 2 fragments are scheduled.
  159. * @TE_V2_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
  160. * number of fragments are valid.
  161. *
  162. * Other than the constant defined above, specifying a fragmentation value 'x'
  163. * means that the event can be fragmented but only the first 'x' will be
  164. * scheduled.
  165. */
  166. enum {
  167. TE_V2_FRAG_NONE = 0,
  168. TE_V2_FRAG_SINGLE = 1,
  169. TE_V2_FRAG_DUAL = 2,
  170. TE_V2_FRAG_MAX = 0xfe,
  171. TE_V2_FRAG_ENDLESS = 0xff
  172. };
  173. /* Repeat the time event endlessly (until removed) */
  174. #define TE_V2_REPEAT_ENDLESS 0xff
  175. /* If a Time Event has bounded repetitions, this is the maximal value */
  176. #define TE_V2_REPEAT_MAX 0xfe
  177. #define TE_V2_PLACEMENT_POS 12
  178. #define TE_V2_ABSENCE_POS 15
  179. /**
  180. * enum iwl_time_event_policy - Time event policy values
  181. * A notification (both event and fragment) includes a status indicating weather
  182. * the FW was able to schedule the event or not. For fragment start/end
  183. * notification the status is always success. There is no start/end fragment
  184. * notification for monolithic events.
  185. *
  186. * @TE_V2_DEFAULT_POLICY: independent, social, present, unoticable
  187. * @TE_V2_NOTIF_HOST_EVENT_START: request/receive notification on event start
  188. * @TE_V2_NOTIF_HOST_EVENT_END:request/receive notification on event end
  189. * @TE_V2_NOTIF_INTERNAL_EVENT_START: internal FW use
  190. * @TE_V2_NOTIF_INTERNAL_EVENT_END: internal FW use.
  191. * @TE_V2_NOTIF_HOST_FRAG_START: request/receive notification on frag start
  192. * @TE_V2_NOTIF_HOST_FRAG_END:request/receive notification on frag end
  193. * @TE_V2_NOTIF_INTERNAL_FRAG_START: internal FW use.
  194. * @TE_V2_NOTIF_INTERNAL_FRAG_END: internal FW use.
  195. * @TE_V2_START_IMMEDIATELY: start time event immediately
  196. * @TE_V2_DEP_OTHER: depends on another time event
  197. * @TE_V2_DEP_TSF: depends on a specific time
  198. * @TE_V2_EVENT_SOCIOPATHIC: can't co-exist with other events of tha same MAC
  199. * @TE_V2_ABSENCE: are we present or absent during the Time Event.
  200. */
  201. enum iwl_time_event_policy {
  202. TE_V2_DEFAULT_POLICY = 0x0,
  203. /* notifications (event start/stop, fragment start/stop) */
  204. TE_V2_NOTIF_HOST_EVENT_START = BIT(0),
  205. TE_V2_NOTIF_HOST_EVENT_END = BIT(1),
  206. TE_V2_NOTIF_INTERNAL_EVENT_START = BIT(2),
  207. TE_V2_NOTIF_INTERNAL_EVENT_END = BIT(3),
  208. TE_V2_NOTIF_HOST_FRAG_START = BIT(4),
  209. TE_V2_NOTIF_HOST_FRAG_END = BIT(5),
  210. TE_V2_NOTIF_INTERNAL_FRAG_START = BIT(6),
  211. TE_V2_NOTIF_INTERNAL_FRAG_END = BIT(7),
  212. TE_V2_START_IMMEDIATELY = BIT(11),
  213. /* placement characteristics */
  214. TE_V2_DEP_OTHER = BIT(TE_V2_PLACEMENT_POS),
  215. TE_V2_DEP_TSF = BIT(TE_V2_PLACEMENT_POS + 1),
  216. TE_V2_EVENT_SOCIOPATHIC = BIT(TE_V2_PLACEMENT_POS + 2),
  217. /* are we present or absent during the Time Event. */
  218. TE_V2_ABSENCE = BIT(TE_V2_ABSENCE_POS),
  219. };
  220. /**
  221. * struct iwl_time_event_cmd - configuring Time Events
  222. * with struct MAC_TIME_EVENT_DATA_API_S_VER_2 (see also
  223. * with version 1. determined by IWL_UCODE_TLV_FLAGS)
  224. * ( TIME_EVENT_CMD = 0x29 )
  225. * @id_and_color: ID and color of the relevant MAC,
  226. * &enum iwl_ctxt_id_and_color
  227. * @action: action to perform, one of &enum iwl_ctxt_action
  228. * @id: this field has two meanings, depending on the action:
  229. * If the action is ADD, then it means the type of event to add.
  230. * For all other actions it is the unique event ID assigned when the
  231. * event was added by the FW.
  232. * @apply_time: When to start the Time Event (in GP2)
  233. * @max_delay: maximum delay to event's start (apply time), in TU
  234. * @depends_on: the unique ID of the event we depend on (if any)
  235. * @interval: interval between repetitions, in TU
  236. * @duration: duration of event in TU
  237. * @repeat: how many repetitions to do, can be TE_REPEAT_ENDLESS
  238. * @max_frags: maximal number of fragments the Time Event can be divided to
  239. * @policy: defines whether uCode shall notify the host or other uCode modules
  240. * on event and/or fragment start and/or end
  241. * using one of TE_INDEPENDENT, TE_DEP_OTHER, TE_DEP_TSF
  242. * TE_EVENT_SOCIOPATHIC
  243. * using TE_ABSENCE and using TE_NOTIF_*,
  244. * &enum iwl_time_event_policy
  245. */
  246. struct iwl_time_event_cmd {
  247. /* COMMON_INDEX_HDR_API_S_VER_1 */
  248. __le32 id_and_color;
  249. __le32 action;
  250. __le32 id;
  251. /* MAC_TIME_EVENT_DATA_API_S_VER_2 */
  252. __le32 apply_time;
  253. __le32 max_delay;
  254. __le32 depends_on;
  255. __le32 interval;
  256. __le32 duration;
  257. u8 repeat;
  258. u8 max_frags;
  259. __le16 policy;
  260. } __packed; /* MAC_TIME_EVENT_CMD_API_S_VER_2 */
  261. /**
  262. * struct iwl_time_event_resp - response structure to iwl_time_event_cmd
  263. * @status: bit 0 indicates success, all others specify errors
  264. * @id: the Time Event type
  265. * @unique_id: the unique ID assigned (in ADD) or given (others) to the TE
  266. * @id_and_color: ID and color of the relevant MAC,
  267. * &enum iwl_ctxt_id_and_color
  268. */
  269. struct iwl_time_event_resp {
  270. __le32 status;
  271. __le32 id;
  272. __le32 unique_id;
  273. __le32 id_and_color;
  274. } __packed; /* MAC_TIME_EVENT_RSP_API_S_VER_1 */
  275. /**
  276. * struct iwl_time_event_notif - notifications of time event start/stop
  277. * ( TIME_EVENT_NOTIFICATION = 0x2a )
  278. * @timestamp: action timestamp in GP2
  279. * @session_id: session's unique id
  280. * @unique_id: unique id of the Time Event itself
  281. * @id_and_color: ID and color of the relevant MAC
  282. * @action: &enum iwl_time_event_policy
  283. * @status: true if scheduled, false otherwise (not executed)
  284. */
  285. struct iwl_time_event_notif {
  286. __le32 timestamp;
  287. __le32 session_id;
  288. __le32 unique_id;
  289. __le32 id_and_color;
  290. __le32 action;
  291. __le32 status;
  292. } __packed; /* MAC_TIME_EVENT_NTFY_API_S_VER_1 */
  293. /*
  294. * Aux ROC command
  295. *
  296. * Command requests the firmware to create a time event for a certain duration
  297. * and remain on the given channel. This is done by using the Aux framework in
  298. * the FW.
  299. * The command was first used for Hot Spot issues - but can be used regardless
  300. * to Hot Spot.
  301. *
  302. * ( HOT_SPOT_CMD 0x53 )
  303. *
  304. * @id_and_color: ID and color of the MAC
  305. * @action: action to perform, one of FW_CTXT_ACTION_*
  306. * @event_unique_id: If the action FW_CTXT_ACTION_REMOVE then the
  307. * event_unique_id should be the id of the time event assigned by ucode.
  308. * Otherwise ignore the event_unique_id.
  309. * @sta_id_and_color: station id and color, resumed during "Remain On Channel"
  310. * activity.
  311. * @channel_info: channel info
  312. * @node_addr: Our MAC Address
  313. * @reserved: reserved for alignment
  314. * @apply_time: GP2 value to start (should always be the current GP2 value)
  315. * @apply_time_max_delay: Maximum apply time delay value in TU. Defines max
  316. * time by which start of the event is allowed to be postponed.
  317. * @duration: event duration in TU To calculate event duration:
  318. * timeEventDuration = min(duration, remainingQuota)
  319. */
  320. struct iwl_hs20_roc_req {
  321. /* COMMON_INDEX_HDR_API_S_VER_1 hdr */
  322. __le32 id_and_color;
  323. __le32 action;
  324. __le32 event_unique_id;
  325. __le32 sta_id_and_color;
  326. struct iwl_fw_channel_info channel_info;
  327. u8 node_addr[ETH_ALEN];
  328. __le16 reserved;
  329. __le32 apply_time;
  330. __le32 apply_time_max_delay;
  331. __le32 duration;
  332. } __packed; /* HOT_SPOT_CMD_API_S_VER_1 */
  333. /*
  334. * values for AUX ROC result values
  335. */
  336. enum iwl_mvm_hot_spot {
  337. HOT_SPOT_RSP_STATUS_OK,
  338. HOT_SPOT_RSP_STATUS_TOO_MANY_EVENTS,
  339. HOT_SPOT_MAX_NUM_OF_SESSIONS,
  340. };
  341. /*
  342. * Aux ROC command response
  343. *
  344. * In response to iwl_hs20_roc_req the FW sends this command to notify the
  345. * driver the uid of the timevent.
  346. *
  347. * ( HOT_SPOT_CMD 0x53 )
  348. *
  349. * @event_unique_id: Unique ID of time event assigned by ucode
  350. * @status: Return status 0 is success, all the rest used for specific errors
  351. */
  352. struct iwl_hs20_roc_res {
  353. __le32 event_unique_id;
  354. __le32 status;
  355. } __packed; /* HOT_SPOT_RSP_API_S_VER_1 */
  356. #endif /* __iwl_fw_api_time_event_h__ */