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