xref: /openbmc/linux/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h (revision 05cf4fe738242183f1237f1b3a28b4479348c0a1)
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 - 2017 Intel Deutschland GmbH
11  * Copyright(c) 2018 Intel Corporation
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of version 2 of the GNU General Public License as
15  * published by the Free Software Foundation.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * The full GNU General Public License is included in this distribution
23  * in the file called COPYING.
24  *
25  * Contact Information:
26  *  Intel Linux Wireless <linuxwifi@intel.com>
27  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28  *
29  * BSD LICENSE
30  *
31  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
34  * Copyright(c) 2018 Intel Corporation
35  * All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  *
41  *  * Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  *  * Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in
45  *    the documentation and/or other materials provided with the
46  *    distribution.
47  *  * Neither the name Intel Corporation nor the names of its
48  *    contributors may be used to endorse or promote products derived
49  *    from this software without specific prior written permission.
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62  *
63  *****************************************************************************/
64 
65 #ifndef __iwl_fw_api_rx_h__
66 #define __iwl_fw_api_rx_h__
67 
68 /* API for pre-9000 hardware */
69 
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 enum iwl_mac_context_info {
80 	MAC_CONTEXT_INFO_NONE,
81 	MAC_CONTEXT_INFO_GSCAN,
82 };
83 
84 /**
85  * struct iwl_rx_phy_info - phy info
86  * (REPLY_RX_PHY_CMD = 0xc0)
87  * @non_cfg_phy_cnt: non configurable DSP phy data byte count
88  * @cfg_phy_cnt: configurable DSP phy data byte count
89  * @stat_id: configurable DSP phy data set ID
90  * @reserved1: reserved
91  * @system_timestamp: GP2  at on air rise
92  * @timestamp: TSF at on air rise
93  * @beacon_time_stamp: beacon at on-air rise
94  * @phy_flags: general phy flags: band, modulation, ...
95  * @channel: channel number
96  * @non_cfg_phy: for various implementations of non_cfg_phy
97  * @rate_n_flags: RATE_MCS_*
98  * @byte_count: frame's byte-count
99  * @frame_time: frame's time on the air, based on byte count and frame rate
100  *	calculation
101  * @mac_active_msk: what MACs were active when the frame was received
102  * @mac_context_info: additional info on the context in which the frame was
103  *	received as defined in &enum iwl_mac_context_info
104  *
105  * Before each Rx, the device sends this data. It contains PHY information
106  * about the reception of the packet.
107  */
108 struct iwl_rx_phy_info {
109 	u8 non_cfg_phy_cnt;
110 	u8 cfg_phy_cnt;
111 	u8 stat_id;
112 	u8 reserved1;
113 	__le32 system_timestamp;
114 	__le64 timestamp;
115 	__le32 beacon_time_stamp;
116 	__le16 phy_flags;
117 	__le16 channel;
118 	__le32 non_cfg_phy[IWL_RX_INFO_PHY_CNT];
119 	__le32 rate_n_flags;
120 	__le32 byte_count;
121 	u8 mac_active_msk;
122 	u8 mac_context_info;
123 	__le16 frame_time;
124 } __packed;
125 
126 /*
127  * TCP offload Rx assist info
128  *
129  * bits 0:3 - reserved
130  * bits 4:7 - MIC CRC length
131  * bits 8:12 - MAC header length
132  * bit 13 - Padding indication
133  * bit 14 - A-AMSDU indication
134  * bit 15 - Offload enabled
135  */
136 enum iwl_csum_rx_assist_info {
137 	CSUM_RXA_RESERVED_MASK	= 0x000f,
138 	CSUM_RXA_MICSIZE_MASK	= 0x00f0,
139 	CSUM_RXA_HEADERLEN_MASK	= 0x1f00,
140 	CSUM_RXA_PADD		= BIT(13),
141 	CSUM_RXA_AMSDU		= BIT(14),
142 	CSUM_RXA_ENA		= BIT(15)
143 };
144 
145 /**
146  * struct iwl_rx_mpdu_res_start - phy info
147  * @byte_count: byte count of the frame
148  * @assist: see &enum iwl_csum_rx_assist_info
149  */
150 struct iwl_rx_mpdu_res_start {
151 	__le16 byte_count;
152 	__le16 assist;
153 } __packed; /* _RX_MPDU_RES_START_API_S_VER_2 */
154 
155 /**
156  * enum iwl_rx_phy_flags - to parse %iwl_rx_phy_info phy_flags
157  * @RX_RES_PHY_FLAGS_BAND_24: true if the packet was received on 2.4 band
158  * @RX_RES_PHY_FLAGS_MOD_CCK: modulation is CCK
159  * @RX_RES_PHY_FLAGS_SHORT_PREAMBLE: true if packet's preamble was short
160  * @RX_RES_PHY_FLAGS_NARROW_BAND: narrow band (<20 MHz) receive
161  * @RX_RES_PHY_FLAGS_ANTENNA: antenna on which the packet was received
162  * @RX_RES_PHY_FLAGS_ANTENNA_POS: antenna bit position
163  * @RX_RES_PHY_FLAGS_AGG: set if the packet was part of an A-MPDU
164  * @RX_RES_PHY_FLAGS_OFDM_HT: The frame was an HT frame
165  * @RX_RES_PHY_FLAGS_OFDM_GF: The frame used GF preamble
166  * @RX_RES_PHY_FLAGS_OFDM_VHT: The frame was a VHT frame
167  */
168 enum iwl_rx_phy_flags {
169 	RX_RES_PHY_FLAGS_BAND_24	= BIT(0),
170 	RX_RES_PHY_FLAGS_MOD_CCK	= BIT(1),
171 	RX_RES_PHY_FLAGS_SHORT_PREAMBLE	= BIT(2),
172 	RX_RES_PHY_FLAGS_NARROW_BAND	= BIT(3),
173 	RX_RES_PHY_FLAGS_ANTENNA	= (0x7 << 4),
174 	RX_RES_PHY_FLAGS_ANTENNA_POS	= 4,
175 	RX_RES_PHY_FLAGS_AGG		= BIT(7),
176 	RX_RES_PHY_FLAGS_OFDM_HT	= BIT(8),
177 	RX_RES_PHY_FLAGS_OFDM_GF	= BIT(9),
178 	RX_RES_PHY_FLAGS_OFDM_VHT	= BIT(10),
179 };
180 
181 /**
182  * enum iwl_mvm_rx_status - written by fw for each Rx packet
183  * @RX_MPDU_RES_STATUS_CRC_OK: CRC is fine
184  * @RX_MPDU_RES_STATUS_OVERRUN_OK: there was no RXE overflow
185  * @RX_MPDU_RES_STATUS_SRC_STA_FOUND: station was found
186  * @RX_MPDU_RES_STATUS_KEY_VALID: key was valid
187  * @RX_MPDU_RES_STATUS_KEY_PARAM_OK: key parameters were usable
188  * @RX_MPDU_RES_STATUS_ICV_OK: ICV is fine, if not, the packet is destroyed
189  * @RX_MPDU_RES_STATUS_MIC_OK: used for CCM alg only. TKIP MIC is checked
190  *	in the driver.
191  * @RX_MPDU_RES_STATUS_TTAK_OK: TTAK is fine
192  * @RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR:  valid for alg = CCM_CMAC or
193  *	alg = CCM only. Checks replay attack for 11w frames. Relevant only if
194  *	%RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME is set.
195  * @RX_MPDU_RES_STATUS_SEC_NO_ENC: this frame is not encrypted
196  * @RX_MPDU_RES_STATUS_SEC_WEP_ENC: this frame is encrypted using WEP
197  * @RX_MPDU_RES_STATUS_SEC_CCM_ENC: this frame is encrypted using CCM
198  * @RX_MPDU_RES_STATUS_SEC_TKIP_ENC: this frame is encrypted using TKIP
199  * @RX_MPDU_RES_STATUS_SEC_EXT_ENC: this frame is encrypted using extension
200  *	algorithm
201  * @RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC: this frame is encrypted using CCM_CMAC
202  * @RX_MPDU_RES_STATUS_SEC_ENC_ERR: this frame couldn't be decrypted
203  * @RX_MPDU_RES_STATUS_SEC_ENC_MSK: bitmask of the encryption algorithm
204  * @RX_MPDU_RES_STATUS_DEC_DONE: this frame has been successfully decrypted
205  * @RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP: extended IV (set with TKIP)
206  * @RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT: key ID comparison done
207  * @RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME: this frame is an 11w management frame
208  * @RX_MPDU_RES_STATUS_CSUM_DONE: checksum was done by the hw
209  * @RX_MPDU_RES_STATUS_CSUM_OK: checksum found no errors
210  * @RX_MPDU_RES_STATUS_STA_ID_MSK: station ID mask
211  * @RX_MDPU_RES_STATUS_STA_ID_SHIFT: station ID bit shift
212  * @RX_MPDU_RES_STATUS_FILTERING_MSK: filter status
213  * @RX_MPDU_RES_STATUS2_FILTERING_MSK: filter status 2
214  */
215 enum iwl_mvm_rx_status {
216 	RX_MPDU_RES_STATUS_CRC_OK			= BIT(0),
217 	RX_MPDU_RES_STATUS_OVERRUN_OK			= BIT(1),
218 	RX_MPDU_RES_STATUS_SRC_STA_FOUND		= BIT(2),
219 	RX_MPDU_RES_STATUS_KEY_VALID			= BIT(3),
220 	RX_MPDU_RES_STATUS_KEY_PARAM_OK			= BIT(4),
221 	RX_MPDU_RES_STATUS_ICV_OK			= BIT(5),
222 	RX_MPDU_RES_STATUS_MIC_OK			= BIT(6),
223 	RX_MPDU_RES_STATUS_TTAK_OK			= BIT(7),
224 	RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR		= BIT(7),
225 	RX_MPDU_RES_STATUS_SEC_NO_ENC			= (0 << 8),
226 	RX_MPDU_RES_STATUS_SEC_WEP_ENC			= (1 << 8),
227 	RX_MPDU_RES_STATUS_SEC_CCM_ENC			= (2 << 8),
228 	RX_MPDU_RES_STATUS_SEC_TKIP_ENC			= (3 << 8),
229 	RX_MPDU_RES_STATUS_SEC_EXT_ENC			= (4 << 8),
230 	RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC		= (6 << 8),
231 	RX_MPDU_RES_STATUS_SEC_ENC_ERR			= (7 << 8),
232 	RX_MPDU_RES_STATUS_SEC_ENC_MSK			= (7 << 8),
233 	RX_MPDU_RES_STATUS_DEC_DONE			= BIT(11),
234 	RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP		= BIT(13),
235 	RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT		= BIT(14),
236 	RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME		= BIT(15),
237 	RX_MPDU_RES_STATUS_CSUM_DONE			= BIT(16),
238 	RX_MPDU_RES_STATUS_CSUM_OK			= BIT(17),
239 	RX_MDPU_RES_STATUS_STA_ID_SHIFT			= 24,
240 	RX_MPDU_RES_STATUS_STA_ID_MSK			= 0x1f << RX_MDPU_RES_STATUS_STA_ID_SHIFT,
241 	RX_MPDU_RES_STATUS_FILTERING_MSK		= (0xc00000),
242 	RX_MPDU_RES_STATUS2_FILTERING_MSK		= (0xc0000000),
243 };
244 
245 /* 9000 series API */
246 enum iwl_rx_mpdu_mac_flags1 {
247 	IWL_RX_MDPU_MFLG1_ADDRTYPE_MASK		= 0x03,
248 	IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_MASK	= 0xf0,
249 	/* shift should be 4, but the length is measured in 2-byte
250 	 * words, so shifting only by 3 gives a byte result
251 	 */
252 	IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_SHIFT	= 3,
253 };
254 
255 enum iwl_rx_mpdu_mac_flags2 {
256 	/* in 2-byte words */
257 	IWL_RX_MPDU_MFLG2_HDR_LEN_MASK		= 0x1f,
258 	IWL_RX_MPDU_MFLG2_PAD			= 0x20,
259 	IWL_RX_MPDU_MFLG2_AMSDU			= 0x40,
260 };
261 
262 enum iwl_rx_mpdu_amsdu_info {
263 	IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK	= 0x7f,
264 	IWL_RX_MPDU_AMSDU_LAST_SUBFRAME		= 0x80,
265 };
266 
267 enum iwl_rx_l3_proto_values {
268 	IWL_RX_L3_TYPE_NONE,
269 	IWL_RX_L3_TYPE_IPV4,
270 	IWL_RX_L3_TYPE_IPV4_FRAG,
271 	IWL_RX_L3_TYPE_IPV6_FRAG,
272 	IWL_RX_L3_TYPE_IPV6,
273 	IWL_RX_L3_TYPE_IPV6_IN_IPV4,
274 	IWL_RX_L3_TYPE_ARP,
275 	IWL_RX_L3_TYPE_EAPOL,
276 };
277 
278 #define IWL_RX_L3_PROTO_POS 4
279 
280 enum iwl_rx_l3l4_flags {
281 	IWL_RX_L3L4_IP_HDR_CSUM_OK		= BIT(0),
282 	IWL_RX_L3L4_TCP_UDP_CSUM_OK		= BIT(1),
283 	IWL_RX_L3L4_TCP_FIN_SYN_RST_PSH		= BIT(2),
284 	IWL_RX_L3L4_TCP_ACK			= BIT(3),
285 	IWL_RX_L3L4_L3_PROTO_MASK		= 0xf << IWL_RX_L3_PROTO_POS,
286 	IWL_RX_L3L4_L4_PROTO_MASK		= 0xf << 8,
287 	IWL_RX_L3L4_RSS_HASH_MASK		= 0xf << 12,
288 };
289 
290 enum iwl_rx_mpdu_status {
291 	IWL_RX_MPDU_STATUS_CRC_OK		= BIT(0),
292 	IWL_RX_MPDU_STATUS_OVERRUN_OK		= BIT(1),
293 	IWL_RX_MPDU_STATUS_SRC_STA_FOUND	= BIT(2),
294 	IWL_RX_MPDU_STATUS_KEY_VALID		= BIT(3),
295 	IWL_RX_MPDU_STATUS_KEY_PARAM_OK		= BIT(4),
296 	IWL_RX_MPDU_STATUS_ICV_OK		= BIT(5),
297 	IWL_RX_MPDU_STATUS_MIC_OK		= BIT(6),
298 	IWL_RX_MPDU_RES_STATUS_TTAK_OK		= BIT(7),
299 	IWL_RX_MPDU_STATUS_SEC_MASK		= 0x7 << 8,
300 	IWL_RX_MPDU_STATUS_SEC_UNKNOWN		= IWL_RX_MPDU_STATUS_SEC_MASK,
301 	IWL_RX_MPDU_STATUS_SEC_NONE		= 0x0 << 8,
302 	IWL_RX_MPDU_STATUS_SEC_WEP		= 0x1 << 8,
303 	IWL_RX_MPDU_STATUS_SEC_CCM		= 0x2 << 8,
304 	IWL_RX_MPDU_STATUS_SEC_TKIP		= 0x3 << 8,
305 	IWL_RX_MPDU_STATUS_SEC_EXT_ENC		= 0x4 << 8,
306 	IWL_RX_MPDU_STATUS_SEC_GCM		= 0x5 << 8,
307 	IWL_RX_MPDU_STATUS_DECRYPTED		= BIT(11),
308 	IWL_RX_MPDU_STATUS_WEP_MATCH		= BIT(12),
309 	IWL_RX_MPDU_STATUS_EXT_IV_MATCH		= BIT(13),
310 	IWL_RX_MPDU_STATUS_KEY_ID_MATCH		= BIT(14),
311 	IWL_RX_MPDU_STATUS_ROBUST_MNG_FRAME	= BIT(15),
312 };
313 
314 enum iwl_rx_mpdu_hash_filter {
315 	IWL_RX_MPDU_HF_A1_HASH_MASK		= 0x3f,
316 	IWL_RX_MPDU_HF_FILTER_STATUS_MASK	= 0xc0,
317 };
318 
319 enum iwl_rx_mpdu_sta_id_flags {
320 	IWL_RX_MPDU_SIF_STA_ID_MASK		= 0x1f,
321 	IWL_RX_MPDU_SIF_RRF_ABORT		= 0x20,
322 	IWL_RX_MPDU_SIF_FILTER_STATUS_MASK	= 0xc0,
323 };
324 
325 #define IWL_RX_REORDER_DATA_INVALID_BAID 0x7f
326 
327 enum iwl_rx_mpdu_reorder_data {
328 	IWL_RX_MPDU_REORDER_NSSN_MASK		= 0x00000fff,
329 	IWL_RX_MPDU_REORDER_SN_MASK		= 0x00fff000,
330 	IWL_RX_MPDU_REORDER_SN_SHIFT		= 12,
331 	IWL_RX_MPDU_REORDER_BAID_MASK		= 0x7f000000,
332 	IWL_RX_MPDU_REORDER_BAID_SHIFT		= 24,
333 	IWL_RX_MPDU_REORDER_BA_OLD_SN		= 0x80000000,
334 };
335 
336 enum iwl_rx_mpdu_phy_info {
337 	IWL_RX_MPDU_PHY_AMPDU		= BIT(5),
338 	IWL_RX_MPDU_PHY_AMPDU_TOGGLE	= BIT(6),
339 	IWL_RX_MPDU_PHY_SHORT_PREAMBLE	= BIT(7),
340 	IWL_RX_MPDU_PHY_TSF_OVERLOAD	= BIT(8),
341 };
342 
343 enum iwl_rx_mpdu_mac_info {
344 	IWL_RX_MPDU_PHY_MAC_INDEX_MASK		= 0x0f,
345 	IWL_RX_MPDU_PHY_PHY_INDEX_MASK		= 0xf0,
346 };
347 
348 /*
349  * enum iwl_rx_he_phy - HE PHY data
350  */
351 enum iwl_rx_he_phy {
352 	IWL_RX_HE_PHY_BEAM_CHNG			= BIT(0),
353 	IWL_RX_HE_PHY_UPLINK			= BIT(1),
354 	IWL_RX_HE_PHY_BSS_COLOR_MASK		= 0xfc,
355 	IWL_RX_HE_PHY_SPATIAL_REUSE_MASK	= 0xf00,
356 	IWL_RX_HE_PHY_SU_EXT_BW10		= BIT(12),
357 	IWL_RX_HE_PHY_TXOP_DUR_MASK		= 0xfe000,
358 	IWL_RX_HE_PHY_LDPC_EXT_SYM		= BIT(20),
359 	IWL_RX_HE_PHY_PRE_FEC_PAD_MASK		= 0x600000,
360 	IWL_RX_HE_PHY_PE_DISAMBIG		= BIT(23),
361 	IWL_RX_HE_PHY_DOPPLER			= BIT(24),
362 	/* 6 bits reserved */
363 	IWL_RX_HE_PHY_DELIM_EOF			= BIT(31),
364 
365 	/* second dword - common data */
366 	IWL_RX_HE_PHY_HE_LTF_NUM_MASK		= 0xe000000000ULL,
367 	IWL_RX_HE_PHY_RU_ALLOC_SEC80		= BIT_ULL(32 + 8),
368 	/* trigger encoded */
369 	IWL_RX_HE_PHY_RU_ALLOC_MASK		= 0xfe0000000000ULL,
370 	IWL_RX_HE_PHY_INFO_TYPE_MASK		= 0xf000000000000000ULL,
371 	IWL_RX_HE_PHY_INFO_TYPE_SU		= 0x0, /* TSF low valid (first DW) */
372 	IWL_RX_HE_PHY_INFO_TYPE_MU		= 0x1, /* TSF low/high valid (both DWs) */
373 	IWL_RX_HE_PHY_INFO_TYPE_MU_EXT_INFO	= 0x2, /* same + SIGB-common0/1/2 valid */
374 	IWL_RX_HE_PHY_INFO_TYPE_TB		= 0x3, /* TSF low/high valid (both DWs) */
375 
376 	/* second dword - MU data */
377 	IWL_RX_HE_PHY_MU_SIGB_COMPRESSION		= BIT_ULL(32 + 0),
378 	IWL_RX_HE_PHY_MU_SIBG_SYM_OR_USER_NUM_MASK	= 0x1e00000000ULL,
379 	IWL_RX_HE_PHY_MU_SIGB_MCS_MASK			= 0xf000000000000ULL,
380 	IWL_RX_HE_PHY_MU_SIGB_DCM			= BIT_ULL(32 + 21),
381 	IWL_RX_HE_PHY_MU_PREAMBLE_PUNC_TYPE_MASK	= 0xc0000000000000ULL,
382 
383 	/* second dword - TB data */
384 	IWL_RX_HE_PHY_TB_PILOT_TYPE			= BIT_ULL(32 + 0),
385 	IWL_RX_HE_PHY_TB_LOW_SS_MASK			= 0xe00000000ULL
386 };
387 
388 enum iwl_rx_he_sigb_common0 {
389 	/* the a1/a2/... is what the PHY/firmware calls the values */
390 	IWL_RX_HE_SIGB_COMMON0_CH1_RU0		= 0x000000ff, /* a1 */
391 	IWL_RX_HE_SIGB_COMMON0_CH1_RU2		= 0x0000ff00, /* a2 */
392 	IWL_RX_HE_SIGB_COMMON0_CH2_RU0		= 0x00ff0000, /* b1 */
393 	IWL_RX_HE_SIGB_COMMON0_CH2_RU2		= 0xff000000, /* b2 */
394 };
395 
396 enum iwl_rx_he_sigb_common1 {
397 	IWL_RX_HE_SIGB_COMMON1_CH1_RU1		= 0x000000ff, /* c1 */
398 	IWL_RX_HE_SIGB_COMMON1_CH1_RU3		= 0x0000ff00, /* c2 */
399 	IWL_RX_HE_SIGB_COMMON1_CH2_RU1		= 0x00ff0000, /* d1 */
400 	IWL_RX_HE_SIGB_COMMON1_CH2_RU3		= 0xff000000, /* d2 */
401 };
402 
403 enum iwl_rx_he_sigb_common2 {
404 	IWL_RX_HE_SIGB_COMMON2_CH1_CTR_RU	= 0x0001,
405 	IWL_RX_HE_SIGB_COMMON2_CH2_CTR_RU	= 0x0002,
406 	IWL_RX_HE_SIGB_COMMON2_CH1_CRC_OK	= 0x0004,
407 	IWL_RX_HE_SIGB_COMMON2_CH2_CRC_OK	= 0x0008,
408 };
409 
410 /**
411  * struct iwl_rx_mpdu_desc_v1 - RX MPDU descriptor
412  */
413 struct iwl_rx_mpdu_desc_v1 {
414 	/* DW7 - carries rss_hash only when rpa_en == 1 */
415 	union {
416 		/**
417 		 * @rss_hash: RSS hash value
418 		 */
419 		__le32 rss_hash;
420 
421 		/**
422 		 * @sigb_common0: for HE sniffer, HE-SIG-B common part 0
423 		 */
424 		__le32 sigb_common0;
425 	};
426 
427 	/* DW8 - carries filter_match only when rpa_en == 1 */
428 	union {
429 		/**
430 		 * @filter_match: filter match value
431 		 */
432 		__le32 filter_match;
433 
434 		/**
435 		 * @sigb_common1: for HE sniffer, HE-SIG-B common part 1
436 		 */
437 		__le32 sigb_common1;
438 	};
439 
440 	/* DW9 */
441 	/**
442 	 * @rate_n_flags: RX rate/flags encoding
443 	 */
444 	__le32 rate_n_flags;
445 	/* DW10 */
446 	/**
447 	 * @energy_a: energy chain A
448 	 */
449 	u8 energy_a;
450 	/**
451 	 * @energy_b: energy chain B
452 	 */
453 	u8 energy_b;
454 	/**
455 	 * @channel: channel number
456 	 */
457 	u8 channel;
458 	/**
459 	 * @mac_context: MAC context mask
460 	 */
461 	u8 mac_context;
462 	/* DW11 */
463 	/**
464 	 * @gp2_on_air_rise: GP2 timer value on air rise (INA)
465 	 */
466 	__le32 gp2_on_air_rise;
467 	/* DW12 & DW13 */
468 	union {
469 		/**
470 		 * @tsf_on_air_rise:
471 		 * TSF value on air rise (INA), only valid if
472 		 * %IWL_RX_MPDU_PHY_TSF_OVERLOAD isn't set
473 		 */
474 		__le64 tsf_on_air_rise;
475 		/**
476 		 * @he_phy_data:
477 		 * HE PHY data, see &enum iwl_rx_he_phy, valid
478 		 * only if %IWL_RX_MPDU_PHY_TSF_OVERLOAD is set
479 		 */
480 		__le64 he_phy_data;
481 	};
482 } __packed;
483 
484 /**
485  * struct iwl_rx_mpdu_desc_v3 - RX MPDU descriptor
486  */
487 struct iwl_rx_mpdu_desc_v3 {
488 	/* DW7 - carries filter_match only when rpa_en == 1 */
489 	union {
490 		/**
491 		 * @filter_match: filter match value
492 		 */
493 		__le32 filter_match;
494 
495 		/**
496 		 * @sigb_common0: for HE sniffer, HE-SIG-B common part 0
497 		 */
498 		__le32 sigb_common0;
499 	};
500 
501 	/* DW8 - carries rss_hash only when rpa_en == 1 */
502 	union {
503 		/**
504 		 * @rss_hash: RSS hash value
505 		 */
506 		__le32 rss_hash;
507 
508 		/**
509 		 * @sigb_common1: for HE sniffer, HE-SIG-B common part 1
510 		 */
511 		__le32 sigb_common1;
512 	};
513 	/* DW9 */
514 	/**
515 	 * @partial_hash: 31:0 ip/tcp header hash
516 	 *	w/o some fields (such as IP SRC addr)
517 	 */
518 	__le32 partial_hash;
519 	/* DW10 */
520 	/**
521 	 * @raw_xsum: raw xsum value
522 	 */
523 	__le32 raw_xsum;
524 	/* DW11 */
525 	/**
526 	 * @rate_n_flags: RX rate/flags encoding
527 	 */
528 	__le32 rate_n_flags;
529 	/* DW12 */
530 	/**
531 	 * @energy_a: energy chain A
532 	 */
533 	u8 energy_a;
534 	/**
535 	 * @energy_b: energy chain B
536 	 */
537 	u8 energy_b;
538 	/**
539 	 * @channel: channel number
540 	 */
541 	u8 channel;
542 	/**
543 	 * @mac_context: MAC context mask
544 	 */
545 	u8 mac_context;
546 	/* DW13 */
547 	/**
548 	 * @gp2_on_air_rise: GP2 timer value on air rise (INA)
549 	 */
550 	__le32 gp2_on_air_rise;
551 	/* DW14 & DW15 */
552 	union {
553 		/**
554 		 * @tsf_on_air_rise:
555 		 * TSF value on air rise (INA), only valid if
556 		 * %IWL_RX_MPDU_PHY_TSF_OVERLOAD isn't set
557 		 */
558 		__le64 tsf_on_air_rise;
559 		/**
560 		 * @he_phy_data:
561 		 * HE PHY data, see &enum iwl_rx_he_phy, valid
562 		 * only if %IWL_RX_MPDU_PHY_TSF_OVERLOAD is set
563 		 */
564 		__le64 he_phy_data;
565 	};
566 	/* DW16 & DW17 */
567 	/**
568 	 * @reserved: reserved
569 	 */
570 	__le32 reserved[2];
571 } __packed; /* RX_MPDU_RES_START_API_S_VER_3 */
572 
573 /**
574  * struct iwl_rx_mpdu_desc - RX MPDU descriptor
575  */
576 struct iwl_rx_mpdu_desc {
577 	/* DW2 */
578 	/**
579 	 * @mpdu_len: MPDU length
580 	 */
581 	__le16 mpdu_len;
582 	/**
583 	 * @mac_flags1: &enum iwl_rx_mpdu_mac_flags1
584 	 */
585 	u8 mac_flags1;
586 	/**
587 	 * @mac_flags2: &enum iwl_rx_mpdu_mac_flags2
588 	 */
589 	u8 mac_flags2;
590 	/* DW3 */
591 	/**
592 	 * @amsdu_info: &enum iwl_rx_mpdu_amsdu_info
593 	 */
594 	u8 amsdu_info;
595 	/**
596 	 * @phy_info: &enum iwl_rx_mpdu_phy_info
597 	 */
598 	__le16 phy_info;
599 	/**
600 	 * @mac_phy_idx: MAC/PHY index
601 	 */
602 	u8 mac_phy_idx;
603 	/* DW4 - carries csum data only when rpa_en == 1 */
604 	/**
605 	 * @raw_csum: raw checksum (alledgedly unreliable)
606 	 */
607 	__le16 raw_csum;
608 
609 	union {
610 		/**
611 		 * @l3l4_flags: &enum iwl_rx_l3l4_flags
612 		 */
613 		__le16 l3l4_flags;
614 
615 		/**
616 		 * @sigb_common2: for HE sniffer, HE-SIG-B common part 2
617 		 */
618 		__le16 sigb_common2;
619 	};
620 	/* DW5 */
621 	/**
622 	 * @status: &enum iwl_rx_mpdu_status
623 	 */
624 	__le16 status;
625 	/**
626 	 * @hash_filter: hash filter value
627 	 */
628 	u8 hash_filter;
629 	/**
630 	 * @sta_id_flags: &enum iwl_rx_mpdu_sta_id_flags
631 	 */
632 	u8 sta_id_flags;
633 	/* DW6 */
634 	/**
635 	 * @reorder_data: &enum iwl_rx_mpdu_reorder_data
636 	 */
637 	__le32 reorder_data;
638 
639 	union {
640 		struct iwl_rx_mpdu_desc_v1 v1;
641 		struct iwl_rx_mpdu_desc_v3 v3;
642 	};
643 } __packed; /* RX_MPDU_RES_START_API_S_VER_3 */
644 
645 #define IWL_RX_DESC_SIZE_V1 offsetofend(struct iwl_rx_mpdu_desc, v1)
646 
647 #define IWL_CD_STTS_OPTIMIZED_POS	0
648 #define IWL_CD_STTS_OPTIMIZED_MSK	0x01
649 #define IWL_CD_STTS_TRANSFER_STATUS_POS	1
650 #define IWL_CD_STTS_TRANSFER_STATUS_MSK	0x0E
651 #define IWL_CD_STTS_WIFI_STATUS_POS	4
652 #define IWL_CD_STTS_WIFI_STATUS_MSK	0xF0
653 
654 /**
655  * enum iwl_completion_desc_transfer_status -  transfer status (bits 1-3)
656  * @IWL_CD_STTS_UNUSED: unused
657  * @IWL_CD_STTS_UNUSED_2: unused
658  * @IWL_CD_STTS_END_TRANSFER: successful transfer complete.
659  *	In sniffer mode, when split is used, set in last CD completion. (RX)
660  * @IWL_CD_STTS_OVERFLOW: In sniffer mode, when using split - used for
661  *	all CD completion. (RX)
662  * @IWL_CD_STTS_ABORTED: CR abort / close flow. (RX)
663  * @IWL_CD_STTS_ERROR: general error (RX)
664  */
665 enum iwl_completion_desc_transfer_status {
666 	IWL_CD_STTS_UNUSED,
667 	IWL_CD_STTS_UNUSED_2,
668 	IWL_CD_STTS_END_TRANSFER,
669 	IWL_CD_STTS_OVERFLOW,
670 	IWL_CD_STTS_ABORTED,
671 	IWL_CD_STTS_ERROR,
672 };
673 
674 /**
675  * enum iwl_completion_desc_wifi_status - wifi status (bits 4-7)
676  * @IWL_CD_STTS_VALID: the packet is valid (RX)
677  * @IWL_CD_STTS_FCS_ERR: frame check sequence error (RX)
678  * @IWL_CD_STTS_SEC_KEY_ERR: error handling the security key of rx (RX)
679  * @IWL_CD_STTS_DECRYPTION_ERR: error decrypting the frame (RX)
680  * @IWL_CD_STTS_DUP: duplicate packet (RX)
681  * @IWL_CD_STTS_ICV_MIC_ERR: MIC error (RX)
682  * @IWL_CD_STTS_INTERNAL_SNAP_ERR: problems removing the snap (RX)
683  * @IWL_CD_STTS_SEC_PORT_FAIL: security port fail (RX)
684  * @IWL_CD_STTS_BA_OLD_SN: block ack received old SN (RX)
685  * @IWL_CD_STTS_QOS_NULL: QoS null packet (RX)
686  * @IWL_CD_STTS_MAC_HDR_ERR: MAC header conversion error (RX)
687  * @IWL_CD_STTS_MAX_RETRANS: reached max number of retransmissions (TX)
688  * @IWL_CD_STTS_EX_LIFETIME: exceeded lifetime (TX)
689  * @IWL_CD_STTS_NOT_USED: completed but not used (RX)
690  * @IWL_CD_STTS_REPLAY_ERR: pn check failed, replay error (RX)
691  */
692 enum iwl_completion_desc_wifi_status {
693 	IWL_CD_STTS_VALID,
694 	IWL_CD_STTS_FCS_ERR,
695 	IWL_CD_STTS_SEC_KEY_ERR,
696 	IWL_CD_STTS_DECRYPTION_ERR,
697 	IWL_CD_STTS_DUP,
698 	IWL_CD_STTS_ICV_MIC_ERR,
699 	IWL_CD_STTS_INTERNAL_SNAP_ERR,
700 	IWL_CD_STTS_SEC_PORT_FAIL,
701 	IWL_CD_STTS_BA_OLD_SN,
702 	IWL_CD_STTS_QOS_NULL,
703 	IWL_CD_STTS_MAC_HDR_ERR,
704 	IWL_CD_STTS_MAX_RETRANS,
705 	IWL_CD_STTS_EX_LIFETIME,
706 	IWL_CD_STTS_NOT_USED,
707 	IWL_CD_STTS_REPLAY_ERR,
708 };
709 
710 struct iwl_frame_release {
711 	u8 baid;
712 	u8 reserved;
713 	__le16 nssn;
714 };
715 
716 enum iwl_rss_hash_func_en {
717 	IWL_RSS_HASH_TYPE_IPV4_TCP,
718 	IWL_RSS_HASH_TYPE_IPV4_UDP,
719 	IWL_RSS_HASH_TYPE_IPV4_PAYLOAD,
720 	IWL_RSS_HASH_TYPE_IPV6_TCP,
721 	IWL_RSS_HASH_TYPE_IPV6_UDP,
722 	IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
723 };
724 
725 #define IWL_RSS_HASH_KEY_CNT 10
726 #define IWL_RSS_INDIRECTION_TABLE_SIZE 128
727 #define IWL_RSS_ENABLE 1
728 
729 /**
730  * struct iwl_rss_config_cmd - RSS (Receive Side Scaling) configuration
731  *
732  * @flags: 1 - enable, 0 - disable
733  * @hash_mask: Type of RSS to use. Values are from %iwl_rss_hash_func_en
734  * @reserved: reserved
735  * @secret_key: 320 bit input of random key configuration from driver
736  * @indirection_table: indirection table
737  */
738 struct iwl_rss_config_cmd {
739 	__le32 flags;
740 	u8 hash_mask;
741 	u8 reserved[3];
742 	__le32 secret_key[IWL_RSS_HASH_KEY_CNT];
743 	u8 indirection_table[IWL_RSS_INDIRECTION_TABLE_SIZE];
744 } __packed; /* RSS_CONFIG_CMD_API_S_VER_1 */
745 
746 #define IWL_MULTI_QUEUE_SYNC_MSG_MAX_SIZE 128
747 #define IWL_MULTI_QUEUE_SYNC_SENDER_POS 0
748 #define IWL_MULTI_QUEUE_SYNC_SENDER_MSK 0xf
749 
750 /**
751  * struct iwl_rxq_sync_cmd - RXQ notification trigger
752  *
753  * @flags: flags of the notification. bit 0:3 are the sender queue
754  * @rxq_mask: rx queues to send the notification on
755  * @count: number of bytes in payload, should be DWORD aligned
756  * @payload: data to send to rx queues
757  */
758 struct iwl_rxq_sync_cmd {
759 	__le32 flags;
760 	__le32 rxq_mask;
761 	__le32 count;
762 	u8 payload[];
763 } __packed; /* MULTI_QUEUE_DRV_SYNC_HDR_CMD_API_S_VER_1 */
764 
765 /**
766  * struct iwl_rxq_sync_notification - Notification triggered by RXQ
767  * sync command
768  *
769  * @count: number of bytes in payload
770  * @payload: data to send to rx queues
771  */
772 struct iwl_rxq_sync_notification {
773 	__le32 count;
774 	u8 payload[];
775 } __packed; /* MULTI_QUEUE_DRV_SYNC_HDR_CMD_API_S_VER_1 */
776 
777 /**
778  * enum iwl_mvm_rxq_notif_type - Internal message identifier
779  *
780  * @IWL_MVM_RXQ_EMPTY: empty sync notification
781  * @IWL_MVM_RXQ_NOTIF_DEL_BA: notify RSS queues of delBA
782  */
783 enum iwl_mvm_rxq_notif_type {
784 	IWL_MVM_RXQ_EMPTY,
785 	IWL_MVM_RXQ_NOTIF_DEL_BA,
786 };
787 
788 /**
789  * struct iwl_mvm_internal_rxq_notif - Internal representation of the data sent
790  * in &iwl_rxq_sync_cmd. Should be DWORD aligned.
791  * FW is agnostic to the payload, so there are no endianity requirements.
792  *
793  * @type: value from &iwl_mvm_rxq_notif_type
794  * @sync: ctrl path is waiting for all notifications to be received
795  * @cookie: internal cookie to identify old notifications
796  * @data: payload
797  */
798 struct iwl_mvm_internal_rxq_notif {
799 	u16 type;
800 	u16 sync;
801 	u32 cookie;
802 	u8 data[];
803 } __packed;
804 
805 /**
806  * enum iwl_mvm_pm_event - type of station PM event
807  * @IWL_MVM_PM_EVENT_AWAKE: station woke up
808  * @IWL_MVM_PM_EVENT_ASLEEP: station went to sleep
809  * @IWL_MVM_PM_EVENT_UAPSD: station sent uAPSD trigger
810  * @IWL_MVM_PM_EVENT_PS_POLL: station sent PS-Poll
811  */
812 enum iwl_mvm_pm_event {
813 	IWL_MVM_PM_EVENT_AWAKE,
814 	IWL_MVM_PM_EVENT_ASLEEP,
815 	IWL_MVM_PM_EVENT_UAPSD,
816 	IWL_MVM_PM_EVENT_PS_POLL,
817 }; /* PEER_PM_NTFY_API_E_VER_1 */
818 
819 /**
820  * struct iwl_mvm_pm_state_notification - station PM state notification
821  * @sta_id: station ID of the station changing state
822  * @type: the new powersave state, see &enum iwl_mvm_pm_event
823  */
824 struct iwl_mvm_pm_state_notification {
825 	u8 sta_id;
826 	u8 type;
827 	/* private: */
828 	__le16 reserved;
829 } __packed; /* PEER_PM_NTFY_API_S_VER_1 */
830 
831 #define BA_WINDOW_STREAMS_MAX		16
832 #define BA_WINDOW_STATUS_TID_MSK	0x000F
833 #define BA_WINDOW_STATUS_STA_ID_POS	4
834 #define BA_WINDOW_STATUS_STA_ID_MSK	0x01F0
835 #define BA_WINDOW_STATUS_VALID_MSK	BIT(9)
836 
837 /**
838  * struct iwl_ba_window_status_notif - reordering window's status notification
839  * @bitmap: bitmap of received frames [start_seq_num + 0]..[start_seq_num + 63]
840  * @ra_tid: bit 3:0 - TID, bit 8:4 - STA_ID, bit 9 - valid
841  * @start_seq_num: the start sequence number of the bitmap
842  * @mpdu_rx_count: the number of received MPDUs since entering D0i3
843  */
844 struct iwl_ba_window_status_notif {
845 	__le64 bitmap[BA_WINDOW_STREAMS_MAX];
846 	__le16 ra_tid[BA_WINDOW_STREAMS_MAX];
847 	__le32 start_seq_num[BA_WINDOW_STREAMS_MAX];
848 	__le16 mpdu_rx_count[BA_WINDOW_STREAMS_MAX];
849 } __packed; /* BA_WINDOW_STATUS_NTFY_API_S_VER_1 */
850 
851 /**
852  * struct iwl_rfh_queue_config - RX queue configuration
853  * @q_num: Q num
854  * @enable: enable queue
855  * @reserved: alignment
856  * @urbd_stts_wrptr: DMA address of urbd_stts_wrptr
857  * @fr_bd_cb: DMA address of freeRB table
858  * @ur_bd_cb: DMA address of used RB table
859  * @fr_bd_wid: Initial index of the free table
860  */
861 struct iwl_rfh_queue_data {
862 	u8 q_num;
863 	u8 enable;
864 	__le16 reserved;
865 	__le64 urbd_stts_wrptr;
866 	__le64 fr_bd_cb;
867 	__le64 ur_bd_cb;
868 	__le32 fr_bd_wid;
869 } __packed; /* RFH_QUEUE_CONFIG_S_VER_1 */
870 
871 /**
872  * struct iwl_rfh_queue_config - RX queue configuration
873  * @num_queues: number of queues configured
874  * @reserved: alignment
875  * @data: DMA addresses per-queue
876  */
877 struct iwl_rfh_queue_config {
878 	u8 num_queues;
879 	u8 reserved[3];
880 	struct iwl_rfh_queue_data data[];
881 } __packed; /* RFH_QUEUE_CONFIG_API_S_VER_1 */
882 
883 #endif /* __iwl_fw_api_rx_h__ */
884