fw-api-mac.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. *
  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 COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <linuxwifi@intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2014 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. #ifndef __fw_api_mac_h__
  63. #define __fw_api_mac_h__
  64. /*
  65. * The first MAC indices (starting from 0) are available to the driver,
  66. * AUX indices follows - 1 for non-CDB, 2 for CDB.
  67. */
  68. #define MAC_INDEX_AUX 4
  69. #define MAC_INDEX_MIN_DRIVER 0
  70. #define NUM_MAC_INDEX_DRIVER MAC_INDEX_AUX
  71. #define NUM_MAC_INDEX (NUM_MAC_INDEX_DRIVER + 1)
  72. #define NUM_MAC_INDEX_CDB (NUM_MAC_INDEX_DRIVER + 2)
  73. #define IWL_MVM_STATION_COUNT 16
  74. #define IWL_MVM_INVALID_STA 0xFF
  75. #define IWL_MVM_TDLS_STA_COUNT 4
  76. enum iwl_ac {
  77. AC_BK,
  78. AC_BE,
  79. AC_VI,
  80. AC_VO,
  81. AC_NUM,
  82. };
  83. /**
  84. * enum iwl_mac_protection_flags - MAC context flags
  85. * @MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames,
  86. * this will require CCK RTS/CTS2self.
  87. * RTS/CTS will protect full burst time.
  88. * @MAC_PROT_FLG_HT_PROT: enable HT protection
  89. * @MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions
  90. * @MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self
  91. */
  92. enum iwl_mac_protection_flags {
  93. MAC_PROT_FLG_TGG_PROTECT = BIT(3),
  94. MAC_PROT_FLG_HT_PROT = BIT(23),
  95. MAC_PROT_FLG_FAT_PROT = BIT(24),
  96. MAC_PROT_FLG_SELF_CTS_EN = BIT(30),
  97. };
  98. #define MAC_FLG_SHORT_SLOT BIT(4)
  99. #define MAC_FLG_SHORT_PREAMBLE BIT(5)
  100. /**
  101. * enum iwl_mac_types - Supported MAC types
  102. * @FW_MAC_TYPE_FIRST: lowest supported MAC type
  103. * @FW_MAC_TYPE_AUX: Auxiliary MAC (internal)
  104. * @FW_MAC_TYPE_LISTENER: monitor MAC type (?)
  105. * @FW_MAC_TYPE_PIBSS: Pseudo-IBSS
  106. * @FW_MAC_TYPE_IBSS: IBSS
  107. * @FW_MAC_TYPE_BSS_STA: BSS (managed) station
  108. * @FW_MAC_TYPE_P2P_DEVICE: P2P Device
  109. * @FW_MAC_TYPE_P2P_STA: P2P client
  110. * @FW_MAC_TYPE_GO: P2P GO
  111. * @FW_MAC_TYPE_TEST: ?
  112. * @FW_MAC_TYPE_MAX: highest support MAC type
  113. */
  114. enum iwl_mac_types {
  115. FW_MAC_TYPE_FIRST = 1,
  116. FW_MAC_TYPE_AUX = FW_MAC_TYPE_FIRST,
  117. FW_MAC_TYPE_LISTENER,
  118. FW_MAC_TYPE_PIBSS,
  119. FW_MAC_TYPE_IBSS,
  120. FW_MAC_TYPE_BSS_STA,
  121. FW_MAC_TYPE_P2P_DEVICE,
  122. FW_MAC_TYPE_P2P_STA,
  123. FW_MAC_TYPE_GO,
  124. FW_MAC_TYPE_TEST,
  125. FW_MAC_TYPE_MAX = FW_MAC_TYPE_TEST
  126. }; /* MAC_CONTEXT_TYPE_API_E_VER_1 */
  127. /**
  128. * enum iwl_tsf_id - TSF hw timer ID
  129. * @TSF_ID_A: use TSF A
  130. * @TSF_ID_B: use TSF B
  131. * @TSF_ID_C: use TSF C
  132. * @TSF_ID_D: use TSF D
  133. * @NUM_TSF_IDS: number of TSF timers available
  134. */
  135. enum iwl_tsf_id {
  136. TSF_ID_A = 0,
  137. TSF_ID_B = 1,
  138. TSF_ID_C = 2,
  139. TSF_ID_D = 3,
  140. NUM_TSF_IDS = 4,
  141. }; /* TSF_ID_API_E_VER_1 */
  142. /**
  143. * struct iwl_mac_data_ap - configuration data for AP MAC context
  144. * @beacon_time: beacon transmit time in system time
  145. * @beacon_tsf: beacon transmit time in TSF
  146. * @bi: beacon interval in TU
  147. * @bi_reciprocal: 2^32 / bi
  148. * @dtim_interval: dtim transmit time in TU
  149. * @dtim_reciprocal: 2^32 / dtim_interval
  150. * @mcast_qid: queue ID for multicast traffic.
  151. * NOTE: obsolete from VER2 and on
  152. * @beacon_template: beacon template ID
  153. */
  154. struct iwl_mac_data_ap {
  155. __le32 beacon_time;
  156. __le64 beacon_tsf;
  157. __le32 bi;
  158. __le32 bi_reciprocal;
  159. __le32 dtim_interval;
  160. __le32 dtim_reciprocal;
  161. __le32 mcast_qid;
  162. __le32 beacon_template;
  163. } __packed; /* AP_MAC_DATA_API_S_VER_2 */
  164. /**
  165. * struct iwl_mac_data_ibss - configuration data for IBSS MAC context
  166. * @beacon_time: beacon transmit time in system time
  167. * @beacon_tsf: beacon transmit time in TSF
  168. * @bi: beacon interval in TU
  169. * @bi_reciprocal: 2^32 / bi
  170. * @beacon_template: beacon template ID
  171. */
  172. struct iwl_mac_data_ibss {
  173. __le32 beacon_time;
  174. __le64 beacon_tsf;
  175. __le32 bi;
  176. __le32 bi_reciprocal;
  177. __le32 beacon_template;
  178. } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
  179. /**
  180. * struct iwl_mac_data_sta - configuration data for station MAC context
  181. * @is_assoc: 1 for associated state, 0 otherwise
  182. * @dtim_time: DTIM arrival time in system time
  183. * @dtim_tsf: DTIM arrival time in TSF
  184. * @bi: beacon interval in TU, applicable only when associated
  185. * @bi_reciprocal: 2^32 / bi , applicable only when associated
  186. * @dtim_interval: DTIM interval in TU, applicable only when associated
  187. * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
  188. * @listen_interval: in beacon intervals, applicable only when associated
  189. * @assoc_id: unique ID assigned by the AP during association
  190. */
  191. struct iwl_mac_data_sta {
  192. __le32 is_assoc;
  193. __le32 dtim_time;
  194. __le64 dtim_tsf;
  195. __le32 bi;
  196. __le32 bi_reciprocal;
  197. __le32 dtim_interval;
  198. __le32 dtim_reciprocal;
  199. __le32 listen_interval;
  200. __le32 assoc_id;
  201. __le32 assoc_beacon_arrive_time;
  202. } __packed; /* STA_MAC_DATA_API_S_VER_1 */
  203. /**
  204. * struct iwl_mac_data_go - configuration data for P2P GO MAC context
  205. * @ap: iwl_mac_data_ap struct with most config data
  206. * @ctwin: client traffic window in TU (period after TBTT when GO is present).
  207. * 0 indicates that there is no CT window.
  208. * @opp_ps_enabled: indicate that opportunistic PS allowed
  209. */
  210. struct iwl_mac_data_go {
  211. struct iwl_mac_data_ap ap;
  212. __le32 ctwin;
  213. __le32 opp_ps_enabled;
  214. } __packed; /* GO_MAC_DATA_API_S_VER_1 */
  215. /**
  216. * struct iwl_mac_data_p2p_sta - configuration data for P2P client MAC context
  217. * @sta: iwl_mac_data_sta struct with most config data
  218. * @ctwin: client traffic window in TU (period after TBTT when GO is present).
  219. * 0 indicates that there is no CT window.
  220. */
  221. struct iwl_mac_data_p2p_sta {
  222. struct iwl_mac_data_sta sta;
  223. __le32 ctwin;
  224. } __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */
  225. /**
  226. * struct iwl_mac_data_pibss - Pseudo IBSS config data
  227. * @stats_interval: interval in TU between statistics notifications to host.
  228. */
  229. struct iwl_mac_data_pibss {
  230. __le32 stats_interval;
  231. } __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */
  232. /*
  233. * struct iwl_mac_data_p2p_dev - configuration data for the P2P Device MAC
  234. * context.
  235. * @is_disc_extended: if set to true, P2P Device discoverability is enabled on
  236. * other channels as well. This should be to true only in case that the
  237. * device is discoverable and there is an active GO. Note that setting this
  238. * field when not needed, will increase the number of interrupts and have
  239. * effect on the platform power, as this setting opens the Rx filters on
  240. * all macs.
  241. */
  242. struct iwl_mac_data_p2p_dev {
  243. __le32 is_disc_extended;
  244. } __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */
  245. /**
  246. * enum iwl_mac_filter_flags - MAC context filter flags
  247. * @MAC_FILTER_IN_PROMISC: accept all data frames
  248. * @MAC_FILTER_IN_CONTROL_AND_MGMT: pass all management and
  249. * control frames to the host
  250. * @MAC_FILTER_ACCEPT_GRP: accept multicast frames
  251. * @MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames
  252. * @MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames
  253. * @MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host
  254. * (in station mode when associated)
  255. * @MAC_FILTER_OUT_BCAST: filter out all broadcast frames
  256. * @MAC_FILTER_IN_CRC32: extract FCS and append it to frames
  257. * @MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host
  258. */
  259. enum iwl_mac_filter_flags {
  260. MAC_FILTER_IN_PROMISC = BIT(0),
  261. MAC_FILTER_IN_CONTROL_AND_MGMT = BIT(1),
  262. MAC_FILTER_ACCEPT_GRP = BIT(2),
  263. MAC_FILTER_DIS_DECRYPT = BIT(3),
  264. MAC_FILTER_DIS_GRP_DECRYPT = BIT(4),
  265. MAC_FILTER_IN_BEACON = BIT(6),
  266. MAC_FILTER_OUT_BCAST = BIT(8),
  267. MAC_FILTER_IN_CRC32 = BIT(11),
  268. MAC_FILTER_IN_PROBE_REQUEST = BIT(12),
  269. };
  270. /**
  271. * enum iwl_mac_qos_flags - QoS flags
  272. * @MAC_QOS_FLG_UPDATE_EDCA: ?
  273. * @MAC_QOS_FLG_TGN: HT is enabled
  274. * @MAC_QOS_FLG_TXOP_TYPE: ?
  275. *
  276. */
  277. enum iwl_mac_qos_flags {
  278. MAC_QOS_FLG_UPDATE_EDCA = BIT(0),
  279. MAC_QOS_FLG_TGN = BIT(1),
  280. MAC_QOS_FLG_TXOP_TYPE = BIT(4),
  281. };
  282. /**
  283. * struct iwl_ac_qos - QOS timing params for MAC_CONTEXT_CMD
  284. * @cw_min: Contention window, start value in numbers of slots.
  285. * Should be a power-of-2, minus 1. Device's default is 0x0f.
  286. * @cw_max: Contention window, max value in numbers of slots.
  287. * Should be a power-of-2, minus 1. Device's default is 0x3f.
  288. * @aifsn: Number of slots in Arbitration Interframe Space (before
  289. * performing random backoff timing prior to Tx). Device default 1.
  290. * @fifos_mask: FIFOs used by this MAC for this AC
  291. * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
  292. *
  293. * One instance of this config struct for each of 4 EDCA access categories
  294. * in struct iwl_qosparam_cmd.
  295. *
  296. * Device will automatically increase contention window by (2*CW) + 1 for each
  297. * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
  298. * value, to cap the CW value.
  299. */
  300. struct iwl_ac_qos {
  301. __le16 cw_min;
  302. __le16 cw_max;
  303. u8 aifsn;
  304. u8 fifos_mask;
  305. __le16 edca_txop;
  306. } __packed; /* AC_QOS_API_S_VER_2 */
  307. /**
  308. * struct iwl_mac_ctx_cmd - command structure to configure MAC contexts
  309. * ( MAC_CONTEXT_CMD = 0x28 )
  310. * @id_and_color: ID and color of the MAC
  311. * @action: action to perform, one of FW_CTXT_ACTION_*
  312. * @mac_type: one of FW_MAC_TYPE_*
  313. * @tsd_id: TSF HW timer, one of TSF_ID_*
  314. * @node_addr: MAC address
  315. * @bssid_addr: BSSID
  316. * @cck_rates: basic rates available for CCK
  317. * @ofdm_rates: basic rates available for OFDM
  318. * @protection_flags: combination of MAC_PROT_FLG_FLAG_*
  319. * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise
  320. * @short_slot: 0x10 for enabling short slots, 0 otherwise
  321. * @filter_flags: combination of MAC_FILTER_*
  322. * @qos_flags: from MAC_QOS_FLG_*
  323. * @ac: one iwl_mac_qos configuration for each AC
  324. * @mac_specific: one of struct iwl_mac_data_*, according to mac_type
  325. */
  326. struct iwl_mac_ctx_cmd {
  327. /* COMMON_INDEX_HDR_API_S_VER_1 */
  328. __le32 id_and_color;
  329. __le32 action;
  330. /* MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */
  331. __le32 mac_type;
  332. __le32 tsf_id;
  333. u8 node_addr[6];
  334. __le16 reserved_for_node_addr;
  335. u8 bssid_addr[6];
  336. __le16 reserved_for_bssid_addr;
  337. __le32 cck_rates;
  338. __le32 ofdm_rates;
  339. __le32 protection_flags;
  340. __le32 cck_short_preamble;
  341. __le32 short_slot;
  342. __le32 filter_flags;
  343. /* MAC_QOS_PARAM_API_S_VER_1 */
  344. __le32 qos_flags;
  345. struct iwl_ac_qos ac[AC_NUM+1];
  346. /* MAC_CONTEXT_COMMON_DATA_API_S */
  347. union {
  348. struct iwl_mac_data_ap ap;
  349. struct iwl_mac_data_go go;
  350. struct iwl_mac_data_sta sta;
  351. struct iwl_mac_data_p2p_sta p2p_sta;
  352. struct iwl_mac_data_p2p_dev p2p_dev;
  353. struct iwl_mac_data_pibss pibss;
  354. struct iwl_mac_data_ibss ibss;
  355. };
  356. } __packed; /* MAC_CONTEXT_CMD_API_S_VER_1 */
  357. static inline u32 iwl_mvm_reciprocal(u32 v)
  358. {
  359. if (!v)
  360. return 0;
  361. return 0xFFFFFFFF / v;
  362. }
  363. #define IWL_NONQOS_SEQ_GET 0x1
  364. #define IWL_NONQOS_SEQ_SET 0x2
  365. struct iwl_nonqos_seq_query_cmd {
  366. __le32 get_set_flag;
  367. __le32 mac_id_n_color;
  368. __le16 value;
  369. __le16 reserved;
  370. } __packed; /* NON_QOS_TX_COUNTER_GET_SET_API_S_VER_1 */
  371. #endif /* __fw_api_mac_h__ */