xref: /freebsd/sys/dev/iwm/if_iwmreg.h (revision 31a8b9782dc354ebd735db7036d7945f160b2527)
1355c1513SAdrian Chadd /*	$OpenBSD: if_iwmreg.h,v 1.65 2021/10/11 09:03:22 stsp Exp $	*/
2d4886179SRui Paulo 
3d4886179SRui Paulo /******************************************************************************
4d4886179SRui Paulo  *
5d4886179SRui Paulo  * This file is provided under a dual BSD/GPLv2 license.  When using or
6d4886179SRui Paulo  * redistributing this file, you may do so under either license.
7d4886179SRui Paulo  *
8d4886179SRui Paulo  * GPL LICENSE SUMMARY
9d4886179SRui Paulo  *
10d4886179SRui Paulo  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
11d4886179SRui Paulo  *
12d4886179SRui Paulo  * This program is free software; you can redistribute it and/or modify
13d4886179SRui Paulo  * it under the terms of version 2 of the GNU General Public License as
14d4886179SRui Paulo  * published by the Free Software Foundation.
15d4886179SRui Paulo  *
16d4886179SRui Paulo  * This program is distributed in the hope that it will be useful, but
17d4886179SRui Paulo  * WITHOUT ANY WARRANTY; without even the implied warranty of
18d4886179SRui Paulo  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19d4886179SRui Paulo  * General Public License for more details.
20d4886179SRui Paulo  *
21d4886179SRui Paulo  * You should have received a copy of the GNU General Public License
22d4886179SRui Paulo  * along with this program; if not, write to the Free Software
23d4886179SRui Paulo  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24d4886179SRui Paulo  * USA
25d4886179SRui Paulo  *
26d4886179SRui Paulo  * The full GNU General Public License is included in this distribution
27d4886179SRui Paulo  * in the file called COPYING.
28d4886179SRui Paulo  *
29d4886179SRui Paulo  * Contact Information:
30d4886179SRui Paulo  *  Intel Linux Wireless <ilw@linux.intel.com>
31d4886179SRui Paulo  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
32d4886179SRui Paulo  *
33d4886179SRui Paulo  * BSD LICENSE
34d4886179SRui Paulo  *
35d4886179SRui Paulo  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
36d4886179SRui Paulo  * All rights reserved.
37d4886179SRui Paulo  *
38d4886179SRui Paulo  * Redistribution and use in source and binary forms, with or without
39d4886179SRui Paulo  * modification, are permitted provided that the following conditions
40d4886179SRui Paulo  * are met:
41d4886179SRui Paulo  *
42d4886179SRui Paulo  *  * Redistributions of source code must retain the above copyright
43d4886179SRui Paulo  *    notice, this list of conditions and the following disclaimer.
44d4886179SRui Paulo  *  * Redistributions in binary form must reproduce the above copyright
45d4886179SRui Paulo  *    notice, this list of conditions and the following disclaimer in
46d4886179SRui Paulo  *    the documentation and/or other materials provided with the
47d4886179SRui Paulo  *    distribution.
48d4886179SRui Paulo  *  * Neither the name Intel Corporation nor the names of its
49d4886179SRui Paulo  *    contributors may be used to endorse or promote products derived
50d4886179SRui Paulo  *    from this software without specific prior written permission.
51d4886179SRui Paulo  *
52d4886179SRui Paulo  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53d4886179SRui Paulo  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54d4886179SRui Paulo  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55d4886179SRui Paulo  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56d4886179SRui Paulo  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57d4886179SRui Paulo  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58d4886179SRui Paulo  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59d4886179SRui Paulo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60d4886179SRui Paulo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61d4886179SRui Paulo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62d4886179SRui Paulo  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63d4886179SRui Paulo  *
64d4886179SRui Paulo  *****************************************************************************/
65355c1513SAdrian Chadd 
66d4886179SRui Paulo #ifndef	__IF_IWM_REG_H__
67d4886179SRui Paulo #define	__IF_IWM_REG_H__
68d4886179SRui Paulo 
69d4886179SRui Paulo #define	le16_to_cpup(_a_)	(le16toh(*(const uint16_t *)(_a_)))
70d4886179SRui Paulo #define	le32_to_cpup(_a_)	(le32toh(*(const uint32_t *)(_a_)))
71d4886179SRui Paulo 
72d4886179SRui Paulo /*
73d4886179SRui Paulo  * BEGIN iwl-csr.h
74d4886179SRui Paulo  */
75d4886179SRui Paulo 
76d4886179SRui Paulo /*
77d4886179SRui Paulo  * CSR (control and status registers)
78d4886179SRui Paulo  *
79d4886179SRui Paulo  * CSR registers are mapped directly into PCI bus space, and are accessible
80d4886179SRui Paulo  * whenever platform supplies power to device, even when device is in
81d4886179SRui Paulo  * low power states due to driver-invoked device resets
82d4886179SRui Paulo  * (e.g. IWM_CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes.
83d4886179SRui Paulo  *
84d4886179SRui Paulo  * Use iwl_write32() and iwl_read32() family to access these registers;
85d4886179SRui Paulo  * these provide simple PCI bus access, without waking up the MAC.
86d4886179SRui Paulo  * Do not use iwl_write_direct32() family for these registers;
87d4886179SRui Paulo  * no need to "grab nic access" via IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ.
88d4886179SRui Paulo  * The MAC (uCode processor, etc.) does not need to be powered up for accessing
89d4886179SRui Paulo  * the CSR registers.
90d4886179SRui Paulo  *
91d4886179SRui Paulo  * NOTE:  Device does need to be awake in order to read this memory
92d4886179SRui Paulo  *        via IWM_CSR_EEPROM and IWM_CSR_OTP registers
93d4886179SRui Paulo  */
94d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG    (0x000) /* hardware interface config */
95d4886179SRui Paulo #define IWM_CSR_INT_COALESCING      (0x004) /* accum ints, 32-usec units */
96d4886179SRui Paulo #define IWM_CSR_INT                 (0x008) /* host interrupt status/ack */
97d4886179SRui Paulo #define IWM_CSR_INT_MASK            (0x00c) /* host interrupt enable */
98d4886179SRui Paulo #define IWM_CSR_FH_INT_STATUS       (0x010) /* busmaster int status/ack*/
99d4886179SRui Paulo #define IWM_CSR_GPIO_IN             (0x018) /* read external chip pins */
100d4886179SRui Paulo #define IWM_CSR_RESET               (0x020) /* busmaster enable, NMI, etc*/
101d4886179SRui Paulo #define IWM_CSR_GP_CNTRL            (0x024)
102d4886179SRui Paulo 
103d4886179SRui Paulo /* 2nd byte of IWM_CSR_INT_COALESCING, not accessible via iwl_write32()! */
104d4886179SRui Paulo #define IWM_CSR_INT_PERIODIC_REG	(0x005)
105d4886179SRui Paulo 
106d4886179SRui Paulo /*
107d4886179SRui Paulo  * Hardware revision info
108d4886179SRui Paulo  * Bit fields:
109d4886179SRui Paulo  * 31-16:  Reserved
110d4886179SRui Paulo  *  15-4:  Type of device:  see IWM_CSR_HW_REV_TYPE_xxx definitions
111d4886179SRui Paulo  *  3-2:  Revision step:  0 = A, 1 = B, 2 = C, 3 = D
112d4886179SRui Paulo  *  1-0:  "Dash" (-) value, as in A-1, etc.
113d4886179SRui Paulo  */
114d4886179SRui Paulo #define IWM_CSR_HW_REV              (0x028)
115d4886179SRui Paulo 
116d4886179SRui Paulo /*
117d4886179SRui Paulo  * EEPROM and OTP (one-time-programmable) memory reads
118d4886179SRui Paulo  *
119d4886179SRui Paulo  * NOTE:  Device must be awake, initialized via apm_ops.init(),
120d4886179SRui Paulo  *        in order to read.
121d4886179SRui Paulo  */
122d4886179SRui Paulo #define IWM_CSR_EEPROM_REG          (0x02c)
123d4886179SRui Paulo #define IWM_CSR_EEPROM_GP           (0x030)
124d4886179SRui Paulo #define IWM_CSR_OTP_GP_REG          (0x034)
125d4886179SRui Paulo 
126d4886179SRui Paulo #define IWM_CSR_GIO_REG		(0x03C)
127d4886179SRui Paulo #define IWM_CSR_GP_UCODE_REG	(0x048)
128d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG	(0x050)
129d4886179SRui Paulo 
130d4886179SRui Paulo /*
131d4886179SRui Paulo  * UCODE-DRIVER GP (general purpose) mailbox registers.
132d4886179SRui Paulo  * SET/CLR registers set/clear bit(s) if "1" is written.
133d4886179SRui Paulo  */
134d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1       (0x054)
135d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1_SET   (0x058)
136d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1_CLR   (0x05c)
137d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP2       (0x060)
138d4886179SRui Paulo 
1396a5bc1d1SSean Bruno #define IWM_CSR_MBOX_SET_REG		(0x088)
1406a5bc1d1SSean Bruno #define IWM_CSR_MBOX_SET_REG_OS_ALIVE	0x20
1416a5bc1d1SSean Bruno 
142d4886179SRui Paulo #define IWM_CSR_LED_REG			(0x094)
143d4886179SRui Paulo #define IWM_CSR_DRAM_INT_TBL_REG	(0x0A0)
144d4886179SRui Paulo #define IWM_CSR_MAC_SHADOW_REG_CTRL	(0x0A8) /* 6000 and up */
145d4886179SRui Paulo 
146d4886179SRui Paulo 
147d4886179SRui Paulo /* GIO Chicken Bits (PCI Express bus link power management) */
148d4886179SRui Paulo #define IWM_CSR_GIO_CHICKEN_BITS    (0x100)
149d4886179SRui Paulo 
150d4886179SRui Paulo /* Analog phase-lock-loop configuration  */
151d4886179SRui Paulo #define IWM_CSR_ANA_PLL_CFG         (0x20c)
152d4886179SRui Paulo 
153d4886179SRui Paulo /*
154d4886179SRui Paulo  * CSR Hardware Revision Workaround Register.  Indicates hardware rev;
155d4886179SRui Paulo  * "step" determines CCK backoff for txpower calculation.  Used for 4965 only.
156d4886179SRui Paulo  * See also IWM_CSR_HW_REV register.
157d4886179SRui Paulo  * Bit fields:
158d4886179SRui Paulo  *  3-2:  0 = A, 1 = B, 2 = C, 3 = D step
159d4886179SRui Paulo  *  1-0:  "Dash" (-) value, as in C-1, etc.
160d4886179SRui Paulo  */
161d4886179SRui Paulo #define IWM_CSR_HW_REV_WA_REG		(0x22C)
162d4886179SRui Paulo 
163d4886179SRui Paulo #define IWM_CSR_DBG_HPET_MEM_REG	(0x240)
164d4886179SRui Paulo #define IWM_CSR_DBG_LINK_PWR_MGMT_REG	(0x250)
165d4886179SRui Paulo 
166d4886179SRui Paulo /* Bits for IWM_CSR_HW_IF_CONFIG_REG */
167d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH	(0x00000003)
168d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP	(0x0000000C)
169d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER	(0x000000C0)
170d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_BIT_MAC_SI	(0x00000100)
171d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI	(0x00000200)
172d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE	(0x00000C00)
173d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH	(0x00003000)
174d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP	(0x0000C000)
175d4886179SRui Paulo 
176d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_POS_MAC_DASH	(0)
177d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_POS_MAC_STEP	(2)
178d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_POS_BOARD_VER	(6)
179d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE	(10)
180d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_POS_PHY_DASH	(12)
181d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_POS_PHY_STEP	(14)
182d4886179SRui Paulo 
183d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A	(0x00080000)
184d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM	(0x00200000)
185d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_BIT_NIC_READY	(0x00400000) /* PCI_OWN_SEM */
186d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */
187d4886179SRui Paulo #define IWM_CSR_HW_IF_CONFIG_REG_PREPARE	(0x08000000) /* WAKE_ME */
1886a5bc1d1SSean Bruno #define IWM_CSR_HW_IF_CONFIG_REG_ENABLE_PME	(0x10000000)
1896a5bc1d1SSean Bruno #define IWM_CSR_HW_IF_CONFIG_REG_PERSIST_MODE	(0x40000000) /* PERSISTENCE */
190d4886179SRui Paulo 
191d4886179SRui Paulo #define IWM_CSR_INT_PERIODIC_DIS		(0x00) /* disable periodic int*/
192d4886179SRui Paulo #define IWM_CSR_INT_PERIODIC_ENA		(0xFF) /* 255*32 usec ~ 8 msec*/
193d4886179SRui Paulo 
194d4886179SRui Paulo /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
195d4886179SRui Paulo  * acknowledged (reset) by host writing "1" to flagged bits. */
196355c1513SAdrian Chadd #define IWM_CSR_INT_BIT_FH_RX	(1U << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
197d4886179SRui Paulo #define IWM_CSR_INT_BIT_HW_ERR	(1 << 29) /* DMA hardware error FH_INT[31] */
198d4886179SRui Paulo #define IWM_CSR_INT_BIT_RX_PERIODIC	(1 << 28) /* Rx periodic */
199d4886179SRui Paulo #define IWM_CSR_INT_BIT_FH_TX	(1 << 27) /* Tx DMA FH_INT[1:0] */
200d4886179SRui Paulo #define IWM_CSR_INT_BIT_SCD	(1 << 26) /* TXQ pointer advanced */
201d4886179SRui Paulo #define IWM_CSR_INT_BIT_SW_ERR	(1 << 25) /* uCode error */
202d4886179SRui Paulo #define IWM_CSR_INT_BIT_RF_KILL	(1 << 7)  /* HW RFKILL switch GP_CNTRL[27] toggled */
203d4886179SRui Paulo #define IWM_CSR_INT_BIT_CT_KILL	(1 << 6)  /* Critical temp (chip too hot) rfkill */
204d4886179SRui Paulo #define IWM_CSR_INT_BIT_SW_RX	(1 << 3)  /* Rx, command responses */
205d4886179SRui Paulo #define IWM_CSR_INT_BIT_WAKEUP	(1 << 1)  /* NIC controller waking up (pwr mgmt) */
206d4886179SRui Paulo #define IWM_CSR_INT_BIT_ALIVE	(1 << 0)  /* uCode interrupts once it initializes */
207d4886179SRui Paulo 
208d4886179SRui Paulo #define IWM_CSR_INI_SET_MASK	(IWM_CSR_INT_BIT_FH_RX   | \
209d4886179SRui Paulo 				 IWM_CSR_INT_BIT_HW_ERR  | \
210d4886179SRui Paulo 				 IWM_CSR_INT_BIT_FH_TX   | \
211d4886179SRui Paulo 				 IWM_CSR_INT_BIT_SW_ERR  | \
212d4886179SRui Paulo 				 IWM_CSR_INT_BIT_RF_KILL | \
213d4886179SRui Paulo 				 IWM_CSR_INT_BIT_SW_RX   | \
214d4886179SRui Paulo 				 IWM_CSR_INT_BIT_WAKEUP  | \
215d4886179SRui Paulo 				 IWM_CSR_INT_BIT_ALIVE   | \
216d4886179SRui Paulo 				 IWM_CSR_INT_BIT_RX_PERIODIC)
217d4886179SRui Paulo 
218d4886179SRui Paulo /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
219355c1513SAdrian Chadd #define IWM_CSR_FH_INT_BIT_ERR       (1U << 31) /* Error */
220d4886179SRui Paulo #define IWM_CSR_FH_INT_BIT_HI_PRIOR  (1 << 30) /* High priority Rx, bypass coalescing */
221d4886179SRui Paulo #define IWM_CSR_FH_INT_BIT_RX_CHNL1  (1 << 17) /* Rx channel 1 */
222d4886179SRui Paulo #define IWM_CSR_FH_INT_BIT_RX_CHNL0  (1 << 16) /* Rx channel 0 */
223d4886179SRui Paulo #define IWM_CSR_FH_INT_BIT_TX_CHNL1  (1 << 1)  /* Tx channel 1 */
224d4886179SRui Paulo #define IWM_CSR_FH_INT_BIT_TX_CHNL0  (1 << 0)  /* Tx channel 0 */
225d4886179SRui Paulo 
226d4886179SRui Paulo #define IWM_CSR_FH_INT_RX_MASK	(IWM_CSR_FH_INT_BIT_HI_PRIOR | \
227d4886179SRui Paulo 				IWM_CSR_FH_INT_BIT_RX_CHNL1 | \
228d4886179SRui Paulo 				IWM_CSR_FH_INT_BIT_RX_CHNL0)
229d4886179SRui Paulo 
230d4886179SRui Paulo #define IWM_CSR_FH_INT_TX_MASK	(IWM_CSR_FH_INT_BIT_TX_CHNL1 | \
231d4886179SRui Paulo 				IWM_CSR_FH_INT_BIT_TX_CHNL0)
232d4886179SRui Paulo 
233d4886179SRui Paulo /* GPIO */
234d4886179SRui Paulo #define IWM_CSR_GPIO_IN_BIT_AUX_POWER                   (0x00000200)
235d4886179SRui Paulo #define IWM_CSR_GPIO_IN_VAL_VAUX_PWR_SRC                (0x00000000)
236d4886179SRui Paulo #define IWM_CSR_GPIO_IN_VAL_VMAIN_PWR_SRC               (0x00000200)
237d4886179SRui Paulo 
238d4886179SRui Paulo /* RESET */
239d4886179SRui Paulo #define IWM_CSR_RESET_REG_FLAG_NEVO_RESET                (0x00000001)
240d4886179SRui Paulo #define IWM_CSR_RESET_REG_FLAG_FORCE_NMI                 (0x00000002)
241d4886179SRui Paulo #define IWM_CSR_RESET_REG_FLAG_SW_RESET                  (0x00000080)
242d4886179SRui Paulo #define IWM_CSR_RESET_REG_FLAG_MASTER_DISABLED           (0x00000100)
243d4886179SRui Paulo #define IWM_CSR_RESET_REG_FLAG_STOP_MASTER               (0x00000200)
244d4886179SRui Paulo #define IWM_CSR_RESET_LINK_PWR_MGMT_DISABLED             (0x80000000)
245d4886179SRui Paulo 
246d4886179SRui Paulo /*
247d4886179SRui Paulo  * GP (general purpose) CONTROL REGISTER
248d4886179SRui Paulo  * Bit fields:
249d4886179SRui Paulo  *    27:  HW_RF_KILL_SW
250d4886179SRui Paulo  *         Indicates state of (platform's) hardware RF-Kill switch
251d4886179SRui Paulo  * 26-24:  POWER_SAVE_TYPE
252d4886179SRui Paulo  *         Indicates current power-saving mode:
253d4886179SRui Paulo  *         000 -- No power saving
254d4886179SRui Paulo  *         001 -- MAC power-down
255d4886179SRui Paulo  *         010 -- PHY (radio) power-down
256d4886179SRui Paulo  *         011 -- Error
257d4886179SRui Paulo  *   9-6:  SYS_CONFIG
258d4886179SRui Paulo  *         Indicates current system configuration, reflecting pins on chip
259d4886179SRui Paulo  *         as forced high/low by device circuit board.
260d4886179SRui Paulo  *     4:  GOING_TO_SLEEP
261d4886179SRui Paulo  *         Indicates MAC is entering a power-saving sleep power-down.
262d4886179SRui Paulo  *         Not a good time to access device-internal resources.
263d4886179SRui Paulo  *     3:  MAC_ACCESS_REQ
264d4886179SRui Paulo  *         Host sets this to request and maintain MAC wakeup, to allow host
265d4886179SRui Paulo  *         access to device-internal resources.  Host must wait for
266d4886179SRui Paulo  *         MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR
267d4886179SRui Paulo  *         device registers.
268d4886179SRui Paulo  *     2:  INIT_DONE
269d4886179SRui Paulo  *         Host sets this to put device into fully operational D0 power mode.
270d4886179SRui Paulo  *         Host resets this after SW_RESET to put device into low power mode.
271d4886179SRui Paulo  *     0:  MAC_CLOCK_READY
272d4886179SRui Paulo  *         Indicates MAC (ucode processor, etc.) is powered up and can run.
273d4886179SRui Paulo  *         Internal resources are accessible.
274d4886179SRui Paulo  *         NOTE:  This does not indicate that the processor is actually running.
275d4886179SRui Paulo  *         NOTE:  This does not indicate that device has completed
276d4886179SRui Paulo  *                init or post-power-down restore of internal SRAM memory.
277d4886179SRui Paulo  *                Use IWM_CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that
278d4886179SRui Paulo  *                SRAM is restored and uCode is in normal operation mode.
279d4886179SRui Paulo  *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
280d4886179SRui Paulo  *                do not need to save/restore it.
281d4886179SRui Paulo  *         NOTE:  After device reset, this bit remains "0" until host sets
282d4886179SRui Paulo  *                INIT_DONE
283d4886179SRui Paulo  */
284d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY        (0x00000001)
285d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_FLAG_INIT_DONE              (0x00000004)
286d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ         (0x00000008)
287d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP         (0x00000010)
288d4886179SRui Paulo 
289d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN           (0x00000001)
290d4886179SRui Paulo 
291d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE         (0x07000000)
2921903c600SMark Johnston #define IWM_CSR_GP_CNTRL_REG_FLAG_RFKILL_WAKE_L1A_EN     (0x04000000)
293d4886179SRui Paulo #define IWM_CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW          (0x08000000)
294d4886179SRui Paulo 
295d4886179SRui Paulo 
296d4886179SRui Paulo /* HW REV */
297d4886179SRui Paulo #define IWM_CSR_HW_REV_DASH(_val)          (((_val) & 0x0000003) >> 0)
298d4886179SRui Paulo #define IWM_CSR_HW_REV_STEP(_val)          (((_val) & 0x000000C) >> 2)
299d4886179SRui Paulo 
300a994fb3bSAdrian Chadd /**
301a994fb3bSAdrian Chadd  *  hw_rev values
302a994fb3bSAdrian Chadd  */
303a994fb3bSAdrian Chadd enum {
304a994fb3bSAdrian Chadd 	IWM_SILICON_A_STEP = 0,
305a994fb3bSAdrian Chadd 	IWM_SILICON_B_STEP,
306a994fb3bSAdrian Chadd 	IWM_SILICON_C_STEP,
307a994fb3bSAdrian Chadd };
308a994fb3bSAdrian Chadd 
309d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_MSK		(0x000FFF0)
310d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_5300	(0x0000020)
311d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_5350	(0x0000030)
312d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_5100	(0x0000050)
313d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_5150	(0x0000040)
314d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_1000	(0x0000060)
315d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_6x00	(0x0000070)
316d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_6x50	(0x0000080)
317d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_6150	(0x0000084)
318d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_6x05	(0x00000B0)
319d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_6x30	IWM_CSR_HW_REV_TYPE_6x05
320d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_6x35	IWM_CSR_HW_REV_TYPE_6x05
321d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_2x30	(0x00000C0)
322d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_2x00	(0x0000100)
323d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_105		(0x0000110)
324d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_135		(0x0000120)
3256a5bc1d1SSean Bruno #define IWM_CSR_HW_REV_TYPE_7265D	(0x0000210)
326d4886179SRui Paulo #define IWM_CSR_HW_REV_TYPE_NONE	(0x00001F0)
327d4886179SRui Paulo 
328d4886179SRui Paulo /* EEPROM REG */
329d4886179SRui Paulo #define IWM_CSR_EEPROM_REG_READ_VALID_MSK	(0x00000001)
330d4886179SRui Paulo #define IWM_CSR_EEPROM_REG_BIT_CMD		(0x00000002)
331d4886179SRui Paulo #define IWM_CSR_EEPROM_REG_MSK_ADDR		(0x0000FFFC)
332d4886179SRui Paulo #define IWM_CSR_EEPROM_REG_MSK_DATA		(0xFFFF0000)
333d4886179SRui Paulo 
334d4886179SRui Paulo /* EEPROM GP */
335d4886179SRui Paulo #define IWM_CSR_EEPROM_GP_VALID_MSK		(0x00000007) /* signature */
336d4886179SRui Paulo #define IWM_CSR_EEPROM_GP_IF_OWNER_MSK	(0x00000180)
337d4886179SRui Paulo #define IWM_CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP	(0x00000000)
338d4886179SRui Paulo #define IWM_CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP		(0x00000001)
339d4886179SRui Paulo #define IWM_CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K		(0x00000002)
340d4886179SRui Paulo #define IWM_CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K		(0x00000004)
341d4886179SRui Paulo 
342d4886179SRui Paulo /* One-time-programmable memory general purpose reg */
343d4886179SRui Paulo #define IWM_CSR_OTP_GP_REG_DEVICE_SELECT  (0x00010000) /* 0 - EEPROM, 1 - OTP */
344d4886179SRui Paulo #define IWM_CSR_OTP_GP_REG_OTP_ACCESS_MODE  (0x00020000) /* 0 - absolute, 1 - relative */
345d4886179SRui Paulo #define IWM_CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK    (0x00100000) /* bit 20 */
346d4886179SRui Paulo #define IWM_CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK  (0x00200000) /* bit 21 */
347d4886179SRui Paulo 
348d4886179SRui Paulo /* GP REG */
349d4886179SRui Paulo #define IWM_CSR_GP_REG_POWER_SAVE_STATUS_MSK    (0x03000000) /* bit 24/25 */
350d4886179SRui Paulo #define IWM_CSR_GP_REG_NO_POWER_SAVE            (0x00000000)
351d4886179SRui Paulo #define IWM_CSR_GP_REG_MAC_POWER_SAVE           (0x01000000)
352d4886179SRui Paulo #define IWM_CSR_GP_REG_PHY_POWER_SAVE           (0x02000000)
353d4886179SRui Paulo #define IWM_CSR_GP_REG_POWER_SAVE_ERROR         (0x03000000)
354d4886179SRui Paulo 
355d4886179SRui Paulo 
356d4886179SRui Paulo /* CSR GIO */
357d4886179SRui Paulo #define IWM_CSR_GIO_REG_VAL_L0S_ENABLED	(0x00000002)
358d4886179SRui Paulo 
359d4886179SRui Paulo /*
360d4886179SRui Paulo  * UCODE-DRIVER GP (general purpose) mailbox register 1
361d4886179SRui Paulo  * Host driver and uCode write and/or read this register to communicate with
362d4886179SRui Paulo  * each other.
363d4886179SRui Paulo  * Bit fields:
364d4886179SRui Paulo  *     4:  UCODE_DISABLE
365d4886179SRui Paulo  *         Host sets this to request permanent halt of uCode, same as
366d4886179SRui Paulo  *         sending CARD_STATE command with "halt" bit set.
367d4886179SRui Paulo  *     3:  CT_KILL_EXIT
368d4886179SRui Paulo  *         Host sets this to request exit from CT_KILL state, i.e. host thinks
369d4886179SRui Paulo  *         device temperature is low enough to continue normal operation.
370d4886179SRui Paulo  *     2:  CMD_BLOCKED
371d4886179SRui Paulo  *         Host sets this during RF KILL power-down sequence (HW, SW, CT KILL)
372d4886179SRui Paulo  *         to release uCode to clear all Tx and command queues, enter
373d4886179SRui Paulo  *         unassociated mode, and power down.
374d4886179SRui Paulo  *         NOTE:  Some devices also use HBUS_TARG_MBX_C register for this bit.
375d4886179SRui Paulo  *     1:  SW_BIT_RFKILL
376d4886179SRui Paulo  *         Host sets this when issuing CARD_STATE command to request
377d4886179SRui Paulo  *         device sleep.
378d4886179SRui Paulo  *     0:  MAC_SLEEP
379d4886179SRui Paulo  *         uCode sets this when preparing a power-saving power-down.
380d4886179SRui Paulo  *         uCode resets this when power-up is complete and SRAM is sane.
381d4886179SRui Paulo  *         NOTE:  device saves internal SRAM data to host when powering down,
382d4886179SRui Paulo  *                and must restore this data after powering back up.
383d4886179SRui Paulo  *                MAC_SLEEP is the best indication that restore is complete.
384d4886179SRui Paulo  *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
385d4886179SRui Paulo  *                do not need to save/restore it.
386d4886179SRui Paulo  */
387d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP             (0x00000001)
388d4886179SRui Paulo #define IWM_CSR_UCODE_SW_BIT_RFKILL                     (0x00000002)
389d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED           (0x00000004)
390d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT      (0x00000008)
391d4886179SRui Paulo #define IWM_CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE       (0x00000020)
392d4886179SRui Paulo 
393d4886179SRui Paulo /* GP Driver */
394d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_MSK		    (0x00000003)
395d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_3x3_HYB	    (0x00000000)
396d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_HYB	    (0x00000001)
397d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA	    (0x00000002)
398d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6	    (0x00000004)
399d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_6050_1x2		    (0x00000008)
400d4886179SRui Paulo 
401d4886179SRui Paulo #define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER	    (0x00000080)
402d4886179SRui Paulo 
403d4886179SRui Paulo /* GIO Chicken Bits (PCI Express bus link power management) */
404d4886179SRui Paulo #define IWM_CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX  (0x00800000)
405d4886179SRui Paulo #define IWM_CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER  (0x20000000)
406d4886179SRui Paulo 
407d4886179SRui Paulo /* LED */
408d4886179SRui Paulo #define IWM_CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
409d4886179SRui Paulo #define IWM_CSR_LED_REG_TURN_ON (0x60)
410d4886179SRui Paulo #define IWM_CSR_LED_REG_TURN_OFF (0x20)
411d4886179SRui Paulo 
412d4886179SRui Paulo /* ANA_PLL */
413d4886179SRui Paulo #define IWM_CSR50_ANA_PLL_CFG_VAL        (0x00880300)
414d4886179SRui Paulo 
415d4886179SRui Paulo /* HPET MEM debug */
416d4886179SRui Paulo #define IWM_CSR_DBG_HPET_MEM_REG_VAL	(0xFFFF0000)
417d4886179SRui Paulo 
418d4886179SRui Paulo /* DRAM INT TABLE */
419355c1513SAdrian Chadd #define IWM_CSR_DRAM_INT_TBL_ENABLE		(1U << 31)
4206a5bc1d1SSean Bruno #define IWM_CSR_DRAM_INIT_TBL_WRITE_POINTER	(1 << 28)
421d4886179SRui Paulo #define IWM_CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
422d4886179SRui Paulo 
423d4886179SRui Paulo /* SECURE boot registers */
424d4886179SRui Paulo #define IWM_CSR_SECURE_BOOT_CONFIG_ADDR	(0x100)
425355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_BURNED_IN_OTP	0x00000001
426355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_NOT_REQ		0x00000002
427d4886179SRui Paulo #define IWM_CSR_SECURE_BOOT_CPU1_STATUS_ADDR	(0x100)
428d4886179SRui Paulo #define IWM_CSR_SECURE_BOOT_CPU2_STATUS_ADDR	(0x100)
429355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_STATUS	0x00000003
430355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_COMPLETED	0x00000002
431355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_SUCCESS	0x00000004
432355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_FAIL	0x00000008
433355c1513SAdrian Chadd #define IWM_CSR_SECURE_BOOT_CPU_STATUS_SIGN_VERF_FAIL	0x00000010
434d4886179SRui Paulo 
4356a5bc1d1SSean Bruno #define IWM_FH_UCODE_LOAD_STATUS	0x1af0
436355c1513SAdrian Chadd 
4376a5bc1d1SSean Bruno #define IWM_FH_MEM_TB_MAX_LENGTH	0x20000
438d4886179SRui Paulo 
439355c1513SAdrian Chadd /* 9000 rx series registers */
440355c1513SAdrian Chadd 
441355c1513SAdrian Chadd #define IWM_RFH_Q0_FRBDCB_BA_LSB 0xA08000 /* 64 bit address */
442355c1513SAdrian Chadd #define IWM_RFH_Q_FRBDCB_BA_LSB(q) (IWM_RFH_Q0_FRBDCB_BA_LSB + (q) * 8)
443355c1513SAdrian Chadd /* Write index table */
444355c1513SAdrian Chadd #define IWM_RFH_Q0_FRBDCB_WIDX 0xA08080
445355c1513SAdrian Chadd #define IWM_RFH_Q_FRBDCB_WIDX(q) (IWM_RFH_Q0_FRBDCB_WIDX + (q) * 4)
446355c1513SAdrian Chadd /* Write index table - shadow registers */
447355c1513SAdrian Chadd #define IWM_RFH_Q0_FRBDCB_WIDX_TRG 0x1C80
448355c1513SAdrian Chadd #define IWM_RFH_Q_FRBDCB_WIDX_TRG(q) (IWM_RFH_Q0_FRBDCB_WIDX_TRG + (q) * 4)
449355c1513SAdrian Chadd /* Read index table */
450355c1513SAdrian Chadd #define IWM_RFH_Q0_FRBDCB_RIDX 0xA080C0
451355c1513SAdrian Chadd #define IWM_RFH_Q_FRBDCB_RIDX(q) (IWM_RFH_Q0_FRBDCB_RIDX + (q) * 4)
452355c1513SAdrian Chadd /* Used list table */
453355c1513SAdrian Chadd #define IWM_RFH_Q0_URBDCB_BA_LSB 0xA08100 /* 64 bit address */
454355c1513SAdrian Chadd #define IWM_RFH_Q_URBDCB_BA_LSB(q) (IWM_RFH_Q0_URBDCB_BA_LSB + (q) * 8)
455355c1513SAdrian Chadd /* Write index table */
456355c1513SAdrian Chadd #define IWM_RFH_Q0_URBDCB_WIDX 0xA08180
457355c1513SAdrian Chadd #define IWM_RFH_Q_URBDCB_WIDX(q) (IWM_RFH_Q0_URBDCB_WIDX + (q) * 4)
458355c1513SAdrian Chadd #define IWM_RFH_Q0_URBDCB_VAID 0xA081C0
459355c1513SAdrian Chadd #define IWM_RFH_Q_URBDCB_VAID(q) (IWM_RFH_Q0_URBDCB_VAID + (q) * 4)
460355c1513SAdrian Chadd /* stts */
461355c1513SAdrian Chadd #define IWM_RFH_Q0_URBD_STTS_WPTR_LSB 0xA08200 /*64 bits address */
462355c1513SAdrian Chadd #define IWM_RFH_Q_URBD_STTS_WPTR_LSB(q) (IWM_RFH_Q0_URBD_STTS_WPTR_LSB + (q) * 8)
463355c1513SAdrian Chadd 
464355c1513SAdrian Chadd #define IWM_RFH_Q0_ORB_WPTR_LSB 0xA08280
465355c1513SAdrian Chadd #define IWM_RFH_Q_ORB_WPTR_LSB(q) (IWM_RFH_Q0_ORB_WPTR_LSB + (q) * 8)
466355c1513SAdrian Chadd #define IWM_RFH_RBDBUF_RBD0_LSB 0xA08300
467355c1513SAdrian Chadd #define IWM_RFH_RBDBUF_RBD_LSB(q) (IWM_RFH_RBDBUF_RBD0_LSB + (q) * 8)
468355c1513SAdrian Chadd 
469355c1513SAdrian Chadd /**
470355c1513SAdrian Chadd  * RFH Status Register
471355c1513SAdrian Chadd  *
472355c1513SAdrian Chadd  * Bit fields:
473355c1513SAdrian Chadd  *
474355c1513SAdrian Chadd  * Bit 29: RBD_FETCH_IDLE
475355c1513SAdrian Chadd  * This status flag is set by the RFH when there is no active RBD fetch from
476355c1513SAdrian Chadd  * DRAM.
477355c1513SAdrian Chadd  * Once the RFH RBD controller starts fetching (or when there is a pending
478355c1513SAdrian Chadd  * RBD read response from DRAM), this flag is immediately turned off.
479355c1513SAdrian Chadd  *
480355c1513SAdrian Chadd  * Bit 30: SRAM_DMA_IDLE
481355c1513SAdrian Chadd  * This status flag is set by the RFH when there is no active transaction from
482355c1513SAdrian Chadd  * SRAM to DRAM.
483355c1513SAdrian Chadd  * Once the SRAM to DRAM DMA is active, this flag is immediately turned off.
484355c1513SAdrian Chadd  *
485355c1513SAdrian Chadd  * Bit 31: RXF_DMA_IDLE
486355c1513SAdrian Chadd  * This status flag is set by the RFH when there is no active transaction from
487355c1513SAdrian Chadd  * RXF to DRAM.
488355c1513SAdrian Chadd  * Once the RXF-to-DRAM DMA is active, this flag is immediately turned off.
489355c1513SAdrian Chadd  */
490355c1513SAdrian Chadd #define IWM_RFH_GEN_STATUS          0xA09808
491355c1513SAdrian Chadd #define IWM_RFH_GEN_STATUS_GEN3     0xA07824
492355c1513SAdrian Chadd #define IWM_RBD_FETCH_IDLE  (1 << 29)
493355c1513SAdrian Chadd #define IWM_SRAM_DMA_IDLE   (1 << 30)
494355c1513SAdrian Chadd #define IWM_RXF_DMA_IDLE    (1U << 31)
495355c1513SAdrian Chadd 
496355c1513SAdrian Chadd /* DMA configuration */
497355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_CFG         0xA09820
498355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_CFG_GEN3    0xA07880
499355c1513SAdrian Chadd /* RB size */
500355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_MASK (0x000F0000) /* bits 16-19 */
501355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_POS 16
502355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_1K  (0x1 << IWM_RFH_RXF_DMA_RB_SIZE_POS)
503355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_2K  (0x2 << IWM_RFH_RXF_DMA_RB_SIZE_POS)
504355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_4K  (0x4 << IWM_RFH_RXF_DMA_RB_SIZE_POS)
505355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_8K  (0x8 << IWM_RFH_RXF_DMA_RB_SIZE_POS)
506355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_12K (0x9 << IWM_RFH_RXF_DMA_RB_SIZE_POS)
507355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_16K (0xA << IWM_RFH_RXF_DMA_RB_SIZE_POS)
508355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_20K (0xB << IWM_RFH_RXF_DMA_RB_SIZE_POS)
509355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_24K (0xC << IWM_RFH_RXF_DMA_RB_SIZE_POS)
510355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_28K (0xD << IWM_RFH_RXF_DMA_RB_SIZE_POS)
511355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RB_SIZE_32K (0xE << IWM_RFH_RXF_DMA_RB_SIZE_POS)
512355c1513SAdrian Chadd /* RB Circular Buffer size:defines the table sizes in RBD units */
513355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_MASK (0x00F00000) /* bits 20-23 */
514355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_POS 20
515355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_8        (0x3 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
516355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_16       (0x4 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
517355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_32       (0x5 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
518355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_64       (0x7 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
519355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_128      (0x7 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
520355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_256      (0x8 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
521355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_512      (0x9 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
522355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_1024     (0xA << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
523355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_RBDCB_SIZE_2048     (0xB << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS)
524355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_MIN_RB_SIZE_MASK    (0x03000000) /* bit 24-25 */
525355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_MIN_RB_SIZE_POS     24
526355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_MIN_RB_4_8          (3 << IWM_RFH_RXF_DMA_MIN_RB_SIZE_POS)
527355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_DROP_TOO_LARGE_MASK (0x04000000) /* bit 26 */
528355c1513SAdrian Chadd #define IWM_RFH_RXF_DMA_SINGLE_FRAME_MASK   (0x20000000) /* bit 29 */
529355c1513SAdrian Chadd #define IWM_RFH_DMA_EN_MASK                 (0xC0000000) /* bits 30-31*/
530355c1513SAdrian Chadd #define IWM_RFH_DMA_EN_ENABLE_VAL           (1U << 31)
531355c1513SAdrian Chadd 
532355c1513SAdrian Chadd #define IWM_RFH_RXF_RXQ_ACTIVE 0xA0980C
533355c1513SAdrian Chadd 
534355c1513SAdrian Chadd #define IWM_RFH_GEN_CFG     0xA09800
535355c1513SAdrian Chadd #define IWM_RFH_GEN_CFG_SERVICE_DMA_SNOOP   (1 << 0)
536355c1513SAdrian Chadd #define IWM_RFH_GEN_CFG_RFH_DMA_SNOOP       (1 << 1)
537355c1513SAdrian Chadd #define IWM_RFH_GEN_CFG_RB_CHUNK_SIZE_128   0x00000010
538355c1513SAdrian Chadd #define IWM_RFH_GEN_CFG_RB_CHUNK_SIZE_64    0x00000000
539355c1513SAdrian Chadd /* the driver assumes everywhere that the default RXQ is 0 */
540355c1513SAdrian Chadd #define IWM_RFH_GEN_CFG_DEFAULT_RXQ_NUM     0xF00
541355c1513SAdrian Chadd 
542355c1513SAdrian Chadd /* end of 9000 rx series registers */
543355c1513SAdrian Chadd 
5446a5bc1d1SSean Bruno #define IWM_LMPM_SECURE_UCODE_LOAD_CPU1_HDR_ADDR	0x1e78
5456a5bc1d1SSean Bruno #define IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR	0x1e7c
5466a5bc1d1SSean Bruno 
5476a5bc1d1SSean Bruno #define IWM_LMPM_SECURE_CPU1_HDR_MEM_SPACE		0x420000
5486a5bc1d1SSean Bruno #define IWM_LMPM_SECURE_CPU2_HDR_MEM_SPACE		0x420400
549d4886179SRui Paulo 
550d4886179SRui Paulo #define IWM_CSR_SECURE_TIME_OUT	(100)
551d4886179SRui Paulo 
5526a5bc1d1SSean Bruno /* extended range in FW SRAM */
5536a5bc1d1SSean Bruno #define IWM_FW_MEM_EXTENDED_START       0x40000
5546a5bc1d1SSean Bruno #define IWM_FW_MEM_EXTENDED_END         0x57FFF
5556a5bc1d1SSean Bruno 
5566a5bc1d1SSean Bruno /* FW chicken bits */
5576a5bc1d1SSean Bruno #define IWM_LMPM_CHICK				0xa01ff8
5586a5bc1d1SSean Bruno #define IWM_LMPM_CHICK_EXTENDED_ADDR_SPACE	0x01
5596a5bc1d1SSean Bruno 
560d4886179SRui Paulo #define IWM_FH_TCSR_0_REG0 (0x1D00)
561d4886179SRui Paulo 
562d4886179SRui Paulo /*
563d4886179SRui Paulo  * HBUS (Host-side Bus)
564d4886179SRui Paulo  *
565d4886179SRui Paulo  * HBUS registers are mapped directly into PCI bus space, but are used
566d4886179SRui Paulo  * to indirectly access device's internal memory or registers that
567d4886179SRui Paulo  * may be powered-down.
568d4886179SRui Paulo  *
569d4886179SRui Paulo  * Use iwl_write_direct32()/iwl_read_direct32() family for these registers;
570d4886179SRui Paulo  * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ
571d4886179SRui Paulo  * to make sure the MAC (uCode processor, etc.) is powered up for accessing
572d4886179SRui Paulo  * internal resources.
573d4886179SRui Paulo  *
574d4886179SRui Paulo  * Do not use iwl_write32()/iwl_read32() family to access these registers;
575d4886179SRui Paulo  * these provide only simple PCI bus access, without waking up the MAC.
576d4886179SRui Paulo  */
577d4886179SRui Paulo #define IWM_HBUS_BASE	(0x400)
578d4886179SRui Paulo 
579d4886179SRui Paulo /*
580d4886179SRui Paulo  * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
581d4886179SRui Paulo  * structures, error log, event log, verifying uCode load).
582d4886179SRui Paulo  * First write to address register, then read from or write to data register
583d4886179SRui Paulo  * to complete the job.  Once the address register is set up, accesses to
584d4886179SRui Paulo  * data registers auto-increment the address by one dword.
585d4886179SRui Paulo  * Bit usage for address registers (read or write):
586d4886179SRui Paulo  *  0-31:  memory address within device
587d4886179SRui Paulo  */
588d4886179SRui Paulo #define IWM_HBUS_TARG_MEM_RADDR     (IWM_HBUS_BASE+0x00c)
589d4886179SRui Paulo #define IWM_HBUS_TARG_MEM_WADDR     (IWM_HBUS_BASE+0x010)
590d4886179SRui Paulo #define IWM_HBUS_TARG_MEM_WDAT      (IWM_HBUS_BASE+0x018)
591d4886179SRui Paulo #define IWM_HBUS_TARG_MEM_RDAT      (IWM_HBUS_BASE+0x01c)
592d4886179SRui Paulo 
593d4886179SRui Paulo /* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */
594d4886179SRui Paulo #define IWM_HBUS_TARG_MBX_C         (IWM_HBUS_BASE+0x030)
595d4886179SRui Paulo #define IWM_HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED         (0x00000004)
596d4886179SRui Paulo 
597d4886179SRui Paulo /*
598d4886179SRui Paulo  * Registers for accessing device's internal peripheral registers
599d4886179SRui Paulo  * (e.g. SCD, BSM, etc.).  First write to address register,
600d4886179SRui Paulo  * then read from or write to data register to complete the job.
601d4886179SRui Paulo  * Bit usage for address registers (read or write):
602d4886179SRui Paulo  *  0-15:  register address (offset) within device
603d4886179SRui Paulo  * 24-25:  (# bytes - 1) to read or write (e.g. 3 for dword)
604d4886179SRui Paulo  */
605d4886179SRui Paulo #define IWM_HBUS_TARG_PRPH_WADDR    (IWM_HBUS_BASE+0x044)
606d4886179SRui Paulo #define IWM_HBUS_TARG_PRPH_RADDR    (IWM_HBUS_BASE+0x048)
607d4886179SRui Paulo #define IWM_HBUS_TARG_PRPH_WDAT     (IWM_HBUS_BASE+0x04c)
608d4886179SRui Paulo #define IWM_HBUS_TARG_PRPH_RDAT     (IWM_HBUS_BASE+0x050)
609d4886179SRui Paulo 
6106a5bc1d1SSean Bruno /* enable the ID buf for read */
6116a5bc1d1SSean Bruno #define IWM_WFPM_PS_CTL_CLR			0xa0300c
6126a5bc1d1SSean Bruno #define IWM_WFMP_MAC_ADDR_0			0xa03080
6136a5bc1d1SSean Bruno #define IWM_WFMP_MAC_ADDR_1			0xa03084
6146a5bc1d1SSean Bruno #define IWM_LMPM_PMG_EN				0xa01cec
6156a5bc1d1SSean Bruno #define IWM_RADIO_REG_SYS_MANUAL_DFT_0		0xad4078
6166a5bc1d1SSean Bruno #define IWM_RFIC_REG_RD				0xad0470
6176a5bc1d1SSean Bruno #define IWM_WFPM_CTRL_REG			0xa03030
6186a5bc1d1SSean Bruno #define IWM_WFPM_AUX_CTL_AUX_IF_MAC_OWNER_MSK	0x08000000
6196a5bc1d1SSean Bruno #define IWM_ENABLE_WFPM				0x80000000
6206a5bc1d1SSean Bruno 
6216a5bc1d1SSean Bruno #define IWM_AUX_MISC_REG			0xa200b0
6226a5bc1d1SSean Bruno #define IWM_HW_STEP_LOCATION_BITS		24
6236a5bc1d1SSean Bruno 
6246a5bc1d1SSean Bruno #define IWM_AUX_MISC_MASTER1_EN			0xa20818
6256a5bc1d1SSean Bruno #define IWM_AUX_MISC_MASTER1_EN_SBE_MSK		0x1
6266a5bc1d1SSean Bruno #define IWM_AUX_MISC_MASTER1_SMPHR_STATUS	0xa20800
6276a5bc1d1SSean Bruno #define IWM_RSA_ENABLE				0xa24b08
6286a5bc1d1SSean Bruno #define IWM_PREG_AUX_BUS_WPROT_0		0xa04cc0
629355c1513SAdrian Chadd #define IWM_PREG_PRPH_WPROT_9000		0xa04ce0
630355c1513SAdrian Chadd #define IWM_PREG_PRPH_WPROT_22000		0xa04d00
6316a5bc1d1SSean Bruno #define IWM_SB_CFG_OVERRIDE_ADDR		0xa26c78
6326a5bc1d1SSean Bruno #define IWM_SB_CFG_OVERRIDE_ENABLE		0x8000
6336a5bc1d1SSean Bruno #define IWM_SB_CFG_BASE_OVERRIDE		0xa20000
6346a5bc1d1SSean Bruno #define IWM_SB_MODIFY_CFG_FLAG			0xa03088
6356a5bc1d1SSean Bruno #define IWM_SB_CPU_1_STATUS			0xa01e30
6366a5bc1d1SSean Bruno #define IWM_SB_CPU_2_STATUS			0Xa01e34
6376a5bc1d1SSean Bruno 
638355c1513SAdrian Chadd #define IWM_UREG_CHICK				0xa05c00
639355c1513SAdrian Chadd #define IWM_UREG_CHICK_MSI_ENABLE		(1 << 24)
640355c1513SAdrian Chadd #define IWM_UREG_CHICK_MSIX_ENABLE		(1 << 25)
641355c1513SAdrian Chadd 
642355c1513SAdrian Chadd #define IWM_HPM_DEBUG				0xa03440
643355c1513SAdrian Chadd #define IWM_HPM_PERSISTENCE_BIT			(1 << 12)
644355c1513SAdrian Chadd #define IWM_PREG_WFPM_ACCESS			(1 << 12)
645355c1513SAdrian Chadd 
646d4886179SRui Paulo /* Used to enable DBGM */
647d4886179SRui Paulo #define IWM_HBUS_TARG_TEST_REG	(IWM_HBUS_BASE+0x05c)
648d4886179SRui Paulo 
649d4886179SRui Paulo /*
650d4886179SRui Paulo  * Per-Tx-queue write pointer (index, really!)
651d4886179SRui Paulo  * Indicates index to next TFD that driver will fill (1 past latest filled).
652d4886179SRui Paulo  * Bit usage:
653d4886179SRui Paulo  *  0-7:  queue write index
654d4886179SRui Paulo  * 11-8:  queue selector
655d4886179SRui Paulo  */
656d4886179SRui Paulo #define IWM_HBUS_TARG_WRPTR         (IWM_HBUS_BASE+0x060)
657d4886179SRui Paulo 
658d4886179SRui Paulo /**********************************************************
659d4886179SRui Paulo  * CSR values
660d4886179SRui Paulo  **********************************************************/
661d4886179SRui Paulo  /*
662d4886179SRui Paulo  * host interrupt timeout value
663d4886179SRui Paulo  * used with setting interrupt coalescing timer
664d4886179SRui Paulo  * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
665d4886179SRui Paulo  *
666d4886179SRui Paulo  * default interrupt coalescing timer is 64 x 32 = 2048 usecs
667d4886179SRui Paulo  */
668d4886179SRui Paulo #define IWM_HOST_INT_TIMEOUT_MAX	(0xFF)
669d4886179SRui Paulo #define IWM_HOST_INT_TIMEOUT_DEF	(0x40)
670d4886179SRui Paulo #define IWM_HOST_INT_TIMEOUT_MIN	(0x0)
671355c1513SAdrian Chadd #define IWM_HOST_INT_OPER_MODE		(1U << 31)
672d4886179SRui Paulo 
673d4886179SRui Paulo /*****************************************************************************
674d4886179SRui Paulo  *                        7000/3000 series SHR DTS addresses                 *
675d4886179SRui Paulo  *****************************************************************************/
676d4886179SRui Paulo 
677d4886179SRui Paulo /* Diode Results Register Structure: */
678355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_DIG_VAL		0x000000FF /* bits [7:0] */
679355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_VREF_LOW		0x0000FF00 /* bits [15:8] */
680355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_VREF_HIGH		0x00FF0000 /* bits [23:16] */
681355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_VREF_ID		0x03000000 /* bits [25:24] */
682355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_PASS_ONCE		0x80000000 /* bits [31:31] */
683355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_FLAGS_MSK		0xFF000000 /* bits [31:24] */
684d4886179SRui Paulo /* Those are the masks INSIDE the flags bit-field: */
685355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_FLAGS_VREFS_ID_POS	0
686355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_FLAGS_VREFS_ID	0x00000003 /* bits [1:0] */
687355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE_POS	7
688355c1513SAdrian Chadd #define IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE	0x00000080 /* bits [7:7] */
689355c1513SAdrian Chadd 
690355c1513SAdrian Chadd /*****************************************************************************
691355c1513SAdrian Chadd  *                        MSIX related registers                             *
692355c1513SAdrian Chadd  *****************************************************************************/
693355c1513SAdrian Chadd 
694355c1513SAdrian Chadd #define IWM_CSR_MSIX_BASE			(0x2000)
695355c1513SAdrian Chadd #define IWM_CSR_MSIX_FH_INT_CAUSES_AD		(IWM_CSR_MSIX_BASE + 0x800)
696355c1513SAdrian Chadd #define IWM_CSR_MSIX_FH_INT_MASK_AD		(IWM_CSR_MSIX_BASE + 0x804)
697355c1513SAdrian Chadd #define IWM_CSR_MSIX_HW_INT_CAUSES_AD		(IWM_CSR_MSIX_BASE + 0x808)
698355c1513SAdrian Chadd #define IWM_CSR_MSIX_HW_INT_MASK_AD		(IWM_CSR_MSIX_BASE + 0x80C)
699355c1513SAdrian Chadd #define IWM_CSR_MSIX_AUTOMASK_ST_AD		(IWM_CSR_MSIX_BASE + 0x810)
700355c1513SAdrian Chadd #define IWM_CSR_MSIX_RX_IVAR_AD_REG		(IWM_CSR_MSIX_BASE + 0x880)
701355c1513SAdrian Chadd #define IWM_CSR_MSIX_IVAR_AD_REG		(IWM_CSR_MSIX_BASE + 0x890)
702355c1513SAdrian Chadd #define IWM_CSR_MSIX_PENDING_PBA_AD		(IWM_CSR_MSIX_BASE + 0x1000)
703355c1513SAdrian Chadd #define IWM_CSR_MSIX_RX_IVAR(cause)		(IWM_CSR_MSIX_RX_IVAR_AD_REG + (cause))
704355c1513SAdrian Chadd #define IWM_CSR_MSIX_IVAR(cause)		(IWM_CSR_MSIX_IVAR_AD_REG + (cause))
705355c1513SAdrian Chadd 
706355c1513SAdrian Chadd /*
707355c1513SAdrian Chadd  * Causes for the FH register interrupts
708355c1513SAdrian Chadd  */
709355c1513SAdrian Chadd enum msix_fh_int_causes {
710355c1513SAdrian Chadd 	IWM_MSIX_FH_INT_CAUSES_Q0		= (1 << 0),
711355c1513SAdrian Chadd 	IWM_MSIX_FH_INT_CAUSES_Q1		= (1 << 1),
712355c1513SAdrian Chadd 	IWM_MSIX_FH_INT_CAUSES_D2S_CH0_NUM	= (1 << 16),
713355c1513SAdrian Chadd 	IWM_MSIX_FH_INT_CAUSES_D2S_CH1_NUM	= (1 << 17),
714355c1513SAdrian Chadd 	IWM_MSIX_FH_INT_CAUSES_S2D		= (1 << 19),
715355c1513SAdrian Chadd 	IWM_MSIX_FH_INT_CAUSES_FH_ERR		= (1 << 21),
716d4886179SRui Paulo };
717d4886179SRui Paulo 
718d4886179SRui Paulo /*
719d4886179SRui Paulo  * END iwl-csr.h
720d4886179SRui Paulo  */
721d4886179SRui Paulo 
722d4886179SRui Paulo /*
723d4886179SRui Paulo  * BEGIN iwl-fw.h
724d4886179SRui Paulo  */
725d4886179SRui Paulo 
726355c1513SAdrian Chadd /*
727355c1513SAdrian Chadd  * Causes for the HW register interrupts
728355c1513SAdrian Chadd  */
729355c1513SAdrian Chadd enum msix_hw_int_causes {
730355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_ALIVE	= (1 << 0),
731355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_WAKEUP	= (1 << 1),
732355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_IPC		= (1 << 1),
733355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_IML		= (1 << 2),
734355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_SW_ERR_V2	= (1 << 5),
735355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_CT_KILL	= (1 << 6),
736355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_RF_KILL	= (1 << 7),
737355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_PERIODIC	= (1 << 8),
738355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_SW_ERR	= (1 << 25),
739355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_SCD		= (1 << 26),
740355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_FH_TX	= (1 << 27),
741355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_HW_ERR	= (1 << 29),
742355c1513SAdrian Chadd 	IWM_MSIX_HW_INT_CAUSES_REG_HAP		= (1 << 30),
743355c1513SAdrian Chadd };
744355c1513SAdrian Chadd 
745355c1513SAdrian Chadd /*
746355c1513SAdrian Chadd  * Registers to map causes to vectors
747355c1513SAdrian Chadd  */
748355c1513SAdrian Chadd enum msix_ivar_for_cause {
749355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_D2S_CH0_NUM		= 0x0,
750355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_D2S_CH1_NUM		= 0x1,
751355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_S2D			= 0x3,
752355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_FH_ERR		= 0x5,
753355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_ALIVE		= 0x10,
754355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_WAKEUP		= 0x11,
755355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_IML		= 0x12,
756355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_CT_KILL		= 0x16,
757355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_RF_KILL		= 0x17,
758355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_PERIODIC	= 0x18,
759355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_SW_ERR		= 0x29,
760355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_SCD		= 0x2a,
761355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_FH_TX		= 0x2b,
762355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_HW_ERR		= 0x2d,
763355c1513SAdrian Chadd 	IWM_MSIX_IVAR_CAUSE_REG_HAP		= 0x2e,
764355c1513SAdrian Chadd };
765355c1513SAdrian Chadd 
766355c1513SAdrian Chadd #define IWM_MSIX_AUTO_CLEAR_CAUSE		(0 << 7)
767355c1513SAdrian Chadd #define IWM_MSIX_NON_AUTO_CLEAR_CAUSE		(1 << 7)
768355c1513SAdrian Chadd 
769d4886179SRui Paulo /**
770355c1513SAdrian Chadd  * uCode API flags
771d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
772d4886179SRui Paulo  *	was a separate TLV but moved here to save space.
773d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
774d4886179SRui Paulo  *	treats good CRC threshold as a boolean
775d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
776355c1513SAdrian Chadd  * @IWM_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
777355c1513SAdrian Chadd  * @IWM_UCODE_TLV_FLAGS_DW_BC_TABLE: The SCD byte count table is in DWORDS
778d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_UAPSD: This uCode image supports uAPSD
779d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_SHORT_BL: 16 entries of black list instead of 64 in scan
780d4886179SRui Paulo  *	offload profile config command.
781d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS: D3 image supports up to six
782d4886179SRui Paulo  *	(rather than two) IPv6 addresses
783d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_NO_BASIC_SSID: not sending a probe with the SSID element
784d4886179SRui Paulo  *	from the probe request template.
785d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL: new NS offload (small version)
786d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE: new NS offload (large version)
787355c1513SAdrian Chadd  * @IWM_UCODE_TLV_FLAGS_P2P_PS: P2P client power save is supported (only on a
788355c1513SAdrian Chadd  *	single bound interface).
7896a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD
7906a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS.
791d4886179SRui Paulo  * @IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save
7926a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering.
793355c1513SAdrian Chadd  * @IWM_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients
794355c1513SAdrian Chadd  *
795d4886179SRui Paulo  */
796355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_PAN			(1 << 0)
797355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_NEWSCAN		(1 << 1)
798355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_MFP			(1 << 2)
799355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_P2P			(1 << 3)
800355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_DW_BC_TABLE		(1 << 4)
801355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_SHORT_BL		(1 << 7)
802355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS	(1 << 10)
803355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_NO_BASIC_SSID	(1 << 12)
804355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL	(1 << 15)
805355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE	(1 << 16)
806355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_P2P_PS		(1 << 21)
807355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM	(1 << 22)
808355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM	(1 << 23)
809355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT	(1 << 24)
810355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_EBS_SUPPORT		(1 << 25)
811355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD	(1 << 26)
812355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_BCAST_FILTERING	(1 << 29)
813355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_GO_UAPSD		(1 << 30)
814355c1513SAdrian Chadd #define IWM_UCODE_TLV_FLAGS_LTE_COEX		(1U << 31)
8156a5bc1d1SSean Bruno 
8166a5bc1d1SSean Bruno #define IWM_UCODE_TLV_FLAG_BITS \
817355c1513SAdrian Chadd 	"\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERGY\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFFL_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX"
8186a5bc1d1SSean Bruno 
8196a5bc1d1SSean Bruno /**
820355c1513SAdrian Chadd  * uCode TLV api
8216a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time
8226a5bc1d1SSean Bruno  *	longer than the passive one, which is essential for fragmented scan.
8236a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source.
824355c1513SAdrian Chadd  * @IWM_UCODE_TLV_API_WIDE_CMD_HDR: ucode supports wide command header
8256a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params
8269dd27490SMark Johnston  * @IWM_UCODE_TLV_API_NEW_VERSION: new versioning format
827355c1513SAdrian Chadd  * @IWM_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size
828355c1513SAdrian Chadd  *	(command version 3) that supports per-chain limits
8299dd27490SMark Johnston  * @IWM_UCODE_TLV_API_SCAN_TSF_REPORT: Scan start time reported in scan
8309dd27490SMark Johnston  *	iteration complete notification, and the timestamp reported for RX
8319dd27490SMark Johnston  *	received during scan, are reported in TSF of the mac specified in the
8329dd27490SMark Johnston  *	scan request.
8339dd27490SMark Johnston  * @IWM_UCODE_TLV_API_TKIP_MIC_KEYS: This ucode supports version 2 of
8349dd27490SMark Johnston  *	ADD_MODIFY_STA_KEY_API_S_VER_2.
8359dd27490SMark Johnston  * @IWM_UCODE_TLV_API_STA_TYPE: This ucode supports station type assignement.
836355c1513SAdrian Chadd  * @IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY: scan APIs use 8-level priority
837355c1513SAdrian Chadd  *	instead of 3.
8389dd27490SMark Johnston  * @IWM_UCODE_TLV_API_NEW_RX_STATS: should new RX STATISTICS API be used
8396a5bc1d1SSean Bruno  *
8406a5bc1d1SSean Bruno  * @IWM_NUM_UCODE_TLV_API: number of bits used
8416a5bc1d1SSean Bruno  */
842355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_FRAGMENTED_SCAN	8
843355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_WIFI_MCC_UPDATE	9
844355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_WIDE_CMD_HDR		14
845355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_LQ_SS_PARAMS		18
846355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_NEW_VERSION		20
847355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY	24
848355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_TX_POWER_CHAIN	27
849355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_SCAN_TSF_REPORT	28
850355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_TKIP_MIC_KEYS         29
851355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_STA_TYPE		30
852355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_NAN2_VER2		31
853355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_ADAPTIVE_DWELL	32
854355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_NEW_RX_STATS		35
855355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_QUOTA_LOW_LATENCY	38
856355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_ADAPTIVE_DWELL_V2	42
857355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_SCAN_EXT_CHAN_VER	58
858355c1513SAdrian Chadd #define IWM_NUM_UCODE_TLV_API			128
8596a5bc1d1SSean Bruno 
860355c1513SAdrian Chadd #define IWM_UCODE_TLV_API_BITS \
861355c1513SAdrian Chadd 	"\020\10FRAGMENTED_SCAN\11WIFI_MCC_UPDATE\16WIDE_CMD_HDR\22LQ_SS_PARAMS\30EXT_SCAN_PRIO\33TX_POWER_CHAIN\35TKIP_MIC_KEYS"
8626a5bc1d1SSean Bruno 
8636a5bc1d1SSean Bruno /**
864355c1513SAdrian Chadd  * uCode capabilities
8656a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_D0I3_SUPPORT: supports D0i3
8666a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_LAR_SUPPORT: supports Location Aware Regulatory
8676a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_UMAC_SCAN: supports UMAC scan.
8686a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_BEAMFORMER: supports Beamformer
8696a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_TOF_SUPPORT: supports Time of Flight (802.11mc FTM)
8706a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_TDLS_SUPPORT: support basic TDLS functionality
8716a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT: supports insertion of current
8726a5bc1d1SSean Bruno  *	tx power value into TPC Report action frame and Link Measurement Report
8736a5bc1d1SSean Bruno  *	action frame
8746a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT: supports updating current
8756a5bc1d1SSean Bruno  *	channel in DS parameter set element in probe requests.
8766a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT: supports adding TPC Report IE in
8776a5bc1d1SSean Bruno  *	probe requests.
8786a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT: supports Quiet Period requests
8796a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_DQA_SUPPORT: supports dynamic queue allocation (DQA),
8806a5bc1d1SSean Bruno  *	which also implies support for the scheduler configuration command
8816a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH: supports TDLS channel switching
8826a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG: Consolidated D3-D0 image
8836a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_HOTSPOT_SUPPORT: supports Hot Spot Command
8846a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_DC2DC_SUPPORT: supports DC2DC Command
8856a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_2G_COEX_SUPPORT: supports 2G coex Command
8866a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_CSUM_SUPPORT: supports TCP Checksum Offload
8876a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_RADIO_BEACON_STATS: support radio and beacon statistics
8886a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_P2P_STANDALONE_UAPSD: support p2p standalone U-APSD
8896a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_BT_COEX_PLCR: enabled BT Coex packet level co-running
8906a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_LAR_MULTI_MCC: ucode supports LAR updates with different
8916a5bc1d1SSean Bruno  *	sources for the MCC. This TLV bit is a future replacement to
8926a5bc1d1SSean Bruno  *	IWM_UCODE_TLV_API_WIFI_MCC_UPDATE. When either is set, multi-source LAR
8936a5bc1d1SSean Bruno  *	is supported.
8946a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_BT_COEX_RRC: supports BT Coex RRC
8956a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan
8966a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_NAN_SUPPORT: supports NAN
8976a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_UMAC_UPLOAD: supports upload mode in umac (1=supported,
8986a5bc1d1SSean Bruno  *	0=no support)
8996a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE: extended DTS measurement
9006a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS: supports short PM timeouts
9016a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT: supports bt-coex Multi-priority LUT
9026a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION: firmware will decide on what
9036a5bc1d1SSean Bruno  *	antenna the beacon should be transmitted
9046a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_BEACON_STORING: firmware will store the latest beacon
9056a5bc1d1SSean Bruno  *	from AP and will send it upon d0i3 exit.
9066a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2: support LAR API V2
9076a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW: firmware responsible for CT-kill
9086a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT: supports temperature
9096a5bc1d1SSean Bruno  *	thresholds reporting
9106a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_CTDP_SUPPORT: supports cTDP command
9116a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED: supports usniffer enabled in
9126a5bc1d1SSean Bruno  *	regular image.
9136a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG: support getting more shared
9146a5bc1d1SSean Bruno  *	memory addresses from the firmware.
9156a5bc1d1SSean Bruno  * @IWM_UCODE_TLV_CAPA_LQM_SUPPORT: supports Link Quality Measurement
916355c1513SAdrian Chadd  * @IWM_UCODE_TLV_CAPA_LMAC_UPLOAD: supports upload mode in lmac (1=supported,
917355c1513SAdrian Chadd  *	0=no support)
9186a5bc1d1SSean Bruno  *
9196a5bc1d1SSean Bruno  * @IWM_NUM_UCODE_TLV_CAPA: number of bits used
9206a5bc1d1SSean Bruno  */
921355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_D0I3_SUPPORT			0
922355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_LAR_SUPPORT			1
923355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_UMAC_SCAN			2
924355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BEAMFORMER			3
925355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_TOF_SUPPORT                  5
926355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_TDLS_SUPPORT			6
927355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT	8
928355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT	9
929355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT	10
930355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT		11
931355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_DQA_SUPPORT			12
932355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH		13
933355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG		17
934355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_HOTSPOT_SUPPORT		18
935355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_DC2DC_CONFIG_SUPPORT		19
936355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_2G_COEX_SUPPORT		20
937355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_CSUM_SUPPORT			21
938355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_RADIO_BEACON_STATS		22
939355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_P2P_STANDALONE_UAPSD		26
940355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BT_COEX_PLCR			28
941355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_LAR_MULTI_MCC		29
942355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BT_COEX_RRC			30
943355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_GSCAN_SUPPORT		31
944355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_NAN_SUPPORT			34
945355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_UMAC_UPLOAD			35
946355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_SOC_LATENCY_SUPPORT		37
947355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BINDING_CDB_SUPPORT		39
948355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_CDB_SUPPORT			40
949355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_DYNAMIC_QUOTA                44
950355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS		48
951355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE		64
952355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS		65
953355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT		67
954355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT	68
955355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION		71
956355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_BEACON_STORING		72
957355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2		73
958355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW		74
959355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT	75
960355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_CTDP_SUPPORT			76
961355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED		77
962355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_LMAC_UPLOAD			79
963355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG	80
964355c1513SAdrian Chadd #define IWM_UCODE_TLV_CAPA_LQM_SUPPORT			81
9656a5bc1d1SSean Bruno 
966355c1513SAdrian Chadd #define IWM_NUM_UCODE_TLV_CAPA 128
967d4886179SRui Paulo 
968d4886179SRui Paulo /* The default calibrate table size if not specified by firmware file */
969d4886179SRui Paulo #define IWM_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE	18
970d4886179SRui Paulo #define IWM_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE		19
971d4886179SRui Paulo #define IWM_MAX_PHY_CALIBRATE_TBL_SIZE			253
972d4886179SRui Paulo 
973d4886179SRui Paulo /* The default max probe length if not specified by the firmware file */
974d4886179SRui Paulo #define IWM_DEFAULT_MAX_PROBE_LENGTH	200
975d4886179SRui Paulo 
976d4886179SRui Paulo /*
977d4886179SRui Paulo  * For 16.0 uCode and above, there is no differentiation between sections,
978d4886179SRui Paulo  * just an offset to the HW address.
979d4886179SRui Paulo  */
9806a5bc1d1SSean Bruno #define IWM_CPU1_CPU2_SEPARATOR_SECTION		0xFFFFCCCC
9816a5bc1d1SSean Bruno #define IWM_PAGING_SEPARATOR_SECTION		0xAAAABBBB
982d4886179SRui Paulo 
983d4886179SRui Paulo /* uCode version contains 4 values: Major/Minor/API/Serial */
984d4886179SRui Paulo #define IWM_UCODE_MAJOR(ver)	(((ver) & 0xFF000000) >> 24)
985d4886179SRui Paulo #define IWM_UCODE_MINOR(ver)	(((ver) & 0x00FF0000) >> 16)
986d4886179SRui Paulo #define IWM_UCODE_API(ver)	(((ver) & 0x0000FF00) >> 8)
987d4886179SRui Paulo #define IWM_UCODE_SERIAL(ver)	((ver) & 0x000000FF)
988d4886179SRui Paulo 
989d4886179SRui Paulo /*
990d4886179SRui Paulo  * Calibration control struct.
991d4886179SRui Paulo  * Sent as part of the phy configuration command.
992d4886179SRui Paulo  * @flow_trigger: bitmap for which calibrations to perform according to
993d4886179SRui Paulo  *		flow triggers.
994d4886179SRui Paulo  * @event_trigger: bitmap for which calibrations to perform according to
995d4886179SRui Paulo  *		event triggers.
996d4886179SRui Paulo  */
997d4886179SRui Paulo struct iwm_tlv_calib_ctrl {
998d4886179SRui Paulo 	uint32_t flow_trigger;
999d4886179SRui Paulo 	uint32_t event_trigger;
1000d4886179SRui Paulo } __packed;
1001d4886179SRui Paulo 
1002355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RADIO_TYPE_POS	0
1003355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RADIO_TYPE	(0x3 << IWM_FW_PHY_CFG_RADIO_TYPE_POS)
1004355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RADIO_STEP_POS	2
1005355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RADIO_STEP	(0x3 << IWM_FW_PHY_CFG_RADIO_STEP_POS)
1006355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RADIO_DASH_POS	4
1007355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RADIO_DASH	(0x3 << IWM_FW_PHY_CFG_RADIO_DASH_POS)
1008355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_TX_CHAIN_POS	16
1009355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_TX_CHAIN		(0xf << IWM_FW_PHY_CFG_TX_CHAIN_POS)
1010355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RX_CHAIN_POS	20
1011355c1513SAdrian Chadd #define IWM_FW_PHY_CFG_RX_CHAIN		(0xf << IWM_FW_PHY_CFG_RX_CHAIN_POS)
1012d4886179SRui Paulo 
1013d4886179SRui Paulo #define IWM_UCODE_MAX_CS		1
1014d4886179SRui Paulo 
1015d4886179SRui Paulo /**
1016d4886179SRui Paulo  * struct iwm_fw_cipher_scheme - a cipher scheme supported by FW.
1017d4886179SRui Paulo  * @cipher: a cipher suite selector
1018d4886179SRui Paulo  * @flags: cipher scheme flags (currently reserved for a future use)
1019d4886179SRui Paulo  * @hdr_len: a size of MPDU security header
1020d4886179SRui Paulo  * @pn_len: a size of PN
1021d4886179SRui Paulo  * @pn_off: an offset of pn from the beginning of the security header
1022d4886179SRui Paulo  * @key_idx_off: an offset of key index byte in the security header
1023d4886179SRui Paulo  * @key_idx_mask: a bit mask of key_idx bits
1024d4886179SRui Paulo  * @key_idx_shift: bit shift needed to get key_idx
1025d4886179SRui Paulo  * @mic_len: mic length in bytes
1026d4886179SRui Paulo  * @hw_cipher: a HW cipher index used in host commands
1027d4886179SRui Paulo  */
1028d4886179SRui Paulo struct iwm_fw_cipher_scheme {
1029d4886179SRui Paulo 	uint32_t cipher;
1030d4886179SRui Paulo 	uint8_t flags;
1031d4886179SRui Paulo 	uint8_t hdr_len;
1032d4886179SRui Paulo 	uint8_t pn_len;
1033d4886179SRui Paulo 	uint8_t pn_off;
1034d4886179SRui Paulo 	uint8_t key_idx_off;
1035d4886179SRui Paulo 	uint8_t key_idx_mask;
1036d4886179SRui Paulo 	uint8_t key_idx_shift;
1037d4886179SRui Paulo 	uint8_t mic_len;
1038d4886179SRui Paulo 	uint8_t hw_cipher;
1039d4886179SRui Paulo } __packed;
1040d4886179SRui Paulo 
1041d4886179SRui Paulo /**
1042d4886179SRui Paulo  * struct iwm_fw_cscheme_list - a cipher scheme list
1043d4886179SRui Paulo  * @size: a number of entries
1044d4886179SRui Paulo  * @cs: cipher scheme entries
1045d4886179SRui Paulo  */
1046d4886179SRui Paulo struct iwm_fw_cscheme_list {
1047d4886179SRui Paulo 	uint8_t size;
1048d4886179SRui Paulo 	struct iwm_fw_cipher_scheme cs[];
1049d4886179SRui Paulo } __packed;
1050d4886179SRui Paulo 
1051d4886179SRui Paulo /*
1052d4886179SRui Paulo  * END iwl-fw.h
1053d4886179SRui Paulo  */
1054d4886179SRui Paulo 
1055d4886179SRui Paulo /*
1056d4886179SRui Paulo  * BEGIN iwl-fw-file.h
1057d4886179SRui Paulo  */
1058d4886179SRui Paulo 
1059d4886179SRui Paulo /* v1/v2 uCode file layout */
1060d4886179SRui Paulo struct iwm_ucode_header {
1061d4886179SRui Paulo 	uint32_t ver;	/* major/minor/API/serial */
1062d4886179SRui Paulo 	union {
1063d4886179SRui Paulo 		struct {
1064d4886179SRui Paulo 			uint32_t inst_size;	/* bytes of runtime code */
1065d4886179SRui Paulo 			uint32_t data_size;	/* bytes of runtime data */
1066d4886179SRui Paulo 			uint32_t init_size;	/* bytes of init code */
1067d4886179SRui Paulo 			uint32_t init_data_size;	/* bytes of init data */
1068d4886179SRui Paulo 			uint32_t boot_size;	/* bytes of bootstrap code */
1069d4886179SRui Paulo 			uint8_t data[0];		/* in same order as sizes */
1070d4886179SRui Paulo 		} v1;
1071d4886179SRui Paulo 		struct {
1072d4886179SRui Paulo 			uint32_t build;		/* build number */
1073d4886179SRui Paulo 			uint32_t inst_size;	/* bytes of runtime code */
1074d4886179SRui Paulo 			uint32_t data_size;	/* bytes of runtime data */
1075d4886179SRui Paulo 			uint32_t init_size;	/* bytes of init code */
1076d4886179SRui Paulo 			uint32_t init_data_size;	/* bytes of init data */
1077d4886179SRui Paulo 			uint32_t boot_size;	/* bytes of bootstrap code */
1078d4886179SRui Paulo 			uint8_t data[0];		/* in same order as sizes */
1079d4886179SRui Paulo 		} v2;
1080d4886179SRui Paulo 	} u;
1081d4886179SRui Paulo };
1082d4886179SRui Paulo 
1083d4886179SRui Paulo /*
1084d4886179SRui Paulo  * new TLV uCode file layout
1085d4886179SRui Paulo  *
1086d4886179SRui Paulo  * The new TLV file format contains TLVs, that each specify
1087d4886179SRui Paulo  * some piece of data.
1088d4886179SRui Paulo  */
1089d4886179SRui Paulo 
1090d4886179SRui Paulo enum iwm_ucode_tlv_type {
1091d4886179SRui Paulo 	IWM_UCODE_TLV_INVALID		= 0, /* unused */
1092d4886179SRui Paulo 	IWM_UCODE_TLV_INST		= 1,
1093d4886179SRui Paulo 	IWM_UCODE_TLV_DATA		= 2,
1094d4886179SRui Paulo 	IWM_UCODE_TLV_INIT		= 3,
1095d4886179SRui Paulo 	IWM_UCODE_TLV_INIT_DATA		= 4,
1096d4886179SRui Paulo 	IWM_UCODE_TLV_BOOT		= 5,
1097d4886179SRui Paulo 	IWM_UCODE_TLV_PROBE_MAX_LEN	= 6, /* a uint32_t value */
1098d4886179SRui Paulo 	IWM_UCODE_TLV_PAN		= 7,
1099d4886179SRui Paulo 	IWM_UCODE_TLV_RUNT_EVTLOG_PTR	= 8,
1100d4886179SRui Paulo 	IWM_UCODE_TLV_RUNT_EVTLOG_SIZE	= 9,
1101d4886179SRui Paulo 	IWM_UCODE_TLV_RUNT_ERRLOG_PTR	= 10,
1102d4886179SRui Paulo 	IWM_UCODE_TLV_INIT_EVTLOG_PTR	= 11,
1103d4886179SRui Paulo 	IWM_UCODE_TLV_INIT_EVTLOG_SIZE	= 12,
1104d4886179SRui Paulo 	IWM_UCODE_TLV_INIT_ERRLOG_PTR	= 13,
1105d4886179SRui Paulo 	IWM_UCODE_TLV_ENHANCE_SENS_TBL	= 14,
1106d4886179SRui Paulo 	IWM_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
1107d4886179SRui Paulo 	IWM_UCODE_TLV_WOWLAN_INST	= 16,
1108d4886179SRui Paulo 	IWM_UCODE_TLV_WOWLAN_DATA	= 17,
1109d4886179SRui Paulo 	IWM_UCODE_TLV_FLAGS		= 18,
1110d4886179SRui Paulo 	IWM_UCODE_TLV_SEC_RT		= 19,
1111d4886179SRui Paulo 	IWM_UCODE_TLV_SEC_INIT		= 20,
1112d4886179SRui Paulo 	IWM_UCODE_TLV_SEC_WOWLAN	= 21,
1113d4886179SRui Paulo 	IWM_UCODE_TLV_DEF_CALIB		= 22,
1114d4886179SRui Paulo 	IWM_UCODE_TLV_PHY_SKU		= 23,
1115d4886179SRui Paulo 	IWM_UCODE_TLV_SECURE_SEC_RT	= 24,
1116d4886179SRui Paulo 	IWM_UCODE_TLV_SECURE_SEC_INIT	= 25,
1117d4886179SRui Paulo 	IWM_UCODE_TLV_SECURE_SEC_WOWLAN	= 26,
1118d4886179SRui Paulo 	IWM_UCODE_TLV_NUM_OF_CPU	= 27,
1119d4886179SRui Paulo 	IWM_UCODE_TLV_CSCHEME		= 28,
1120d4886179SRui Paulo 	/*
1121d4886179SRui Paulo 	 * Following two are not in our base tag, but allow
1122d4886179SRui Paulo 	 * handling ucode version 9.
1123d4886179SRui Paulo 	 */
1124d4886179SRui Paulo 	IWM_UCODE_TLV_API_CHANGES_SET	= 29,
11256a5bc1d1SSean Bruno 	IWM_UCODE_TLV_ENABLED_CAPABILITIES = 30,
11266a5bc1d1SSean Bruno 	IWM_UCODE_TLV_N_SCAN_CHANNELS	= 31,
11276a5bc1d1SSean Bruno 	IWM_UCODE_TLV_PAGING		= 32,
11286a5bc1d1SSean Bruno 	IWM_UCODE_TLV_SEC_RT_USNIFFER	= 34,
11296a5bc1d1SSean Bruno 	IWM_UCODE_TLV_SDIO_ADMA_ADDR	= 35,
11306a5bc1d1SSean Bruno 	IWM_UCODE_TLV_FW_VERSION	= 36,
11316a5bc1d1SSean Bruno 	IWM_UCODE_TLV_FW_DBG_DEST	= 38,
11326a5bc1d1SSean Bruno 	IWM_UCODE_TLV_FW_DBG_CONF	= 39,
11336a5bc1d1SSean Bruno 	IWM_UCODE_TLV_FW_DBG_TRIGGER	= 40,
1134267c626fSMark Johnston 	IWM_UCODE_TLV_CMD_VERSIONS	= 48,
11356a5bc1d1SSean Bruno 	IWM_UCODE_TLV_FW_GSCAN_CAPA	= 50,
113600da8199SAdrian Chadd 	IWM_UCODE_TLV_FW_MEM_SEG	= 51,
1137355c1513SAdrian Chadd 	IWM_UCODE_TLV_UMAC_DEBUG_ADDRS	= 54,
1138355c1513SAdrian Chadd 	IWM_UCODE_TLV_LMAC_DEBUG_ADDRS	= 55,
1139355c1513SAdrian Chadd 	IWM_UCODE_TLV_HW_TYPE		= 58,
1140d4886179SRui Paulo };
1141d4886179SRui Paulo 
1142355c1513SAdrian Chadd #define IWM_UCODE_TLV_DEBUG_BASE		0x1000005
1143355c1513SAdrian Chadd #define IWM_UCODE_TLV_TYPE_DEBUG_INFO		(IWM_UCODE_TLV_DEBUG_BASE + 0)
1144355c1513SAdrian Chadd #define IWM_UCODE_TLV_TYPE_BUFFER_ALLOCATION	(IWM_UCODE_TLV_DEBUG_BASE + 1)
1145355c1513SAdrian Chadd #define IWM_UCODE_TLV_TYPE_HCMD			(IWM_UCODE_TLV_DEBUG_BASE + 2)
1146355c1513SAdrian Chadd #define IWM_UCODE_TLV_TYPE_REGIONS		(IWM_UCODE_TLV_DEBUG_BASE + 3)
1147355c1513SAdrian Chadd #define IWM_UCODE_TLV_TYPE_TRIGGERS		(IWM_UCODE_TLV_DEBUG_BASE + 4)
1148355c1513SAdrian Chadd #define IWM_UCODE_TLV_DEBUG_MAX			IWM_UCODE_TLV_TYPE_TRIGGERS
1149355c1513SAdrian Chadd 
1150d4886179SRui Paulo struct iwm_ucode_tlv {
1151d4886179SRui Paulo 	uint32_t type;		/* see above */
1152d4886179SRui Paulo 	uint32_t length;		/* not including type/length fields */
1153d4886179SRui Paulo 	uint8_t data[0];
1154d4886179SRui Paulo };
1155d4886179SRui Paulo 
11566a5bc1d1SSean Bruno struct iwm_ucode_api {
11576a5bc1d1SSean Bruno 	uint32_t api_index;
11586a5bc1d1SSean Bruno 	uint32_t api_flags;
11596a5bc1d1SSean Bruno } __packed;
11606a5bc1d1SSean Bruno 
11616a5bc1d1SSean Bruno struct iwm_ucode_capa {
11626a5bc1d1SSean Bruno 	uint32_t api_index;
11636a5bc1d1SSean Bruno 	uint32_t api_capa;
11646a5bc1d1SSean Bruno } __packed;
11656a5bc1d1SSean Bruno 
1166d4886179SRui Paulo #define IWM_TLV_UCODE_MAGIC	0x0a4c5749
1167d4886179SRui Paulo 
1168d4886179SRui Paulo struct iwm_tlv_ucode_header {
1169d4886179SRui Paulo 	/*
1170d4886179SRui Paulo 	 * The TLV style ucode header is distinguished from
1171d4886179SRui Paulo 	 * the v1/v2 style header by first four bytes being
1172d4886179SRui Paulo 	 * zero, as such is an invalid combination of
1173d4886179SRui Paulo 	 * major/minor/API/serial versions.
1174d4886179SRui Paulo 	 */
1175d4886179SRui Paulo 	uint32_t zero;
1176d4886179SRui Paulo 	uint32_t magic;
1177d4886179SRui Paulo 	uint8_t human_readable[64];
1178d4886179SRui Paulo 	uint32_t ver;		/* major/minor/API/serial */
1179d4886179SRui Paulo 	uint32_t build;
1180d4886179SRui Paulo 	uint64_t ignore;
1181d4886179SRui Paulo 	/*
1182d4886179SRui Paulo 	 * The data contained herein has a TLV layout,
1183d4886179SRui Paulo 	 * see above for the TLV header and types.
1184d4886179SRui Paulo 	 * Note that each TLV is padded to a length
1185d4886179SRui Paulo 	 * that is a multiple of 4 for alignment.
1186d4886179SRui Paulo 	 */
1187d4886179SRui Paulo 	uint8_t data[0];
1188d4886179SRui Paulo };
1189d4886179SRui Paulo 
1190d4886179SRui Paulo /*
1191d4886179SRui Paulo  * END iwl-fw-file.h
1192d4886179SRui Paulo  */
1193d4886179SRui Paulo 
1194d4886179SRui Paulo /*
1195d4886179SRui Paulo  * BEGIN iwl-prph.h
1196d4886179SRui Paulo  */
1197d4886179SRui Paulo 
1198d4886179SRui Paulo /*
1199d4886179SRui Paulo  * Registers in this file are internal, not PCI bus memory mapped.
1200d4886179SRui Paulo  * Driver accesses these via IWM_HBUS_TARG_PRPH_* registers.
1201d4886179SRui Paulo  */
1202d4886179SRui Paulo #define IWM_PRPH_BASE	(0x00000)
1203d4886179SRui Paulo #define IWM_PRPH_END	(0xFFFFF)
1204d4886179SRui Paulo 
1205d4886179SRui Paulo /* APMG (power management) constants */
1206d4886179SRui Paulo #define IWM_APMG_BASE			(IWM_PRPH_BASE + 0x3000)
1207d4886179SRui Paulo #define IWM_APMG_CLK_CTRL_REG		(IWM_APMG_BASE + 0x0000)
1208d4886179SRui Paulo #define IWM_APMG_CLK_EN_REG		(IWM_APMG_BASE + 0x0004)
1209d4886179SRui Paulo #define IWM_APMG_CLK_DIS_REG		(IWM_APMG_BASE + 0x0008)
1210d4886179SRui Paulo #define IWM_APMG_PS_CTRL_REG		(IWM_APMG_BASE + 0x000c)
1211d4886179SRui Paulo #define IWM_APMG_PCIDEV_STT_REG		(IWM_APMG_BASE + 0x0010)
1212d4886179SRui Paulo #define IWM_APMG_RFKILL_REG		(IWM_APMG_BASE + 0x0014)
1213d4886179SRui Paulo #define IWM_APMG_RTC_INT_STT_REG	(IWM_APMG_BASE + 0x001c)
1214d4886179SRui Paulo #define IWM_APMG_RTC_INT_MSK_REG	(IWM_APMG_BASE + 0x0020)
1215d4886179SRui Paulo #define IWM_APMG_DIGITAL_SVR_REG	(IWM_APMG_BASE + 0x0058)
1216d4886179SRui Paulo #define IWM_APMG_ANALOG_SVR_REG		(IWM_APMG_BASE + 0x006C)
1217d4886179SRui Paulo 
1218d4886179SRui Paulo #define IWM_APMS_CLK_VAL_MRB_FUNC_MODE	(0x00000001)
1219d4886179SRui Paulo #define IWM_APMG_CLK_VAL_DMA_CLK_RQT	(0x00000200)
1220d4886179SRui Paulo #define IWM_APMG_CLK_VAL_BSM_CLK_RQT	(0x00000800)
1221d4886179SRui Paulo 
1222d4886179SRui Paulo #define IWM_APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS	(0x00400000)
1223d4886179SRui Paulo #define IWM_APMG_PS_CTRL_VAL_RESET_REQ			(0x04000000)
1224d4886179SRui Paulo #define IWM_APMG_PS_CTRL_MSK_PWR_SRC			(0x03000000)
1225d4886179SRui Paulo #define IWM_APMG_PS_CTRL_VAL_PWR_SRC_VMAIN		(0x00000000)
1226d4886179SRui Paulo #define IWM_APMG_PS_CTRL_VAL_PWR_SRC_VAUX		(0x02000000)
1227d4886179SRui Paulo #define IWM_APMG_SVR_VOLTAGE_CONFIG_BIT_MSK		(0x000001E0) /* bit 8:5 */
1228d4886179SRui Paulo #define IWM_APMG_SVR_DIGITAL_VOLTAGE_1_32		(0x00000060)
1229d4886179SRui Paulo 
1230d4886179SRui Paulo #define IWM_APMG_PCIDEV_STT_VAL_L1_ACT_DIS		(0x00000800)
1231d4886179SRui Paulo 
1232d4886179SRui Paulo #define IWM_APMG_RTC_INT_STT_RFKILL			(0x10000000)
1233d4886179SRui Paulo 
1234d4886179SRui Paulo /* Device system time */
1235d4886179SRui Paulo #define IWM_DEVICE_SYSTEM_TIME_REG 0xA0206C
1236d4886179SRui Paulo 
1237d4886179SRui Paulo /* Device NMI register */
1238d4886179SRui Paulo #define IWM_DEVICE_SET_NMI_REG		0x00a01c30
12396a5bc1d1SSean Bruno #define IWM_DEVICE_SET_NMI_VAL_HW	0x01
12406a5bc1d1SSean Bruno #define IWM_DEVICE_SET_NMI_VAL_DRV	0x80
12416a5bc1d1SSean Bruno #define IWM_DEVICE_SET_NMI_8000_REG	0x00a01c24
12426a5bc1d1SSean Bruno #define IWM_DEVICE_SET_NMI_8000_VAL	0x1000000
12436a5bc1d1SSean Bruno 
12446a5bc1d1SSean Bruno /*
12456a5bc1d1SSean Bruno  * Device reset for family 8000
12466a5bc1d1SSean Bruno  * write to bit 24 in order to reset the CPU
12476a5bc1d1SSean Bruno */
12486a5bc1d1SSean Bruno #define IWM_RELEASE_CPU_RESET		0x300c
12496a5bc1d1SSean Bruno #define IWM_RELEASE_CPU_RESET_BIT	0x1000000
12506a5bc1d1SSean Bruno 
1251d4886179SRui Paulo 
1252d4886179SRui Paulo /*****************************************************************************
1253d4886179SRui Paulo  *                        7000/3000 series SHR DTS addresses                 *
1254d4886179SRui Paulo  *****************************************************************************/
1255d4886179SRui Paulo 
1256d4886179SRui Paulo #define IWM_SHR_MISC_WFM_DTS_EN		(0x00a10024)
1257d4886179SRui Paulo #define IWM_DTSC_CFG_MODE		(0x00a10604)
1258d4886179SRui Paulo #define IWM_DTSC_VREF_AVG		(0x00a10648)
1259d4886179SRui Paulo #define IWM_DTSC_VREF5_AVG		(0x00a1064c)
1260d4886179SRui Paulo #define IWM_DTSC_CFG_MODE_PERIODIC	(0x2)
1261d4886179SRui Paulo #define IWM_DTSC_PTAT_AVG		(0x00a10650)
1262d4886179SRui Paulo 
1263d4886179SRui Paulo 
1264d4886179SRui Paulo /**
1265d4886179SRui Paulo  * Tx Scheduler
1266d4886179SRui Paulo  *
1267d4886179SRui Paulo  * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs
1268d4886179SRui Paulo  * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in
1269d4886179SRui Paulo  * host DRAM.  It steers each frame's Tx command (which contains the frame
1270d4886179SRui Paulo  * data) into one of up to 7 prioritized Tx DMA FIFO channels within the
1271d4886179SRui Paulo  * device.  A queue maps to only one (selectable by driver) Tx DMA channel,
1272d4886179SRui Paulo  * but one DMA channel may take input from several queues.
1273d4886179SRui Paulo  *
1274d4886179SRui Paulo  * Tx DMA FIFOs have dedicated purposes.
1275d4886179SRui Paulo  *
1276d4886179SRui Paulo  * For 5000 series and up, they are used differently
1277d4886179SRui Paulo  * (cf. iwl5000_default_queue_to_tx_fifo in iwl-5000.c):
1278d4886179SRui Paulo  *
1279d4886179SRui Paulo  * 0 -- EDCA BK (background) frames, lowest priority
1280d4886179SRui Paulo  * 1 -- EDCA BE (best effort) frames, normal priority
1281d4886179SRui Paulo  * 2 -- EDCA VI (video) frames, higher priority
1282d4886179SRui Paulo  * 3 -- EDCA VO (voice) and management frames, highest priority
1283d4886179SRui Paulo  * 4 -- unused
1284d4886179SRui Paulo  * 5 -- unused
1285d4886179SRui Paulo  * 6 -- unused
1286d4886179SRui Paulo  * 7 -- Commands
1287d4886179SRui Paulo  *
1288d4886179SRui Paulo  * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
1289d4886179SRui Paulo  * In addition, driver can map the remaining queues to Tx DMA/FIFO
1290d4886179SRui Paulo  * channels 0-3 to support 11n aggregation via EDCA DMA channels.
1291d4886179SRui Paulo  *
1292d4886179SRui Paulo  * The driver sets up each queue to work in one of two modes:
1293d4886179SRui Paulo  *
1294d4886179SRui Paulo  * 1)  Scheduler-Ack, in which the scheduler automatically supports a
1295d4886179SRui Paulo  *     block-ack (BA) window of up to 64 TFDs.  In this mode, each queue
1296d4886179SRui Paulo  *     contains TFDs for a unique combination of Recipient Address (RA)
1297d4886179SRui Paulo  *     and Traffic Identifier (TID), that is, traffic of a given
1298d4886179SRui Paulo  *     Quality-Of-Service (QOS) priority, destined for a single station.
1299d4886179SRui Paulo  *
1300d4886179SRui Paulo  *     In scheduler-ack mode, the scheduler keeps track of the Tx status of
1301d4886179SRui Paulo  *     each frame within the BA window, including whether it's been transmitted,
1302d4886179SRui Paulo  *     and whether it's been acknowledged by the receiving station.  The device
1303d4886179SRui Paulo  *     automatically processes block-acks received from the receiving STA,
1304d4886179SRui Paulo  *     and reschedules un-acked frames to be retransmitted (successful
1305d4886179SRui Paulo  *     Tx completion may end up being out-of-order).
1306d4886179SRui Paulo  *
1307d4886179SRui Paulo  *     The driver must maintain the queue's Byte Count table in host DRAM
1308d4886179SRui Paulo  *     for this mode.
1309d4886179SRui Paulo  *     This mode does not support fragmentation.
1310d4886179SRui Paulo  *
1311d4886179SRui Paulo  * 2)  FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
1312d4886179SRui Paulo  *     The device may automatically retry Tx, but will retry only one frame
1313d4886179SRui Paulo  *     at a time, until receiving ACK from receiving station, or reaching
1314d4886179SRui Paulo  *     retry limit and giving up.
1315d4886179SRui Paulo  *
1316d4886179SRui Paulo  *     The command queue (#4/#9) must use this mode!
1317d4886179SRui Paulo  *     This mode does not require use of the Byte Count table in host DRAM.
1318d4886179SRui Paulo  *
1319d4886179SRui Paulo  * Driver controls scheduler operation via 3 means:
1320d4886179SRui Paulo  * 1)  Scheduler registers
1321d4886179SRui Paulo  * 2)  Shared scheduler data base in internal SRAM
1322d4886179SRui Paulo  * 3)  Shared data in host DRAM
1323d4886179SRui Paulo  *
1324d4886179SRui Paulo  * Initialization:
1325d4886179SRui Paulo  *
1326d4886179SRui Paulo  * When loading, driver should allocate memory for:
1327d4886179SRui Paulo  * 1)  16 TFD circular buffers, each with space for (typically) 256 TFDs.
1328d4886179SRui Paulo  * 2)  16 Byte Count circular buffers in 16 KBytes contiguous memory
1329d4886179SRui Paulo  *     (1024 bytes for each queue).
1330d4886179SRui Paulo  *
1331d4886179SRui Paulo  * After receiving "Alive" response from uCode, driver must initialize
1332d4886179SRui Paulo  * the scheduler (especially for queue #4/#9, the command queue, otherwise
1333d4886179SRui Paulo  * the driver can't issue commands!):
1334d4886179SRui Paulo  */
1335d4886179SRui Paulo #define IWM_SCD_MEM_LOWER_BOUND		(0x0000)
1336d4886179SRui Paulo 
1337d4886179SRui Paulo /**
1338d4886179SRui Paulo  * Max Tx window size is the max number of contiguous TFDs that the scheduler
1339d4886179SRui Paulo  * can keep track of at one time when creating block-ack chains of frames.
1340d4886179SRui Paulo  * Note that "64" matches the number of ack bits in a block-ack packet.
1341d4886179SRui Paulo  */
1342d4886179SRui Paulo #define IWM_SCD_WIN_SIZE				64
1343d4886179SRui Paulo #define IWM_SCD_FRAME_LIMIT				64
1344d4886179SRui Paulo 
1345d4886179SRui Paulo #define IWM_SCD_TXFIFO_POS_TID			(0)
1346d4886179SRui Paulo #define IWM_SCD_TXFIFO_POS_RA			(4)
1347d4886179SRui Paulo #define IWM_SCD_QUEUE_RA_TID_MAP_RATID_MSK	(0x01FF)
1348d4886179SRui Paulo 
1349d4886179SRui Paulo /* agn SCD */
1350d4886179SRui Paulo #define IWM_SCD_QUEUE_STTS_REG_POS_TXF		(0)
1351d4886179SRui Paulo #define IWM_SCD_QUEUE_STTS_REG_POS_ACTIVE	(3)
1352d4886179SRui Paulo #define IWM_SCD_QUEUE_STTS_REG_POS_WSL		(4)
1353d4886179SRui Paulo #define IWM_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN	(19)
1354d4886179SRui Paulo #define IWM_SCD_QUEUE_STTS_REG_MSK		(0x017F0000)
1355d4886179SRui Paulo 
1356d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG1_CREDIT_POS	(8)
1357d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG1_CREDIT_MSK	(0x00FFFF00)
1358d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS	(24)
1359d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK	(0xFF000000)
1360d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS	(0)
1361d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK	(0x0000007F)
1362d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
1363d4886179SRui Paulo #define IWM_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
13646a5bc1d1SSean Bruno #define IWM_SCD_GP_CTRL_ENABLE_31_QUEUES	(1 << 0)
13656a5bc1d1SSean Bruno #define IWM_SCD_GP_CTRL_AUTO_ACTIVE_MODE	(1 << 18)
1366d4886179SRui Paulo 
1367d4886179SRui Paulo /* Context Data */
1368d4886179SRui Paulo #define IWM_SCD_CONTEXT_MEM_LOWER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x600)
1369d4886179SRui Paulo #define IWM_SCD_CONTEXT_MEM_UPPER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x6A0)
1370d4886179SRui Paulo 
1371d4886179SRui Paulo /* Tx status */
1372d4886179SRui Paulo #define IWM_SCD_TX_STTS_MEM_LOWER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x6A0)
1373d4886179SRui Paulo #define IWM_SCD_TX_STTS_MEM_UPPER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x7E0)
1374d4886179SRui Paulo 
1375d4886179SRui Paulo /* Translation Data */
1376d4886179SRui Paulo #define IWM_SCD_TRANS_TBL_MEM_LOWER_BOUND (IWM_SCD_MEM_LOWER_BOUND + 0x7E0)
1377d4886179SRui Paulo #define IWM_SCD_TRANS_TBL_MEM_UPPER_BOUND (IWM_SCD_MEM_LOWER_BOUND + 0x808)
1378d4886179SRui Paulo 
1379d4886179SRui Paulo #define IWM_SCD_CONTEXT_QUEUE_OFFSET(x)\
1380d4886179SRui Paulo 	(IWM_SCD_CONTEXT_MEM_LOWER_BOUND + ((x) * 8))
1381d4886179SRui Paulo 
1382d4886179SRui Paulo #define IWM_SCD_TX_STTS_QUEUE_OFFSET(x)\
1383d4886179SRui Paulo 	(IWM_SCD_TX_STTS_MEM_LOWER_BOUND + ((x) * 16))
1384d4886179SRui Paulo 
1385d4886179SRui Paulo #define IWM_SCD_TRANS_TBL_OFFSET_QUEUE(x) \
1386d4886179SRui Paulo 	((IWM_SCD_TRANS_TBL_MEM_LOWER_BOUND + ((x) * 2)) & 0xfffc)
1387d4886179SRui Paulo 
1388d4886179SRui Paulo #define IWM_SCD_BASE			(IWM_PRPH_BASE + 0xa02c00)
1389d4886179SRui Paulo 
1390d4886179SRui Paulo #define IWM_SCD_SRAM_BASE_ADDR	(IWM_SCD_BASE + 0x0)
1391d4886179SRui Paulo #define IWM_SCD_DRAM_BASE_ADDR	(IWM_SCD_BASE + 0x8)
1392d4886179SRui Paulo #define IWM_SCD_AIT		(IWM_SCD_BASE + 0x0c)
1393d4886179SRui Paulo #define IWM_SCD_TXFACT		(IWM_SCD_BASE + 0x10)
1394d4886179SRui Paulo #define IWM_SCD_ACTIVE		(IWM_SCD_BASE + 0x14)
1395d4886179SRui Paulo #define IWM_SCD_QUEUECHAIN_SEL	(IWM_SCD_BASE + 0xe8)
1396d4886179SRui Paulo #define IWM_SCD_CHAINEXT_EN	(IWM_SCD_BASE + 0x244)
1397d4886179SRui Paulo #define IWM_SCD_AGGR_SEL	(IWM_SCD_BASE + 0x248)
1398d4886179SRui Paulo #define IWM_SCD_INTERRUPT_MASK	(IWM_SCD_BASE + 0x108)
13996a5bc1d1SSean Bruno #define IWM_SCD_GP_CTRL		(IWM_SCD_BASE + 0x1a8)
14006a5bc1d1SSean Bruno #define IWM_SCD_EN_CTRL		(IWM_SCD_BASE + 0x254)
1401d4886179SRui Paulo 
1402d4886179SRui Paulo static inline unsigned int IWM_SCD_QUEUE_WRPTR(unsigned int chnl)
1403d4886179SRui Paulo {
1404d4886179SRui Paulo 	if (chnl < 20)
1405d4886179SRui Paulo 		return IWM_SCD_BASE + 0x18 + chnl * 4;
1406d4886179SRui Paulo 	return IWM_SCD_BASE + 0x284 + (chnl - 20) * 4;
1407d4886179SRui Paulo }
1408d4886179SRui Paulo 
1409d4886179SRui Paulo static inline unsigned int IWM_SCD_QUEUE_RDPTR(unsigned int chnl)
1410d4886179SRui Paulo {
1411d4886179SRui Paulo 	if (chnl < 20)
1412d4886179SRui Paulo 		return IWM_SCD_BASE + 0x68 + chnl * 4;
1413d524e370SAdrian Chadd 	return IWM_SCD_BASE + 0x2B4 + chnl * 4;
1414d4886179SRui Paulo }
1415d4886179SRui Paulo 
1416d4886179SRui Paulo static inline unsigned int IWM_SCD_QUEUE_STATUS_BITS(unsigned int chnl)
1417d4886179SRui Paulo {
1418d4886179SRui Paulo 	if (chnl < 20)
1419d4886179SRui Paulo 		return IWM_SCD_BASE + 0x10c + chnl * 4;
1420d524e370SAdrian Chadd 	return IWM_SCD_BASE + 0x334 + chnl * 4;
1421d4886179SRui Paulo }
1422d4886179SRui Paulo 
1423d4886179SRui Paulo /*********************** END TX SCHEDULER *************************************/
1424d4886179SRui Paulo 
1425d4886179SRui Paulo /* Oscillator clock */
1426d4886179SRui Paulo #define IWM_OSC_CLK				(0xa04068)
1427d4886179SRui Paulo #define IWM_OSC_CLK_FORCE_CONTROL		(0x8)
1428d4886179SRui Paulo 
1429d4886179SRui Paulo /*
1430d4886179SRui Paulo  * END iwl-prph.h
1431d4886179SRui Paulo  */
1432d4886179SRui Paulo 
1433d4886179SRui Paulo /*
1434d4886179SRui Paulo  * BEGIN iwl-fh.h
1435d4886179SRui Paulo  */
1436d4886179SRui Paulo 
1437d4886179SRui Paulo /****************************/
1438d4886179SRui Paulo /* Flow Handler Definitions */
1439d4886179SRui Paulo /****************************/
1440d4886179SRui Paulo 
1441d4886179SRui Paulo /**
1442d4886179SRui Paulo  * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
1443d4886179SRui Paulo  * Addresses are offsets from device's PCI hardware base address.
1444d4886179SRui Paulo  */
1445d4886179SRui Paulo #define IWM_FH_MEM_LOWER_BOUND                   (0x1000)
1446d4886179SRui Paulo #define IWM_FH_MEM_UPPER_BOUND                   (0x2000)
1447d4886179SRui Paulo 
1448d4886179SRui Paulo /**
1449d4886179SRui Paulo  * Keep-Warm (KW) buffer base address.
1450d4886179SRui Paulo  *
1451d4886179SRui Paulo  * Driver must allocate a 4KByte buffer that is for keeping the
1452d4886179SRui Paulo  * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
1453d4886179SRui Paulo  * DRAM access when doing Txing or Rxing.  The dummy accesses prevent host
1454d4886179SRui Paulo  * from going into a power-savings mode that would cause higher DRAM latency,
1455d4886179SRui Paulo  * and possible data over/under-runs, before all Tx/Rx is complete.
1456d4886179SRui Paulo  *
1457d4886179SRui Paulo  * Driver loads IWM_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
1458d4886179SRui Paulo  * of the buffer, which must be 4K aligned.  Once this is set up, the device
1459d4886179SRui Paulo  * automatically invokes keep-warm accesses when normal accesses might not
1460d4886179SRui Paulo  * be sufficient to maintain fast DRAM response.
1461d4886179SRui Paulo  *
1462d4886179SRui Paulo  * Bit fields:
1463d4886179SRui Paulo  *  31-0:  Keep-warm buffer physical base address [35:4], must be 4K aligned
1464d4886179SRui Paulo  */
1465d4886179SRui Paulo #define IWM_FH_KW_MEM_ADDR_REG		     (IWM_FH_MEM_LOWER_BOUND + 0x97C)
1466d4886179SRui Paulo 
1467d4886179SRui Paulo 
1468d4886179SRui Paulo /**
1469d4886179SRui Paulo  * TFD Circular Buffers Base (CBBC) addresses
1470d4886179SRui Paulo  *
1471d4886179SRui Paulo  * Device has 16 base pointer registers, one for each of 16 host-DRAM-resident
1472d4886179SRui Paulo  * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
1473d4886179SRui Paulo  * (see struct iwm_tfd_frame).  These 16 pointer registers are offset by 0x04
1474d4886179SRui Paulo  * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
1475d4886179SRui Paulo  * aligned (address bits 0-7 must be 0).
1476d4886179SRui Paulo  * Later devices have 20 (5000 series) or 30 (higher) queues, but the registers
1477d4886179SRui Paulo  * for them are in different places.
1478d4886179SRui Paulo  *
1479d4886179SRui Paulo  * Bit fields in each pointer register:
1480d4886179SRui Paulo  *  27-0: TFD CB physical base address [35:8], must be 256-byte aligned
1481d4886179SRui Paulo  */
1482d4886179SRui Paulo #define IWM_FH_MEM_CBBC_0_15_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0x9D0)
1483d4886179SRui Paulo #define IWM_FH_MEM_CBBC_0_15_UPPER_BOUN		(IWM_FH_MEM_LOWER_BOUND + 0xA10)
1484d4886179SRui Paulo #define IWM_FH_MEM_CBBC_16_19_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xBF0)
1485d4886179SRui Paulo #define IWM_FH_MEM_CBBC_16_19_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xC00)
1486d4886179SRui Paulo #define IWM_FH_MEM_CBBC_20_31_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xB20)
1487d4886179SRui Paulo #define IWM_FH_MEM_CBBC_20_31_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xB80)
1488d4886179SRui Paulo 
1489d4886179SRui Paulo /* Find TFD CB base pointer for given queue */
1490d4886179SRui Paulo static inline unsigned int IWM_FH_MEM_CBBC_QUEUE(unsigned int chnl)
1491d4886179SRui Paulo {
1492d4886179SRui Paulo 	if (chnl < 16)
1493d4886179SRui Paulo 		return IWM_FH_MEM_CBBC_0_15_LOWER_BOUND + 4 * chnl;
1494d4886179SRui Paulo 	if (chnl < 20)
1495d4886179SRui Paulo 		return IWM_FH_MEM_CBBC_16_19_LOWER_BOUND + 4 * (chnl - 16);
1496d4886179SRui Paulo 	return IWM_FH_MEM_CBBC_20_31_LOWER_BOUND + 4 * (chnl - 20);
1497d4886179SRui Paulo }
1498d4886179SRui Paulo 
1499d4886179SRui Paulo 
1500d4886179SRui Paulo /**
1501d4886179SRui Paulo  * Rx SRAM Control and Status Registers (RSCSR)
1502d4886179SRui Paulo  *
1503d4886179SRui Paulo  * These registers provide handshake between driver and device for the Rx queue
1504d4886179SRui Paulo  * (this queue handles *all* command responses, notifications, Rx data, etc.
1505d4886179SRui Paulo  * sent from uCode to host driver).  Unlike Tx, there is only one Rx
1506d4886179SRui Paulo  * queue, and only one Rx DMA/FIFO channel.  Also unlike Tx, which can
1507d4886179SRui Paulo  * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
1508d4886179SRui Paulo  * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
1509d4886179SRui Paulo  * mapping between RBDs and RBs.
1510d4886179SRui Paulo  *
1511d4886179SRui Paulo  * Driver must allocate host DRAM memory for the following, and set the
1512d4886179SRui Paulo  * physical address of each into device registers:
1513d4886179SRui Paulo  *
1514d4886179SRui Paulo  * 1)  Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
1515d4886179SRui Paulo  *     entries (although any power of 2, up to 4096, is selectable by driver).
1516d4886179SRui Paulo  *     Each entry (1 dword) points to a receive buffer (RB) of consistent size
1517d4886179SRui Paulo  *     (typically 4K, although 8K or 16K are also selectable by driver).
1518d4886179SRui Paulo  *     Driver sets up RB size and number of RBDs in the CB via Rx config
1519d4886179SRui Paulo  *     register IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG.
1520d4886179SRui Paulo  *
1521d4886179SRui Paulo  *     Bit fields within one RBD:
1522d4886179SRui Paulo  *     27-0:  Receive Buffer physical address bits [35:8], 256-byte aligned
1523d4886179SRui Paulo  *
1524d4886179SRui Paulo  *     Driver sets physical address [35:8] of base of RBD circular buffer
1525d4886179SRui Paulo  *     into IWM_FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
1526d4886179SRui Paulo  *
1527d4886179SRui Paulo  * 2)  Rx status buffer, 8 bytes, in which uCode indicates which Rx Buffers
1528d4886179SRui Paulo  *     (RBs) have been filled, via a "write pointer", actually the index of
1529d4886179SRui Paulo  *     the RB's corresponding RBD within the circular buffer.  Driver sets
1530d4886179SRui Paulo  *     physical address [35:4] into IWM_FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
1531d4886179SRui Paulo  *
1532d4886179SRui Paulo  *     Bit fields in lower dword of Rx status buffer (upper dword not used
1533d4886179SRui Paulo  *     by driver:
1534d4886179SRui Paulo  *     31-12:  Not used by driver
1535d4886179SRui Paulo  *     11- 0:  Index of last filled Rx buffer descriptor
1536d4886179SRui Paulo  *             (device writes, driver reads this value)
1537d4886179SRui Paulo  *
1538d4886179SRui Paulo  * As the driver prepares Receive Buffers (RBs) for device to fill, driver must
1539d4886179SRui Paulo  * enter pointers to these RBs into contiguous RBD circular buffer entries,
1540d4886179SRui Paulo  * and update the device's "write" index register,
1541d4886179SRui Paulo  * IWM_FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
1542d4886179SRui Paulo  *
1543d4886179SRui Paulo  * This "write" index corresponds to the *next* RBD that the driver will make
1544d4886179SRui Paulo  * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
1545d4886179SRui Paulo  * the circular buffer.  This value should initially be 0 (before preparing any
1546d4886179SRui Paulo  * RBs), should be 8 after preparing the first 8 RBs (for example), and must
1547d4886179SRui Paulo  * wrap back to 0 at the end of the circular buffer (but don't wrap before
1548d4886179SRui Paulo  * "read" index has advanced past 1!  See below).
1549d4886179SRui Paulo  * NOTE:  DEVICE EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
1550d4886179SRui Paulo  *
1551d4886179SRui Paulo  * As the device fills RBs (referenced from contiguous RBDs within the circular
1552d4886179SRui Paulo  * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
1553d4886179SRui Paulo  * to tell the driver the index of the latest filled RBD.  The driver must
1554d4886179SRui Paulo  * read this "read" index from DRAM after receiving an Rx interrupt from device
1555d4886179SRui Paulo  *
1556d4886179SRui Paulo  * The driver must also internally keep track of a third index, which is the
1557d4886179SRui Paulo  * next RBD to process.  When receiving an Rx interrupt, driver should process
1558d4886179SRui Paulo  * all filled but unprocessed RBs up to, but not including, the RB
1559d4886179SRui Paulo  * corresponding to the "read" index.  For example, if "read" index becomes "1",
1560d4886179SRui Paulo  * driver may process the RB pointed to by RBD 0.  Depending on volume of
1561d4886179SRui Paulo  * traffic, there may be many RBs to process.
1562d4886179SRui Paulo  *
1563d4886179SRui Paulo  * If read index == write index, device thinks there is no room to put new data.
1564d4886179SRui Paulo  * Due to this, the maximum number of filled RBs is 255, instead of 256.  To
1565d4886179SRui Paulo  * be safe, make sure that there is a gap of at least 2 RBDs between "write"
1566d4886179SRui Paulo  * and "read" indexes; that is, make sure that there are no more than 254
1567d4886179SRui Paulo  * buffers waiting to be filled.
1568d4886179SRui Paulo  */
1569d4886179SRui Paulo #define IWM_FH_MEM_RSCSR_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xBC0)
1570d4886179SRui Paulo #define IWM_FH_MEM_RSCSR_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xC00)
1571d4886179SRui Paulo #define IWM_FH_MEM_RSCSR_CHNL0		(IWM_FH_MEM_RSCSR_LOWER_BOUND)
1572d4886179SRui Paulo 
1573d4886179SRui Paulo /**
1574d4886179SRui Paulo  * Physical base address of 8-byte Rx Status buffer.
1575d4886179SRui Paulo  * Bit fields:
1576d4886179SRui Paulo  *  31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
1577d4886179SRui Paulo  */
1578d4886179SRui Paulo #define IWM_FH_RSCSR_CHNL0_STTS_WPTR_REG	(IWM_FH_MEM_RSCSR_CHNL0)
1579d4886179SRui Paulo 
1580d4886179SRui Paulo /**
1581d4886179SRui Paulo  * Physical base address of Rx Buffer Descriptor Circular Buffer.
1582d4886179SRui Paulo  * Bit fields:
1583d4886179SRui Paulo  *  27-0:  RBD CD physical base address [35:8], must be 256-byte aligned.
1584d4886179SRui Paulo  */
1585d4886179SRui Paulo #define IWM_FH_RSCSR_CHNL0_RBDCB_BASE_REG	(IWM_FH_MEM_RSCSR_CHNL0 + 0x004)
1586d4886179SRui Paulo 
1587d4886179SRui Paulo /**
1588d4886179SRui Paulo  * Rx write pointer (index, really!).
1589d4886179SRui Paulo  * Bit fields:
1590d4886179SRui Paulo  *  11-0:  Index of driver's most recent prepared-to-be-filled RBD, + 1.
1591d4886179SRui Paulo  *         NOTE:  For 256-entry circular buffer, use only bits [7:0].
1592d4886179SRui Paulo  */
1593d4886179SRui Paulo #define IWM_FH_RSCSR_CHNL0_RBDCB_WPTR_REG	(IWM_FH_MEM_RSCSR_CHNL0 + 0x008)
1594d4886179SRui Paulo #define IWM_FH_RSCSR_CHNL0_WPTR		(IWM_FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
1595d4886179SRui Paulo 
1596d4886179SRui Paulo #define IWM_FW_RSCSR_CHNL0_RXDCB_RDPTR_REG	(IWM_FH_MEM_RSCSR_CHNL0 + 0x00c)
1597d4886179SRui Paulo #define IWM_FH_RSCSR_CHNL0_RDPTR		IWM_FW_RSCSR_CHNL0_RXDCB_RDPTR_REG
1598d4886179SRui Paulo 
1599d4886179SRui Paulo /**
1600d4886179SRui Paulo  * Rx Config/Status Registers (RCSR)
1601d4886179SRui Paulo  * Rx Config Reg for channel 0 (only channel used)
1602d4886179SRui Paulo  *
1603d4886179SRui Paulo  * Driver must initialize IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
1604d4886179SRui Paulo  * normal operation (see bit fields).
1605d4886179SRui Paulo  *
1606d4886179SRui Paulo  * Clearing IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
1607d4886179SRui Paulo  * Driver should poll IWM_FH_MEM_RSSR_RX_STATUS_REG	for
1608d4886179SRui Paulo  * IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
1609d4886179SRui Paulo  *
1610d4886179SRui Paulo  * Bit fields:
1611d4886179SRui Paulo  * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1612d4886179SRui Paulo  *        '10' operate normally
1613d4886179SRui Paulo  * 29-24: reserved
1614d4886179SRui Paulo  * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
1615d4886179SRui Paulo  *        min "5" for 32 RBDs, max "12" for 4096 RBDs.
1616d4886179SRui Paulo  * 19-18: reserved
1617d4886179SRui Paulo  * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
1618d4886179SRui Paulo  *        '10' 12K, '11' 16K.
1619d4886179SRui Paulo  * 15-14: reserved
1620d4886179SRui Paulo  * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
1621d4886179SRui Paulo  * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
1622d4886179SRui Paulo  *        typical value 0x10 (about 1/2 msec)
1623d4886179SRui Paulo  *  3- 0: reserved
1624d4886179SRui Paulo  */
1625d4886179SRui Paulo #define IWM_FH_MEM_RCSR_LOWER_BOUND      (IWM_FH_MEM_LOWER_BOUND + 0xC00)
1626d4886179SRui Paulo #define IWM_FH_MEM_RCSR_UPPER_BOUND      (IWM_FH_MEM_LOWER_BOUND + 0xCC0)
1627d4886179SRui Paulo #define IWM_FH_MEM_RCSR_CHNL0            (IWM_FH_MEM_RCSR_LOWER_BOUND)
1628d4886179SRui Paulo 
1629d4886179SRui Paulo #define IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG	(IWM_FH_MEM_RCSR_CHNL0)
1630d4886179SRui Paulo #define IWM_FH_MEM_RCSR_CHNL0_RBDCB_WPTR	(IWM_FH_MEM_RCSR_CHNL0 + 0x8)
1631d4886179SRui Paulo #define IWM_FH_MEM_RCSR_CHNL0_FLUSH_RB_REQ	(IWM_FH_MEM_RCSR_CHNL0 + 0x10)
1632d4886179SRui Paulo 
1633d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */
1634d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK   (0x00001000) /* bits 12 */
1635d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */
1636d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK   (0x00030000) /* bits 16-17 */
1637d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */
1638d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/
1639d4886179SRui Paulo 
1640d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS	(20)
1641d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS	(4)
1642d4886179SRui Paulo #define IWM_RX_RB_TIMEOUT	(0x11)
1643d4886179SRui Paulo 
1644d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL         (0x00000000)
1645d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL     (0x40000000)
1646d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL        (0x80000000)
1647d4886179SRui Paulo 
1648d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K    (0x00000000)
1649d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K    (0x00010000)
1650d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K   (0x00020000)
1651d4886179SRui Paulo #define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K   (0x00030000)
1652d4886179SRui Paulo 
1653d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY              (0x00000004)
1654d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL    (0x00000000)
1655d4886179SRui Paulo #define IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL  (0x00001000)
1656d4886179SRui Paulo 
1657d4886179SRui Paulo /**
1658d4886179SRui Paulo  * Rx Shared Status Registers (RSSR)
1659d4886179SRui Paulo  *
1660d4886179SRui Paulo  * After stopping Rx DMA channel (writing 0 to
1661d4886179SRui Paulo  * IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
1662d4886179SRui Paulo  * IWM_FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
1663d4886179SRui Paulo  *
1664d4886179SRui Paulo  * Bit fields:
1665d4886179SRui Paulo  *  24:  1 = Channel 0 is idle
1666d4886179SRui Paulo  *
1667d4886179SRui Paulo  * IWM_FH_MEM_RSSR_SHARED_CTRL_REG and IWM_FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
1668d4886179SRui Paulo  * contain default values that should not be altered by the driver.
1669d4886179SRui Paulo  */
1670d4886179SRui Paulo #define IWM_FH_MEM_RSSR_LOWER_BOUND     (IWM_FH_MEM_LOWER_BOUND + 0xC40)
1671d4886179SRui Paulo #define IWM_FH_MEM_RSSR_UPPER_BOUND     (IWM_FH_MEM_LOWER_BOUND + 0xD00)
1672d4886179SRui Paulo 
1673d4886179SRui Paulo #define IWM_FH_MEM_RSSR_SHARED_CTRL_REG (IWM_FH_MEM_RSSR_LOWER_BOUND)
1674d4886179SRui Paulo #define IWM_FH_MEM_RSSR_RX_STATUS_REG	(IWM_FH_MEM_RSSR_LOWER_BOUND + 0x004)
1675d4886179SRui Paulo #define IWM_FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
1676d4886179SRui Paulo 					(IWM_FH_MEM_RSSR_LOWER_BOUND + 0x008)
1677d4886179SRui Paulo 
1678d4886179SRui Paulo #define IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE	(0x01000000)
1679d4886179SRui Paulo 
1680d4886179SRui Paulo #define IWM_FH_MEM_TFDIB_REG1_ADDR_BITSHIFT	28
1681d4886179SRui Paulo 
1682d4886179SRui Paulo /* TFDB  Area - TFDs buffer table */
1683d4886179SRui Paulo #define IWM_FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK      (0xFFFFFFFF)
1684d4886179SRui Paulo #define IWM_FH_TFDIB_LOWER_BOUND       (IWM_FH_MEM_LOWER_BOUND + 0x900)
1685d4886179SRui Paulo #define IWM_FH_TFDIB_UPPER_BOUND       (IWM_FH_MEM_LOWER_BOUND + 0x958)
1686d4886179SRui Paulo #define IWM_FH_TFDIB_CTRL0_REG(_chnl)  (IWM_FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
1687d4886179SRui Paulo #define IWM_FH_TFDIB_CTRL1_REG(_chnl)  (IWM_FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
1688d4886179SRui Paulo 
1689d4886179SRui Paulo /**
1690d4886179SRui Paulo  * Transmit DMA Channel Control/Status Registers (TCSR)
1691d4886179SRui Paulo  *
1692d4886179SRui Paulo  * Device has one configuration register for each of 8 Tx DMA/FIFO channels
1693d4886179SRui Paulo  * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1694d4886179SRui Paulo  * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1695d4886179SRui Paulo  *
1696d4886179SRui Paulo  * To use a Tx DMA channel, driver must initialize its
1697d4886179SRui Paulo  * IWM_FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1698d4886179SRui Paulo  *
1699d4886179SRui Paulo  * IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1700d4886179SRui Paulo  * IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1701d4886179SRui Paulo  *
1702d4886179SRui Paulo  * All other bits should be 0.
1703d4886179SRui Paulo  *
1704d4886179SRui Paulo  * Bit fields:
1705d4886179SRui Paulo  * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1706d4886179SRui Paulo  *        '10' operate normally
1707d4886179SRui Paulo  * 29- 4: Reserved, set to "0"
1708d4886179SRui Paulo  *     3: Enable internal DMA requests (1, normal operation), disable (0)
1709d4886179SRui Paulo  *  2- 0: Reserved, set to "0"
1710d4886179SRui Paulo  */
1711d4886179SRui Paulo #define IWM_FH_TCSR_LOWER_BOUND  (IWM_FH_MEM_LOWER_BOUND + 0xD00)
1712d4886179SRui Paulo #define IWM_FH_TCSR_UPPER_BOUND  (IWM_FH_MEM_LOWER_BOUND + 0xE60)
1713d4886179SRui Paulo 
1714d4886179SRui Paulo /* Find Control/Status reg for given Tx DMA/FIFO channel */
1715d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_NUM                            (8)
1716d4886179SRui Paulo 
1717d4886179SRui Paulo /* TCSR: tx_config register values */
1718d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl)	\
1719d4886179SRui Paulo 		(IWM_FH_TCSR_LOWER_BOUND + 0x20 * (_chnl))
1720d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_CREDIT_REG(_chnl)	\
1721d4886179SRui Paulo 		(IWM_FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
1722d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl)	\
1723d4886179SRui Paulo 		(IWM_FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
1724d4886179SRui Paulo 
1725d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF	(0x00000000)
1726d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV	(0x00000001)
1727d4886179SRui Paulo 
1728d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE	(0x00000000)
1729d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE		(0x00000008)
1730d4886179SRui Paulo 
1731d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT	(0x00000000)
1732d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD	(0x00100000)
1733d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD	(0x00200000)
1734d4886179SRui Paulo 
1735d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT	(0x00000000)
1736d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD	(0x00400000)
1737d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD	(0x00800000)
1738d4886179SRui Paulo 
1739d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE		(0x00000000)
1740d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF	(0x40000000)
1741d4886179SRui Paulo #define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE		(0x80000000)
1742d4886179SRui Paulo 
1743d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY	(0x00000000)
1744d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT	(0x00002000)
1745d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID	(0x00000003)
1746d4886179SRui Paulo 
1747d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM		(20)
1748d4886179SRui Paulo #define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX		(12)
1749d4886179SRui Paulo 
1750d4886179SRui Paulo /**
1751d4886179SRui Paulo  * Tx Shared Status Registers (TSSR)
1752d4886179SRui Paulo  *
1753d4886179SRui Paulo  * After stopping Tx DMA channel (writing 0 to
1754d4886179SRui Paulo  * IWM_FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1755d4886179SRui Paulo  * IWM_FH_TSSR_TX_STATUS_REG until selected Tx channel is idle
1756d4886179SRui Paulo  * (channel's buffers empty | no pending requests).
1757d4886179SRui Paulo  *
1758d4886179SRui Paulo  * Bit fields:
1759d4886179SRui Paulo  * 31-24:  1 = Channel buffers empty (channel 7:0)
1760d4886179SRui Paulo  * 23-16:  1 = No pending requests (channel 7:0)
1761d4886179SRui Paulo  */
1762d4886179SRui Paulo #define IWM_FH_TSSR_LOWER_BOUND		(IWM_FH_MEM_LOWER_BOUND + 0xEA0)
1763d4886179SRui Paulo #define IWM_FH_TSSR_UPPER_BOUND		(IWM_FH_MEM_LOWER_BOUND + 0xEC0)
1764d4886179SRui Paulo 
1765d4886179SRui Paulo #define IWM_FH_TSSR_TX_STATUS_REG	(IWM_FH_TSSR_LOWER_BOUND + 0x010)
1766d4886179SRui Paulo 
1767d4886179SRui Paulo /**
1768d4886179SRui Paulo  * Bit fields for TSSR(Tx Shared Status & Control) error status register:
1769d4886179SRui Paulo  * 31:  Indicates an address error when accessed to internal memory
1770d4886179SRui Paulo  *	uCode/driver must write "1" in order to clear this flag
1771d4886179SRui Paulo  * 30:  Indicates that Host did not send the expected number of dwords to FH
1772d4886179SRui Paulo  *	uCode/driver must write "1" in order to clear this flag
1773d4886179SRui Paulo  * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
1774d4886179SRui Paulo  *	command was received from the scheduler while the TRB was already full
1775d4886179SRui Paulo  *	with previous command
1776d4886179SRui Paulo  *	uCode/driver must write "1" in order to clear this flag
1777d4886179SRui Paulo  * 7-0: Each status bit indicates a channel's TxCredit error. When an error
1778d4886179SRui Paulo  *	bit is set, it indicates that the FH has received a full indication
1779d4886179SRui Paulo  *	from the RTC TxFIFO and the current value of the TxCredit counter was
1780d4886179SRui Paulo  *	not equal to zero. This mean that the credit mechanism was not
1781d4886179SRui Paulo  *	synchronized to the TxFIFO status
1782d4886179SRui Paulo  *	uCode/driver must write "1" in order to clear this flag
1783d4886179SRui Paulo  */
1784d4886179SRui Paulo #define IWM_FH_TSSR_TX_ERROR_REG	(IWM_FH_TSSR_LOWER_BOUND + 0x018)
1785d4886179SRui Paulo #define IWM_FH_TSSR_TX_MSG_CONFIG_REG	(IWM_FH_TSSR_LOWER_BOUND + 0x008)
1786d4886179SRui Paulo 
1787d4886179SRui Paulo #define IWM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
1788d4886179SRui Paulo 
1789d4886179SRui Paulo /* Tx service channels */
1790d4886179SRui Paulo #define IWM_FH_SRVC_CHNL		(9)
1791d4886179SRui Paulo #define IWM_FH_SRVC_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0x9C8)
1792d4886179SRui Paulo #define IWM_FH_SRVC_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0x9D0)
1793d4886179SRui Paulo #define IWM_FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
1794d4886179SRui Paulo 		(IWM_FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
1795d4886179SRui Paulo 
1796d4886179SRui Paulo #define IWM_FH_TX_CHICKEN_BITS_REG	(IWM_FH_MEM_LOWER_BOUND + 0xE98)
1797d4886179SRui Paulo #define IWM_FH_TX_TRB_REG(_chan)	(IWM_FH_MEM_LOWER_BOUND + 0x958 + \
1798d4886179SRui Paulo 					(_chan) * 4)
1799d4886179SRui Paulo 
1800d4886179SRui Paulo /* Instruct FH to increment the retry count of a packet when
1801d4886179SRui Paulo  * it is brought from the memory to TX-FIFO
1802d4886179SRui Paulo  */
1803d4886179SRui Paulo #define IWM_FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN	(0x00000002)
1804d4886179SRui Paulo 
1805d4886179SRui Paulo #define IWM_RX_QUEUE_SIZE                         256
1806d4886179SRui Paulo #define IWM_RX_QUEUE_MASK                         255
1807d4886179SRui Paulo #define IWM_RX_QUEUE_SIZE_LOG                     8
1808d4886179SRui Paulo 
1809d4886179SRui Paulo /*
1810d4886179SRui Paulo  * RX related structures and functions
1811d4886179SRui Paulo  */
1812d4886179SRui Paulo #define IWM_RX_FREE_BUFFERS 64
1813d4886179SRui Paulo #define IWM_RX_LOW_WATERMARK 8
1814d4886179SRui Paulo 
1815d4886179SRui Paulo /**
1816d4886179SRui Paulo  * struct iwm_rb_status - reseve buffer status
1817d4886179SRui Paulo  * 	host memory mapped FH registers
1818d4886179SRui Paulo  * @closed_rb_num [0:11] - Indicates the index of the RB which was closed
1819d4886179SRui Paulo  * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed
1820d4886179SRui Paulo  * @finished_rb_num [0:11] - Indicates the index of the current RB
1821d4886179SRui Paulo  * 	in which the last frame was written to
1822d4886179SRui Paulo  * @finished_fr_num [0:11] - Indicates the index of the RX Frame
1823d4886179SRui Paulo  * 	which was transferred
1824d4886179SRui Paulo  */
1825d4886179SRui Paulo struct iwm_rb_status {
1826d4886179SRui Paulo 	uint16_t closed_rb_num;
1827d4886179SRui Paulo 	uint16_t closed_fr_num;
1828d4886179SRui Paulo 	uint16_t finished_rb_num;
1829d4886179SRui Paulo 	uint16_t finished_fr_nam;
1830d4886179SRui Paulo 	uint32_t unused;
1831d4886179SRui Paulo } __packed;
1832d4886179SRui Paulo 
1833d4886179SRui Paulo 
1834d4886179SRui Paulo #define IWM_TFD_QUEUE_SIZE_MAX		(256)
1835d4886179SRui Paulo #define IWM_TFD_QUEUE_SIZE_BC_DUP	(64)
1836d4886179SRui Paulo #define IWM_TFD_QUEUE_BC_SIZE		(IWM_TFD_QUEUE_SIZE_MAX + \
1837d4886179SRui Paulo 					IWM_TFD_QUEUE_SIZE_BC_DUP)
1838d4886179SRui Paulo #define IWM_TX_DMA_MASK        DMA_BIT_MASK(36)
1839d4886179SRui Paulo #define IWM_NUM_OF_TBS		20
1840d4886179SRui Paulo 
1841d4886179SRui Paulo static inline uint8_t iwm_get_dma_hi_addr(bus_addr_t addr)
1842d4886179SRui Paulo {
1843d4886179SRui Paulo 	return (sizeof(addr) > sizeof(uint32_t) ? (addr >> 16) >> 16 : 0) & 0xF;
1844d4886179SRui Paulo }
1845d4886179SRui Paulo /**
1846d4886179SRui Paulo  * struct iwm_tfd_tb transmit buffer descriptor within transmit frame descriptor
1847d4886179SRui Paulo  *
1848d4886179SRui Paulo  * This structure contains dma address and length of transmission address
1849d4886179SRui Paulo  *
1850d4886179SRui Paulo  * @lo: low [31:0] portion of the dma address of TX buffer
1851d4886179SRui Paulo  * 	every even is unaligned on 16 bit boundary
1852d4886179SRui Paulo  * @hi_n_len 0-3 [35:32] portion of dma
1853d4886179SRui Paulo  *	     4-15 length of the tx buffer
1854d4886179SRui Paulo  */
1855d4886179SRui Paulo struct iwm_tfd_tb {
1856d4886179SRui Paulo 	uint32_t lo;
1857d4886179SRui Paulo 	uint16_t hi_n_len;
1858d4886179SRui Paulo } __packed;
1859d4886179SRui Paulo 
1860d4886179SRui Paulo /**
1861d4886179SRui Paulo  * struct iwm_tfd
1862d4886179SRui Paulo  *
1863d4886179SRui Paulo  * Transmit Frame Descriptor (TFD)
1864d4886179SRui Paulo  *
1865d4886179SRui Paulo  * @ __reserved1[3] reserved
1866d4886179SRui Paulo  * @ num_tbs 0-4 number of active tbs
1867d4886179SRui Paulo  *	     5   reserved
1868d4886179SRui Paulo  * 	     6-7 padding (not used)
1869d4886179SRui Paulo  * @ tbs[20]	transmit frame buffer descriptors
1870d4886179SRui Paulo  * @ __pad 	padding
1871d4886179SRui Paulo  *
1872d4886179SRui Paulo  * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
1873d4886179SRui Paulo  * Both driver and device share these circular buffers, each of which must be
1874d4886179SRui Paulo  * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
1875d4886179SRui Paulo  *
1876d4886179SRui Paulo  * Driver must indicate the physical address of the base of each
1877d4886179SRui Paulo  * circular buffer via the IWM_FH_MEM_CBBC_QUEUE registers.
1878d4886179SRui Paulo  *
1879d4886179SRui Paulo  * Each TFD contains pointer/size information for up to 20 data buffers
1880d4886179SRui Paulo  * in host DRAM.  These buffers collectively contain the (one) frame described
1881d4886179SRui Paulo  * by the TFD.  Each buffer must be a single contiguous block of memory within
1882d4886179SRui Paulo  * itself, but buffers may be scattered in host DRAM.  Each buffer has max size
1883d4886179SRui Paulo  * of (4K - 4).  The concatenates all of a TFD's buffers into a single
1884d4886179SRui Paulo  * Tx frame, up to 8 KBytes in size.
1885d4886179SRui Paulo  *
1886d4886179SRui Paulo  * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
1887d4886179SRui Paulo  */
1888d4886179SRui Paulo struct iwm_tfd {
1889d4886179SRui Paulo 	uint8_t __reserved1[3];
1890d4886179SRui Paulo 	uint8_t num_tbs;
1891d4886179SRui Paulo 	struct iwm_tfd_tb tbs[IWM_NUM_OF_TBS];
1892d4886179SRui Paulo 	uint32_t __pad;
1893d4886179SRui Paulo } __packed;
1894d4886179SRui Paulo 
1895d4886179SRui Paulo /* Keep Warm Size */
1896d4886179SRui Paulo #define IWM_KW_SIZE 0x1000	/* 4k */
1897d4886179SRui Paulo 
1898d4886179SRui Paulo /* Fixed (non-configurable) rx data from phy */
1899d4886179SRui Paulo 
1900d4886179SRui Paulo /**
1901d4886179SRui Paulo  * struct iwm_agn_schedq_bc_tbl scheduler byte count table
1902d4886179SRui Paulo  *	base physical address provided by IWM_SCD_DRAM_BASE_ADDR
1903d4886179SRui Paulo  * @tfd_offset  0-12 - tx command byte count
1904d4886179SRui Paulo  *	       12-16 - station index
1905d4886179SRui Paulo  */
1906d4886179SRui Paulo struct iwm_agn_scd_bc_tbl {
1907d4886179SRui Paulo 	uint16_t tfd_offset[IWM_TFD_QUEUE_BC_SIZE];
1908d4886179SRui Paulo } __packed;
1909d4886179SRui Paulo 
1910355c1513SAdrian Chadd 
1911d4886179SRui Paulo /*
1912d4886179SRui Paulo  * END iwl-fh.h
1913d4886179SRui Paulo  */
1914d4886179SRui Paulo 
1915d4886179SRui Paulo /*
1916d4886179SRui Paulo  * BEGIN mvm/fw-api.h
1917d4886179SRui Paulo  */
1918d4886179SRui Paulo 
1919355c1513SAdrian Chadd #define IWM_TX_CRC_SIZE 4
1920355c1513SAdrian Chadd #define IWM_TX_DELIMITER_SIZE 4
1921355c1513SAdrian Chadd 
19226a5bc1d1SSean Bruno /* Maximum number of Tx queues. */
1923e7065dd1SMark Johnston #define IWM_MAX_QUEUES	31
1924d4886179SRui Paulo 
1925355c1513SAdrian Chadd /**
1926355c1513SAdrian Chadd  * DQA - Dynamic Queue Allocation -introduction
1927355c1513SAdrian Chadd  *
1928355c1513SAdrian Chadd  * Dynamic Queue Allocation (AKA "DQA") is a feature implemented in iwlwifi
1929355c1513SAdrian Chadd  * to allow dynamic allocation of queues on-demand, rather than allocate them
1930355c1513SAdrian Chadd  * statically ahead of time. Ideally, we would like to allocate one queue
1931355c1513SAdrian Chadd  * per RA/TID, thus allowing an AP - for example - to send BE traffic to STA2
1932355c1513SAdrian Chadd  * even if it also needs to send traffic to a sleeping STA1, without being
1933355c1513SAdrian Chadd  * blocked by the sleeping station.
1934355c1513SAdrian Chadd  *
1935355c1513SAdrian Chadd  * Although the queues in DQA mode are dynamically allocated, there are still
1936355c1513SAdrian Chadd  * some queues that are statically allocated:
1937355c1513SAdrian Chadd  *	TXQ #0 - command queue
1938355c1513SAdrian Chadd  *	TXQ #1 - aux frames
1939355c1513SAdrian Chadd  *	TXQ #2 - P2P device frames
1940355c1513SAdrian Chadd  *	TXQ #3 - P2P GO/SoftAP GCAST/BCAST frames
1941355c1513SAdrian Chadd  *	TXQ #4 - BSS DATA frames queue
1942355c1513SAdrian Chadd  *	TXQ #5-8 - non-QoS data, QoS no-data, and MGMT frames queue pool
1943355c1513SAdrian Chadd  *	TXQ #9 - P2P GO/SoftAP probe responses
1944355c1513SAdrian Chadd  *	TXQ #10-31 - QoS DATA frames queue pool (for Tx aggregation)
1945355c1513SAdrian Chadd  */
1946d4886179SRui Paulo 
1947355c1513SAdrian Chadd /* static DQA Tx queue numbers */
1948355c1513SAdrian Chadd #define IWM_DQA_CMD_QUEUE		0
1949355c1513SAdrian Chadd #define IWM_DQA_AUX_QUEUE		1
1950355c1513SAdrian Chadd #define IWM_DQA_P2P_DEVICE_QUEUE	2
1951355c1513SAdrian Chadd #define IWM_DQA_INJECT_MONITOR_QUEUE	2
1952355c1513SAdrian Chadd #define IWM_DQA_GCAST_QUEUE		3
1953355c1513SAdrian Chadd #define IWM_DQA_BSS_CLIENT_QUEUE	4
1954355c1513SAdrian Chadd #define IWM_DQA_MIN_MGMT_QUEUE		5
1955355c1513SAdrian Chadd #define IWM_DQA_MAX_MGMT_QUEUE		8
1956355c1513SAdrian Chadd #define IWM_DQA_AP_PROBE_RESP_QUEUE	9
1957355c1513SAdrian Chadd #define IWM_DQA_MIN_DATA_QUEUE		10
1958355c1513SAdrian Chadd #define IWM_DQA_MAX_DATA_QUEUE		31
1959355c1513SAdrian Chadd 
1960355c1513SAdrian Chadd /* Reserve 8 DQA Tx queues, from 10 up to 17, for A-MPDU aggregation. */
1961355c1513SAdrian Chadd #define IWM_MAX_TID_COUNT	8
1962355c1513SAdrian Chadd #define IWM_FIRST_AGG_TX_QUEUE	IWM_DQA_MIN_DATA_QUEUE
1963355c1513SAdrian Chadd #define IWM_LAST_AGG_TX_QUEUE	(IWM_FIRST_AGG_TX_QUEUE + IWM_MAX_TID_COUNT - 1)
1964355c1513SAdrian Chadd 
1965355c1513SAdrian Chadd /* legacy non-DQA queues; the legacy command queue uses a different number! */
1966355c1513SAdrian Chadd #define IWM_OFFCHANNEL_QUEUE	8
1967355c1513SAdrian Chadd #define IWM_CMD_QUEUE		9
1968355c1513SAdrian Chadd #define IWM_AUX_QUEUE		15
1969355c1513SAdrian Chadd 
1970355c1513SAdrian Chadd #define IWM_TX_FIFO_BK	0
1971355c1513SAdrian Chadd #define IWM_TX_FIFO_BE	1
1972355c1513SAdrian Chadd #define IWM_TX_FIFO_VI	2
1973355c1513SAdrian Chadd #define IWM_TX_FIFO_VO	3
1974355c1513SAdrian Chadd #define IWM_TX_FIFO_MCAST	5
1975355c1513SAdrian Chadd #define IWM_TX_FIFO_CMD	7
1976d4886179SRui Paulo 
1977e7065dd1SMark Johnston #define IWM_STATION_COUNT	16
1978d4886179SRui Paulo 
1979355c1513SAdrian Chadd /*
1980355c1513SAdrian Chadd  * Commands
1981355c1513SAdrian Chadd  */
1982355c1513SAdrian Chadd #define IWM_ALIVE		0x1
1983355c1513SAdrian Chadd #define IWM_REPLY_ERROR		0x2
1984355c1513SAdrian Chadd #define IWM_INIT_COMPLETE_NOTIF	0x4
1985d4886179SRui Paulo 
1986d4886179SRui Paulo /* PHY context commands */
1987355c1513SAdrian Chadd #define IWM_PHY_CONTEXT_CMD	0x8
1988355c1513SAdrian Chadd #define IWM_DBG_CFG		0x9
1989d4886179SRui Paulo 
19906a5bc1d1SSean Bruno /* UMAC scan commands */
1991355c1513SAdrian Chadd #define IWM_SCAN_ITERATION_COMPLETE_UMAC	0xb5
1992355c1513SAdrian Chadd #define IWM_SCAN_CFG_CMD			0xc
1993355c1513SAdrian Chadd #define IWM_SCAN_REQ_UMAC			0xd
1994355c1513SAdrian Chadd #define IWM_SCAN_ABORT_UMAC			0xe
1995355c1513SAdrian Chadd #define IWM_SCAN_COMPLETE_UMAC			0xf
19966a5bc1d1SSean Bruno 
1997d4886179SRui Paulo /* station table */
1998355c1513SAdrian Chadd #define IWM_ADD_STA_KEY	0x17
1999355c1513SAdrian Chadd #define IWM_ADD_STA	0x18
2000355c1513SAdrian Chadd #define IWM_REMOVE_STA	0x19
2001d4886179SRui Paulo 
2002d4886179SRui Paulo /* TX */
2003355c1513SAdrian Chadd #define IWM_TX_CMD		0x1c
2004355c1513SAdrian Chadd #define IWM_TXPATH_FLUSH	0x1e
2005355c1513SAdrian Chadd #define IWM_MGMT_MCAST_KEY	0x1f
2006d4886179SRui Paulo 
20076a5bc1d1SSean Bruno /* scheduler config */
2008355c1513SAdrian Chadd #define IWM_SCD_QUEUE_CFG	0x1d
20096a5bc1d1SSean Bruno 
2010d4886179SRui Paulo /* global key */
2011355c1513SAdrian Chadd #define IWM_WEP_KEY	0x20
2012d4886179SRui Paulo 
2013d4886179SRui Paulo /* MAC and Binding commands */
2014355c1513SAdrian Chadd #define IWM_MAC_CONTEXT_CMD		0x28
2015355c1513SAdrian Chadd #define IWM_TIME_EVENT_CMD		0x29 /* both CMD and response */
2016355c1513SAdrian Chadd #define IWM_TIME_EVENT_NOTIFICATION	0x2a
2017355c1513SAdrian Chadd #define IWM_BINDING_CONTEXT_CMD		0x2b
2018355c1513SAdrian Chadd #define IWM_TIME_QUOTA_CMD		0x2c
2019355c1513SAdrian Chadd #define IWM_NON_QOS_TX_COUNTER_CMD	0x2d
2020d4886179SRui Paulo 
2021355c1513SAdrian Chadd #define IWM_LQ_CMD	0x4e
2022355c1513SAdrian Chadd 
2023355c1513SAdrian Chadd /* Calibration */
2024355c1513SAdrian Chadd #define IWM_TEMPERATURE_NOTIFICATION		0x62
2025355c1513SAdrian Chadd #define IWM_CALIBRATION_CFG_CMD			0x65
2026355c1513SAdrian Chadd #define IWM_CALIBRATION_RES_NOTIFICATION	0x66
2027355c1513SAdrian Chadd #define IWM_CALIBRATION_COMPLETE_NOTIFICATION	0x67
2028355c1513SAdrian Chadd #define IWM_RADIO_VERSION_NOTIFICATION		0x68
2029d4886179SRui Paulo 
2030ad35d471SAdrian Chadd /* paging block to FW cpu2 */
2031355c1513SAdrian Chadd #define IWM_FW_PAGING_BLOCK_CMD	0x4f
2032d4886179SRui Paulo 
2033d4886179SRui Paulo /* Scan offload */
2034355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_REQUEST_CMD		0x51
2035355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_ABORT_CMD		0x52
2036355c1513SAdrian Chadd #define IWM_HOT_SPOT_CMD			0x53
2037355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_COMPLETE		0x6d
2038355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_UPDATE_PROFILES_CMD	0x6e
2039355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_CONFIG_CMD		0x6f
2040355c1513SAdrian Chadd #define IWM_MATCH_FOUND_NOTIFICATION		0xd9
2041355c1513SAdrian Chadd #define IWM_SCAN_ITERATION_COMPLETE		0xe7
2042d4886179SRui Paulo 
2043d4886179SRui Paulo /* Phy */
2044355c1513SAdrian Chadd #define IWM_PHY_CONFIGURATION_CMD		0x6a
2045355c1513SAdrian Chadd #define IWM_CALIB_RES_NOTIF_PHY_DB		0x6b
2046355c1513SAdrian Chadd #define IWM_PHY_DB_CMD				0x6c
2047d4886179SRui Paulo 
2048d4886179SRui Paulo /* Power - legacy power table command */
2049355c1513SAdrian Chadd #define IWM_POWER_TABLE_CMD				0x77
2050355c1513SAdrian Chadd #define IWM_PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION	0x78
2051355c1513SAdrian Chadd #define IWM_LTR_CONFIG					0xee
2052d4886179SRui Paulo 
2053d4886179SRui Paulo /* Thermal Throttling*/
2054355c1513SAdrian Chadd #define IWM_REPLY_THERMAL_MNG_BACKOFF	0x7e
2055d4886179SRui Paulo 
2056d4886179SRui Paulo /* NVM */
2057355c1513SAdrian Chadd #define IWM_NVM_ACCESS_CMD	0x88
2058d4886179SRui Paulo 
2059355c1513SAdrian Chadd #define IWM_SET_CALIB_DEFAULT_CMD	0x8e
2060d4886179SRui Paulo 
2061355c1513SAdrian Chadd #define IWM_BEACON_NOTIFICATION		0x90
2062355c1513SAdrian Chadd #define IWM_BEACON_TEMPLATE_CMD		0x91
2063355c1513SAdrian Chadd #define IWM_TX_ANT_CONFIGURATION_CMD	0x98
2064355c1513SAdrian Chadd #define IWM_BT_CONFIG			0x9b
2065355c1513SAdrian Chadd #define IWM_STATISTICS_NOTIFICATION	0x9d
2066355c1513SAdrian Chadd #define IWM_REDUCE_TX_POWER_CMD		0x9f
2067d4886179SRui Paulo 
2068d4886179SRui Paulo /* RF-KILL commands and notifications */
2069355c1513SAdrian Chadd #define IWM_CARD_STATE_CMD		0xa0
2070355c1513SAdrian Chadd #define IWM_CARD_STATE_NOTIFICATION	0xa1
2071d4886179SRui Paulo 
2072355c1513SAdrian Chadd #define IWM_MISSED_BEACONS_NOTIFICATION	0xa2
2073d4886179SRui Paulo 
2074355c1513SAdrian Chadd #define IWM_MFUART_LOAD_NOTIFICATION	0xb1
20756a5bc1d1SSean Bruno 
2076d4886179SRui Paulo /* Power - new power table command */
2077355c1513SAdrian Chadd #define IWM_MAC_PM_POWER_TABLE	0xa9
2078d4886179SRui Paulo 
2079355c1513SAdrian Chadd #define IWM_REPLY_RX_PHY_CMD	0xc0
2080355c1513SAdrian Chadd #define IWM_REPLY_RX_MPDU_CMD	0xc1
2081355c1513SAdrian Chadd #define IWM_BA_NOTIF		0xc5
2082d4886179SRui Paulo 
20836a5bc1d1SSean Bruno /* Location Aware Regulatory */
2084355c1513SAdrian Chadd #define IWM_MCC_UPDATE_CMD	0xc8
2085355c1513SAdrian Chadd #define IWM_MCC_CHUB_UPDATE_CMD	0xc9
20866a5bc1d1SSean Bruno 
2087d4886179SRui Paulo /* BT Coex */
2088355c1513SAdrian Chadd #define IWM_BT_COEX_PRIO_TABLE	0xcc
2089355c1513SAdrian Chadd #define IWM_BT_COEX_PROT_ENV	0xcd
2090355c1513SAdrian Chadd #define IWM_BT_PROFILE_NOTIFICATION	0xce
2091355c1513SAdrian Chadd #define IWM_BT_COEX_CI	0x5d
2092d4886179SRui Paulo 
2093355c1513SAdrian Chadd #define IWM_REPLY_SF_CFG_CMD		0xd1
2094355c1513SAdrian Chadd #define IWM_REPLY_BEACON_FILTERING_CMD	0xd2
2095d4886179SRui Paulo 
20966a5bc1d1SSean Bruno /* DTS measurements */
2097355c1513SAdrian Chadd #define IWM_CMD_DTS_MEASUREMENT_TRIGGER		0xdc
2098355c1513SAdrian Chadd #define IWM_DTS_MEASUREMENT_NOTIFICATION	0xdd
20996a5bc1d1SSean Bruno 
2100355c1513SAdrian Chadd #define IWM_REPLY_DEBUG_CMD	0xf0
2101355c1513SAdrian Chadd #define IWM_DEBUG_LOG_MSG	0xf7
2102d4886179SRui Paulo 
2103355c1513SAdrian Chadd #define IWM_MCAST_FILTER_CMD	0xd0
2104d4886179SRui Paulo 
2105d4886179SRui Paulo /* D3 commands/notifications */
2106355c1513SAdrian Chadd #define IWM_D3_CONFIG_CMD		0xd3
2107355c1513SAdrian Chadd #define IWM_PROT_OFFLOAD_CONFIG_CMD	0xd4
2108355c1513SAdrian Chadd #define IWM_OFFLOADS_QUERY_CMD		0xd5
2109355c1513SAdrian Chadd #define IWM_REMOTE_WAKE_CONFIG_CMD	0xd6
2110d4886179SRui Paulo 
2111d4886179SRui Paulo /* for WoWLAN in particular */
2112355c1513SAdrian Chadd #define IWM_WOWLAN_PATTERNS		0xe0
2113355c1513SAdrian Chadd #define IWM_WOWLAN_CONFIGURATION	0xe1
2114355c1513SAdrian Chadd #define IWM_WOWLAN_TSC_RSC_PARAM	0xe2
2115355c1513SAdrian Chadd #define IWM_WOWLAN_TKIP_PARAM		0xe3
2116355c1513SAdrian Chadd #define IWM_WOWLAN_KEK_KCK_MATERIAL	0xe4
2117355c1513SAdrian Chadd #define IWM_WOWLAN_GET_STATUSES		0xe5
2118355c1513SAdrian Chadd #define IWM_WOWLAN_TX_POWER_PER_DB	0xe6
2119d4886179SRui Paulo 
2120d4886179SRui Paulo /* and for NetDetect */
2121355c1513SAdrian Chadd #define IWM_NET_DETECT_CONFIG_CMD		0x54
2122355c1513SAdrian Chadd #define IWM_NET_DETECT_PROFILES_QUERY_CMD	0x56
2123355c1513SAdrian Chadd #define IWM_NET_DETECT_PROFILES_CMD		0x57
2124355c1513SAdrian Chadd #define IWM_NET_DETECT_HOTSPOTS_CMD		0x58
2125355c1513SAdrian Chadd #define IWM_NET_DETECT_HOTSPOTS_QUERY_CMD	0x59
2126d4886179SRui Paulo 
2127355c1513SAdrian Chadd /* system group command IDs */
2128355c1513SAdrian Chadd #define IWM_FSEQ_VER_MISMATCH_NOTIFICATION	0xff
2129355c1513SAdrian Chadd 
2130355c1513SAdrian Chadd #define IWM_REPLY_MAX	0xff
2131355c1513SAdrian Chadd 
2132355c1513SAdrian Chadd /* PHY_OPS subcommand IDs */
2133355c1513SAdrian Chadd #define IWM_CMD_DTS_MEASUREMENT_TRIGGER_WIDE	0x0
2134355c1513SAdrian Chadd #define IWM_CTDP_CONFIG_CMD			0x03
2135355c1513SAdrian Chadd #define IWM_TEMP_REPORTING_THRESHOLDS_CMD	0x04
2136355c1513SAdrian Chadd #define IWM_CT_KILL_NOTIFICATION		0xFE
2137355c1513SAdrian Chadd #define IWM_DTS_MEASUREMENT_NOTIF_WIDE		0xFF
21384329ac62SAdrian Chadd 
21394329ac62SAdrian Chadd /* command groups */
2140355c1513SAdrian Chadd #define IWM_LEGACY_GROUP	0x0
2141355c1513SAdrian Chadd #define IWM_LONG_GROUP		0x1
2142355c1513SAdrian Chadd #define IWM_SYSTEM_GROUP	0x2
2143355c1513SAdrian Chadd #define IWM_MAC_CONF_GROUP	0x3
2144355c1513SAdrian Chadd #define IWM_PHY_OPS_GROUP	0x4
2145355c1513SAdrian Chadd #define IWM_DATA_PATH_GROUP	0x5
2146355c1513SAdrian Chadd #define IWM_PROT_OFFLOAD_GROUP	0xb
2147355c1513SAdrian Chadd 
2148355c1513SAdrian Chadd /* SYSTEM_GROUP group subcommand IDs */
2149355c1513SAdrian Chadd 
2150355c1513SAdrian Chadd #define IWM_SHARED_MEM_CFG_CMD		0x00
2151355c1513SAdrian Chadd #define IWM_SOC_CONFIGURATION_CMD	0x01
2152355c1513SAdrian Chadd #define IWM_INIT_EXTENDED_CFG_CMD	0x03
2153355c1513SAdrian Chadd #define IWM_FW_ERROR_RECOVERY_CMD	0x07
2154355c1513SAdrian Chadd 
2155355c1513SAdrian Chadd /* DATA_PATH group subcommand IDs */
2156355c1513SAdrian Chadd #define IWM_DQA_ENABLE_CMD	0x00
2157355c1513SAdrian Chadd 
2158355c1513SAdrian Chadd /*
2159355c1513SAdrian Chadd  * struct iwm_dqa_enable_cmd
2160355c1513SAdrian Chadd  * @cmd_queue: the TXQ number of the command queue
2161355c1513SAdrian Chadd  */
2162355c1513SAdrian Chadd struct iwm_dqa_enable_cmd {
2163355c1513SAdrian Chadd 	uint32_t cmd_queue;
2164355c1513SAdrian Chadd } __packed; /* DQA_CONTROL_CMD_API_S_VER_1 */
21654329ac62SAdrian Chadd 
2166d4886179SRui Paulo /**
2167d4886179SRui Paulo  * struct iwm_cmd_response - generic response struct for most commands
2168d4886179SRui Paulo  * @status: status of the command asked, changes for each one
2169d4886179SRui Paulo  */
2170d4886179SRui Paulo struct iwm_cmd_response {
2171d4886179SRui Paulo 	uint32_t status;
2172d4886179SRui Paulo };
2173d4886179SRui Paulo 
2174d4886179SRui Paulo /*
2175d4886179SRui Paulo  * struct iwm_tx_ant_cfg_cmd
2176d4886179SRui Paulo  * @valid: valid antenna configuration
2177d4886179SRui Paulo  */
2178d4886179SRui Paulo struct iwm_tx_ant_cfg_cmd {
2179d4886179SRui Paulo 	uint32_t valid;
2180d4886179SRui Paulo } __packed;
2181d4886179SRui Paulo 
2182d4886179SRui Paulo /**
2183d4886179SRui Paulo  * struct iwm_reduce_tx_power_cmd - TX power reduction command
2184d4886179SRui Paulo  * IWM_REDUCE_TX_POWER_CMD = 0x9f
2185d4886179SRui Paulo  * @flags: (reserved for future implementation)
2186d4886179SRui Paulo  * @mac_context_id: id of the mac ctx for which we are reducing TX power.
2187d4886179SRui Paulo  * @pwr_restriction: TX power restriction in dBms.
2188d4886179SRui Paulo  */
2189d4886179SRui Paulo struct iwm_reduce_tx_power_cmd {
2190d4886179SRui Paulo 	uint8_t flags;
2191d4886179SRui Paulo 	uint8_t mac_context_id;
2192d4886179SRui Paulo 	uint16_t pwr_restriction;
2193d4886179SRui Paulo } __packed; /* IWM_TX_REDUCED_POWER_API_S_VER_1 */
2194d4886179SRui Paulo 
2195d4886179SRui Paulo /*
2196d4886179SRui Paulo  * Calibration control struct.
2197d4886179SRui Paulo  * Sent as part of the phy configuration command.
2198d4886179SRui Paulo  * @flow_trigger: bitmap for which calibrations to perform according to
2199d4886179SRui Paulo  *		flow triggers.
2200d4886179SRui Paulo  * @event_trigger: bitmap for which calibrations to perform according to
2201d4886179SRui Paulo  *		event triggers.
2202d4886179SRui Paulo  */
2203d4886179SRui Paulo struct iwm_calib_ctrl {
2204d4886179SRui Paulo 	uint32_t flow_trigger;
2205d4886179SRui Paulo 	uint32_t event_trigger;
2206d4886179SRui Paulo } __packed;
2207d4886179SRui Paulo 
2208355c1513SAdrian Chadd /* This defines the bitmap of various calibrations to enable in both
2209d4886179SRui Paulo  * init ucode and runtime ucode through IWM_CALIBRATION_CFG_CMD.
2210d4886179SRui Paulo  */
2211355c1513SAdrian Chadd #define IWM_CALIB_CFG_XTAL_IDX			(1 << 0)
2212355c1513SAdrian Chadd #define IWM_CALIB_CFG_TEMPERATURE_IDX		(1 << 1)
2213355c1513SAdrian Chadd #define IWM_CALIB_CFG_VOLTAGE_READ_IDX		(1 << 2)
2214355c1513SAdrian Chadd #define IWM_CALIB_CFG_PAPD_IDX			(1 << 3)
2215355c1513SAdrian Chadd #define IWM_CALIB_CFG_TX_PWR_IDX		(1 << 4)
2216355c1513SAdrian Chadd #define IWM_CALIB_CFG_DC_IDX			(1 << 5)
2217355c1513SAdrian Chadd #define IWM_CALIB_CFG_BB_FILTER_IDX		(1 << 6)
2218355c1513SAdrian Chadd #define IWM_CALIB_CFG_LO_LEAKAGE_IDX		(1 << 7)
2219355c1513SAdrian Chadd #define IWM_CALIB_CFG_TX_IQ_IDX			(1 << 8)
2220355c1513SAdrian Chadd #define IWM_CALIB_CFG_TX_IQ_SKEW_IDX		(1 << 9)
2221355c1513SAdrian Chadd #define IWM_CALIB_CFG_RX_IQ_IDX			(1 << 10)
2222355c1513SAdrian Chadd #define IWM_CALIB_CFG_RX_IQ_SKEW_IDX		(1 << 11)
2223355c1513SAdrian Chadd #define IWM_CALIB_CFG_SENSITIVITY_IDX		(1 << 12)
2224355c1513SAdrian Chadd #define IWM_CALIB_CFG_CHAIN_NOISE_IDX		(1 << 13)
2225355c1513SAdrian Chadd #define IWM_CALIB_CFG_DISCONNECTED_ANT_IDX	(1 << 14)
2226355c1513SAdrian Chadd #define IWM_CALIB_CFG_ANT_COUPLING_IDX		(1 << 15)
2227355c1513SAdrian Chadd #define IWM_CALIB_CFG_DAC_IDX			(1 << 16)
2228355c1513SAdrian Chadd #define IWM_CALIB_CFG_ABS_IDX			(1 << 17)
2229355c1513SAdrian Chadd #define IWM_CALIB_CFG_AGC_IDX			(1 << 18)
2230d4886179SRui Paulo 
2231d4886179SRui Paulo /*
2232d4886179SRui Paulo  * Phy configuration command.
2233d4886179SRui Paulo  */
2234d4886179SRui Paulo struct iwm_phy_cfg_cmd {
2235d4886179SRui Paulo 	uint32_t	phy_cfg;
2236d4886179SRui Paulo 	struct iwm_calib_ctrl calib_control;
2237d4886179SRui Paulo } __packed;
2238d4886179SRui Paulo 
2239d4886179SRui Paulo #define IWM_PHY_CFG_RADIO_TYPE	((1 << 0) | (1 << 1))
2240d4886179SRui Paulo #define IWM_PHY_CFG_RADIO_STEP	((1 << 2) | (1 << 3))
2241d4886179SRui Paulo #define IWM_PHY_CFG_RADIO_DASH	((1 << 4) | (1 << 5))
2242d4886179SRui Paulo #define IWM_PHY_CFG_PRODUCT_NUMBER	((1 << 6) | (1 << 7))
2243d4886179SRui Paulo #define IWM_PHY_CFG_TX_CHAIN_A	(1 << 8)
2244d4886179SRui Paulo #define IWM_PHY_CFG_TX_CHAIN_B	(1 << 9)
2245d4886179SRui Paulo #define IWM_PHY_CFG_TX_CHAIN_C	(1 << 10)
2246d4886179SRui Paulo #define IWM_PHY_CFG_RX_CHAIN_A	(1 << 12)
2247d4886179SRui Paulo #define IWM_PHY_CFG_RX_CHAIN_B	(1 << 13)
2248d4886179SRui Paulo #define IWM_PHY_CFG_RX_CHAIN_C	(1 << 14)
2249d4886179SRui Paulo 
2250355c1513SAdrian Chadd #define IWM_MAX_DTS_TRIPS	8
2251355c1513SAdrian Chadd 
2252355c1513SAdrian Chadd /**
2253355c1513SAdrian Chadd  * struct iwm_ct_kill_notif - CT-kill entry notification
2254355c1513SAdrian Chadd  *
2255355c1513SAdrian Chadd  * @temperature: the current temperature in celsius
2256355c1513SAdrian Chadd  * @reserved: reserved
2257355c1513SAdrian Chadd  */
2258355c1513SAdrian Chadd struct iwm_ct_kill_notif {
2259355c1513SAdrian Chadd 	uint16_t temperature;
2260355c1513SAdrian Chadd 	uint16_t reserved;
2261355c1513SAdrian Chadd } __packed; /* GRP_PHY_CT_KILL_NTF */
2262355c1513SAdrian Chadd 
2263355c1513SAdrian Chadd /**
2264355c1513SAdrian Chadd  * struct iwm_temp_report_ths_cmd - set temperature thresholds
2265355c1513SAdrian Chadd  * (IWM_TEMP_REPORTING_THRESHOLDS_CMD)
2266355c1513SAdrian Chadd  *
2267355c1513SAdrian Chadd  * @num_temps: number of temperature thresholds passed
2268355c1513SAdrian Chadd  * @thresholds: array with the thresholds to be configured
2269355c1513SAdrian Chadd  */
2270355c1513SAdrian Chadd struct iwm_temp_report_ths_cmd {
2271355c1513SAdrian Chadd 	uint32_t num_temps;
2272355c1513SAdrian Chadd 	uint16_t thresholds[IWM_MAX_DTS_TRIPS];
2273355c1513SAdrian Chadd } __packed; /* GRP_PHY_TEMP_REPORTING_THRESHOLDS_CMD */
2274355c1513SAdrian Chadd 
2275355c1513SAdrian Chadd /*
2276355c1513SAdrian Chadd  * PHY db
2277355c1513SAdrian Chadd  */
2278355c1513SAdrian Chadd 
2279355c1513SAdrian Chadd enum iwm_phy_db_section_type {
2280355c1513SAdrian Chadd 	IWM_PHY_DB_CFG = 1,
2281355c1513SAdrian Chadd 	IWM_PHY_DB_CALIB_NCH,
2282355c1513SAdrian Chadd 	IWM_PHY_DB_UNUSED,
2283355c1513SAdrian Chadd 	IWM_PHY_DB_CALIB_CHG_PAPD,
2284355c1513SAdrian Chadd 	IWM_PHY_DB_CALIB_CHG_TXP,
2285355c1513SAdrian Chadd 	IWM_PHY_DB_MAX
2286355c1513SAdrian Chadd };
2287355c1513SAdrian Chadd 
2288355c1513SAdrian Chadd /*
2289355c1513SAdrian Chadd  * phy db - configure operational ucode
2290355c1513SAdrian Chadd  */
2291355c1513SAdrian Chadd struct iwm_phy_db_cmd {
2292355c1513SAdrian Chadd 	uint16_t type;
2293355c1513SAdrian Chadd 	uint16_t length;
2294355c1513SAdrian Chadd 	uint8_t data[];
2295355c1513SAdrian Chadd } __packed;
2296355c1513SAdrian Chadd 
2297355c1513SAdrian Chadd /* for parsing of tx power channel group data that comes from the firmware*/
2298355c1513SAdrian Chadd struct iwm_phy_db_chg_txp {
2299355c1513SAdrian Chadd 	uint32_t space;
2300355c1513SAdrian Chadd 	uint16_t max_channel_idx;
2301355c1513SAdrian Chadd } __packed;
2302355c1513SAdrian Chadd 
2303355c1513SAdrian Chadd /*
2304355c1513SAdrian Chadd  * phy db - Receive phy db chunk after calibrations
2305355c1513SAdrian Chadd  */
2306355c1513SAdrian Chadd struct iwm_calib_res_notif_phy_db {
2307355c1513SAdrian Chadd 	uint16_t type;
2308355c1513SAdrian Chadd 	uint16_t length;
2309355c1513SAdrian Chadd 	uint8_t data[];
2310355c1513SAdrian Chadd } __packed;
2311355c1513SAdrian Chadd 
2312355c1513SAdrian Chadd /* 7k family NVM HW-Section offset (in words) definitions */
2313355c1513SAdrian Chadd #define IWM_HW_ADDR	0x15
2314355c1513SAdrian Chadd /* 7k family NVM SW-Section offset (in words) definitions */
2315355c1513SAdrian Chadd #define IWM_NVM_SW_SECTION	0x1C0
2316355c1513SAdrian Chadd #define IWM_NVM_VERSION		0
2317355c1513SAdrian Chadd #define IWM_RADIO_CFG		1
2318355c1513SAdrian Chadd #define IWM_SKU			2
2319355c1513SAdrian Chadd #define IWM_N_HW_ADDRS		3
2320355c1513SAdrian Chadd #define IWM_NVM_CHANNELS	0x1E0 - IWM_NVM_SW_SECTION
2321355c1513SAdrian Chadd /* 7k family NVM calibration section offset (in words) definitions */
2322355c1513SAdrian Chadd #define IWM_NVM_CALIB_SECTION	0x2B8
2323355c1513SAdrian Chadd #define IWM_XTAL_CALIB		(0x316 - IWM_NVM_CALIB_SECTION)
2324355c1513SAdrian Chadd 
2325355c1513SAdrian Chadd /* 8k family NVM HW-Section offset (in words) definitions */
2326355c1513SAdrian Chadd #define IWM_HW_ADDR0_WFPM_8000		0x12
2327355c1513SAdrian Chadd #define IWM_HW_ADDR1_WFPM_8000		0x16
2328355c1513SAdrian Chadd #define IWM_HW_ADDR0_PCIE_8000		0x8A
2329355c1513SAdrian Chadd #define IWM_HW_ADDR1_PCIE_8000		0x8E
2330355c1513SAdrian Chadd #define IWM_MAC_ADDRESS_OVERRIDE_8000	1
2331355c1513SAdrian Chadd 
2332355c1513SAdrian Chadd /* 8k family NVM SW-Section offset (in words) definitions */
2333355c1513SAdrian Chadd #define IWM_NVM_SW_SECTION_8000	0x1C0
2334355c1513SAdrian Chadd #define IWM_NVM_VERSION_8000	0
2335355c1513SAdrian Chadd #define IWM_RADIO_CFG_8000	0
2336355c1513SAdrian Chadd #define IWM_SKU_8000		2
2337355c1513SAdrian Chadd #define IWM_N_HW_ADDRS_8000	3
2338355c1513SAdrian Chadd 
2339355c1513SAdrian Chadd /* 8k family NVM REGULATORY -Section offset (in words) definitions */
2340355c1513SAdrian Chadd #define IWM_NVM_CHANNELS_8000		0
2341355c1513SAdrian Chadd #define IWM_NVM_LAR_OFFSET_8000_OLD	0x4C7
2342355c1513SAdrian Chadd #define IWM_NVM_LAR_OFFSET_8000		0x507
2343355c1513SAdrian Chadd #define IWM_NVM_LAR_ENABLED_8000	0x7
2344355c1513SAdrian Chadd 
2345355c1513SAdrian Chadd /* 8k family NVM calibration section offset (in words) definitions */
2346355c1513SAdrian Chadd #define IWM_NVM_CALIB_SECTION_8000	0x2B8
2347355c1513SAdrian Chadd #define IWM_XTAL_CALIB_8000		(0x316 - IWM_NVM_CALIB_SECTION_8000)
2348355c1513SAdrian Chadd 
2349355c1513SAdrian Chadd /* SKU Capabilities (actual values from NVM definition) */
2350355c1513SAdrian Chadd #define IWM_NVM_SKU_CAP_BAND_24GHZ	(1 << 0)
2351355c1513SAdrian Chadd #define IWM_NVM_SKU_CAP_BAND_52GHZ	(1 << 1)
2352355c1513SAdrian Chadd #define IWM_NVM_SKU_CAP_11N_ENABLE	(1 << 2)
2353355c1513SAdrian Chadd #define IWM_NVM_SKU_CAP_11AC_ENABLE	(1 << 3)
2354355c1513SAdrian Chadd #define IWM_NVM_SKU_CAP_MIMO_DISABLE	(1 << 5)
2355355c1513SAdrian Chadd 
2356355c1513SAdrian Chadd /* radio config bits (actual values from NVM definition) */
2357355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_DASH_MSK(x)   (x & 0x3)         /* bits 0-1   */
2358355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_STEP_MSK(x)   ((x >> 2)  & 0x3) /* bits 2-3   */
2359355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_TYPE_MSK(x)   ((x >> 4)  & 0x3) /* bits 4-5   */
2360355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_PNUM_MSK(x)   ((x >> 6)  & 0x3) /* bits 6-7   */
2361355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8)  & 0xF) /* bits 8-11  */
2362355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
2363355c1513SAdrian Chadd 
2364355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_PNUM_MSK_8000(x)		(x & 0xF)
2365355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_DASH_MSK_8000(x)		((x >> 4) & 0xF)
2366355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_STEP_MSK_8000(x)		((x >> 8) & 0xF)
2367355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_TYPE_MSK_8000(x)		((x >> 12) & 0xFFF)
2368355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_TX_ANT_MSK_8000(x)	((x >> 24) & 0xF)
2369355c1513SAdrian Chadd #define IWM_NVM_RF_CFG_RX_ANT_MSK_8000(x)	((x >> 28) & 0xF)
2370355c1513SAdrian Chadd 
2371355c1513SAdrian Chadd /*
2372355c1513SAdrian Chadd  * channel flags in NVM
2373355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_VALID: channel is usable for this SKU/geo
2374355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_IBSS: usable as an IBSS channel
2375355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_ACTIVE: active scanning allowed
2376355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_RADAR: radar detection required
2377355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_DFS: dynamic freq selection candidate
2378355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_WIDE: 20 MHz channel okay (?)
2379355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_40MHZ: 40 MHz channel okay (?)
2380355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_80MHZ: 80 MHz channel okay (?)
2381355c1513SAdrian Chadd  * @IWM_NVM_CHANNEL_160MHZ: 160 MHz channel okay (?)
2382355c1513SAdrian Chadd  */
2383355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_VALID	(1 << 0)
2384355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_IBSS	(1 << 1)
2385355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_ACTIVE	(1 << 3)
2386355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_RADAR	(1 << 4)
2387355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_DFS	(1 << 7)
2388355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_WIDE	(1 << 8)
2389355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_40MHZ	(1 << 9)
2390355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_80MHZ	(1 << 10)
2391355c1513SAdrian Chadd #define IWM_NVM_CHANNEL_160MHZ	(1 << 11)
2392d4886179SRui Paulo 
2393d4886179SRui Paulo /* Target of the IWM_NVM_ACCESS_CMD */
2394355c1513SAdrian Chadd #define IWM_NVM_ACCESS_TARGET_CACHE	0
2395355c1513SAdrian Chadd #define IWM_NVM_ACCESS_TARGET_OTP	1
2396355c1513SAdrian Chadd #define IWM_NVM_ACCESS_TARGET_EEPROM	2
2397d4886179SRui Paulo 
2398d4886179SRui Paulo /* Section types for IWM_NVM_ACCESS_CMD */
2399355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_HW			0
2400355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_SW			1
2401355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_PAPD		2
2402355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_REGULATORY		3
2403355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_CALIBRATION	4
2404355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_PRODUCTION		5
2405355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_POST_FCS_CALIB	6
2406355c1513SAdrian Chadd /* 7 unknown */
2407355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_REGULATORY_SDP	8
2408355c1513SAdrian Chadd /* 9 unknown */
2409355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_HW_8000		10
2410355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_MAC_OVERRIDE	11
2411355c1513SAdrian Chadd #define IWM_NVM_SECTION_TYPE_PHY_SKU		12
2412355c1513SAdrian Chadd #define IWM_NVM_NUM_OF_SECTIONS			13
2413d4886179SRui Paulo 
2414d4886179SRui Paulo /**
2415d4886179SRui Paulo  * struct iwm_nvm_access_cmd_ver2 - Request the device to send an NVM section
2416d4886179SRui Paulo  * @op_code: 0 - read, 1 - write
2417d4886179SRui Paulo  * @target: IWM_NVM_ACCESS_TARGET_*
2418d4886179SRui Paulo  * @type: IWM_NVM_SECTION_TYPE_*
2419d4886179SRui Paulo  * @offset: offset in bytes into the section
2420d4886179SRui Paulo  * @length: in bytes, to read/write
2421d4886179SRui Paulo  * @data: if write operation, the data to write. On read its empty
2422d4886179SRui Paulo  */
2423d4886179SRui Paulo struct iwm_nvm_access_cmd {
2424d4886179SRui Paulo 	uint8_t op_code;
2425d4886179SRui Paulo 	uint8_t target;
2426d4886179SRui Paulo 	uint16_t type;
2427d4886179SRui Paulo 	uint16_t offset;
2428d4886179SRui Paulo 	uint16_t length;
2429d4886179SRui Paulo 	uint8_t data[];
2430d4886179SRui Paulo } __packed; /* IWM_NVM_ACCESS_CMD_API_S_VER_2 */
2431d4886179SRui Paulo 
2432355c1513SAdrian Chadd /*
2433355c1513SAdrian Chadd  * Block paging calculations
2434355c1513SAdrian Chadd  */
2435355c1513SAdrian Chadd #define IWM_PAGE_2_EXP_SIZE 12 /* 4K == 2^12 */
2436355c1513SAdrian Chadd #define IWM_FW_PAGING_SIZE (1 << IWM_PAGE_2_EXP_SIZE) /* page size is 4KB */
2437355c1513SAdrian Chadd #define IWM_PAGE_PER_GROUP_2_EXP_SIZE 3
2438355c1513SAdrian Chadd /* 8 pages per group */
2439355c1513SAdrian Chadd #define IWM_NUM_OF_PAGE_PER_GROUP (1 << IWM_PAGE_PER_GROUP_2_EXP_SIZE)
2440355c1513SAdrian Chadd /* don't change, support only 32KB size */
2441355c1513SAdrian Chadd #define IWM_PAGING_BLOCK_SIZE (IWM_NUM_OF_PAGE_PER_GROUP * IWM_FW_PAGING_SIZE)
2442355c1513SAdrian Chadd /* 32K == 2^15 */
2443355c1513SAdrian Chadd #define IWM_BLOCK_2_EXP_SIZE (IWM_PAGE_2_EXP_SIZE + IWM_PAGE_PER_GROUP_2_EXP_SIZE)
2444355c1513SAdrian Chadd 
2445355c1513SAdrian Chadd /*
2446355c1513SAdrian Chadd  * Image paging calculations
2447355c1513SAdrian Chadd  */
2448355c1513SAdrian Chadd #define IWM_BLOCK_PER_IMAGE_2_EXP_SIZE 5
2449355c1513SAdrian Chadd /* 2^5 == 32 blocks per image */
2450355c1513SAdrian Chadd #define IWM_NUM_OF_BLOCK_PER_IMAGE (1 << IWM_BLOCK_PER_IMAGE_2_EXP_SIZE)
2451355c1513SAdrian Chadd /* maximum image size 1024KB */
2452355c1513SAdrian Chadd #define IWM_MAX_PAGING_IMAGE_SIZE (IWM_NUM_OF_BLOCK_PER_IMAGE * IWM_PAGING_BLOCK_SIZE)
2453355c1513SAdrian Chadd 
2454355c1513SAdrian Chadd /* Virtual address signature */
2455355c1513SAdrian Chadd #define IWM_PAGING_ADDR_SIG 0xAA000000
2456355c1513SAdrian Chadd 
2457355c1513SAdrian Chadd #define IWM_PAGING_CMD_IS_SECURED (1 << 9)
2458355c1513SAdrian Chadd #define IWM_PAGING_CMD_IS_ENABLED (1 << 8)
2459355c1513SAdrian Chadd #define IWM_PAGING_CMD_NUM_OF_PAGES_IN_LAST_GRP_POS 0
2460355c1513SAdrian Chadd #define IWM_PAGING_TLV_SECURE_MASK 1
2461355c1513SAdrian Chadd 
2462ad35d471SAdrian Chadd #define IWM_NUM_OF_FW_PAGING_BLOCKS	33 /* 32 for data and 1 block for CSS */
2463ad35d471SAdrian Chadd 
2464ad35d471SAdrian Chadd /*
2465ad35d471SAdrian Chadd  * struct iwm_fw_paging_cmd - paging layout
2466ad35d471SAdrian Chadd  *
2467ad35d471SAdrian Chadd  * (IWM_FW_PAGING_BLOCK_CMD = 0x4f)
2468ad35d471SAdrian Chadd  *
2469ad35d471SAdrian Chadd  * Send to FW the paging layout in the driver.
2470ad35d471SAdrian Chadd  *
2471ad35d471SAdrian Chadd  * @flags: various flags for the command
2472ad35d471SAdrian Chadd  * @block_size: the block size in powers of 2
2473ad35d471SAdrian Chadd  * @block_num: number of blocks specified in the command.
2474ad35d471SAdrian Chadd  * @device_phy_addr: virtual addresses from device side
2475ad35d471SAdrian Chadd */
2476ad35d471SAdrian Chadd struct iwm_fw_paging_cmd {
2477ad35d471SAdrian Chadd 	uint32_t flags;
2478ad35d471SAdrian Chadd 	uint32_t block_size;
2479ad35d471SAdrian Chadd 	uint32_t block_num;
2480ad35d471SAdrian Chadd 	uint32_t device_phy_addr[IWM_NUM_OF_FW_PAGING_BLOCKS];
2481ad35d471SAdrian Chadd } __packed; /* IWM_FW_PAGING_BLOCK_CMD_API_S_VER_1 */
2482ad35d471SAdrian Chadd 
2483d4886179SRui Paulo /**
2484d4886179SRui Paulo  * struct iwm_nvm_access_resp_ver2 - response to IWM_NVM_ACCESS_CMD
2485d4886179SRui Paulo  * @offset: offset in bytes into the section
2486d4886179SRui Paulo  * @length: in bytes, either how much was written or read
2487d4886179SRui Paulo  * @type: IWM_NVM_SECTION_TYPE_*
2488d4886179SRui Paulo  * @status: 0 for success, fail otherwise
2489d4886179SRui Paulo  * @data: if read operation, the data returned. Empty on write.
2490d4886179SRui Paulo  */
2491d4886179SRui Paulo struct iwm_nvm_access_resp {
2492d4886179SRui Paulo 	uint16_t offset;
2493d4886179SRui Paulo 	uint16_t length;
2494d4886179SRui Paulo 	uint16_t type;
2495d4886179SRui Paulo 	uint16_t status;
2496d4886179SRui Paulo 	uint8_t data[];
2497d4886179SRui Paulo } __packed; /* IWM_NVM_ACCESS_CMD_RESP_API_S_VER_2 */
2498d4886179SRui Paulo 
2499e7065dd1SMark Johnston /* IWM_ALIVE 0x1 */
2500d4886179SRui Paulo 
2501d4886179SRui Paulo /* alive response is_valid values */
2502d4886179SRui Paulo #define IWM_ALIVE_RESP_UCODE_OK	(1 << 0)
2503d4886179SRui Paulo #define IWM_ALIVE_RESP_RFKILL	(1 << 1)
2504d4886179SRui Paulo 
2505d4886179SRui Paulo /* alive response ver_type values */
2506355c1513SAdrian Chadd #define IWM_FW_TYPE_HW		0
2507355c1513SAdrian Chadd #define IWM_FW_TYPE_PROT	1
2508355c1513SAdrian Chadd #define IWM_FW_TYPE_AP		2
2509355c1513SAdrian Chadd #define IWM_FW_TYPE_WOWLAN	3
2510355c1513SAdrian Chadd #define IWM_FW_TYPE_TIMING	4
2511355c1513SAdrian Chadd #define IWM_FW_TYPE_WIPAN	5
2512d4886179SRui Paulo 
2513d4886179SRui Paulo /* alive response ver_subtype values */
2514355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_FULL_FEATURE	0
2515355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_BOOTSRAP		1 /* Not valid */
2516355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_REDUCED		2
2517355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_ALIVE_ONLY	3
2518355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_WOWLAN		4
2519355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_AP_SUBTYPE	5
2520355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_WIPAN		6
2521355c1513SAdrian Chadd #define IWM_FW_SUBTYPE_INITIALIZE	9
2522d4886179SRui Paulo 
2523d4886179SRui Paulo #define IWM_ALIVE_STATUS_ERR 0xDEAD
2524d4886179SRui Paulo #define IWM_ALIVE_STATUS_OK 0xCAFE
2525d4886179SRui Paulo 
2526d4886179SRui Paulo #define IWM_ALIVE_FLG_RFKILL	(1 << 0)
2527d4886179SRui Paulo 
2528e4bc6d1dSKyle Evans struct iwm_lmac_alive {
2529e4bc6d1dSKyle Evans 	uint32_t ucode_major;
2530e4bc6d1dSKyle Evans 	uint32_t ucode_minor;
2531d4886179SRui Paulo 	uint8_t ver_subtype;
2532d4886179SRui Paulo 	uint8_t ver_type;
2533d4886179SRui Paulo 	uint8_t mac;
2534d4886179SRui Paulo 	uint8_t opt;
25356a5bc1d1SSean Bruno 	uint32_t timestamp;
25366a5bc1d1SSean Bruno 	uint32_t error_event_table_ptr;	/* SRAM address for error log */
25376a5bc1d1SSean Bruno 	uint32_t log_event_table_ptr;	/* SRAM address for LMAC event log */
25386a5bc1d1SSean Bruno 	uint32_t cpu_register_ptr;
25396a5bc1d1SSean Bruno 	uint32_t dbgm_config_ptr;
25406a5bc1d1SSean Bruno 	uint32_t alive_counter_ptr;
25416a5bc1d1SSean Bruno 	uint32_t scd_base_ptr;		/* SRAM address for SCD */
25426a5bc1d1SSean Bruno 	uint32_t st_fwrd_addr;		/* pointer to Store and forward */
25436a5bc1d1SSean Bruno 	uint32_t st_fwrd_size;
2544e4bc6d1dSKyle Evans } __packed; /* UCODE_ALIVE_NTFY_API_S_VER_3 */
2545e4bc6d1dSKyle Evans 
2546e4bc6d1dSKyle Evans struct iwm_umac_alive {
2547e4bc6d1dSKyle Evans 	uint32_t umac_major;            /* UMAC version: major */
2548e4bc6d1dSKyle Evans 	uint32_t umac_minor;            /* UMAC version: minor */
25496a5bc1d1SSean Bruno 	uint32_t error_info_addr;       /* SRAM address for UMAC error log */
25506a5bc1d1SSean Bruno 	uint32_t dbg_print_buff_addr;
2551e4bc6d1dSKyle Evans } __packed; /* UMAC_ALIVE_DATA_API_S_VER_2 */
2552e4bc6d1dSKyle Evans 
2553e7065dd1SMark Johnston struct iwm_alive_resp_v3 {
2554e4bc6d1dSKyle Evans 	uint16_t status;
2555e4bc6d1dSKyle Evans 	uint16_t flags;
2556e4bc6d1dSKyle Evans 	struct iwm_lmac_alive lmac_data;
2557e4bc6d1dSKyle Evans 	struct iwm_umac_alive umac_data;
2558e4bc6d1dSKyle Evans } __packed; /* ALIVE_RES_API_S_VER_3 */
25596a5bc1d1SSean Bruno 
2560e7065dd1SMark Johnston struct iwm_alive_resp {
25616a5bc1d1SSean Bruno 	uint16_t status;
25626a5bc1d1SSean Bruno 	uint16_t flags;
2563e4bc6d1dSKyle Evans 	struct iwm_lmac_alive lmac_data[2];
2564e4bc6d1dSKyle Evans 	struct iwm_umac_alive umac_data;
2565e4bc6d1dSKyle Evans }__packed; /* ALIVE_RES_API_S_VER_4 */
25666a5bc1d1SSean Bruno 
2567355c1513SAdrian Chadd 
2568355c1513SAdrian Chadd #define IWM_SOC_CONFIG_CMD_FLAGS_DISCRETE	(1 << 0)
2569355c1513SAdrian Chadd #define IWM_SOC_CONFIG_CMD_FLAGS_LOW_LATENCY	(1 << 1)
2570355c1513SAdrian Chadd 
2571355c1513SAdrian Chadd #define IWM_SOC_FLAGS_LTR_APPLY_DELAY_MASK		0xc
2572355c1513SAdrian Chadd #define IWM_SOC_FLAGS_LTR_APPLY_DELAY_NONE		0
2573355c1513SAdrian Chadd #define IWM_SOC_FLAGS_LTR_APPLY_DELAY_200		1
2574355c1513SAdrian Chadd #define IWM_SOC_FLAGS_LTR_APPLY_DELAY_2500		2
2575355c1513SAdrian Chadd #define IWM_SOC_FLAGS_LTR_APPLY_DELAY_1820		3
2576355c1513SAdrian Chadd 
2577355c1513SAdrian Chadd /**
2578355c1513SAdrian Chadd  * struct iwm_soc_configuration_cmd - Set device stabilization latency
2579355c1513SAdrian Chadd  *
2580355c1513SAdrian Chadd  * @flags: soc settings flags.  In VER_1, we can only set the DISCRETE
2581355c1513SAdrian Chadd  *	flag, because the FW treats the whole value as an integer. In
2582355c1513SAdrian Chadd  *	VER_2, we can set the bits independently.
2583355c1513SAdrian Chadd  * @latency: time for SOC to ensure stable power & XTAL
2584355c1513SAdrian Chadd  */
2585355c1513SAdrian Chadd struct iwm_soc_configuration_cmd {
2586355c1513SAdrian Chadd 	uint32_t flags;
2587355c1513SAdrian Chadd 	uint32_t latency;
2588355c1513SAdrian Chadd } __packed; /*
2589355c1513SAdrian Chadd 	     * SOC_CONFIGURATION_CMD_S_VER_1 (see description above)
2590355c1513SAdrian Chadd 	     * SOC_CONFIGURATION_CMD_S_VER_2
2591355c1513SAdrian Chadd 	     */
2592355c1513SAdrian Chadd 
2593355c1513SAdrian Chadd 
2594d4886179SRui Paulo /* Error response/notification */
2595355c1513SAdrian Chadd #define IWM_FW_ERR_UNKNOWN_CMD		0x0
2596355c1513SAdrian Chadd #define IWM_FW_ERR_INVALID_CMD_PARAM	0x1
2597355c1513SAdrian Chadd #define IWM_FW_ERR_SERVICE		0x2
2598355c1513SAdrian Chadd #define IWM_FW_ERR_ARC_MEMORY		0x3
2599355c1513SAdrian Chadd #define IWM_FW_ERR_ARC_CODE		0x4
2600355c1513SAdrian Chadd #define IWM_FW_ERR_WATCH_DOG		0x5
2601355c1513SAdrian Chadd #define IWM_FW_ERR_WEP_GRP_KEY_INDX	0x10
2602355c1513SAdrian Chadd #define IWM_FW_ERR_WEP_KEY_SIZE		0x11
2603355c1513SAdrian Chadd #define IWM_FW_ERR_OBSOLETE_FUNC	0x12
2604355c1513SAdrian Chadd #define IWM_FW_ERR_UNEXPECTED		0xFE
2605355c1513SAdrian Chadd #define IWM_FW_ERR_FATAL		0xFF
2606d4886179SRui Paulo 
2607d4886179SRui Paulo /**
2608d4886179SRui Paulo  * struct iwm_error_resp - FW error indication
2609d4886179SRui Paulo  * ( IWM_REPLY_ERROR = 0x2 )
2610d4886179SRui Paulo  * @error_type: one of IWM_FW_ERR_*
26112fae7b81SGordon Bergling  * @cmd_id: the command ID for which the error occurred
2612d4886179SRui Paulo  * @bad_cmd_seq_num: sequence number of the erroneous command
2613d4886179SRui Paulo  * @error_service: which service created the error, applicable only if
2614d4886179SRui Paulo  *	error_type = 2, otherwise 0
2615d4886179SRui Paulo  * @timestamp: TSF in usecs.
2616d4886179SRui Paulo  */
2617d4886179SRui Paulo struct iwm_error_resp {
2618d4886179SRui Paulo 	uint32_t error_type;
2619d4886179SRui Paulo 	uint8_t cmd_id;
2620d4886179SRui Paulo 	uint8_t reserved1;
2621d4886179SRui Paulo 	uint16_t bad_cmd_seq_num;
2622d4886179SRui Paulo 	uint32_t error_service;
2623d4886179SRui Paulo 	uint64_t timestamp;
2624d4886179SRui Paulo } __packed;
2625d4886179SRui Paulo 
2626355c1513SAdrian Chadd #define IWM_FW_CMD_VER_UNKNOWN 99
2627355c1513SAdrian Chadd 
2628355c1513SAdrian Chadd /**
2629355c1513SAdrian Chadd  * struct iwm_fw_cmd_version - firmware command version entry
2630355c1513SAdrian Chadd  * @cmd: command ID
2631355c1513SAdrian Chadd  * @group: group ID
2632355c1513SAdrian Chadd  * @cmd_ver: command version
2633355c1513SAdrian Chadd  * @notif_ver: notification version
2634355c1513SAdrian Chadd  */
2635355c1513SAdrian Chadd struct iwm_fw_cmd_version {
2636355c1513SAdrian Chadd 	uint8_t cmd;
2637355c1513SAdrian Chadd 	uint8_t group;
2638355c1513SAdrian Chadd 	uint8_t cmd_ver;
2639355c1513SAdrian Chadd 	uint8_t notif_ver;
2640355c1513SAdrian Chadd } __packed;
2641355c1513SAdrian Chadd 
2642d4886179SRui Paulo 
2643d4886179SRui Paulo /* Common PHY, MAC and Bindings definitions */
2644d4886179SRui Paulo 
2645d4886179SRui Paulo #define IWM_MAX_MACS_IN_BINDING	(3)
2646d4886179SRui Paulo #define IWM_MAX_BINDINGS	(4)
2647d4886179SRui Paulo #define IWM_AUX_BINDING_INDEX	(3)
2648d4886179SRui Paulo #define IWM_MAX_PHYS		(4)
2649d4886179SRui Paulo 
2650d4886179SRui Paulo /* Used to extract ID and color from the context dword */
2651d4886179SRui Paulo #define IWM_FW_CTXT_ID_POS	(0)
2652d4886179SRui Paulo #define IWM_FW_CTXT_ID_MSK	(0xff << IWM_FW_CTXT_ID_POS)
2653d4886179SRui Paulo #define IWM_FW_CTXT_COLOR_POS	(8)
2654d4886179SRui Paulo #define IWM_FW_CTXT_COLOR_MSK	(0xff << IWM_FW_CTXT_COLOR_POS)
2655d4886179SRui Paulo #define IWM_FW_CTXT_INVALID	(0xffffffff)
2656d4886179SRui Paulo 
2657d4886179SRui Paulo #define IWM_FW_CMD_ID_AND_COLOR(_id, _color) ((_id << IWM_FW_CTXT_ID_POS) |\
2658d4886179SRui Paulo 					  (_color << IWM_FW_CTXT_COLOR_POS))
2659d4886179SRui Paulo 
2660d4886179SRui Paulo /* Possible actions on PHYs, MACs and Bindings */
2661355c1513SAdrian Chadd #define IWM_FW_CTXT_ACTION_STUB		0
2662355c1513SAdrian Chadd #define IWM_FW_CTXT_ACTION_ADD		1
2663355c1513SAdrian Chadd #define IWM_FW_CTXT_ACTION_MODIFY	2
2664355c1513SAdrian Chadd #define IWM_FW_CTXT_ACTION_REMOVE	3
2665355c1513SAdrian Chadd #define IWM_FW_CTXT_ACTION_NUM		4
2666355c1513SAdrian Chadd /* COMMON_CONTEXT_ACTION_API_E_VER_1 */
2667d4886179SRui Paulo 
2668d4886179SRui Paulo /* Time Events */
2669d4886179SRui Paulo 
2670d4886179SRui Paulo /* Time Event types, according to MAC type */
2671355c1513SAdrian Chadd 
2672d4886179SRui Paulo /* BSS Station Events */
2673355c1513SAdrian Chadd #define IWM_TE_BSS_STA_AGGRESSIVE_ASSOC	0
2674355c1513SAdrian Chadd #define IWM_TE_BSS_STA_ASSOC		1
2675355c1513SAdrian Chadd #define IWM_TE_BSS_EAP_DHCP_PROT	2
2676355c1513SAdrian Chadd #define IWM_TE_BSS_QUIET_PERIOD		3
2677d4886179SRui Paulo 
2678d4886179SRui Paulo /* P2P Device Events */
2679355c1513SAdrian Chadd #define IWM_TE_P2P_DEVICE_DISCOVERABLE	4
2680355c1513SAdrian Chadd #define IWM_TE_P2P_DEVICE_LISTEN	5
2681355c1513SAdrian Chadd #define IWM_TE_P2P_DEVICE_ACTION_SCAN	6
2682355c1513SAdrian Chadd #define IWM_TE_P2P_DEVICE_FULL_SCAN	7
2683d4886179SRui Paulo 
2684d4886179SRui Paulo /* P2P Client Events */
2685355c1513SAdrian Chadd #define IWM_TE_P2P_CLIENT_AGGRESSIVE_ASSOC	8
2686355c1513SAdrian Chadd #define IWM_TE_P2P_CLIENT_ASSOC			9
2687355c1513SAdrian Chadd #define IWM_TE_P2P_CLIENT_QUIET_PERIOD		10
2688d4886179SRui Paulo 
2689d4886179SRui Paulo /* P2P GO Events */
2690355c1513SAdrian Chadd #define IWM_TE_P2P_GO_ASSOC_PROT	11
2691355c1513SAdrian Chadd #define IWM_TE_P2P_GO_REPETITIVE_NOA	12
2692355c1513SAdrian Chadd #define IWM_TE_P2P_GO_CT_WINDOW		13
2693d4886179SRui Paulo 
2694d4886179SRui Paulo /* WiDi Sync Events */
2695355c1513SAdrian Chadd #define IWM_TE_WIDI_TX_SYNC	14
2696d4886179SRui Paulo 
2697355c1513SAdrian Chadd #define IWM_TE_MAX	15
2698355c1513SAdrian Chadd /* IWM_MAC_EVENT_TYPE_API_E_VER_1 */
2699d4886179SRui Paulo 
2700d4886179SRui Paulo 
2701d4886179SRui Paulo 
2702d4886179SRui Paulo /* Time event - defines for command API v1 */
2703d4886179SRui Paulo 
2704d4886179SRui Paulo /*
2705d4886179SRui Paulo  * @IWM_TE_V1_FRAG_NONE: fragmentation of the time event is NOT allowed.
2706d4886179SRui Paulo  * @IWM_TE_V1_FRAG_SINGLE: fragmentation of the time event is allowed, but only
2707d4886179SRui Paulo  *	the first fragment is scheduled.
2708d4886179SRui Paulo  * @IWM_TE_V1_FRAG_DUAL: fragmentation of the time event is allowed, but only
2709d4886179SRui Paulo  *	the first 2 fragments are scheduled.
2710d4886179SRui Paulo  * @IWM_TE_V1_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
2711d4886179SRui Paulo  *	number of fragments are valid.
2712d4886179SRui Paulo  *
2713d4886179SRui Paulo  * Other than the constant defined above, specifying a fragmentation value 'x'
2714d4886179SRui Paulo  * means that the event can be fragmented but only the first 'x' will be
2715d4886179SRui Paulo  * scheduled.
2716d4886179SRui Paulo  */
2717355c1513SAdrian Chadd #define IWM_TE_V1_FRAG_NONE	0
2718355c1513SAdrian Chadd #define IWM_TE_V1_FRAG_SINGLE	1
2719355c1513SAdrian Chadd #define IWM_TE_V1_FRAG_DUAL	2
2720355c1513SAdrian Chadd #define IWM_TE_V1_FRAG_ENDLESS	0xffffffff
2721d4886179SRui Paulo 
2722d4886179SRui Paulo /* If a Time Event can be fragmented, this is the max number of fragments */
2723d4886179SRui Paulo #define IWM_TE_V1_FRAG_MAX_MSK		0x0fffffff
2724d4886179SRui Paulo /* Repeat the time event endlessly (until removed) */
2725d4886179SRui Paulo #define IWM_TE_V1_REPEAT_ENDLESS	0xffffffff
2726d4886179SRui Paulo /* If a Time Event has bounded repetitions, this is the maximal value */
2727d4886179SRui Paulo #define IWM_TE_V1_REPEAT_MAX_MSK_V1	0x0fffffff
2728d4886179SRui Paulo 
2729d4886179SRui Paulo /* Time Event dependencies: none, on another TE, or in a specific time */
2730355c1513SAdrian Chadd #define IWM_TE_V1_INDEPENDENT		0
2731355c1513SAdrian Chadd #define IWM_TE_V1_DEP_OTHER		(1 << 0)
2732355c1513SAdrian Chadd #define IWM_TE_V1_DEP_TSF		(1 << 1)
2733355c1513SAdrian Chadd #define IWM_TE_V1_EVENT_SOCIOPATHIC	(1 << 2)
2734355c1513SAdrian Chadd /* IWM_MAC_EVENT_DEPENDENCY_POLICY_API_E_VER_2 */
2735d4886179SRui Paulo 
2736d4886179SRui Paulo /*
2737d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_NONE: no notifications
2738d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_HOST_EVENT_START: request/receive notification on event start
2739d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_HOST_EVENT_END:request/receive notification on event end
2740d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_INTERNAL_EVENT_START: internal FW use
2741d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_INTERNAL_EVENT_END: internal FW use.
2742d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_HOST_FRAG_START: request/receive notification on frag start
2743d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_HOST_FRAG_END:request/receive notification on frag end
2744d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_INTERNAL_FRAG_START: internal FW use.
2745d4886179SRui Paulo  * @IWM_TE_V1_NOTIF_INTERNAL_FRAG_END: internal FW use.
2746d4886179SRui Paulo  *
2747d4886179SRui Paulo  * Supported Time event notifications configuration.
2748d4886179SRui Paulo  * A notification (both event and fragment) includes a status indicating weather
2749d4886179SRui Paulo  * the FW was able to schedule the event or not. For fragment start/end
2750d4886179SRui Paulo  * notification the status is always success. There is no start/end fragment
2751d4886179SRui Paulo  * notification for monolithic events.
2752d4886179SRui Paulo  */
2753355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_NONE			0
2754355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_HOST_EVENT_START	(1 << 0)
2755355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_HOST_EVENT_END		(1 << 1)
2756355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_INTERNAL_EVENT_START	(1 << 2)
2757355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_INTERNAL_EVENT_END	(1 << 3)
2758355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_HOST_FRAG_START		(1 << 4)
2759355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_HOST_FRAG_END		(1 << 5)
2760355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_INTERNAL_FRAG_START	(1 << 6)
2761355c1513SAdrian Chadd #define IWM_TE_V1_NOTIF_INTERNAL_FRAG_END	(1 << 7)
2762355c1513SAdrian Chadd /* IWM_MAC_EVENT_ACTION_API_E_VER_2 */
2763355c1513SAdrian Chadd 
2764d4886179SRui Paulo 
2765d045c744SAdrian Chadd /* Time event - defines for command API */
2766d4886179SRui Paulo 
2767355c1513SAdrian Chadd /**
2768355c1513SAdrian Chadd  * DOC: Time Events - what is it?
2769355c1513SAdrian Chadd  *
2770355c1513SAdrian Chadd  * Time Events are a fw feature that allows the driver to control the presence
2771355c1513SAdrian Chadd  * of the device on the channel. Since the fw supports multiple channels
2772355c1513SAdrian Chadd  * concurrently, the fw may choose to jump to another channel at any time.
2773355c1513SAdrian Chadd  * In order to make sure that the fw is on a specific channel at a certain time
2774355c1513SAdrian Chadd  * and for a certain duration, the driver needs to issue a time event.
2775355c1513SAdrian Chadd  *
2776355c1513SAdrian Chadd  * The simplest example is for BSS association. The driver issues a time event,
2777355c1513SAdrian Chadd  * waits for it to start, and only then tells mac80211 that we can start the
2778355c1513SAdrian Chadd  * association. This way, we make sure that the association will be done
2779355c1513SAdrian Chadd  * smoothly and won't be interrupted by channel switch decided within the fw.
2780355c1513SAdrian Chadd  */
2781355c1513SAdrian Chadd 
2782355c1513SAdrian Chadd  /**
2783355c1513SAdrian Chadd  * DOC: The flow against the fw
2784355c1513SAdrian Chadd  *
2785355c1513SAdrian Chadd  * When the driver needs to make sure we are in a certain channel, at a certain
2786355c1513SAdrian Chadd  * time and for a certain duration, it sends a Time Event. The flow against the
2787355c1513SAdrian Chadd  * fw goes like this:
2788355c1513SAdrian Chadd  *	1) Driver sends a TIME_EVENT_CMD to the fw
2789355c1513SAdrian Chadd  *	2) Driver gets the response for that command. This response contains the
2790355c1513SAdrian Chadd  *	   Unique ID (UID) of the event.
2791355c1513SAdrian Chadd  *	3) The fw sends notification when the event starts.
2792355c1513SAdrian Chadd  *
2793355c1513SAdrian Chadd  * Of course the API provides various options that allow to cover parameters
2794355c1513SAdrian Chadd  * of the flow.
2795355c1513SAdrian Chadd  *	What is the duration of the event?
2796355c1513SAdrian Chadd  *	What is the start time of the event?
2797355c1513SAdrian Chadd  *	Is there an end-time for the event?
2798355c1513SAdrian Chadd  *	How much can the event be delayed?
2799355c1513SAdrian Chadd  *	Can the event be split?
2800355c1513SAdrian Chadd  *	If yes what is the maximal number of chunks?
2801355c1513SAdrian Chadd  *	etc...
2802355c1513SAdrian Chadd  */
2803355c1513SAdrian Chadd 
2804d4886179SRui Paulo /*
2805d4886179SRui Paulo  * @IWM_TE_V2_FRAG_NONE: fragmentation of the time event is NOT allowed.
2806d4886179SRui Paulo  * @IWM_TE_V2_FRAG_SINGLE: fragmentation of the time event is allowed, but only
2807d4886179SRui Paulo  *  the first fragment is scheduled.
2808d4886179SRui Paulo  * @IWM_TE_V2_FRAG_DUAL: fragmentation of the time event is allowed, but only
2809d4886179SRui Paulo  *  the first 2 fragments are scheduled.
2810d4886179SRui Paulo  * @IWM_TE_V2_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
2811d4886179SRui Paulo  *  number of fragments are valid.
2812d4886179SRui Paulo  *
2813d4886179SRui Paulo  * Other than the constant defined above, specifying a fragmentation value 'x'
2814d4886179SRui Paulo  * means that the event can be fragmented but only the first 'x' will be
2815d4886179SRui Paulo  * scheduled.
2816d4886179SRui Paulo  */
2817355c1513SAdrian Chadd #define IWM_TE_V2_FRAG_NONE		0
2818355c1513SAdrian Chadd #define IWM_TE_V2_FRAG_SINGLE		1
2819355c1513SAdrian Chadd #define IWM_TE_V2_FRAG_DUAL		2
2820355c1513SAdrian Chadd #define IWM_TE_V2_FRAG_MAX		0xfe
2821355c1513SAdrian Chadd #define IWM_TE_V2_FRAG_ENDLESS		0xff
2822d4886179SRui Paulo 
2823d4886179SRui Paulo /* Repeat the time event endlessly (until removed) */
2824d4886179SRui Paulo #define IWM_TE_V2_REPEAT_ENDLESS	0xff
2825d4886179SRui Paulo /* If a Time Event has bounded repetitions, this is the maximal value */
2826d4886179SRui Paulo #define IWM_TE_V2_REPEAT_MAX	0xfe
2827d4886179SRui Paulo 
2828d4886179SRui Paulo #define IWM_TE_V2_PLACEMENT_POS	12
2829d4886179SRui Paulo #define IWM_TE_V2_ABSENCE_POS	15
2830d4886179SRui Paulo 
2831d045c744SAdrian Chadd /* Time event policy values
2832d4886179SRui Paulo  * A notification (both event and fragment) includes a status indicating weather
2833d4886179SRui Paulo  * the FW was able to schedule the event or not. For fragment start/end
2834d4886179SRui Paulo  * notification the status is always success. There is no start/end fragment
2835d4886179SRui Paulo  * notification for monolithic events.
2836d4886179SRui Paulo  *
2837d4886179SRui Paulo  * @IWM_TE_V2_DEFAULT_POLICY: independent, social, present, unoticable
2838d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_HOST_EVENT_START: request/receive notification on event start
2839d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_HOST_EVENT_END:request/receive notification on event end
2840d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_INTERNAL_EVENT_START: internal FW use
2841d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_INTERNAL_EVENT_END: internal FW use.
2842d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_HOST_FRAG_START: request/receive notification on frag start
2843d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_HOST_FRAG_END:request/receive notification on frag end
2844d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_INTERNAL_FRAG_START: internal FW use.
2845d4886179SRui Paulo  * @IWM_TE_V2_NOTIF_INTERNAL_FRAG_END: internal FW use.
2846d4886179SRui Paulo  * @IWM_TE_V2_DEP_OTHER: depends on another time event
2847d4886179SRui Paulo  * @IWM_TE_V2_DEP_TSF: depends on a specific time
2848d4886179SRui Paulo  * @IWM_TE_V2_EVENT_SOCIOPATHIC: can't co-exist with other events of tha same MAC
2849d4886179SRui Paulo  * @IWM_TE_V2_ABSENCE: are we present or absent during the Time Event.
2850d4886179SRui Paulo  */
2851355c1513SAdrian Chadd #define IWM_TE_V2_DEFAULT_POLICY		0x0
2852d4886179SRui Paulo 
2853d4886179SRui Paulo /* notifications (event start/stop, fragment start/stop) */
2854355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_HOST_EVENT_START	(1 << 0)
2855355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_HOST_EVENT_END		(1 << 1)
2856355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_INTERNAL_EVENT_START	(1 << 2)
2857355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_INTERNAL_EVENT_END	(1 << 3)
2858d4886179SRui Paulo 
2859355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_HOST_FRAG_START		(1 << 4)
2860355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_HOST_FRAG_END		(1 << 5)
2861355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_INTERNAL_FRAG_START	(1 << 6)
2862355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_INTERNAL_FRAG_END	(1 << 7)
2863355c1513SAdrian Chadd #define IWM_T2_V2_START_IMMEDIATELY		(1 << 11)
2864d4886179SRui Paulo 
2865355c1513SAdrian Chadd #define IWM_TE_V2_NOTIF_MSK	0xff
2866d4886179SRui Paulo 
2867d4886179SRui Paulo /* placement characteristics */
2868355c1513SAdrian Chadd #define IWM_TE_V2_DEP_OTHER		(1 << IWM_TE_V2_PLACEMENT_POS)
2869355c1513SAdrian Chadd #define IWM_TE_V2_DEP_TSF		(1 << (IWM_TE_V2_PLACEMENT_POS + 1))
2870355c1513SAdrian Chadd #define IWM_TE_V2_EVENT_SOCIOPATHIC	(1 << (IWM_TE_V2_PLACEMENT_POS + 2))
2871d4886179SRui Paulo 
2872d4886179SRui Paulo /* are we present or absent during the Time Event. */
2873355c1513SAdrian Chadd #define IWM_TE_V2_ABSENCE		(1 << IWM_TE_V2_ABSENCE_POS)
2874d4886179SRui Paulo 
2875d4886179SRui Paulo /**
2876d045c744SAdrian Chadd  * struct iwm_time_event_cmd_api - configuring Time Events
2877d4886179SRui Paulo  * with struct IWM_MAC_TIME_EVENT_DATA_API_S_VER_2 (see also
2878d4886179SRui Paulo  * with version 1. determined by IWM_UCODE_TLV_FLAGS)
2879d4886179SRui Paulo  * ( IWM_TIME_EVENT_CMD = 0x29 )
2880d4886179SRui Paulo  * @id_and_color: ID and color of the relevant MAC
2881d4886179SRui Paulo  * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2882d4886179SRui Paulo  * @id: this field has two meanings, depending on the action:
2883d4886179SRui Paulo  *	If the action is ADD, then it means the type of event to add.
2884d4886179SRui Paulo  *	For all other actions it is the unique event ID assigned when the
2885d4886179SRui Paulo  *	event was added by the FW.
2886d4886179SRui Paulo  * @apply_time: When to start the Time Event (in GP2)
2887d4886179SRui Paulo  * @max_delay: maximum delay to event's start (apply time), in TU
2888d4886179SRui Paulo  * @depends_on: the unique ID of the event we depend on (if any)
2889d4886179SRui Paulo  * @interval: interval between repetitions, in TU
2890d4886179SRui Paulo  * @duration: duration of event in TU
2891d4886179SRui Paulo  * @repeat: how many repetitions to do, can be IWM_TE_REPEAT_ENDLESS
2892d4886179SRui Paulo  * @max_frags: maximal number of fragments the Time Event can be divided to
2893d4886179SRui Paulo  * @policy: defines whether uCode shall notify the host or other uCode modules
2894d4886179SRui Paulo  *	on event and/or fragment start and/or end
2895d4886179SRui Paulo  *	using one of IWM_TE_INDEPENDENT, IWM_TE_DEP_OTHER, IWM_TE_DEP_TSF
2896d4886179SRui Paulo  *	IWM_TE_EVENT_SOCIOPATHIC
2897d4886179SRui Paulo  *	using IWM_TE_ABSENCE and using IWM_TE_NOTIF_*
2898d4886179SRui Paulo  */
2899d045c744SAdrian Chadd struct iwm_time_event_cmd {
2900d4886179SRui Paulo 	/* COMMON_INDEX_HDR_API_S_VER_1 */
2901d4886179SRui Paulo 	uint32_t id_and_color;
2902d4886179SRui Paulo 	uint32_t action;
2903d4886179SRui Paulo 	uint32_t id;
2904d4886179SRui Paulo 	/* IWM_MAC_TIME_EVENT_DATA_API_S_VER_2 */
2905d4886179SRui Paulo 	uint32_t apply_time;
2906d4886179SRui Paulo 	uint32_t max_delay;
2907d4886179SRui Paulo 	uint32_t depends_on;
2908d4886179SRui Paulo 	uint32_t interval;
2909d4886179SRui Paulo 	uint32_t duration;
2910d4886179SRui Paulo 	uint8_t repeat;
2911d4886179SRui Paulo 	uint8_t max_frags;
2912d4886179SRui Paulo 	uint16_t policy;
2913d4886179SRui Paulo } __packed; /* IWM_MAC_TIME_EVENT_CMD_API_S_VER_2 */
2914d4886179SRui Paulo 
2915d4886179SRui Paulo /**
2916d4886179SRui Paulo  * struct iwm_time_event_resp - response structure to iwm_time_event_cmd
2917d4886179SRui Paulo  * @status: bit 0 indicates success, all others specify errors
2918d4886179SRui Paulo  * @id: the Time Event type
2919d4886179SRui Paulo  * @unique_id: the unique ID assigned (in ADD) or given (others) to the TE
2920d4886179SRui Paulo  * @id_and_color: ID and color of the relevant MAC
2921d4886179SRui Paulo  */
2922d4886179SRui Paulo struct iwm_time_event_resp {
2923d4886179SRui Paulo 	uint32_t status;
2924d4886179SRui Paulo 	uint32_t id;
2925d4886179SRui Paulo 	uint32_t unique_id;
2926d4886179SRui Paulo 	uint32_t id_and_color;
2927d4886179SRui Paulo } __packed; /* IWM_MAC_TIME_EVENT_RSP_API_S_VER_1 */
2928d4886179SRui Paulo 
2929d4886179SRui Paulo /**
2930d4886179SRui Paulo  * struct iwm_time_event_notif - notifications of time event start/stop
2931d4886179SRui Paulo  * ( IWM_TIME_EVENT_NOTIFICATION = 0x2a )
2932d4886179SRui Paulo  * @timestamp: action timestamp in GP2
2933d4886179SRui Paulo  * @session_id: session's unique id
2934d4886179SRui Paulo  * @unique_id: unique id of the Time Event itself
2935d4886179SRui Paulo  * @id_and_color: ID and color of the relevant MAC
2936d4886179SRui Paulo  * @action: one of IWM_TE_NOTIF_START or IWM_TE_NOTIF_END
2937d4886179SRui Paulo  * @status: true if scheduled, false otherwise (not executed)
2938d4886179SRui Paulo  */
2939d4886179SRui Paulo struct iwm_time_event_notif {
2940d4886179SRui Paulo 	uint32_t timestamp;
2941d4886179SRui Paulo 	uint32_t session_id;
2942d4886179SRui Paulo 	uint32_t unique_id;
2943d4886179SRui Paulo 	uint32_t id_and_color;
2944d4886179SRui Paulo 	uint32_t action;
2945d4886179SRui Paulo 	uint32_t status;
2946d4886179SRui Paulo } __packed; /* IWM_MAC_TIME_EVENT_NTFY_API_S_VER_1 */
2947d4886179SRui Paulo 
2948d4886179SRui Paulo 
2949d4886179SRui Paulo /* Bindings and Time Quota */
2950d4886179SRui Paulo 
2951d4886179SRui Paulo /**
2952355c1513SAdrian Chadd  * struct iwm_binding_cmd_v1 - configuring bindings
2953355c1513SAdrian Chadd  * ( IWM_BINDING_CONTEXT_CMD = 0x2b )
2954355c1513SAdrian Chadd  * @id_and_color: ID and color of the relevant Binding
2955355c1513SAdrian Chadd  * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2956355c1513SAdrian Chadd  * @macs: array of MAC id and colors which belong to the binding
2957355c1513SAdrian Chadd  * @phy: PHY id and color which belongs to the binding
2958355c1513SAdrian Chadd  * @lmac_id: the lmac id the binding belongs to
2959355c1513SAdrian Chadd  */
2960355c1513SAdrian Chadd struct iwm_binding_cmd_v1 {
2961355c1513SAdrian Chadd 	/* COMMON_INDEX_HDR_API_S_VER_1 */
2962355c1513SAdrian Chadd 	uint32_t id_and_color;
2963355c1513SAdrian Chadd 	uint32_t action;
2964355c1513SAdrian Chadd 	/* IWM_BINDING_DATA_API_S_VER_1 */
2965355c1513SAdrian Chadd 	uint32_t macs[IWM_MAX_MACS_IN_BINDING];
2966355c1513SAdrian Chadd 	uint32_t phy;
2967355c1513SAdrian Chadd } __packed; /* IWM_BINDING_CMD_API_S_VER_1 */
2968355c1513SAdrian Chadd 
2969355c1513SAdrian Chadd /**
2970d4886179SRui Paulo  * struct iwm_binding_cmd - configuring bindings
2971d4886179SRui Paulo  * ( IWM_BINDING_CONTEXT_CMD = 0x2b )
2972d4886179SRui Paulo  * @id_and_color: ID and color of the relevant Binding
2973d4886179SRui Paulo  * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2974d4886179SRui Paulo  * @macs: array of MAC id and colors which belong to the binding
2975d4886179SRui Paulo  * @phy: PHY id and color which belongs to the binding
2976355c1513SAdrian Chadd  * @lmac_id: the lmac id the binding belongs to
2977d4886179SRui Paulo  */
2978d4886179SRui Paulo struct iwm_binding_cmd {
2979d4886179SRui Paulo 	/* COMMON_INDEX_HDR_API_S_VER_1 */
2980d4886179SRui Paulo 	uint32_t id_and_color;
2981d4886179SRui Paulo 	uint32_t action;
2982d4886179SRui Paulo 	/* IWM_BINDING_DATA_API_S_VER_1 */
2983d4886179SRui Paulo 	uint32_t macs[IWM_MAX_MACS_IN_BINDING];
2984d4886179SRui Paulo 	uint32_t phy;
2985355c1513SAdrian Chadd 	uint32_t lmac_id;
2986355c1513SAdrian Chadd } __packed; /* IWM_BINDING_CMD_API_S_VER_2 */
2987355c1513SAdrian Chadd 
2988355c1513SAdrian Chadd #define IWM_LMAC_24G_INDEX		0
2989355c1513SAdrian Chadd #define IWM_LMAC_5G_INDEX		1
2990d4886179SRui Paulo 
2991d4886179SRui Paulo /* The maximal number of fragments in the FW's schedule session */
2992e7065dd1SMark Johnston #define IWM_MAX_QUOTA 128
2993d4886179SRui Paulo 
2994d4886179SRui Paulo /**
2995d4886179SRui Paulo  * struct iwm_time_quota_data - configuration of time quota per binding
2996d4886179SRui Paulo  * @id_and_color: ID and color of the relevant Binding
2997d4886179SRui Paulo  * @quota: absolute time quota in TU. The scheduler will try to divide the
2998d4886179SRui Paulo  *	remainig quota (after Time Events) according to this quota.
2999d4886179SRui Paulo  * @max_duration: max uninterrupted context duration in TU
3000d4886179SRui Paulo  */
3001355c1513SAdrian Chadd struct iwm_time_quota_data_v1 {
3002d4886179SRui Paulo 	uint32_t id_and_color;
3003d4886179SRui Paulo 	uint32_t quota;
3004d4886179SRui Paulo 	uint32_t max_duration;
3005d4886179SRui Paulo } __packed; /* IWM_TIME_QUOTA_DATA_API_S_VER_1 */
3006d4886179SRui Paulo 
3007d4886179SRui Paulo /**
3008d4886179SRui Paulo  * struct iwm_time_quota_cmd - configuration of time quota between bindings
3009d4886179SRui Paulo  * ( IWM_TIME_QUOTA_CMD = 0x2c )
3010d4886179SRui Paulo  * @quotas: allocations per binding
3011d4886179SRui Paulo  */
3012355c1513SAdrian Chadd struct iwm_time_quota_cmd_v1 {
3013355c1513SAdrian Chadd 	struct iwm_time_quota_data_v1 quotas[IWM_MAX_BINDINGS];
3014355c1513SAdrian Chadd } __packed; /* IWM_TIME_QUOTA_ALLOCATION_CMD_API_S_VER_1 */
3015355c1513SAdrian Chadd 
3016355c1513SAdrian Chadd #define IWM_QUOTA_LOW_LATENCY_NONE	0
3017355c1513SAdrian Chadd #define IWM_QUOTA_LOW_LATENCY_TX	(1 << 0)
3018355c1513SAdrian Chadd #define IWM_QUOTA_LOW_LATENCY_RX	(1 << 1)
3019355c1513SAdrian Chadd 
3020355c1513SAdrian Chadd /**
3021355c1513SAdrian Chadd  * struct iwm_time_quota_data - configuration of time quota per binding
3022355c1513SAdrian Chadd  * @id_and_color: ID and color of the relevant Binding.
3023355c1513SAdrian Chadd  * @quota: absolute time quota in TU. The scheduler will try to divide the
3024355c1513SAdrian Chadd  *	remainig quota (after Time Events) according to this quota.
3025355c1513SAdrian Chadd  * @max_duration: max uninterrupted context duration in TU
3026355c1513SAdrian Chadd  * @low_latency: low latency status IWM_QUOTA_LOW_LATENCY_*
3027355c1513SAdrian Chadd  */
3028355c1513SAdrian Chadd struct iwm_time_quota_data {
3029355c1513SAdrian Chadd 	uint32_t id_and_color;
3030355c1513SAdrian Chadd 	uint32_t quota;
3031355c1513SAdrian Chadd 	uint32_t max_duration;
3032355c1513SAdrian Chadd 	uint32_t low_latency;
3033355c1513SAdrian Chadd }; /* TIME_QUOTA_DATA_API_S_VER_2 */
3034355c1513SAdrian Chadd 
3035355c1513SAdrian Chadd /**
3036355c1513SAdrian Chadd  * struct iwm_time_quota_cmd - configuration of time quota between bindings
3037355c1513SAdrian Chadd  * ( TIME_QUOTA_CMD = 0x2c )
3038355c1513SAdrian Chadd  * Note: on non-CDB the fourth one is the auxilary mac and is essentially zero.
3039355c1513SAdrian Chadd  * On CDB the fourth one is a regular binding.
3040355c1513SAdrian Chadd  *
3041355c1513SAdrian Chadd  * @quotas: allocations per binding
3042355c1513SAdrian Chadd  */
3043d4886179SRui Paulo struct iwm_time_quota_cmd {
3044d4886179SRui Paulo 	struct iwm_time_quota_data quotas[IWM_MAX_BINDINGS];
3045355c1513SAdrian Chadd } __packed; /* TIME_QUOTA_ALLOCATION_CMD_API_S_VER_2 */
3046d4886179SRui Paulo 
3047d4886179SRui Paulo 
3048d4886179SRui Paulo /* PHY context */
3049d4886179SRui Paulo 
3050d4886179SRui Paulo /* Supported bands */
3051d4886179SRui Paulo #define IWM_PHY_BAND_5  (0)
3052d4886179SRui Paulo #define IWM_PHY_BAND_24 (1)
3053d4886179SRui Paulo 
3054d4886179SRui Paulo /* Supported channel width, vary if there is VHT support */
3055d4886179SRui Paulo #define IWM_PHY_VHT_CHANNEL_MODE20	(0x0)
3056d4886179SRui Paulo #define IWM_PHY_VHT_CHANNEL_MODE40	(0x1)
3057d4886179SRui Paulo #define IWM_PHY_VHT_CHANNEL_MODE80	(0x2)
3058d4886179SRui Paulo #define IWM_PHY_VHT_CHANNEL_MODE160	(0x3)
3059d4886179SRui Paulo 
3060d4886179SRui Paulo /*
3061d4886179SRui Paulo  * Control channel position:
3062d4886179SRui Paulo  * For legacy set bit means upper channel, otherwise lower.
3063d4886179SRui Paulo  * For VHT - bit-2 marks if the control is lower/upper relative to center-freq
3064d4886179SRui Paulo  *   bits-1:0 mark the distance from the center freq. for 20Mhz, offset is 0.
3065d4886179SRui Paulo  *                                   center_freq
3066d4886179SRui Paulo  *                                        |
3067d4886179SRui Paulo  * 40Mhz                          |_______|_______|
3068d4886179SRui Paulo  * 80Mhz                  |_______|_______|_______|_______|
3069d4886179SRui Paulo  * 160Mhz |_______|_______|_______|_______|_______|_______|_______|_______|
3070d4886179SRui Paulo  * code      011     010     001     000  |  100     101     110    111
3071d4886179SRui Paulo  */
3072d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_1_BELOW  (0x0)
3073d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_2_BELOW  (0x1)
3074d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_3_BELOW  (0x2)
3075d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_4_BELOW  (0x3)
3076d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_1_ABOVE  (0x4)
3077d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_2_ABOVE  (0x5)
3078d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_3_ABOVE  (0x6)
3079d4886179SRui Paulo #define IWM_PHY_VHT_CTRL_POS_4_ABOVE  (0x7)
3080d4886179SRui Paulo 
3081d4886179SRui Paulo /*
3082d4886179SRui Paulo  * @band: IWM_PHY_BAND_*
3083d4886179SRui Paulo  * @channel: channel number
3084d4886179SRui Paulo  * @width: PHY_[VHT|LEGACY]_CHANNEL_*
3085d4886179SRui Paulo  * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_*
3086d4886179SRui Paulo  */
3087355c1513SAdrian Chadd struct iwm_fw_channel_info_v1 {
3088d4886179SRui Paulo 	uint8_t band;
3089d4886179SRui Paulo 	uint8_t channel;
3090d4886179SRui Paulo 	uint8_t width;
3091d4886179SRui Paulo 	uint8_t ctrl_pos;
3092355c1513SAdrian Chadd } __packed; /* CHANNEL_CONFIG_API_S_VER_1 */
3093355c1513SAdrian Chadd 
3094355c1513SAdrian Chadd /*
3095355c1513SAdrian Chadd  * struct iwm_fw_channel_info - channel information
3096355c1513SAdrian Chadd  *
3097355c1513SAdrian Chadd  * @channel: channel number
3098355c1513SAdrian Chadd  * @band: PHY_BAND_*
3099355c1513SAdrian Chadd  * @width: PHY_[VHT|LEGACY]_CHANNEL_*
3100355c1513SAdrian Chadd  * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_*
3101355c1513SAdrian Chadd  * @reserved: for future use and alignment
3102355c1513SAdrian Chadd  */
3103355c1513SAdrian Chadd struct iwm_fw_channel_info {
3104355c1513SAdrian Chadd 	uint32_t channel;
3105355c1513SAdrian Chadd 	uint8_t band;
3106355c1513SAdrian Chadd 	uint8_t width;
3107355c1513SAdrian Chadd 	uint8_t ctrl_pos;
3108355c1513SAdrian Chadd 	uint8_t reserved;
3109355c1513SAdrian Chadd } __packed; /* CHANNEL_CONFIG_API_S_VER_2 */
3110d4886179SRui Paulo 
3111d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_DRIVER_FORCE_POS	(0)
3112d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_DRIVER_FORCE_MSK \
3113d4886179SRui Paulo 	(0x1 << IWM_PHY_RX_CHAIN_DRIVER_FORCE_POS)
3114d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_VALID_POS		(1)
3115d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_VALID_MSK \
3116d4886179SRui Paulo 	(0x7 << IWM_PHY_RX_CHAIN_VALID_POS)
3117d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_FORCE_SEL_POS	(4)
3118d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_FORCE_SEL_MSK \
3119d4886179SRui Paulo 	(0x7 << IWM_PHY_RX_CHAIN_FORCE_SEL_POS)
3120d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
3121d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_FORCE_MIMO_SEL_MSK \
3122d4886179SRui Paulo 	(0x7 << IWM_PHY_RX_CHAIN_FORCE_MIMO_SEL_POS)
3123d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_CNT_POS		(10)
3124d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_CNT_MSK \
3125d4886179SRui Paulo 	(0x3 << IWM_PHY_RX_CHAIN_CNT_POS)
3126d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_MIMO_CNT_POS	(12)
3127d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_MIMO_CNT_MSK \
3128d4886179SRui Paulo 	(0x3 << IWM_PHY_RX_CHAIN_MIMO_CNT_POS)
3129d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_MIMO_FORCE_POS	(14)
3130d4886179SRui Paulo #define IWM_PHY_RX_CHAIN_MIMO_FORCE_MSK \
3131d4886179SRui Paulo 	(0x1 << IWM_PHY_RX_CHAIN_MIMO_FORCE_POS)
3132d4886179SRui Paulo 
3133d4886179SRui Paulo /* TODO: fix the value, make it depend on firmware at runtime? */
3134d4886179SRui Paulo #define IWM_NUM_PHY_CTX	3
3135d4886179SRui Paulo 
3136d4886179SRui Paulo /* TODO: complete missing documentation */
3137d4886179SRui Paulo /**
3138d4886179SRui Paulo  * struct iwm_phy_context_cmd - config of the PHY context
3139d4886179SRui Paulo  * ( IWM_PHY_CONTEXT_CMD = 0x8 )
3140d4886179SRui Paulo  * @id_and_color: ID and color of the relevant Binding
3141d4886179SRui Paulo  * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
3142d4886179SRui Paulo  * @apply_time: 0 means immediate apply and context switch.
3143d4886179SRui Paulo  *	other value means apply new params after X usecs
3144d4886179SRui Paulo  * @tx_param_color: ???
3145d4886179SRui Paulo  * @channel_info:
3146d4886179SRui Paulo  * @txchain_info: ???
3147d4886179SRui Paulo  * @rxchain_info: ???
3148d4886179SRui Paulo  * @acquisition_data: ???
3149d4886179SRui Paulo  * @dsp_cfg_flags: set to 0
3150d4886179SRui Paulo  */
3151355c1513SAdrian Chadd /*
3152355c1513SAdrian Chadd  * XXX Intel forgot to bump the PHY_CONTEXT command API when they increased
3153355c1513SAdrian Chadd  * the size of fw_channel_info from v1 to v2.
3154355c1513SAdrian Chadd  * To keep things simple we define two versions of this struct, and both
3155355c1513SAdrian Chadd  * are labled as CMD_API_VER_1. (The Linux iwlwifi driver performs dark
3156355c1513SAdrian Chadd  * magic with pointers to struct members instead.)
3157355c1513SAdrian Chadd  */
3158355c1513SAdrian Chadd /* This version must be used if IWM_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS is set: */
3159355c1513SAdrian Chadd struct iwm_phy_context_cmd_uhb {
3160d4886179SRui Paulo 	/* COMMON_INDEX_HDR_API_S_VER_1 */
3161d4886179SRui Paulo 	uint32_t id_and_color;
3162d4886179SRui Paulo 	uint32_t action;
3163d4886179SRui Paulo 	/* IWM_PHY_CONTEXT_DATA_API_S_VER_1 */
3164d4886179SRui Paulo 	uint32_t apply_time;
3165d4886179SRui Paulo 	uint32_t tx_param_color;
3166d4886179SRui Paulo 	struct iwm_fw_channel_info ci;
3167d4886179SRui Paulo 	uint32_t txchain_info;
3168d4886179SRui Paulo 	uint32_t rxchain_info;
3169d4886179SRui Paulo 	uint32_t acquisition_data;
3170d4886179SRui Paulo 	uint32_t dsp_cfg_flags;
3171d4886179SRui Paulo } __packed; /* IWM_PHY_CONTEXT_CMD_API_VER_1 */
3172355c1513SAdrian Chadd /* This version must be used otherwise: */
3173355c1513SAdrian Chadd struct iwm_phy_context_cmd {
3174355c1513SAdrian Chadd 	/* COMMON_INDEX_HDR_API_S_VER_1 */
3175355c1513SAdrian Chadd 	uint32_t id_and_color;
3176355c1513SAdrian Chadd 	uint32_t action;
3177355c1513SAdrian Chadd 	/* IWM_PHY_CONTEXT_DATA_API_S_VER_1 */
3178355c1513SAdrian Chadd 	uint32_t apply_time;
3179355c1513SAdrian Chadd 	uint32_t tx_param_color;
3180355c1513SAdrian Chadd 	struct iwm_fw_channel_info_v1 ci;
3181355c1513SAdrian Chadd 	uint32_t txchain_info;
3182355c1513SAdrian Chadd 	uint32_t rxchain_info;
3183355c1513SAdrian Chadd 	uint32_t acquisition_data;
3184355c1513SAdrian Chadd 	uint32_t dsp_cfg_flags;
3185355c1513SAdrian Chadd } __packed; /* IWM_PHY_CONTEXT_CMD_API_VER_1 */
3186d4886179SRui Paulo 
3187d4886179SRui Paulo #define IWM_RX_INFO_PHY_CNT 8
3188d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_ABC_IDX 1
3189d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_A_MSK 0x000000ff
3190d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_B_MSK 0x0000ff00
3191d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_C_MSK 0x00ff0000
3192d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_A_POS 0
3193d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_B_POS 8
3194d4886179SRui Paulo #define IWM_RX_INFO_ENERGY_ANT_C_POS 16
3195d4886179SRui Paulo 
3196d4886179SRui Paulo #define IWM_RX_INFO_AGC_IDX 1
3197d4886179SRui Paulo #define IWM_RX_INFO_RSSI_AB_IDX 2
3198d4886179SRui Paulo #define IWM_OFDM_AGC_A_MSK 0x0000007f
3199d4886179SRui Paulo #define IWM_OFDM_AGC_A_POS 0
3200d4886179SRui Paulo #define IWM_OFDM_AGC_B_MSK 0x00003f80
3201d4886179SRui Paulo #define IWM_OFDM_AGC_B_POS 7
3202d4886179SRui Paulo #define IWM_OFDM_AGC_CODE_MSK 0x3fe00000
3203d4886179SRui Paulo #define IWM_OFDM_AGC_CODE_POS 20
3204d4886179SRui Paulo #define IWM_OFDM_RSSI_INBAND_A_MSK 0x00ff
3205d4886179SRui Paulo #define IWM_OFDM_RSSI_A_POS 0
3206d4886179SRui Paulo #define IWM_OFDM_RSSI_ALLBAND_A_MSK 0xff00
3207d4886179SRui Paulo #define IWM_OFDM_RSSI_ALLBAND_A_POS 8
3208d4886179SRui Paulo #define IWM_OFDM_RSSI_INBAND_B_MSK 0xff0000
3209d4886179SRui Paulo #define IWM_OFDM_RSSI_B_POS 16
3210d4886179SRui Paulo #define IWM_OFDM_RSSI_ALLBAND_B_MSK 0xff000000
3211d4886179SRui Paulo #define IWM_OFDM_RSSI_ALLBAND_B_POS 24
3212d4886179SRui Paulo 
3213d4886179SRui Paulo /**
3214d4886179SRui Paulo  * struct iwm_rx_phy_info - phy info
3215d4886179SRui Paulo  * (IWM_REPLY_RX_PHY_CMD = 0xc0)
3216d4886179SRui Paulo  * @non_cfg_phy_cnt: non configurable DSP phy data byte count
3217d4886179SRui Paulo  * @cfg_phy_cnt: configurable DSP phy data byte count
3218d4886179SRui Paulo  * @stat_id: configurable DSP phy data set ID
3219d4886179SRui Paulo  * @reserved1:
3220d4886179SRui Paulo  * @system_timestamp: GP2  at on air rise
3221d4886179SRui Paulo  * @timestamp: TSF at on air rise
3222d4886179SRui Paulo  * @beacon_time_stamp: beacon at on-air rise
3223d4886179SRui Paulo  * @phy_flags: general phy flags: band, modulation, ...
3224d4886179SRui Paulo  * @channel: channel number
3225d4886179SRui Paulo  * @non_cfg_phy_buf: for various implementations of non_cfg_phy
3226d4886179SRui Paulo  * @rate_n_flags: IWM_RATE_MCS_*
3227d4886179SRui Paulo  * @byte_count: frame's byte-count
3228d4886179SRui Paulo  * @frame_time: frame's time on the air, based on byte count and frame rate
3229d4886179SRui Paulo  *	calculation
3230d4886179SRui Paulo  * @mac_active_msk: what MACs were active when the frame was received
3231d4886179SRui Paulo  *
3232d4886179SRui Paulo  * Before each Rx, the device sends this data. It contains PHY information
3233d4886179SRui Paulo  * about the reception of the packet.
3234d4886179SRui Paulo  */
3235d4886179SRui Paulo struct iwm_rx_phy_info {
3236d4886179SRui Paulo 	uint8_t non_cfg_phy_cnt;
3237d4886179SRui Paulo 	uint8_t cfg_phy_cnt;
3238d4886179SRui Paulo 	uint8_t stat_id;
3239d4886179SRui Paulo 	uint8_t reserved1;
3240d4886179SRui Paulo 	uint32_t system_timestamp;
3241d4886179SRui Paulo 	uint64_t timestamp;
3242d4886179SRui Paulo 	uint32_t beacon_time_stamp;
3243d4886179SRui Paulo 	uint16_t phy_flags;
3244d4886179SRui Paulo #define IWM_PHY_INFO_FLAG_SHPREAMBLE	(1 << 2)
3245d4886179SRui Paulo 	uint16_t channel;
3246d4886179SRui Paulo 	uint32_t non_cfg_phy[IWM_RX_INFO_PHY_CNT];
3247355c1513SAdrian Chadd #if 0
3248355c1513SAdrian Chadd 	/* OpenBSD update; will need to convert code to use this field */
3249355c1513SAdrian Chadd 	uint32_t rate_n_flags;
3250355c1513SAdrian Chadd #else
3251d4886179SRui Paulo 	uint8_t rate;
3252d4886179SRui Paulo 	uint8_t rflags;
3253d4886179SRui Paulo 	uint16_t xrflags;
3254355c1513SAdrian Chadd #endif
3255d4886179SRui Paulo 	uint32_t byte_count;
3256d4886179SRui Paulo 	uint16_t mac_active_msk;
3257d4886179SRui Paulo 	uint16_t frame_time;
3258d4886179SRui Paulo } __packed;
3259d4886179SRui Paulo 
3260d4886179SRui Paulo struct iwm_rx_mpdu_res_start {
3261d4886179SRui Paulo 	uint16_t byte_count;
3262d4886179SRui Paulo 	uint16_t reserved;
3263d4886179SRui Paulo } __packed;
3264d4886179SRui Paulo 
3265d4886179SRui Paulo /**
3266355c1513SAdrian Chadd  * Values to parse %iwm_rx_phy_info phy_flags
3267d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_BAND_24: true if the packet was received on 2.4 band
3268d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_MOD_CCK:
3269d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_SHORT_PREAMBLE: true if packet's preamble was short
3270d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_NARROW_BAND:
3271d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_ANTENNA: antenna on which the packet was received
3272d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_AGG: set if the packet was part of an A-MPDU
3273d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_OFDM_HT: The frame was an HT frame
3274d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_OFDM_GF: The frame used GF preamble
3275d4886179SRui Paulo  * @IWM_RX_RES_PHY_FLAGS_OFDM_VHT: The frame was a VHT frame
3276d4886179SRui Paulo  */
3277355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_BAND_24		(1 << 0)
3278355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_MOD_CCK		(1 << 1)
3279355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_SHORT_PREAMBLE	(1 << 2)
3280355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_NARROW_BAND	(1 << 3)
3281355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_ANTENNA		(0x7 << 4)
3282355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_ANTENNA_POS	4
3283355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_AGG		(1 << 7)
3284355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_OFDM_HT		(1 << 8)
3285355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_OFDM_GF		(1 << 9)
3286355c1513SAdrian Chadd #define IWM_RX_RES_PHY_FLAGS_OFDM_VHT		(1 << 10)
3287d4886179SRui Paulo 
3288d4886179SRui Paulo /**
3289355c1513SAdrian Chadd  * Values written by fw for each Rx packet
3290d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_CRC_OK: CRC is fine
3291d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_OVERRUN_OK: there was no RXE overflow
3292d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SRC_STA_FOUND:
3293d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_KEY_VALID:
3294d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_KEY_PARAM_OK:
3295d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_ICV_OK: ICV is fine, if not, the packet is destroyed
3296d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_MIC_OK: used for CCM alg only. TKIP MIC is checked
3297d4886179SRui Paulo  *	in the driver.
3298d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_TTAK_OK: TTAK is fine
3299d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR:  valid for alg = CCM_CMAC or
3300d4886179SRui Paulo  *	alg = CCM only. Checks replay attack for 11w frames. Relevant only if
3301d4886179SRui Paulo  *	%IWM_RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME is set.
3302d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_NO_ENC: this frame is not encrypted
3303d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_WEP_ENC: this frame is encrypted using WEP
3304d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_CCM_ENC: this frame is encrypted using CCM
3305d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_TKIP_ENC: this frame is encrypted using TKIP
3306d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC: this frame is encrypted using CCM_CMAC
3307d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_ENC_ERR: this frame couldn't be decrypted
3308d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_SEC_ENC_MSK: bitmask of the encryption algorithm
3309d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_DEC_DONE: this frame has been successfully decrypted
3310d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP:
3311d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP:
3312d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT:
3313d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME: this frame is an 11w management frame
3314d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_HASH_INDEX_MSK:
3315d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_STA_ID_MSK:
3316d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_RRF_KILL:
3317d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS_FILTERING_MSK:
3318d4886179SRui Paulo  * @IWM_RX_MPDU_RES_STATUS2_FILTERING_MSK:
3319d4886179SRui Paulo  */
3320355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_CRC_OK			(1 << 0)
3321355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_OVERRUN_OK		(1 << 1)
3322355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SRC_STA_FOUND		(1 << 2)
3323355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_KEY_VALID		(1 << 3)
3324355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_KEY_PARAM_OK		(1 << 4)
3325355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_ICV_OK			(1 << 5)
3326355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_MIC_OK			(1 << 6)
3327355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_TTAK_OK			(1 << 7)
3328355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR	(1 << 7)
3329355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_NO_ENC		(0 << 8)
3330355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_WEP_ENC		(1 << 8)
3331355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_CCM_ENC		(2 << 8)
3332355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_TKIP_ENC		(3 << 8)
3333355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_EXT_ENC		(4 << 8)
3334355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC		(6 << 8)
3335355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_ENC_ERR		(7 << 8)
3336355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_SEC_ENC_MSK		(7 << 8)
3337355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_DEC_DONE			(1 << 11)
3338355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP	(1 << 12)
3339355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP		(1 << 13)
3340355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT		(1 << 14)
3341355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME		(1 << 15)
3342355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_HASH_INDEX_MSK		(0x3F0000)
3343355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_STA_ID_MSK		(0x1f000000)
3344355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_RRF_KILL			(1 << 29)
3345355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS_FILTERING_MSK		(0xc00000)
3346355c1513SAdrian Chadd #define IWM_RX_MPDU_RES_STATUS2_FILTERING_MSK		(0xc0000000)
3347d4886179SRui Paulo 
3348355c1513SAdrian Chadd #define IWM_RX_MPDU_MFLG1_ADDRTYPE_MASK		0x03
3349355c1513SAdrian Chadd #define IWM_RX_MPDU_MFLG1_MIC_CRC_LEN_MASK	0xf0
3350355c1513SAdrian Chadd #define IWM_RX_MPDU_MFLG1_MIC_CRC_LEN_SHIFT	3
335196c5aa2fSMark Johnston 
3352355c1513SAdrian Chadd #define IWM_RX_MPDU_MFLG2_HDR_LEN_MASK		0x1f
3353355c1513SAdrian Chadd #define	IWM_RX_MPDU_MFLG2_PAD			0x20
3354355c1513SAdrian Chadd #define IWM_RX_MPDU_MFLG2_AMSDU			0x40
335596c5aa2fSMark Johnston 
3356355c1513SAdrian Chadd #define IWM_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK	0x7f
3357355c1513SAdrian Chadd #define IWM_RX_MPDU_AMSDU_LAST_SUBFRAME		0x80
3358355c1513SAdrian Chadd 
3359355c1513SAdrian Chadd #define IWM_RX_MPDU_PHY_AMPDU			(1 << 5)
3360355c1513SAdrian Chadd #define IWM_RX_MPDU_PHY_AMPDU_TOGGLE		(1 << 6)
3361355c1513SAdrian Chadd #define IWM_RX_MPDU_PHY_SHORT_PREAMBLE		(1 << 7)
3362355c1513SAdrian Chadd #define IWM_RX_MPDU_PHY_NCCK_ADDTL_NTFY		(1 << 7)
3363355c1513SAdrian Chadd #define IWM_RX_MPDU_PHY_TSF_OVERLOAD		(1 << 8)
336496c5aa2fSMark Johnston 
336596c5aa2fSMark Johnston struct iwm_rx_mpdu_desc_v1 {
336696c5aa2fSMark Johnston 	union {
336796c5aa2fSMark Johnston 		uint32_t rss_hash;
336896c5aa2fSMark Johnston 		uint32_t phy_data2;
336996c5aa2fSMark Johnston 	};
337096c5aa2fSMark Johnston 	union {
337196c5aa2fSMark Johnston 		uint32_t filter_match;
337296c5aa2fSMark Johnston 		uint32_t phy_data3;
337396c5aa2fSMark Johnston 	};
337496c5aa2fSMark Johnston 	uint32_t rate_n_flags;
337596c5aa2fSMark Johnston 	uint8_t energy_a;
337696c5aa2fSMark Johnston 	uint8_t energy_b;
337796c5aa2fSMark Johnston 	uint8_t channel;
337896c5aa2fSMark Johnston 	uint8_t mac_context;
337996c5aa2fSMark Johnston 	uint32_t gp2_on_air_rise;
338096c5aa2fSMark Johnston 	union {
338196c5aa2fSMark Johnston 		uint64_t tsf_on_air_rise;
338296c5aa2fSMark Johnston 		struct {
338396c5aa2fSMark Johnston 			uint32_t phy_data0;
338496c5aa2fSMark Johnston 			uint32_t phy_data1;
338596c5aa2fSMark Johnston 		};
338696c5aa2fSMark Johnston 	};
338796c5aa2fSMark Johnston } __packed;
338896c5aa2fSMark Johnston 
3389355c1513SAdrian Chadd #define IWM_RX_REORDER_DATA_INVALID_BAID	0x7f
3390355c1513SAdrian Chadd 
3391355c1513SAdrian Chadd #define IWM_RX_MPDU_REORDER_NSSN_MASK		0x00000fff
3392355c1513SAdrian Chadd #define IWM_RX_MPDU_REORDER_SN_MASK		0x00fff000
3393355c1513SAdrian Chadd #define IWM_RX_MPDU_REORDER_SN_SHIFT		12
3394355c1513SAdrian Chadd #define IWM_RX_MPDU_REORDER_BAID_MASK		0x7f000000
3395355c1513SAdrian Chadd #define IWM_RX_MPDU_REORDER_BAID_SHIFT		24
3396355c1513SAdrian Chadd #define IWM_RX_MPDU_REORDER_BA_OLD_SN		0x80000000
3397355c1513SAdrian Chadd 
339896c5aa2fSMark Johnston struct iwm_rx_mpdu_desc {
339996c5aa2fSMark Johnston 	uint16_t mpdu_len;
340096c5aa2fSMark Johnston 	uint8_t mac_flags1;
340196c5aa2fSMark Johnston 	uint8_t mac_flags2;
340296c5aa2fSMark Johnston 	uint8_t amsdu_info;
340396c5aa2fSMark Johnston 	uint16_t phy_info;
340496c5aa2fSMark Johnston 	uint8_t mac_phy_idx;
340596c5aa2fSMark Johnston 	uint16_t raw_csum;
340696c5aa2fSMark Johnston 	union {
340796c5aa2fSMark Johnston 		uint16_t l3l4_flags;
340896c5aa2fSMark Johnston 		uint16_t phy_data4;
340996c5aa2fSMark Johnston 	};
341096c5aa2fSMark Johnston 	uint16_t status;
341196c5aa2fSMark Johnston 	uint8_t hash_filter;
341296c5aa2fSMark Johnston 	uint8_t sta_id_flags;
341396c5aa2fSMark Johnston 	uint32_t reorder_data;
341496c5aa2fSMark Johnston 	struct iwm_rx_mpdu_desc_v1 v1;
341596c5aa2fSMark Johnston } __packed;
341696c5aa2fSMark Johnston 
3417d4886179SRui Paulo /**
3418d4886179SRui Paulo  * struct iwm_radio_version_notif - information on the radio version
3419d4886179SRui Paulo  * ( IWM_RADIO_VERSION_NOTIFICATION = 0x68 )
3420d4886179SRui Paulo  * @radio_flavor:
3421d4886179SRui Paulo  * @radio_step:
3422d4886179SRui Paulo  * @radio_dash:
3423d4886179SRui Paulo  */
3424d4886179SRui Paulo struct iwm_radio_version_notif {
3425d4886179SRui Paulo 	uint32_t radio_flavor;
3426d4886179SRui Paulo 	uint32_t radio_step;
3427d4886179SRui Paulo 	uint32_t radio_dash;
3428d4886179SRui Paulo } __packed; /* IWM_RADIO_VERSION_NOTOFICATION_S_VER_1 */
3429d4886179SRui Paulo 
3430355c1513SAdrian Chadd #define IWM_CARD_ENABLED		0x00
3431355c1513SAdrian Chadd #define IWM_HW_CARD_DISABLED		0x01
3432355c1513SAdrian Chadd #define IWM_SW_CARD_DISABLED		0x02
3433355c1513SAdrian Chadd #define IWM_CT_KILL_CARD_DISABLED	0x04
3434355c1513SAdrian Chadd #define IWM_HALT_CARD_DISABLED		0x08
3435355c1513SAdrian Chadd #define IWM_CARD_DISABLED_MSK		0x0f
3436355c1513SAdrian Chadd #define IWM_CARD_IS_RX_ON		0x10
3437d4886179SRui Paulo 
3438d4886179SRui Paulo /**
3439d4886179SRui Paulo  * struct iwm_radio_version_notif - information on the radio version
3440d4886179SRui Paulo  * (IWM_CARD_STATE_NOTIFICATION = 0xa1 )
3441d4886179SRui Paulo  * @flags: %iwm_card_state_flags
3442d4886179SRui Paulo  */
3443d4886179SRui Paulo struct iwm_card_state_notif {
3444d4886179SRui Paulo 	uint32_t flags;
3445d4886179SRui Paulo } __packed; /* CARD_STATE_NTFY_API_S_VER_1 */
3446d4886179SRui Paulo 
3447d4886179SRui Paulo /**
3448d4886179SRui Paulo  * struct iwm_missed_beacons_notif - information on missed beacons
3449d4886179SRui Paulo  * ( IWM_MISSED_BEACONS_NOTIFICATION = 0xa2 )
3450d4886179SRui Paulo  * @mac_id: interface ID
3451d4886179SRui Paulo  * @consec_missed_beacons_since_last_rx: number of consecutive missed
3452d4886179SRui Paulo  *	beacons since last RX.
3453d4886179SRui Paulo  * @consec_missed_beacons: number of consecutive missed beacons
3454d4886179SRui Paulo  * @num_expected_beacons:
3455d4886179SRui Paulo  * @num_recvd_beacons:
3456d4886179SRui Paulo  */
3457d4886179SRui Paulo struct iwm_missed_beacons_notif {
3458d4886179SRui Paulo 	uint32_t mac_id;
3459d4886179SRui Paulo 	uint32_t consec_missed_beacons_since_last_rx;
3460d4886179SRui Paulo 	uint32_t consec_missed_beacons;
3461d4886179SRui Paulo 	uint32_t num_expected_beacons;
3462d4886179SRui Paulo 	uint32_t num_recvd_beacons;
3463d4886179SRui Paulo } __packed; /* IWM_MISSED_BEACON_NTFY_API_S_VER_3 */
3464d4886179SRui Paulo 
3465d4886179SRui Paulo /**
34666a5bc1d1SSean Bruno  * struct iwm_mfuart_load_notif - mfuart image version & status
34676a5bc1d1SSean Bruno  * ( IWM_MFUART_LOAD_NOTIFICATION = 0xb1 )
34686a5bc1d1SSean Bruno  * @installed_ver: installed image version
34696a5bc1d1SSean Bruno  * @external_ver: external image version
34706a5bc1d1SSean Bruno  * @status: MFUART loading status
34716a5bc1d1SSean Bruno  * @duration: MFUART loading time
34726a5bc1d1SSean Bruno */
34736a5bc1d1SSean Bruno struct iwm_mfuart_load_notif {
34746a5bc1d1SSean Bruno 	uint32_t installed_ver;
34756a5bc1d1SSean Bruno 	uint32_t external_ver;
34766a5bc1d1SSean Bruno 	uint32_t status;
34776a5bc1d1SSean Bruno 	uint32_t duration;
34786a5bc1d1SSean Bruno } __packed; /*MFU_LOADER_NTFY_API_S_VER_1*/
34796a5bc1d1SSean Bruno 
34806a5bc1d1SSean Bruno /**
3481d4886179SRui Paulo  * struct iwm_set_calib_default_cmd - set default value for calibration.
3482d4886179SRui Paulo  * ( IWM_SET_CALIB_DEFAULT_CMD = 0x8e )
3483d4886179SRui Paulo  * @calib_index: the calibration to set value for
3484d4886179SRui Paulo  * @length: of data
3485d4886179SRui Paulo  * @data: the value to set for the calibration result
3486d4886179SRui Paulo  */
3487d4886179SRui Paulo struct iwm_set_calib_default_cmd {
3488d4886179SRui Paulo 	uint16_t calib_index;
3489d4886179SRui Paulo 	uint16_t length;
3490d4886179SRui Paulo 	uint8_t data[0];
3491d4886179SRui Paulo } __packed; /* IWM_PHY_CALIB_OVERRIDE_VALUES_S */
3492d4886179SRui Paulo 
3493d4886179SRui Paulo #define IWM_MAX_PORT_ID_NUM	2
3494d4886179SRui Paulo #define IWM_MAX_MCAST_FILTERING_ADDRESSES 256
3495d4886179SRui Paulo 
3496d4886179SRui Paulo /**
3497d4886179SRui Paulo  * struct iwm_mcast_filter_cmd - configure multicast filter.
3498d4886179SRui Paulo  * @filter_own: Set 1 to filter out multicast packets sent by station itself
3499d4886179SRui Paulo  * @port_id:	Multicast MAC addresses array specifier. This is a strange way
3500d4886179SRui Paulo  *		to identify network interface adopted in host-device IF.
3501d4886179SRui Paulo  *		It is used by FW as index in array of addresses. This array has
3502d4886179SRui Paulo  *		IWM_MAX_PORT_ID_NUM members.
3503d4886179SRui Paulo  * @count:	Number of MAC addresses in the array
3504d4886179SRui Paulo  * @pass_all:	Set 1 to pass all multicast packets.
3505d4886179SRui Paulo  * @bssid:	current association BSSID.
3506d4886179SRui Paulo  * @addr_list:	Place holder for array of MAC addresses.
3507d4886179SRui Paulo  *		IMPORTANT: add padding if necessary to ensure DWORD alignment.
3508d4886179SRui Paulo  */
3509d4886179SRui Paulo struct iwm_mcast_filter_cmd {
3510d4886179SRui Paulo 	uint8_t filter_own;
3511d4886179SRui Paulo 	uint8_t port_id;
3512d4886179SRui Paulo 	uint8_t count;
3513d4886179SRui Paulo 	uint8_t pass_all;
3514d4886179SRui Paulo 	uint8_t bssid[6];
3515d4886179SRui Paulo 	uint8_t reserved[2];
3516d4886179SRui Paulo 	uint8_t addr_list[0];
3517d4886179SRui Paulo } __packed; /* IWM_MCAST_FILTERING_CMD_API_S_VER_1 */
3518d4886179SRui Paulo 
3519e7065dd1SMark Johnston struct iwm_statistics_dbg {
3520d4886179SRui Paulo 	uint32_t burst_check;
3521d4886179SRui Paulo 	uint32_t burst_count;
3522d4886179SRui Paulo 	uint32_t wait_for_silence_timeout_cnt;
3523d4886179SRui Paulo 	uint32_t reserved[3];
3524d4886179SRui Paulo } __packed; /* IWM_STATISTICS_DEBUG_API_S_VER_2 */
3525d4886179SRui Paulo 
3526e7065dd1SMark Johnston struct iwm_statistics_div {
3527d4886179SRui Paulo 	uint32_t tx_on_a;
3528d4886179SRui Paulo 	uint32_t tx_on_b;
3529d4886179SRui Paulo 	uint32_t exec_time;
3530d4886179SRui Paulo 	uint32_t probe_time;
3531d4886179SRui Paulo 	uint32_t rssi_ant;
3532d4886179SRui Paulo 	uint32_t reserved2;
3533d4886179SRui Paulo } __packed; /* IWM_STATISTICS_SLOW_DIV_API_S_VER_2 */
3534d4886179SRui Paulo 
3535355c1513SAdrian Chadd struct iwm_statistics_general_common {
3536355c1513SAdrian Chadd 	uint32_t temperature;   /* radio temperature */
3537355c1513SAdrian Chadd 	uint32_t temperature_m; /* radio voltage */
3538355c1513SAdrian Chadd 	struct iwm_statistics_dbg dbg;
3539355c1513SAdrian Chadd 	uint32_t sleep_time;
3540355c1513SAdrian Chadd 	uint32_t slots_out;
3541355c1513SAdrian Chadd 	uint32_t slots_idle;
3542355c1513SAdrian Chadd 	uint32_t ttl_timestamp;
3543355c1513SAdrian Chadd 	struct iwm_statistics_div div;
3544355c1513SAdrian Chadd 	uint32_t rx_enable_counter;
3545355c1513SAdrian Chadd 	/*
3546355c1513SAdrian Chadd 	 * num_of_sos_states:
3547355c1513SAdrian Chadd 	 *  count the number of times we have to re-tune
3548355c1513SAdrian Chadd 	 *  in order to get out of bad PHY status
3549355c1513SAdrian Chadd 	 */
3550355c1513SAdrian Chadd 	uint32_t num_of_sos_states;
3551355c1513SAdrian Chadd } __packed; /* IWM_STATISTICS_GENERAL_API_S_VER_5 */
3552355c1513SAdrian Chadd 
3553e7065dd1SMark Johnston struct iwm_statistics_rx_non_phy {
3554d4886179SRui Paulo 	uint32_t bogus_cts;	/* CTS received when not expecting CTS */
3555d4886179SRui Paulo 	uint32_t bogus_ack;	/* ACK received when not expecting ACK */
3556d4886179SRui Paulo 	uint32_t non_bssid_frames;	/* number of frames with BSSID that
3557d4886179SRui Paulo 					 * doesn't belong to the STA BSSID */
3558d4886179SRui Paulo 	uint32_t filtered_frames;	/* count frames that were dumped in the
3559d4886179SRui Paulo 				 * filtering process */
3560d4886179SRui Paulo 	uint32_t non_channel_beacons;	/* beacons with our bss id but not on
3561d4886179SRui Paulo 					 * our serving channel */
3562d4886179SRui Paulo 	uint32_t channel_beacons;	/* beacons with our bss id and in our
3563d4886179SRui Paulo 				 * serving channel */
3564d4886179SRui Paulo 	uint32_t num_missed_bcon;	/* number of missed beacons */
3565d4886179SRui Paulo 	uint32_t adc_rx_saturation_time;	/* count in 0.8us units the time the
3566d4886179SRui Paulo 					 * ADC was in saturation */
3567d4886179SRui Paulo 	uint32_t ina_detection_search_time;/* total time (in 0.8us) searched
3568d4886179SRui Paulo 					  * for INA */
3569d4886179SRui Paulo 	uint32_t beacon_silence_rssi[3];/* RSSI silence after beacon frame */
3570d4886179SRui Paulo 	uint32_t interference_data_flag;	/* flag for interference data
3571d4886179SRui Paulo 					 * availability. 1 when data is
3572d4886179SRui Paulo 					 * available. */
3573d4886179SRui Paulo 	uint32_t channel_load;		/* counts RX Enable time in uSec */
3574d4886179SRui Paulo 	uint32_t dsp_false_alarms;	/* DSP false alarm (both OFDM
3575d4886179SRui Paulo 					 * and CCK) counter */
3576d4886179SRui Paulo 	uint32_t beacon_rssi_a;
3577d4886179SRui Paulo 	uint32_t beacon_rssi_b;
3578d4886179SRui Paulo 	uint32_t beacon_rssi_c;
3579d4886179SRui Paulo 	uint32_t beacon_energy_a;
3580d4886179SRui Paulo 	uint32_t beacon_energy_b;
3581d4886179SRui Paulo 	uint32_t beacon_energy_c;
3582d4886179SRui Paulo 	uint32_t num_bt_kills;
3583d4886179SRui Paulo 	uint32_t mac_id;
3584d4886179SRui Paulo 	uint32_t directed_data_mpdu;
3585d4886179SRui Paulo } __packed; /* IWM_STATISTICS_RX_NON_PHY_API_S_VER_3 */
3586d4886179SRui Paulo 
3587e7065dd1SMark Johnston struct iwm_statistics_rx_phy {
3588d4886179SRui Paulo 	uint32_t ina_cnt;
3589d4886179SRui Paulo 	uint32_t fina_cnt;
3590d4886179SRui Paulo 	uint32_t plcp_err;
3591d4886179SRui Paulo 	uint32_t crc32_err;
3592d4886179SRui Paulo 	uint32_t overrun_err;
3593d4886179SRui Paulo 	uint32_t early_overrun_err;
3594d4886179SRui Paulo 	uint32_t crc32_good;
3595d4886179SRui Paulo 	uint32_t false_alarm_cnt;
3596d4886179SRui Paulo 	uint32_t fina_sync_err_cnt;
3597d4886179SRui Paulo 	uint32_t sfd_timeout;
3598d4886179SRui Paulo 	uint32_t fina_timeout;
3599d4886179SRui Paulo 	uint32_t unresponded_rts;
3600d4886179SRui Paulo 	uint32_t rxe_frame_limit_overrun;
3601d4886179SRui Paulo 	uint32_t sent_ack_cnt;
3602d4886179SRui Paulo 	uint32_t sent_cts_cnt;
3603d4886179SRui Paulo 	uint32_t sent_ba_rsp_cnt;
3604d4886179SRui Paulo 	uint32_t dsp_self_kill;
3605d4886179SRui Paulo 	uint32_t mh_format_err;
3606d4886179SRui Paulo 	uint32_t re_acq_main_rssi_sum;
3607d4886179SRui Paulo 	uint32_t reserved;
3608d4886179SRui Paulo } __packed; /* IWM_STATISTICS_RX_PHY_API_S_VER_2 */
3609d4886179SRui Paulo 
3610e7065dd1SMark Johnston struct iwm_statistics_rx_ht_phy {
3611d4886179SRui Paulo 	uint32_t plcp_err;
3612d4886179SRui Paulo 	uint32_t overrun_err;
3613d4886179SRui Paulo 	uint32_t early_overrun_err;
3614d4886179SRui Paulo 	uint32_t crc32_good;
3615d4886179SRui Paulo 	uint32_t crc32_err;
3616d4886179SRui Paulo 	uint32_t mh_format_err;
3617d4886179SRui Paulo 	uint32_t agg_crc32_good;
3618d4886179SRui Paulo 	uint32_t agg_mpdu_cnt;
3619d4886179SRui Paulo 	uint32_t agg_cnt;
3620d4886179SRui Paulo 	uint32_t unsupport_mcs;
3621d4886179SRui Paulo } __packed;  /* IWM_STATISTICS_HT_RX_PHY_API_S_VER_1 */
3622d4886179SRui Paulo 
3623d4886179SRui Paulo #define IWM_MAX_CHAINS 3
3624d4886179SRui Paulo 
3625e7065dd1SMark Johnston struct iwm_statistics_tx_non_phy_agg {
3626d4886179SRui Paulo 	uint32_t ba_timeout;
3627d4886179SRui Paulo 	uint32_t ba_reschedule_frames;
3628d4886179SRui Paulo 	uint32_t scd_query_agg_frame_cnt;
3629d4886179SRui Paulo 	uint32_t scd_query_no_agg;
3630d4886179SRui Paulo 	uint32_t scd_query_agg;
3631d4886179SRui Paulo 	uint32_t scd_query_mismatch;
3632d4886179SRui Paulo 	uint32_t frame_not_ready;
3633d4886179SRui Paulo 	uint32_t underrun;
3634d4886179SRui Paulo 	uint32_t bt_prio_kill;
3635d4886179SRui Paulo 	uint32_t rx_ba_rsp_cnt;
3636d4886179SRui Paulo 	int8_t txpower[IWM_MAX_CHAINS];
3637d4886179SRui Paulo 	int8_t reserved;
3638d4886179SRui Paulo 	uint32_t reserved2;
3639d4886179SRui Paulo } __packed; /* IWM_STATISTICS_TX_NON_PHY_AGG_API_S_VER_1 */
3640d4886179SRui Paulo 
3641e7065dd1SMark Johnston struct iwm_statistics_tx_channel_width {
3642d4886179SRui Paulo 	uint32_t ext_cca_narrow_ch20[1];
3643d4886179SRui Paulo 	uint32_t ext_cca_narrow_ch40[2];
3644d4886179SRui Paulo 	uint32_t ext_cca_narrow_ch80[3];
3645d4886179SRui Paulo 	uint32_t ext_cca_narrow_ch160[4];
3646d4886179SRui Paulo 	uint32_t last_tx_ch_width_indx;
3647d4886179SRui Paulo 	uint32_t rx_detected_per_ch_width[4];
3648d4886179SRui Paulo 	uint32_t success_per_ch_width[4];
3649d4886179SRui Paulo 	uint32_t fail_per_ch_width[4];
3650d4886179SRui Paulo }; /* IWM_STATISTICS_TX_CHANNEL_WIDTH_API_S_VER_1 */
3651d4886179SRui Paulo 
3652e7065dd1SMark Johnston struct iwm_statistics_tx {
3653355c1513SAdrian Chadd 	uint32_t preamble_cnt;
3654355c1513SAdrian Chadd 	uint32_t rx_detected_cnt;
3655355c1513SAdrian Chadd 	uint32_t bt_prio_defer_cnt;
3656355c1513SAdrian Chadd 	uint32_t bt_prio_kill_cnt;
3657355c1513SAdrian Chadd 	uint32_t few_bytes_cnt;
3658355c1513SAdrian Chadd 	uint32_t cts_timeout;
3659355c1513SAdrian Chadd 	uint32_t ack_timeout;
3660355c1513SAdrian Chadd 	uint32_t expected_ack_cnt;
3661355c1513SAdrian Chadd 	uint32_t actual_ack_cnt;
3662355c1513SAdrian Chadd 	uint32_t dump_msdu_cnt;
3663355c1513SAdrian Chadd 	uint32_t burst_abort_next_frame_mismatch_cnt;
3664355c1513SAdrian Chadd 	uint32_t burst_abort_missing_next_frame_cnt;
3665355c1513SAdrian Chadd 	uint32_t cts_timeout_collision;
3666355c1513SAdrian Chadd 	uint32_t ack_or_ba_timeout_collision;
3667e7065dd1SMark Johnston 	struct iwm_statistics_tx_non_phy_agg agg;
3668e7065dd1SMark Johnston 	struct iwm_statistics_tx_channel_width channel_width;
3669d4886179SRui Paulo } __packed; /* IWM_STATISTICS_TX_API_S_VER_4 */
3670d4886179SRui Paulo 
3671d4886179SRui Paulo 
3672e7065dd1SMark Johnston struct iwm_statistics_bt_activity {
3673d4886179SRui Paulo 	uint32_t hi_priority_tx_req_cnt;
3674d4886179SRui Paulo 	uint32_t hi_priority_tx_denied_cnt;
3675d4886179SRui Paulo 	uint32_t lo_priority_tx_req_cnt;
3676d4886179SRui Paulo 	uint32_t lo_priority_tx_denied_cnt;
3677d4886179SRui Paulo 	uint32_t hi_priority_rx_req_cnt;
3678d4886179SRui Paulo 	uint32_t hi_priority_rx_denied_cnt;
3679d4886179SRui Paulo 	uint32_t lo_priority_rx_req_cnt;
3680d4886179SRui Paulo 	uint32_t lo_priority_rx_denied_cnt;
3681d4886179SRui Paulo } __packed;  /* IWM_STATISTICS_BT_ACTIVITY_API_S_VER_1 */
3682d4886179SRui Paulo 
3683355c1513SAdrian Chadd struct iwm_statistics_general {
3684355c1513SAdrian Chadd 	struct iwm_statistics_general_common common;
3685d4886179SRui Paulo 	uint32_t beacon_filtered;
3686d4886179SRui Paulo 	uint32_t missed_beacons;
3687355c1513SAdrian Chadd 	int8_t beacon_filter_average_energy;
3688355c1513SAdrian Chadd 	int8_t beacon_filter_reason;
3689355c1513SAdrian Chadd 	int8_t beacon_filter_current_energy;
3690355c1513SAdrian Chadd 	int8_t beacon_filter_reserved;
3691d4886179SRui Paulo 	uint32_t beacon_filter_delta_time;
3692e7065dd1SMark Johnston 	struct iwm_statistics_bt_activity bt_activity;
3693355c1513SAdrian Chadd } __packed; /* IWM_STATISTICS_GENERAL_API_S_VER_5 */
3694d4886179SRui Paulo 
3695e7065dd1SMark Johnston struct iwm_statistics_rx {
3696e7065dd1SMark Johnston 	struct iwm_statistics_rx_phy ofdm;
3697e7065dd1SMark Johnston 	struct iwm_statistics_rx_phy cck;
3698e7065dd1SMark Johnston 	struct iwm_statistics_rx_non_phy general;
3699e7065dd1SMark Johnston 	struct iwm_statistics_rx_ht_phy ofdm_ht;
3700d4886179SRui Paulo } __packed; /* IWM_STATISTICS_RX_API_S_VER_3 */
3701d4886179SRui Paulo 
3702d4886179SRui Paulo /*
3703d4886179SRui Paulo  * IWM_STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3704d4886179SRui Paulo  *
3705d4886179SRui Paulo  * By default, uCode issues this notification after receiving a beacon
3706d4886179SRui Paulo  * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
3707355c1513SAdrian Chadd  * IWM_REPLY_STATISTICS_CMD 0x9c, above.
3708355c1513SAdrian Chadd  *
3709355c1513SAdrian Chadd  * Statistics counters continue to increment beacon after beacon, but are
3710355c1513SAdrian Chadd  * cleared when changing channels or when driver issues IWM_REPLY_STATISTICS_CMD
3711355c1513SAdrian Chadd  * 0x9c with CLEAR_STATS bit set (see above).
3712355c1513SAdrian Chadd  *
3713355c1513SAdrian Chadd  * uCode also issues this notification during scans.  uCode clears statistics
3714355c1513SAdrian Chadd  * appropriately so that each notification contains statistics for only the
3715355c1513SAdrian Chadd  * one channel that has just been scanned.
3716d4886179SRui Paulo  */
3717d4886179SRui Paulo 
3718355c1513SAdrian Chadd struct iwm_notif_statistics { /* IWM_STATISTICS_NTFY_API_S_VER_8 */
3719d4886179SRui Paulo 	uint32_t flag;
3720e7065dd1SMark Johnston 	struct iwm_statistics_rx rx;
3721e7065dd1SMark Johnston 	struct iwm_statistics_tx tx;
3722355c1513SAdrian Chadd 	struct iwm_statistics_general general;
3723355c1513SAdrian Chadd } __packed;
3724d4886179SRui Paulo 
3725d4886179SRui Paulo /***********************************
3726d4886179SRui Paulo  * Smart Fifo API
3727d4886179SRui Paulo  ***********************************/
3728d4886179SRui Paulo /* Smart Fifo state */
3729355c1513SAdrian Chadd 
3730d4886179SRui Paulo enum iwm_sf_state {
3731d4886179SRui Paulo 	IWM_SF_LONG_DELAY_ON = 0, /* should never be called by driver */
3732d4886179SRui Paulo 	IWM_SF_FULL_ON,
3733d4886179SRui Paulo 	IWM_SF_UNINIT,
3734d4886179SRui Paulo 	IWM_SF_INIT_OFF,
3735d4886179SRui Paulo 	IWM_SF_HW_NUM_STATES
3736d4886179SRui Paulo };
3737d4886179SRui Paulo 
3738d4886179SRui Paulo /* Smart Fifo possible scenario */
3739d4886179SRui Paulo enum iwm_sf_scenario {
3740d4886179SRui Paulo 	IWM_SF_SCENARIO_SINGLE_UNICAST,
3741d4886179SRui Paulo 	IWM_SF_SCENARIO_AGG_UNICAST,
3742d4886179SRui Paulo 	IWM_SF_SCENARIO_MULTICAST,
3743d4886179SRui Paulo 	IWM_SF_SCENARIO_BA_RESP,
3744d4886179SRui Paulo 	IWM_SF_SCENARIO_TX_RESP,
3745d4886179SRui Paulo 	IWM_SF_NUM_SCENARIO
3746d4886179SRui Paulo };
3747d4886179SRui Paulo 
3748d4886179SRui Paulo #define IWM_SF_TRANSIENT_STATES_NUMBER 2 /* IWM_SF_LONG_DELAY_ON and IWM_SF_FULL_ON */
3749d4886179SRui Paulo #define IWM_SF_NUM_TIMEOUT_TYPES 2	/* Aging timer and Idle timer */
3750d4886179SRui Paulo 
3751d4886179SRui Paulo /* smart FIFO default values */
3752d4886179SRui Paulo #define IWM_SF_W_MARK_SISO 4096
3753d4886179SRui Paulo #define IWM_SF_W_MARK_MIMO2 8192
3754d4886179SRui Paulo #define IWM_SF_W_MARK_MIMO3 6144
3755d4886179SRui Paulo #define IWM_SF_W_MARK_LEGACY 4096
3756d4886179SRui Paulo #define IWM_SF_W_MARK_SCAN 4096
3757d4886179SRui Paulo 
37586a5bc1d1SSean Bruno /* SF Scenarios timers for default configuration (aligned to 32 uSec) */
37596a5bc1d1SSean Bruno #define IWM_SF_SINGLE_UNICAST_IDLE_TIMER_DEF 160	/* 150 uSec  */
37606a5bc1d1SSean Bruno #define IWM_SF_SINGLE_UNICAST_AGING_TIMER_DEF 400	/* 0.4 mSec */
37616a5bc1d1SSean Bruno #define IWM_SF_AGG_UNICAST_IDLE_TIMER_DEF 160		/* 150 uSec */
37626a5bc1d1SSean Bruno #define IWM_SF_AGG_UNICAST_AGING_TIMER_DEF 400		/* 0.4 mSec */
3763355c1513SAdrian Chadd #define IWM_SF_MCAST_IDLE_TIMER_DEF 160			/* 150 mSec */
37646a5bc1d1SSean Bruno #define IWM_SF_MCAST_AGING_TIMER_DEF 400		/* 0.4 mSec */
37656a5bc1d1SSean Bruno #define IWM_SF_BA_IDLE_TIMER_DEF 160			/* 150 uSec */
37666a5bc1d1SSean Bruno #define IWM_SF_BA_AGING_TIMER_DEF 400			/* 0.4 mSec */
37676a5bc1d1SSean Bruno #define IWM_SF_TX_RE_IDLE_TIMER_DEF 160			/* 150 uSec */
37686a5bc1d1SSean Bruno #define IWM_SF_TX_RE_AGING_TIMER_DEF 400		/* 0.4 mSec */
37696a5bc1d1SSean Bruno 
3770d4886179SRui Paulo /* SF Scenarios timers for FULL_ON state (aligned to 32 uSec) */
3771d4886179SRui Paulo #define IWM_SF_SINGLE_UNICAST_IDLE_TIMER 320	/* 300 uSec  */
3772d4886179SRui Paulo #define IWM_SF_SINGLE_UNICAST_AGING_TIMER 2016	/* 2 mSec */
3773d4886179SRui Paulo #define IWM_SF_AGG_UNICAST_IDLE_TIMER 320	/* 300 uSec */
3774d4886179SRui Paulo #define IWM_SF_AGG_UNICAST_AGING_TIMER 2016	/* 2 mSec */
3775d4886179SRui Paulo #define IWM_SF_MCAST_IDLE_TIMER 2016		/* 2 mSec */
3776d4886179SRui Paulo #define IWM_SF_MCAST_AGING_TIMER 10016		/* 10 mSec */
3777d4886179SRui Paulo #define IWM_SF_BA_IDLE_TIMER 320		/* 300 uSec */
3778d4886179SRui Paulo #define IWM_SF_BA_AGING_TIMER 2016		/* 2 mSec */
3779d4886179SRui Paulo #define IWM_SF_TX_RE_IDLE_TIMER 320		/* 300 uSec */
3780d4886179SRui Paulo #define IWM_SF_TX_RE_AGING_TIMER 2016		/* 2 mSec */
3781d4886179SRui Paulo 
3782d4886179SRui Paulo #define IWM_SF_LONG_DELAY_AGING_TIMER 1000000	/* 1 Sec */
3783d4886179SRui Paulo 
37846a5bc1d1SSean Bruno #define IWM_SF_CFG_DUMMY_NOTIF_OFF	(1 << 16)
37856a5bc1d1SSean Bruno 
3786d4886179SRui Paulo /**
3787d4886179SRui Paulo  * Smart Fifo configuration command.
3788355c1513SAdrian Chadd  * @state: smart fifo state, types listed in enum %iwm_sf_state.
37898acb6621SGordon Bergling  * @watermark: Minimum allowed available free space in RXF for transient state.
3790d4886179SRui Paulo  * @long_delay_timeouts: aging and idle timer values for each scenario
3791d4886179SRui Paulo  * in long delay state.
3792d4886179SRui Paulo  * @full_on_timeouts: timer values for each scenario in full on state.
3793d4886179SRui Paulo  */
3794d4886179SRui Paulo struct iwm_sf_cfg_cmd {
3795ef81578cSImre Vadász 	uint32_t state;
3796d4886179SRui Paulo 	uint32_t watermark[IWM_SF_TRANSIENT_STATES_NUMBER];
3797d4886179SRui Paulo 	uint32_t long_delay_timeouts[IWM_SF_NUM_SCENARIO][IWM_SF_NUM_TIMEOUT_TYPES];
3798d4886179SRui Paulo 	uint32_t full_on_timeouts[IWM_SF_NUM_SCENARIO][IWM_SF_NUM_TIMEOUT_TYPES];
3799d4886179SRui Paulo } __packed; /* IWM_SF_CFG_API_S_VER_2 */
3800d4886179SRui Paulo 
3801d4886179SRui Paulo /*
3802d4886179SRui Paulo  * END mvm/fw-api.h
3803d4886179SRui Paulo  */
3804d4886179SRui Paulo 
3805d4886179SRui Paulo /*
3806d4886179SRui Paulo  * BEGIN mvm/fw-api-mac.h
3807d4886179SRui Paulo  */
3808d4886179SRui Paulo 
3809355c1513SAdrian Chadd /*
3810355c1513SAdrian Chadd  * The first MAC indices (starting from 0)
3811355c1513SAdrian Chadd  * are available to the driver, AUX follows
3812355c1513SAdrian Chadd  */
3813355c1513SAdrian Chadd #define IWM_MAC_INDEX_AUX		4
3814355c1513SAdrian Chadd #define IWM_MAC_INDEX_MIN_DRIVER	0
3815355c1513SAdrian Chadd #define IWM_NUM_MAC_INDEX_DRIVER	IWM_MAC_INDEX_AUX
3816355c1513SAdrian Chadd 
3817355c1513SAdrian Chadd #define IWM_AC_BK	0
3818355c1513SAdrian Chadd #define IWM_AC_BE	1
3819355c1513SAdrian Chadd #define IWM_AC_VI	2
3820355c1513SAdrian Chadd #define IWM_AC_VO	3
3821355c1513SAdrian Chadd #define IWM_AC_NUM	4
3822d4886179SRui Paulo 
3823d4886179SRui Paulo /**
3824355c1513SAdrian Chadd  * MAC context flags
3825d4886179SRui Paulo  * @IWM_MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames,
3826d4886179SRui Paulo  *	this will require CCK RTS/CTS2self.
3827d4886179SRui Paulo  *	RTS/CTS will protect full burst time.
3828d4886179SRui Paulo  * @IWM_MAC_PROT_FLG_HT_PROT: enable HT protection
3829d4886179SRui Paulo  * @IWM_MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions
3830d4886179SRui Paulo  * @IWM_MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self
3831d4886179SRui Paulo  */
3832355c1513SAdrian Chadd #define IWM_MAC_PROT_FLG_TGG_PROTECT	(1 << 3)
3833355c1513SAdrian Chadd #define IWM_MAC_PROT_FLG_HT_PROT	(1 << 23)
3834355c1513SAdrian Chadd #define IWM_MAC_PROT_FLG_FAT_PROT	(1 << 24)
3835355c1513SAdrian Chadd #define IWM_MAC_PROT_FLG_SELF_CTS_EN	(1 << 30)
3836d4886179SRui Paulo 
3837d4886179SRui Paulo #define IWM_MAC_FLG_SHORT_SLOT		(1 << 4)
3838d4886179SRui Paulo #define IWM_MAC_FLG_SHORT_PREAMBLE	(1 << 5)
3839d4886179SRui Paulo 
3840d4886179SRui Paulo /**
3841355c1513SAdrian Chadd  * Supported MAC types
3842d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_FIRST: lowest supported MAC type
3843d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_AUX: Auxiliary MAC (internal)
3844d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_LISTENER: monitor MAC type (?)
3845d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_PIBSS: Pseudo-IBSS
3846d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_IBSS: IBSS
3847d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_BSS_STA: BSS (managed) station
3848d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_P2P_DEVICE: P2P Device
3849d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_P2P_STA: P2P client
3850d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_GO: P2P GO
3851d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_TEST: ?
3852d4886179SRui Paulo  * @IWM_FW_MAC_TYPE_MAX: highest support MAC type
3853d4886179SRui Paulo  */
3854355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_FIRST		1
3855355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_AUX		IWM_FW_MAC_TYPE_FIRST
3856355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_LISTENER	2
3857355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_PIBSS		3
3858355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_IBSS		4
3859355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_BSS_STA		5
3860355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_P2P_DEVICE	6
3861355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_P2P_STA		7
3862355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_GO		8
3863355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_TEST		9
3864355c1513SAdrian Chadd #define IWM_FW_MAC_TYPE_MAX		IWM_FW_MAC_TYPE_TEST
3865355c1513SAdrian Chadd /* IWM_MAC_CONTEXT_TYPE_API_E_VER_1 */
3866d4886179SRui Paulo 
3867d4886179SRui Paulo /**
3868355c1513SAdrian Chadd  * TSF hw timer ID
3869d4886179SRui Paulo  * @IWM_TSF_ID_A: use TSF A
3870d4886179SRui Paulo  * @IWM_TSF_ID_B: use TSF B
3871d4886179SRui Paulo  * @IWM_TSF_ID_C: use TSF C
3872d4886179SRui Paulo  * @IWM_TSF_ID_D: use TSF D
3873d4886179SRui Paulo  * @IWM_NUM_TSF_IDS: number of TSF timers available
3874d4886179SRui Paulo  */
3875355c1513SAdrian Chadd #define IWM_TSF_ID_A	0
3876355c1513SAdrian Chadd #define IWM_TSF_ID_B	1
3877355c1513SAdrian Chadd #define IWM_TSF_ID_C	2
3878355c1513SAdrian Chadd #define IWM_TSF_ID_D	3
3879355c1513SAdrian Chadd #define IWM_NUM_TSF_IDS	4
3880355c1513SAdrian Chadd /* IWM_TSF_ID_API_E_VER_1 */
3881d4886179SRui Paulo 
3882d4886179SRui Paulo /**
3883d4886179SRui Paulo  * struct iwm_mac_data_ap - configuration data for AP MAC context
3884d4886179SRui Paulo  * @beacon_time: beacon transmit time in system time
3885d4886179SRui Paulo  * @beacon_tsf: beacon transmit time in TSF
3886d4886179SRui Paulo  * @bi: beacon interval in TU
3887d4886179SRui Paulo  * @bi_reciprocal: 2^32 / bi
3888d4886179SRui Paulo  * @dtim_interval: dtim transmit time in TU
3889d4886179SRui Paulo  * @dtim_reciprocal: 2^32 / dtim_interval
3890d4886179SRui Paulo  * @mcast_qid: queue ID for multicast traffic
3891355c1513SAdrian Chadd  *	NOTE: obsolete from VER2 and on
3892d4886179SRui Paulo  * @beacon_template: beacon template ID
3893d4886179SRui Paulo  */
3894d4886179SRui Paulo struct iwm_mac_data_ap {
3895d4886179SRui Paulo 	uint32_t beacon_time;
3896d4886179SRui Paulo 	uint64_t beacon_tsf;
3897d4886179SRui Paulo 	uint32_t bi;
3898d4886179SRui Paulo 	uint32_t bi_reciprocal;
3899d4886179SRui Paulo 	uint32_t dtim_interval;
3900d4886179SRui Paulo 	uint32_t dtim_reciprocal;
3901d4886179SRui Paulo 	uint32_t mcast_qid;
3902d4886179SRui Paulo 	uint32_t beacon_template;
3903355c1513SAdrian Chadd } __packed; /* AP_MAC_DATA_API_S_VER_2 */
3904d4886179SRui Paulo 
3905d4886179SRui Paulo /**
3906d4886179SRui Paulo  * struct iwm_mac_data_ibss - configuration data for IBSS MAC context
3907d4886179SRui Paulo  * @beacon_time: beacon transmit time in system time
3908d4886179SRui Paulo  * @beacon_tsf: beacon transmit time in TSF
3909d4886179SRui Paulo  * @bi: beacon interval in TU
3910d4886179SRui Paulo  * @bi_reciprocal: 2^32 / bi
3911d4886179SRui Paulo  * @beacon_template: beacon template ID
3912d4886179SRui Paulo  */
3913d4886179SRui Paulo struct iwm_mac_data_ibss {
3914d4886179SRui Paulo 	uint32_t beacon_time;
3915d4886179SRui Paulo 	uint64_t beacon_tsf;
3916d4886179SRui Paulo 	uint32_t bi;
3917d4886179SRui Paulo 	uint32_t bi_reciprocal;
3918d4886179SRui Paulo 	uint32_t beacon_template;
3919d4886179SRui Paulo } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
3920d4886179SRui Paulo 
3921d4886179SRui Paulo /**
3922d4886179SRui Paulo  * struct iwm_mac_data_sta - configuration data for station MAC context
3923d4886179SRui Paulo  * @is_assoc: 1 for associated state, 0 otherwise
3924d4886179SRui Paulo  * @dtim_time: DTIM arrival time in system time
3925d4886179SRui Paulo  * @dtim_tsf: DTIM arrival time in TSF
3926d4886179SRui Paulo  * @bi: beacon interval in TU, applicable only when associated
3927d4886179SRui Paulo  * @bi_reciprocal: 2^32 / bi , applicable only when associated
3928d4886179SRui Paulo  * @dtim_interval: DTIM interval in TU, applicable only when associated
3929d4886179SRui Paulo  * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
3930d4886179SRui Paulo  * @listen_interval: in beacon intervals, applicable only when associated
3931d4886179SRui Paulo  * @assoc_id: unique ID assigned by the AP during association
3932d4886179SRui Paulo  */
3933d4886179SRui Paulo struct iwm_mac_data_sta {
3934d4886179SRui Paulo 	uint32_t is_assoc;
3935d4886179SRui Paulo 	uint32_t dtim_time;
3936d4886179SRui Paulo 	uint64_t dtim_tsf;
3937d4886179SRui Paulo 	uint32_t bi;
3938d4886179SRui Paulo 	uint32_t bi_reciprocal;
3939d4886179SRui Paulo 	uint32_t dtim_interval;
3940d4886179SRui Paulo 	uint32_t dtim_reciprocal;
3941d4886179SRui Paulo 	uint32_t listen_interval;
3942d4886179SRui Paulo 	uint32_t assoc_id;
3943d4886179SRui Paulo 	uint32_t assoc_beacon_arrive_time;
3944d4886179SRui Paulo } __packed; /* IWM_STA_MAC_DATA_API_S_VER_1 */
3945d4886179SRui Paulo 
3946d4886179SRui Paulo /**
3947d4886179SRui Paulo  * struct iwm_mac_data_go - configuration data for P2P GO MAC context
3948d4886179SRui Paulo  * @ap: iwm_mac_data_ap struct with most config data
3949d4886179SRui Paulo  * @ctwin: client traffic window in TU (period after TBTT when GO is present).
3950d4886179SRui Paulo  *	0 indicates that there is no CT window.
3951d4886179SRui Paulo  * @opp_ps_enabled: indicate that opportunistic PS allowed
3952d4886179SRui Paulo  */
3953d4886179SRui Paulo struct iwm_mac_data_go {
3954d4886179SRui Paulo 	struct iwm_mac_data_ap ap;
3955d4886179SRui Paulo 	uint32_t ctwin;
3956d4886179SRui Paulo 	uint32_t opp_ps_enabled;
3957d4886179SRui Paulo } __packed; /* GO_MAC_DATA_API_S_VER_1 */
3958d4886179SRui Paulo 
3959d4886179SRui Paulo /**
3960d4886179SRui Paulo  * struct iwm_mac_data_p2p_sta - configuration data for P2P client MAC context
3961d4886179SRui Paulo  * @sta: iwm_mac_data_sta struct with most config data
3962d4886179SRui Paulo  * @ctwin: client traffic window in TU (period after TBTT when GO is present).
3963d4886179SRui Paulo  *	0 indicates that there is no CT window.
3964d4886179SRui Paulo  */
3965d4886179SRui Paulo struct iwm_mac_data_p2p_sta {
3966d4886179SRui Paulo 	struct iwm_mac_data_sta sta;
3967d4886179SRui Paulo 	uint32_t ctwin;
3968d4886179SRui Paulo } __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */
3969d4886179SRui Paulo 
3970d4886179SRui Paulo /**
3971d4886179SRui Paulo  * struct iwm_mac_data_pibss - Pseudo IBSS config data
3972d4886179SRui Paulo  * @stats_interval: interval in TU between statistics notifications to host.
3973d4886179SRui Paulo  */
3974d4886179SRui Paulo struct iwm_mac_data_pibss {
3975d4886179SRui Paulo 	uint32_t stats_interval;
3976d4886179SRui Paulo } __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */
3977d4886179SRui Paulo 
3978d4886179SRui Paulo /*
3979d4886179SRui Paulo  * struct iwm_mac_data_p2p_dev - configuration data for the P2P Device MAC
3980d4886179SRui Paulo  * context.
3981d4886179SRui Paulo  * @is_disc_extended: if set to true, P2P Device discoverability is enabled on
3982d4886179SRui Paulo  *	other channels as well. This should be to true only in case that the
3983d4886179SRui Paulo  *	device is discoverable and there is an active GO. Note that setting this
3984d4886179SRui Paulo  *	field when not needed, will increase the number of interrupts and have
3985d4886179SRui Paulo  *	effect on the platform power, as this setting opens the Rx filters on
3986d4886179SRui Paulo  *	all macs.
3987d4886179SRui Paulo  */
3988d4886179SRui Paulo struct iwm_mac_data_p2p_dev {
3989d4886179SRui Paulo 	uint32_t is_disc_extended;
3990d4886179SRui Paulo } __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */
3991d4886179SRui Paulo 
3992d4886179SRui Paulo /**
3993355c1513SAdrian Chadd  * MAC context filter flags
3994d4886179SRui Paulo  * @IWM_MAC_FILTER_IN_PROMISC: accept all data frames
3995d4886179SRui Paulo  * @IWM_MAC_FILTER_IN_CONTROL_AND_MGMT: pass all mangement and
3996d4886179SRui Paulo  *	control frames to the host
3997d4886179SRui Paulo  * @IWM_MAC_FILTER_ACCEPT_GRP: accept multicast frames
3998d4886179SRui Paulo  * @IWM_MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames
3999d4886179SRui Paulo  * @IWM_MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames
4000d4886179SRui Paulo  * @IWM_MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host
4001d4886179SRui Paulo  *	(in station mode when associated)
4002d4886179SRui Paulo  * @IWM_MAC_FILTER_OUT_BCAST: filter out all broadcast frames
4003d4886179SRui Paulo  * @IWM_MAC_FILTER_IN_CRC32: extract FCS and append it to frames
4004d4886179SRui Paulo  * @IWM_MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host
4005d4886179SRui Paulo  */
4006355c1513SAdrian Chadd #define IWM_MAC_FILTER_IN_PROMISC		(1 << 0)
4007355c1513SAdrian Chadd #define IWM_MAC_FILTER_IN_CONTROL_AND_MGMT	(1 << 1)
4008355c1513SAdrian Chadd #define IWM_MAC_FILTER_ACCEPT_GRP		(1 << 2)
4009355c1513SAdrian Chadd #define IWM_MAC_FILTER_DIS_DECRYPT		(1 << 3)
4010355c1513SAdrian Chadd #define IWM_MAC_FILTER_DIS_GRP_DECRYPT		(1 << 4)
4011355c1513SAdrian Chadd #define IWM_MAC_FILTER_IN_BEACON		(1 << 6)
4012355c1513SAdrian Chadd #define IWM_MAC_FILTER_OUT_BCAST		(1 << 8)
4013355c1513SAdrian Chadd #define IWM_MAC_FILTER_IN_CRC32			(1 << 11)
4014355c1513SAdrian Chadd #define IWM_MAC_FILTER_IN_PROBE_REQUEST		(1 << 12)
4015d4886179SRui Paulo 
4016d4886179SRui Paulo /**
4017355c1513SAdrian Chadd  * QoS flags
4018d4886179SRui Paulo  * @IWM_MAC_QOS_FLG_UPDATE_EDCA: ?
4019d4886179SRui Paulo  * @IWM_MAC_QOS_FLG_TGN: HT is enabled
4020d4886179SRui Paulo  * @IWM_MAC_QOS_FLG_TXOP_TYPE: ?
4021d4886179SRui Paulo  *
4022d4886179SRui Paulo  */
4023355c1513SAdrian Chadd #define IWM_MAC_QOS_FLG_UPDATE_EDCA	(1 << 0)
4024355c1513SAdrian Chadd #define IWM_MAC_QOS_FLG_TGN		(1 << 1)
4025355c1513SAdrian Chadd #define IWM_MAC_QOS_FLG_TXOP_TYPE	(1 << 4)
4026d4886179SRui Paulo 
4027d4886179SRui Paulo /**
4028d4886179SRui Paulo  * struct iwm_ac_qos - QOS timing params for IWM_MAC_CONTEXT_CMD
4029d4886179SRui Paulo  * @cw_min: Contention window, start value in numbers of slots.
4030d4886179SRui Paulo  *	Should be a power-of-2, minus 1.  Device's default is 0x0f.
4031d4886179SRui Paulo  * @cw_max: Contention window, max value in numbers of slots.
4032d4886179SRui Paulo  *	Should be a power-of-2, minus 1.  Device's default is 0x3f.
4033d4886179SRui Paulo  * @aifsn:  Number of slots in Arbitration Interframe Space (before
4034d4886179SRui Paulo  *	performing random backoff timing prior to Tx).  Device default 1.
4035d4886179SRui Paulo  * @fifos_mask: FIFOs used by this MAC for this AC
4036d4886179SRui Paulo  * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
4037d4886179SRui Paulo  *
4038d4886179SRui Paulo  * One instance of this config struct for each of 4 EDCA access categories
4039d4886179SRui Paulo  * in struct iwm_qosparam_cmd.
4040d4886179SRui Paulo  *
4041d4886179SRui Paulo  * Device will automatically increase contention window by (2*CW) + 1 for each
4042d4886179SRui Paulo  * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
4043d4886179SRui Paulo  * value, to cap the CW value.
4044d4886179SRui Paulo  */
4045d4886179SRui Paulo struct iwm_ac_qos {
4046d4886179SRui Paulo 	uint16_t cw_min;
4047d4886179SRui Paulo 	uint16_t cw_max;
4048d4886179SRui Paulo 	uint8_t aifsn;
4049d4886179SRui Paulo 	uint8_t fifos_mask;
4050d4886179SRui Paulo 	uint16_t edca_txop;
4051d4886179SRui Paulo } __packed; /* IWM_AC_QOS_API_S_VER_2 */
4052d4886179SRui Paulo 
4053d4886179SRui Paulo /**
4054d4886179SRui Paulo  * struct iwm_mac_ctx_cmd - command structure to configure MAC contexts
4055d4886179SRui Paulo  * ( IWM_MAC_CONTEXT_CMD = 0x28 )
4056d4886179SRui Paulo  * @id_and_color: ID and color of the MAC
4057d4886179SRui Paulo  * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
4058d4886179SRui Paulo  * @mac_type: one of IWM_FW_MAC_TYPE_*
4059355c1513SAdrian Chadd  * @tsf_id: TSF HW timer, one of IWM_TSF_ID_*
4060d4886179SRui Paulo  * @node_addr: MAC address
4061d4886179SRui Paulo  * @bssid_addr: BSSID
4062d4886179SRui Paulo  * @cck_rates: basic rates available for CCK
4063d4886179SRui Paulo  * @ofdm_rates: basic rates available for OFDM
4064d4886179SRui Paulo  * @protection_flags: combination of IWM_MAC_PROT_FLG_FLAG_*
4065d4886179SRui Paulo  * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise
4066d4886179SRui Paulo  * @short_slot: 0x10 for enabling short slots, 0 otherwise
4067d4886179SRui Paulo  * @filter_flags: combination of IWM_MAC_FILTER_*
4068d4886179SRui Paulo  * @qos_flags: from IWM_MAC_QOS_FLG_*
4069d4886179SRui Paulo  * @ac: one iwm_mac_qos configuration for each AC
4070d4886179SRui Paulo  * @mac_specific: one of struct iwm_mac_data_*, according to mac_type
4071d4886179SRui Paulo  */
4072d4886179SRui Paulo struct iwm_mac_ctx_cmd {
4073d4886179SRui Paulo 	/* COMMON_INDEX_HDR_API_S_VER_1 */
4074d4886179SRui Paulo 	uint32_t id_and_color;
4075d4886179SRui Paulo 	uint32_t action;
4076d4886179SRui Paulo 	/* IWM_MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */
4077d4886179SRui Paulo 	uint32_t mac_type;
4078d4886179SRui Paulo 	uint32_t tsf_id;
4079d4886179SRui Paulo 	uint8_t node_addr[6];
4080d4886179SRui Paulo 	uint16_t reserved_for_node_addr;
4081d4886179SRui Paulo 	uint8_t bssid_addr[6];
4082d4886179SRui Paulo 	uint16_t reserved_for_bssid_addr;
4083d4886179SRui Paulo 	uint32_t cck_rates;
4084d4886179SRui Paulo 	uint32_t ofdm_rates;
4085d4886179SRui Paulo 	uint32_t protection_flags;
4086d4886179SRui Paulo 	uint32_t cck_short_preamble;
4087d4886179SRui Paulo 	uint32_t short_slot;
4088d4886179SRui Paulo 	uint32_t filter_flags;
4089d4886179SRui Paulo 	/* IWM_MAC_QOS_PARAM_API_S_VER_1 */
4090d4886179SRui Paulo 	uint32_t qos_flags;
4091d4886179SRui Paulo 	struct iwm_ac_qos ac[IWM_AC_NUM+1];
4092d4886179SRui Paulo 	/* IWM_MAC_CONTEXT_COMMON_DATA_API_S */
4093d4886179SRui Paulo 	union {
4094d4886179SRui Paulo 		struct iwm_mac_data_ap ap;
4095d4886179SRui Paulo 		struct iwm_mac_data_go go;
4096d4886179SRui Paulo 		struct iwm_mac_data_sta sta;
4097d4886179SRui Paulo 		struct iwm_mac_data_p2p_sta p2p_sta;
4098d4886179SRui Paulo 		struct iwm_mac_data_p2p_dev p2p_dev;
4099d4886179SRui Paulo 		struct iwm_mac_data_pibss pibss;
4100d4886179SRui Paulo 		struct iwm_mac_data_ibss ibss;
4101d4886179SRui Paulo 	};
4102d4886179SRui Paulo } __packed; /* IWM_MAC_CONTEXT_CMD_API_S_VER_1 */
4103d4886179SRui Paulo 
4104e7065dd1SMark Johnston static inline uint32_t iwm_reciprocal(uint32_t v)
4105d4886179SRui Paulo {
4106d4886179SRui Paulo 	if (!v)
4107d4886179SRui Paulo 		return 0;
4108d4886179SRui Paulo 	return 0xFFFFFFFF / v;
4109d4886179SRui Paulo }
4110d4886179SRui Paulo 
4111d4886179SRui Paulo #define IWM_NONQOS_SEQ_GET	0x1
4112d4886179SRui Paulo #define IWM_NONQOS_SEQ_SET	0x2
4113d4886179SRui Paulo struct iwm_nonqos_seq_query_cmd {
4114d4886179SRui Paulo 	uint32_t get_set_flag;
4115d4886179SRui Paulo 	uint32_t mac_id_n_color;
4116d4886179SRui Paulo 	uint16_t value;
4117d4886179SRui Paulo 	uint16_t reserved;
4118d4886179SRui Paulo } __packed; /* IWM_NON_QOS_TX_COUNTER_GET_SET_API_S_VER_1 */
4119d4886179SRui Paulo 
4120d4886179SRui Paulo /*
4121d4886179SRui Paulo  * END mvm/fw-api-mac.h
4122d4886179SRui Paulo  */
4123d4886179SRui Paulo 
4124d4886179SRui Paulo /*
4125d4886179SRui Paulo  * BEGIN mvm/fw-api-power.h
4126d4886179SRui Paulo  */
4127d4886179SRui Paulo 
4128d4886179SRui Paulo /* Power Management Commands, Responses, Notifications */
4129d4886179SRui Paulo 
41309612bbf4SKyle Evans /**
4131355c1513SAdrian Chadd  * masks for LTR config command flags
41329612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status
41339612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow
41349612bbf4SKyle Evans  *      memory access
41359612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR
41369612bbf4SKyle Evans  *      reg change
41379612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from
41389612bbf4SKyle Evans  *      D0 to D3
41399612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
41409612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
41419612bbf4SKyle Evans  * @IWM_LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
41429612bbf4SKyle Evans  */
4143355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_FEATURE_ENABLE			0x00000001
4144355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS	0x00000002
4145355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH		0x00000004
4146355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3		0x00000008
4147355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_SW_SET_SHORT			0x00000010
4148355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_SW_SET_LONG			0x00000020
4149355c1513SAdrian Chadd #define IWM_LTR_CFG_FLAG_DENIE_C10_ON_PD		0x00000040
41509612bbf4SKyle Evans 
41519612bbf4SKyle Evans /**
41529612bbf4SKyle Evans  * struct iwm_ltr_config_cmd_v1 - configures the LTR
41539612bbf4SKyle Evans  * @flags: See %enum iwm_ltr_config_flags
41549612bbf4SKyle Evans  */
41559612bbf4SKyle Evans struct iwm_ltr_config_cmd_v1 {
41569612bbf4SKyle Evans 	uint32_t flags;
41579612bbf4SKyle Evans 	uint32_t static_long;
41589612bbf4SKyle Evans 	uint32_t static_short;
41599612bbf4SKyle Evans } __packed; /* LTR_CAPABLE_API_S_VER_1 */
41609612bbf4SKyle Evans 
41619612bbf4SKyle Evans #define IWM_LTR_VALID_STATES_NUM 4
41629612bbf4SKyle Evans 
41639612bbf4SKyle Evans /**
41649612bbf4SKyle Evans  * struct iwm_ltr_config_cmd - configures the LTR
41659612bbf4SKyle Evans  * @flags: See %enum iwm_ltr_config_flags
41669612bbf4SKyle Evans  * @static_long:
41679612bbf4SKyle Evans  * @static_short:
41689612bbf4SKyle Evans  * @ltr_cfg_values:
41699612bbf4SKyle Evans  * @ltr_short_idle_timeout:
41709612bbf4SKyle Evans  */
41719612bbf4SKyle Evans struct iwm_ltr_config_cmd {
41729612bbf4SKyle Evans 	uint32_t flags;
41739612bbf4SKyle Evans 	uint32_t static_long;
41749612bbf4SKyle Evans 	uint32_t static_short;
41759612bbf4SKyle Evans 	uint32_t ltr_cfg_values[IWM_LTR_VALID_STATES_NUM];
41769612bbf4SKyle Evans 	uint32_t ltr_short_idle_timeout;
41779612bbf4SKyle Evans } __packed; /* LTR_CAPABLE_API_S_VER_2 */
41789612bbf4SKyle Evans 
4179d4886179SRui Paulo /* Radio LP RX Energy Threshold measured in dBm */
4180d4886179SRui Paulo #define IWM_POWER_LPRX_RSSI_THRESHOLD	75
4181d4886179SRui Paulo #define IWM_POWER_LPRX_RSSI_THRESHOLD_MAX	94
4182d4886179SRui Paulo #define IWM_POWER_LPRX_RSSI_THRESHOLD_MIN	30
4183d4886179SRui Paulo 
4184d4886179SRui Paulo /**
4185355c1513SAdrian Chadd  * Masks for iwm_mac_power_cmd command flags
4186d4886179SRui Paulo  * @IWM_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
4187d4886179SRui Paulo  *		receiver and transmitter. '0' - does not allow.
4188d4886179SRui Paulo  * @IWM_POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
4189d4886179SRui Paulo  *		'1' Driver enables PM (use rest of parameters)
4190d4886179SRui Paulo  * @IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM,
4191d4886179SRui Paulo  *		'1' PM could sleep over DTIM till listen Interval.
4192d4886179SRui Paulo  * @IWM_POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all
4193d4886179SRui Paulo  *		access categories are both delivery and trigger enabled.
4194d4886179SRui Paulo  * @IWM_POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and
4195d4886179SRui Paulo  *		PBW Snoozing enabled
4196d4886179SRui Paulo  * @IWM_POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
4197d4886179SRui Paulo  * @IWM_POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
4198d4886179SRui Paulo  * @IWM_POWER_FLAGS_AP_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
4199d4886179SRui Paulo  *		detection enablement
4200d4886179SRui Paulo */
4201355c1513SAdrian Chadd #define IWM_POWER_FLAGS_POWER_SAVE_ENA_MSK		(1 << 0)
4202355c1513SAdrian Chadd #define IWM_POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK	(1 << 1)
4203355c1513SAdrian Chadd #define IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK		(1 << 2)
4204355c1513SAdrian Chadd #define IWM_POWER_FLAGS_SNOOZE_ENA_MSK			(1 << 5)
4205355c1513SAdrian Chadd #define IWM_POWER_FLAGS_BT_SCO_ENA			(1 << 8)
4206355c1513SAdrian Chadd #define IWM_POWER_FLAGS_ADVANCE_PM_ENA_MSK		(1 << 9)
4207355c1513SAdrian Chadd #define IWM_POWER_FLAGS_LPRX_ENA_MSK			(1 << 11)
4208355c1513SAdrian Chadd #define IWM_POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK	(1 << 12)
4209d4886179SRui Paulo 
4210d4886179SRui Paulo #define IWM_POWER_VEC_SIZE 5
4211d4886179SRui Paulo 
4212d4886179SRui Paulo /**
4213355c1513SAdrian Chadd  * Masks for device power command flags
4214355c1513SAdrian Chadd  * @IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK:
4215355c1513SAdrian Chadd  *   '1' Allow to save power by turning off receiver and transmitter.
4216355c1513SAdrian Chadd  *   '0' Do not allow. This flag should be always set to '1' unless
4217355c1513SAdrian Chadd  *       one needs to disable actual power down for debug purposes.
4218355c1513SAdrian Chadd  * @IWM_DEVICE_POWER_FLAGS_CAM_MSK:
4219355c1513SAdrian Chadd  *   '1' CAM (Continuous Active Mode) is set, power management is disabled.
4220355c1513SAdrian Chadd  *   '0' Power management is enabled, one of the power schemes is applied.
4221d4886179SRui Paulo  */
4222355c1513SAdrian Chadd #define IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK	(1 << 0)
4223355c1513SAdrian Chadd #define IWM_DEVICE_POWER_FLAGS_CAM_MSK			(1 << 13)
4224d4886179SRui Paulo 
4225d4886179SRui Paulo /**
4226d4886179SRui Paulo  * struct iwm_device_power_cmd - device wide power command.
4227355c1513SAdrian Chadd  * IWM_POWER_TABLE_CMD = 0x77 (command, has simple generic response)
4228d4886179SRui Paulo  *
4229d4886179SRui Paulo  * @flags:	Power table command flags from IWM_DEVICE_POWER_FLAGS_*
4230d4886179SRui Paulo  */
4231d4886179SRui Paulo struct iwm_device_power_cmd {
4232d4886179SRui Paulo 	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
4233d4886179SRui Paulo 	uint16_t flags;
4234d4886179SRui Paulo 	uint16_t reserved;
4235d4886179SRui Paulo } __packed;
4236d4886179SRui Paulo 
4237d4886179SRui Paulo /**
4238d4886179SRui Paulo  * struct iwm_mac_power_cmd - New power command containing uAPSD support
4239d4886179SRui Paulo  * IWM_MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
4240d4886179SRui Paulo  * @id_and_color:	MAC contex identifier
4241d4886179SRui Paulo  * @flags:		Power table command flags from POWER_FLAGS_*
4242d4886179SRui Paulo  * @keep_alive_seconds:	Keep alive period in seconds. Default - 25 sec.
4243d4886179SRui Paulo  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
4244d4886179SRui Paulo  *			set regardless of power scheme or current power state.
4245d4886179SRui Paulo  *			FW use this value also when PM is disabled.
4246d4886179SRui Paulo  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
4247d4886179SRui Paulo  *			PSM transition - legacy PM
4248d4886179SRui Paulo  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
4249d4886179SRui Paulo  *			PSM transition - legacy PM
4250d4886179SRui Paulo  * @sleep_interval:	not in use
4251d4886179SRui Paulo  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
4252d4886179SRui Paulo  *			is set. For example, if it is required to skip over
4253d4886179SRui Paulo  *			one DTIM, this value need to be set to 2 (DTIM periods).
4254d4886179SRui Paulo  * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
4255d4886179SRui Paulo  *			PSM transition - uAPSD
4256d4886179SRui Paulo  * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
4257d4886179SRui Paulo  *			PSM transition - uAPSD
4258d4886179SRui Paulo  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
4259d4886179SRui Paulo  *			Default: 80dbm
4260d4886179SRui Paulo  * @num_skip_dtim:	Number of DTIMs to skip if Skip over DTIM flag is set
4261d4886179SRui Paulo  * @snooze_interval:	Maximum time between attempts to retrieve buffered data
4262d4886179SRui Paulo  *			from the AP [msec]
4263d4886179SRui Paulo  * @snooze_window:	A window of time in which PBW snoozing insures that all
4264d4886179SRui Paulo  *			packets received. It is also the minimum time from last
4265d4886179SRui Paulo  *			received unicast RX packet, before client stops snoozing
4266d4886179SRui Paulo  *			for data. [msec]
4267d4886179SRui Paulo  * @snooze_step:	TBD
4268d4886179SRui Paulo  * @qndp_tid:		TID client shall use for uAPSD QNDP triggers
4269d4886179SRui Paulo  * @uapsd_ac_flags:	Set trigger-enabled and delivery-enabled indication for
4270d4886179SRui Paulo  *			each corresponding AC.
4271d4886179SRui Paulo  *			Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
4272d4886179SRui Paulo  * @uapsd_max_sp:	Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
4273d4886179SRui Paulo  *			values.
4274d4886179SRui Paulo  * @heavy_tx_thld_packets:	TX threshold measured in number of packets
4275d4886179SRui Paulo  * @heavy_rx_thld_packets:	RX threshold measured in number of packets
4276d4886179SRui Paulo  * @heavy_tx_thld_percentage:	TX threshold measured in load's percentage
4277d4886179SRui Paulo  * @heavy_rx_thld_percentage:	RX threshold measured in load's percentage
4278d4886179SRui Paulo  * @limited_ps_threshold:
4279d4886179SRui Paulo */
4280d4886179SRui Paulo struct iwm_mac_power_cmd {
4281d4886179SRui Paulo 	/* CONTEXT_DESC_API_T_VER_1 */
4282d4886179SRui Paulo 	uint32_t id_and_color;
4283d4886179SRui Paulo 
4284d4886179SRui Paulo 	/* CLIENT_PM_POWER_TABLE_S_VER_1 */
4285d4886179SRui Paulo 	uint16_t flags;
4286d4886179SRui Paulo 	uint16_t keep_alive_seconds;
4287d4886179SRui Paulo 	uint32_t rx_data_timeout;
4288d4886179SRui Paulo 	uint32_t tx_data_timeout;
4289d4886179SRui Paulo 	uint32_t rx_data_timeout_uapsd;
4290d4886179SRui Paulo 	uint32_t tx_data_timeout_uapsd;
4291d4886179SRui Paulo 	uint8_t lprx_rssi_threshold;
4292d4886179SRui Paulo 	uint8_t skip_dtim_periods;
4293d4886179SRui Paulo 	uint16_t snooze_interval;
4294d4886179SRui Paulo 	uint16_t snooze_window;
4295d4886179SRui Paulo 	uint8_t snooze_step;
4296d4886179SRui Paulo 	uint8_t qndp_tid;
4297d4886179SRui Paulo 	uint8_t uapsd_ac_flags;
4298d4886179SRui Paulo 	uint8_t uapsd_max_sp;
4299d4886179SRui Paulo 	uint8_t heavy_tx_thld_packets;
4300d4886179SRui Paulo 	uint8_t heavy_rx_thld_packets;
4301d4886179SRui Paulo 	uint8_t heavy_tx_thld_percentage;
4302d4886179SRui Paulo 	uint8_t heavy_rx_thld_percentage;
4303d4886179SRui Paulo 	uint8_t limited_ps_threshold;
4304d4886179SRui Paulo 	uint8_t reserved;
4305d4886179SRui Paulo } __packed;
4306d4886179SRui Paulo 
4307355c1513SAdrian Chadd #define IWM_DEFAULT_PS_TX_DATA_TIMEOUT      (100 * 1000)
4308355c1513SAdrian Chadd #define IWM_DEFAULT_PS_RX_DATA_TIMEOUT      (100 * 1000)
4309355c1513SAdrian Chadd 
4310d4886179SRui Paulo /*
4311d4886179SRui Paulo  * struct iwm_uapsd_misbehaving_ap_notif - FW sends this notification when
4312d4886179SRui Paulo  * associated AP is identified as improperly implementing uAPSD protocol.
4313d4886179SRui Paulo  * IWM_PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
4314d4886179SRui Paulo  * @sta_id: index of station in uCode's station table - associated AP ID in
4315d4886179SRui Paulo  *	    this context.
4316d4886179SRui Paulo  */
4317d4886179SRui Paulo struct iwm_uapsd_misbehaving_ap_notif {
4318d4886179SRui Paulo 	uint32_t sta_id;
4319d4886179SRui Paulo 	uint8_t mac_id;
4320d4886179SRui Paulo 	uint8_t reserved[3];
4321d4886179SRui Paulo } __packed;
4322d4886179SRui Paulo 
4323d4886179SRui Paulo /**
4324d4886179SRui Paulo  * struct iwm_beacon_filter_cmd
4325d4886179SRui Paulo  * IWM_REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
4326d4886179SRui Paulo  * @id_and_color: MAC contex identifier
4327d4886179SRui Paulo  * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
4328d4886179SRui Paulo  *      to driver if delta in Energy values calculated for this and last
4329d4886179SRui Paulo  *      passed beacon is greater than this threshold. Zero value means that
4330d4886179SRui Paulo  *      the Energy change is ignored for beacon filtering, and beacon will
4331d4886179SRui Paulo  *      not be forced to be sent to driver regardless of this delta. Typical
4332d4886179SRui Paulo  *      energy delta 5dB.
4333d4886179SRui Paulo  * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
4334d4886179SRui Paulo  *      Send beacon to driver if delta in Energy values calculated for this
4335d4886179SRui Paulo  *      and last passed beacon is greater than this threshold. Zero value
4336d4886179SRui Paulo  *      means that the Energy change is ignored for beacon filtering while in
4337d4886179SRui Paulo  *      Roaming state, typical energy delta 1dB.
4338d4886179SRui Paulo  * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
4339d4886179SRui Paulo  *      calculated for current beacon is less than the threshold, use
4340d4886179SRui Paulo  *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
4341d4886179SRui Paulo  *      Threshold. Typical energy threshold is -72dBm.
4342d4886179SRui Paulo  * @bf_temp_threshold: This threshold determines the type of temperature
4343d4886179SRui Paulo  *	filtering (Slow or Fast) that is selected (Units are in Celsuis):
4344d4886179SRui Paulo  *      If the current temperature is above this threshold - Fast filter
4345d4886179SRui Paulo  *	will be used, If the current temperature is below this threshold -
4346d4886179SRui Paulo  *	Slow filter will be used.
4347d4886179SRui Paulo  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
4348d4886179SRui Paulo  *      calculated for this and the last passed beacon is greater than this
4349d4886179SRui Paulo  *      threshold. Zero value means that the temperature change is ignored for
4350d4886179SRui Paulo  *      beacon filtering; beacons will not be  forced to be sent to driver
4351355c1513SAdrian Chadd  *      regardless of whether its temerature has been changed.
4352d4886179SRui Paulo  * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
4353d4886179SRui Paulo  *      calculated for this and the last passed beacon is greater than this
4354d4886179SRui Paulo  *      threshold. Zero value means that the temperature change is ignored for
4355d4886179SRui Paulo  *      beacon filtering; beacons will not be forced to be sent to driver
4356355c1513SAdrian Chadd  *      regardless of whether its temerature has been changed.
4357d4886179SRui Paulo  * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
4358355c1513SAdrian Chadd  * @bf_escape_timer: Send beacons to driver if no beacons were passed
4359d4886179SRui Paulo  *      for a specific period of time. Units: Beacons.
4360d4886179SRui Paulo  * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
4361d4886179SRui Paulo  *      for a longer period of time then this escape-timeout. Units: Beacons.
4362d4886179SRui Paulo  * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
4363d4886179SRui Paulo  */
4364d4886179SRui Paulo struct iwm_beacon_filter_cmd {
4365d4886179SRui Paulo 	uint32_t bf_energy_delta;
4366d4886179SRui Paulo 	uint32_t bf_roaming_energy_delta;
4367d4886179SRui Paulo 	uint32_t bf_roaming_state;
4368d4886179SRui Paulo 	uint32_t bf_temp_threshold;
4369d4886179SRui Paulo 	uint32_t bf_temp_fast_filter;
4370d4886179SRui Paulo 	uint32_t bf_temp_slow_filter;
4371d4886179SRui Paulo 	uint32_t bf_enable_beacon_filter;
4372d4886179SRui Paulo 	uint32_t bf_debug_flag;
4373d4886179SRui Paulo 	uint32_t bf_escape_timer;
4374d4886179SRui Paulo 	uint32_t ba_escape_timer;
4375d4886179SRui Paulo 	uint32_t ba_enable_beacon_abort;
4376d4886179SRui Paulo } __packed;
4377d4886179SRui Paulo 
4378d4886179SRui Paulo /* Beacon filtering and beacon abort */
4379d4886179SRui Paulo #define IWM_BF_ENERGY_DELTA_DEFAULT 5
4380d4886179SRui Paulo #define IWM_BF_ENERGY_DELTA_MAX 255
4381d4886179SRui Paulo #define IWM_BF_ENERGY_DELTA_MIN 0
4382d4886179SRui Paulo 
4383d4886179SRui Paulo #define IWM_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
4384d4886179SRui Paulo #define IWM_BF_ROAMING_ENERGY_DELTA_MAX 255
4385d4886179SRui Paulo #define IWM_BF_ROAMING_ENERGY_DELTA_MIN 0
4386d4886179SRui Paulo 
4387d4886179SRui Paulo #define IWM_BF_ROAMING_STATE_DEFAULT 72
4388d4886179SRui Paulo #define IWM_BF_ROAMING_STATE_MAX 255
4389d4886179SRui Paulo #define IWM_BF_ROAMING_STATE_MIN 0
4390d4886179SRui Paulo 
4391d4886179SRui Paulo #define IWM_BF_TEMP_THRESHOLD_DEFAULT 112
4392d4886179SRui Paulo #define IWM_BF_TEMP_THRESHOLD_MAX 255
4393d4886179SRui Paulo #define IWM_BF_TEMP_THRESHOLD_MIN 0
4394d4886179SRui Paulo 
4395d4886179SRui Paulo #define IWM_BF_TEMP_FAST_FILTER_DEFAULT 1
4396d4886179SRui Paulo #define IWM_BF_TEMP_FAST_FILTER_MAX 255
4397d4886179SRui Paulo #define IWM_BF_TEMP_FAST_FILTER_MIN 0
4398d4886179SRui Paulo 
4399d4886179SRui Paulo #define IWM_BF_TEMP_SLOW_FILTER_DEFAULT 5
4400d4886179SRui Paulo #define IWM_BF_TEMP_SLOW_FILTER_MAX 255
4401d4886179SRui Paulo #define IWM_BF_TEMP_SLOW_FILTER_MIN 0
4402d4886179SRui Paulo 
4403d4886179SRui Paulo #define IWM_BF_ENABLE_BEACON_FILTER_DEFAULT 1
4404d4886179SRui Paulo 
4405d4886179SRui Paulo #define IWM_BF_DEBUG_FLAG_DEFAULT 0
4406d4886179SRui Paulo 
4407d4886179SRui Paulo #define IWM_BF_ESCAPE_TIMER_DEFAULT 50
4408d4886179SRui Paulo #define IWM_BF_ESCAPE_TIMER_MAX 1024
4409d4886179SRui Paulo #define IWM_BF_ESCAPE_TIMER_MIN 0
4410d4886179SRui Paulo 
4411d4886179SRui Paulo #define IWM_BA_ESCAPE_TIMER_DEFAULT 6
4412d4886179SRui Paulo #define IWM_BA_ESCAPE_TIMER_D3 9
4413d4886179SRui Paulo #define IWM_BA_ESCAPE_TIMER_MAX 1024
4414d4886179SRui Paulo #define IWM_BA_ESCAPE_TIMER_MIN 0
4415d4886179SRui Paulo 
4416d4886179SRui Paulo #define IWM_BA_ENABLE_BEACON_ABORT_DEFAULT 1
4417d4886179SRui Paulo 
4418d4886179SRui Paulo #define IWM_BF_CMD_CONFIG_DEFAULTS					     \
4419d4886179SRui Paulo 	.bf_energy_delta = htole32(IWM_BF_ENERGY_DELTA_DEFAULT),	     \
4420d4886179SRui Paulo 	.bf_roaming_energy_delta =					     \
4421d4886179SRui Paulo 		htole32(IWM_BF_ROAMING_ENERGY_DELTA_DEFAULT),	     \
4422d4886179SRui Paulo 	.bf_roaming_state = htole32(IWM_BF_ROAMING_STATE_DEFAULT),	     \
4423d4886179SRui Paulo 	.bf_temp_threshold = htole32(IWM_BF_TEMP_THRESHOLD_DEFAULT),     \
4424d4886179SRui Paulo 	.bf_temp_fast_filter = htole32(IWM_BF_TEMP_FAST_FILTER_DEFAULT), \
4425d4886179SRui Paulo 	.bf_temp_slow_filter = htole32(IWM_BF_TEMP_SLOW_FILTER_DEFAULT), \
4426d4886179SRui Paulo 	.bf_debug_flag = htole32(IWM_BF_DEBUG_FLAG_DEFAULT),	     \
4427d4886179SRui Paulo 	.bf_escape_timer = htole32(IWM_BF_ESCAPE_TIMER_DEFAULT),	     \
4428d4886179SRui Paulo 	.ba_escape_timer = htole32(IWM_BA_ESCAPE_TIMER_DEFAULT)
4429d4886179SRui Paulo 
4430d4886179SRui Paulo /*
4431d4886179SRui Paulo  * END mvm/fw-api-power.h
4432d4886179SRui Paulo  */
4433d4886179SRui Paulo 
4434d4886179SRui Paulo /*
4435d4886179SRui Paulo  * BEGIN mvm/fw-api-rs.h
4436d4886179SRui Paulo  */
4437d4886179SRui Paulo 
4438355c1513SAdrian Chadd 
4439355c1513SAdrian Chadd /* uCode API values for HT/VHT bit rates */
4440355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_0_PLCP	0
4441355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_1_PLCP	1
4442355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_2_PLCP	2
4443355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_3_PLCP	3
4444355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_4_PLCP	4
4445355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_5_PLCP	5
4446355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_6_PLCP	6
4447355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_7_PLCP	7
4448355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_8_PLCP	0x8
4449355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_9_PLCP	0x9
4450355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_10_PLCP	0xA
4451355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_11_PLCP	0xB
4452355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_12_PLCP	0xC
4453355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_13_PLCP	0xD
4454355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_14_PLCP	0xE
4455355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_15_PLCP	0xF
4456355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_0_PLCP	0
4457355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_1_PLCP	1
4458355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_2_PLCP	2
4459355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_3_PLCP	3
4460355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_4_PLCP	4
4461355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_5_PLCP	5
4462355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_6_PLCP	6
4463355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_7_PLCP	7
4464355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_8_PLCP	8
4465355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_9_PLCP	9
4466355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_0_PLCP	0x10
4467355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_1_PLCP	0x11
4468355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_2_PLCP	0x12
4469355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_3_PLCP	0x13
4470355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_4_PLCP	0x14
4471355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_5_PLCP	0x15
4472355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_6_PLCP	0x16
4473355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_7_PLCP	0x17
4474355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_8_PLCP	0x18
4475355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_9_PLCP	0x19
4476355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_INV_PLCP	0x20
4477355c1513SAdrian Chadd #define IWM_RATE_HT_MIMO2_MCS_INV_PLCP	IWM_RATE_HT_SISO_MCS_INV_PLCP
4478355c1513SAdrian Chadd #define IWM_RATE_VHT_SISO_MCS_INV_PLCP	IWM_RATE_HT_SISO_MCS_INV_PLCP
4479355c1513SAdrian Chadd #define IWM_RATE_VHT_MIMO2_MCS_INV_PLCP	IWM_RATE_HT_SISO_MCS_INV_PLCP
4480355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_8_PLCP	IWM_RATE_HT_SISO_MCS_INV_PLCP
4481355c1513SAdrian Chadd #define IWM_RATE_HT_SISO_MCS_9_PLCP	IWM_RATE_HT_SISO_MCS_INV_PLCP
4482355c1513SAdrian Chadd 
4483d4886179SRui Paulo /*
4484*31a8b978SAdrian Chadd  * These serve as indexes into struct iwm_rate iwm_rates[IWM_RIDX_MAX].
4485d4886179SRui Paulo  */
4486d4886179SRui Paulo enum {
4487d4886179SRui Paulo 	IWM_RATE_1M_INDEX = 0,
4488d4886179SRui Paulo 	IWM_FIRST_CCK_RATE = IWM_RATE_1M_INDEX,
4489d4886179SRui Paulo 	IWM_RATE_2M_INDEX,
4490d4886179SRui Paulo 	IWM_RATE_5M_INDEX,
4491d4886179SRui Paulo 	IWM_RATE_11M_INDEX,
4492d4886179SRui Paulo 	IWM_LAST_CCK_RATE = IWM_RATE_11M_INDEX,
4493d4886179SRui Paulo 	IWM_RATE_6M_INDEX,
4494d4886179SRui Paulo 	IWM_FIRST_OFDM_RATE = IWM_RATE_6M_INDEX,
4495d4886179SRui Paulo 	IWM_RATE_MCS_0_INDEX = IWM_RATE_6M_INDEX,
4496d4886179SRui Paulo 	IWM_FIRST_HT_RATE = IWM_RATE_MCS_0_INDEX,
4497d4886179SRui Paulo 	IWM_FIRST_VHT_RATE = IWM_RATE_MCS_0_INDEX,
4498d4886179SRui Paulo 	IWM_RATE_9M_INDEX,
4499d4886179SRui Paulo 	IWM_RATE_12M_INDEX,
4500d4886179SRui Paulo 	IWM_RATE_MCS_1_INDEX = IWM_RATE_12M_INDEX,
4501*31a8b978SAdrian Chadd 	IWM_RATE_MCS_8_INDEX,
4502*31a8b978SAdrian Chadd 	IWM_FIRST_HT_MIMO2_RATE = IWM_RATE_MCS_8_INDEX,
4503d4886179SRui Paulo 	IWM_RATE_18M_INDEX,
4504d4886179SRui Paulo 	IWM_RATE_MCS_2_INDEX = IWM_RATE_18M_INDEX,
4505d4886179SRui Paulo 	IWM_RATE_24M_INDEX,
4506d4886179SRui Paulo 	IWM_RATE_MCS_3_INDEX = IWM_RATE_24M_INDEX,
4507*31a8b978SAdrian Chadd 	IWM_RATE_MCS_9_INDEX,
4508d4886179SRui Paulo 	IWM_RATE_36M_INDEX,
4509d4886179SRui Paulo 	IWM_RATE_MCS_4_INDEX = IWM_RATE_36M_INDEX,
4510*31a8b978SAdrian Chadd 	IWM_RATE_MCS_10_INDEX,
4511d4886179SRui Paulo 	IWM_RATE_48M_INDEX,
4512d4886179SRui Paulo 	IWM_RATE_MCS_5_INDEX = IWM_RATE_48M_INDEX,
4513*31a8b978SAdrian Chadd 	IWM_RATE_MCS_11_INDEX,
4514d4886179SRui Paulo 	IWM_RATE_54M_INDEX,
4515d4886179SRui Paulo 	IWM_RATE_MCS_6_INDEX = IWM_RATE_54M_INDEX,
4516d4886179SRui Paulo 	IWM_LAST_NON_HT_RATE = IWM_RATE_54M_INDEX,
4517*31a8b978SAdrian Chadd 	IWM_RATE_MCS_7_INDEX,
4518*31a8b978SAdrian Chadd 	IWM_LAST_HT_SISO_RATE = IWM_RATE_MCS_7_INDEX,
4519*31a8b978SAdrian Chadd 	IWM_RATE_MCS_12_INDEX,
4520*31a8b978SAdrian Chadd 	IWM_RATE_MCS_13_INDEX,
4521*31a8b978SAdrian Chadd 	IWM_RATE_MCS_14_INDEX,
4522*31a8b978SAdrian Chadd 	IWM_RATE_MCS_15_INDEX,
4523*31a8b978SAdrian Chadd 	IWM_LAST_HT_RATE = IWM_RATE_MCS_15_INDEX,
4524d4886179SRui Paulo 	IWM_LAST_VHT_RATE = IWM_RATE_MCS_9_INDEX,
4525d4886179SRui Paulo 	IWM_RATE_COUNT_LEGACY = IWM_LAST_NON_HT_RATE + 1,
4526*31a8b978SAdrian Chadd 	IWM_RATE_COUNT = IWM_LAST_HT_RATE + 1,
4527d4886179SRui Paulo };
4528d4886179SRui Paulo 
4529d4886179SRui Paulo #define IWM_RATE_BIT_MSK(r) (1 << (IWM_RATE_##r##M_INDEX))
4530d4886179SRui Paulo 
4531d4886179SRui Paulo /* fw API values for legacy bit rates, both OFDM and CCK */
4532355c1513SAdrian Chadd #define IWM_RATE_6M_PLCP 	13
4533355c1513SAdrian Chadd #define IWM_RATE_9M_PLCP 	15
4534355c1513SAdrian Chadd #define IWM_RATE_12M_PLCP	5
4535355c1513SAdrian Chadd #define IWM_RATE_18M_PLCP	7
4536355c1513SAdrian Chadd #define IWM_RATE_24M_PLCP	9
4537355c1513SAdrian Chadd #define IWM_RATE_36M_PLCP	11
4538355c1513SAdrian Chadd #define IWM_RATE_48M_PLCP	1
4539355c1513SAdrian Chadd #define IWM_RATE_54M_PLCP	3
4540355c1513SAdrian Chadd #define IWM_RATE_1M_PLCP 	10
4541355c1513SAdrian Chadd #define IWM_RATE_2M_PLCP 	20
4542355c1513SAdrian Chadd #define IWM_RATE_5M_PLCP 	55
4543355c1513SAdrian Chadd #define IWM_RATE_11M_PLCP	110
4544355c1513SAdrian Chadd #define IWM_RATE_INVM_PLCP	0xff
4545d4886179SRui Paulo 
4546d4886179SRui Paulo /*
4547d4886179SRui Paulo  * rate_n_flags bit fields
4548d4886179SRui Paulo  *
4549d4886179SRui Paulo  * The 32-bit value has different layouts in the low 8 bites depending on the
4550d4886179SRui Paulo  * format. There are three formats, HT, VHT and legacy (11abg, with subformats
4551d4886179SRui Paulo  * for CCK and OFDM).
4552d4886179SRui Paulo  *
4553d4886179SRui Paulo  * High-throughput (HT) rate format
4554d4886179SRui Paulo  *	bit 8 is 1, bit 26 is 0, bit 9 is 0 (OFDM)
4555d4886179SRui Paulo  * Very High-throughput (VHT) rate format
4556d4886179SRui Paulo  *	bit 8 is 0, bit 26 is 1, bit 9 is 0 (OFDM)
4557d4886179SRui Paulo  * Legacy OFDM rate format for bits 7:0
4558d4886179SRui Paulo  *	bit 8 is 0, bit 26 is 0, bit 9 is 0 (OFDM)
4559d4886179SRui Paulo  * Legacy CCK rate format for bits 7:0:
4560d4886179SRui Paulo  *	bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK)
4561d4886179SRui Paulo  */
4562d4886179SRui Paulo 
4563d4886179SRui Paulo /* Bit 8: (1) HT format, (0) legacy or VHT format */
4564d4886179SRui Paulo #define IWM_RATE_MCS_HT_POS 8
4565d4886179SRui Paulo #define IWM_RATE_MCS_HT_MSK (1 << IWM_RATE_MCS_HT_POS)
4566d4886179SRui Paulo 
4567d4886179SRui Paulo /* Bit 9: (1) CCK, (0) OFDM.  HT (bit 8) must be "0" for this bit to be valid */
4568d4886179SRui Paulo #define IWM_RATE_MCS_CCK_POS 9
4569d4886179SRui Paulo #define IWM_RATE_MCS_CCK_MSK (1 << IWM_RATE_MCS_CCK_POS)
4570d4886179SRui Paulo 
4571d4886179SRui Paulo /* Bit 26: (1) VHT format, (0) legacy format in bits 8:0 */
4572d4886179SRui Paulo #define IWM_RATE_MCS_VHT_POS 26
4573d4886179SRui Paulo #define IWM_RATE_MCS_VHT_MSK (1 << IWM_RATE_MCS_VHT_POS)
4574d4886179SRui Paulo 
4575355c1513SAdrian Chadd /* Bit 31: (1) RTS (2) CTS */
4576355c1513SAdrian Chadd #define IWM_RATE_MCS_RTS_REQUIRED_POS 30
4577355c1513SAdrian Chadd #define IWM_RATE_MCS_RTS_REQUIRED_MSK (1 << IWM_RATE_MCS_RTS_REQUIRED_POS)
4578d4886179SRui Paulo 
4579d4886179SRui Paulo /*
4580d4886179SRui Paulo  * High-throughput (HT) rate format for bits 7:0
4581d4886179SRui Paulo  *
4582d4886179SRui Paulo  *  2-0:  MCS rate base
4583d4886179SRui Paulo  *        0)   6 Mbps
4584d4886179SRui Paulo  *        1)  12 Mbps
4585d4886179SRui Paulo  *        2)  18 Mbps
4586d4886179SRui Paulo  *        3)  24 Mbps
4587d4886179SRui Paulo  *        4)  36 Mbps
4588d4886179SRui Paulo  *        5)  48 Mbps
4589d4886179SRui Paulo  *        6)  54 Mbps
4590d4886179SRui Paulo  *        7)  60 Mbps
4591d4886179SRui Paulo  *  4-3:  0)  Single stream (SISO)
4592d4886179SRui Paulo  *        1)  Dual stream (MIMO)
4593d4886179SRui Paulo  *        2)  Triple stream (MIMO)
4594d4886179SRui Paulo  *    5:  Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
4595d4886179SRui Paulo  *  (bits 7-6 are zero)
4596d4886179SRui Paulo  *
4597d4886179SRui Paulo  * Together the low 5 bits work out to the MCS index because we don't
4598d4886179SRui Paulo  * support MCSes above 15/23, and 0-7 have one stream, 8-15 have two
4599d4886179SRui Paulo  * streams and 16-23 have three streams. We could also support MCS 32
4600d4886179SRui Paulo  * which is the duplicate 20 MHz MCS (bit 5 set, all others zero.)
4601d4886179SRui Paulo  */
4602d4886179SRui Paulo #define IWM_RATE_HT_MCS_RATE_CODE_MSK	0x7
4603d4886179SRui Paulo #define IWM_RATE_HT_MCS_NSS_POS             3
4604d4886179SRui Paulo #define IWM_RATE_HT_MCS_NSS_MSK             (3 << IWM_RATE_HT_MCS_NSS_POS)
4605d4886179SRui Paulo 
4606d4886179SRui Paulo /* Bit 10: (1) Use Green Field preamble */
4607d4886179SRui Paulo #define IWM_RATE_HT_MCS_GF_POS		10
4608d4886179SRui Paulo #define IWM_RATE_HT_MCS_GF_MSK		(1 << IWM_RATE_HT_MCS_GF_POS)
4609d4886179SRui Paulo 
4610d4886179SRui Paulo #define IWM_RATE_HT_MCS_INDEX_MSK		0x3f
4611d4886179SRui Paulo 
4612d4886179SRui Paulo /*
4613d4886179SRui Paulo  * Very High-throughput (VHT) rate format for bits 7:0
4614d4886179SRui Paulo  *
4615d4886179SRui Paulo  *  3-0:  VHT MCS (0-9)
4616d4886179SRui Paulo  *  5-4:  number of streams - 1:
4617d4886179SRui Paulo  *        0)  Single stream (SISO)
4618d4886179SRui Paulo  *        1)  Dual stream (MIMO)
4619d4886179SRui Paulo  *        2)  Triple stream (MIMO)
4620d4886179SRui Paulo  */
4621d4886179SRui Paulo 
4622d4886179SRui Paulo /* Bit 4-5: (0) SISO, (1) MIMO2 (2) MIMO3 */
4623d4886179SRui Paulo #define IWM_RATE_VHT_MCS_RATE_CODE_MSK	0xf
4624d4886179SRui Paulo #define IWM_RATE_VHT_MCS_NSS_POS		4
4625d4886179SRui Paulo #define IWM_RATE_VHT_MCS_NSS_MSK		(3 << IWM_RATE_VHT_MCS_NSS_POS)
4626d4886179SRui Paulo 
4627d4886179SRui Paulo /*
4628d4886179SRui Paulo  * Legacy OFDM rate format for bits 7:0
4629d4886179SRui Paulo  *
4630d4886179SRui Paulo  *  3-0:  0xD)   6 Mbps
4631d4886179SRui Paulo  *        0xF)   9 Mbps
4632d4886179SRui Paulo  *        0x5)  12 Mbps
4633d4886179SRui Paulo  *        0x7)  18 Mbps
4634d4886179SRui Paulo  *        0x9)  24 Mbps
4635d4886179SRui Paulo  *        0xB)  36 Mbps
4636d4886179SRui Paulo  *        0x1)  48 Mbps
4637d4886179SRui Paulo  *        0x3)  54 Mbps
4638d4886179SRui Paulo  * (bits 7-4 are 0)
4639d4886179SRui Paulo  *
4640d4886179SRui Paulo  * Legacy CCK rate format for bits 7:0:
4641d4886179SRui Paulo  * bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK):
4642d4886179SRui Paulo  *
4643d4886179SRui Paulo  *  6-0:   10)  1 Mbps
4644d4886179SRui Paulo  *         20)  2 Mbps
4645d4886179SRui Paulo  *         55)  5.5 Mbps
4646d4886179SRui Paulo  *        110)  11 Mbps
4647d4886179SRui Paulo  * (bit 7 is 0)
4648d4886179SRui Paulo  */
4649d4886179SRui Paulo #define IWM_RATE_LEGACY_RATE_MSK 0xff
4650d4886179SRui Paulo 
4651d4886179SRui Paulo 
4652d4886179SRui Paulo /*
4653d4886179SRui Paulo  * Bit 11-12: (0) 20MHz, (1) 40MHz, (2) 80MHz, (3) 160MHz
4654d4886179SRui Paulo  * 0 and 1 are valid for HT and VHT, 2 and 3 only for VHT
4655d4886179SRui Paulo  */
4656d4886179SRui Paulo #define IWM_RATE_MCS_CHAN_WIDTH_POS		11
4657d4886179SRui Paulo #define IWM_RATE_MCS_CHAN_WIDTH_MSK		(3 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4658d4886179SRui Paulo #define IWM_RATE_MCS_CHAN_WIDTH_20		(0 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4659d4886179SRui Paulo #define IWM_RATE_MCS_CHAN_WIDTH_40		(1 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4660d4886179SRui Paulo #define IWM_RATE_MCS_CHAN_WIDTH_80		(2 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4661d4886179SRui Paulo #define IWM_RATE_MCS_CHAN_WIDTH_160		(3 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4662d4886179SRui Paulo 
4663d4886179SRui Paulo /* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
4664d4886179SRui Paulo #define IWM_RATE_MCS_SGI_POS		13
4665d4886179SRui Paulo #define IWM_RATE_MCS_SGI_MSK		(1 << IWM_RATE_MCS_SGI_POS)
4666d4886179SRui Paulo 
4667d4886179SRui Paulo /* Bit 14-16: Antenna selection (1) Ant A, (2) Ant B, (4) Ant C */
4668d4886179SRui Paulo #define IWM_RATE_MCS_ANT_POS		14
4669d4886179SRui Paulo #define IWM_RATE_MCS_ANT_A_MSK		(1 << IWM_RATE_MCS_ANT_POS)
4670d4886179SRui Paulo #define IWM_RATE_MCS_ANT_B_MSK		(2 << IWM_RATE_MCS_ANT_POS)
4671d4886179SRui Paulo #define IWM_RATE_MCS_ANT_C_MSK		(4 << IWM_RATE_MCS_ANT_POS)
4672d4886179SRui Paulo #define IWM_RATE_MCS_ANT_AB_MSK		(IWM_RATE_MCS_ANT_A_MSK | \
4673d4886179SRui Paulo 					 IWM_RATE_MCS_ANT_B_MSK)
4674d4886179SRui Paulo #define IWM_RATE_MCS_ANT_ABC_MSK		(IWM_RATE_MCS_ANT_AB_MSK | \
4675d4886179SRui Paulo 					 IWM_RATE_MCS_ANT_C_MSK)
4676d4886179SRui Paulo #define IWM_RATE_MCS_ANT_MSK		IWM_RATE_MCS_ANT_ABC_MSK
4677d4886179SRui Paulo #define IWM_RATE_MCS_ANT_NUM 3
4678d4886179SRui Paulo 
4679d4886179SRui Paulo /* Bit 17-18: (0) SS, (1) SS*2 */
4680d4886179SRui Paulo #define IWM_RATE_MCS_STBC_POS		17
4681d4886179SRui Paulo #define IWM_RATE_MCS_STBC_MSK		(1 << IWM_RATE_MCS_STBC_POS)
4682d4886179SRui Paulo 
4683d4886179SRui Paulo /* Bit 19: (0) Beamforming is off, (1) Beamforming is on */
4684d4886179SRui Paulo #define IWM_RATE_MCS_BF_POS			19
4685d4886179SRui Paulo #define IWM_RATE_MCS_BF_MSK			(1 << IWM_RATE_MCS_BF_POS)
4686d4886179SRui Paulo 
4687d4886179SRui Paulo /* Bit 20: (0) ZLF is off, (1) ZLF is on */
4688d4886179SRui Paulo #define IWM_RATE_MCS_ZLF_POS		20
4689d4886179SRui Paulo #define IWM_RATE_MCS_ZLF_MSK		(1 << IWM_RATE_MCS_ZLF_POS)
4690d4886179SRui Paulo 
4691d4886179SRui Paulo /* Bit 24-25: (0) 20MHz (no dup), (1) 2x20MHz, (2) 4x20MHz, 3 8x20MHz */
4692d4886179SRui Paulo #define IWM_RATE_MCS_DUP_POS		24
4693d4886179SRui Paulo #define IWM_RATE_MCS_DUP_MSK		(3 << IWM_RATE_MCS_DUP_POS)
4694d4886179SRui Paulo 
4695d4886179SRui Paulo /* Bit 27: (1) LDPC enabled, (0) LDPC disabled */
4696d4886179SRui Paulo #define IWM_RATE_MCS_LDPC_POS		27
4697d4886179SRui Paulo #define IWM_RATE_MCS_LDPC_MSK		(1 << IWM_RATE_MCS_LDPC_POS)
4698d4886179SRui Paulo 
4699d4886179SRui Paulo 
4700d4886179SRui Paulo /* Link Quality definitions */
4701d4886179SRui Paulo 
4702d4886179SRui Paulo /* # entries in rate scale table to support Tx retries */
4703d4886179SRui Paulo #define  IWM_LQ_MAX_RETRY_NUM 16
4704d4886179SRui Paulo 
4705d4886179SRui Paulo /* Link quality command flags bit fields */
4706d4886179SRui Paulo 
4707d4886179SRui Paulo /* Bit 0: (0) Don't use RTS (1) Use RTS */
4708d4886179SRui Paulo #define IWM_LQ_FLAG_USE_RTS_POS             0
4709d4886179SRui Paulo #define IWM_LQ_FLAG_USE_RTS_MSK	        (1 << IWM_LQ_FLAG_USE_RTS_POS)
4710d4886179SRui Paulo 
4711d4886179SRui Paulo /* Bit 1-3: LQ command color. Used to match responses to LQ commands */
4712d4886179SRui Paulo #define IWM_LQ_FLAG_COLOR_POS               1
4713d4886179SRui Paulo #define IWM_LQ_FLAG_COLOR_MSK               (7 << IWM_LQ_FLAG_COLOR_POS)
4714d4886179SRui Paulo 
4715d4886179SRui Paulo /* Bit 4-5: Tx RTS BW Signalling
4716d4886179SRui Paulo  * (0) No RTS BW signalling
4717d4886179SRui Paulo  * (1) Static BW signalling
4718d4886179SRui Paulo  * (2) Dynamic BW signalling
4719d4886179SRui Paulo  */
4720d4886179SRui Paulo #define IWM_LQ_FLAG_RTS_BW_SIG_POS          4
4721d4886179SRui Paulo #define IWM_LQ_FLAG_RTS_BW_SIG_NONE         (0 << IWM_LQ_FLAG_RTS_BW_SIG_POS)
4722d4886179SRui Paulo #define IWM_LQ_FLAG_RTS_BW_SIG_STATIC       (1 << IWM_LQ_FLAG_RTS_BW_SIG_POS)
4723d4886179SRui Paulo #define IWM_LQ_FLAG_RTS_BW_SIG_DYNAMIC      (2 << IWM_LQ_FLAG_RTS_BW_SIG_POS)
4724d4886179SRui Paulo 
4725d4886179SRui Paulo /* Bit 6: (0) No dynamic BW selection (1) Allow dynamic BW selection
4726d4886179SRui Paulo  * Dyanmic BW selection allows Tx with narrower BW then requested in rates
4727d4886179SRui Paulo  */
4728d4886179SRui Paulo #define IWM_LQ_FLAG_DYNAMIC_BW_POS          6
4729d4886179SRui Paulo #define IWM_LQ_FLAG_DYNAMIC_BW_MSK          (1 << IWM_LQ_FLAG_DYNAMIC_BW_POS)
4730d4886179SRui Paulo 
4731355c1513SAdrian Chadd /* Antenna flags. */
4732355c1513SAdrian Chadd #define IWM_ANT_A	(1 << 0)
4733355c1513SAdrian Chadd #define IWM_ANT_B	(1 << 1)
4734355c1513SAdrian Chadd #define IWM_ANT_C	(1 << 2)
4735355c1513SAdrian Chadd /* Shortcuts. */
4736355c1513SAdrian Chadd #define IWM_ANT_AB	(IWM_ANT_A | IWM_ANT_B)
4737355c1513SAdrian Chadd #define IWM_ANT_BC	(IWM_ANT_B | IWM_ANT_C)
4738355c1513SAdrian Chadd #define IWM_ANT_ABC	(IWM_ANT_A | IWM_ANT_B | IWM_ANT_C)
473940fea7fdSAdrian Chadd 
4740d4886179SRui Paulo /**
4741d4886179SRui Paulo  * struct iwm_lq_cmd - link quality command
4742d4886179SRui Paulo  * @sta_id: station to update
4743d4886179SRui Paulo  * @control: not used
4744d4886179SRui Paulo  * @flags: combination of IWM_LQ_FLAG_*
4745d4886179SRui Paulo  * @mimo_delim: the first SISO index in rs_table, which separates MIMO
4746d4886179SRui Paulo  *	and SISO rates
4747d4886179SRui Paulo  * @single_stream_ant_msk: best antenna for SISO (can be dual in CDD).
4748355c1513SAdrian Chadd  *	Should be IWM_ANT_[ABC]
4749355c1513SAdrian Chadd  * @dual_stream_ant_msk: best antennas for MIMO, combination of IWM_ANT_[ABC]
4750d4886179SRui Paulo  * @initial_rate_index: first index from rs_table per AC category
4751d4886179SRui Paulo  * @agg_time_limit: aggregation max time threshold in usec/100, meaning
4752d4886179SRui Paulo  *	value of 100 is one usec. Range is 100 to 8000
4753d4886179SRui Paulo  * @agg_disable_start_th: try-count threshold for starting aggregation.
4754d4886179SRui Paulo  *	If a frame has higher try-count, it should not be selected for
4755d4886179SRui Paulo  *	starting an aggregation sequence.
4756d4886179SRui Paulo  * @agg_frame_cnt_limit: max frame count in an aggregation.
4757d4886179SRui Paulo  *	0: no limit
4758d4886179SRui Paulo  *	1: no aggregation (one frame per aggregation)
4759d4886179SRui Paulo  *	2 - 0x3f: maximal number of frames (up to 3f == 63)
4760d4886179SRui Paulo  * @rs_table: array of rates for each TX try, each is rate_n_flags,
4761d4886179SRui Paulo  *	meaning it is a combination of IWM_RATE_MCS_* and IWM_RATE_*_PLCP
4762355c1513SAdrian Chadd  * @bf_params: beam forming params, currently not used
4763d4886179SRui Paulo  */
4764d4886179SRui Paulo struct iwm_lq_cmd {
4765d4886179SRui Paulo 	uint8_t sta_id;
4766355c1513SAdrian Chadd 	uint8_t reserved1;
4767d4886179SRui Paulo 	uint16_t control;
4768d4886179SRui Paulo 	/* LINK_QUAL_GENERAL_PARAMS_API_S_VER_1 */
4769d4886179SRui Paulo 	uint8_t flags;
4770d4886179SRui Paulo 	uint8_t mimo_delim;
4771d4886179SRui Paulo 	uint8_t single_stream_ant_msk;
4772d4886179SRui Paulo 	uint8_t dual_stream_ant_msk;
4773d4886179SRui Paulo 	uint8_t initial_rate_index[IWM_AC_NUM];
4774d4886179SRui Paulo 	/* LINK_QUAL_AGG_PARAMS_API_S_VER_1 */
4775d4886179SRui Paulo 	uint16_t agg_time_limit;
4776d4886179SRui Paulo 	uint8_t agg_disable_start_th;
4777d4886179SRui Paulo 	uint8_t agg_frame_cnt_limit;
4778d4886179SRui Paulo 	uint32_t reserved2;
4779d4886179SRui Paulo 	uint32_t rs_table[IWM_LQ_MAX_RETRY_NUM];
4780355c1513SAdrian Chadd 	uint32_t bf_params;
4781d4886179SRui Paulo }; /* LINK_QUALITY_CMD_API_S_VER_1 */
4782d4886179SRui Paulo 
4783d4886179SRui Paulo /*
4784d4886179SRui Paulo  * END mvm/fw-api-rs.h
4785d4886179SRui Paulo  */
4786d4886179SRui Paulo 
4787d4886179SRui Paulo /*
4788d4886179SRui Paulo  * BEGIN mvm/fw-api-tx.h
4789d4886179SRui Paulo  */
4790d4886179SRui Paulo 
4791d4886179SRui Paulo /**
4792355c1513SAdrian Chadd  * bitmasks for tx_flags in TX command
4793d4886179SRui Paulo  * @IWM_TX_CMD_FLG_PROT_REQUIRE: use RTS or CTS-to-self to protect the frame
4794d4886179SRui Paulo  * @IWM_TX_CMD_FLG_ACK: expect ACK from receiving station
4795d4886179SRui Paulo  * @IWM_TX_CMD_FLG_STA_RATE: use RS table with initial index from the TX command.
4796d4886179SRui Paulo  *	Otherwise, use rate_n_flags from the TX command
4797d4886179SRui Paulo  * @IWM_TX_CMD_FLG_BA: this frame is a block ack
4798d4886179SRui Paulo  * @IWM_TX_CMD_FLG_BAR: this frame is a BA request, immediate BAR is expected
4799d4886179SRui Paulo  *	Must set IWM_TX_CMD_FLG_ACK with this flag.
4800d4886179SRui Paulo  * @IWM_TX_CMD_FLG_TXOP_PROT: protect frame with full TXOP protection
4801d4886179SRui Paulo  * @IWM_TX_CMD_FLG_VHT_NDPA: mark frame is NDPA for VHT beamformer sequence
4802d4886179SRui Paulo  * @IWM_TX_CMD_FLG_HT_NDPA: mark frame is NDPA for HT beamformer sequence
4803d4886179SRui Paulo  * @IWM_TX_CMD_FLG_CSI_FDBK2HOST: mark to send feedback to host (only if good CRC)
4804d4886179SRui Paulo  * @IWM_TX_CMD_FLG_BT_DIS: disable BT priority for this frame
4805d4886179SRui Paulo  * @IWM_TX_CMD_FLG_SEQ_CTL: set if FW should override the sequence control.
4806d4886179SRui Paulo  *	Should be set for mgmt, non-QOS data, mcast, bcast and in scan command
4807d4886179SRui Paulo  * @IWM_TX_CMD_FLG_MORE_FRAG: this frame is non-last MPDU
4808d4886179SRui Paulo  * @IWM_TX_CMD_FLG_NEXT_FRAME: this frame includes information of the next frame
4809d4886179SRui Paulo  * @IWM_TX_CMD_FLG_TSF: FW should calculate and insert TSF in the frame
4810d4886179SRui Paulo  *	Should be set for beacons and probe responses
4811d4886179SRui Paulo  * @IWM_TX_CMD_FLG_CALIB: activate PA TX power calibrations
4812d4886179SRui Paulo  * @IWM_TX_CMD_FLG_KEEP_SEQ_CTL: if seq_ctl is set, don't increase inner seq count
4813d4886179SRui Paulo  * @IWM_TX_CMD_FLG_AGG_START: allow this frame to start aggregation
4814d4886179SRui Paulo  * @IWM_TX_CMD_FLG_MH_PAD: driver inserted 2 byte padding after MAC header.
4815d4886179SRui Paulo  *	Should be set for 26/30 length MAC headers
4816d4886179SRui Paulo  * @IWM_TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW
4817355c1513SAdrian Chadd  * @IWM_TX_CMD_FLG_CCMP_AGG: this frame uses CCMP for aggregation acceleration
4818d4886179SRui Paulo  * @IWM_TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation
4819d4886179SRui Paulo  * @IWM_TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id
4820d4886179SRui Paulo  * @IWM_TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped
4821d4886179SRui Paulo  * @IWM_TX_CMD_FLG_EXEC_PAPD: execute PAPD
4822d4886179SRui Paulo  * @IWM_TX_CMD_FLG_PAPD_TYPE: 0 for reference power, 1 for nominal power
4823d4886179SRui Paulo  * @IWM_TX_CMD_FLG_HCCA_CHUNK: mark start of TSPEC chunk
4824d4886179SRui Paulo  */
4825355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_PROT_REQUIRE	(1 << 0)
4826355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_ACK		(1 << 3)
4827355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_STA_RATE		(1 << 4)
4828355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_BA		(1 << 5)
4829355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_BAR		(1 << 6)
4830355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_TXOP_PROT	(1 << 7)
4831355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_VHT_NDPA		(1 << 8)
4832355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_HT_NDPA		(1 << 9)
4833355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_CSI_FDBK2HOST	(1 << 10)
4834355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_BT_DIS		(1 << 12)
4835355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_SEQ_CTL		(1 << 13)
4836355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_MORE_FRAG	(1 << 14)
4837355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_NEXT_FRAME	(1 << 15)
4838355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_TSF		(1 << 16)
4839355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_CALIB		(1 << 17)
4840355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_KEEP_SEQ_CTL	(1 << 18)
4841355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_AGG_START	(1 << 19)
4842355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_MH_PAD		(1 << 20)
4843355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_RESP_TO_DRV	(1 << 21)
4844355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_CCMP_AGG		(1 << 22)
4845355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_TKIP_MIC_DONE	(1 << 23)
4846355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_DUR		(1 << 25)
4847355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_FW_DROP		(1 << 26)
4848355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_EXEC_PAPD	(1 << 27)
4849355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_PAPD_TYPE	(1 << 28)
4850355c1513SAdrian Chadd #define IWM_TX_CMD_FLG_HCCA_CHUNK	(1U << 31)
4851355c1513SAdrian Chadd /* IWM_TX_FLAGS_BITS_API_S_VER_1 */
4852d4886179SRui Paulo 
48532b8cf46aSImre Vadász /**
48542b8cf46aSImre Vadász  * enum iwm_tx_pm_timeouts - pm timeout values in TX command
48552b8cf46aSImre Vadász  * @IWM_PM_FRAME_NONE: no need to suspend sleep mode
48562b8cf46aSImre Vadász  * @IWM_PM_FRAME_MGMT: fw suspend sleep mode for 100TU
48572b8cf46aSImre Vadász  * @IWM_PM_FRAME_ASSOC: fw suspend sleep mode for 10sec
48582b8cf46aSImre Vadász  */
48592b8cf46aSImre Vadász enum iwm_tx_pm_timeouts {
48602b8cf46aSImre Vadász 	IWM_PM_FRAME_NONE		= 0,
48612b8cf46aSImre Vadász 	IWM_PM_FRAME_MGMT		= 2,
48622b8cf46aSImre Vadász 	IWM_PM_FRAME_ASSOC		= 3,
48632b8cf46aSImre Vadász };
48642b8cf46aSImre Vadász 
4865d4886179SRui Paulo /*
4866d4886179SRui Paulo  * TX command security control
4867d4886179SRui Paulo  */
4868d4886179SRui Paulo #define IWM_TX_CMD_SEC_WEP		0x01
4869d4886179SRui Paulo #define IWM_TX_CMD_SEC_CCM		0x02
4870d4886179SRui Paulo #define IWM_TX_CMD_SEC_TKIP		0x03
4871d4886179SRui Paulo #define IWM_TX_CMD_SEC_EXT		0x04
4872d4886179SRui Paulo #define IWM_TX_CMD_SEC_MSK		0x07
4873d4886179SRui Paulo #define IWM_TX_CMD_SEC_WEP_KEY_IDX_POS	6
4874d4886179SRui Paulo #define IWM_TX_CMD_SEC_WEP_KEY_IDX_MSK	0xc0
4875d4886179SRui Paulo #define IWM_TX_CMD_SEC_KEY128		0x08
4876d4886179SRui Paulo 
4877355c1513SAdrian Chadd /* TODO: how does these values are OK with only 16 bit variable??? */
4878355c1513SAdrian Chadd /*
4879355c1513SAdrian Chadd  * TX command next frame info
4880355c1513SAdrian Chadd  *
4881355c1513SAdrian Chadd  * bits 0:2 - security control (IWM_TX_CMD_SEC_*)
4882355c1513SAdrian Chadd  * bit 3 - immediate ACK required
4883355c1513SAdrian Chadd  * bit 4 - rate is taken from STA table
4884355c1513SAdrian Chadd  * bit 5 - frame belongs to BA stream
4885355c1513SAdrian Chadd  * bit 6 - immediate BA response expected
4886355c1513SAdrian Chadd  * bit 7 - unused
4887355c1513SAdrian Chadd  * bits 8:15 - Station ID
4888355c1513SAdrian Chadd  * bits 16:31 - rate
4889355c1513SAdrian Chadd  */
4890355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_ACK_MSK		(0x8)
4891355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_STA_RATE_MSK	(0x10)
4892355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_BA_MSK		(0x20)
4893355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_IMM_BA_RSP_MSK	(0x40)
4894355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_FLAGS_MSK		(0xf8)
4895355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_STA_ID_MSK	(0xff00)
4896355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_STA_ID_POS	(8)
4897355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_RATE_MSK		(0xffff0000)
4898355c1513SAdrian Chadd #define IWM_TX_CMD_NEXT_FRAME_RATE_POS		(16)
4899355c1513SAdrian Chadd 
4900d4886179SRui Paulo /*
4901d4886179SRui Paulo  * TX command Frame life time in us - to be written in pm_frame_timeout
4902d4886179SRui Paulo  */
4903d4886179SRui Paulo #define IWM_TX_CMD_LIFE_TIME_INFINITE	0xFFFFFFFF
4904d4886179SRui Paulo #define IWM_TX_CMD_LIFE_TIME_DEFAULT	2000000 /* 2000 ms*/
4905d4886179SRui Paulo #define IWM_TX_CMD_LIFE_TIME_PROBE_RESP	40000 /* 40 ms */
4906d4886179SRui Paulo #define IWM_TX_CMD_LIFE_TIME_EXPIRED_FRAME	0
4907d4886179SRui Paulo 
4908d4886179SRui Paulo /*
4909d4886179SRui Paulo  * TID for non QoS frames - to be written in tid_tspec
4910d4886179SRui Paulo  */
4911355c1513SAdrian Chadd #define IWM_MAX_TID_COUNT	8
4912355c1513SAdrian Chadd #define IWM_TID_NON_QOS		0
4913355c1513SAdrian Chadd #define IWM_TID_MGMT		15
4914d4886179SRui Paulo 
4915d4886179SRui Paulo /*
4916d4886179SRui Paulo  * Limits on the retransmissions - to be written in {data,rts}_retry_limit
4917d4886179SRui Paulo  */
4918d4886179SRui Paulo #define IWM_DEFAULT_TX_RETRY			15
4919d4886179SRui Paulo #define IWM_MGMT_DFAULT_RETRY_LIMIT		3
4920355c1513SAdrian Chadd #define IWM_RTS_DFAULT_RETRY_LIMIT		3
4921d4886179SRui Paulo #define IWM_BAR_DFAULT_RETRY_LIMIT		60
4922d4886179SRui Paulo #define IWM_LOW_RETRY_LIMIT			7
4923d4886179SRui Paulo 
4924d2c7b21aSMark Johnston /**
4925d2c7b21aSMark Johnston  * enum iwm_tx_offload_assist_flags_pos -  set %iwm_tx_cmd offload_assist values
4926355c1513SAdrian Chadd  * @TX_CMD_OFFLD_IP_HDR: offset to start of IP header (in words)
4927d2c7b21aSMark Johnston  *	from mac header end. For normal case it is 4 words for SNAP.
4928d2c7b21aSMark Johnston  *	note: tx_cmd, mac header and pad are not counted in the offset.
4929d2c7b21aSMark Johnston  *	This is used to help the offload in case there is tunneling such as
4930d2c7b21aSMark Johnston  *	IPv6 in IPv4, in such case the ip header offset should point to the
4931d2c7b21aSMark Johnston  *	inner ip header and IPv4 checksum of the external header should be
4932d2c7b21aSMark Johnston  *	calculated by driver.
4933355c1513SAdrian Chadd  * @TX_CMD_OFFLD_L4_EN: enable TCP/UDP checksum
4934355c1513SAdrian Chadd  * @TX_CMD_OFFLD_L3_EN: enable IP header checksum
4935355c1513SAdrian Chadd  * @TX_CMD_OFFLD_MH_SIZE: size of the mac header in words. Includes the IV
4936d2c7b21aSMark Johnston  *	field. Doesn't include the pad.
4937355c1513SAdrian Chadd  * @TX_CMD_OFFLD_PAD: mark 2-byte pad was inserted after the mac header for
4938d2c7b21aSMark Johnston  *	alignment
4939355c1513SAdrian Chadd  * @TX_CMD_OFFLD_AMSDU: mark TX command is A-MSDU
4940d2c7b21aSMark Johnston  */
4941355c1513SAdrian Chadd #define IWM_TX_CMD_OFFLD_IP_HDR		(1 << 0)
4942355c1513SAdrian Chadd #define IWM_TX_CMD_OFFLD_L4_EN		(1 << 6)
4943355c1513SAdrian Chadd #define IWM_TX_CMD_OFFLD_L3_EN		(1 << 7)
4944355c1513SAdrian Chadd #define IWM_TX_CMD_OFFLD_MH_SIZE	(1 << 8)
4945355c1513SAdrian Chadd #define IWM_TX_CMD_OFFLD_PAD		(1 << 13)
4946355c1513SAdrian Chadd #define IWM_TX_CMD_OFFLD_AMSDU		(1 << 14)
4947d2c7b21aSMark Johnston 
4948d4886179SRui Paulo /* TODO: complete documentation for try_cnt and btkill_cnt */
4949d4886179SRui Paulo /**
4950d4886179SRui Paulo  * struct iwm_tx_cmd - TX command struct to FW
4951d4886179SRui Paulo  * ( IWM_TX_CMD = 0x1c )
4952d4886179SRui Paulo  * @len: in bytes of the payload, see below for details
4953d2c7b21aSMark Johnston  * @offload_assist: TX offload configuration
4954d4886179SRui Paulo  * @tx_flags: combination of IWM_TX_CMD_FLG_*
4955d4886179SRui Paulo  * @rate_n_flags: rate for *all* Tx attempts, if IWM_TX_CMD_FLG_STA_RATE_MSK is
4956d4886179SRui Paulo  *	cleared. Combination of IWM_RATE_MCS_*
4957d4886179SRui Paulo  * @sta_id: index of destination station in FW station table
4958d4886179SRui Paulo  * @sec_ctl: security control, IWM_TX_CMD_SEC_*
4959cef367e6SEitan Adler  * @initial_rate_index: index into the rate table for initial TX attempt.
4960d4886179SRui Paulo  *	Applied if IWM_TX_CMD_FLG_STA_RATE_MSK is set, normally 0 for data frames.
4961d4886179SRui Paulo  * @key: security key
4962355c1513SAdrian Chadd  * @next_frame_flags: IWM_TX_CMD_SEC_* and IWM_TX_CMD_NEXT_FRAME_*
4963d4886179SRui Paulo  * @life_time: frame life time (usecs??)
4964d4886179SRui Paulo  * @dram_lsb_ptr: Physical address of scratch area in the command (try_cnt +
4965d4886179SRui Paulo  *	btkill_cnd + reserved), first 32 bits. "0" disables usage.
4966d4886179SRui Paulo  * @dram_msb_ptr: upper bits of the scratch physical address
4967d4886179SRui Paulo  * @rts_retry_limit: max attempts for RTS
4968d4886179SRui Paulo  * @data_retry_limit: max attempts to send the data packet
4969d4886179SRui Paulo  * @tid_spec: TID/tspec
4970d4886179SRui Paulo  * @pm_frame_timeout: PM TX frame timeout
4971d4886179SRui Paulo  * @driver_txop: duration od EDCA TXOP, in 32-usec units. Set this if not
4972d4886179SRui Paulo  *	specified by HCCA protocol
4973d4886179SRui Paulo  *
4974d4886179SRui Paulo  * The byte count (both len and next_frame_len) includes MAC header
4975d4886179SRui Paulo  * (24/26/30/32 bytes)
4976d4886179SRui Paulo  * + 2 bytes pad if 26/30 header size
4977d4886179SRui Paulo  * + 8 byte IV for CCM or TKIP (not used for WEP)
4978d4886179SRui Paulo  * + Data payload
4979d4886179SRui Paulo  * + 8-byte MIC (not used for CCM/WEP)
4980d4886179SRui Paulo  * It does not include post-MAC padding, i.e.,
4981d4886179SRui Paulo  * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.
4982d4886179SRui Paulo  * Range of len: 14-2342 bytes.
4983d4886179SRui Paulo  *
4984d4886179SRui Paulo  * After the struct fields the MAC header is placed, plus any padding,
4985d4886179SRui Paulo  * and then the actial payload.
4986d4886179SRui Paulo  */
4987d4886179SRui Paulo struct iwm_tx_cmd {
4988d4886179SRui Paulo 	uint16_t len;
4989d2c7b21aSMark Johnston 	uint16_t offload_assist;
4990d4886179SRui Paulo 	uint32_t tx_flags;
4991d4886179SRui Paulo 	struct {
4992d4886179SRui Paulo 		uint8_t try_cnt;
4993d4886179SRui Paulo 		uint8_t btkill_cnt;
4994d4886179SRui Paulo 		uint16_t reserved;
4995d4886179SRui Paulo 	} scratch; /* DRAM_SCRATCH_API_U_VER_1 */
4996d4886179SRui Paulo 	uint32_t rate_n_flags;
4997d4886179SRui Paulo 	uint8_t sta_id;
4998d4886179SRui Paulo 	uint8_t sec_ctl;
4999d4886179SRui Paulo 	uint8_t initial_rate_index;
5000d4886179SRui Paulo 	uint8_t reserved2;
5001d4886179SRui Paulo 	uint8_t key[16];
5002d2ec5b52SMark Johnston 	uint32_t reserved3;
5003d4886179SRui Paulo 	uint32_t life_time;
5004d4886179SRui Paulo 	uint32_t dram_lsb_ptr;
5005d4886179SRui Paulo 	uint8_t dram_msb_ptr;
5006d4886179SRui Paulo 	uint8_t rts_retry_limit;
5007d4886179SRui Paulo 	uint8_t data_retry_limit;
5008d4886179SRui Paulo 	uint8_t tid_tspec;
5009d4886179SRui Paulo 	uint16_t pm_frame_timeout;
5010d2ec5b52SMark Johnston 	uint16_t reserved4;
5011d4886179SRui Paulo 	uint8_t payload[0];
5012d4886179SRui Paulo 	struct ieee80211_frame hdr[0];
5013355c1513SAdrian Chadd } __packed; /* IWM_TX_CMD_API_S_VER_6 */
5014d4886179SRui Paulo 
5015d4886179SRui Paulo /*
5016d4886179SRui Paulo  * TX response related data
5017d4886179SRui Paulo  */
5018d4886179SRui Paulo 
5019d4886179SRui Paulo /*
5020355c1513SAdrian Chadd  * status that is returned by the fw after attempts to Tx
5021d4886179SRui Paulo  * @IWM_TX_STATUS_FAIL_STA_COLOR_MISMATCH: mismatch between color of Tx cmd and
5022d4886179SRui Paulo  *	STA table
5023d4886179SRui Paulo  * Valid only if frame_count =1
5024d4886179SRui Paulo  */
5025355c1513SAdrian Chadd #define IWM_TX_STATUS_MSK		0x000000ff
5026355c1513SAdrian Chadd #define IWM_TX_STATUS_SUCCESS		0x01
5027355c1513SAdrian Chadd #define IWM_TX_STATUS_DIRECT_DONE	0x02
5028d4886179SRui Paulo /* postpone TX */
5029355c1513SAdrian Chadd #define IWM_TX_STATUS_POSTPONE_DELAY		0x40
5030355c1513SAdrian Chadd #define IWM_TX_STATUS_POSTPONE_FEW_BYTES	0x41
5031355c1513SAdrian Chadd #define IWM_TX_STATUS_POSTPONE_BT_PRIO		0x42
5032355c1513SAdrian Chadd #define IWM_TX_STATUS_POSTPONE_QUIET_PERIOD	0x43
5033355c1513SAdrian Chadd #define IWM_TX_STATUS_POSTPONE_CALC_TTAK	0x44
5034d4886179SRui Paulo /* abort TX */
5035355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY	0x81
5036355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_SHORT_LIMIT			0x82
5037355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_LONG_LIMIT			0x83
5038355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_UNDERRUN			0x84
5039355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_DRAIN_FLOW			0x85
5040355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_RFKILL_FLUSH			0x86
5041355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_LIFE_EXPIRE			0x87
5042355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_DEST_PS			0x88
5043355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_HOST_ABORTED			0x89
5044355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_BT_RETRY			0x8a
5045355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_STA_INVALID			0x8b
5046355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_FRAG_DROPPED			0x8c
5047355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_TID_DISABLE			0x8d
5048355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_FIFO_FLUSHED			0x8e
5049355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_SMALL_CF_POLL		0x8f
5050355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_FW_DROP			0x90
5051355c1513SAdrian Chadd #define IWM_TX_STATUS_FAIL_STA_COLOR_MISMATCH		0x91
5052355c1513SAdrian Chadd #define IWM_TX_STATUS_INTERNAL_ABORT			0x92
5053355c1513SAdrian Chadd #define IWM_TX_MODE_MSK			0x00000f00
5054355c1513SAdrian Chadd #define IWM_TX_MODE_NO_BURST		0x00000000
5055355c1513SAdrian Chadd #define IWM_TX_MODE_IN_BURST_SEQ	0x00000100
5056355c1513SAdrian Chadd #define IWM_TX_MODE_FIRST_IN_BURST	0x00000200
5057355c1513SAdrian Chadd #define IWM_TX_QUEUE_NUM_MSK		0x0001f000
5058355c1513SAdrian Chadd #define IWM_TX_NARROW_BW_MSK		0x00060000
5059355c1513SAdrian Chadd #define IWM_TX_NARROW_BW_1DIV2		0x00020000
5060355c1513SAdrian Chadd #define IWM_TX_NARROW_BW_1DIV4		0x00040000
5061355c1513SAdrian Chadd #define IWM_TX_NARROW_BW_1DIV8		0x00060000
5062d4886179SRui Paulo 
5063d4886179SRui Paulo /*
5064355c1513SAdrian Chadd  * TX aggregation status
5065d4886179SRui Paulo  * @IWM_AGG_TX_STATE_TRY_CNT_MSK: Retry count for 1st frame in aggregation (retries
5066d4886179SRui Paulo  *	occur if tx failed for this frame when it was a member of a previous
5067d4886179SRui Paulo  *	aggregation block). If rate scaling is used, retry count indicates the
5068d4886179SRui Paulo  *	rate table entry used for all frames in the new agg.
5069d4886179SRui Paulo  */
5070355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_STATUS_MSK		0x0fff
5071355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_TRANSMITTED		0x0000
5072355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_UNDERRUN		0x0001
5073355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_BT_PRIO		0x0002
5074355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_FEW_BYTES		0x0004
5075355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_ABORT			0x0008
5076355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_LAST_SENT_TTL		0x0010
5077355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_LAST_SENT_TRY_CNT	0x0020
5078355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_LAST_SENT_BT_KILL	0x0040
5079355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_SCD_QUERY		0x0080
5080355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_TEST_BAD_CRC32		0x0100
5081355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_RESPONSE		0x01ff
5082355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_DUMP_TX		0x0200
5083355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_DELAY_TX		0x0400
5084355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_TRY_CNT_POS	12
5085355c1513SAdrian Chadd #define IWM_AGG_TX_STATE_TRY_CNT_MSK	(0xf << IWM_AGG_TX_STATE_TRY_CNT_POS)
5086d4886179SRui Paulo 
5087d4886179SRui Paulo #define IWM_AGG_TX_STATE_LAST_SENT_MSK  (IWM_AGG_TX_STATE_LAST_SENT_TTL| \
5088d4886179SRui Paulo 				     IWM_AGG_TX_STATE_LAST_SENT_TRY_CNT| \
5089d4886179SRui Paulo 				     IWM_AGG_TX_STATE_LAST_SENT_BT_KILL)
5090d4886179SRui Paulo 
5091d4886179SRui Paulo /*
5092d4886179SRui Paulo  * The mask below describes a status where we are absolutely sure that the MPDU
5093d4886179SRui Paulo  * wasn't sent. For BA/Underrun we cannot be that sure. All we know that we've
5094d4886179SRui Paulo  * written the bytes to the TXE, but we know nothing about what the DSP did.
5095d4886179SRui Paulo  */
5096d4886179SRui Paulo #define IWM_AGG_TX_STAT_FRAME_NOT_SENT (IWM_AGG_TX_STATE_FEW_BYTES | \
5097d4886179SRui Paulo 				    IWM_AGG_TX_STATE_ABORT | \
5098d4886179SRui Paulo 				    IWM_AGG_TX_STATE_SCD_QUERY)
5099d4886179SRui Paulo 
5100d4886179SRui Paulo /*
5101d4886179SRui Paulo  * IWM_REPLY_TX = 0x1c (response)
5102d4886179SRui Paulo  *
5103d4886179SRui Paulo  * This response may be in one of two slightly different formats, indicated
5104d4886179SRui Paulo  * by the frame_count field:
5105d4886179SRui Paulo  *
5106d4886179SRui Paulo  * 1)	No aggregation (frame_count == 1).  This reports Tx results for a single
5107d4886179SRui Paulo  *	frame. Multiple attempts, at various bit rates, may have been made for
5108d4886179SRui Paulo  *	this frame.
5109d4886179SRui Paulo  *
5110d4886179SRui Paulo  * 2)	Aggregation (frame_count > 1).  This reports Tx results for two or more
5111d4886179SRui Paulo  *	frames that used block-acknowledge.  All frames were transmitted at
5112d4886179SRui Paulo  *	same rate. Rate scaling may have been used if first frame in this new
5113d4886179SRui Paulo  *	agg block failed in previous agg block(s).
5114d4886179SRui Paulo  *
5115d4886179SRui Paulo  *	Note that, for aggregation, ACK (block-ack) status is not delivered
5116d4886179SRui Paulo  *	here; block-ack has not been received by the time the device records
5117d4886179SRui Paulo  *	this status.
5118d4886179SRui Paulo  *	This status relates to reasons the tx might have been blocked or aborted
5119d4886179SRui Paulo  *	within the device, rather than whether it was received successfully by
5120d4886179SRui Paulo  *	the destination station.
5121d4886179SRui Paulo  */
5122d4886179SRui Paulo 
5123d4886179SRui Paulo /**
5124d4886179SRui Paulo  * struct iwm_agg_tx_status - per packet TX aggregation status
5125355c1513SAdrian Chadd  * @status: IWM_AGG_TX_STATE_*
5126355c1513SAdrian Chadd  * @idx: Tx queue index of this frame
5127355c1513SAdrian Chadd  * @qid: Tx queue ID of this frame
5128d4886179SRui Paulo  */
5129d4886179SRui Paulo struct iwm_agg_tx_status {
5130d4886179SRui Paulo 	uint16_t status;
5131355c1513SAdrian Chadd #if 0
5132355c1513SAdrian Chadd 	/* OpenBSD update - convert code to use this */
5133355c1513SAdrian Chadd 	uint8_t idx;
5134355c1513SAdrian Chadd 	uint8_t qid;
5135355c1513SAdrian Chadd #else
5136d4886179SRui Paulo 	uint16_t sequence;
5137355c1513SAdrian Chadd #endif
5138d4886179SRui Paulo } __packed;
5139d4886179SRui Paulo 
5140d4886179SRui Paulo /*
5141d4886179SRui Paulo  * definitions for initial rate index field
5142d4886179SRui Paulo  * bits [3:0] initial rate index
5143d4886179SRui Paulo  * bits [6:4] rate table color, used for the initial rate
5144d4886179SRui Paulo  * bit-7 invalid rate indication
5145d4886179SRui Paulo  */
5146d4886179SRui Paulo #define IWM_TX_RES_INIT_RATE_INDEX_MSK 0x0f
5147d4886179SRui Paulo #define IWM_TX_RES_RATE_TABLE_COLOR_MSK 0x70
5148d4886179SRui Paulo #define IWM_TX_RES_INV_RATE_INDEX_MSK 0x80
5149d4886179SRui Paulo 
5150e7065dd1SMark Johnston #define IWM_TX_RES_GET_TID(_ra_tid) ((_ra_tid) & 0x0f)
5151e7065dd1SMark Johnston #define IWM_TX_RES_GET_RA(_ra_tid) ((_ra_tid) >> 4)
5152d4886179SRui Paulo 
5153d4886179SRui Paulo /**
5154e7065dd1SMark Johnston  * struct iwm_tx_resp - notifies that fw is TXing a packet
5155d4886179SRui Paulo  * ( IWM_REPLY_TX = 0x1c )
5156d4886179SRui Paulo  * @frame_count: 1 no aggregation, >1 aggregation
5157d4886179SRui Paulo  * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
5158d4886179SRui Paulo  * @failure_rts: num of failures due to unsuccessful RTS
5159d4886179SRui Paulo  * @failure_frame: num failures due to no ACK (unused for agg)
5160d4886179SRui Paulo  * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
5161d4886179SRui Paulo  *	Tx of all the batch. IWM_RATE_MCS_*
5162d4886179SRui Paulo  * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
5163d4886179SRui Paulo  *	for agg: RTS + CTS + aggregation tx time + block-ack time.
5164d4886179SRui Paulo  *	in usec.
5165d4886179SRui Paulo  * @pa_status: tx power info
5166d4886179SRui Paulo  * @pa_integ_res_a: tx power info
5167d4886179SRui Paulo  * @pa_integ_res_b: tx power info
5168d4886179SRui Paulo  * @pa_integ_res_c: tx power info
5169d4886179SRui Paulo  * @measurement_req_id: tx power info
5170d4886179SRui Paulo  * @tfd_info: TFD information set by the FH
5171355c1513SAdrian Chadd  * @seq_ctl: sequence control field from IEEE80211 frame header
5172d4886179SRui Paulo  * @byte_cnt: byte count from the Tx cmd
5173d4886179SRui Paulo  * @tlc_info: TLC rate info
5174d4886179SRui Paulo  * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
5175d4886179SRui Paulo  * @frame_ctrl: frame control
5176d4886179SRui Paulo  * @status: for non-agg:  frame status IWM_TX_STATUS_*
5177d4886179SRui Paulo  *	for agg: status of 1st frame, IWM_AGG_TX_STATE_*; other frame status fields
5178d4886179SRui Paulo  *	follow this one, up to frame_count.
5179d4886179SRui Paulo  *
5180d4886179SRui Paulo  * After the array of statuses comes the SSN of the SCD. Look at
5181e7065dd1SMark Johnston  * %iwm_get_scd_ssn for more details.
5182d4886179SRui Paulo  */
5183e7065dd1SMark Johnston struct iwm_tx_resp {
5184d4886179SRui Paulo 	uint8_t frame_count;
5185d4886179SRui Paulo 	uint8_t bt_kill_count;
5186d4886179SRui Paulo 	uint8_t failure_rts;
5187d4886179SRui Paulo 	uint8_t failure_frame;
5188d4886179SRui Paulo 	uint32_t initial_rate;
5189d4886179SRui Paulo 	uint16_t wireless_media_time;
5190d4886179SRui Paulo 
5191d4886179SRui Paulo 	uint8_t pa_status;
5192d4886179SRui Paulo 	uint8_t pa_integ_res_a[3];
5193d4886179SRui Paulo 	uint8_t pa_integ_res_b[3];
5194d4886179SRui Paulo 	uint8_t pa_integ_res_c[3];
5195d4886179SRui Paulo 	uint16_t measurement_req_id;
5196355c1513SAdrian Chadd 	uint16_t reserved;
5197d4886179SRui Paulo 
5198d4886179SRui Paulo 	uint32_t tfd_info;
5199d4886179SRui Paulo 	uint16_t seq_ctl;
5200d4886179SRui Paulo 	uint16_t byte_cnt;
5201d4886179SRui Paulo 	uint8_t tlc_info;
5202d4886179SRui Paulo 	uint8_t ra_tid;
5203d4886179SRui Paulo 	uint16_t frame_ctrl;
5204d4886179SRui Paulo 
5205d4886179SRui Paulo 	struct iwm_agg_tx_status status;
5206d4886179SRui Paulo } __packed; /* IWM_TX_RSP_API_S_VER_3 */
5207d4886179SRui Paulo 
5208d4886179SRui Paulo /**
5209e7065dd1SMark Johnston  * struct iwm_ba_notif - notifies about reception of BA
5210d4886179SRui Paulo  * ( IWM_BA_NOTIF = 0xc5 )
5211355c1513SAdrian Chadd  * @sta_addr: MAC address
5212d4886179SRui Paulo  * @sta_id: Index of recipient (BA-sending) station in fw's station table
5213d4886179SRui Paulo  * @tid: tid of the session
5214355c1513SAdrian Chadd  * @seq_ctl: sequence control field from IEEE80211 frame header (the first
5215355c1513SAdrian Chadd  * bit in @bitmap corresponds to the sequence number stored here)
5216d4886179SRui Paulo  * @bitmap: the bitmap of the BA notification as seen in the air
5217d4886179SRui Paulo  * @scd_flow: the tx queue this BA relates to
5218d4886179SRui Paulo  * @scd_ssn: the index of the last contiguously sent packet
5219d4886179SRui Paulo  * @txed: number of Txed frames in this batch
5220d4886179SRui Paulo  * @txed_2_done: number of Acked frames in this batch
5221355c1513SAdrian Chadd  * @reduced_txp: power reduced according to TPC. This is the actual value and
5222355c1513SAdrian Chadd  *	not a copy from the LQ command. Thus, if not the first rate was used
5223355c1513SAdrian Chadd  *	for Tx-ing then this value will be set to 0 by FW.
5224355c1513SAdrian Chadd  * @reserved1: reserved
5225d4886179SRui Paulo  */
5226e7065dd1SMark Johnston struct iwm_ba_notif {
5227355c1513SAdrian Chadd 	uint8_t sta_addr[ETHER_ADDR_LEN];
5228d4886179SRui Paulo 	uint16_t reserved;
5229d4886179SRui Paulo 
5230d4886179SRui Paulo 	uint8_t sta_id;
5231d4886179SRui Paulo 	uint8_t tid;
5232d4886179SRui Paulo 	uint16_t seq_ctl;
5233d4886179SRui Paulo 	uint64_t bitmap;
5234d4886179SRui Paulo 	uint16_t scd_flow;
5235d4886179SRui Paulo 	uint16_t scd_ssn;
5236d4886179SRui Paulo 	uint8_t txed;
5237d4886179SRui Paulo 	uint8_t txed_2_done;
5238355c1513SAdrian Chadd 	uint8_t reduced_txp;
5239355c1513SAdrian Chadd 	uint8_t reserved1;
5240d4886179SRui Paulo } __packed;
5241d4886179SRui Paulo 
5242d4886179SRui Paulo /*
5243d4886179SRui Paulo  * struct iwm_mac_beacon_cmd - beacon template command
5244d4886179SRui Paulo  * @tx: the tx commands associated with the beacon frame
52459f4dc7fdSGordon Bergling  * @template_id: currently equal to the mac context id of the corresponding
5246d4886179SRui Paulo  *  mac.
5247d4886179SRui Paulo  * @tim_idx: the offset of the tim IE in the beacon
5248d4886179SRui Paulo  * @tim_size: the length of the tim IE
5249d4886179SRui Paulo  * @frame: the template of the beacon frame
5250d4886179SRui Paulo  */
5251d4886179SRui Paulo struct iwm_mac_beacon_cmd {
5252d4886179SRui Paulo 	struct iwm_tx_cmd tx;
5253d4886179SRui Paulo 	uint32_t template_id;
5254d4886179SRui Paulo 	uint32_t tim_idx;
5255d4886179SRui Paulo 	uint32_t tim_size;
5256d4886179SRui Paulo 	struct ieee80211_frame frame[0];
5257d4886179SRui Paulo } __packed;
5258d4886179SRui Paulo 
5259d4886179SRui Paulo struct iwm_beacon_notif {
5260e7065dd1SMark Johnston 	struct iwm_tx_resp beacon_notify_hdr;
5261d4886179SRui Paulo 	uint64_t tsf;
5262d4886179SRui Paulo 	uint32_t ibss_mgr_status;
5263d4886179SRui Paulo } __packed;
5264d4886179SRui Paulo 
5265d4886179SRui Paulo /**
5266355c1513SAdrian Chadd  * dump (flush) control flags
5267cef367e6SEitan Adler  * @IWM_DUMP_TX_FIFO_FLUSH: Dump MSDUs until the FIFO is empty
5268d4886179SRui Paulo  *	and the TFD queues are empty.
5269d4886179SRui Paulo  */
5270355c1513SAdrian Chadd #define IWM_DUMP_TX_FIFO_FLUSH	(1 << 1)
5271d4886179SRui Paulo 
5272d4886179SRui Paulo /**
5273d4886179SRui Paulo  * struct iwm_tx_path_flush_cmd -- queue/FIFO flush command
5274d4886179SRui Paulo  * @queues_ctl: bitmap of queues to flush
5275d4886179SRui Paulo  * @flush_ctl: control flags
5276d4886179SRui Paulo  * @reserved: reserved
5277d4886179SRui Paulo  */
5278355c1513SAdrian Chadd struct iwm_tx_path_flush_cmd_v1 {
5279d4886179SRui Paulo 	uint32_t queues_ctl;
5280d4886179SRui Paulo 	uint16_t flush_ctl;
5281d4886179SRui Paulo 	uint16_t reserved;
5282d4886179SRui Paulo } __packed; /* IWM_TX_PATH_FLUSH_CMD_API_S_VER_1 */
5283d4886179SRui Paulo 
5284d4886179SRui Paulo /**
5285355c1513SAdrian Chadd  * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command
5286355c1513SAdrian Chadd  * @sta_id: station ID to flush
5287355c1513SAdrian Chadd  * @tid_mask: TID mask to flush
5288355c1513SAdrian Chadd  * @reserved: reserved
5289355c1513SAdrian Chadd  */
5290355c1513SAdrian Chadd struct iwm_tx_path_flush_cmd {
5291355c1513SAdrian Chadd 	uint32_t sta_id;
5292355c1513SAdrian Chadd 	uint16_t tid_mask;
5293355c1513SAdrian Chadd 	uint16_t reserved;
5294355c1513SAdrian Chadd } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_2 */
5295355c1513SAdrian Chadd 
5296355c1513SAdrian Chadd /**
5297e7065dd1SMark Johnston  * iwm_get_scd_ssn - returns the SSN of the SCD
5298d4886179SRui Paulo  * @tx_resp: the Tx response from the fw (agg or non-agg)
5299d4886179SRui Paulo  *
5300d4886179SRui Paulo  * When the fw sends an AMPDU, it fetches the MPDUs one after the other. Since
5301d4886179SRui Paulo  * it can't know that everything will go well until the end of the AMPDU, it
5302d4886179SRui Paulo  * can't know in advance the number of MPDUs that will be sent in the current
5303d4886179SRui Paulo  * batch. This is why it writes the agg Tx response while it fetches the MPDUs.
5304d4886179SRui Paulo  * Hence, it can't know in advance what the SSN of the SCD will be at the end
5305d4886179SRui Paulo  * of the batch. This is why the SSN of the SCD is written at the end of the
5306d4886179SRui Paulo  * whole struct at a variable offset. This function knows how to cope with the
5307d4886179SRui Paulo  * variable offset and returns the SSN of the SCD.
5308d4886179SRui Paulo  */
5309e7065dd1SMark Johnston static inline uint32_t iwm_get_scd_ssn(struct iwm_tx_resp *tx_resp)
5310d4886179SRui Paulo {
5311d4886179SRui Paulo 	return le32_to_cpup((uint32_t *)&tx_resp->status +
5312d4886179SRui Paulo 			    tx_resp->frame_count) & 0xfff;
5313d4886179SRui Paulo }
5314d4886179SRui Paulo 
5315d4886179SRui Paulo /*
5316d4886179SRui Paulo  * END mvm/fw-api-tx.h
5317d4886179SRui Paulo  */
5318d4886179SRui Paulo 
5319d4886179SRui Paulo /*
5320d4886179SRui Paulo  * BEGIN mvm/fw-api-scan.h
5321d4886179SRui Paulo  */
5322d4886179SRui Paulo 
53236a5bc1d1SSean Bruno /**
53246a5bc1d1SSean Bruno  * struct iwm_scd_txq_cfg_cmd - New txq hw scheduler config command
53256a5bc1d1SSean Bruno  * @token:
53266a5bc1d1SSean Bruno  * @sta_id: station id
53276a5bc1d1SSean Bruno  * @tid:
53286a5bc1d1SSean Bruno  * @scd_queue: scheduler queue to confiug
53296a5bc1d1SSean Bruno  * @enable: 1 queue enable, 0 queue disable
53306a5bc1d1SSean Bruno  * @aggregate: 1 aggregated queue, 0 otherwise
5331e7065dd1SMark Johnston  * @tx_fifo: %enum iwm_tx_fifo
53326a5bc1d1SSean Bruno  * @window: BA window size
53336a5bc1d1SSean Bruno  * @ssn: SSN for the BA agreement
53346a5bc1d1SSean Bruno  */
53356a5bc1d1SSean Bruno struct iwm_scd_txq_cfg_cmd {
53366a5bc1d1SSean Bruno 	uint8_t token;
53376a5bc1d1SSean Bruno 	uint8_t sta_id;
53386a5bc1d1SSean Bruno 	uint8_t tid;
53396a5bc1d1SSean Bruno 	uint8_t scd_queue;
53406a5bc1d1SSean Bruno 	uint8_t enable;
53416a5bc1d1SSean Bruno 	uint8_t aggregate;
53426a5bc1d1SSean Bruno 	uint8_t tx_fifo;
53436a5bc1d1SSean Bruno 	uint8_t window;
53446a5bc1d1SSean Bruno 	uint16_t ssn;
53456a5bc1d1SSean Bruno 	uint16_t reserved;
53466a5bc1d1SSean Bruno } __packed; /* SCD_QUEUE_CFG_CMD_API_S_VER_1 */
53476a5bc1d1SSean Bruno 
53486a5bc1d1SSean Bruno /**
53496a5bc1d1SSean Bruno  * struct iwm_scd_txq_cfg_rsp
53506a5bc1d1SSean Bruno  * @token: taken from the command
53516a5bc1d1SSean Bruno  * @sta_id: station id from the command
53526a5bc1d1SSean Bruno  * @tid: tid from the command
53536a5bc1d1SSean Bruno  * @scd_queue: scd_queue from the command
53546a5bc1d1SSean Bruno  */
53556a5bc1d1SSean Bruno struct iwm_scd_txq_cfg_rsp {
53566a5bc1d1SSean Bruno 	uint8_t token;
53576a5bc1d1SSean Bruno 	uint8_t sta_id;
53586a5bc1d1SSean Bruno 	uint8_t tid;
53596a5bc1d1SSean Bruno 	uint8_t scd_queue;
53606a5bc1d1SSean Bruno } __packed; /* SCD_QUEUE_CFG_RSP_API_S_VER_1 */
53616a5bc1d1SSean Bruno 
53626a5bc1d1SSean Bruno 
5363d4886179SRui Paulo /* Scan Commands, Responses, Notifications */
5364d4886179SRui Paulo 
5365d4886179SRui Paulo /* Masks for iwm_scan_channel.type flags */
5366d4886179SRui Paulo #define IWM_SCAN_CHANNEL_TYPE_ACTIVE	(1 << 0)
53679afea60fSAndriy Voskoboinyk #define IWM_SCAN_CHANNEL_NSSIDS(x)	(((1 << (x)) - 1) << 1)
5368d4886179SRui Paulo 
5369d4886179SRui Paulo /* Max number of IEs for direct SSID scans in a command */
5370d4886179SRui Paulo #define IWM_PROBE_OPTION_MAX		20
5371d4886179SRui Paulo 
5372d4886179SRui Paulo /**
5373d4886179SRui Paulo  * struct iwm_ssid_ie - directed scan network information element
5374d4886179SRui Paulo  *
5375d4886179SRui Paulo  * Up to 20 of these may appear in IWM_REPLY_SCAN_CMD,
5376d4886179SRui Paulo  * selected by "type" bit field in struct iwm_scan_channel;
5377d4886179SRui Paulo  * each channel may select different ssids from among the 20 entries.
5378d4886179SRui Paulo  * SSID IEs get transmitted in reverse order of entry.
5379d4886179SRui Paulo  */
5380d4886179SRui Paulo struct iwm_ssid_ie {
5381d4886179SRui Paulo 	uint8_t id;
5382d4886179SRui Paulo 	uint8_t len;
5383d4886179SRui Paulo 	uint8_t ssid[IEEE80211_NWID_LEN];
5384d4886179SRui Paulo } __packed; /* IWM_SCAN_DIRECT_SSID_IE_API_S_VER_1 */
5385d4886179SRui Paulo 
53866a5bc1d1SSean Bruno /* scan offload */
53876a5bc1d1SSean Bruno #define IWM_SCAN_MAX_BLACKLIST_LEN	64
53886a5bc1d1SSean Bruno #define IWM_SCAN_SHORT_BLACKLIST_LEN	16
53896a5bc1d1SSean Bruno #define IWM_SCAN_MAX_PROFILES		11
53906a5bc1d1SSean Bruno #define IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE	512
53916a5bc1d1SSean Bruno 
53926a5bc1d1SSean Bruno /* Default watchdog (in MS) for scheduled scan iteration */
53936a5bc1d1SSean Bruno #define IWM_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
53946a5bc1d1SSean Bruno 
53956a5bc1d1SSean Bruno #define IWM_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
53966a5bc1d1SSean Bruno #define IWM_CAN_ABORT_STATUS 1
53976a5bc1d1SSean Bruno 
53986a5bc1d1SSean Bruno #define IWM_FULL_SCAN_MULTIPLIER 5
53996a5bc1d1SSean Bruno #define IWM_FAST_SCHED_SCAN_ITERATIONS 3
54006a5bc1d1SSean Bruno #define IWM_MAX_SCHED_SCAN_PLANS 2
54016a5bc1d1SSean Bruno 
5402d4886179SRui Paulo /**
54036a5bc1d1SSean Bruno  * iwm_scan_schedule_lmac - schedule of scan offload
54046a5bc1d1SSean Bruno  * @delay:		delay between iterations, in seconds.
54056a5bc1d1SSean Bruno  * @iterations:		num of scan iterations
54066a5bc1d1SSean Bruno  * @full_scan_mul:	number of partial scans before each full scan
5407d4886179SRui Paulo  */
54086a5bc1d1SSean Bruno struct iwm_scan_schedule_lmac {
54096a5bc1d1SSean Bruno 	uint16_t delay;
54106a5bc1d1SSean Bruno 	uint8_t iterations;
54116a5bc1d1SSean Bruno 	uint8_t full_scan_mul;
54126a5bc1d1SSean Bruno } __packed; /* SCAN_SCHEDULE_API_S */
54136a5bc1d1SSean Bruno 
54146a5bc1d1SSean Bruno /**
54156a5bc1d1SSean Bruno  * iwm_scan_req_tx_cmd - SCAN_REQ_TX_CMD_API_S
54166a5bc1d1SSean Bruno  * @tx_flags: combination of TX_CMD_FLG_*
54176a5bc1d1SSean Bruno  * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
54186a5bc1d1SSean Bruno  *	cleared. Combination of RATE_MCS_*
54196a5bc1d1SSean Bruno  * @sta_id: index of destination station in FW station table
54206a5bc1d1SSean Bruno  * @reserved: for alignment and future use
54216a5bc1d1SSean Bruno  */
54226a5bc1d1SSean Bruno struct iwm_scan_req_tx_cmd {
54236a5bc1d1SSean Bruno 	uint32_t tx_flags;
54246a5bc1d1SSean Bruno 	uint32_t rate_n_flags;
54256a5bc1d1SSean Bruno 	uint8_t sta_id;
54266a5bc1d1SSean Bruno 	uint8_t reserved[3];
54276a5bc1d1SSean Bruno } __packed;
54286a5bc1d1SSean Bruno 
5429355c1513SAdrian Chadd #define IWM_UNIFIED_SCAN_CHANNEL_FULL		(1 << 27)
5430355c1513SAdrian Chadd #define IWM_UNIFIED_SCAN_CHANNEL_PARTIAL	(1 << 28)
54316a5bc1d1SSean Bruno 
54326a5bc1d1SSean Bruno /**
54336a5bc1d1SSean Bruno  * iwm_scan_channel_cfg_lmac - SCAN_CHANNEL_CFG_S_VER2
54346a5bc1d1SSean Bruno  * @flags:		bits 1-20: directed scan to i'th ssid
54356a5bc1d1SSean Bruno  *			other bits &enum iwm_scan_channel_flags_lmac
54366a5bc1d1SSean Bruno  * @channel_number:	channel number 1-13 etc
54376a5bc1d1SSean Bruno  * @iter_count:		scan iteration on this channel
54386a5bc1d1SSean Bruno  * @iter_interval:	interval in seconds between iterations on one channel
54396a5bc1d1SSean Bruno  */
54406a5bc1d1SSean Bruno struct iwm_scan_channel_cfg_lmac {
54416a5bc1d1SSean Bruno 	uint32_t flags;
54426a5bc1d1SSean Bruno 	uint16_t channel_num;
54436a5bc1d1SSean Bruno 	uint16_t iter_count;
54446a5bc1d1SSean Bruno 	uint32_t iter_interval;
54456a5bc1d1SSean Bruno } __packed;
5446d4886179SRui Paulo 
5447d4886179SRui Paulo /*
54486a5bc1d1SSean Bruno  * iwm_scan_probe_segment - PROBE_SEGMENT_API_S_VER_1
54496a5bc1d1SSean Bruno  * @offset: offset in the data block
54506a5bc1d1SSean Bruno  * @len: length of the segment
5451d4886179SRui Paulo  */
54526a5bc1d1SSean Bruno struct iwm_scan_probe_segment {
54536a5bc1d1SSean Bruno 	uint16_t offset;
54546a5bc1d1SSean Bruno 	uint16_t len;
54556a5bc1d1SSean Bruno } __packed;
54566a5bc1d1SSean Bruno 
54576a5bc1d1SSean Bruno /* iwm_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_2
54586a5bc1d1SSean Bruno  * @mac_header: first (and common) part of the probe
54596a5bc1d1SSean Bruno  * @band_data: band specific data
54606a5bc1d1SSean Bruno  * @common_data: last (and common) part of the probe
54616a5bc1d1SSean Bruno  * @buf: raw data block
54626a5bc1d1SSean Bruno  */
5463355c1513SAdrian Chadd struct iwm_scan_probe_req_v1 {
54646a5bc1d1SSean Bruno 	struct iwm_scan_probe_segment mac_header;
54656a5bc1d1SSean Bruno 	struct iwm_scan_probe_segment band_data[2];
54666a5bc1d1SSean Bruno 	struct iwm_scan_probe_segment common_data;
54676a5bc1d1SSean Bruno 	uint8_t buf[IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE];
54686a5bc1d1SSean Bruno } __packed;
54696a5bc1d1SSean Bruno 
5470355c1513SAdrian Chadd /* iwl_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_v2
5471355c1513SAdrian Chadd  * @mac_header: first (and common) part of the probe
5472355c1513SAdrian Chadd  * @band_data: band specific data
5473355c1513SAdrian Chadd  * @common_data: last (and common) part of the probe
5474355c1513SAdrian Chadd  * @buf: raw data block
5475355c1513SAdrian Chadd  */
5476355c1513SAdrian Chadd struct iwm_scan_probe_req {
5477355c1513SAdrian Chadd 	struct iwm_scan_probe_segment mac_header;
5478355c1513SAdrian Chadd 	struct iwm_scan_probe_segment band_data[3];
5479355c1513SAdrian Chadd 	struct iwm_scan_probe_segment common_data;
5480355c1513SAdrian Chadd 	uint8_t buf[IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE];
5481355c1513SAdrian Chadd } __packed;
5482355c1513SAdrian Chadd 
5483355c1513SAdrian Chadd 
5484355c1513SAdrian Chadd #define IWM_SCAN_CHANNEL_FLAG_EBS		(1 << 0)
5485355c1513SAdrian Chadd #define IWM_SCAN_CHANNEL_FLAG_EBS_ACCURATE	(1 << 1)
5486355c1513SAdrian Chadd #define IWM_SCAN_CHANNEL_FLAG_CACHE_ADD		(1 << 2)
54876a5bc1d1SSean Bruno 
54886a5bc1d1SSean Bruno /* iwm_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
54896a5bc1d1SSean Bruno  * @flags: enum iwm_scan_channel_flags
54906a5bc1d1SSean Bruno  * @non_ebs_ratio: defines the ratio of number of scan iterations where EBS is
54916a5bc1d1SSean Bruno  *	involved.
54926a5bc1d1SSean Bruno  *	1 - EBS is disabled.
54936a5bc1d1SSean Bruno  *	2 - every second scan will be full scan(and so on).
54946a5bc1d1SSean Bruno  */
54956a5bc1d1SSean Bruno struct iwm_scan_channel_opt {
54966a5bc1d1SSean Bruno 	uint16_t flags;
54976a5bc1d1SSean Bruno 	uint16_t non_ebs_ratio;
54986a5bc1d1SSean Bruno } __packed;
54996a5bc1d1SSean Bruno 
55006a5bc1d1SSean Bruno /**
5501355c1513SAdrian Chadd  * LMAC scan flags
5502e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
55036a5bc1d1SSean Bruno  *      without filtering.
5504e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
5505e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
5506e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
5507e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS multiple SSID matching
5508e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
5509e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report
55106a5bc1d1SSean Bruno  *      and DS parameter set IEs into probe requests.
5511e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_EXTENDED_DWELL: use extended dwell time on channels
55126a5bc1d1SSean Bruno  *      1, 6 and 11.
5513e7065dd1SMark Johnston  * @IWM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches
55146a5bc1d1SSean Bruno  */
5515355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_PASS_ALL		(1 << 0)
5516355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_PASSIVE		(1 << 1)
5517355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_PRE_CONNECTION	(1 << 2)
5518355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_ITER_COMPLETE	(1 << 3)
5519355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS	(1 << 4)
5520355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_FRAGMENTED	(1 << 5)
5521355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAGS_RRM_ENABLED	(1 << 6)
5522355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_EXTENDED_DWELL	(1 << 7)
5523355c1513SAdrian Chadd #define IWM_LMAC_SCAN_FLAG_MATCH		(1 << 9)
55246a5bc1d1SSean Bruno 
5525355c1513SAdrian Chadd #define IWM_SCAN_PRIORITY_LOW		0
5526355c1513SAdrian Chadd #define IWM_SCAN_PRIORITY_MEDIUM	1
5527355c1513SAdrian Chadd #define IWM_SCAN_PRIORITY_HIGH		2
55286a5bc1d1SSean Bruno 
55296a5bc1d1SSean Bruno /**
55306a5bc1d1SSean Bruno  * iwm_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
55316a5bc1d1SSean Bruno  * @reserved1: for alignment and future use
55326a5bc1d1SSean Bruno  * @channel_num: num of channels to scan
55336a5bc1d1SSean Bruno  * @active-dwell: dwell time for active channels
55346a5bc1d1SSean Bruno  * @passive-dwell: dwell time for passive channels
55356a5bc1d1SSean Bruno  * @fragmented-dwell: dwell time for fragmented passive scan
55366a5bc1d1SSean Bruno  * @extended_dwell: dwell time for channels 1, 6 and 11 (in certain cases)
55376a5bc1d1SSean Bruno  * @reserved2: for alignment and future use
55386a5bc1d1SSean Bruno  * @rx_chain_selct: PHY_RX_CHAIN_* flags
5539e7065dd1SMark Johnston  * @scan_flags: &enum iwm_lmac_scan_flags
55406a5bc1d1SSean Bruno  * @max_out_time: max time (in TU) to be out of associated channel
55416a5bc1d1SSean Bruno  * @suspend_time: pause scan this long (TUs) when returning to service channel
55426a5bc1d1SSean Bruno  * @flags: RXON flags
55436a5bc1d1SSean Bruno  * @filter_flags: RXON filter
55446a5bc1d1SSean Bruno  * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
55456a5bc1d1SSean Bruno  * @direct_scan: list of SSIDs for directed active scan
55466a5bc1d1SSean Bruno  * @scan_prio: enum iwm_scan_priority
55476a5bc1d1SSean Bruno  * @iter_num: number of scan iterations
55486a5bc1d1SSean Bruno  * @delay: delay in seconds before first iteration
55496a5bc1d1SSean Bruno  * @schedule: two scheduling plans. The first one is finite, the second one can
55506a5bc1d1SSean Bruno  *	be infinite.
55516a5bc1d1SSean Bruno  * @channel_opt: channel optimization options, for full and partial scan
55526a5bc1d1SSean Bruno  * @data: channel configuration and probe request packet.
55536a5bc1d1SSean Bruno  */
55546a5bc1d1SSean Bruno struct iwm_scan_req_lmac {
55556a5bc1d1SSean Bruno 	/* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
55566a5bc1d1SSean Bruno 	uint32_t reserved1;
55576a5bc1d1SSean Bruno 	uint8_t n_channels;
55586a5bc1d1SSean Bruno 	uint8_t active_dwell;
55596a5bc1d1SSean Bruno 	uint8_t passive_dwell;
55606a5bc1d1SSean Bruno 	uint8_t fragmented_dwell;
55616a5bc1d1SSean Bruno 	uint8_t extended_dwell;
55626a5bc1d1SSean Bruno 	uint8_t reserved2;
55636a5bc1d1SSean Bruno 	uint16_t rx_chain_select;
55646a5bc1d1SSean Bruno 	uint32_t scan_flags;
55656a5bc1d1SSean Bruno 	uint32_t max_out_time;
55666a5bc1d1SSean Bruno 	uint32_t suspend_time;
55676a5bc1d1SSean Bruno 	/* RX_ON_FLAGS_API_S_VER_1 */
55686a5bc1d1SSean Bruno 	uint32_t flags;
55696a5bc1d1SSean Bruno 	uint32_t filter_flags;
55706a5bc1d1SSean Bruno 	struct iwm_scan_req_tx_cmd tx_cmd[2];
55716a5bc1d1SSean Bruno 	struct iwm_ssid_ie direct_scan[IWM_PROBE_OPTION_MAX];
55726a5bc1d1SSean Bruno 	uint32_t scan_prio;
55736a5bc1d1SSean Bruno 	/* SCAN_REQ_PERIODIC_PARAMS_API_S */
55746a5bc1d1SSean Bruno 	uint32_t iter_num;
55756a5bc1d1SSean Bruno 	uint32_t delay;
55766a5bc1d1SSean Bruno 	struct iwm_scan_schedule_lmac schedule[IWM_MAX_SCHED_SCAN_PLANS];
55776a5bc1d1SSean Bruno 	struct iwm_scan_channel_opt channel_opt[2];
55786a5bc1d1SSean Bruno 	uint8_t data[];
55796a5bc1d1SSean Bruno } __packed;
55806a5bc1d1SSean Bruno 
55816a5bc1d1SSean Bruno /**
55826a5bc1d1SSean Bruno  * iwm_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
55836a5bc1d1SSean Bruno  * @last_schedule_line: last schedule line executed (fast or regular)
55846a5bc1d1SSean Bruno  * @last_schedule_iteration: last scan iteration executed before scan abort
55856a5bc1d1SSean Bruno  * @status: enum iwm_scan_offload_complete_status
55866a5bc1d1SSean Bruno  * @ebs_status: EBS success status &enum iwm_scan_ebs_status
55876a5bc1d1SSean Bruno  * @time_after_last_iter; time in seconds elapsed after last iteration
55886a5bc1d1SSean Bruno  */
55896a5bc1d1SSean Bruno struct iwm_periodic_scan_complete {
55906a5bc1d1SSean Bruno 	uint8_t last_schedule_line;
55916a5bc1d1SSean Bruno 	uint8_t last_schedule_iteration;
55926a5bc1d1SSean Bruno 	uint8_t status;
55936a5bc1d1SSean Bruno 	uint8_t ebs_status;
55946a5bc1d1SSean Bruno 	uint32_t time_after_last_iter;
55956a5bc1d1SSean Bruno 	uint32_t reserved;
55966a5bc1d1SSean Bruno } __packed;
5597d4886179SRui Paulo 
5598d4886179SRui Paulo /**
559927898346SKyle Evans  * struct iwm_scan_results_notif - scan results for one channel -
560027898346SKyle Evans  *      SCAN_RESULT_NTF_API_S_VER_3
5601d4886179SRui Paulo  * @channel: which channel the results are from
5602d4886179SRui Paulo  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
5603d4886179SRui Paulo  * @probe_status: IWM_SCAN_PROBE_STATUS_*, indicates success of probe request
5604d4886179SRui Paulo  * @num_probe_not_sent: # of request that weren't sent due to not enough time
5605d4886179SRui Paulo  * @duration: duration spent in channel, in usecs
5606d4886179SRui Paulo  */
5607d4886179SRui Paulo struct iwm_scan_results_notif {
5608d4886179SRui Paulo 	uint8_t channel;
5609d4886179SRui Paulo 	uint8_t band;
5610d4886179SRui Paulo 	uint8_t probe_status;
5611d4886179SRui Paulo 	uint8_t num_probe_not_sent;
5612d4886179SRui Paulo 	uint32_t duration;
561327898346SKyle Evans } __packed;
5614d4886179SRui Paulo 
5615355c1513SAdrian Chadd #define IWM_SCAN_CLIENT_SCHED_SCAN		(1 << 0)
5616355c1513SAdrian Chadd #define IWM_SCAN_CLIENT_NETDETECT		(1 << 1)
5617355c1513SAdrian Chadd #define IWM_SCAN_CLIENT_ASSET_TRACKING		(1 << 2)
5618d4886179SRui Paulo 
5619d4886179SRui Paulo /**
5620d4886179SRui Paulo  * iwm_scan_offload_blacklist - IWM_SCAN_OFFLOAD_BLACKLIST_S
5621d4886179SRui Paulo  * @ssid:		MAC address to filter out
5622d4886179SRui Paulo  * @reported_rssi:	AP rssi reported to the host
5623d4886179SRui Paulo  * @client_bitmap: clients ignore this entry  - enum scan_framework_client
5624d4886179SRui Paulo  */
5625d4886179SRui Paulo struct iwm_scan_offload_blacklist {
5626355c1513SAdrian Chadd 	uint8_t ssid[ETHER_ADDR_LEN];
5627d4886179SRui Paulo 	uint8_t reported_rssi;
5628d4886179SRui Paulo 	uint8_t client_bitmap;
5629d4886179SRui Paulo } __packed;
5630d4886179SRui Paulo 
5631355c1513SAdrian Chadd #define IWM_NETWORK_TYPE_BSS	1
5632355c1513SAdrian Chadd #define IWM_NETWORK_TYPE_IBSS	2
5633355c1513SAdrian Chadd #define IWM_NETWORK_TYPE_ANY	3
5634d4886179SRui Paulo 
5635355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_SELECT_2_4	0x4
5636355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_SELECT_5_2	0x8
5637355c1513SAdrian Chadd #define IWM_SCAN_OFFLOAD_SELECT_ANY	0xc
5638d4886179SRui Paulo 
5639d4886179SRui Paulo /**
5640d4886179SRui Paulo  * iwm_scan_offload_profile - IWM_SCAN_OFFLOAD_PROFILE_S
5641d4886179SRui Paulo  * @ssid_index:		index to ssid list in fixed part
5642d4886179SRui Paulo  * @unicast_cipher:	encryption olgorithm to match - bitmap
5643d4886179SRui Paulo  * @aut_alg:		authentication olgorithm to match - bitmap
5644d4886179SRui Paulo  * @network_type:	enum iwm_scan_offload_network_type
5645d4886179SRui Paulo  * @band_selection:	enum iwm_scan_offload_band_selection
5646d4886179SRui Paulo  * @client_bitmap:	clients waiting for match - enum scan_framework_client
5647d4886179SRui Paulo  */
5648d4886179SRui Paulo struct iwm_scan_offload_profile {
5649d4886179SRui Paulo 	uint8_t ssid_index;
5650d4886179SRui Paulo 	uint8_t unicast_cipher;
5651d4886179SRui Paulo 	uint8_t auth_alg;
5652d4886179SRui Paulo 	uint8_t network_type;
5653d4886179SRui Paulo 	uint8_t band_selection;
5654d4886179SRui Paulo 	uint8_t client_bitmap;
5655d4886179SRui Paulo 	uint8_t reserved[2];
5656d4886179SRui Paulo } __packed;
5657d4886179SRui Paulo 
5658d4886179SRui Paulo /**
5659d4886179SRui Paulo  * iwm_scan_offload_profile_cfg - IWM_SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_1
5660d4886179SRui Paulo  * @blaclist:		AP list to filter off from scan results
5661d4886179SRui Paulo  * @profiles:		profiles to search for match
5662d4886179SRui Paulo  * @blacklist_len:	length of blacklist
5663d4886179SRui Paulo  * @num_profiles:	num of profiles in the list
5664d4886179SRui Paulo  * @match_notify:	clients waiting for match found notification
5665d4886179SRui Paulo  * @pass_match:		clients waiting for the results
5666d4886179SRui Paulo  * @active_clients:	active clients bitmap - enum scan_framework_client
5667d4886179SRui Paulo  * @any_beacon_notify:	clients waiting for match notification without match
5668d4886179SRui Paulo  */
5669d4886179SRui Paulo struct iwm_scan_offload_profile_cfg {
5670d4886179SRui Paulo 	struct iwm_scan_offload_profile profiles[IWM_SCAN_MAX_PROFILES];
5671d4886179SRui Paulo 	uint8_t blacklist_len;
5672d4886179SRui Paulo 	uint8_t num_profiles;
5673d4886179SRui Paulo 	uint8_t match_notify;
5674d4886179SRui Paulo 	uint8_t pass_match;
5675d4886179SRui Paulo 	uint8_t active_clients;
5676d4886179SRui Paulo 	uint8_t any_beacon_notify;
5677d4886179SRui Paulo 	uint8_t reserved[2];
5678d4886179SRui Paulo } __packed;
5679d4886179SRui Paulo 
568022359652SImre Vadász enum iwm_scan_offload_complete_status {
5681d4886179SRui Paulo 	IWM_SCAN_OFFLOAD_COMPLETED	= 1,
5682d4886179SRui Paulo 	IWM_SCAN_OFFLOAD_ABORTED	= 2,
5683d4886179SRui Paulo };
5684d4886179SRui Paulo 
5685cd20383eSAdrian Chadd enum iwm_scan_ebs_status {
5686cd20383eSAdrian Chadd 	IWM_SCAN_EBS_SUCCESS,
5687cd20383eSAdrian Chadd 	IWM_SCAN_EBS_FAILED,
5688cd20383eSAdrian Chadd 	IWM_SCAN_EBS_CHAN_NOT_FOUND,
5689cd20383eSAdrian Chadd 	IWM_SCAN_EBS_INACTIVE,
5690cd20383eSAdrian Chadd };
5691cd20383eSAdrian Chadd 
5692d4886179SRui Paulo /**
56936a5bc1d1SSean Bruno  * struct iwm_lmac_scan_complete_notif - notifies end of scanning (all channels)
56946a5bc1d1SSean Bruno  *	SCAN_COMPLETE_NTF_API_S_VER_3
56956a5bc1d1SSean Bruno  * @scanned_channels: number of channels scanned (and number of valid results)
56966a5bc1d1SSean Bruno  * @status: one of SCAN_COMP_STATUS_*
56976a5bc1d1SSean Bruno  * @bt_status: BT on/off status
56986a5bc1d1SSean Bruno  * @last_channel: last channel that was scanned
56996a5bc1d1SSean Bruno  * @tsf_low: TSF timer (lower half) in usecs
57006a5bc1d1SSean Bruno  * @tsf_high: TSF timer (higher half) in usecs
57016a5bc1d1SSean Bruno  * @results: an array of scan results, only "scanned_channels" of them are valid
57026a5bc1d1SSean Bruno  */
57036a5bc1d1SSean Bruno struct iwm_lmac_scan_complete_notif {
57046a5bc1d1SSean Bruno 	uint8_t scanned_channels;
57056a5bc1d1SSean Bruno 	uint8_t status;
57066a5bc1d1SSean Bruno 	uint8_t bt_status;
57076a5bc1d1SSean Bruno 	uint8_t last_channel;
57086a5bc1d1SSean Bruno 	uint32_t tsf_low;
57096a5bc1d1SSean Bruno 	uint32_t tsf_high;
57106a5bc1d1SSean Bruno 	struct iwm_scan_results_notif results[];
57116a5bc1d1SSean Bruno } __packed;
57126a5bc1d1SSean Bruno 
57136a5bc1d1SSean Bruno 
57146a5bc1d1SSean Bruno /* UMAC Scan API */
57156a5bc1d1SSean Bruno 
57166a5bc1d1SSean Bruno /* The maximum of either of these cannot exceed 8, because we use an
5717e7065dd1SMark Johnston  * 8-bit mask (see IWM_SCAN_MASK).
57186a5bc1d1SSean Bruno  */
5719e7065dd1SMark Johnston #define IWM_MAX_UMAC_SCANS 8
5720e7065dd1SMark Johnston #define IWM_MAX_LMAC_SCANS 1
57216a5bc1d1SSean Bruno 
5722355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_ACTIVATE			(1 << 0)
5723355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_DEACTIVATE			(1 << 1)
5724355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_FORBID_CHUB_REQS		(1 << 2)
5725355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS		(1 << 3)
5726355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_TX_CHAINS		(1 << 8)
5727355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_RX_CHAINS		(1 << 9)
5728355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_AUX_STA_ID		(1 << 10)
5729355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_ALL_TIMES		(1 << 11)
5730355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_EFFECTIVE_TIMES	(1 << 12)
5731355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS		(1 << 13)
5732355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_LEGACY_RATES		(1 << 14)
5733355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_MAC_ADDR		(1 << 15)
5734355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_FRAGMENTED		(1 << 16)
5735355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_CLEAR_FRAGMENTED		(1 << 17)
5736355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_CAM_MODE		(1 << 18)
5737355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_CLEAR_CAM_MODE		(1 << 19)
5738355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_SET_PROMISC_MODE		(1 << 20)
5739355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_FLAG_CLEAR_PROMISC_MODE		(1 << 21)
57406a5bc1d1SSean Bruno 
57416a5bc1d1SSean Bruno /* Bits 26-31 are for num of channels in channel_array */
57426a5bc1d1SSean Bruno #define IWM_SCAN_CONFIG_N_CHANNELS(n) ((n) << 26)
57436a5bc1d1SSean Bruno 
57446a5bc1d1SSean Bruno /* OFDM basic rates */
5745355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_6M		(1 << 0)
5746355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_9M		(1 << 1)
5747355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_12M	(1 << 2)
5748355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_18M	(1 << 3)
5749355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_24M	(1 << 4)
5750355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_36M	(1 << 5)
5751355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_48M	(1 << 6)
5752355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_54M	(1 << 7)
57536a5bc1d1SSean Bruno /* CCK basic rates */
5754355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_1M		(1 << 8)
5755355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_2M		(1 << 9)
5756355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_5M		(1 << 10)
5757355c1513SAdrian Chadd #define IWM_SCAN_CONFIG_RATE_11M	(1 << 11)
57586a5bc1d1SSean Bruno 
57596a5bc1d1SSean Bruno /* Bits 16-27 are for supported rates */
57606a5bc1d1SSean Bruno #define IWM_SCAN_CONFIG_SUPPORTED_RATE(rate)	((rate) << 16)
57616a5bc1d1SSean Bruno 
5762355c1513SAdrian Chadd #define IWM_CHANNEL_FLAG_EBS				(1 << 0)
5763355c1513SAdrian Chadd #define IWM_CHANNEL_FLAG_ACCURATE_EBS			(1 << 1)
5764355c1513SAdrian Chadd #define IWM_CHANNEL_FLAG_EBS_ADD			(1 << 2)
5765355c1513SAdrian Chadd #define IWM_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE	(1 << 3)
57666a5bc1d1SSean Bruno 
57676a5bc1d1SSean Bruno /**
57686a5bc1d1SSean Bruno  * struct iwm_scan_config
57696a5bc1d1SSean Bruno  * @flags:			enum scan_config_flags
57706a5bc1d1SSean Bruno  * @tx_chains:			valid_tx antenna - ANT_* definitions
57716a5bc1d1SSean Bruno  * @rx_chains:			valid_rx antenna - ANT_* definitions
57726a5bc1d1SSean Bruno  * @legacy_rates:		default legacy rates - enum scan_config_rates
57736a5bc1d1SSean Bruno  * @out_of_channel_time:	default max out of serving channel time
57746a5bc1d1SSean Bruno  * @suspend_time:		default max suspend time
57756a5bc1d1SSean Bruno  * @dwell_active:		default dwell time for active scan
57766a5bc1d1SSean Bruno  * @dwell_passive:		default dwell time for passive scan
57776a5bc1d1SSean Bruno  * @dwell_fragmented:		default dwell time for fragmented scan
57786a5bc1d1SSean Bruno  * @dwell_extended:		default dwell time for channels 1, 6 and 11
57796a5bc1d1SSean Bruno  * @mac_addr:			default mac address to be used in probes
57806a5bc1d1SSean Bruno  * @bcast_sta_id:		the index of the station in the fw
57816a5bc1d1SSean Bruno  * @channel_flags:		default channel flags - enum iwm_channel_flags
57826a5bc1d1SSean Bruno  *				scan_config_channel_flag
57836a5bc1d1SSean Bruno  * @channel_array:		default supported channels
57846a5bc1d1SSean Bruno  */
57856a5bc1d1SSean Bruno struct iwm_scan_config {
57866a5bc1d1SSean Bruno 	uint32_t flags;
57876a5bc1d1SSean Bruno 	uint32_t tx_chains;
57886a5bc1d1SSean Bruno 	uint32_t rx_chains;
57896a5bc1d1SSean Bruno 	uint32_t legacy_rates;
57906a5bc1d1SSean Bruno 	uint32_t out_of_channel_time;
57916a5bc1d1SSean Bruno 	uint32_t suspend_time;
57926a5bc1d1SSean Bruno 	uint8_t dwell_active;
57936a5bc1d1SSean Bruno 	uint8_t dwell_passive;
57946a5bc1d1SSean Bruno 	uint8_t dwell_fragmented;
57956a5bc1d1SSean Bruno 	uint8_t dwell_extended;
5796355c1513SAdrian Chadd 	uint8_t mac_addr[ETHER_ADDR_LEN];
57976a5bc1d1SSean Bruno 	uint8_t bcast_sta_id;
57986a5bc1d1SSean Bruno 	uint8_t channel_flags;
57996a5bc1d1SSean Bruno 	uint8_t channel_array[];
58006a5bc1d1SSean Bruno } __packed; /* SCAN_CONFIG_DB_CMD_API_S */
58016a5bc1d1SSean Bruno 
58026a5bc1d1SSean Bruno /**
58036a5bc1d1SSean Bruno  * iwm_umac_scan_flags
58046a5bc1d1SSean Bruno  *@IWM_UMAC_SCAN_FLAG_PREEMPTIVE: scan process triggered by this scan request
58056a5bc1d1SSean Bruno  *	can be preempted by other scan requests with higher priority.
58066a5bc1d1SSean Bruno  *	The low priority scan will be resumed when the higher proirity scan is
58076a5bc1d1SSean Bruno  *	completed.
58086a5bc1d1SSean Bruno  *@IWM_UMAC_SCAN_FLAG_START_NOTIF: notification will be sent to the driver
58096a5bc1d1SSean Bruno  *	when scan starts.
58106a5bc1d1SSean Bruno  */
5811355c1513SAdrian Chadd #define IWM_UMAC_SCAN_FLAG_PREEMPTIVE		(1 << 0)
5812355c1513SAdrian Chadd #define IWM_UMAC_SCAN_FLAG_START_NOTIF		(1 << 1)
58136a5bc1d1SSean Bruno 
5814355c1513SAdrian Chadd #define IWM_UMAC_SCAN_UID_TYPE_OFFSET		0
5815355c1513SAdrian Chadd #define IWM_UMAC_SCAN_UID_SEQ_OFFSET		8
58166a5bc1d1SSean Bruno 
5817355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_PERIODIC	(1 << 0)
5818355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_OVER_BT		(1 << 1)
5819355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_PASS_ALL	(1 << 2)
5820355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_PASSIVE		(1 << 3)
5821355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT	(1 << 4)
5822355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE	(1 << 5)
5823355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_MULTIPLE_SSID	(1 << 6)
5824355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_FRAGMENTED	(1 << 7)
5825355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED	(1 << 8)
5826355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_MATCH		(1 << 9)
5827355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL	(1 << 10)
5828355c1513SAdrian Chadd /* Extended dwell is obselete when adaptive dwell is used, making this
5829355c1513SAdrian Chadd  * bit reusable. Hence, probe request defer is used only when adaptive
5830355c1513SAdrian Chadd  * dwell is supported. */
5831355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_PROB_REQ_DEFER_SUPP	(1 << 10)
5832355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_LMAC2_FRAGMENTED	(1 << 11)
5833355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_ADAPTIVE_DWELL		(1 << 13)
5834355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_MAX_CHNL_TIME		(1 << 14)
5835355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS_PROB_REQ_HIGH_TX_RATE	(1 << 15)
5836355c1513SAdrian Chadd 
5837355c1513SAdrian Chadd /**
5838355c1513SAdrian Chadd  * UMAC scan general flags #2
5839355c1513SAdrian Chadd  * @IWM_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL: Whether to send a complete
5840355c1513SAdrian Chadd  *	notification per channel or not.
5841355c1513SAdrian Chadd  * @IWM_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER: Whether to allow channel
5842355c1513SAdrian Chadd  *	reorder optimization or not.
5843355c1513SAdrian Chadd  */
5844355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL		(1 << 0)
5845355c1513SAdrian Chadd #define IWM_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER	(1 << 1)
58466a5bc1d1SSean Bruno 
58476a5bc1d1SSean Bruno /**
58486a5bc1d1SSean Bruno  * struct iwm_scan_channel_cfg_umac
58496a5bc1d1SSean Bruno  * @flags:		bitmap - 0-19:	directed scan to i'th ssid.
58506a5bc1d1SSean Bruno  * @channel_num:	channel number 1-13 etc.
58516a5bc1d1SSean Bruno  * @iter_count:		repetition count for the channel.
58526a5bc1d1SSean Bruno  * @iter_interval:	interval between two scan iterations on one channel.
58536a5bc1d1SSean Bruno  */
58546a5bc1d1SSean Bruno struct iwm_scan_channel_cfg_umac {
58556a5bc1d1SSean Bruno 	uint32_t flags;
58569afea60fSAndriy Voskoboinyk #define IWM_SCAN_CHANNEL_UMAC_NSSIDS(x)			((1 << (x)) - 1)
58576a5bc1d1SSean Bruno 	uint8_t channel_num;
58586a5bc1d1SSean Bruno 	uint8_t iter_count;
58596a5bc1d1SSean Bruno 	uint16_t iter_interval;
5860355c1513SAdrian Chadd } __packed; /* SCAN_CHANNEL_CFG_S_VER1 */
58616a5bc1d1SSean Bruno 
58626a5bc1d1SSean Bruno /**
58636a5bc1d1SSean Bruno  * struct iwm_scan_umac_schedule
58646a5bc1d1SSean Bruno  * @interval: interval in seconds between scan iterations
58656a5bc1d1SSean Bruno  * @iter_count: num of scan iterations for schedule plan, 0xff for infinite loop
58666a5bc1d1SSean Bruno  * @reserved: for alignment and future use
58676a5bc1d1SSean Bruno  */
58686a5bc1d1SSean Bruno struct iwm_scan_umac_schedule {
58696a5bc1d1SSean Bruno 	uint16_t interval;
58706a5bc1d1SSean Bruno 	uint8_t iter_count;
58716a5bc1d1SSean Bruno 	uint8_t reserved;
58726a5bc1d1SSean Bruno } __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
58736a5bc1d1SSean Bruno 
58746a5bc1d1SSean Bruno /**
58756a5bc1d1SSean Bruno  * struct iwm_scan_req_umac_tail - the rest of the UMAC scan request command
58766a5bc1d1SSean Bruno  *      parameters following channels configuration array.
58776a5bc1d1SSean Bruno  * @schedule: two scheduling plans.
58786a5bc1d1SSean Bruno  * @delay: delay in TUs before starting the first scan iteration
58796a5bc1d1SSean Bruno  * @reserved: for future use and alignment
58806a5bc1d1SSean Bruno  * @preq: probe request with IEs blocks
58816a5bc1d1SSean Bruno  * @direct_scan: list of SSIDs for directed active scan
58826a5bc1d1SSean Bruno  */
5883355c1513SAdrian Chadd struct iwm_scan_req_umac_tail_v1 {
58846a5bc1d1SSean Bruno 	/* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
58856a5bc1d1SSean Bruno 	struct iwm_scan_umac_schedule schedule[IWM_MAX_SCHED_SCAN_PLANS];
58866a5bc1d1SSean Bruno 	uint16_t delay;
58876a5bc1d1SSean Bruno 	uint16_t reserved;
58886a5bc1d1SSean Bruno 	/* SCAN_PROBE_PARAMS_API_S_VER_1 */
5889355c1513SAdrian Chadd 	struct iwm_scan_probe_req_v1 preq;
5890355c1513SAdrian Chadd 	struct iwm_ssid_ie direct_scan[IWM_PROBE_OPTION_MAX];
5891355c1513SAdrian Chadd } __packed;
5892355c1513SAdrian Chadd 
5893355c1513SAdrian Chadd /**
5894355c1513SAdrian Chadd  * struct iwm_scan_req_umac_tail - the rest of the UMAC scan request command
5895355c1513SAdrian Chadd  *      parameters following channels configuration array.
5896355c1513SAdrian Chadd  * @schedule: two scheduling plans.
5897355c1513SAdrian Chadd  * @delay: delay in TUs before starting the first scan iteration
5898355c1513SAdrian Chadd  * @reserved: for future use and alignment
5899355c1513SAdrian Chadd  * @preq: probe request with IEs blocks
5900355c1513SAdrian Chadd  * @direct_scan: list of SSIDs for directed active scan
5901355c1513SAdrian Chadd  */
5902355c1513SAdrian Chadd struct iwm_scan_req_umac_tail_v2 {
5903355c1513SAdrian Chadd 	/* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
5904355c1513SAdrian Chadd 	struct iwm_scan_umac_schedule schedule[IWM_MAX_SCHED_SCAN_PLANS];
5905355c1513SAdrian Chadd 	uint16_t delay;
5906355c1513SAdrian Chadd 	uint16_t reserved;
5907355c1513SAdrian Chadd 	/* SCAN_PROBE_PARAMS_API_S_VER_2 */
59086a5bc1d1SSean Bruno 	struct iwm_scan_probe_req preq;
59096a5bc1d1SSean Bruno 	struct iwm_ssid_ie direct_scan[IWM_PROBE_OPTION_MAX];
59106a5bc1d1SSean Bruno } __packed;
59116a5bc1d1SSean Bruno 
59126a5bc1d1SSean Bruno /**
5913355c1513SAdrian Chadd  * struct iwm_scan_umac_chan_param
5914355c1513SAdrian Chadd  * @flags: channel flags &enum iwl_scan_channel_flags
5915666c8655SMark Johnston  * @count: num of channels in scan request
5916666c8655SMark Johnston  * @reserved: for future use and alignment
5917666c8655SMark Johnston  */
5918666c8655SMark Johnston struct iwm_scan_umac_chan_param {
5919666c8655SMark Johnston 	uint8_t flags;
5920666c8655SMark Johnston 	uint8_t count;
5921666c8655SMark Johnston 	uint16_t reserved;
5922355c1513SAdrian Chadd } __packed; /* SCAN_CHANNEL_PARAMS_API_S_VER_1 */
5923355c1513SAdrian Chadd 
5924355c1513SAdrian Chadd #define IWM_SCAN_LB_LMAC_IDX 0
5925355c1513SAdrian Chadd #define IWM_SCAN_HB_LMAC_IDX 1
5926666c8655SMark Johnston 
5927666c8655SMark Johnston /**
59286a5bc1d1SSean Bruno  * struct iwm_scan_req_umac
5929355c1513SAdrian Chadd  * @flags: &enum iwl_umac_scan_flags
5930355c1513SAdrian Chadd  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
5931355c1513SAdrian Chadd  * @ooc_priority: out of channel priority - &enum iwl_scan_priority
5932355c1513SAdrian Chadd  * @general_flags: &enum iwl_umac_scan_general_flags
5933666c8655SMark Johnston  * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
59346a5bc1d1SSean Bruno  * @extended_dwell: dwell time for channels 1, 6 and 11
5935666c8655SMark Johnston  * @active_dwell: dwell time for active scan per LMAC
5936666c8655SMark Johnston  * @passive_dwell: dwell time for passive scan per LMAC
59376a5bc1d1SSean Bruno  * @fragmented_dwell: dwell time for fragmented passive scan
5938666c8655SMark Johnston  * @adwell_default_n_aps: for adaptive dwell the default number of APs
5939666c8655SMark Johnston  *	per channel
5940666c8655SMark Johnston  * @adwell_default_n_aps_social: for adaptive dwell the default
5941666c8655SMark Johnston  *	number of APs per social (1,6,11) channel
5942666c8655SMark Johnston  * @general_flags2: &enum iwl_umac_scan_general_flags2
5943666c8655SMark Johnston  * @adwell_max_budget: for adaptive dwell the maximal budget of TU to be added
5944666c8655SMark Johnston  *	to total scan time
5945666c8655SMark Johnston  * @max_out_time: max out of serving channel time, per LMAC - for CDB there
5946355c1513SAdrian Chadd  *	are 2 LMACs (high band and low band)
5947666c8655SMark Johnston  * @suspend_time: max suspend time, per LMAC - for CDB there are 2 LMACs
5948666c8655SMark Johnston  * @scan_priority: scan internal prioritization &enum iwl_scan_priority
5949666c8655SMark Johnston  * @num_of_fragments: Number of fragments needed for full coverage per band.
5950666c8655SMark Johnston  *	Relevant only for fragmented scan.
5951355c1513SAdrian Chadd  * @channel: &struct iwm_scan_umac_chan_param
59526a5bc1d1SSean Bruno  * @reserved: for future use and alignment
5953666c8655SMark Johnston  * @reserved3: for future use and alignment
59546a5bc1d1SSean Bruno  * @data: &struct iwm_scan_channel_cfg_umac and
59556a5bc1d1SSean Bruno  *	&struct iwm_scan_req_umac_tail
59566a5bc1d1SSean Bruno  */
59576a5bc1d1SSean Bruno struct iwm_scan_req_umac {
59586a5bc1d1SSean Bruno 	uint32_t flags;
59596a5bc1d1SSean Bruno 	uint32_t uid;
59606a5bc1d1SSean Bruno 	uint32_t ooc_priority;
5961355c1513SAdrian Chadd 	/* SCAN_GENERAL_PARAMS_API_S_VER_1 */
5962666c8655SMark Johnston 	uint16_t general_flags;
5963666c8655SMark Johnston 	uint8_t reserved;
5964666c8655SMark Johnston 	uint8_t scan_start_mac_id;
5965666c8655SMark Johnston 	union {
5966666c8655SMark Johnston 		struct {
59676a5bc1d1SSean Bruno 			uint8_t extended_dwell;
59686a5bc1d1SSean Bruno 			uint8_t active_dwell;
59696a5bc1d1SSean Bruno 			uint8_t passive_dwell;
59706a5bc1d1SSean Bruno 			uint8_t fragmented_dwell;
59716a5bc1d1SSean Bruno 			uint32_t max_out_time;
59726a5bc1d1SSean Bruno 			uint32_t suspend_time;
59736a5bc1d1SSean Bruno 			uint32_t scan_priority;
5974666c8655SMark Johnston 			struct iwm_scan_umac_chan_param channel;
59756a5bc1d1SSean Bruno 			uint8_t data[];
5976355c1513SAdrian Chadd 		} v1; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
5977355c1513SAdrian Chadd 		struct {
5978355c1513SAdrian Chadd 			uint8_t extended_dwell;
5979355c1513SAdrian Chadd 			uint8_t active_dwell;
5980355c1513SAdrian Chadd 			uint8_t passive_dwell;
5981355c1513SAdrian Chadd 			uint8_t fragmented_dwell;
5982355c1513SAdrian Chadd 			uint32_t max_out_time[2];
5983355c1513SAdrian Chadd 			uint32_t suspend_time[2];
5984355c1513SAdrian Chadd 			uint32_t scan_priority;
5985355c1513SAdrian Chadd 			struct iwm_scan_umac_chan_param channel;
5986355c1513SAdrian Chadd 			uint8_t data[];
5987355c1513SAdrian Chadd 		} v6; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_6 */
5988666c8655SMark Johnston 		struct {
5989666c8655SMark Johnston 			uint8_t active_dwell;
5990666c8655SMark Johnston 			uint8_t passive_dwell;
5991666c8655SMark Johnston 			uint8_t fragmented_dwell;
5992666c8655SMark Johnston 			uint8_t adwell_default_n_aps;
5993666c8655SMark Johnston 			uint8_t adwell_default_n_aps_social;
5994666c8655SMark Johnston 			uint8_t reserved3;
5995666c8655SMark Johnston 			uint16_t adwell_max_budget;
5996666c8655SMark Johnston 			uint32_t max_out_time[2];
5997666c8655SMark Johnston 			uint32_t suspend_time[2];
5998666c8655SMark Johnston 			uint32_t scan_priority;
5999666c8655SMark Johnston 			struct iwm_scan_umac_chan_param channel;
6000666c8655SMark Johnston 			uint8_t data[];
6001355c1513SAdrian Chadd 		} v7; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_7 */
6002355c1513SAdrian Chadd 		struct {
6003355c1513SAdrian Chadd 			uint8_t active_dwell[2];
6004355c1513SAdrian Chadd 			uint8_t reserved2;
6005355c1513SAdrian Chadd 			uint8_t adwell_default_n_aps;
6006355c1513SAdrian Chadd 			uint8_t adwell_default_n_aps_social;
6007355c1513SAdrian Chadd 			uint8_t general_flags2;
6008355c1513SAdrian Chadd 			uint16_t adwell_max_budget;
6009355c1513SAdrian Chadd 			uint32_t max_out_time[2];
6010355c1513SAdrian Chadd 			uint32_t suspend_time[2];
6011355c1513SAdrian Chadd 			uint32_t scan_priority;
6012355c1513SAdrian Chadd 			uint8_t passive_dwell[2];
6013355c1513SAdrian Chadd 			uint8_t num_of_fragments[2];
6014355c1513SAdrian Chadd 			struct iwm_scan_umac_chan_param channel;
6015355c1513SAdrian Chadd 			uint8_t data[];
6016355c1513SAdrian Chadd 		} v8; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_8 */
6017355c1513SAdrian Chadd 		struct {
6018355c1513SAdrian Chadd 			uint8_t active_dwell[2];
6019355c1513SAdrian Chadd 			uint8_t adwell_default_hb_n_aps;
6020355c1513SAdrian Chadd 			uint8_t adwell_default_lb_n_aps;
6021355c1513SAdrian Chadd 			uint8_t adwell_default_n_aps_social;
6022355c1513SAdrian Chadd 			uint8_t general_flags2;
6023355c1513SAdrian Chadd 			uint16_t adwell_max_budget;
6024355c1513SAdrian Chadd 			uint32_t max_out_time[2];
6025355c1513SAdrian Chadd 			uint32_t suspend_time[2];
6026355c1513SAdrian Chadd 			uint32_t scan_priority;
6027355c1513SAdrian Chadd 			uint8_t passive_dwell[2];
6028355c1513SAdrian Chadd 			uint8_t num_of_fragments[2];
6029355c1513SAdrian Chadd 			struct iwm_scan_umac_chan_param channel;
6030355c1513SAdrian Chadd 			uint8_t data[];
6031355c1513SAdrian Chadd 		} v9; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_9 */
6032666c8655SMark Johnston 	};
6033666c8655SMark Johnston } __packed;
6034666c8655SMark Johnston 
6035355c1513SAdrian Chadd #define IWM_SCAN_REQ_UMAC_SIZE_V8 sizeof(struct iwm_scan_req_umac)
6036666c8655SMark Johnston #define IWM_SCAN_REQ_UMAC_SIZE_V7 48
6037355c1513SAdrian Chadd #define IWM_SCAN_REQ_UMAC_SIZE_V6 44
6038666c8655SMark Johnston #define IWM_SCAN_REQ_UMAC_SIZE_V1 36
60396a5bc1d1SSean Bruno 
60406a5bc1d1SSean Bruno /**
60416a5bc1d1SSean Bruno  * struct iwm_umac_scan_abort
60426a5bc1d1SSean Bruno  * @uid: scan id, &enum iwm_umac_scan_uid_offsets
60436a5bc1d1SSean Bruno  * @flags: reserved
60446a5bc1d1SSean Bruno  */
60456a5bc1d1SSean Bruno struct iwm_umac_scan_abort {
60466a5bc1d1SSean Bruno 	uint32_t uid;
60476a5bc1d1SSean Bruno 	uint32_t flags;
60486a5bc1d1SSean Bruno } __packed; /* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */
60496a5bc1d1SSean Bruno 
60506a5bc1d1SSean Bruno /**
60516a5bc1d1SSean Bruno  * struct iwm_umac_scan_complete
60526a5bc1d1SSean Bruno  * @uid: scan id, &enum iwm_umac_scan_uid_offsets
60536a5bc1d1SSean Bruno  * @last_schedule: last scheduling line
60546a5bc1d1SSean Bruno  * @last_iter:	last scan iteration number
60556a5bc1d1SSean Bruno  * @scan status: &enum iwm_scan_offload_complete_status
60566a5bc1d1SSean Bruno  * @ebs_status: &enum iwm_scan_ebs_status
60576a5bc1d1SSean Bruno  * @time_from_last_iter: time elapsed from last iteration
60586a5bc1d1SSean Bruno  * @reserved: for future use
60596a5bc1d1SSean Bruno  */
60606a5bc1d1SSean Bruno struct iwm_umac_scan_complete {
60616a5bc1d1SSean Bruno 	uint32_t uid;
60626a5bc1d1SSean Bruno 	uint8_t last_schedule;
60636a5bc1d1SSean Bruno 	uint8_t last_iter;
60646a5bc1d1SSean Bruno 	uint8_t status;
60656a5bc1d1SSean Bruno 	uint8_t ebs_status;
60666a5bc1d1SSean Bruno 	uint32_t time_from_last_iter;
60676a5bc1d1SSean Bruno 	uint32_t reserved;
60686a5bc1d1SSean Bruno } __packed; /* SCAN_COMPLETE_NTF_UMAC_API_S_VER_1 */
60696a5bc1d1SSean Bruno 
60706a5bc1d1SSean Bruno #define IWM_SCAN_OFFLOAD_MATCHING_CHANNELS_LEN 5
60716a5bc1d1SSean Bruno /**
60726a5bc1d1SSean Bruno  * struct iwm_scan_offload_profile_match - match information
60736a5bc1d1SSean Bruno  * @bssid: matched bssid
60746a5bc1d1SSean Bruno  * @channel: channel where the match occurred
60756a5bc1d1SSean Bruno  * @energy:
60766a5bc1d1SSean Bruno  * @matching_feature:
60776a5bc1d1SSean Bruno  * @matching_channels: bitmap of channels that matched, referencing
60786a5bc1d1SSean Bruno  *	the channels passed in tue scan offload request
60796a5bc1d1SSean Bruno  */
60806a5bc1d1SSean Bruno struct iwm_scan_offload_profile_match {
6081355c1513SAdrian Chadd 	uint8_t bssid[ETHER_ADDR_LEN];
60826a5bc1d1SSean Bruno 	uint16_t reserved;
60836a5bc1d1SSean Bruno 	uint8_t channel;
60846a5bc1d1SSean Bruno 	uint8_t energy;
60856a5bc1d1SSean Bruno 	uint8_t matching_feature;
60866a5bc1d1SSean Bruno 	uint8_t matching_channels[IWM_SCAN_OFFLOAD_MATCHING_CHANNELS_LEN];
60876a5bc1d1SSean Bruno } __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_1 */
60886a5bc1d1SSean Bruno 
60896a5bc1d1SSean Bruno /**
60906a5bc1d1SSean Bruno  * struct iwm_scan_offload_profiles_query - match results query response
60916a5bc1d1SSean Bruno  * @matched_profiles: bitmap of matched profiles, referencing the
60926a5bc1d1SSean Bruno  *	matches passed in the scan offload request
60936a5bc1d1SSean Bruno  * @last_scan_age: age of the last offloaded scan
60946a5bc1d1SSean Bruno  * @n_scans_done: number of offloaded scans done
60956a5bc1d1SSean Bruno  * @gp2_d0u: GP2 when D0U occurred
60966a5bc1d1SSean Bruno  * @gp2_invoked: GP2 when scan offload was invoked
60976a5bc1d1SSean Bruno  * @resume_while_scanning: not used
60986a5bc1d1SSean Bruno  * @self_recovery: obsolete
60996a5bc1d1SSean Bruno  * @reserved: reserved
61006a5bc1d1SSean Bruno  * @matches: array of match information, one for each match
61016a5bc1d1SSean Bruno  */
61026a5bc1d1SSean Bruno struct iwm_scan_offload_profiles_query {
61036a5bc1d1SSean Bruno 	uint32_t matched_profiles;
61046a5bc1d1SSean Bruno 	uint32_t last_scan_age;
61056a5bc1d1SSean Bruno 	uint32_t n_scans_done;
61066a5bc1d1SSean Bruno 	uint32_t gp2_d0u;
61076a5bc1d1SSean Bruno 	uint32_t gp2_invoked;
61086a5bc1d1SSean Bruno 	uint8_t resume_while_scanning;
61096a5bc1d1SSean Bruno 	uint8_t self_recovery;
61106a5bc1d1SSean Bruno 	uint16_t reserved;
61116a5bc1d1SSean Bruno 	struct iwm_scan_offload_profile_match matches[IWM_SCAN_MAX_PROFILES];
61126a5bc1d1SSean Bruno } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
61136a5bc1d1SSean Bruno 
61146a5bc1d1SSean Bruno /**
61156a5bc1d1SSean Bruno  * struct iwm_umac_scan_iter_complete_notif - notifies end of scanning iteration
61166a5bc1d1SSean Bruno  * @uid: scan id, &enum iwm_umac_scan_uid_offsets
61176a5bc1d1SSean Bruno  * @scanned_channels: number of channels scanned and number of valid elements in
61186a5bc1d1SSean Bruno  *	results array
61196a5bc1d1SSean Bruno  * @status: one of SCAN_COMP_STATUS_*
61206a5bc1d1SSean Bruno  * @bt_status: BT on/off status
61216a5bc1d1SSean Bruno  * @last_channel: last channel that was scanned
61226a5bc1d1SSean Bruno  * @tsf_low: TSF timer (lower half) in usecs
61236a5bc1d1SSean Bruno  * @tsf_high: TSF timer (higher half) in usecs
61246a5bc1d1SSean Bruno  * @results: array of scan results, only "scanned_channels" of them are valid
61256a5bc1d1SSean Bruno  */
61266a5bc1d1SSean Bruno struct iwm_umac_scan_iter_complete_notif {
61276a5bc1d1SSean Bruno 	uint32_t uid;
61286a5bc1d1SSean Bruno 	uint8_t scanned_channels;
61296a5bc1d1SSean Bruno 	uint8_t status;
61306a5bc1d1SSean Bruno 	uint8_t bt_status;
61316a5bc1d1SSean Bruno 	uint8_t last_channel;
61326a5bc1d1SSean Bruno 	uint32_t tsf_low;
61336a5bc1d1SSean Bruno 	uint32_t tsf_high;
61346a5bc1d1SSean Bruno 	struct iwm_scan_results_notif results[];
61356a5bc1d1SSean Bruno } __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_1 */
61366a5bc1d1SSean Bruno 
6137355c1513SAdrian Chadd #define IWM_GSCAN_START_CMD			0x0
6138355c1513SAdrian Chadd #define IWM_GSCAN_STOP_CMD			0x1
6139355c1513SAdrian Chadd #define IWM_GSCAN_SET_HOTLIST_CMD		0x2
6140355c1513SAdrian Chadd #define IWM_GSCAN_RESET_HOTLIST_CMD		0x3
6141355c1513SAdrian Chadd #define IWM_GSCAN_SET_SIGNIFICANT_CHANGE_CMD	0x4
6142355c1513SAdrian Chadd #define IWM_GSCAN_RESET_SIGNIFICANT_CHANGE_CMD	0x5
6143355c1513SAdrian Chadd #define IWM_GSCAN_SIGNIFICANT_CHANGE_EVENT	0xFD
6144355c1513SAdrian Chadd #define IWM_GSCAN_HOTLIST_CHANGE_EVENT		0xFE
6145355c1513SAdrian Chadd #define IWM_GSCAN_RESULTS_AVAILABLE_EVENT	0xFF
6146355c1513SAdrian Chadd 
6147355c1513SAdrian Chadd /*
6148355c1513SAdrian Chadd  * END mvm/fw-api-scan.h
61496a5bc1d1SSean Bruno  */
6150355c1513SAdrian Chadd 
6151355c1513SAdrian Chadd /*
6152355c1513SAdrian Chadd  * BEGIN mvm/fw-api-sta.h
6153355c1513SAdrian Chadd  */
61546a5bc1d1SSean Bruno 
61556a5bc1d1SSean Bruno /* STA API */
61566a5bc1d1SSean Bruno 
6157d4886179SRui Paulo /**
6158355c1513SAdrian Chadd  * flags for the ADD_STA host command
6159d4886179SRui Paulo  * @IWM_STA_FLG_REDUCED_TX_PWR_CTRL:
6160d4886179SRui Paulo  * @IWM_STA_FLG_REDUCED_TX_PWR_DATA:
61616a5bc1d1SSean Bruno  * @IWM_STA_FLG_DISABLE_TX: set if TX should be disabled
6162d4886179SRui Paulo  * @IWM_STA_FLG_PS: set if STA is in Power Save
6163d4886179SRui Paulo  * @IWM_STA_FLG_INVALID: set if STA is invalid
6164d4886179SRui Paulo  * @IWM_STA_FLG_DLP_EN: Direct Link Protocol is enabled
6165d4886179SRui Paulo  * @IWM_STA_FLG_SET_ALL_KEYS: the current key applies to all key IDs
6166d4886179SRui Paulo  * @IWM_STA_FLG_DRAIN_FLOW: drain flow
6167d4886179SRui Paulo  * @IWM_STA_FLG_PAN: STA is for PAN interface
6168d4886179SRui Paulo  * @IWM_STA_FLG_CLASS_AUTH:
6169d4886179SRui Paulo  * @IWM_STA_FLG_CLASS_ASSOC:
6170d4886179SRui Paulo  * @IWM_STA_FLG_CLASS_MIMO_PROT:
6171d4886179SRui Paulo  * @IWM_STA_FLG_MAX_AGG_SIZE_MSK: maximal size for A-MPDU
6172d4886179SRui Paulo  * @IWM_STA_FLG_AGG_MPDU_DENS_MSK: maximal MPDU density for Tx aggregation
6173d4886179SRui Paulo  * @IWM_STA_FLG_FAT_EN_MSK: support for channel width (for Tx). This flag is
6174d4886179SRui Paulo  *	initialised by driver and can be updated by fw upon reception of
6175d4886179SRui Paulo  *	action frames that can change the channel width. When cleared the fw
6176d4886179SRui Paulo  *	will send all the frames in 20MHz even when FAT channel is requested.
6177d4886179SRui Paulo  * @IWM_STA_FLG_MIMO_EN_MSK: support for MIMO. This flag is initialised by the
6178d4886179SRui Paulo  *	driver and can be updated by fw upon reception of action frames.
6179d4886179SRui Paulo  * @IWM_STA_FLG_MFP_EN: Management Frame Protection
6180d4886179SRui Paulo  */
6181355c1513SAdrian Chadd #define IWM_STA_FLG_REDUCED_TX_PWR_CTRL	(1 << 3)
6182355c1513SAdrian Chadd #define IWM_STA_FLG_REDUCED_TX_PWR_DATA	(1 << 6)
6183d4886179SRui Paulo 
6184355c1513SAdrian Chadd #define IWM_STA_FLG_DISABLE_TX		(1 << 4)
6185d4886179SRui Paulo 
6186355c1513SAdrian Chadd #define IWM_STA_FLG_PS			(1 << 8)
6187355c1513SAdrian Chadd #define IWM_STA_FLG_DRAIN_FLOW		(1 << 12)
6188355c1513SAdrian Chadd #define IWM_STA_FLG_PAN			(1 << 13)
6189355c1513SAdrian Chadd #define IWM_STA_FLG_CLASS_AUTH		(1 << 14)
6190355c1513SAdrian Chadd #define IWM_STA_FLG_CLASS_ASSOC		(1 << 15)
6191355c1513SAdrian Chadd #define IWM_STA_FLG_RTS_MIMO_PROT	(1 << 17)
6192d4886179SRui Paulo 
6193355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_SHIFT	19
6194355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_8K	(0 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6195355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_16K	(1 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6196355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_32K	(2 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6197355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_64K	(3 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6198355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_128K	(4 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6199355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_256K	(5 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6200355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_512K	(6 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6201355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_1024K	(7 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6202355c1513SAdrian Chadd #define IWM_STA_FLG_MAX_AGG_SIZE_MSK	(7 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT)
6203d4886179SRui Paulo 
6204355c1513SAdrian Chadd #define IWM_STA_FLG_AGG_MPDU_DENS_SHIFT	23
6205355c1513SAdrian Chadd #define IWM_STA_FLG_AGG_MPDU_DENS_2US	(4 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT)
6206355c1513SAdrian Chadd #define IWM_STA_FLG_AGG_MPDU_DENS_4US	(5 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT)
6207355c1513SAdrian Chadd #define IWM_STA_FLG_AGG_MPDU_DENS_8US	(6 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT)
6208355c1513SAdrian Chadd #define IWM_STA_FLG_AGG_MPDU_DENS_16US	(7 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT)
6209355c1513SAdrian Chadd #define IWM_STA_FLG_AGG_MPDU_DENS_MSK	(7 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT)
6210d4886179SRui Paulo 
6211355c1513SAdrian Chadd #define IWM_STA_FLG_FAT_EN_20MHZ	(0 << 26)
6212355c1513SAdrian Chadd #define IWM_STA_FLG_FAT_EN_40MHZ	(1 << 26)
6213355c1513SAdrian Chadd #define IWM_STA_FLG_FAT_EN_80MHZ	(2 << 26)
6214355c1513SAdrian Chadd #define IWM_STA_FLG_FAT_EN_160MHZ	(3 << 26)
6215355c1513SAdrian Chadd #define IWM_STA_FLG_FAT_EN_MSK		(3 << 26)
6216d4886179SRui Paulo 
6217355c1513SAdrian Chadd #define IWM_STA_FLG_MIMO_EN_SISO	(0 << 28)
6218355c1513SAdrian Chadd #define IWM_STA_FLG_MIMO_EN_MIMO2	(1 << 28)
6219355c1513SAdrian Chadd #define IWM_STA_FLG_MIMO_EN_MIMO3	(2 << 28)
6220355c1513SAdrian Chadd #define IWM_STA_FLG_MIMO_EN_MSK		(3 << 28)
6221d4886179SRui Paulo 
6222d4886179SRui Paulo /**
6223355c1513SAdrian Chadd  * key flags for the ADD_STA host command
6224d4886179SRui Paulo  * @IWM_STA_KEY_FLG_NO_ENC: no encryption
6225d4886179SRui Paulo  * @IWM_STA_KEY_FLG_WEP: WEP encryption algorithm
6226d4886179SRui Paulo  * @IWM_STA_KEY_FLG_CCM: CCMP encryption algorithm
6227d4886179SRui Paulo  * @IWM_STA_KEY_FLG_TKIP: TKIP encryption algorithm
6228d4886179SRui Paulo  * @IWM_STA_KEY_FLG_EXT: extended cipher algorithm (depends on the FW support)
6229d4886179SRui Paulo  * @IWM_STA_KEY_FLG_CMAC: CMAC encryption algorithm
6230d4886179SRui Paulo  * @IWM_STA_KEY_FLG_ENC_UNKNOWN: unknown encryption algorithm
6231d4886179SRui Paulo  * @IWM_STA_KEY_FLG_EN_MSK: mask for encryption algorithmi value
6232d4886179SRui Paulo  * @IWM_STA_KEY_FLG_WEP_KEY_MAP: wep is either a group key (0 - legacy WEP) or from
6233d4886179SRui Paulo  *	station info array (1 - n 1X mode)
6234d4886179SRui Paulo  * @IWM_STA_KEY_FLG_KEYID_MSK: the index of the key
6235d4886179SRui Paulo  * @IWM_STA_KEY_NOT_VALID: key is invalid
6236d4886179SRui Paulo  * @IWM_STA_KEY_FLG_WEP_13BYTES: set for 13 bytes WEP key
6237355c1513SAdrian Chadd  * @IWM_STA_KEY_MULTICAST: set for multicast key
6238d4886179SRui Paulo  * @IWM_STA_KEY_MFP: key is used for Management Frame Protection
6239d4886179SRui Paulo  */
6240355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_NO_ENC		(0 << 0)
6241355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_WEP		(1 << 0)
6242355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_CCM		(2 << 0)
6243355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_TKIP		(3 << 0)
6244355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_EXT		(4 << 0)
6245355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_CMAC		(6 << 0)
6246355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_ENC_UNKNOWN	(7 << 0)
6247355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_EN_MSK		(7 << 0)
6248355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_WEP_KEY_MAP	(1 << 3)
6249355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_KEYID_POS	8
6250355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_KEYID_MSK	(3 << IWM_STA_KEY_FLG_KEYID_POS)
6251355c1513SAdrian Chadd #define IWM_STA_KEY_NOT_VALID		(1 << 11)
6252355c1513SAdrian Chadd #define IWM_STA_KEY_FLG_WEP_13BYTES	(1 << 12)
6253355c1513SAdrian Chadd #define IWM_STA_KEY_MULTICAST		(1 << 14)
6254355c1513SAdrian Chadd #define IWM_STA_KEY_MFP			(1 << 15)
6255d4886179SRui Paulo 
6256d4886179SRui Paulo /**
6257355c1513SAdrian Chadd  * indicate to the fw what flag are being changed
62586a5bc1d1SSean Bruno  * @IWM_STA_MODIFY_QUEUE_REMOVAL: this command removes a queue
6259d4886179SRui Paulo  * @IWM_STA_MODIFY_TID_DISABLE_TX: this command modifies %tid_disable_tx
6260d4886179SRui Paulo  * @IWM_STA_MODIFY_TX_RATE: unused
6261d4886179SRui Paulo  * @IWM_STA_MODIFY_ADD_BA_TID: this command modifies %add_immediate_ba_tid
6262d4886179SRui Paulo  * @IWM_STA_MODIFY_REMOVE_BA_TID: this command modifies %remove_immediate_ba_tid
6263d4886179SRui Paulo  * @IWM_STA_MODIFY_SLEEPING_STA_TX_COUNT: this command modifies %sleep_tx_count
6264d4886179SRui Paulo  * @IWM_STA_MODIFY_PROT_TH:
6265d4886179SRui Paulo  * @IWM_STA_MODIFY_QUEUES: modify the queues used by this station
6266d4886179SRui Paulo  */
6267355c1513SAdrian Chadd #define IWM_STA_MODIFY_QUEUE_REMOVAL		(1 << 0)
6268355c1513SAdrian Chadd #define IWM_STA_MODIFY_TID_DISABLE_TX		(1 << 1)
6269355c1513SAdrian Chadd #define IWM_STA_MODIFY_TX_RATE			(1 << 2)
6270355c1513SAdrian Chadd #define IWM_STA_MODIFY_ADD_BA_TID		(1 << 3)
6271355c1513SAdrian Chadd #define IWM_STA_MODIFY_REMOVE_BA_TID		(1 << 4)
6272355c1513SAdrian Chadd #define IWM_STA_MODIFY_SLEEPING_STA_TX_COUNT	(1 << 5)
6273355c1513SAdrian Chadd #define IWM_STA_MODIFY_PROT_TH			(1 << 6)
6274355c1513SAdrian Chadd #define IWM_STA_MODIFY_QUEUES			(1 << 7)
6275d4886179SRui Paulo 
6276d4886179SRui Paulo #define IWM_STA_MODE_MODIFY	1
6277d4886179SRui Paulo 
6278d4886179SRui Paulo /**
6279355c1513SAdrian Chadd  * type of sleep of the station
6280d4886179SRui Paulo  * @IWM_STA_SLEEP_STATE_AWAKE:
6281d4886179SRui Paulo  * @IWM_STA_SLEEP_STATE_PS_POLL:
6282d4886179SRui Paulo  * @IWM_STA_SLEEP_STATE_UAPSD:
62836a5bc1d1SSean Bruno  * @IWM_STA_SLEEP_STATE_MOREDATA: set more-data bit on
62846a5bc1d1SSean Bruno  *	(last) released frame
6285d4886179SRui Paulo  */
6286355c1513SAdrian Chadd #define IWM_STA_SLEEP_STATE_AWAKE	0
6287355c1513SAdrian Chadd #define IWM_STA_SLEEP_STATE_PS_POLL	(1 << 0)
6288355c1513SAdrian Chadd #define IWM_STA_SLEEP_STATE_UAPSD	(1 << 1)
6289355c1513SAdrian Chadd #define IWM_STA_SLEEP_STATE_MOREDATA	(1 << 2)
6290d4886179SRui Paulo 
6291d4886179SRui Paulo /* STA ID and color bits definitions */
6292d4886179SRui Paulo #define IWM_STA_ID_SEED		(0x0f)
6293d4886179SRui Paulo #define IWM_STA_ID_POS		(0)
6294d4886179SRui Paulo #define IWM_STA_ID_MSK		(IWM_STA_ID_SEED << IWM_STA_ID_POS)
6295d4886179SRui Paulo 
6296d4886179SRui Paulo #define IWM_STA_COLOR_SEED	(0x7)
6297d4886179SRui Paulo #define IWM_STA_COLOR_POS	(4)
6298d4886179SRui Paulo #define IWM_STA_COLOR_MSK	(IWM_STA_COLOR_SEED << IWM_STA_COLOR_POS)
6299d4886179SRui Paulo 
6300d4886179SRui Paulo #define IWM_STA_ID_N_COLOR_GET_COLOR(id_n_color) \
6301d4886179SRui Paulo 	(((id_n_color) & IWM_STA_COLOR_MSK) >> IWM_STA_COLOR_POS)
6302d4886179SRui Paulo #define IWM_STA_ID_N_COLOR_GET_ID(id_n_color)    \
6303d4886179SRui Paulo 	(((id_n_color) & IWM_STA_ID_MSK) >> IWM_STA_ID_POS)
6304d4886179SRui Paulo 
6305d4886179SRui Paulo #define IWM_STA_KEY_MAX_NUM (16)
6306d4886179SRui Paulo #define IWM_STA_KEY_IDX_INVALID (0xff)
6307d4886179SRui Paulo #define IWM_STA_KEY_MAX_DATA_KEY_NUM (4)
6308d4886179SRui Paulo #define IWM_MAX_GLOBAL_KEYS (4)
6309d4886179SRui Paulo #define IWM_STA_KEY_LEN_WEP40 (5)
6310d4886179SRui Paulo #define IWM_STA_KEY_LEN_WEP104 (13)
6311d4886179SRui Paulo 
6312d4886179SRui Paulo /**
6313e7065dd1SMark Johnston  * struct iwm_keyinfo - key information
6314d4886179SRui Paulo  * @key_flags: type %iwm_sta_key_flag
6315d4886179SRui Paulo  * @tkip_rx_tsc_byte2: TSC[2] for key mix ph1 detection
6316d4886179SRui Paulo  * @tkip_rx_ttak: 10-byte unicast TKIP TTAK for Rx
6317d4886179SRui Paulo  * @key_offset: key offset in the fw's key table
6318d4886179SRui Paulo  * @key: 16-byte unicast decryption key
6319d4886179SRui Paulo  * @tx_secur_seq_cnt: initial RSC / PN needed for replay check
6320d4886179SRui Paulo  * @hw_tkip_mic_rx_key: byte: MIC Rx Key - used for TKIP only
6321d4886179SRui Paulo  * @hw_tkip_mic_tx_key: byte: MIC Tx Key - used for TKIP only
6322d4886179SRui Paulo  */
6323e7065dd1SMark Johnston struct iwm_keyinfo {
6324d4886179SRui Paulo 	uint16_t key_flags;
6325d4886179SRui Paulo 	uint8_t tkip_rx_tsc_byte2;
6326d4886179SRui Paulo 	uint8_t reserved1;
6327d4886179SRui Paulo 	uint16_t tkip_rx_ttak[5];
6328d4886179SRui Paulo 	uint8_t key_offset;
6329d4886179SRui Paulo 	uint8_t reserved2;
6330d4886179SRui Paulo 	uint8_t key[16];
6331d4886179SRui Paulo 	uint64_t tx_secur_seq_cnt;
6332d4886179SRui Paulo 	uint64_t hw_tkip_mic_rx_key;
6333d4886179SRui Paulo 	uint64_t hw_tkip_mic_tx_key;
6334d4886179SRui Paulo } __packed;
6335d4886179SRui Paulo 
63366a5bc1d1SSean Bruno #define IWM_ADD_STA_STATUS_MASK		0xFF
63376a5bc1d1SSean Bruno #define IWM_ADD_STA_BAID_VALID_MASK	0x8000
63386a5bc1d1SSean Bruno #define IWM_ADD_STA_BAID_MASK		0x7F00
63396a5bc1d1SSean Bruno #define IWM_ADD_STA_BAID_SHIFT		8
63406a5bc1d1SSean Bruno 
6341d4886179SRui Paulo /**
6342355c1513SAdrian Chadd  * struct iwm_add_sta_cmd_v7 - Add/modify a station in the fw's sta table.
63436a5bc1d1SSean Bruno  * ( REPLY_ADD_STA = 0x18 )
6344355c1513SAdrian Chadd  * @add_modify: 1: modify existing, 0: add new station
6345355c1513SAdrian Chadd  * @awake_acs:
63466a5bc1d1SSean Bruno  * @tid_disable_tx: is tid BIT(tid) enabled for Tx. Clear BIT(x) to enable
6347355c1513SAdrian Chadd  *	AMPDU for tid x. Set %IWM_STA_MODIFY_TID_DISABLE_TX to change this field.
6348355c1513SAdrian Chadd  * @mac_id_n_color: the Mac context this station belongs to
6349355c1513SAdrian Chadd  * @addr[ETHER_ADDR_LEN]: station's MAC address
6350d4886179SRui Paulo  * @sta_id: index of station in uCode's station table
6351355c1513SAdrian Chadd  * @modify_mask: IWM_STA_MODIFY_*, selects which parameters to modify vs. leave
6352d4886179SRui Paulo  *	alone. 1 - modify, 0 - don't change.
6353355c1513SAdrian Chadd  * @station_flags: look at %iwm_sta_flags
6354355c1513SAdrian Chadd  * @station_flags_msk: what of %station_flags have changed
6355d4886179SRui Paulo  * @add_immediate_ba_tid: tid for which to add block-ack support (Rx)
6356355c1513SAdrian Chadd  *	Set %IWM_STA_MODIFY_ADD_BA_TID to use this field, and also set
6357d4886179SRui Paulo  *	add_immediate_ba_ssn.
6358d4886179SRui Paulo  * @remove_immediate_ba_tid: tid for which to remove block-ack support (Rx)
6359355c1513SAdrian Chadd  *	Set %IWM_STA_MODIFY_REMOVE_BA_TID to use this field
6360d4886179SRui Paulo  * @add_immediate_ba_ssn: ssn for the Rx block-ack session. Used together with
6361d4886179SRui Paulo  *	add_immediate_ba_tid.
6362d4886179SRui Paulo  * @sleep_tx_count: number of packets to transmit to station even though it is
6363d4886179SRui Paulo  *	asleep. Used to synchronise PS-poll and u-APSD responses while ucode
6364d4886179SRui Paulo  *	keeps track of STA sleep state.
6365355c1513SAdrian Chadd  * @sleep_state_flags: Look at %iwm_sta_sleep_flag.
6366d4886179SRui Paulo  * @assoc_id: assoc_id to be sent in VHT PLCP (9-bit), for grp use 0, for AP
6367d4886179SRui Paulo  *	mac-addr.
6368d4886179SRui Paulo  * @beamform_flags: beam forming controls
6369d4886179SRui Paulo  * @tfd_queue_msk: tfd queues used by this station
6370d4886179SRui Paulo  *
6371d4886179SRui Paulo  * The device contains an internal table of per-station information, with info
6372d4886179SRui Paulo  * on security keys, aggregation parameters, and Tx rates for initial Tx
6373355c1513SAdrian Chadd  * attempt and any retries (set by IWM_REPLY_TX_LINK_QUALITY_CMD).
6374d4886179SRui Paulo  *
6375d4886179SRui Paulo  * ADD_STA sets up the table entry for one station, either creating a new
6376d4886179SRui Paulo  * entry, or modifying a pre-existing one.
6377d4886179SRui Paulo  */
6378e7065dd1SMark Johnston struct iwm_add_sta_cmd_v7 {
6379d4886179SRui Paulo 	uint8_t add_modify;
63806a5bc1d1SSean Bruno 	uint8_t awake_acs;
6381d4886179SRui Paulo 	uint16_t tid_disable_tx;
6382d4886179SRui Paulo 	uint32_t mac_id_n_color;
6383355c1513SAdrian Chadd 	uint8_t addr[ETHER_ADDR_LEN];	/* _STA_ID_MODIFY_INFO_API_S_VER_1 */
6384d4886179SRui Paulo 	uint16_t reserved2;
6385d4886179SRui Paulo 	uint8_t sta_id;
6386d4886179SRui Paulo 	uint8_t modify_mask;
6387d4886179SRui Paulo 	uint16_t reserved3;
6388d4886179SRui Paulo 	uint32_t station_flags;
6389d4886179SRui Paulo 	uint32_t station_flags_msk;
6390d4886179SRui Paulo 	uint8_t add_immediate_ba_tid;
6391d4886179SRui Paulo 	uint8_t remove_immediate_ba_tid;
6392d4886179SRui Paulo 	uint16_t add_immediate_ba_ssn;
6393d4886179SRui Paulo 	uint16_t sleep_tx_count;
6394d4886179SRui Paulo 	uint16_t sleep_state_flags;
6395d4886179SRui Paulo 	uint16_t assoc_id;
6396d4886179SRui Paulo 	uint16_t beamform_flags;
6397d4886179SRui Paulo 	uint32_t tfd_queue_msk;
63986a5bc1d1SSean Bruno } __packed; /* ADD_STA_CMD_API_S_VER_7 */
6399d4886179SRui Paulo 
6400d4886179SRui Paulo /**
6401e7065dd1SMark Johnston  * struct iwm_add_sta_cmd - Add/modify a station in the fw's sta table.
640209a07cd5SMark Johnston  * ( REPLY_ADD_STA = 0x18 )
6403355c1513SAdrian Chadd  * @add_modify: see &enum iwl_sta_mode
640409a07cd5SMark Johnston  * @awake_acs: ACs to transmit data on while station is sleeping (for U-APSD)
640509a07cd5SMark Johnston  * @tid_disable_tx: is tid BIT(tid) enabled for Tx. Clear BIT(x) to enable
640609a07cd5SMark Johnston  *	AMPDU for tid x. Set %STA_MODIFY_TID_DISABLE_TX to change this field.
640709a07cd5SMark Johnston  * @mac_id_n_color: the Mac context this station belongs to,
640809a07cd5SMark Johnston  *	see &enum iwl_ctxt_id_and_color
640909a07cd5SMark Johnston  * @addr: station's MAC address
641009a07cd5SMark Johnston  * @reserved2: reserved
641109a07cd5SMark Johnston  * @sta_id: index of station in uCode's station table
641209a07cd5SMark Johnston  * @modify_mask: STA_MODIFY_*, selects which parameters to modify vs. leave
641309a07cd5SMark Johnston  *	alone. 1 - modify, 0 - don't change.
641409a07cd5SMark Johnston  * @reserved3: reserved
6415355c1513SAdrian Chadd  * @station_flags: look at &enum iwl_sta_flags
641609a07cd5SMark Johnston  * @station_flags_msk: what of %station_flags have changed,
6417355c1513SAdrian Chadd  *	also &enum iwl_sta_flags
641809a07cd5SMark Johnston  * @add_immediate_ba_tid: tid for which to add block-ack support (Rx)
641909a07cd5SMark Johnston  *	Set %STA_MODIFY_ADD_BA_TID to use this field, and also set
642009a07cd5SMark Johnston  *	add_immediate_ba_ssn.
642109a07cd5SMark Johnston  * @remove_immediate_ba_tid: tid for which to remove block-ack support (Rx)
642209a07cd5SMark Johnston  *	Set %STA_MODIFY_REMOVE_BA_TID to use this field
642309a07cd5SMark Johnston  * @add_immediate_ba_ssn: ssn for the Rx block-ack session. Used together with
642409a07cd5SMark Johnston  *	add_immediate_ba_tid.
642509a07cd5SMark Johnston  * @sleep_tx_count: number of packets to transmit to station even though it is
642609a07cd5SMark Johnston  *	asleep. Used to synchronise PS-poll and u-APSD responses while ucode
642709a07cd5SMark Johnston  *	keeps track of STA sleep state.
642809a07cd5SMark Johnston  * @station_type: type of this station. See &enum iwl_sta_type.
642909a07cd5SMark Johnston  * @sleep_state_flags: Look at &enum iwl_sta_sleep_flag.
643009a07cd5SMark Johnston  * @assoc_id: assoc_id to be sent in VHT PLCP (9-bit), for grp use 0, for AP
643109a07cd5SMark Johnston  *	mac-addr.
643209a07cd5SMark Johnston  * @beamform_flags: beam forming controls
643309a07cd5SMark Johnston  * @tfd_queue_msk: tfd queues used by this station.
643409a07cd5SMark Johnston  *	Obselete for new TX API (9 and above).
643509a07cd5SMark Johnston  * @rx_ba_window: aggregation window size
643609a07cd5SMark Johnston  * @sp_length: the size of the SP in actual number of frames
643709a07cd5SMark Johnston  * @uapsd_acs:  4 LS bits are trigger enabled ACs, 4 MS bits are the deliver
643809a07cd5SMark Johnston  *	enabled ACs.
643909a07cd5SMark Johnston  *
644009a07cd5SMark Johnston  * The device contains an internal table of per-station information, with info
644109a07cd5SMark Johnston  * on security keys, aggregation parameters, and Tx rates for initial Tx
644209a07cd5SMark Johnston  * attempt and any retries (set by REPLY_TX_LINK_QUALITY_CMD).
644309a07cd5SMark Johnston  *
644409a07cd5SMark Johnston  * ADD_STA sets up the table entry for one station, either creating a new
644509a07cd5SMark Johnston  * entry, or modifying a pre-existing one.
644609a07cd5SMark Johnston  */
6447e7065dd1SMark Johnston struct iwm_add_sta_cmd {
644809a07cd5SMark Johnston 	uint8_t add_modify;
644909a07cd5SMark Johnston 	uint8_t awake_acs;
645009a07cd5SMark Johnston 	uint16_t tid_disable_tx;
645109a07cd5SMark Johnston 	uint32_t mac_id_n_color;
6452355c1513SAdrian Chadd 	uint8_t addr[ETHER_ADDR_LEN];	/* _STA_ID_MODIFY_INFO_API_S_VER_1 */
645309a07cd5SMark Johnston 	uint16_t reserved2;
645409a07cd5SMark Johnston 	uint8_t sta_id;
645509a07cd5SMark Johnston 	uint8_t modify_mask;
645609a07cd5SMark Johnston 	uint16_t reserved3;
645709a07cd5SMark Johnston 	uint32_t station_flags;
645809a07cd5SMark Johnston 	uint32_t station_flags_msk;
645909a07cd5SMark Johnston 	uint8_t add_immediate_ba_tid;
646009a07cd5SMark Johnston 	uint8_t remove_immediate_ba_tid;
646109a07cd5SMark Johnston 	uint16_t add_immediate_ba_ssn;
646209a07cd5SMark Johnston 	uint16_t sleep_tx_count;
646309a07cd5SMark Johnston 	uint8_t sleep_state_flags;
646409a07cd5SMark Johnston 	uint8_t station_type;
646509a07cd5SMark Johnston 	uint16_t assoc_id;
646609a07cd5SMark Johnston 	uint16_t beamform_flags;
646709a07cd5SMark Johnston 	uint32_t tfd_queue_msk;
646809a07cd5SMark Johnston 	uint16_t rx_ba_window;
646909a07cd5SMark Johnston 	uint8_t sp_length;
647009a07cd5SMark Johnston 	uint8_t uapsd_acs;
647109a07cd5SMark Johnston } __packed; /* ADD_STA_CMD_API_S_VER_10 */
647209a07cd5SMark Johnston 
647309a07cd5SMark Johnston /**
6474355c1513SAdrian Chadd  * FW station types
6475355c1513SAdrian Chadd  * ( REPLY_ADD_STA = 0x18 )
6476355c1513SAdrian Chadd  * @IWM_STA_LINK: Link station - normal RX and TX traffic.
6477355c1513SAdrian Chadd  * @IWM_STA_GENERAL_PURPOSE: General purpose. In AP mode used for beacons
6478355c1513SAdrian Chadd  *	and probe responses.
6479355c1513SAdrian Chadd  * @IWM_STA_MULTICAST: multicast traffic,
6480355c1513SAdrian Chadd  * @IWM_STA_TDLS_LINK: TDLS link station
6481355c1513SAdrian Chadd  * @IWM_STA_AUX_ACTIVITY: auxilary station (scan, ROC and so on).
6482355c1513SAdrian Chadd  */
6483355c1513SAdrian Chadd #define IWM_STA_LINK		0
6484355c1513SAdrian Chadd #define IWM_STA_GENERAL_PURPOSE	1
6485355c1513SAdrian Chadd #define IWM_STA_MULTICAST	2
6486355c1513SAdrian Chadd #define IWM_STA_TDLS_LINK	3
6487355c1513SAdrian Chadd #define IWM_STA_AUX_ACTIVITY	4
6488355c1513SAdrian Chadd 
6489355c1513SAdrian Chadd /**
6490355c1513SAdrian Chadd  * struct iwm_add_sta_key_common - add/modify sta key common part
6491355c1513SAdrian Chadd  * ( REPLY_ADD_STA_KEY = 0x17 )
6492d4886179SRui Paulo  * @sta_id: index of station in uCode's station table
6493d4886179SRui Paulo  * @key_offset: key offset in key storage
6494355c1513SAdrian Chadd  * @key_flags: IWM_STA_KEY_FLG_*
6495d4886179SRui Paulo  * @key: key material data
6496d4886179SRui Paulo  * @rx_secur_seq_cnt: RX security sequence counter for the key
6497d4886179SRui Paulo  */
6498355c1513SAdrian Chadd struct iwm_add_sta_key_common {
6499d4886179SRui Paulo 	uint8_t sta_id;
6500d4886179SRui Paulo 	uint8_t key_offset;
6501d4886179SRui Paulo 	uint16_t key_flags;
6502355c1513SAdrian Chadd 	uint8_t key[32];
6503d4886179SRui Paulo 	uint8_t rx_secur_seq_cnt[16];
6504355c1513SAdrian Chadd } __packed;
6505355c1513SAdrian Chadd 
6506355c1513SAdrian Chadd /**
6507355c1513SAdrian Chadd  * struct iwm_add_sta_key_cmd_v1 - add/modify sta key
6508355c1513SAdrian Chadd  * @common: see &struct iwm_add_sta_key_common
6509355c1513SAdrian Chadd  * @tkip_rx_tsc_byte2: TSC[2] for key mix ph1 detection
6510355c1513SAdrian Chadd  * @reserved: reserved
6511355c1513SAdrian Chadd  * @tkip_rx_ttak: 10-byte unicast TKIP TTAK for Rx
6512355c1513SAdrian Chadd  */
6513355c1513SAdrian Chadd struct iwm_add_sta_key_cmd_v1 {
6514355c1513SAdrian Chadd 	struct iwm_add_sta_key_common common;
6515d4886179SRui Paulo 	uint8_t tkip_rx_tsc_byte2;
6516d4886179SRui Paulo 	uint8_t reserved;
6517d4886179SRui Paulo 	uint16_t tkip_rx_ttak[5];
6518355c1513SAdrian Chadd } __packed; /* ADD_MODIFY_STA_KEY_API_S_VER_1 */
6519d4886179SRui Paulo 
6520d4886179SRui Paulo /**
6521355c1513SAdrian Chadd  * struct iwm_add_sta_key_cmd - add/modify sta key
6522355c1513SAdrian Chadd  * @common: see &struct iwm_add_sta_key_common
6523355c1513SAdrian Chadd  * @rx_mic_key: TKIP RX unicast or multicast key
6524355c1513SAdrian Chadd  * @tx_mic_key: TKIP TX key
6525355c1513SAdrian Chadd  * @transmit_seq_cnt: TSC, transmit packet number
6526355c1513SAdrian Chadd  */
6527355c1513SAdrian Chadd struct iwm_add_sta_key_cmd {
6528355c1513SAdrian Chadd 	struct iwm_add_sta_key_common common;
6529355c1513SAdrian Chadd 	uint64_t rx_mic_key;
6530355c1513SAdrian Chadd 	uint64_t tx_mic_key;
6531355c1513SAdrian Chadd 	uint64_t transmit_seq_cnt;
6532355c1513SAdrian Chadd } __packed; /* ADD_MODIFY_STA_KEY_API_S_VER_2 */
6533355c1513SAdrian Chadd 
6534355c1513SAdrian Chadd /**
6535355c1513SAdrian Chadd  * status in the response to ADD_STA command
6536d4886179SRui Paulo  * @IWM_ADD_STA_SUCCESS: operation was executed successfully
6537d4886179SRui Paulo  * @IWM_ADD_STA_STATIONS_OVERLOAD: no room left in the fw's station table
6538d4886179SRui Paulo  * @IWM_ADD_STA_IMMEDIATE_BA_FAILURE: can't add Rx block ack session
6539d4886179SRui Paulo  * @IWM_ADD_STA_MODIFY_NON_EXISTING_STA: driver requested to modify a station
6540d4886179SRui Paulo  *	that doesn't exist.
6541d4886179SRui Paulo  */
6542355c1513SAdrian Chadd #define IWM_ADD_STA_SUCCESS			0x1
6543355c1513SAdrian Chadd #define IWM_ADD_STA_STATIONS_OVERLOAD		0x2
6544355c1513SAdrian Chadd #define IWM_ADD_STA_IMMEDIATE_BA_FAILURE	0x4
6545355c1513SAdrian Chadd #define IWM_ADD_STA_MODIFY_NON_EXISTING_STA	0x8
6546d4886179SRui Paulo 
6547d4886179SRui Paulo /**
6548e7065dd1SMark Johnston  * struct iwm_rm_sta_cmd - Add / modify a station in the fw's station table
6549d4886179SRui Paulo  * ( IWM_REMOVE_STA = 0x19 )
6550d4886179SRui Paulo  * @sta_id: the station id of the station to be removed
6551d4886179SRui Paulo  */
6552e7065dd1SMark Johnston struct iwm_rm_sta_cmd {
6553d4886179SRui Paulo 	uint8_t sta_id;
6554d4886179SRui Paulo 	uint8_t reserved[3];
6555d4886179SRui Paulo } __packed; /* IWM_REMOVE_STA_CMD_API_S_VER_2 */
6556d4886179SRui Paulo 
6557d4886179SRui Paulo /**
6558e7065dd1SMark Johnston  * struct iwm_mgmt_mcast_key_cmd
6559d4886179SRui Paulo  * ( IWM_MGMT_MCAST_KEY = 0x1f )
6560d4886179SRui Paulo  * @ctrl_flags: %iwm_sta_key_flag
6561d4886179SRui Paulo  * @IGTK:
6562d4886179SRui Paulo  * @K1: IGTK master key
6563d4886179SRui Paulo  * @K2: IGTK sub key
6564d4886179SRui Paulo  * @sta_id: station ID that support IGTK
6565d4886179SRui Paulo  * @key_id:
6566d4886179SRui Paulo  * @receive_seq_cnt: initial RSC/PN needed for replay check
6567d4886179SRui Paulo  */
6568e7065dd1SMark Johnston struct iwm_mgmt_mcast_key_cmd {
6569d4886179SRui Paulo 	uint32_t ctrl_flags;
6570d4886179SRui Paulo 	uint8_t IGTK[16];
6571d4886179SRui Paulo 	uint8_t K1[16];
6572d4886179SRui Paulo 	uint8_t K2[16];
6573d4886179SRui Paulo 	uint32_t key_id;
6574d4886179SRui Paulo 	uint32_t sta_id;
6575d4886179SRui Paulo 	uint64_t receive_seq_cnt;
6576d4886179SRui Paulo } __packed; /* SEC_MGMT_MULTICAST_KEY_CMD_API_S_VER_1 */
6577d4886179SRui Paulo 
6578e7065dd1SMark Johnston struct iwm_wep_key {
6579d4886179SRui Paulo 	uint8_t key_index;
6580d4886179SRui Paulo 	uint8_t key_offset;
6581d4886179SRui Paulo 	uint16_t reserved1;
6582d4886179SRui Paulo 	uint8_t key_size;
6583d4886179SRui Paulo 	uint8_t reserved2[3];
6584d4886179SRui Paulo 	uint8_t key[16];
6585d4886179SRui Paulo } __packed;
6586d4886179SRui Paulo 
6587e7065dd1SMark Johnston struct iwm_wep_key_cmd {
6588d4886179SRui Paulo 	uint32_t mac_id_n_color;
6589d4886179SRui Paulo 	uint8_t num_keys;
6590d4886179SRui Paulo 	uint8_t decryption_type;
6591d4886179SRui Paulo 	uint8_t flags;
6592d4886179SRui Paulo 	uint8_t reserved;
6593e7065dd1SMark Johnston 	struct iwm_wep_key wep_key[0];
6594d4886179SRui Paulo } __packed; /* SEC_CURR_WEP_KEY_CMD_API_S_VER_2 */
6595d4886179SRui Paulo 
6596d4886179SRui Paulo /*
65976a5bc1d1SSean Bruno  * BT coex
65986a5bc1d1SSean Bruno  */
65996a5bc1d1SSean Bruno 
6600355c1513SAdrian Chadd #define IWM_BT_COEX_DISABLE		0x0
6601355c1513SAdrian Chadd #define IWM_BT_COEX_NW			0x1
6602355c1513SAdrian Chadd #define IWM_BT_COEX_BT			0x2
6603355c1513SAdrian Chadd #define IWM_BT_COEX_WIFI		0x3
6604355c1513SAdrian Chadd /* BT_COEX_MODES_E */
66056a5bc1d1SSean Bruno 
6606355c1513SAdrian Chadd #define IWM_BT_COEX_MPLUT_ENABLED	(1 << 0)
6607355c1513SAdrian Chadd #define IWM_BT_COEX_MPLUT_BOOST_ENABLED	(1 << 1)
6608355c1513SAdrian Chadd #define IWM_BT_COEX_SYNC2SCO_ENABLED	(1 << 2)
6609355c1513SAdrian Chadd #define IWM_BT_COEX_CORUN_ENABLED	(1 << 3)
6610355c1513SAdrian Chadd #define IWM_BT_COEX_HIGH_BAND_RET	(1 << 4)
6611355c1513SAdrian Chadd /* BT_COEX_MODULES_ENABLE_E_VER_1 */
66126a5bc1d1SSean Bruno 
66136a5bc1d1SSean Bruno /**
66146a5bc1d1SSean Bruno  * struct iwm_bt_coex_cmd - bt coex configuration command
66156a5bc1d1SSean Bruno  * @mode: enum %iwm_bt_coex_mode
66166a5bc1d1SSean Bruno  * @enabled_modules: enum %iwm_bt_coex_enabled_modules
66176a5bc1d1SSean Bruno  *
66186a5bc1d1SSean Bruno  * The structure is used for the BT_COEX command.
66196a5bc1d1SSean Bruno  */
66206a5bc1d1SSean Bruno struct iwm_bt_coex_cmd {
66216a5bc1d1SSean Bruno 	uint32_t mode;
66226a5bc1d1SSean Bruno 	uint32_t enabled_modules;
66236a5bc1d1SSean Bruno } __packed; /* BT_COEX_CMD_API_S_VER_6 */
66246a5bc1d1SSean Bruno 
66256a5bc1d1SSean Bruno 
66266a5bc1d1SSean Bruno /*
66276a5bc1d1SSean Bruno  * Location Aware Regulatory (LAR) API - MCC updates
66286a5bc1d1SSean Bruno  */
66296a5bc1d1SSean Bruno 
66306a5bc1d1SSean Bruno /**
66316a5bc1d1SSean Bruno  * struct iwm_mcc_update_cmd_v1 - Request the device to update geographic
66326a5bc1d1SSean Bruno  * regulatory profile according to the given MCC (Mobile Country Code).
66336a5bc1d1SSean Bruno  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
66346a5bc1d1SSean Bruno  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
66356a5bc1d1SSean Bruno  * MCC in the cmd response will be the relevant MCC in the NVM.
66366a5bc1d1SSean Bruno  * @mcc: given mobile country code
66376a5bc1d1SSean Bruno  * @source_id: the source from where we got the MCC, see iwm_mcc_source
66386a5bc1d1SSean Bruno  * @reserved: reserved for alignment
66396a5bc1d1SSean Bruno  */
66406a5bc1d1SSean Bruno struct iwm_mcc_update_cmd_v1 {
66416a5bc1d1SSean Bruno 	uint16_t mcc;
66426a5bc1d1SSean Bruno 	uint8_t source_id;
66436a5bc1d1SSean Bruno 	uint8_t reserved;
66446a5bc1d1SSean Bruno } __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_1 */
66456a5bc1d1SSean Bruno 
66466a5bc1d1SSean Bruno /**
66476a5bc1d1SSean Bruno  * struct iwm_mcc_update_cmd - Request the device to update geographic
66486a5bc1d1SSean Bruno  * regulatory profile according to the given MCC (Mobile Country Code).
66496a5bc1d1SSean Bruno  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
66506a5bc1d1SSean Bruno  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
66516a5bc1d1SSean Bruno  * MCC in the cmd response will be the relevant MCC in the NVM.
66526a5bc1d1SSean Bruno  * @mcc: given mobile country code
66536a5bc1d1SSean Bruno  * @source_id: the source from where we got the MCC, see iwm_mcc_source
66546a5bc1d1SSean Bruno  * @reserved: reserved for alignment
66556a5bc1d1SSean Bruno  * @key: integrity key for MCC API OEM testing
66566a5bc1d1SSean Bruno  * @reserved2: reserved
66576a5bc1d1SSean Bruno  */
66586a5bc1d1SSean Bruno struct iwm_mcc_update_cmd {
66596a5bc1d1SSean Bruno 	uint16_t mcc;
66606a5bc1d1SSean Bruno 	uint8_t source_id;
66616a5bc1d1SSean Bruno 	uint8_t reserved;
66626a5bc1d1SSean Bruno 	uint32_t key;
66636a5bc1d1SSean Bruno 	uint32_t reserved2[5];
66646a5bc1d1SSean Bruno } __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_2 */
66656a5bc1d1SSean Bruno 
66666a5bc1d1SSean Bruno /**
66676a5bc1d1SSean Bruno  * iwm_mcc_update_resp_v1  - response to MCC_UPDATE_CMD.
66686a5bc1d1SSean Bruno  * Contains the new channel control profile map, if changed, and the new MCC
66696a5bc1d1SSean Bruno  * (mobile country code).
66706a5bc1d1SSean Bruno  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
66716a5bc1d1SSean Bruno  * @status: see &enum iwm_mcc_update_status
66726a5bc1d1SSean Bruno  * @mcc: the new applied MCC
66736a5bc1d1SSean Bruno  * @cap: capabilities for all channels which matches the MCC
66746a5bc1d1SSean Bruno  * @source_id: the MCC source, see iwm_mcc_source
66756a5bc1d1SSean Bruno  * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
66766a5bc1d1SSean Bruno  *		channels, depending on platform)
66776a5bc1d1SSean Bruno  * @channels: channel control data map, DWORD for each channel. Only the first
66786a5bc1d1SSean Bruno  *	16bits are used.
66796a5bc1d1SSean Bruno  */
66806a5bc1d1SSean Bruno struct iwm_mcc_update_resp_v1  {
66816a5bc1d1SSean Bruno 	uint32_t status;
66826a5bc1d1SSean Bruno 	uint16_t mcc;
66836a5bc1d1SSean Bruno 	uint8_t cap;
66846a5bc1d1SSean Bruno 	uint8_t source_id;
66856a5bc1d1SSean Bruno 	uint32_t n_channels;
66866a5bc1d1SSean Bruno 	uint32_t channels[0];
66876a5bc1d1SSean Bruno } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_1 */
66886a5bc1d1SSean Bruno 
66896a5bc1d1SSean Bruno /**
6690355c1513SAdrian Chadd  * iwm_mcc_update_resp_v2 - response to MCC_UPDATE_CMD.
66916a5bc1d1SSean Bruno  * Contains the new channel control profile map, if changed, and the new MCC
66926a5bc1d1SSean Bruno  * (mobile country code).
66936a5bc1d1SSean Bruno  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
66946a5bc1d1SSean Bruno  * @status: see &enum iwm_mcc_update_status
66956a5bc1d1SSean Bruno  * @mcc: the new applied MCC
66966a5bc1d1SSean Bruno  * @cap: capabilities for all channels which matches the MCC
66976a5bc1d1SSean Bruno  * @source_id: the MCC source, see iwm_mcc_source
66986a5bc1d1SSean Bruno  * @time: time elapsed from the MCC test start (in 30 seconds TU)
66996a5bc1d1SSean Bruno  * @reserved: reserved.
67006a5bc1d1SSean Bruno  * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
67016a5bc1d1SSean Bruno  *		channels, depending on platform)
67026a5bc1d1SSean Bruno  * @channels: channel control data map, DWORD for each channel. Only the first
67036a5bc1d1SSean Bruno  *	16bits are used.
67046a5bc1d1SSean Bruno  */
6705355c1513SAdrian Chadd struct iwm_mcc_update_resp_v2 {
67066a5bc1d1SSean Bruno 	uint32_t status;
67076a5bc1d1SSean Bruno 	uint16_t mcc;
67086a5bc1d1SSean Bruno 	uint8_t cap;
67096a5bc1d1SSean Bruno 	uint8_t source_id;
67106a5bc1d1SSean Bruno 	uint16_t time;
67116a5bc1d1SSean Bruno 	uint16_t reserved;
67126a5bc1d1SSean Bruno 	uint32_t n_channels;
67136a5bc1d1SSean Bruno 	uint32_t channels[0];
67146a5bc1d1SSean Bruno } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_2 */
67156a5bc1d1SSean Bruno 
6716355c1513SAdrian Chadd #define IWM_GEO_NO_INFO			0
6717355c1513SAdrian Chadd #define IWM_GEO_WMM_ETSI_5GHZ_INFO	(1 << 0)
6718355c1513SAdrian Chadd 
6719355c1513SAdrian Chadd /**
6720355c1513SAdrian Chadd  * iwm_mcc_update_resp_v3 - response to MCC_UPDATE_CMD.
6721355c1513SAdrian Chadd  * Contains the new channel control profile map, if changed, and the new MCC
6722355c1513SAdrian Chadd  * (mobile country code).
6723355c1513SAdrian Chadd  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
6724355c1513SAdrian Chadd  * @status: see &enum iwm_mcc_update_status
6725355c1513SAdrian Chadd  * @mcc: the new applied MCC
6726355c1513SAdrian Chadd  * @cap: capabilities for all channels which matches the MCC
6727355c1513SAdrian Chadd  * @source_id: the MCC source, see IWM_MCC_SOURCE_*
6728355c1513SAdrian Chadd  * @time: time elapsed from the MCC test start (in 30 seconds TU)
6729355c1513SAdrian Chadd  * @geo_info: geographic specific profile information
6730355c1513SAdrian Chadd  * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
6731355c1513SAdrian Chadd  *		channels, depending on platform)
6732355c1513SAdrian Chadd  * @channels: channel control data map, DWORD for each channel. Only the first
6733355c1513SAdrian Chadd  *	16bits are used.
6734355c1513SAdrian Chadd  */
6735355c1513SAdrian Chadd struct iwm_mcc_update_resp_v3 {
6736355c1513SAdrian Chadd 	uint32_t status;
6737355c1513SAdrian Chadd 	uint16_t mcc;
6738355c1513SAdrian Chadd 	uint8_t cap;
6739355c1513SAdrian Chadd 	uint8_t source_id;
6740355c1513SAdrian Chadd 	uint16_t time;
6741355c1513SAdrian Chadd 	uint16_t geo_info;
6742355c1513SAdrian Chadd 	uint32_t n_channels;
6743355c1513SAdrian Chadd 	uint32_t channels[0];
6744355c1513SAdrian Chadd } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_3 */
6745355c1513SAdrian Chadd 
67466a5bc1d1SSean Bruno /**
67476a5bc1d1SSean Bruno  * struct iwm_mcc_chub_notif - chub notifies of mcc change
67486a5bc1d1SSean Bruno  * (MCC_CHUB_UPDATE_CMD = 0xc9)
67496a5bc1d1SSean Bruno  * The Chub (Communication Hub, CommsHUB) is a HW component that connects to
67506a5bc1d1SSean Bruno  * the cellular and connectivity cores that gets updates of the mcc, and
67516a5bc1d1SSean Bruno  * notifies the ucode directly of any mcc change.
67526a5bc1d1SSean Bruno  * The ucode requests the driver to request the device to update geographic
67536a5bc1d1SSean Bruno  * regulatory  profile according to the given MCC (Mobile Country Code).
67546a5bc1d1SSean Bruno  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
67556a5bc1d1SSean Bruno  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
67566a5bc1d1SSean Bruno  * MCC in the cmd response will be the relevant MCC in the NVM.
67576a5bc1d1SSean Bruno  * @mcc: given mobile country code
67586a5bc1d1SSean Bruno  * @source_id: identity of the change originator, see iwm_mcc_source
67596a5bc1d1SSean Bruno  * @reserved1: reserved for alignment
67606a5bc1d1SSean Bruno  */
67616a5bc1d1SSean Bruno struct iwm_mcc_chub_notif {
67626a5bc1d1SSean Bruno 	uint16_t mcc;
67636a5bc1d1SSean Bruno 	uint8_t source_id;
67646a5bc1d1SSean Bruno 	uint8_t reserved1;
67656a5bc1d1SSean Bruno } __packed; /* LAR_MCC_NOTIFY_S */
67666a5bc1d1SSean Bruno 
6767355c1513SAdrian Chadd #define IWM_MCC_RESP_NEW_CHAN_PROFILE			0
6768355c1513SAdrian Chadd #define IWM_MCC_RESP_SAME_CHAN_PROFILE			1
6769355c1513SAdrian Chadd #define IWM_MCC_RESP_INVALID				2
6770355c1513SAdrian Chadd #define IWM_MCC_RESP_NVM_DISABLED			3
6771355c1513SAdrian Chadd #define IWM_MCC_RESP_ILLEGAL				4
6772355c1513SAdrian Chadd #define IWM_MCC_RESP_LOW_PRIORITY			5
6773355c1513SAdrian Chadd #define IWM_MCC_RESP_TEST_MODE_ACTIVE			6
6774355c1513SAdrian Chadd #define IWM_MCC_RESP_TEST_MODE_NOT_ACTIVE		7
6775355c1513SAdrian Chadd #define IWM_MCC_RESP_TEST_MODE_DENIAL_OF_SERVICE	8
67766a5bc1d1SSean Bruno 
6777355c1513SAdrian Chadd #define IWM_MCC_SOURCE_OLD_FW			0
6778355c1513SAdrian Chadd #define IWM_MCC_SOURCE_ME			1
6779355c1513SAdrian Chadd #define IWM_MCC_SOURCE_BIOS			2
6780355c1513SAdrian Chadd #define IWM_MCC_SOURCE_3G_LTE_HOST		3
6781355c1513SAdrian Chadd #define IWM_MCC_SOURCE_3G_LTE_DEVICE		4
6782355c1513SAdrian Chadd #define IWM_MCC_SOURCE_WIFI			5
6783355c1513SAdrian Chadd #define IWM_MCC_SOURCE_RESERVED			6
6784355c1513SAdrian Chadd #define IWM_MCC_SOURCE_DEFAULT			7
6785355c1513SAdrian Chadd #define IWM_MCC_SOURCE_UNINITIALIZED		8
6786355c1513SAdrian Chadd #define IWM_MCC_SOURCE_MCC_API			9
6787355c1513SAdrian Chadd #define IWM_MCC_SOURCE_GET_CURRENT		0x10
6788355c1513SAdrian Chadd #define IWM_MCC_SOURCE_GETTING_MCC_TEST_MODE	0x11
67896a5bc1d1SSean Bruno 
6790a717dd3aSAdrian Chadd /**
6791a717dd3aSAdrian Chadd  * struct iwm_dts_measurement_notif_v1 - measurements notification
6792a717dd3aSAdrian Chadd  *
6793a717dd3aSAdrian Chadd  * @temp: the measured temperature
6794a717dd3aSAdrian Chadd  * @voltage: the measured voltage
6795a717dd3aSAdrian Chadd  */
6796a717dd3aSAdrian Chadd struct iwm_dts_measurement_notif_v1 {
6797a717dd3aSAdrian Chadd 	int32_t temp;
6798a717dd3aSAdrian Chadd 	int32_t voltage;
6799a717dd3aSAdrian Chadd } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S_VER_1*/
6800a717dd3aSAdrian Chadd 
6801a717dd3aSAdrian Chadd /**
6802a717dd3aSAdrian Chadd  * struct iwm_dts_measurement_notif_v2 - measurements notification
6803a717dd3aSAdrian Chadd  *
6804a717dd3aSAdrian Chadd  * @temp: the measured temperature
6805a717dd3aSAdrian Chadd  * @voltage: the measured voltage
6806a717dd3aSAdrian Chadd  * @threshold_idx: the trip index that was crossed
6807a717dd3aSAdrian Chadd  */
6808a717dd3aSAdrian Chadd struct iwm_dts_measurement_notif_v2 {
6809a717dd3aSAdrian Chadd 	int32_t temp;
6810a717dd3aSAdrian Chadd 	int32_t voltage;
6811a717dd3aSAdrian Chadd 	int32_t threshold_idx;
6812a717dd3aSAdrian Chadd } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S_VER_2 */
6813a717dd3aSAdrian Chadd 
6814355c1513SAdrian Chadd 
68156a5bc1d1SSean Bruno /*
6816d4886179SRui Paulo  * Some cherry-picked definitions
6817d4886179SRui Paulo  */
6818d4886179SRui Paulo 
6819d4886179SRui Paulo #define IWM_FRAME_LIMIT	64
6820d4886179SRui Paulo 
68216a5bc1d1SSean Bruno /*
6822355c1513SAdrian Chadd  * From Linux commit ab02165ccec4c78162501acedeef1a768acdb811:
6823355c1513SAdrian Chadd  *   As the firmware is slowly running out of command IDs and grouping of
6824355c1513SAdrian Chadd  *   commands is desirable anyway, the firmware is extending the command
6825355c1513SAdrian Chadd  *   header from 4 bytes to 8 bytes to introduce a group (in place of the
6826355c1513SAdrian Chadd  *   former flags field, since that's always 0 on commands and thus can
6827355c1513SAdrian Chadd  *   be easily used to distinguish between the two).
6828355c1513SAdrian Chadd  *
68296a5bc1d1SSean Bruno  * These functions retrieve specific information from the id field in
68306a5bc1d1SSean Bruno  * the iwm_host_cmd struct which contains the command id, the group id,
6831355c1513SAdrian Chadd  * and the version of the command.
68326a5bc1d1SSean Bruno */
68336a5bc1d1SSean Bruno static inline uint8_t
68346a5bc1d1SSean Bruno iwm_cmd_opcode(uint32_t cmdid)
68356a5bc1d1SSean Bruno {
68366a5bc1d1SSean Bruno 	return cmdid & 0xff;
68376a5bc1d1SSean Bruno }
68386a5bc1d1SSean Bruno 
68396a5bc1d1SSean Bruno static inline uint8_t
68406a5bc1d1SSean Bruno iwm_cmd_groupid(uint32_t cmdid)
68416a5bc1d1SSean Bruno {
6842702287e4SAdrian Chadd 	return ((cmdid & 0xff00) >> 8);
68436a5bc1d1SSean Bruno }
68446a5bc1d1SSean Bruno 
68456a5bc1d1SSean Bruno static inline uint8_t
68466a5bc1d1SSean Bruno iwm_cmd_version(uint32_t cmdid)
68476a5bc1d1SSean Bruno {
68486a5bc1d1SSean Bruno 	return ((cmdid & 0xff0000) >> 16);
68496a5bc1d1SSean Bruno }
68506a5bc1d1SSean Bruno 
68516a5bc1d1SSean Bruno static inline uint32_t
68526a5bc1d1SSean Bruno iwm_cmd_id(uint8_t opcode, uint8_t groupid, uint8_t version)
68536a5bc1d1SSean Bruno {
68546a5bc1d1SSean Bruno 	return opcode + (groupid << 8) + (version << 16);
68556a5bc1d1SSean Bruno }
68566a5bc1d1SSean Bruno 
68576a5bc1d1SSean Bruno /* make uint16_t wide id out of uint8_t group and opcode */
68586a5bc1d1SSean Bruno #define IWM_WIDE_ID(grp, opcode) ((grp << 8) | opcode)
68596a5bc1d1SSean Bruno 
68606a5bc1d1SSean Bruno /* due to the conversion, this group is special */
68616a5bc1d1SSean Bruno #define IWM_ALWAYS_LONG_GROUP   1
68626a5bc1d1SSean Bruno 
6863d4886179SRui Paulo struct iwm_cmd_header {
6864d4886179SRui Paulo 	uint8_t code;
6865d4886179SRui Paulo 	uint8_t flags;
6866d4886179SRui Paulo 	uint8_t idx;
6867d4886179SRui Paulo 	uint8_t qid;
6868d4886179SRui Paulo } __packed;
6869d4886179SRui Paulo 
68706a5bc1d1SSean Bruno struct iwm_cmd_header_wide {
68716a5bc1d1SSean Bruno 	uint8_t opcode;
68726a5bc1d1SSean Bruno 	uint8_t group_id;
68736a5bc1d1SSean Bruno 	uint8_t idx;
68746a5bc1d1SSean Bruno 	uint8_t qid;
68756a5bc1d1SSean Bruno 	uint16_t length;
68766a5bc1d1SSean Bruno 	uint8_t reserved;
68776a5bc1d1SSean Bruno 	uint8_t version;
68786a5bc1d1SSean Bruno } __packed;
68796a5bc1d1SSean Bruno 
6880355c1513SAdrian Chadd #define IWM_POWER_SCHEME_CAM	1
6881355c1513SAdrian Chadd #define IWM_POWER_SCHEME_BPS	2
6882355c1513SAdrian Chadd #define IWM_POWER_SCHEME_LP	3
6883d4886179SRui Paulo 
6884d4886179SRui Paulo #define IWM_DEF_CMD_PAYLOAD_SIZE 320
68857a8b94e1SAdrian Chadd #define IWM_MAX_CMD_PAYLOAD_SIZE ((4096 - 4) - sizeof(struct iwm_cmd_header))
6886d4886179SRui Paulo #define IWM_CMD_FAILED_MSK 0x40
6887d4886179SRui Paulo 
68886a5bc1d1SSean Bruno /**
68896a5bc1d1SSean Bruno  * struct iwm_device_cmd
68906a5bc1d1SSean Bruno  *
68916a5bc1d1SSean Bruno  * For allocation of the command and tx queues, this establishes the overall
68926a5bc1d1SSean Bruno  * size of the largest command we send to uCode, except for commands that
68936a5bc1d1SSean Bruno  * aren't fully copied and use other TFD space.
68946a5bc1d1SSean Bruno  */
6895d4886179SRui Paulo struct iwm_device_cmd {
68966a5bc1d1SSean Bruno 	union {
68976a5bc1d1SSean Bruno 		struct {
6898d4886179SRui Paulo 			struct iwm_cmd_header hdr;
6899d4886179SRui Paulo 			uint8_t data[IWM_DEF_CMD_PAYLOAD_SIZE];
69006a5bc1d1SSean Bruno 		};
69016a5bc1d1SSean Bruno 		struct {
69026a5bc1d1SSean Bruno 			struct iwm_cmd_header_wide hdr_wide;
69036a5bc1d1SSean Bruno 			uint8_t data_wide[IWM_DEF_CMD_PAYLOAD_SIZE -
69046a5bc1d1SSean Bruno 					sizeof(struct iwm_cmd_header_wide) +
69056a5bc1d1SSean Bruno 					sizeof(struct iwm_cmd_header)];
69066a5bc1d1SSean Bruno 		};
69076a5bc1d1SSean Bruno 	};
6908d4886179SRui Paulo } __packed;
6909d4886179SRui Paulo 
6910d4886179SRui Paulo struct iwm_rx_packet {
6911d4886179SRui Paulo 	/*
6912d4886179SRui Paulo 	 * The first 4 bytes of the RX frame header contain both the RX frame
6913d4886179SRui Paulo 	 * size and some flags.
6914d4886179SRui Paulo 	 * Bit fields:
6915d4886179SRui Paulo 	 * 31:    flag flush RB request
6916d4886179SRui Paulo 	 * 30:    flag ignore TC (terminal counter) request
6917d4886179SRui Paulo 	 * 29:    flag fast IRQ request
6918355c1513SAdrian Chadd 	 * 28-26: Reserved
6919355c1513SAdrian Chadd 	 * 25:    Offload enabled
6920355c1513SAdrian Chadd 	 * 24:    RPF enabled
6921355c1513SAdrian Chadd 	 * 23:    RSS enabled
6922355c1513SAdrian Chadd 	 * 22:    Checksum enabled
6923355c1513SAdrian Chadd 	 * 21-16: RX queue
6924355c1513SAdrian Chadd 	 * 15-14: Reserved
6925d4886179SRui Paulo 	 * 13-00: RX frame size
6926d4886179SRui Paulo 	 */
6927d4886179SRui Paulo 	uint32_t len_n_flags;
6928d4886179SRui Paulo 	struct iwm_cmd_header hdr;
6929d4886179SRui Paulo 	uint8_t data[];
6930d4886179SRui Paulo } __packed;
6931d4886179SRui Paulo 
6932d4886179SRui Paulo #define	IWM_FH_RSCSR_FRAME_SIZE_MSK	0x00003fff
6933702287e4SAdrian Chadd #define	IWM_FH_RSCSR_FRAME_INVALID	0x55550000
6934702287e4SAdrian Chadd #define	IWM_FH_RSCSR_FRAME_ALIGN	0x40
6935355c1513SAdrian Chadd #define	IWM_FH_RSCSR_RPA_EN		(1 << 25)
6936355c1513SAdrian Chadd #define	IWM_FH_RSCSR_RADA_EN		(1 << 26)
6937355c1513SAdrian Chadd #define	IWM_FH_RSCSR_RXQ_POS		16
6938355c1513SAdrian Chadd #define	IWM_FH_RSCSR_RXQ_MASK		0x3F0000
6939d4886179SRui Paulo 
6940d4886179SRui Paulo static inline uint32_t
6941d4886179SRui Paulo iwm_rx_packet_len(const struct iwm_rx_packet *pkt)
6942d4886179SRui Paulo {
6943d4886179SRui Paulo 
6944d4886179SRui Paulo 	return le32toh(pkt->len_n_flags) & IWM_FH_RSCSR_FRAME_SIZE_MSK;
6945d4886179SRui Paulo }
6946d4886179SRui Paulo 
6947d4886179SRui Paulo static inline uint32_t
6948d4886179SRui Paulo iwm_rx_packet_payload_len(const struct iwm_rx_packet *pkt)
6949d4886179SRui Paulo {
6950d4886179SRui Paulo 
6951d4886179SRui Paulo 	return iwm_rx_packet_len(pkt) - sizeof(pkt->hdr);
6952d4886179SRui Paulo }
6953d4886179SRui Paulo 
6954d4886179SRui Paulo 
6955d4886179SRui Paulo #define IWM_MIN_DBM	-100
6956d4886179SRui Paulo #define IWM_MAX_DBM	-33	/* realistic guess */
6957d4886179SRui Paulo 
6958d4886179SRui Paulo #define IWM_READ(sc, reg)						\
6959d4886179SRui Paulo 	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
6960d4886179SRui Paulo 
6961d4886179SRui Paulo #define IWM_WRITE(sc, reg, val)						\
6962d4886179SRui Paulo 	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
6963d4886179SRui Paulo 
6964d4886179SRui Paulo #define IWM_WRITE_1(sc, reg, val)					\
6965d4886179SRui Paulo 	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
6966d4886179SRui Paulo 
6967d4886179SRui Paulo #define IWM_SETBITS(sc, reg, mask)					\
6968d4886179SRui Paulo 	IWM_WRITE(sc, reg, IWM_READ(sc, reg) | (mask))
6969d4886179SRui Paulo 
6970d4886179SRui Paulo #define IWM_CLRBITS(sc, reg, mask)					\
6971d4886179SRui Paulo 	IWM_WRITE(sc, reg, IWM_READ(sc, reg) & ~(mask))
6972d4886179SRui Paulo 
6973d4886179SRui Paulo #define IWM_BARRIER_WRITE(sc)						\
6974d4886179SRui Paulo 	bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz,	\
6975d4886179SRui Paulo 	    BUS_SPACE_BARRIER_WRITE)
6976d4886179SRui Paulo 
6977d4886179SRui Paulo #define IWM_BARRIER_READ_WRITE(sc)					\
6978d4886179SRui Paulo 	bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz,	\
6979d4886179SRui Paulo 	    BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
6980d4886179SRui Paulo 
6981d4886179SRui Paulo #endif	/* __IF_IWM_REG_H__ */
6982