xref: /freebsd/sys/contrib/dev/iwlwifi/fw/api/tx.h (revision 681ce946)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2021 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 /* TODO: complete documentation for try_cnt and btkill_cnt */
181 /**
182  * struct iwl_tx_cmd - TX command struct to FW
183  * ( TX_CMD = 0x1c )
184  * @len: in bytes of the payload, see below for details
185  * @offload_assist: TX offload configuration
186  * @tx_flags: combination of TX_CMD_FLG_*, see &enum iwl_tx_flags
187  * @scratch: scratch buffer used by the device
188  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
189  *	cleared. Combination of RATE_MCS_*
190  * @sta_id: index of destination station in FW station table
191  * @sec_ctl: security control, TX_CMD_SEC_*
192  * @initial_rate_index: index into the the rate table for initial TX attempt.
193  *	Applied if TX_CMD_FLG_STA_RATE_MSK is set, normally 0 for data frames.
194  * @reserved2: reserved
195  * @key: security key
196  * @reserved3: reserved
197  * @life_time: frame life time (usecs??)
198  * @dram_lsb_ptr: Physical address of scratch area in the command (try_cnt +
199  *	btkill_cnd + reserved), first 32 bits. "0" disables usage.
200  * @dram_msb_ptr: upper bits of the scratch physical address
201  * @rts_retry_limit: max attempts for RTS
202  * @data_retry_limit: max attempts to send the data packet
203  * @tid_tspec: TID/tspec
204  * @pm_frame_timeout: PM TX frame timeout
205  * @reserved4: reserved
206  * @payload: payload (same as @hdr)
207  * @hdr: 802.11 header (same as @payload)
208  *
209  * The byte count (both len and next_frame_len) includes MAC header
210  * (24/26/30/32 bytes)
211  * + 2 bytes pad if 26/30 header size
212  * + 8 byte IV for CCM or TKIP (not used for WEP)
213  * + Data payload
214  * + 8-byte MIC (not used for CCM/WEP)
215  * It does not include post-MAC padding, i.e.,
216  * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.
217  * Range of len: 14-2342 bytes.
218  *
219  * After the struct fields the MAC header is placed, plus any padding,
220  * and then the actial payload.
221  */
222 struct iwl_tx_cmd {
223 	__le16 len;
224 	__le16 offload_assist;
225 	__le32 tx_flags;
226 	struct {
227 		u8 try_cnt;
228 		u8 btkill_cnt;
229 		__le16 reserved;
230 	} scratch; /* DRAM_SCRATCH_API_U_VER_1 */
231 	__le32 rate_n_flags;
232 	u8 sta_id;
233 	u8 sec_ctl;
234 	u8 initial_rate_index;
235 	u8 reserved2;
236 	u8 key[16];
237 	__le32 reserved3;
238 	__le32 life_time;
239 	__le32 dram_lsb_ptr;
240 	u8 dram_msb_ptr;
241 	u8 rts_retry_limit;
242 	u8 data_retry_limit;
243 	u8 tid_tspec;
244 	__le16 pm_frame_timeout;
245 	__le16 reserved4;
246 	u8 payload[0];
247 	struct ieee80211_hdr hdr[0];
248 } __packed; /* TX_CMD_API_S_VER_6 */
249 
250 struct iwl_dram_sec_info {
251 	__le32 pn_low;
252 	__le16 pn_high;
253 	__le16 aux_info;
254 } __packed; /* DRAM_SEC_INFO_API_S_VER_1 */
255 
256 /**
257  * struct iwl_tx_cmd_gen2 - TX command struct to FW for 22000 devices
258  * ( TX_CMD = 0x1c )
259  * @len: in bytes of the payload, see below for details
260  * @offload_assist: TX offload configuration
261  * @flags: combination of &enum iwl_tx_cmd_flags
262  * @dram_info: FW internal DRAM storage
263  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
264  *	cleared. Combination of RATE_MCS_*
265  * @hdr: 802.11 header
266  */
267 struct iwl_tx_cmd_gen2 {
268 	__le16 len;
269 	__le16 offload_assist;
270 	__le32 flags;
271 	struct iwl_dram_sec_info dram_info;
272 	__le32 rate_n_flags;
273 	struct ieee80211_hdr hdr[];
274 } __packed; /* TX_CMD_API_S_VER_7,
275 	       TX_CMD_API_S_VER_9 */
276 
277 /**
278  * struct iwl_tx_cmd_gen3 - TX command struct to FW for AX210+ devices
279  * ( TX_CMD = 0x1c )
280  * @len: in bytes of the payload, see below for details
281  * @flags: combination of &enum iwl_tx_cmd_flags
282  * @offload_assist: TX offload configuration
283  * @dram_info: FW internal DRAM storage
284  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
285  *	cleared. Combination of RATE_MCS_*
286  * @ttl: time to live - packet lifetime limit. The FW should drop if
287  *	passed.
288  * @hdr: 802.11 header
289  */
290 struct iwl_tx_cmd_gen3 {
291 	__le16 len;
292 	__le16 flags;
293 	__le32 offload_assist;
294 	struct iwl_dram_sec_info dram_info;
295 	__le32 rate_n_flags;
296 	__le64 ttl;
297 	struct ieee80211_hdr hdr[];
298 } __packed; /* TX_CMD_API_S_VER_8,
299 	       TX_CMD_API_S_VER_10 */
300 
301 /*
302  * TX response related data
303  */
304 
305 /*
306  * enum iwl_tx_status - status that is returned by the fw after attempts to Tx
307  * @TX_STATUS_SUCCESS:
308  * @TX_STATUS_DIRECT_DONE:
309  * @TX_STATUS_POSTPONE_DELAY:
310  * @TX_STATUS_POSTPONE_FEW_BYTES:
311  * @TX_STATUS_POSTPONE_BT_PRIO:
312  * @TX_STATUS_POSTPONE_QUIET_PERIOD:
313  * @TX_STATUS_POSTPONE_CALC_TTAK:
314  * @TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY:
315  * @TX_STATUS_FAIL_SHORT_LIMIT:
316  * @TX_STATUS_FAIL_LONG_LIMIT:
317  * @TX_STATUS_FAIL_UNDERRUN:
318  * @TX_STATUS_FAIL_DRAIN_FLOW:
319  * @TX_STATUS_FAIL_RFKILL_FLUSH:
320  * @TX_STATUS_FAIL_LIFE_EXPIRE:
321  * @TX_STATUS_FAIL_DEST_PS:
322  * @TX_STATUS_FAIL_HOST_ABORTED:
323  * @TX_STATUS_FAIL_BT_RETRY:
324  * @TX_STATUS_FAIL_STA_INVALID:
325  * @TX_TATUS_FAIL_FRAG_DROPPED:
326  * @TX_STATUS_FAIL_TID_DISABLE:
327  * @TX_STATUS_FAIL_FIFO_FLUSHED:
328  * @TX_STATUS_FAIL_SMALL_CF_POLL:
329  * @TX_STATUS_FAIL_FW_DROP:
330  * @TX_STATUS_FAIL_STA_COLOR_MISMATCH: mismatch between color of Tx cmd and
331  *	STA table
332  * @TX_FRAME_STATUS_INTERNAL_ABORT:
333  * @TX_MODE_MSK:
334  * @TX_MODE_NO_BURST:
335  * @TX_MODE_IN_BURST_SEQ:
336  * @TX_MODE_FIRST_IN_BURST:
337  * @TX_QUEUE_NUM_MSK:
338  *
339  * Valid only if frame_count =1
340  * TODO: complete documentation
341  */
342 enum iwl_tx_status {
343 	TX_STATUS_MSK = 0x000000ff,
344 	TX_STATUS_SUCCESS = 0x01,
345 	TX_STATUS_DIRECT_DONE = 0x02,
346 	/* postpone TX */
347 	TX_STATUS_POSTPONE_DELAY = 0x40,
348 	TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
349 	TX_STATUS_POSTPONE_BT_PRIO = 0x42,
350 	TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
351 	TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
352 	/* abort TX */
353 	TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
354 	TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
355 	TX_STATUS_FAIL_LONG_LIMIT = 0x83,
356 	TX_STATUS_FAIL_UNDERRUN = 0x84,
357 	TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
358 	TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
359 	TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
360 	TX_STATUS_FAIL_DEST_PS = 0x88,
361 	TX_STATUS_FAIL_HOST_ABORTED = 0x89,
362 	TX_STATUS_FAIL_BT_RETRY = 0x8a,
363 	TX_STATUS_FAIL_STA_INVALID = 0x8b,
364 	TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
365 	TX_STATUS_FAIL_TID_DISABLE = 0x8d,
366 	TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
367 	TX_STATUS_FAIL_SMALL_CF_POLL = 0x8f,
368 	TX_STATUS_FAIL_FW_DROP = 0x90,
369 	TX_STATUS_FAIL_STA_COLOR_MISMATCH = 0x91,
370 	TX_STATUS_INTERNAL_ABORT = 0x92,
371 	TX_MODE_MSK = 0x00000f00,
372 	TX_MODE_NO_BURST = 0x00000000,
373 	TX_MODE_IN_BURST_SEQ = 0x00000100,
374 	TX_MODE_FIRST_IN_BURST = 0x00000200,
375 	TX_QUEUE_NUM_MSK = 0x0001f000,
376 	TX_NARROW_BW_MSK = 0x00060000,
377 	TX_NARROW_BW_1DIV2 = 0x00020000,
378 	TX_NARROW_BW_1DIV4 = 0x00040000,
379 	TX_NARROW_BW_1DIV8 = 0x00060000,
380 };
381 
382 /*
383  * enum iwl_tx_agg_status - TX aggregation status
384  * @AGG_TX_STATE_STATUS_MSK:
385  * @AGG_TX_STATE_TRANSMITTED:
386  * @AGG_TX_STATE_UNDERRUN:
387  * @AGG_TX_STATE_BT_PRIO:
388  * @AGG_TX_STATE_FEW_BYTES:
389  * @AGG_TX_STATE_ABORT:
390  * @AGG_TX_STATE_TX_ON_AIR_DROP: TX_ON_AIR signal drop without underrun or
391  *	BT detection
392  * @AGG_TX_STATE_LAST_SENT_TRY_CNT:
393  * @AGG_TX_STATE_LAST_SENT_BT_KILL:
394  * @AGG_TX_STATE_SCD_QUERY:
395  * @AGG_TX_STATE_TEST_BAD_CRC32:
396  * @AGG_TX_STATE_RESPONSE:
397  * @AGG_TX_STATE_DUMP_TX:
398  * @AGG_TX_STATE_DELAY_TX:
399  * @AGG_TX_STATE_TRY_CNT_MSK: Retry count for 1st frame in aggregation (retries
400  *	occur if tx failed for this frame when it was a member of a previous
401  *	aggregation block). If rate scaling is used, retry count indicates the
402  *	rate table entry used for all frames in the new agg.
403  * @AGG_TX_STATE_SEQ_NUM_MSK: Command ID and sequence number of Tx command for
404  *	this frame
405  *
406  * TODO: complete documentation
407  */
408 enum iwl_tx_agg_status {
409 	AGG_TX_STATE_STATUS_MSK = 0x00fff,
410 	AGG_TX_STATE_TRANSMITTED = 0x000,
411 	AGG_TX_STATE_UNDERRUN = 0x001,
412 	AGG_TX_STATE_BT_PRIO = 0x002,
413 	AGG_TX_STATE_FEW_BYTES = 0x004,
414 	AGG_TX_STATE_ABORT = 0x008,
415 	AGG_TX_STATE_TX_ON_AIR_DROP = 0x010,
416 	AGG_TX_STATE_LAST_SENT_TRY_CNT = 0x020,
417 	AGG_TX_STATE_LAST_SENT_BT_KILL = 0x040,
418 	AGG_TX_STATE_SCD_QUERY = 0x080,
419 	AGG_TX_STATE_TEST_BAD_CRC32 = 0x0100,
420 	AGG_TX_STATE_RESPONSE = 0x1ff,
421 	AGG_TX_STATE_DUMP_TX = 0x200,
422 	AGG_TX_STATE_DELAY_TX = 0x400,
423 	AGG_TX_STATE_TRY_CNT_POS = 12,
424 	AGG_TX_STATE_TRY_CNT_MSK = 0xf << AGG_TX_STATE_TRY_CNT_POS,
425 };
426 
427 /*
428  * The mask below describes a status where we are absolutely sure that the MPDU
429  * wasn't sent. For BA/Underrun we cannot be that sure. All we know that we've
430  * written the bytes to the TXE, but we know nothing about what the DSP did.
431  */
432 #define AGG_TX_STAT_FRAME_NOT_SENT (AGG_TX_STATE_FEW_BYTES | \
433 				    AGG_TX_STATE_ABORT | \
434 				    AGG_TX_STATE_SCD_QUERY)
435 
436 /*
437  * REPLY_TX = 0x1c (response)
438  *
439  * This response may be in one of two slightly different formats, indicated
440  * by the frame_count field:
441  *
442  * 1)	No aggregation (frame_count == 1).  This reports Tx results for a single
443  *	frame. Multiple attempts, at various bit rates, may have been made for
444  *	this frame.
445  *
446  * 2)	Aggregation (frame_count > 1).  This reports Tx results for two or more
447  *	frames that used block-acknowledge.  All frames were transmitted at
448  *	same rate. Rate scaling may have been used if first frame in this new
449  *	agg block failed in previous agg block(s).
450  *
451  *	Note that, for aggregation, ACK (block-ack) status is not delivered
452  *	here; block-ack has not been received by the time the device records
453  *	this status.
454  *	This status relates to reasons the tx might have been blocked or aborted
455  *	within the device, rather than whether it was received successfully by
456  *	the destination station.
457  */
458 
459 /**
460  * struct agg_tx_status - per packet TX aggregation status
461  * @status: See &enum iwl_tx_agg_status
462  * @sequence: Sequence # for this frame's Tx cmd (not SSN!)
463  */
464 struct agg_tx_status {
465 	__le16 status;
466 	__le16 sequence;
467 } __packed;
468 
469 /*
470  * definitions for initial rate index field
471  * bits [3:0] initial rate index
472  * bits [6:4] rate table color, used for the initial rate
473  * bit-7 invalid rate indication
474  */
475 #define TX_RES_INIT_RATE_INDEX_MSK 0x0f
476 #define TX_RES_RATE_TABLE_COLOR_POS 4
477 #define TX_RES_RATE_TABLE_COLOR_MSK 0x70
478 #define TX_RES_INV_RATE_INDEX_MSK 0x80
479 #define TX_RES_RATE_TABLE_COL_GET(_f) (((_f) & TX_RES_RATE_TABLE_COLOR_MSK) >>\
480 				       TX_RES_RATE_TABLE_COLOR_POS)
481 
482 #define IWL_MVM_TX_RES_GET_TID(_ra_tid) ((_ra_tid) & 0x0f)
483 #define IWL_MVM_TX_RES_GET_RA(_ra_tid) ((_ra_tid) >> 4)
484 
485 /**
486  * struct iwl_mvm_tx_resp_v3 - notifies that fw is TXing a packet
487  * ( REPLY_TX = 0x1c )
488  * @frame_count: 1 no aggregation, >1 aggregation
489  * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
490  * @failure_rts: num of failures due to unsuccessful RTS
491  * @failure_frame: num failures due to no ACK (unused for agg)
492  * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
493  *	Tx of all the batch. RATE_MCS_*
494  * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
495  *	for agg: RTS + CTS + aggregation tx time + block-ack time.
496  *	in usec.
497  * @pa_status: tx power info
498  * @pa_integ_res_a: tx power info
499  * @pa_integ_res_b: tx power info
500  * @pa_integ_res_c: tx power info
501  * @measurement_req_id: tx power info
502  * @reduced_tpc: transmit power reduction used
503  * @reserved: reserved
504  * @tfd_info: TFD information set by the FH
505  * @seq_ctl: sequence control from the Tx cmd
506  * @byte_cnt: byte count from the Tx cmd
507  * @tlc_info: TLC rate info
508  * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
509  * @frame_ctrl: frame control
510  * @status: for non-agg:  frame status TX_STATUS_*
511  *	for agg: status of 1st frame, AGG_TX_STATE_*; other frame status fields
512  *	follow this one, up to frame_count. Length in @frame_count.
513  *
514  * After the array of statuses comes the SSN of the SCD. Look at
515  * %iwl_mvm_get_scd_ssn for more details.
516  */
517 struct iwl_mvm_tx_resp_v3 {
518 	u8 frame_count;
519 	u8 bt_kill_count;
520 	u8 failure_rts;
521 	u8 failure_frame;
522 	__le32 initial_rate;
523 	__le16 wireless_media_time;
524 
525 	u8 pa_status;
526 	u8 pa_integ_res_a[3];
527 	u8 pa_integ_res_b[3];
528 	u8 pa_integ_res_c[3];
529 	__le16 measurement_req_id;
530 	u8 reduced_tpc;
531 	u8 reserved;
532 
533 	__le32 tfd_info;
534 	__le16 seq_ctl;
535 	__le16 byte_cnt;
536 	u8 tlc_info;
537 	u8 ra_tid;
538 	__le16 frame_ctrl;
539 	struct agg_tx_status status[];
540 } __packed; /* TX_RSP_API_S_VER_3 */
541 
542 /**
543  * struct iwl_mvm_tx_resp - notifies that fw is TXing a packet
544  * ( REPLY_TX = 0x1c )
545  * @frame_count: 1 no aggregation, >1 aggregation
546  * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
547  * @failure_rts: num of failures due to unsuccessful RTS
548  * @failure_frame: num failures due to no ACK (unused for agg)
549  * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
550  *	Tx of all the batch. RATE_MCS_*
551  * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
552  *	for agg: RTS + CTS + aggregation tx time + block-ack time.
553  *	in usec.
554  * @pa_status: tx power info
555  * @pa_integ_res_a: tx power info
556  * @pa_integ_res_b: tx power info
557  * @pa_integ_res_c: tx power info
558  * @measurement_req_id: tx power info
559  * @reduced_tpc: transmit power reduction used
560  * @reserved: reserved
561  * @tfd_info: TFD information set by the FH
562  * @seq_ctl: sequence control from the Tx cmd
563  * @byte_cnt: byte count from the Tx cmd
564  * @tlc_info: TLC rate info
565  * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
566  * @frame_ctrl: frame control
567  * @tx_queue: TX queue for this response
568  * @reserved2: reserved for padding/alignment
569  * @status: for non-agg:  frame status TX_STATUS_*
570  *	For version 6 TX response isn't received for aggregation at all.
571  *
572  * After the array of statuses comes the SSN of the SCD. Look at
573  * %iwl_mvm_get_scd_ssn for more details.
574  */
575 struct iwl_mvm_tx_resp {
576 	u8 frame_count;
577 	u8 bt_kill_count;
578 	u8 failure_rts;
579 	u8 failure_frame;
580 	__le32 initial_rate;
581 	__le16 wireless_media_time;
582 
583 	u8 pa_status;
584 	u8 pa_integ_res_a[3];
585 	u8 pa_integ_res_b[3];
586 	u8 pa_integ_res_c[3];
587 	__le16 measurement_req_id;
588 	u8 reduced_tpc;
589 	u8 reserved;
590 
591 	__le32 tfd_info;
592 	__le16 seq_ctl;
593 	__le16 byte_cnt;
594 	u8 tlc_info;
595 	u8 ra_tid;
596 	__le16 frame_ctrl;
597 	__le16 tx_queue;
598 	__le16 reserved2;
599 	struct agg_tx_status status;
600 } __packed; /* TX_RSP_API_S_VER_6,
601 	       TX_RSP_API_S_VER_7 */
602 
603 /**
604  * struct iwl_mvm_ba_notif - notifies about reception of BA
605  * ( BA_NOTIF = 0xc5 )
606  * @sta_addr: MAC address
607  * @reserved: reserved
608  * @sta_id: Index of recipient (BA-sending) station in fw's station table
609  * @tid: tid of the session
610  * @seq_ctl: sequence control field
611  * @bitmap: the bitmap of the BA notification as seen in the air
612  * @scd_flow: the tx queue this BA relates to
613  * @scd_ssn: the index of the last contiguously sent packet
614  * @txed: number of Txed frames in this batch
615  * @txed_2_done: number of Acked frames in this batch
616  * @reduced_txp: power reduced according to TPC. This is the actual value and
617  *	not a copy from the LQ command. Thus, if not the first rate was used
618  *	for Tx-ing then this value will be set to 0 by FW.
619  * @reserved1: reserved
620  */
621 struct iwl_mvm_ba_notif {
622 	u8 sta_addr[ETH_ALEN];
623 	__le16 reserved;
624 
625 	u8 sta_id;
626 	u8 tid;
627 	__le16 seq_ctl;
628 	__le64 bitmap;
629 	__le16 scd_flow;
630 	__le16 scd_ssn;
631 	u8 txed;
632 	u8 txed_2_done;
633 	u8 reduced_txp;
634 	u8 reserved1;
635 } __packed;
636 
637 /**
638  * struct iwl_mvm_compressed_ba_tfd - progress of a TFD queue
639  * @q_num: TFD queue number
640  * @tfd_index: Index of first un-acked frame in the  TFD queue
641  * @scd_queue: For debug only - the physical queue the TFD queue is bound to
642  * @tid: TID of the queue (0-7)
643  * @reserved: reserved for alignment
644  */
645 struct iwl_mvm_compressed_ba_tfd {
646 	__le16 q_num;
647 	__le16 tfd_index;
648 	u8 scd_queue;
649 	u8 tid;
650 	u8 reserved[2];
651 } __packed; /* COMPRESSED_BA_TFD_API_S_VER_1 */
652 
653 /**
654  * struct iwl_mvm_compressed_ba_ratid - progress of a RA TID queue
655  * @q_num: RA TID queue number
656  * @tid: TID of the queue
657  * @ssn: BA window current SSN
658  */
659 struct iwl_mvm_compressed_ba_ratid {
660 	u8 q_num;
661 	u8 tid;
662 	__le16 ssn;
663 } __packed; /* COMPRESSED_BA_RATID_API_S_VER_1 */
664 
665 /*
666  * enum iwl_mvm_ba_resp_flags - TX aggregation status
667  * @IWL_MVM_BA_RESP_TX_AGG: generated due to BA
668  * @IWL_MVM_BA_RESP_TX_BAR: generated due to BA after BAR
669  * @IWL_MVM_BA_RESP_TX_AGG_FAIL: aggregation didn't receive BA
670  * @IWL_MVM_BA_RESP_TX_UNDERRUN: aggregation got underrun
671  * @IWL_MVM_BA_RESP_TX_BT_KILL: aggregation got BT-kill
672  * @IWL_MVM_BA_RESP_TX_DSP_TIMEOUT: aggregation didn't finish within the
673  *	expected time
674  */
675 enum iwl_mvm_ba_resp_flags {
676 	IWL_MVM_BA_RESP_TX_AGG,
677 	IWL_MVM_BA_RESP_TX_BAR,
678 	IWL_MVM_BA_RESP_TX_AGG_FAIL,
679 	IWL_MVM_BA_RESP_TX_UNDERRUN,
680 	IWL_MVM_BA_RESP_TX_BT_KILL,
681 	IWL_MVM_BA_RESP_TX_DSP_TIMEOUT
682 };
683 
684 /**
685  * struct iwl_mvm_compressed_ba_notif - notifies about reception of BA
686  * ( BA_NOTIF = 0xc5 )
687  * @flags: status flag, see the &iwl_mvm_ba_resp_flags
688  * @sta_id: Index of recipient (BA-sending) station in fw's station table
689  * @reduced_txp: power reduced according to TPC. This is the actual value and
690  *	not a copy from the LQ command. Thus, if not the first rate was used
691  *	for Tx-ing then this value will be set to 0 by FW.
692  * @tlc_rate_info: TLC rate info, initial rate index, TLC table color
693  * @retry_cnt: retry count
694  * @query_byte_cnt: SCD query byte count
695  * @query_frame_cnt: SCD query frame count
696  * @txed: number of frames sent in the aggregation (all-TIDs)
697  * @done: number of frames that were Acked by the BA (all-TIDs)
698  * @reserved: reserved (for alignment)
699  * @wireless_time: Wireless-media time
700  * @tx_rate: the rate the aggregation was sent at
701  * @tfd_cnt: number of TFD-Q elements
702  * @ra_tid_cnt: number of RATID-Q elements
703  * @tfd: array of TFD queue status updates. See &iwl_mvm_compressed_ba_tfd
704  *	for details. Length in @tfd_cnt.
705  * @ra_tid: array of RA-TID queue status updates. For debug purposes only. See
706  *	&iwl_mvm_compressed_ba_ratid for more details. Length in @ra_tid_cnt.
707  */
708 struct iwl_mvm_compressed_ba_notif {
709 	__le32 flags;
710 	u8 sta_id;
711 	u8 reduced_txp;
712 	u8 tlc_rate_info;
713 	u8 retry_cnt;
714 	__le32 query_byte_cnt;
715 	__le16 query_frame_cnt;
716 	__le16 txed;
717 	__le16 done;
718 	__le16 reserved;
719 	__le32 wireless_time;
720 	__le32 tx_rate;
721 	__le16 tfd_cnt;
722 	__le16 ra_tid_cnt;
723 	struct iwl_mvm_compressed_ba_ratid ra_tid[0];
724 	struct iwl_mvm_compressed_ba_tfd tfd[];
725 } __packed; /* COMPRESSED_BA_RES_API_S_VER_4,
726 	       COMPRESSED_BA_RES_API_S_VER_5 */
727 
728 /**
729  * struct iwl_mac_beacon_cmd_v6 - beacon template command
730  * @tx: the tx commands associated with the beacon frame
731  * @template_id: currently equal to the mac context id of the coresponding
732  *  mac.
733  * @tim_idx: the offset of the tim IE in the beacon
734  * @tim_size: the length of the tim IE
735  * @frame: the template of the beacon frame
736  */
737 struct iwl_mac_beacon_cmd_v6 {
738 	struct iwl_tx_cmd tx;
739 	__le32 template_id;
740 	__le32 tim_idx;
741 	__le32 tim_size;
742 	struct ieee80211_hdr frame[];
743 } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_6 */
744 
745 /**
746  * struct iwl_mac_beacon_cmd_v7 - beacon template command with offloaded CSA
747  * @tx: the tx commands associated with the beacon frame
748  * @template_id: currently equal to the mac context id of the coresponding
749  *  mac.
750  * @tim_idx: the offset of the tim IE in the beacon
751  * @tim_size: the length of the tim IE
752  * @ecsa_offset: offset to the ECSA IE if present
753  * @csa_offset: offset to the CSA IE if present
754  * @frame: the template of the beacon frame
755  */
756 struct iwl_mac_beacon_cmd_v7 {
757 	struct iwl_tx_cmd tx;
758 	__le32 template_id;
759 	__le32 tim_idx;
760 	__le32 tim_size;
761 	__le32 ecsa_offset;
762 	__le32 csa_offset;
763 	struct ieee80211_hdr frame[];
764 } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_7 */
765 
766 /* Bit flags for BEACON_TEMPLATE_CMD_API until version 10 */
767 enum iwl_mac_beacon_flags_v1 {
768 	IWL_MAC_BEACON_CCK_V1	= BIT(8),
769 	IWL_MAC_BEACON_ANT_A_V1 = BIT(9),
770 	IWL_MAC_BEACON_ANT_B_V1 = BIT(10),
771 	IWL_MAC_BEACON_FILS_V1	= BIT(12),
772 };
773 
774 /* Bit flags for BEACON_TEMPLATE_CMD_API version 11 and above */
775 enum iwl_mac_beacon_flags {
776 	IWL_MAC_BEACON_CCK	= BIT(5),
777 	IWL_MAC_BEACON_ANT_A	= BIT(6),
778 	IWL_MAC_BEACON_ANT_B	= BIT(7),
779 	IWL_MAC_BEACON_FILS	= BIT(8),
780 };
781 
782 /**
783  * struct iwl_mac_beacon_cmd - beacon template command with offloaded CSA
784  * @byte_cnt: byte count of the beacon frame.
785  * @flags: least significant byte for rate code. The most significant byte
786  *	is &enum iwl_mac_beacon_flags.
787  * @short_ssid: Short SSID
788  * @reserved: reserved
789  * @template_id: currently equal to the mac context id of the coresponding mac.
790  * @tim_idx: the offset of the tim IE in the beacon
791  * @tim_size: the length of the tim IE
792  * @ecsa_offset: offset to the ECSA IE if present
793  * @csa_offset: offset to the CSA IE if present
794  * @frame: the template of the beacon frame
795  */
796 struct iwl_mac_beacon_cmd {
797 	__le16 byte_cnt;
798 	__le16 flags;
799 	__le32 short_ssid;
800 	__le32 reserved;
801 	__le32 template_id;
802 	__le32 tim_idx;
803 	__le32 tim_size;
804 	__le32 ecsa_offset;
805 	__le32 csa_offset;
806 	struct ieee80211_hdr frame[];
807 } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_10,
808 	       BEACON_TEMPLATE_CMD_API_S_VER_11,
809 	       BEACON_TEMPLATE_CMD_API_S_VER_12 */
810 
811 struct iwl_beacon_notif {
812 	struct iwl_mvm_tx_resp beacon_notify_hdr;
813 	__le64 tsf;
814 	__le32 ibss_mgr_status;
815 } __packed;
816 
817 /**
818  * struct iwl_extended_beacon_notif_v5 - notifies about beacon transmission
819  * @beacon_notify_hdr: tx response command associated with the beacon
820  * @tsf: last beacon tsf
821  * @ibss_mgr_status: whether IBSS is manager
822  * @gp2: last beacon time in gp2
823  */
824 struct iwl_extended_beacon_notif_v5 {
825 	struct iwl_mvm_tx_resp beacon_notify_hdr;
826 	__le64 tsf;
827 	__le32 ibss_mgr_status;
828 	__le32 gp2;
829 } __packed; /* BEACON_NTFY_API_S_VER_5 */
830 
831 /**
832  * struct iwl_extended_beacon_notif - notifies about beacon transmission
833  * @status: the status of the Tx response of the beacon
834  * @tsf: last beacon tsf
835  * @ibss_mgr_status: whether IBSS is manager
836  * @gp2: last beacon time in gp2
837  */
838 struct iwl_extended_beacon_notif {
839 	__le32 status;
840 	__le64 tsf;
841 	__le32 ibss_mgr_status;
842 	__le32 gp2;
843 } __packed; /* BEACON_NTFY_API_S_VER_6_ */
844 
845 /**
846  * enum iwl_dump_control - dump (flush) control flags
847  * @DUMP_TX_FIFO_FLUSH: Dump MSDUs until the the FIFO is empty
848  *	and the TFD queues are empty.
849  */
850 enum iwl_dump_control {
851 	DUMP_TX_FIFO_FLUSH	= BIT(1),
852 };
853 
854 /**
855  * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command
856  * @queues_ctl: bitmap of queues to flush
857  * @flush_ctl: control flags
858  * @reserved: reserved
859  */
860 struct iwl_tx_path_flush_cmd_v1 {
861 	__le32 queues_ctl;
862 	__le16 flush_ctl;
863 	__le16 reserved;
864 } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_1 */
865 
866 /**
867  * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command
868  * @sta_id: station ID to flush
869  * @tid_mask: TID mask to flush
870  * @reserved: reserved
871  */
872 struct iwl_tx_path_flush_cmd {
873 	__le32 sta_id;
874 	__le16 tid_mask;
875 	__le16 reserved;
876 } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_2 */
877 
878 #define IWL_TX_FLUSH_QUEUE_RSP 16
879 
880 /**
881  * struct iwl_flush_queue_info - virtual flush queue info
882  * @queue_num: virtual queue id
883  * @read_before_flush: read pointer before flush
884  * @read_after_flush: read pointer after flush
885  */
886 struct iwl_flush_queue_info {
887 	__le16 tid;
888 	__le16 queue_num;
889 	__le16 read_before_flush;
890 	__le16 read_after_flush;
891 } __packed; /* TFDQ_FLUSH_INFO_API_S_VER_1 */
892 
893 /**
894  * struct iwl_tx_path_flush_cmd_rsp -- queue/FIFO flush command response
895  * @num_flushed_queues: number of queues in queues array
896  * @queues: all flushed queues
897  */
898 struct iwl_tx_path_flush_cmd_rsp {
899 	__le16 sta_id;
900 	__le16 num_flushed_queues;
901 	struct iwl_flush_queue_info queues[IWL_TX_FLUSH_QUEUE_RSP];
902 } __packed; /* TX_PATH_FLUSH_CMD_RSP_API_S_VER_1 */
903 
904 /* Available options for the SCD_QUEUE_CFG HCMD */
905 enum iwl_scd_cfg_actions {
906 	SCD_CFG_DISABLE_QUEUE		= 0x0,
907 	SCD_CFG_ENABLE_QUEUE		= 0x1,
908 	SCD_CFG_UPDATE_QUEUE_TID	= 0x2,
909 };
910 
911 /**
912  * struct iwl_scd_txq_cfg_cmd - New txq hw scheduler config command
913  * @token: unused
914  * @sta_id: station id
915  * @tid: TID
916  * @scd_queue: scheduler queue to confiug
917  * @action: 1 queue enable, 0 queue disable, 2 change txq's tid owner
918  *	Value is one of &enum iwl_scd_cfg_actions options
919  * @aggregate: 1 aggregated queue, 0 otherwise
920  * @tx_fifo: &enum iwl_mvm_tx_fifo
921  * @window: BA window size
922  * @ssn: SSN for the BA agreement
923  * @reserved: reserved
924  */
925 struct iwl_scd_txq_cfg_cmd {
926 	u8 token;
927 	u8 sta_id;
928 	u8 tid;
929 	u8 scd_queue;
930 	u8 action;
931 	u8 aggregate;
932 	u8 tx_fifo;
933 	u8 window;
934 	__le16 ssn;
935 	__le16 reserved;
936 } __packed; /* SCD_QUEUE_CFG_CMD_API_S_VER_1 */
937 
938 /**
939  * struct iwl_scd_txq_cfg_rsp
940  * @token: taken from the command
941  * @sta_id: station id from the command
942  * @tid: tid from the command
943  * @scd_queue: scd_queue from the command
944  */
945 struct iwl_scd_txq_cfg_rsp {
946 	u8 token;
947 	u8 sta_id;
948 	u8 tid;
949 	u8 scd_queue;
950 } __packed; /* SCD_QUEUE_CFG_RSP_API_S_VER_1 */
951 
952 #endif /* __iwl_fw_api_tx_h__ */
953