mac.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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) 2017 Intel Deutschland 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. * The full GNU General Public License is included in this distribution
  21. * in the file called COPYING.
  22. *
  23. * Contact Information:
  24. * Intel Linux Wireless <linuxwifi@intel.com>
  25. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  26. *
  27. * BSD LICENSE
  28. *
  29. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  30. * Copyright(c) 2017 Intel Deutschland GmbH
  31. * All rights reserved.
  32. *
  33. * Redistribution and use in source and binary forms, with or without
  34. * modification, are permitted provided that the following conditions
  35. * are met:
  36. *
  37. * * Redistributions of source code must retain the above copyright
  38. * notice, this list of conditions and the following disclaimer.
  39. * * Redistributions in binary form must reproduce the above copyright
  40. * notice, this list of conditions and the following disclaimer in
  41. * the documentation and/or other materials provided with the
  42. * distribution.
  43. * * Neither the name Intel Corporation nor the names of its
  44. * contributors may be used to endorse or promote products derived
  45. * from this software without specific prior written permission.
  46. *
  47. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  48. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  49. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  50. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  51. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  52. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  53. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  54. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  55. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  56. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  57. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  58. *****************************************************************************/
  59. #ifndef __iwl_fw_api_mac_h__
  60. #define __iwl_fw_api_mac_h__
  61. /*
  62. * The first MAC indices (starting from 0) are available to the driver,
  63. * AUX indices follows - 1 for non-CDB, 2 for CDB.
  64. */
  65. #define MAC_INDEX_AUX 4
  66. #define MAC_INDEX_MIN_DRIVER 0
  67. #define NUM_MAC_INDEX_DRIVER MAC_INDEX_AUX
  68. #define NUM_MAC_INDEX (NUM_MAC_INDEX_DRIVER + 1)
  69. #define NUM_MAC_INDEX_CDB (NUM_MAC_INDEX_DRIVER + 2)
  70. #define IWL_MVM_STATION_COUNT 16
  71. #define IWL_MVM_INVALID_STA 0xFF
  72. enum iwl_ac {
  73. AC_BK,
  74. AC_BE,
  75. AC_VI,
  76. AC_VO,
  77. AC_NUM,
  78. };
  79. /**
  80. * enum iwl_mac_protection_flags - MAC context flags
  81. * @MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames,
  82. * this will require CCK RTS/CTS2self.
  83. * RTS/CTS will protect full burst time.
  84. * @MAC_PROT_FLG_HT_PROT: enable HT protection
  85. * @MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions
  86. * @MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self
  87. */
  88. enum iwl_mac_protection_flags {
  89. MAC_PROT_FLG_TGG_PROTECT = BIT(3),
  90. MAC_PROT_FLG_HT_PROT = BIT(23),
  91. MAC_PROT_FLG_FAT_PROT = BIT(24),
  92. MAC_PROT_FLG_SELF_CTS_EN = BIT(30),
  93. };
  94. #define MAC_FLG_SHORT_SLOT BIT(4)
  95. #define MAC_FLG_SHORT_PREAMBLE BIT(5)
  96. /**
  97. * enum iwl_mac_types - Supported MAC types
  98. * @FW_MAC_TYPE_FIRST: lowest supported MAC type
  99. * @FW_MAC_TYPE_AUX: Auxiliary MAC (internal)
  100. * @FW_MAC_TYPE_LISTENER: monitor MAC type (?)
  101. * @FW_MAC_TYPE_PIBSS: Pseudo-IBSS
  102. * @FW_MAC_TYPE_IBSS: IBSS
  103. * @FW_MAC_TYPE_BSS_STA: BSS (managed) station
  104. * @FW_MAC_TYPE_P2P_DEVICE: P2P Device
  105. * @FW_MAC_TYPE_P2P_STA: P2P client
  106. * @FW_MAC_TYPE_GO: P2P GO
  107. * @FW_MAC_TYPE_TEST: ?
  108. * @FW_MAC_TYPE_MAX: highest support MAC type
  109. */
  110. enum iwl_mac_types {
  111. FW_MAC_TYPE_FIRST = 1,
  112. FW_MAC_TYPE_AUX = FW_MAC_TYPE_FIRST,
  113. FW_MAC_TYPE_LISTENER,
  114. FW_MAC_TYPE_PIBSS,
  115. FW_MAC_TYPE_IBSS,
  116. FW_MAC_TYPE_BSS_STA,
  117. FW_MAC_TYPE_P2P_DEVICE,
  118. FW_MAC_TYPE_P2P_STA,
  119. FW_MAC_TYPE_GO,
  120. FW_MAC_TYPE_TEST,
  121. FW_MAC_TYPE_MAX = FW_MAC_TYPE_TEST
  122. }; /* MAC_CONTEXT_TYPE_API_E_VER_1 */
  123. /**
  124. * enum iwl_tsf_id - TSF hw timer ID
  125. * @TSF_ID_A: use TSF A
  126. * @TSF_ID_B: use TSF B
  127. * @TSF_ID_C: use TSF C
  128. * @TSF_ID_D: use TSF D
  129. * @NUM_TSF_IDS: number of TSF timers available
  130. */
  131. enum iwl_tsf_id {
  132. TSF_ID_A = 0,
  133. TSF_ID_B = 1,
  134. TSF_ID_C = 2,
  135. TSF_ID_D = 3,
  136. NUM_TSF_IDS = 4,
  137. }; /* TSF_ID_API_E_VER_1 */
  138. /**
  139. * struct iwl_mac_data_ap - configuration data for AP MAC context
  140. * @beacon_time: beacon transmit time in system time
  141. * @beacon_tsf: beacon transmit time in TSF
  142. * @bi: beacon interval in TU
  143. * @bi_reciprocal: 2^32 / bi
  144. * @dtim_interval: dtim transmit time in TU
  145. * @dtim_reciprocal: 2^32 / dtim_interval
  146. * @mcast_qid: queue ID for multicast traffic.
  147. * NOTE: obsolete from VER2 and on
  148. * @beacon_template: beacon template ID
  149. */
  150. struct iwl_mac_data_ap {
  151. __le32 beacon_time;
  152. __le64 beacon_tsf;
  153. __le32 bi;
  154. __le32 bi_reciprocal;
  155. __le32 dtim_interval;
  156. __le32 dtim_reciprocal;
  157. __le32 mcast_qid;
  158. __le32 beacon_template;
  159. } __packed; /* AP_MAC_DATA_API_S_VER_2 */
  160. /**
  161. * struct iwl_mac_data_ibss - configuration data for IBSS MAC context
  162. * @beacon_time: beacon transmit time in system time
  163. * @beacon_tsf: beacon transmit time in TSF
  164. * @bi: beacon interval in TU
  165. * @bi_reciprocal: 2^32 / bi
  166. * @beacon_template: beacon template ID
  167. */
  168. struct iwl_mac_data_ibss {
  169. __le32 beacon_time;
  170. __le64 beacon_tsf;
  171. __le32 bi;
  172. __le32 bi_reciprocal;
  173. __le32 beacon_template;
  174. } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
  175. /**
  176. * struct iwl_mac_data_sta - configuration data for station MAC context
  177. * @is_assoc: 1 for associated state, 0 otherwise
  178. * @dtim_time: DTIM arrival time in system time
  179. * @dtim_tsf: DTIM arrival time in TSF
  180. * @bi: beacon interval in TU, applicable only when associated
  181. * @bi_reciprocal: 2^32 / bi , applicable only when associated
  182. * @dtim_interval: DTIM interval in TU, applicable only when associated
  183. * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
  184. * @listen_interval: in beacon intervals, applicable only when associated
  185. * @assoc_id: unique ID assigned by the AP during association
  186. * @assoc_beacon_arrive_time: TSF of first beacon after association
  187. */
  188. struct iwl_mac_data_sta {
  189. __le32 is_assoc;
  190. __le32 dtim_time;
  191. __le64 dtim_tsf;
  192. __le32 bi;
  193. __le32 bi_reciprocal;
  194. __le32 dtim_interval;
  195. __le32 dtim_reciprocal;
  196. __le32 listen_interval;
  197. __le32 assoc_id;
  198. __le32 assoc_beacon_arrive_time;
  199. } __packed; /* STA_MAC_DATA_API_S_VER_1 */
  200. /**
  201. * struct iwl_mac_data_go - configuration data for P2P GO MAC context
  202. * @ap: iwl_mac_data_ap struct with most config data
  203. * @ctwin: client traffic window in TU (period after TBTT when GO is present).
  204. * 0 indicates that there is no CT window.
  205. * @opp_ps_enabled: indicate that opportunistic PS allowed
  206. */
  207. struct iwl_mac_data_go {
  208. struct iwl_mac_data_ap ap;
  209. __le32 ctwin;
  210. __le32 opp_ps_enabled;
  211. } __packed; /* GO_MAC_DATA_API_S_VER_1 */
  212. /**
  213. * struct iwl_mac_data_p2p_sta - configuration data for P2P client MAC context
  214. * @sta: iwl_mac_data_sta struct with most config data
  215. * @ctwin: client traffic window in TU (period after TBTT when GO is present).
  216. * 0 indicates that there is no CT window.
  217. */
  218. struct iwl_mac_data_p2p_sta {
  219. struct iwl_mac_data_sta sta;
  220. __le32 ctwin;
  221. } __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */
  222. /**
  223. * struct iwl_mac_data_pibss - Pseudo IBSS config data
  224. * @stats_interval: interval in TU between statistics notifications to host.
  225. */
  226. struct iwl_mac_data_pibss {
  227. __le32 stats_interval;
  228. } __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */
  229. /*
  230. * struct iwl_mac_data_p2p_dev - configuration data for the P2P Device MAC
  231. * context.
  232. * @is_disc_extended: if set to true, P2P Device discoverability is enabled on
  233. * other channels as well. This should be to true only in case that the
  234. * device is discoverable and there is an active GO. Note that setting this
  235. * field when not needed, will increase the number of interrupts and have
  236. * effect on the platform power, as this setting opens the Rx filters on
  237. * all macs.
  238. */
  239. struct iwl_mac_data_p2p_dev {
  240. __le32 is_disc_extended;
  241. } __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */
  242. /**
  243. * enum iwl_mac_filter_flags - MAC context filter flags
  244. * @MAC_FILTER_IN_PROMISC: accept all data frames
  245. * @MAC_FILTER_IN_CONTROL_AND_MGMT: pass all management and
  246. * control frames to the host
  247. * @MAC_FILTER_ACCEPT_GRP: accept multicast frames
  248. * @MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames
  249. * @MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames
  250. * @MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host
  251. * (in station mode when associated)
  252. * @MAC_FILTER_OUT_BCAST: filter out all broadcast frames
  253. * @MAC_FILTER_IN_CRC32: extract FCS and append it to frames
  254. * @MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host
  255. */
  256. enum iwl_mac_filter_flags {
  257. MAC_FILTER_IN_PROMISC = BIT(0),
  258. MAC_FILTER_IN_CONTROL_AND_MGMT = BIT(1),
  259. MAC_FILTER_ACCEPT_GRP = BIT(2),
  260. MAC_FILTER_DIS_DECRYPT = BIT(3),
  261. MAC_FILTER_DIS_GRP_DECRYPT = BIT(4),
  262. MAC_FILTER_IN_BEACON = BIT(6),
  263. MAC_FILTER_OUT_BCAST = BIT(8),
  264. MAC_FILTER_IN_CRC32 = BIT(11),
  265. MAC_FILTER_IN_PROBE_REQUEST = BIT(12),
  266. };
  267. /**
  268. * enum iwl_mac_qos_flags - QoS flags
  269. * @MAC_QOS_FLG_UPDATE_EDCA: ?
  270. * @MAC_QOS_FLG_TGN: HT is enabled
  271. * @MAC_QOS_FLG_TXOP_TYPE: ?
  272. *
  273. */
  274. enum iwl_mac_qos_flags {
  275. MAC_QOS_FLG_UPDATE_EDCA = BIT(0),
  276. MAC_QOS_FLG_TGN = BIT(1),
  277. MAC_QOS_FLG_TXOP_TYPE = BIT(4),
  278. };
  279. /**
  280. * struct iwl_ac_qos - QOS timing params for MAC_CONTEXT_CMD
  281. * @cw_min: Contention window, start value in numbers of slots.
  282. * Should be a power-of-2, minus 1. Device's default is 0x0f.
  283. * @cw_max: Contention window, max value in numbers of slots.
  284. * Should be a power-of-2, minus 1. Device's default is 0x3f.
  285. * @aifsn: Number of slots in Arbitration Interframe Space (before
  286. * performing random backoff timing prior to Tx). Device default 1.
  287. * @fifos_mask: FIFOs used by this MAC for this AC
  288. * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
  289. *
  290. * One instance of this config struct for each of 4 EDCA access categories
  291. * in struct iwl_qosparam_cmd.
  292. *
  293. * Device will automatically increase contention window by (2*CW) + 1 for each
  294. * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
  295. * value, to cap the CW value.
  296. */
  297. struct iwl_ac_qos {
  298. __le16 cw_min;
  299. __le16 cw_max;
  300. u8 aifsn;
  301. u8 fifos_mask;
  302. __le16 edca_txop;
  303. } __packed; /* AC_QOS_API_S_VER_2 */
  304. /**
  305. * struct iwl_mac_ctx_cmd - command structure to configure MAC contexts
  306. * ( MAC_CONTEXT_CMD = 0x28 )
  307. * @id_and_color: ID and color of the MAC
  308. * @action: action to perform, one of FW_CTXT_ACTION_*
  309. * @mac_type: one of &enum iwl_mac_types
  310. * @tsf_id: TSF HW timer, one of &enum iwl_tsf_id
  311. * @node_addr: MAC address
  312. * @reserved_for_node_addr: reserved
  313. * @bssid_addr: BSSID
  314. * @reserved_for_bssid_addr: reserved
  315. * @cck_rates: basic rates available for CCK
  316. * @ofdm_rates: basic rates available for OFDM
  317. * @protection_flags: combination of &enum iwl_mac_protection_flags
  318. * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise
  319. * @short_slot: 0x10 for enabling short slots, 0 otherwise
  320. * @filter_flags: combination of &enum iwl_mac_filter_flags
  321. * @qos_flags: from &enum iwl_mac_qos_flags
  322. * @ac: one iwl_mac_qos configuration for each AC
  323. */
  324. struct iwl_mac_ctx_cmd {
  325. /* COMMON_INDEX_HDR_API_S_VER_1 */
  326. __le32 id_and_color;
  327. __le32 action;
  328. /* MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */
  329. __le32 mac_type;
  330. __le32 tsf_id;
  331. u8 node_addr[6];
  332. __le16 reserved_for_node_addr;
  333. u8 bssid_addr[6];
  334. __le16 reserved_for_bssid_addr;
  335. __le32 cck_rates;
  336. __le32 ofdm_rates;
  337. __le32 protection_flags;
  338. __le32 cck_short_preamble;
  339. __le32 short_slot;
  340. __le32 filter_flags;
  341. /* MAC_QOS_PARAM_API_S_VER_1 */
  342. __le32 qos_flags;
  343. struct iwl_ac_qos ac[AC_NUM+1];
  344. /* MAC_CONTEXT_COMMON_DATA_API_S */
  345. union {
  346. struct iwl_mac_data_ap ap;
  347. struct iwl_mac_data_go go;
  348. struct iwl_mac_data_sta sta;
  349. struct iwl_mac_data_p2p_sta p2p_sta;
  350. struct iwl_mac_data_p2p_dev p2p_dev;
  351. struct iwl_mac_data_pibss pibss;
  352. struct iwl_mac_data_ibss ibss;
  353. };
  354. } __packed; /* MAC_CONTEXT_CMD_API_S_VER_1 */
  355. static inline u32 iwl_mvm_reciprocal(u32 v)
  356. {
  357. if (!v)
  358. return 0;
  359. return 0xFFFFFFFF / v;
  360. }
  361. #define IWL_NONQOS_SEQ_GET 0x1
  362. #define IWL_NONQOS_SEQ_SET 0x2
  363. struct iwl_nonqos_seq_query_cmd {
  364. __le32 get_set_flag;
  365. __le32 mac_id_n_color;
  366. __le16 value;
  367. __le16 reserved;
  368. } __packed; /* NON_QOS_TX_COUNTER_GET_SET_API_S_VER_1 */
  369. /**
  370. * struct iwl_missed_beacons_notif - information on missed beacons
  371. * ( MISSED_BEACONS_NOTIFICATION = 0xa2 )
  372. * @mac_id: interface ID
  373. * @consec_missed_beacons_since_last_rx: number of consecutive missed
  374. * beacons since last RX.
  375. * @consec_missed_beacons: number of consecutive missed beacons
  376. * @num_expected_beacons: number of expected beacons
  377. * @num_recvd_beacons: number of received beacons
  378. */
  379. struct iwl_missed_beacons_notif {
  380. __le32 mac_id;
  381. __le32 consec_missed_beacons_since_last_rx;
  382. __le32 consec_missed_beacons;
  383. __le32 num_expected_beacons;
  384. __le32 num_recvd_beacons;
  385. } __packed; /* MISSED_BEACON_NTFY_API_S_VER_3 */
  386. #endif /* __iwl_fw_api_mac_h__ */