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