fw-api-rx.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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) 2015 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. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  24. * USA
  25. *
  26. * The full GNU General Public License is included in this distribution
  27. * in the file called COPYING.
  28. *
  29. * Contact Information:
  30. * Intel Linux Wireless <linuxwifi@intel.com>
  31. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  32. *
  33. * BSD LICENSE
  34. *
  35. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  36. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  37. * Copyright(c) 2015 Intel Deutschland GmbH
  38. * All rights reserved.
  39. *
  40. * Redistribution and use in source and binary forms, with or without
  41. * modification, are permitted provided that the following conditions
  42. * are met:
  43. *
  44. * * Redistributions of source code must retain the above copyright
  45. * notice, this list of conditions and the following disclaimer.
  46. * * Redistributions in binary form must reproduce the above copyright
  47. * notice, this list of conditions and the following disclaimer in
  48. * the documentation and/or other materials provided with the
  49. * distribution.
  50. * * Neither the name Intel Corporation nor the names of its
  51. * contributors may be used to endorse or promote products derived
  52. * from this software without specific prior written permission.
  53. *
  54. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  55. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  56. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  57. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  58. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  59. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  60. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  61. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  62. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  63. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  64. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  65. *
  66. *****************************************************************************/
  67. #ifndef __fw_api_rx_h__
  68. #define __fw_api_rx_h__
  69. /* API for pre-9000 hardware */
  70. #define IWL_RX_INFO_PHY_CNT 8
  71. #define IWL_RX_INFO_ENERGY_ANT_ABC_IDX 1
  72. #define IWL_RX_INFO_ENERGY_ANT_A_MSK 0x000000ff
  73. #define IWL_RX_INFO_ENERGY_ANT_B_MSK 0x0000ff00
  74. #define IWL_RX_INFO_ENERGY_ANT_C_MSK 0x00ff0000
  75. #define IWL_RX_INFO_ENERGY_ANT_A_POS 0
  76. #define IWL_RX_INFO_ENERGY_ANT_B_POS 8
  77. #define IWL_RX_INFO_ENERGY_ANT_C_POS 16
  78. /**
  79. * struct iwl_rx_phy_info - phy info
  80. * (REPLY_RX_PHY_CMD = 0xc0)
  81. * @non_cfg_phy_cnt: non configurable DSP phy data byte count
  82. * @cfg_phy_cnt: configurable DSP phy data byte count
  83. * @stat_id: configurable DSP phy data set ID
  84. * @reserved1:
  85. * @system_timestamp: GP2 at on air rise
  86. * @timestamp: TSF at on air rise
  87. * @beacon_time_stamp: beacon at on-air rise
  88. * @phy_flags: general phy flags: band, modulation, ...
  89. * @channel: channel number
  90. * @non_cfg_phy_buf: for various implementations of non_cfg_phy
  91. * @rate_n_flags: RATE_MCS_*
  92. * @byte_count: frame's byte-count
  93. * @frame_time: frame's time on the air, based on byte count and frame rate
  94. * calculation
  95. * @mac_active_msk: what MACs were active when the frame was received
  96. *
  97. * Before each Rx, the device sends this data. It contains PHY information
  98. * about the reception of the packet.
  99. */
  100. struct iwl_rx_phy_info {
  101. u8 non_cfg_phy_cnt;
  102. u8 cfg_phy_cnt;
  103. u8 stat_id;
  104. u8 reserved1;
  105. __le32 system_timestamp;
  106. __le64 timestamp;
  107. __le32 beacon_time_stamp;
  108. __le16 phy_flags;
  109. __le16 channel;
  110. __le32 non_cfg_phy[IWL_RX_INFO_PHY_CNT];
  111. __le32 rate_n_flags;
  112. __le32 byte_count;
  113. __le16 mac_active_msk;
  114. __le16 frame_time;
  115. } __packed;
  116. /*
  117. * TCP offload Rx assist info
  118. *
  119. * bits 0:3 - reserved
  120. * bits 4:7 - MIC CRC length
  121. * bits 8:12 - MAC header length
  122. * bit 13 - Padding indication
  123. * bit 14 - A-AMSDU indication
  124. * bit 15 - Offload enabled
  125. */
  126. enum iwl_csum_rx_assist_info {
  127. CSUM_RXA_RESERVED_MASK = 0x000f,
  128. CSUM_RXA_MICSIZE_MASK = 0x00f0,
  129. CSUM_RXA_HEADERLEN_MASK = 0x1f00,
  130. CSUM_RXA_PADD = BIT(13),
  131. CSUM_RXA_AMSDU = BIT(14),
  132. CSUM_RXA_ENA = BIT(15)
  133. };
  134. /**
  135. * struct iwl_rx_mpdu_res_start - phy info
  136. * @assist: see CSUM_RX_ASSIST_ above
  137. */
  138. struct iwl_rx_mpdu_res_start {
  139. __le16 byte_count;
  140. __le16 assist;
  141. } __packed; /* _RX_MPDU_RES_START_API_S_VER_2 */
  142. /**
  143. * enum iwl_rx_phy_flags - to parse %iwl_rx_phy_info phy_flags
  144. * @RX_RES_PHY_FLAGS_BAND_24: true if the packet was received on 2.4 band
  145. * @RX_RES_PHY_FLAGS_MOD_CCK:
  146. * @RX_RES_PHY_FLAGS_SHORT_PREAMBLE: true if packet's preamble was short
  147. * @RX_RES_PHY_FLAGS_NARROW_BAND:
  148. * @RX_RES_PHY_FLAGS_ANTENNA: antenna on which the packet was received
  149. * @RX_RES_PHY_FLAGS_AGG: set if the packet was part of an A-MPDU
  150. * @RX_RES_PHY_FLAGS_OFDM_HT: The frame was an HT frame
  151. * @RX_RES_PHY_FLAGS_OFDM_GF: The frame used GF preamble
  152. * @RX_RES_PHY_FLAGS_OFDM_VHT: The frame was a VHT frame
  153. */
  154. enum iwl_rx_phy_flags {
  155. RX_RES_PHY_FLAGS_BAND_24 = BIT(0),
  156. RX_RES_PHY_FLAGS_MOD_CCK = BIT(1),
  157. RX_RES_PHY_FLAGS_SHORT_PREAMBLE = BIT(2),
  158. RX_RES_PHY_FLAGS_NARROW_BAND = BIT(3),
  159. RX_RES_PHY_FLAGS_ANTENNA = (0x7 << 4),
  160. RX_RES_PHY_FLAGS_ANTENNA_POS = 4,
  161. RX_RES_PHY_FLAGS_AGG = BIT(7),
  162. RX_RES_PHY_FLAGS_OFDM_HT = BIT(8),
  163. RX_RES_PHY_FLAGS_OFDM_GF = BIT(9),
  164. RX_RES_PHY_FLAGS_OFDM_VHT = BIT(10),
  165. };
  166. /**
  167. * enum iwl_mvm_rx_status - written by fw for each Rx packet
  168. * @RX_MPDU_RES_STATUS_CRC_OK: CRC is fine
  169. * @RX_MPDU_RES_STATUS_OVERRUN_OK: there was no RXE overflow
  170. * @RX_MPDU_RES_STATUS_SRC_STA_FOUND:
  171. * @RX_MPDU_RES_STATUS_KEY_VALID:
  172. * @RX_MPDU_RES_STATUS_KEY_PARAM_OK:
  173. * @RX_MPDU_RES_STATUS_ICV_OK: ICV is fine, if not, the packet is destroyed
  174. * @RX_MPDU_RES_STATUS_MIC_OK: used for CCM alg only. TKIP MIC is checked
  175. * in the driver.
  176. * @RX_MPDU_RES_STATUS_TTAK_OK: TTAK is fine
  177. * @RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR: valid for alg = CCM_CMAC or
  178. * alg = CCM only. Checks replay attack for 11w frames. Relevant only if
  179. * %RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME is set.
  180. * @RX_MPDU_RES_STATUS_SEC_NO_ENC: this frame is not encrypted
  181. * @RX_MPDU_RES_STATUS_SEC_WEP_ENC: this frame is encrypted using WEP
  182. * @RX_MPDU_RES_STATUS_SEC_CCM_ENC: this frame is encrypted using CCM
  183. * @RX_MPDU_RES_STATUS_SEC_TKIP_ENC: this frame is encrypted using TKIP
  184. * @RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC: this frame is encrypted using CCM_CMAC
  185. * @RX_MPDU_RES_STATUS_SEC_ENC_ERR: this frame couldn't be decrypted
  186. * @RX_MPDU_RES_STATUS_SEC_ENC_MSK: bitmask of the encryption algorithm
  187. * @RX_MPDU_RES_STATUS_DEC_DONE: this frame has been successfully decrypted
  188. * @RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP:
  189. * @RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP:
  190. * @RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT:
  191. * @RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME: this frame is an 11w management frame
  192. * @RX_MPDU_RES_STATUS_CSUM_DONE: checksum was done by the hw
  193. * @RX_MPDU_RES_STATUS_CSUM_OK: checksum found no errors
  194. * @RX_MPDU_RES_STATUS_HASH_INDEX_MSK:
  195. * @RX_MPDU_RES_STATUS_STA_ID_MSK:
  196. * @RX_MPDU_RES_STATUS_RRF_KILL:
  197. * @RX_MPDU_RES_STATUS_FILTERING_MSK:
  198. * @RX_MPDU_RES_STATUS2_FILTERING_MSK:
  199. */
  200. enum iwl_mvm_rx_status {
  201. RX_MPDU_RES_STATUS_CRC_OK = BIT(0),
  202. RX_MPDU_RES_STATUS_OVERRUN_OK = BIT(1),
  203. RX_MPDU_RES_STATUS_SRC_STA_FOUND = BIT(2),
  204. RX_MPDU_RES_STATUS_KEY_VALID = BIT(3),
  205. RX_MPDU_RES_STATUS_KEY_PARAM_OK = BIT(4),
  206. RX_MPDU_RES_STATUS_ICV_OK = BIT(5),
  207. RX_MPDU_RES_STATUS_MIC_OK = BIT(6),
  208. RX_MPDU_RES_STATUS_TTAK_OK = BIT(7),
  209. RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR = BIT(7),
  210. RX_MPDU_RES_STATUS_SEC_NO_ENC = (0 << 8),
  211. RX_MPDU_RES_STATUS_SEC_WEP_ENC = (1 << 8),
  212. RX_MPDU_RES_STATUS_SEC_CCM_ENC = (2 << 8),
  213. RX_MPDU_RES_STATUS_SEC_TKIP_ENC = (3 << 8),
  214. RX_MPDU_RES_STATUS_SEC_EXT_ENC = (4 << 8),
  215. RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC = (6 << 8),
  216. RX_MPDU_RES_STATUS_SEC_ENC_ERR = (7 << 8),
  217. RX_MPDU_RES_STATUS_SEC_ENC_MSK = (7 << 8),
  218. RX_MPDU_RES_STATUS_DEC_DONE = BIT(11),
  219. RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP = BIT(12),
  220. RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP = BIT(13),
  221. RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT = BIT(14),
  222. RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME = BIT(15),
  223. RX_MPDU_RES_STATUS_CSUM_DONE = BIT(16),
  224. RX_MPDU_RES_STATUS_CSUM_OK = BIT(17),
  225. RX_MPDU_RES_STATUS_HASH_INDEX_MSK = (0x3F0000),
  226. RX_MDPU_RES_STATUS_STA_ID_SHIFT = 24,
  227. RX_MPDU_RES_STATUS_STA_ID_MSK = 0x1f << RX_MDPU_RES_STATUS_STA_ID_SHIFT,
  228. RX_MPDU_RES_STATUS_RRF_KILL = BIT(29),
  229. RX_MPDU_RES_STATUS_FILTERING_MSK = (0xc00000),
  230. RX_MPDU_RES_STATUS2_FILTERING_MSK = (0xc0000000),
  231. };
  232. /* 9000 series API */
  233. enum iwl_rx_mpdu_mac_flags1 {
  234. IWL_RX_MDPU_MFLG1_ADDRTYPE_MASK = 0x03,
  235. IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_MASK = 0xf0,
  236. /* shift should be 4, but the length is measured in 2-byte
  237. * words, so shifting only by 3 gives a byte result
  238. */
  239. IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_SHIFT = 3,
  240. };
  241. enum iwl_rx_mpdu_mac_flags2 {
  242. /* in 2-byte words */
  243. IWL_RX_MPDU_MFLG2_HDR_LEN_MASK = 0x1f,
  244. IWL_RX_MPDU_MFLG2_PAD = 0x20,
  245. IWL_RX_MPDU_MFLG2_AMSDU = 0x40,
  246. };
  247. enum iwl_rx_mpdu_amsdu_info {
  248. IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK = 0x3f,
  249. IWL_RX_MPDU_AMSDU_LAST_SUBFRAME = 0x40,
  250. /* 0x80 bit reserved for now */
  251. };
  252. enum iwl_rx_l3l4_flags {
  253. IWL_RX_L3L4_IP_HDR_CSUM_OK = BIT(0),
  254. IWL_RX_L3L4_TCP_UDP_CSUM_OK = BIT(1),
  255. IWL_RX_L3L4_TCP_FIN_SYN_RST_PSH = BIT(2),
  256. IWL_RX_L3L4_TCP_ACK = BIT(3),
  257. IWL_RX_L3L4_L3_PROTO_MASK = 0xf << 4,
  258. IWL_RX_L3L4_L4_PROTO_MASK = 0xf << 8,
  259. IWL_RX_L3L4_RSS_HASH_MASK = 0xf << 12,
  260. };
  261. enum iwl_rx_mpdu_status {
  262. IWL_RX_MPDU_STATUS_CRC_OK = BIT(0),
  263. IWL_RX_MPDU_STATUS_OVERRUN_OK = BIT(1),
  264. IWL_RX_MPDU_STATUS_SRC_STA_FOUND = BIT(2),
  265. IWL_RX_MPDU_STATUS_KEY_VALID = BIT(3),
  266. IWL_RX_MPDU_STATUS_KEY_ERROR = BIT(4),
  267. IWL_RX_MPDU_STATUS_ICV_OK = BIT(5),
  268. IWL_RX_MPDU_STATUS_MIC_OK = BIT(6),
  269. IWL_RX_MPDU_STATUS_SEC_MASK = 0x7 << 8,
  270. IWL_RX_MPDU_STATUS_SEC_NONE = 0x0 << 8,
  271. IWL_RX_MPDU_STATUS_SEC_WEP = 0x1 << 8,
  272. IWL_RX_MPDU_STATUS_SEC_CCM = 0x2 << 8,
  273. IWL_RX_MPDU_STATUS_SEC_TKIP = 0x3 << 8,
  274. IWL_RX_MPDU_STATUS_DECRYPTED = BIT(11),
  275. IWL_RX_MPDU_STATUS_WEP_MATCH = BIT(12),
  276. IWL_RX_MPDU_STATUS_EXT_IV_MATCH = BIT(13),
  277. IWL_RX_MPDU_STATUS_KEY_ID_MATCH = BIT(14),
  278. IWL_RX_MPDU_STATUS_KEY_COLOR = BIT(15),
  279. };
  280. enum iwl_rx_mpdu_hash_filter {
  281. IWL_RX_MPDU_HF_A1_HASH_MASK = 0x3f,
  282. IWL_RX_MPDU_HF_FILTER_STATUS_MASK = 0xc0,
  283. };
  284. enum iwl_rx_mpdu_sta_id_flags {
  285. IWL_RX_MPDU_SIF_STA_ID_MASK = 0x1f,
  286. IWL_RX_MPDU_SIF_RRF_ABORT = 0x20,
  287. IWL_RX_MPDU_SIF_FILTER_STATUS_MASK = 0xc0,
  288. };
  289. enum iwl_rx_mpdu_reorder_data {
  290. IWL_RX_MPDU_REORDER_NSSN_MASK = 0x00000fff,
  291. IWL_RX_MPDU_REORDER_SN_MASK = 0x00fff000,
  292. IWL_RX_MPDU_REORDER_SN_SHIFT = 12,
  293. IWL_RX_MPDU_REORDER_BAID_MASK = 0x7f000000,
  294. IWL_RX_MPDU_REORDER_BAID_SHIFT = 24,
  295. IWL_RX_MPDU_REORDER_BA_OLD_SN = 0x80000000,
  296. };
  297. struct iwl_rx_mpdu_desc {
  298. /* DW2 */
  299. __le16 mpdu_len;
  300. u8 mac_flags1;
  301. u8 mac_flags2;
  302. /* DW3 */
  303. u8 amsdu_info;
  304. __le16 reserved_for_software;
  305. u8 mac_phy_idx;
  306. /* DW4 */
  307. __le16 raw_csum; /* alledgedly unreliable */
  308. __le16 l3l4_flags;
  309. /* DW5 */
  310. __le16 status;
  311. u8 hash_filter;
  312. u8 sta_id_flags;
  313. /* DW6 */
  314. __le32 reorder_data;
  315. /* DW7 */
  316. __le32 rss_hash;
  317. /* DW8 */
  318. __le32 filter_match;
  319. /* DW9 */
  320. __le32 gp2_on_air_rise;
  321. /* DW10 */
  322. __le32 rate_n_flags;
  323. /* DW11 */
  324. u8 energy_a, energy_b, energy_c, channel;
  325. /* DW12 & DW13 */
  326. __le64 tsf_on_air_rise;
  327. } __packed;
  328. struct iwl_frame_release {
  329. u8 baid;
  330. u8 reserved;
  331. __le16 nssn;
  332. };
  333. #endif /* __fw_api_rx_h__ */