xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h (revision 702648721db590b3425c31ade294000e18808345)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
4  * Copyright (C) 2016-2017 Intel Deutschland GmbH
5  */
6 #ifndef __iwl_fw_api_tx_h__
7 #define __iwl_fw_api_tx_h__
8 #include <linux/ieee80211.h>
9 
10 /**
11  * enum iwl_tx_flags - bitmasks for tx_flags in TX command
12  * @TX_CMD_FLG_PROT_REQUIRE: use RTS or CTS-to-self to protect the frame
13  * @TX_CMD_FLG_WRITE_TX_POWER: update current tx power value in the mgmt frame
14  * @TX_CMD_FLG_ACK: expect ACK from receiving station
15  * @TX_CMD_FLG_STA_RATE: use RS table with initial index from the TX command.
16  *	Otherwise, use rate_n_flags from the TX command
17  * @TX_CMD_FLG_BAR: this frame is a BA request, immediate BAR is expected
18  *	Must set TX_CMD_FLG_ACK with this flag.
19  * @TX_CMD_FLG_TXOP_PROT: TXOP protection requested
20  * @TX_CMD_FLG_VHT_NDPA: mark frame is NDPA for VHT beamformer sequence
21  * @TX_CMD_FLG_HT_NDPA: mark frame is NDPA for HT beamformer sequence
22  * @TX_CMD_FLG_CSI_FDBK2HOST: mark to send feedback to host (only if good CRC)
23  * @TX_CMD_FLG_BT_PRIO_MASK: BT priority value
24  * @TX_CMD_FLG_BT_PRIO_POS: the position of the BT priority (bit 11 is ignored
25  *	on old firmwares).
26  * @TX_CMD_FLG_BT_DIS: disable BT priority for this frame
27  * @TX_CMD_FLG_SEQ_CTL: set if FW should override the sequence control.
28  *	Should be set for mgmt, non-QOS data, mcast, bcast and in scan command
29  * @TX_CMD_FLG_MORE_FRAG: this frame is non-last MPDU
30  * @TX_CMD_FLG_TSF: FW should calculate and insert TSF in the frame
31  *	Should be set for beacons and probe responses
32  * @TX_CMD_FLG_CALIB: activate PA TX power calibrations
33  * @TX_CMD_FLG_KEEP_SEQ_CTL: if seq_ctl is set, don't increase inner seq count
34  * @TX_CMD_FLG_MH_PAD: driver inserted 2 byte padding after MAC header.
35  *	Should be set for 26/30 length MAC headers
36  * @TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW
37  * @TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation
38  * @TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id
39  * @TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped
40  * @TX_CMD_FLG_EXEC_PAPD: execute PAPD
41  * @TX_CMD_FLG_PAPD_TYPE: 0 for reference power, 1 for nominal power
42  * @TX_CMD_FLG_HCCA_CHUNK: mark start of TSPEC chunk
43  */
44 enum iwl_tx_flags {
45 	TX_CMD_FLG_PROT_REQUIRE		= BIT(0),
46 	TX_CMD_FLG_WRITE_TX_POWER	= BIT(1),
47 	TX_CMD_FLG_ACK			= BIT(3),
48 	TX_CMD_FLG_STA_RATE		= BIT(4),
49 	TX_CMD_FLG_BAR			= BIT(6),
50 	TX_CMD_FLG_TXOP_PROT		= BIT(7),
51 	TX_CMD_FLG_VHT_NDPA		= BIT(8),
52 	TX_CMD_FLG_HT_NDPA		= BIT(9),
53 	TX_CMD_FLG_CSI_FDBK2HOST	= BIT(10),
54 	TX_CMD_FLG_BT_PRIO_POS		= 11,
55 	TX_CMD_FLG_BT_PRIO_MASK		= BIT(11) | BIT(12),
56 	TX_CMD_FLG_BT_DIS		= BIT(12),
57 	TX_CMD_FLG_SEQ_CTL		= BIT(13),
58 	TX_CMD_FLG_MORE_FRAG		= BIT(14),
59 	TX_CMD_FLG_TSF			= BIT(16),
60 	TX_CMD_FLG_CALIB		= BIT(17),
61 	TX_CMD_FLG_KEEP_SEQ_CTL		= BIT(18),
62 	TX_CMD_FLG_MH_PAD		= BIT(20),
63 	TX_CMD_FLG_RESP_TO_DRV		= BIT(21),
64 	TX_CMD_FLG_TKIP_MIC_DONE	= BIT(23),
65 	TX_CMD_FLG_DUR			= BIT(25),
66 	TX_CMD_FLG_FW_DROP		= BIT(26),
67 	TX_CMD_FLG_EXEC_PAPD		= BIT(27),
68 	TX_CMD_FLG_PAPD_TYPE		= BIT(28),
69 	TX_CMD_FLG_HCCA_CHUNK		= BIT(31)
70 }; /* TX_FLAGS_BITS_API_S_VER_1 */
71 
72 /**
73  * enum iwl_tx_cmd_flags - bitmasks for tx_flags in TX command for 22000
74  * @IWL_TX_FLAGS_CMD_RATE: use rate from the TX command
75  * @IWL_TX_FLAGS_ENCRYPT_DIS: frame should not be encrypted, even if it belongs
76  *	to a secured STA
77  * @IWL_TX_FLAGS_HIGH_PRI: high priority frame (like EAPOL) - can affect rate
78  *	selection, retry limits and BT kill
79  */
80 enum iwl_tx_cmd_flags {
81 	IWL_TX_FLAGS_CMD_RATE		= BIT(0),
82 	IWL_TX_FLAGS_ENCRYPT_DIS	= BIT(1),
83 	IWL_TX_FLAGS_HIGH_PRI		= BIT(2),
84 	/* Use these flags only from
85 	 * TX_FLAGS_BITS_API_S_VER_4 and above */
86 	IWL_TX_FLAGS_RTS		= BIT(3),
87 	IWL_TX_FLAGS_CTS		= BIT(4),
88 }; /* TX_FLAGS_BITS_API_S_VER_3 */
89 
90 /**
91  * enum iwl_tx_pm_timeouts - pm timeout values in TX command
92  * @PM_FRAME_NONE: no need to suspend sleep mode
93  * @PM_FRAME_MGMT: fw suspend sleep mode for 100TU
94  * @PM_FRAME_ASSOC: fw suspend sleep mode for 10sec
95  */
96 enum iwl_tx_pm_timeouts {
97 	PM_FRAME_NONE		= 0,
98 	PM_FRAME_MGMT		= 2,
99 	PM_FRAME_ASSOC		= 3,
100 };
101 
102 #define TX_CMD_SEC_MSK			0x07
103 #define TX_CMD_SEC_WEP_KEY_IDX_POS	6
104 #define TX_CMD_SEC_WEP_KEY_IDX_MSK	0xc0
105 
106 /**
107  * enum iwl_tx_cmd_sec_ctrl - bitmasks for security control in TX command
108  * @TX_CMD_SEC_WEP: WEP encryption algorithm.
109  * @TX_CMD_SEC_CCM: CCM encryption algorithm.
110  * @TX_CMD_SEC_TKIP: TKIP encryption algorithm.
111  * @TX_CMD_SEC_EXT: extended cipher algorithm.
112  * @TX_CMD_SEC_GCMP: GCMP encryption algorithm.
113  * @TX_CMD_SEC_KEY128: set for 104 bits WEP key.
114  * @TX_CMD_SEC_KEY_FROM_TABLE: for a non-WEP key, set if the key should be taken
115  *	from the table instead of from the TX command.
116  *	If the key is taken from the key table its index should be given by the
117  *	first byte of the TX command key field.
118  */
119 enum iwl_tx_cmd_sec_ctrl {
120 	TX_CMD_SEC_WEP			= 0x01,
121 	TX_CMD_SEC_CCM			= 0x02,
122 	TX_CMD_SEC_TKIP			= 0x03,
123 	TX_CMD_SEC_EXT			= 0x04,
124 	TX_CMD_SEC_GCMP			= 0x05,
125 	TX_CMD_SEC_KEY128		= 0x08,
126 	TX_CMD_SEC_KEY_FROM_TABLE	= 0x10,
127 };
128 
129 /*
130  * TX command Frame life time in us - to be written in pm_frame_timeout
131  */
132 #define TX_CMD_LIFE_TIME_INFINITE	0xFFFFFFFF
133 #define TX_CMD_LIFE_TIME_DEFAULT	2000000 /* 2000 ms*/
134 #define TX_CMD_LIFE_TIME_PROBE_RESP	40000 /* 40 ms */
135 #define TX_CMD_LIFE_TIME_EXPIRED_FRAME	0
136 
137 /*
138  * TID for non QoS frames - to be written in tid_tspec
139  */
140 #define IWL_TID_NON_QOS	0
141 
142 /*
143  * Limits on the retransmissions - to be written in {data,rts}_retry_limit
144  */
145 #define IWL_DEFAULT_TX_RETRY			15
146 #define IWL_MGMT_DFAULT_RETRY_LIMIT		3
147 #define IWL_RTS_DFAULT_RETRY_LIMIT		60
148 #define IWL_BAR_DFAULT_RETRY_LIMIT		60
149 #define IWL_LOW_RETRY_LIMIT			7
150 
151 /**
152  * enum iwl_tx_offload_assist_flags_pos -  set %iwl_tx_cmd offload_assist values
153  * @TX_CMD_OFFLD_IP_HDR: offset to start of IP header (in words)
154  *	from mac header end. For normal case it is 4 words for SNAP.
155  *	note: tx_cmd, mac header and pad are not counted in the offset.
156  *	This is used to help the offload in case there is tunneling such as
157  *	IPv6 in IPv4, in such case the ip header offset should point to the
158  *	inner ip header and IPv4 checksum of the external header should be
159  *	calculated by driver.
160  * @TX_CMD_OFFLD_L4_EN: enable TCP/UDP checksum
161  * @TX_CMD_OFFLD_L3_EN: enable IP header checksum
162  * @TX_CMD_OFFLD_MH_SIZE: size of the mac header in words. Includes the IV
163  *	field. Doesn't include the pad.
164  * @TX_CMD_OFFLD_PAD: mark 2-byte pad was inserted after the mac header for
165  *	alignment
166  * @TX_CMD_OFFLD_AMSDU: mark TX command is A-MSDU
167  */
168 enum iwl_tx_offload_assist_flags_pos {
169 	TX_CMD_OFFLD_IP_HDR =		0,
170 	TX_CMD_OFFLD_L4_EN =		6,
171 	TX_CMD_OFFLD_L3_EN =		7,
172 	TX_CMD_OFFLD_MH_SIZE =		8,
173 	TX_CMD_OFFLD_PAD =		13,
174 	TX_CMD_OFFLD_AMSDU =		14,
175 };
176 
177 #define IWL_TX_CMD_OFFLD_MH_MASK	0x1f
178 #define IWL_TX_CMD_OFFLD_IP_HDR_MASK	0x3f
179 
180 enum iwl_tx_offload_assist_bz {
181 	IWL_TX_CMD_OFFLD_BZ_RESULT_OFFS		= 0x000003ff,
182 	IWL_TX_CMD_OFFLD_BZ_START_OFFS		= 0x001ff800,
183 	IWL_TX_CMD_OFFLD_BZ_MH_LEN		= 0x07c00000,
184 	IWL_TX_CMD_OFFLD_BZ_MH_PAD		= 0x08000000,
185 	IWL_TX_CMD_OFFLD_BZ_AMSDU		= 0x10000000,
186 	IWL_TX_CMD_OFFLD_BZ_ZERO2ONES		= 0x20000000,
187 	IWL_TX_CMD_OFFLD_BZ_ENABLE_CSUM		= 0x40000000,
188 	IWL_TX_CMD_OFFLD_BZ_PARTIAL_CSUM	= 0x80000000,
189 };
190 
191 /* TODO: complete documentation for try_cnt and btkill_cnt */
192 /**
193  * struct iwl_tx_cmd - TX command struct to FW
194  * ( TX_CMD = 0x1c )
195  * @len: in bytes of the payload, see below for details
196  * @offload_assist: TX offload configuration
197  * @tx_flags: combination of TX_CMD_FLG_*, see &enum iwl_tx_flags
198  * @scratch: scratch buffer used by the device
199  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
200  *	cleared. Combination of RATE_MCS_*
201  * @sta_id: index of destination station in FW station table
202  * @sec_ctl: security control, TX_CMD_SEC_*
203  * @initial_rate_index: index into the the rate table for initial TX attempt.
204  *	Applied if TX_CMD_FLG_STA_RATE_MSK is set, normally 0 for data frames.
205  * @reserved2: reserved
206  * @key: security key
207  * @reserved3: reserved
208  * @life_time: frame life time (usecs??)
209  * @dram_lsb_ptr: Physical address of scratch area in the command (try_cnt +
210  *	btkill_cnd + reserved), first 32 bits. "0" disables usage.
211  * @dram_msb_ptr: upper bits of the scratch physical address
212  * @rts_retry_limit: max attempts for RTS
213  * @data_retry_limit: max attempts to send the data packet
214  * @tid_tspec: TID/tspec
215  * @pm_frame_timeout: PM TX frame timeout
216  * @reserved4: reserved
217  * @payload: payload (same as @hdr)
218  * @hdr: 802.11 header (same as @payload)
219  *
220  * The byte count (both len and next_frame_len) includes MAC header
221  * (24/26/30/32 bytes)
222  * + 2 bytes pad if 26/30 header size
223  * + 8 byte IV for CCM or TKIP (not used for WEP)
224  * + Data payload
225  * + 8-byte MIC (not used for CCM/WEP)
226  * It does not include post-MAC padding, i.e.,
227  * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.
228  * Range of len: 14-2342 bytes.
229  *
230  * After the struct fields the MAC header is placed, plus any padding,
231  * and then the actial payload.
232  */
233 struct iwl_tx_cmd {
234 	__le16 len;
235 	__le16 offload_assist;
236 	__le32 tx_flags;
237 	struct {
238 		u8 try_cnt;
239 		u8 btkill_cnt;
240 		__le16 reserved;
241 	} scratch; /* DRAM_SCRATCH_API_U_VER_1 */
242 	__le32 rate_n_flags;
243 	u8 sta_id;
244 	u8 sec_ctl;
245 	u8 initial_rate_index;
246 	u8 reserved2;
247 	u8 key[16];
248 	__le32 reserved3;
249 	__le32 life_time;
250 	__le32 dram_lsb_ptr;
251 	u8 dram_msb_ptr;
252 	u8 rts_retry_limit;
253 	u8 data_retry_limit;
254 	u8 tid_tspec;
255 	__le16 pm_frame_timeout;
256 	__le16 reserved4;
257 	union {
258 		DECLARE_FLEX_ARRAY(u8, payload);
259 		DECLARE_FLEX_ARRAY(struct ieee80211_hdr, hdr);
260 	};
261 } __packed; /* TX_CMD_API_S_VER_6 */
262 
263 struct iwl_dram_sec_info {
264 	__le32 pn_low;
265 	__le16 pn_high;
266 	__le16 aux_info;
267 } __packed; /* DRAM_SEC_INFO_API_S_VER_1 */
268 
269 /**
270  * struct iwl_tx_cmd_gen2 - TX command struct to FW for 22000 devices
271  * ( TX_CMD = 0x1c )
272  * @len: in bytes of the payload, see below for details
273  * @offload_assist: TX offload configuration
274  * @flags: combination of &enum iwl_tx_cmd_flags
275  * @dram_info: FW internal DRAM storage
276  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
277  *	cleared. Combination of RATE_MCS_*
278  * @hdr: 802.11 header
279  */
280 struct iwl_tx_cmd_gen2 {
281 	__le16 len;
282 	__le16 offload_assist;
283 	__le32 flags;
284 	struct iwl_dram_sec_info dram_info;
285 	__le32 rate_n_flags;
286 	struct ieee80211_hdr hdr[];
287 } __packed; /* TX_CMD_API_S_VER_7,
288 	       TX_CMD_API_S_VER_9 */
289 
290 /**
291  * struct iwl_tx_cmd_gen3 - TX command struct to FW for AX210+ devices
292  * ( TX_CMD = 0x1c )
293  * @len: in bytes of the payload, see below for details
294  * @flags: combination of &enum iwl_tx_cmd_flags
295  * @offload_assist: TX offload configuration
296  * @dram_info: FW internal DRAM storage
297  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
298  *	cleared. Combination of RATE_MCS_*
299  * @reserved: reserved
300  * @hdr: 802.11 header
301  */
302 struct iwl_tx_cmd_gen3 {
303 	__le16 len;
304 	__le16 flags;
305 	__le32 offload_assist;
306 	struct iwl_dram_sec_info dram_info;
307 	__le32 rate_n_flags;
308 	u8 reserved[8];
309 	struct ieee80211_hdr hdr[];
310 } __packed; /* TX_CMD_API_S_VER_8,
311 	       TX_CMD_API_S_VER_10 */
312 
313 /*
314  * TX response related data
315  */
316 
317 /*
318  * enum iwl_tx_status - status that is returned by the fw after attempts to Tx
319  * @TX_STATUS_SUCCESS:
320  * @TX_STATUS_DIRECT_DONE:
321  * @TX_STATUS_POSTPONE_DELAY:
322  * @TX_STATUS_POSTPONE_FEW_BYTES:
323  * @TX_STATUS_POSTPONE_BT_PRIO:
324  * @TX_STATUS_POSTPONE_QUIET_PERIOD:
325  * @TX_STATUS_POSTPONE_CALC_TTAK:
326  * @TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY:
327  * @TX_STATUS_FAIL_SHORT_LIMIT:
328  * @TX_STATUS_FAIL_LONG_LIMIT:
329  * @TX_STATUS_FAIL_UNDERRUN:
330  * @TX_STATUS_FAIL_DRAIN_FLOW:
331  * @TX_STATUS_FAIL_RFKILL_FLUSH:
332  * @TX_STATUS_FAIL_LIFE_EXPIRE:
333  * @TX_STATUS_FAIL_DEST_PS:
334  * @TX_STATUS_FAIL_HOST_ABORTED:
335  * @TX_STATUS_FAIL_BT_RETRY:
336  * @TX_STATUS_FAIL_STA_INVALID:
337  * @TX_TATUS_FAIL_FRAG_DROPPED:
338  * @TX_STATUS_FAIL_TID_DISABLE:
339  * @TX_STATUS_FAIL_FIFO_FLUSHED:
340  * @TX_STATUS_FAIL_SMALL_CF_POLL:
341  * @TX_STATUS_FAIL_FW_DROP:
342  * @TX_STATUS_FAIL_STA_COLOR_MISMATCH: mismatch between color of Tx cmd and
343  *	STA table
344  * @TX_FRAME_STATUS_INTERNAL_ABORT:
345  * @TX_MODE_MSK:
346  * @TX_MODE_NO_BURST:
347  * @TX_MODE_IN_BURST_SEQ:
348  * @TX_MODE_FIRST_IN_BURST:
349  * @TX_QUEUE_NUM_MSK:
350  *
351  * Valid only if frame_count =1
352  * TODO: complete documentation
353  */
354 enum iwl_tx_status {
355 	TX_STATUS_MSK = 0x000000ff,
356 	TX_STATUS_SUCCESS = 0x01,
357 	TX_STATUS_DIRECT_DONE = 0x02,
358 	/* postpone TX */
359 	TX_STATUS_POSTPONE_DELAY = 0x40,
360 	TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
361 	TX_STATUS_POSTPONE_BT_PRIO = 0x42,
362 	TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
363 	TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
364 	/* abort TX */
365 	TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
366 	TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
367 	TX_STATUS_FAIL_LONG_LIMIT = 0x83,
368 	TX_STATUS_FAIL_UNDERRUN = 0x84,
369 	TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
370 	TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
371 	TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
372 	TX_STATUS_FAIL_DEST_PS = 0x88,
373 	TX_STATUS_FAIL_HOST_ABORTED = 0x89,
374 	TX_STATUS_FAIL_BT_RETRY = 0x8a,
375 	TX_STATUS_FAIL_STA_INVALID = 0x8b,
376 	TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
377 	TX_STATUS_FAIL_TID_DISABLE = 0x8d,
378 	TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
379 	TX_STATUS_FAIL_SMALL_CF_POLL = 0x8f,
380 	TX_STATUS_FAIL_FW_DROP = 0x90,
381 	TX_STATUS_FAIL_STA_COLOR_MISMATCH = 0x91,
382 	TX_STATUS_INTERNAL_ABORT = 0x92,
383 	TX_MODE_MSK = 0x00000f00,
384 	TX_MODE_NO_BURST = 0x00000000,
385 	TX_MODE_IN_BURST_SEQ = 0x00000100,
386 	TX_MODE_FIRST_IN_BURST = 0x00000200,
387 	TX_QUEUE_NUM_MSK = 0x0001f000,
388 	TX_NARROW_BW_MSK = 0x00060000,
389 	TX_NARROW_BW_1DIV2 = 0x00020000,
390 	TX_NARROW_BW_1DIV4 = 0x00040000,
391 	TX_NARROW_BW_1DIV8 = 0x00060000,
392 };
393 
394 /*
395  * enum iwl_tx_agg_status - TX aggregation status
396  * @AGG_TX_STATE_STATUS_MSK:
397  * @AGG_TX_STATE_TRANSMITTED:
398  * @AGG_TX_STATE_UNDERRUN:
399  * @AGG_TX_STATE_BT_PRIO:
400  * @AGG_TX_STATE_FEW_BYTES:
401  * @AGG_TX_STATE_ABORT:
402  * @AGG_TX_STATE_TX_ON_AIR_DROP: TX_ON_AIR signal drop without underrun or
403  *	BT detection
404  * @AGG_TX_STATE_LAST_SENT_TRY_CNT:
405  * @AGG_TX_STATE_LAST_SENT_BT_KILL:
406  * @AGG_TX_STATE_SCD_QUERY:
407  * @AGG_TX_STATE_TEST_BAD_CRC32:
408  * @AGG_TX_STATE_RESPONSE:
409  * @AGG_TX_STATE_DUMP_TX:
410  * @AGG_TX_STATE_DELAY_TX:
411  * @AGG_TX_STATE_TRY_CNT_MSK: Retry count for 1st frame in aggregation (retries
412  *	occur if tx failed for this frame when it was a member of a previous
413  *	aggregation block). If rate scaling is used, retry count indicates the
414  *	rate table entry used for all frames in the new agg.
415  * @AGG_TX_STATE_SEQ_NUM_MSK: Command ID and sequence number of Tx command for
416  *	this frame
417  *
418  * TODO: complete documentation
419  */
420 enum iwl_tx_agg_status {
421 	AGG_TX_STATE_STATUS_MSK = 0x00fff,
422 	AGG_TX_STATE_TRANSMITTED = 0x000,
423 	AGG_TX_STATE_UNDERRUN = 0x001,
424 	AGG_TX_STATE_BT_PRIO = 0x002,
425 	AGG_TX_STATE_FEW_BYTES = 0x004,
426 	AGG_TX_STATE_ABORT = 0x008,
427 	AGG_TX_STATE_TX_ON_AIR_DROP = 0x010,
428 	AGG_TX_STATE_LAST_SENT_TRY_CNT = 0x020,
429 	AGG_TX_STATE_LAST_SENT_BT_KILL = 0x040,
430 	AGG_TX_STATE_SCD_QUERY = 0x080,
431 	AGG_TX_STATE_TEST_BAD_CRC32 = 0x0100,
432 	AGG_TX_STATE_RESPONSE = 0x1ff,
433 	AGG_TX_STATE_DUMP_TX = 0x200,
434 	AGG_TX_STATE_DELAY_TX = 0x400,
435 	AGG_TX_STATE_TRY_CNT_POS = 12,
436 	AGG_TX_STATE_TRY_CNT_MSK = 0xf << AGG_TX_STATE_TRY_CNT_POS,
437 };
438 
439 /*
440  * The mask below describes a status where we are absolutely sure that the MPDU
441  * wasn't sent. For BA/Underrun we cannot be that sure. All we know that we've
442  * written the bytes to the TXE, but we know nothing about what the DSP did.
443  */
444 #define AGG_TX_STAT_FRAME_NOT_SENT (AGG_TX_STATE_FEW_BYTES | \
445 				    AGG_TX_STATE_ABORT | \
446 				    AGG_TX_STATE_SCD_QUERY)
447 
448 /*
449  * REPLY_TX = 0x1c (response)
450  *
451  * This response may be in one of two slightly different formats, indicated
452  * by the frame_count field:
453  *
454  * 1)	No aggregation (frame_count == 1).  This reports Tx results for a single
455  *	frame. Multiple attempts, at various bit rates, may have been made for
456  *	this frame.
457  *
458  * 2)	Aggregation (frame_count > 1).  This reports Tx results for two or more
459  *	frames that used block-acknowledge.  All frames were transmitted at
460  *	same rate. Rate scaling may have been used if first frame in this new
461  *	agg block failed in previous agg block(s).
462  *
463  *	Note that, for aggregation, ACK (block-ack) status is not delivered
464  *	here; block-ack has not been received by the time the device records
465  *	this status.
466  *	This status relates to reasons the tx might have been blocked or aborted
467  *	within the device, rather than whether it was received successfully by
468  *	the destination station.
469  */
470 
471 /**
472  * struct agg_tx_status - per packet TX aggregation status
473  * @status: See &enum iwl_tx_agg_status
474  * @sequence: Sequence # for this frame's Tx cmd (not SSN!)
475  */
476 struct agg_tx_status {
477 	__le16 status;
478 	__le16 sequence;
479 } __packed;
480 
481 /*
482  * definitions for initial rate index field
483  * bits [3:0] initial rate index
484  * bits [6:4] rate table color, used for the initial rate
485  * bit-7 invalid rate indication
486  */
487 #define TX_RES_INIT_RATE_INDEX_MSK 0x0f
488 #define TX_RES_RATE_TABLE_COLOR_POS 4
489 #define TX_RES_RATE_TABLE_COLOR_MSK 0x70
490 #define TX_RES_INV_RATE_INDEX_MSK 0x80
491 #define TX_RES_RATE_TABLE_COL_GET(_f) (((_f) & TX_RES_RATE_TABLE_COLOR_MSK) >>\
492 				       TX_RES_RATE_TABLE_COLOR_POS)
493 
494 #define IWL_MVM_TX_RES_GET_TID(_ra_tid) ((_ra_tid) & 0x0f)
495 #define IWL_MVM_TX_RES_GET_RA(_ra_tid) ((_ra_tid) >> 4)
496 
497 /**
498  * struct iwl_mvm_tx_resp_v3 - notifies that fw is TXing a packet
499  * ( REPLY_TX = 0x1c )
500  * @frame_count: 1 no aggregation, >1 aggregation
501  * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
502  * @failure_rts: num of failures due to unsuccessful RTS
503  * @failure_frame: num failures due to no ACK (unused for agg)
504  * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
505  *	Tx of all the batch. RATE_MCS_*
506  * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
507  *	for agg: RTS + CTS + aggregation tx time + block-ack time.
508  *	in usec.
509  * @pa_status: tx power info
510  * @pa_integ_res_a: tx power info
511  * @pa_integ_res_b: tx power info
512  * @pa_integ_res_c: tx power info
513  * @measurement_req_id: tx power info
514  * @reduced_tpc: transmit power reduction used
515  * @reserved: reserved
516  * @tfd_info: TFD information set by the FH
517  * @seq_ctl: sequence control from the Tx cmd
518  * @byte_cnt: byte count from the Tx cmd
519  * @tlc_info: TLC rate info
520  * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
521  * @frame_ctrl: frame control
522  * @status: for non-agg:  frame status TX_STATUS_*
523  *	for agg: status of 1st frame, AGG_TX_STATE_*; other frame status fields
524  *	follow this one, up to frame_count. Length in @frame_count.
525  *
526  * After the array of statuses comes the SSN of the SCD. Look at
527  * %iwl_mvm_get_scd_ssn for more details.
528  */
529 struct iwl_mvm_tx_resp_v3 {
530 	u8 frame_count;
531 	u8 bt_kill_count;
532 	u8 failure_rts;
533 	u8 failure_frame;
534 	__le32 initial_rate;
535 	__le16 wireless_media_time;
536 
537 	u8 pa_status;
538 	u8 pa_integ_res_a[3];
539 	u8 pa_integ_res_b[3];
540 	u8 pa_integ_res_c[3];
541 	__le16 measurement_req_id;
542 	u8 reduced_tpc;
543 	u8 reserved;
544 
545 	__le32 tfd_info;
546 	__le16 seq_ctl;
547 	__le16 byte_cnt;
548 	u8 tlc_info;
549 	u8 ra_tid;
550 	__le16 frame_ctrl;
551 	struct agg_tx_status status[];
552 } __packed; /* TX_RSP_API_S_VER_3 */
553 
554 /**
555  * struct iwl_mvm_tx_resp - notifies that fw is TXing a packet
556  * ( REPLY_TX = 0x1c )
557  * @frame_count: 1 no aggregation, >1 aggregation
558  * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
559  * @failure_rts: num of failures due to unsuccessful RTS
560  * @failure_frame: num failures due to no ACK (unused for agg)
561  * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
562  *	Tx of all the batch. RATE_MCS_*
563  * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
564  *	for agg: RTS + CTS + aggregation tx time + block-ack time.
565  *	in usec.
566  * @pa_status: tx power info
567  * @pa_integ_res_a: tx power info
568  * @pa_integ_res_b: tx power info
569  * @pa_integ_res_c: tx power info
570  * @measurement_req_id: tx power info
571  * @reduced_tpc: transmit power reduction used
572  * @reserved: reserved
573  * @tfd_info: TFD information set by the FH
574  * @seq_ctl: sequence control from the Tx cmd
575  * @byte_cnt: byte count from the Tx cmd
576  * @tlc_info: TLC rate info
577  * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
578  * @frame_ctrl: frame control
579  * @tx_queue: TX queue for this response
580  * @reserved2: reserved for padding/alignment
581  * @status: for non-agg:  frame status TX_STATUS_*
582  *	For version 6 TX response isn't received for aggregation at all.
583  *
584  * After the array of statuses comes the SSN of the SCD. Look at
585  * %iwl_mvm_get_scd_ssn for more details.
586  */
587 struct iwl_mvm_tx_resp {
588 	u8 frame_count;
589 	u8 bt_kill_count;
590 	u8 failure_rts;
591 	u8 failure_frame;
592 	__le32 initial_rate;
593 	__le16 wireless_media_time;
594 
595 	u8 pa_status;
596 	u8 pa_integ_res_a[3];
597 	u8 pa_integ_res_b[3];
598 	u8 pa_integ_res_c[3];
599 	__le16 measurement_req_id;
600 	u8 reduced_tpc;
601 	u8 reserved;
602 
603 	__le32 tfd_info;
604 	__le16 seq_ctl;
605 	__le16 byte_cnt;
606 	u8 tlc_info;
607 	u8 ra_tid;
608 	__le16 frame_ctrl;
609 	__le16 tx_queue;
610 	__le16 reserved2;
611 	struct agg_tx_status status;
612 } __packed; /* TX_RSP_API_S_VER_6,
613 	       TX_RSP_API_S_VER_7 */
614 
615 /**
616  * struct iwl_mvm_ba_notif - notifies about reception of BA
617  * ( BA_NOTIF = 0xc5 )
618  * @sta_addr: MAC address
619  * @reserved: reserved
620  * @sta_id: Index of recipient (BA-sending) station in fw's station table
621  * @tid: tid of the session
622  * @seq_ctl: sequence control field
623  * @bitmap: the bitmap of the BA notification as seen in the air
624  * @scd_flow: the tx queue this BA relates to
625  * @scd_ssn: the index of the last contiguously sent packet
626  * @txed: number of Txed frames in this batch
627  * @txed_2_done: number of Acked frames in this batch
628  * @reduced_txp: power reduced according to TPC. This is the actual value and
629  *	not a copy from the LQ command. Thus, if not the first rate was used
630  *	for Tx-ing then this value will be set to 0 by FW.
631  * @reserved1: reserved
632  */
633 struct iwl_mvm_ba_notif {
634 	u8 sta_addr[ETH_ALEN];
635 	__le16 reserved;
636 
637 	u8 sta_id;
638 	u8 tid;
639 	__le16 seq_ctl;
640 	__le64 bitmap;
641 	__le16 scd_flow;
642 	__le16 scd_ssn;
643 	u8 txed;
644 	u8 txed_2_done;
645 	u8 reduced_txp;
646 	u8 reserved1;
647 } __packed;
648 
649 /**
650  * struct iwl_mvm_compressed_ba_tfd - progress of a TFD queue
651  * @q_num: TFD queue number
652  * @tfd_index: Index of first un-acked frame in the  TFD queue
653  * @scd_queue: For debug only - the physical queue the TFD queue is bound to
654  * @tid: TID of the queue (0-7)
655  * @reserved: reserved for alignment
656  */
657 struct iwl_mvm_compressed_ba_tfd {
658 	__le16 q_num;
659 	__le16 tfd_index;
660 	u8 scd_queue;
661 	u8 tid;
662 	u8 reserved[2];
663 } __packed; /* COMPRESSED_BA_TFD_API_S_VER_1 */
664 
665 /**
666  * struct iwl_mvm_compressed_ba_ratid - progress of a RA TID queue
667  * @q_num: RA TID queue number
668  * @tid: TID of the queue
669  * @ssn: BA window current SSN
670  */
671 struct iwl_mvm_compressed_ba_ratid {
672 	u8 q_num;
673 	u8 tid;
674 	__le16 ssn;
675 } __packed; /* COMPRESSED_BA_RATID_API_S_VER_1 */
676 
677 /*
678  * enum iwl_mvm_ba_resp_flags - TX aggregation status
679  * @IWL_MVM_BA_RESP_TX_AGG: generated due to BA
680  * @IWL_MVM_BA_RESP_TX_BAR: generated due to BA after BAR
681  * @IWL_MVM_BA_RESP_TX_AGG_FAIL: aggregation didn't receive BA
682  * @IWL_MVM_BA_RESP_TX_UNDERRUN: aggregation got underrun
683  * @IWL_MVM_BA_RESP_TX_BT_KILL: aggregation got BT-kill
684  * @IWL_MVM_BA_RESP_TX_DSP_TIMEOUT: aggregation didn't finish within the
685  *	expected time
686  */
687 enum iwl_mvm_ba_resp_flags {
688 	IWL_MVM_BA_RESP_TX_AGG,
689 	IWL_MVM_BA_RESP_TX_BAR,
690 	IWL_MVM_BA_RESP_TX_AGG_FAIL,
691 	IWL_MVM_BA_RESP_TX_UNDERRUN,
692 	IWL_MVM_BA_RESP_TX_BT_KILL,
693 	IWL_MVM_BA_RESP_TX_DSP_TIMEOUT
694 };
695 
696 /**
697  * struct iwl_mvm_compressed_ba_notif - notifies about reception of BA
698  * ( BA_NOTIF = 0xc5 )
699  * @flags: status flag, see the &iwl_mvm_ba_resp_flags
700  * @sta_id: Index of recipient (BA-sending) station in fw's station table
701  * @reduced_txp: power reduced according to TPC. This is the actual value and
702  *	not a copy from the LQ command. Thus, if not the first rate was used
703  *	for Tx-ing then this value will be set to 0 by FW.
704  * @tlc_rate_info: TLC rate info, initial rate index, TLC table color
705  * @retry_cnt: retry count
706  * @query_byte_cnt: SCD query byte count
707  * @query_frame_cnt: SCD query frame count
708  * @txed: number of frames sent in the aggregation (all-TIDs)
709  * @done: number of frames that were Acked by the BA (all-TIDs)
710  * @reserved: reserved (for alignment)
711  * @wireless_time: Wireless-media time
712  * @tx_rate: the rate the aggregation was sent at
713  * @tfd_cnt: number of TFD-Q elements
714  * @ra_tid_cnt: number of RATID-Q elements
715  * @tfd: array of TFD queue status updates. See &iwl_mvm_compressed_ba_tfd
716  *	for details. Length in @tfd_cnt.
717  * @ra_tid: array of RA-TID queue status updates. For debug purposes only. See
718  *	&iwl_mvm_compressed_ba_ratid for more details. Length in @ra_tid_cnt.
719  */
720 struct iwl_mvm_compressed_ba_notif {
721 	__le32 flags;
722 	u8 sta_id;
723 	u8 reduced_txp;
724 	u8 tlc_rate_info;
725 	u8 retry_cnt;
726 	__le32 query_byte_cnt;
727 	__le16 query_frame_cnt;
728 	__le16 txed;
729 	__le16 done;
730 	__le16 reserved;
731 	__le32 wireless_time;
732 	__le32 tx_rate;
733 	__le16 tfd_cnt;
734 	__le16 ra_tid_cnt;
735 	union {
736 		DECLARE_FLEX_ARRAY(struct iwl_mvm_compressed_ba_ratid, ra_tid);
737 		DECLARE_FLEX_ARRAY(struct iwl_mvm_compressed_ba_tfd, tfd);
738 	};
739 } __packed; /* COMPRESSED_BA_RES_API_S_VER_4,
740 	       COMPRESSED_BA_RES_API_S_VER_5 */
741 
742 /**
743  * struct iwl_mac_beacon_cmd_v6 - beacon template command
744  * @tx: the tx commands associated with the beacon frame
745  * @template_id: currently equal to the mac context id of the coresponding
746  *  mac.
747  * @tim_idx: the offset of the tim IE in the beacon
748  * @tim_size: the length of the tim IE
749  * @frame: the template of the beacon frame
750  */
751 struct iwl_mac_beacon_cmd_v6 {
752 	struct iwl_tx_cmd tx;
753 	__le32 template_id;
754 	__le32 tim_idx;
755 	__le32 tim_size;
756 	struct ieee80211_hdr frame[];
757 } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_6 */
758 
759 /**
760  * struct iwl_mac_beacon_cmd_v7 - beacon template command with offloaded CSA
761  * @tx: the tx commands associated with the beacon frame
762  * @template_id: currently equal to the mac context id of the coresponding
763  *  mac.
764  * @tim_idx: the offset of the tim IE in the beacon
765  * @tim_size: the length of the tim IE
766  * @ecsa_offset: offset to the ECSA IE if present
767  * @csa_offset: offset to the CSA IE if present
768  * @frame: the template of the beacon frame
769  */
770 struct iwl_mac_beacon_cmd_v7 {
771 	struct iwl_tx_cmd tx;
772 	__le32 template_id;
773 	__le32 tim_idx;
774 	__le32 tim_size;
775 	__le32 ecsa_offset;
776 	__le32 csa_offset;
777 	struct ieee80211_hdr frame[];
778 } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_7 */
779 
780 /* Bit flags for BEACON_TEMPLATE_CMD_API until version 10 */
781 enum iwl_mac_beacon_flags_v1 {
782 	IWL_MAC_BEACON_CCK_V1	= BIT(8),
783 	IWL_MAC_BEACON_ANT_A_V1 = BIT(9),
784 	IWL_MAC_BEACON_ANT_B_V1 = BIT(10),
785 	IWL_MAC_BEACON_FILS_V1	= BIT(12),
786 };
787 
788 /* Bit flags for BEACON_TEMPLATE_CMD_API version 11 and above */
789 enum iwl_mac_beacon_flags {
790 	IWL_MAC_BEACON_CCK	= BIT(5),
791 	IWL_MAC_BEACON_ANT_A	= BIT(6),
792 	IWL_MAC_BEACON_ANT_B	= BIT(7),
793 	IWL_MAC_BEACON_FILS	= BIT(8),
794 };
795 
796 /**
797  * struct iwl_mac_beacon_cmd - beacon template command with offloaded CSA
798  * @byte_cnt: byte count of the beacon frame.
799  * @flags: least significant byte for rate code. The most significant byte
800  *	is &enum iwl_mac_beacon_flags.
801  * @short_ssid: Short SSID
802  * @reserved: reserved
803  * @link_id: the firmware id of the link that will use this beacon
804  * @tim_idx: the offset of the tim IE in the beacon
805  * @tim_size: the length of the tim IE
806  * @ecsa_offset: offset to the ECSA IE if present
807  * @csa_offset: offset to the CSA IE if present
808  * @frame: the template of the beacon frame
809  */
810 struct iwl_mac_beacon_cmd {
811 	__le16 byte_cnt;
812 	__le16 flags;
813 	__le32 short_ssid;
814 	__le32 reserved;
815 	__le32 link_id;
816 	__le32 tim_idx;
817 	__le32 tim_size;
818 	__le32 ecsa_offset;
819 	__le32 csa_offset;
820 	struct ieee80211_hdr frame[];
821 } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_10,
822 	     * BEACON_TEMPLATE_CMD_API_S_VER_11,
823 	     * BEACON_TEMPLATE_CMD_API_S_VER_12,
824 	     * BEACON_TEMPLATE_CMD_API_S_VER_13
825 	     */
826 
827 struct iwl_beacon_notif {
828 	struct iwl_mvm_tx_resp beacon_notify_hdr;
829 	__le64 tsf;
830 	__le32 ibss_mgr_status;
831 } __packed;
832 
833 /**
834  * struct iwl_extended_beacon_notif_v5 - notifies about beacon transmission
835  * @beacon_notify_hdr: tx response command associated with the beacon
836  * @tsf: last beacon tsf
837  * @ibss_mgr_status: whether IBSS is manager
838  * @gp2: last beacon time in gp2
839  */
840 struct iwl_extended_beacon_notif_v5 {
841 	struct iwl_mvm_tx_resp beacon_notify_hdr;
842 	__le64 tsf;
843 	__le32 ibss_mgr_status;
844 	__le32 gp2;
845 } __packed; /* BEACON_NTFY_API_S_VER_5 */
846 
847 /**
848  * struct iwl_extended_beacon_notif - notifies about beacon transmission
849  * @status: the status of the Tx response of the beacon
850  * @tsf: last beacon tsf
851  * @ibss_mgr_status: whether IBSS is manager
852  * @gp2: last beacon time in gp2
853  */
854 struct iwl_extended_beacon_notif {
855 	__le32 status;
856 	__le64 tsf;
857 	__le32 ibss_mgr_status;
858 	__le32 gp2;
859 } __packed; /* BEACON_NTFY_API_S_VER_6_ */
860 
861 /**
862  * enum iwl_dump_control - dump (flush) control flags
863  * @DUMP_TX_FIFO_FLUSH: Dump MSDUs until the the FIFO is empty
864  *	and the TFD queues are empty.
865  */
866 enum iwl_dump_control {
867 	DUMP_TX_FIFO_FLUSH	= BIT(1),
868 };
869 
870 /**
871  * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command
872  * @queues_ctl: bitmap of queues to flush
873  * @flush_ctl: control flags
874  * @reserved: reserved
875  */
876 struct iwl_tx_path_flush_cmd_v1 {
877 	__le32 queues_ctl;
878 	__le16 flush_ctl;
879 	__le16 reserved;
880 } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_1 */
881 
882 /**
883  * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command
884  * @sta_id: station ID to flush
885  * @tid_mask: TID mask to flush
886  * @reserved: reserved
887  */
888 struct iwl_tx_path_flush_cmd {
889 	__le32 sta_id;
890 	__le16 tid_mask;
891 	__le16 reserved;
892 } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_2 */
893 
894 #define IWL_TX_FLUSH_QUEUE_RSP 16
895 
896 /**
897  * struct iwl_flush_queue_info - virtual flush queue info
898  * @queue_num: virtual queue id
899  * @read_before_flush: read pointer before flush
900  * @read_after_flush: read pointer after flush
901  */
902 struct iwl_flush_queue_info {
903 	__le16 tid;
904 	__le16 queue_num;
905 	__le16 read_before_flush;
906 	__le16 read_after_flush;
907 } __packed; /* TFDQ_FLUSH_INFO_API_S_VER_1 */
908 
909 /**
910  * struct iwl_tx_path_flush_cmd_rsp -- queue/FIFO flush command response
911  * @num_flushed_queues: number of queues in queues array
912  * @queues: all flushed queues
913  */
914 struct iwl_tx_path_flush_cmd_rsp {
915 	__le16 sta_id;
916 	__le16 num_flushed_queues;
917 	struct iwl_flush_queue_info queues[IWL_TX_FLUSH_QUEUE_RSP];
918 } __packed; /* TX_PATH_FLUSH_CMD_RSP_API_S_VER_1 */
919 
920 /* Available options for the SCD_QUEUE_CFG HCMD */
921 enum iwl_scd_cfg_actions {
922 	SCD_CFG_DISABLE_QUEUE		= 0x0,
923 	SCD_CFG_ENABLE_QUEUE		= 0x1,
924 	SCD_CFG_UPDATE_QUEUE_TID	= 0x2,
925 };
926 
927 /**
928  * struct iwl_scd_txq_cfg_cmd - New txq hw scheduler config command
929  * @token: unused
930  * @sta_id: station id
931  * @tid: TID
932  * @scd_queue: scheduler queue to confiug
933  * @action: 1 queue enable, 0 queue disable, 2 change txq's tid owner
934  *	Value is one of &enum iwl_scd_cfg_actions options
935  * @aggregate: 1 aggregated queue, 0 otherwise
936  * @tx_fifo: &enum iwl_mvm_tx_fifo
937  * @window: BA window size
938  * @ssn: SSN for the BA agreement
939  * @reserved: reserved
940  */
941 struct iwl_scd_txq_cfg_cmd {
942 	u8 token;
943 	u8 sta_id;
944 	u8 tid;
945 	u8 scd_queue;
946 	u8 action;
947 	u8 aggregate;
948 	u8 tx_fifo;
949 	u8 window;
950 	__le16 ssn;
951 	__le16 reserved;
952 } __packed; /* SCD_QUEUE_CFG_CMD_API_S_VER_1 */
953 
954 /**
955  * struct iwl_scd_txq_cfg_rsp
956  * @token: taken from the command
957  * @sta_id: station id from the command
958  * @tid: tid from the command
959  * @scd_queue: scd_queue from the command
960  */
961 struct iwl_scd_txq_cfg_rsp {
962 	u8 token;
963 	u8 sta_id;
964 	u8 tid;
965 	u8 scd_queue;
966 } __packed; /* SCD_QUEUE_CFG_RSP_API_S_VER_1 */
967 
968 #endif /* __iwl_fw_api_tx_h__ */
969