if_iwmreg.h revision 330163
1/*	$OpenBSD: if_iwmreg.h,v 1.4 2015/06/15 08:06:11 stsp Exp $	*/
2/*	$FreeBSD: stable/11/sys/dev/iwm/if_iwmreg.h 330163 2018-03-01 05:09:49Z eadler $ */
3
4/******************************************************************************
5 *
6 * This file is provided under a dual BSD/GPLv2 license.  When using or
7 * redistributing this file, you may do so under either license.
8 *
9 * GPL LICENSE SUMMARY
10 *
11 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
25 * USA
26 *
27 * The full GNU General Public License is included in this distribution
28 * in the file called COPYING.
29 *
30 * Contact Information:
31 *  Intel Linux Wireless <ilw@linux.intel.com>
32 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
33 *
34 * BSD LICENSE
35 *
36 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
37 * All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 *
43 *  * Redistributions of source code must retain the above copyright
44 *    notice, this list of conditions and the following disclaimer.
45 *  * Redistributions in binary form must reproduce the above copyright
46 *    notice, this list of conditions and the following disclaimer in
47 *    the documentation and/or other materials provided with the
48 *    distribution.
49 *  * Neither the name Intel Corporation nor the names of its
50 *    contributors may be used to endorse or promote products derived
51 *    from this software without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *
65 *****************************************************************************/
66#ifndef	__IF_IWM_REG_H__
67#define	__IF_IWM_REG_H__
68
69#define	le16_to_cpup(_a_)	(le16toh(*(const uint16_t *)(_a_)))
70#define	le32_to_cpup(_a_)	(le32toh(*(const uint32_t *)(_a_)))
71
72/*
73 * BEGIN iwl-csr.h
74 */
75
76/*
77 * CSR (control and status registers)
78 *
79 * CSR registers are mapped directly into PCI bus space, and are accessible
80 * whenever platform supplies power to device, even when device is in
81 * low power states due to driver-invoked device resets
82 * (e.g. IWM_CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes.
83 *
84 * Use iwl_write32() and iwl_read32() family to access these registers;
85 * these provide simple PCI bus access, without waking up the MAC.
86 * Do not use iwl_write_direct32() family for these registers;
87 * no need to "grab nic access" via IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ.
88 * The MAC (uCode processor, etc.) does not need to be powered up for accessing
89 * the CSR registers.
90 *
91 * NOTE:  Device does need to be awake in order to read this memory
92 *        via IWM_CSR_EEPROM and IWM_CSR_OTP registers
93 */
94#define IWM_CSR_HW_IF_CONFIG_REG    (0x000) /* hardware interface config */
95#define IWM_CSR_INT_COALESCING      (0x004) /* accum ints, 32-usec units */
96#define IWM_CSR_INT                 (0x008) /* host interrupt status/ack */
97#define IWM_CSR_INT_MASK            (0x00c) /* host interrupt enable */
98#define IWM_CSR_FH_INT_STATUS       (0x010) /* busmaster int status/ack*/
99#define IWM_CSR_GPIO_IN             (0x018) /* read external chip pins */
100#define IWM_CSR_RESET               (0x020) /* busmaster enable, NMI, etc*/
101#define IWM_CSR_GP_CNTRL            (0x024)
102
103/* 2nd byte of IWM_CSR_INT_COALESCING, not accessible via iwl_write32()! */
104#define IWM_CSR_INT_PERIODIC_REG	(0x005)
105
106/*
107 * Hardware revision info
108 * Bit fields:
109 * 31-16:  Reserved
110 *  15-4:  Type of device:  see IWM_CSR_HW_REV_TYPE_xxx definitions
111 *  3-2:  Revision step:  0 = A, 1 = B, 2 = C, 3 = D
112 *  1-0:  "Dash" (-) value, as in A-1, etc.
113 */
114#define IWM_CSR_HW_REV              (0x028)
115
116/*
117 * EEPROM and OTP (one-time-programmable) memory reads
118 *
119 * NOTE:  Device must be awake, initialized via apm_ops.init(),
120 *        in order to read.
121 */
122#define IWM_CSR_EEPROM_REG          (0x02c)
123#define IWM_CSR_EEPROM_GP           (0x030)
124#define IWM_CSR_OTP_GP_REG          (0x034)
125
126#define IWM_CSR_GIO_REG		(0x03C)
127#define IWM_CSR_GP_UCODE_REG	(0x048)
128#define IWM_CSR_GP_DRIVER_REG	(0x050)
129
130/*
131 * UCODE-DRIVER GP (general purpose) mailbox registers.
132 * SET/CLR registers set/clear bit(s) if "1" is written.
133 */
134#define IWM_CSR_UCODE_DRV_GP1       (0x054)
135#define IWM_CSR_UCODE_DRV_GP1_SET   (0x058)
136#define IWM_CSR_UCODE_DRV_GP1_CLR   (0x05c)
137#define IWM_CSR_UCODE_DRV_GP2       (0x060)
138
139#define IWM_CSR_MBOX_SET_REG		(0x088)
140#define IWM_CSR_MBOX_SET_REG_OS_ALIVE	0x20
141
142#define IWM_CSR_LED_REG			(0x094)
143#define IWM_CSR_DRAM_INT_TBL_REG	(0x0A0)
144#define IWM_CSR_MAC_SHADOW_REG_CTRL	(0x0A8) /* 6000 and up */
145
146
147/* GIO Chicken Bits (PCI Express bus link power management) */
148#define IWM_CSR_GIO_CHICKEN_BITS    (0x100)
149
150/* Analog phase-lock-loop configuration  */
151#define IWM_CSR_ANA_PLL_CFG         (0x20c)
152
153/*
154 * CSR Hardware Revision Workaround Register.  Indicates hardware rev;
155 * "step" determines CCK backoff for txpower calculation.  Used for 4965 only.
156 * See also IWM_CSR_HW_REV register.
157 * Bit fields:
158 *  3-2:  0 = A, 1 = B, 2 = C, 3 = D step
159 *  1-0:  "Dash" (-) value, as in C-1, etc.
160 */
161#define IWM_CSR_HW_REV_WA_REG		(0x22C)
162
163#define IWM_CSR_DBG_HPET_MEM_REG	(0x240)
164#define IWM_CSR_DBG_LINK_PWR_MGMT_REG	(0x250)
165
166/* Bits for IWM_CSR_HW_IF_CONFIG_REG */
167#define IWM_CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH	(0x00000003)
168#define IWM_CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP	(0x0000000C)
169#define IWM_CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER	(0x000000C0)
170#define IWM_CSR_HW_IF_CONFIG_REG_BIT_MAC_SI	(0x00000100)
171#define IWM_CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI	(0x00000200)
172#define IWM_CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE	(0x00000C00)
173#define IWM_CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH	(0x00003000)
174#define IWM_CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP	(0x0000C000)
175
176#define IWM_CSR_HW_IF_CONFIG_REG_POS_MAC_DASH	(0)
177#define IWM_CSR_HW_IF_CONFIG_REG_POS_MAC_STEP	(2)
178#define IWM_CSR_HW_IF_CONFIG_REG_POS_BOARD_VER	(6)
179#define IWM_CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE	(10)
180#define IWM_CSR_HW_IF_CONFIG_REG_POS_PHY_DASH	(12)
181#define IWM_CSR_HW_IF_CONFIG_REG_POS_PHY_STEP	(14)
182
183#define IWM_CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A	(0x00080000)
184#define IWM_CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM	(0x00200000)
185#define IWM_CSR_HW_IF_CONFIG_REG_BIT_NIC_READY	(0x00400000) /* PCI_OWN_SEM */
186#define IWM_CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */
187#define IWM_CSR_HW_IF_CONFIG_REG_PREPARE	(0x08000000) /* WAKE_ME */
188#define IWM_CSR_HW_IF_CONFIG_REG_ENABLE_PME	(0x10000000)
189#define IWM_CSR_HW_IF_CONFIG_REG_PERSIST_MODE	(0x40000000) /* PERSISTENCE */
190
191#define IWM_CSR_INT_PERIODIC_DIS		(0x00) /* disable periodic int*/
192#define IWM_CSR_INT_PERIODIC_ENA		(0xFF) /* 255*32 usec ~ 8 msec*/
193
194/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
195 * acknowledged (reset) by host writing "1" to flagged bits. */
196#define IWM_CSR_INT_BIT_FH_RX	(1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
197#define IWM_CSR_INT_BIT_HW_ERR	(1 << 29) /* DMA hardware error FH_INT[31] */
198#define IWM_CSR_INT_BIT_RX_PERIODIC	(1 << 28) /* Rx periodic */
199#define IWM_CSR_INT_BIT_FH_TX	(1 << 27) /* Tx DMA FH_INT[1:0] */
200#define IWM_CSR_INT_BIT_SCD	(1 << 26) /* TXQ pointer advanced */
201#define IWM_CSR_INT_BIT_SW_ERR	(1 << 25) /* uCode error */
202#define IWM_CSR_INT_BIT_RF_KILL	(1 << 7)  /* HW RFKILL switch GP_CNTRL[27] toggled */
203#define IWM_CSR_INT_BIT_CT_KILL	(1 << 6)  /* Critical temp (chip too hot) rfkill */
204#define IWM_CSR_INT_BIT_SW_RX	(1 << 3)  /* Rx, command responses */
205#define IWM_CSR_INT_BIT_WAKEUP	(1 << 1)  /* NIC controller waking up (pwr mgmt) */
206#define IWM_CSR_INT_BIT_ALIVE	(1 << 0)  /* uCode interrupts once it initializes */
207
208#define IWM_CSR_INI_SET_MASK	(IWM_CSR_INT_BIT_FH_RX   | \
209				 IWM_CSR_INT_BIT_HW_ERR  | \
210				 IWM_CSR_INT_BIT_FH_TX   | \
211				 IWM_CSR_INT_BIT_SW_ERR  | \
212				 IWM_CSR_INT_BIT_RF_KILL | \
213				 IWM_CSR_INT_BIT_SW_RX   | \
214				 IWM_CSR_INT_BIT_WAKEUP  | \
215				 IWM_CSR_INT_BIT_ALIVE   | \
216				 IWM_CSR_INT_BIT_RX_PERIODIC)
217
218/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
219#define IWM_CSR_FH_INT_BIT_ERR       (1 << 31) /* Error */
220#define IWM_CSR_FH_INT_BIT_HI_PRIOR  (1 << 30) /* High priority Rx, bypass coalescing */
221#define IWM_CSR_FH_INT_BIT_RX_CHNL1  (1 << 17) /* Rx channel 1 */
222#define IWM_CSR_FH_INT_BIT_RX_CHNL0  (1 << 16) /* Rx channel 0 */
223#define IWM_CSR_FH_INT_BIT_TX_CHNL1  (1 << 1)  /* Tx channel 1 */
224#define IWM_CSR_FH_INT_BIT_TX_CHNL0  (1 << 0)  /* Tx channel 0 */
225
226#define IWM_CSR_FH_INT_RX_MASK	(IWM_CSR_FH_INT_BIT_HI_PRIOR | \
227				IWM_CSR_FH_INT_BIT_RX_CHNL1 | \
228				IWM_CSR_FH_INT_BIT_RX_CHNL0)
229
230#define IWM_CSR_FH_INT_TX_MASK	(IWM_CSR_FH_INT_BIT_TX_CHNL1 | \
231				IWM_CSR_FH_INT_BIT_TX_CHNL0)
232
233/* GPIO */
234#define IWM_CSR_GPIO_IN_BIT_AUX_POWER                   (0x00000200)
235#define IWM_CSR_GPIO_IN_VAL_VAUX_PWR_SRC                (0x00000000)
236#define IWM_CSR_GPIO_IN_VAL_VMAIN_PWR_SRC               (0x00000200)
237
238/* RESET */
239#define IWM_CSR_RESET_REG_FLAG_NEVO_RESET                (0x00000001)
240#define IWM_CSR_RESET_REG_FLAG_FORCE_NMI                 (0x00000002)
241#define IWM_CSR_RESET_REG_FLAG_SW_RESET                  (0x00000080)
242#define IWM_CSR_RESET_REG_FLAG_MASTER_DISABLED           (0x00000100)
243#define IWM_CSR_RESET_REG_FLAG_STOP_MASTER               (0x00000200)
244#define IWM_CSR_RESET_LINK_PWR_MGMT_DISABLED             (0x80000000)
245
246/*
247 * GP (general purpose) CONTROL REGISTER
248 * Bit fields:
249 *    27:  HW_RF_KILL_SW
250 *         Indicates state of (platform's) hardware RF-Kill switch
251 * 26-24:  POWER_SAVE_TYPE
252 *         Indicates current power-saving mode:
253 *         000 -- No power saving
254 *         001 -- MAC power-down
255 *         010 -- PHY (radio) power-down
256 *         011 -- Error
257 *   9-6:  SYS_CONFIG
258 *         Indicates current system configuration, reflecting pins on chip
259 *         as forced high/low by device circuit board.
260 *     4:  GOING_TO_SLEEP
261 *         Indicates MAC is entering a power-saving sleep power-down.
262 *         Not a good time to access device-internal resources.
263 *     3:  MAC_ACCESS_REQ
264 *         Host sets this to request and maintain MAC wakeup, to allow host
265 *         access to device-internal resources.  Host must wait for
266 *         MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR
267 *         device registers.
268 *     2:  INIT_DONE
269 *         Host sets this to put device into fully operational D0 power mode.
270 *         Host resets this after SW_RESET to put device into low power mode.
271 *     0:  MAC_CLOCK_READY
272 *         Indicates MAC (ucode processor, etc.) is powered up and can run.
273 *         Internal resources are accessible.
274 *         NOTE:  This does not indicate that the processor is actually running.
275 *         NOTE:  This does not indicate that device has completed
276 *                init or post-power-down restore of internal SRAM memory.
277 *                Use IWM_CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that
278 *                SRAM is restored and uCode is in normal operation mode.
279 *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
280 *                do not need to save/restore it.
281 *         NOTE:  After device reset, this bit remains "0" until host sets
282 *                INIT_DONE
283 */
284#define IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY        (0x00000001)
285#define IWM_CSR_GP_CNTRL_REG_FLAG_INIT_DONE              (0x00000004)
286#define IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ         (0x00000008)
287#define IWM_CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP         (0x00000010)
288
289#define IWM_CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN           (0x00000001)
290
291#define IWM_CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE         (0x07000000)
292#define IWM_CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE         (0x04000000)
293#define IWM_CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW          (0x08000000)
294
295
296/* HW REV */
297#define IWM_CSR_HW_REV_DASH(_val)          (((_val) & 0x0000003) >> 0)
298#define IWM_CSR_HW_REV_STEP(_val)          (((_val) & 0x000000C) >> 2)
299
300/**
301 *  hw_rev values
302 */
303enum {
304	IWM_SILICON_A_STEP = 0,
305	IWM_SILICON_B_STEP,
306	IWM_SILICON_C_STEP,
307};
308
309
310#define IWM_CSR_HW_REV_TYPE_MSK		(0x000FFF0)
311#define IWM_CSR_HW_REV_TYPE_5300	(0x0000020)
312#define IWM_CSR_HW_REV_TYPE_5350	(0x0000030)
313#define IWM_CSR_HW_REV_TYPE_5100	(0x0000050)
314#define IWM_CSR_HW_REV_TYPE_5150	(0x0000040)
315#define IWM_CSR_HW_REV_TYPE_1000	(0x0000060)
316#define IWM_CSR_HW_REV_TYPE_6x00	(0x0000070)
317#define IWM_CSR_HW_REV_TYPE_6x50	(0x0000080)
318#define IWM_CSR_HW_REV_TYPE_6150	(0x0000084)
319#define IWM_CSR_HW_REV_TYPE_6x05	(0x00000B0)
320#define IWM_CSR_HW_REV_TYPE_6x30	IWM_CSR_HW_REV_TYPE_6x05
321#define IWM_CSR_HW_REV_TYPE_6x35	IWM_CSR_HW_REV_TYPE_6x05
322#define IWM_CSR_HW_REV_TYPE_2x30	(0x00000C0)
323#define IWM_CSR_HW_REV_TYPE_2x00	(0x0000100)
324#define IWM_CSR_HW_REV_TYPE_105		(0x0000110)
325#define IWM_CSR_HW_REV_TYPE_135		(0x0000120)
326#define IWM_CSR_HW_REV_TYPE_7265D	(0x0000210)
327#define IWM_CSR_HW_REV_TYPE_NONE	(0x00001F0)
328
329/* EEPROM REG */
330#define IWM_CSR_EEPROM_REG_READ_VALID_MSK	(0x00000001)
331#define IWM_CSR_EEPROM_REG_BIT_CMD		(0x00000002)
332#define IWM_CSR_EEPROM_REG_MSK_ADDR		(0x0000FFFC)
333#define IWM_CSR_EEPROM_REG_MSK_DATA		(0xFFFF0000)
334
335/* EEPROM GP */
336#define IWM_CSR_EEPROM_GP_VALID_MSK		(0x00000007) /* signature */
337#define IWM_CSR_EEPROM_GP_IF_OWNER_MSK	(0x00000180)
338#define IWM_CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP	(0x00000000)
339#define IWM_CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP		(0x00000001)
340#define IWM_CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K		(0x00000002)
341#define IWM_CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K		(0x00000004)
342
343/* One-time-programmable memory general purpose reg */
344#define IWM_CSR_OTP_GP_REG_DEVICE_SELECT  (0x00010000) /* 0 - EEPROM, 1 - OTP */
345#define IWM_CSR_OTP_GP_REG_OTP_ACCESS_MODE  (0x00020000) /* 0 - absolute, 1 - relative */
346#define IWM_CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK    (0x00100000) /* bit 20 */
347#define IWM_CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK  (0x00200000) /* bit 21 */
348
349/* GP REG */
350#define IWM_CSR_GP_REG_POWER_SAVE_STATUS_MSK    (0x03000000) /* bit 24/25 */
351#define IWM_CSR_GP_REG_NO_POWER_SAVE            (0x00000000)
352#define IWM_CSR_GP_REG_MAC_POWER_SAVE           (0x01000000)
353#define IWM_CSR_GP_REG_PHY_POWER_SAVE           (0x02000000)
354#define IWM_CSR_GP_REG_POWER_SAVE_ERROR         (0x03000000)
355
356
357/* CSR GIO */
358#define IWM_CSR_GIO_REG_VAL_L0S_ENABLED	(0x00000002)
359
360/*
361 * UCODE-DRIVER GP (general purpose) mailbox register 1
362 * Host driver and uCode write and/or read this register to communicate with
363 * each other.
364 * Bit fields:
365 *     4:  UCODE_DISABLE
366 *         Host sets this to request permanent halt of uCode, same as
367 *         sending CARD_STATE command with "halt" bit set.
368 *     3:  CT_KILL_EXIT
369 *         Host sets this to request exit from CT_KILL state, i.e. host thinks
370 *         device temperature is low enough to continue normal operation.
371 *     2:  CMD_BLOCKED
372 *         Host sets this during RF KILL power-down sequence (HW, SW, CT KILL)
373 *         to release uCode to clear all Tx and command queues, enter
374 *         unassociated mode, and power down.
375 *         NOTE:  Some devices also use HBUS_TARG_MBX_C register for this bit.
376 *     1:  SW_BIT_RFKILL
377 *         Host sets this when issuing CARD_STATE command to request
378 *         device sleep.
379 *     0:  MAC_SLEEP
380 *         uCode sets this when preparing a power-saving power-down.
381 *         uCode resets this when power-up is complete and SRAM is sane.
382 *         NOTE:  device saves internal SRAM data to host when powering down,
383 *                and must restore this data after powering back up.
384 *                MAC_SLEEP is the best indication that restore is complete.
385 *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
386 *                do not need to save/restore it.
387 */
388#define IWM_CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP             (0x00000001)
389#define IWM_CSR_UCODE_SW_BIT_RFKILL                     (0x00000002)
390#define IWM_CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED           (0x00000004)
391#define IWM_CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT      (0x00000008)
392#define IWM_CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE       (0x00000020)
393
394/* GP Driver */
395#define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_MSK		    (0x00000003)
396#define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_3x3_HYB	    (0x00000000)
397#define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_HYB	    (0x00000001)
398#define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA	    (0x00000002)
399#define IWM_CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6	    (0x00000004)
400#define IWM_CSR_GP_DRIVER_REG_BIT_6050_1x2		    (0x00000008)
401
402#define IWM_CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER	    (0x00000080)
403
404/* GIO Chicken Bits (PCI Express bus link power management) */
405#define IWM_CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX  (0x00800000)
406#define IWM_CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER  (0x20000000)
407
408/* LED */
409#define IWM_CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
410#define IWM_CSR_LED_REG_TURN_ON (0x60)
411#define IWM_CSR_LED_REG_TURN_OFF (0x20)
412
413/* ANA_PLL */
414#define IWM_CSR50_ANA_PLL_CFG_VAL        (0x00880300)
415
416/* HPET MEM debug */
417#define IWM_CSR_DBG_HPET_MEM_REG_VAL	(0xFFFF0000)
418
419/* DRAM INT TABLE */
420#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1 << 31)
421#define IWM_CSR_DRAM_INIT_TBL_WRITE_POINTER	(1 << 28)
422#define IWM_CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
423
424/* SECURE boot registers */
425#define IWM_CSR_SECURE_BOOT_CONFIG_ADDR	(0x100)
426enum iwm_secure_boot_config_reg {
427	IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_BURNED_IN_OTP	= 0x00000001,
428	IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_NOT_REQ	= 0x00000002,
429};
430
431#define IWM_CSR_SECURE_BOOT_CPU1_STATUS_ADDR	(0x100)
432#define IWM_CSR_SECURE_BOOT_CPU2_STATUS_ADDR	(0x100)
433enum iwm_secure_boot_status_reg {
434	IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_STATUS		= 0x00000003,
435	IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_COMPLETED	= 0x00000002,
436	IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_SUCCESS		= 0x00000004,
437	IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_FAIL		= 0x00000008,
438	IWM_CSR_SECURE_BOOT_CPU_STATUS_SIGN_VERF_FAIL	= 0x00000010,
439};
440
441#define IWM_FH_UCODE_LOAD_STATUS	0x1af0
442#define IWM_CSR_UCODE_LOAD_STATUS_ADDR	0x1e70
443enum iwm_secure_load_status_reg {
444	IWM_LMPM_CPU_UCODE_LOADING_STARTED		= 0x00000001,
445	IWM_LMPM_CPU_HDRS_LOADING_COMPLETED		= 0x00000003,
446	IWM_LMPM_CPU_UCODE_LOADING_COMPLETED		= 0x00000007,
447	IWM_LMPM_CPU_STATUS_NUM_OF_LAST_COMPLETED	= 0x000000F8,
448	IWM_LMPM_CPU_STATUS_NUM_OF_LAST_LOADED_BLOCK	= 0x0000FF00,
449};
450#define IWM_FH_MEM_TB_MAX_LENGTH	0x20000
451
452#define IWM_LMPM_SECURE_INSPECTOR_CODE_ADDR		0x1e38
453#define IWM_LMPM_SECURE_INSPECTOR_DATA_ADDR		0x1e3c
454#define IWM_LMPM_SECURE_UCODE_LOAD_CPU1_HDR_ADDR	0x1e78
455#define IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR	0x1e7c
456
457#define IWM_LMPM_SECURE_INSPECTOR_CODE_MEM_SPACE	0x400000
458#define IWM_LMPM_SECURE_INSPECTOR_DATA_MEM_SPACE	0x402000
459#define IWM_LMPM_SECURE_CPU1_HDR_MEM_SPACE		0x420000
460#define IWM_LMPM_SECURE_CPU2_HDR_MEM_SPACE		0x420400
461
462#define IWM_CSR_SECURE_TIME_OUT	(100)
463
464/* extended range in FW SRAM */
465#define IWM_FW_MEM_EXTENDED_START       0x40000
466#define IWM_FW_MEM_EXTENDED_END         0x57FFF
467
468/* FW chicken bits */
469#define IWM_LMPM_CHICK				0xa01ff8
470#define IWM_LMPM_CHICK_EXTENDED_ADDR_SPACE	0x01
471
472#define IWM_FH_TCSR_0_REG0 (0x1D00)
473
474/*
475 * HBUS (Host-side Bus)
476 *
477 * HBUS registers are mapped directly into PCI bus space, but are used
478 * to indirectly access device's internal memory or registers that
479 * may be powered-down.
480 *
481 * Use iwl_write_direct32()/iwl_read_direct32() family for these registers;
482 * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ
483 * to make sure the MAC (uCode processor, etc.) is powered up for accessing
484 * internal resources.
485 *
486 * Do not use iwl_write32()/iwl_read32() family to access these registers;
487 * these provide only simple PCI bus access, without waking up the MAC.
488 */
489#define IWM_HBUS_BASE	(0x400)
490
491/*
492 * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
493 * structures, error log, event log, verifying uCode load).
494 * First write to address register, then read from or write to data register
495 * to complete the job.  Once the address register is set up, accesses to
496 * data registers auto-increment the address by one dword.
497 * Bit usage for address registers (read or write):
498 *  0-31:  memory address within device
499 */
500#define IWM_HBUS_TARG_MEM_RADDR     (IWM_HBUS_BASE+0x00c)
501#define IWM_HBUS_TARG_MEM_WADDR     (IWM_HBUS_BASE+0x010)
502#define IWM_HBUS_TARG_MEM_WDAT      (IWM_HBUS_BASE+0x018)
503#define IWM_HBUS_TARG_MEM_RDAT      (IWM_HBUS_BASE+0x01c)
504
505/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */
506#define IWM_HBUS_TARG_MBX_C         (IWM_HBUS_BASE+0x030)
507#define IWM_HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED         (0x00000004)
508
509/*
510 * Registers for accessing device's internal peripheral registers
511 * (e.g. SCD, BSM, etc.).  First write to address register,
512 * then read from or write to data register to complete the job.
513 * Bit usage for address registers (read or write):
514 *  0-15:  register address (offset) within device
515 * 24-25:  (# bytes - 1) to read or write (e.g. 3 for dword)
516 */
517#define IWM_HBUS_TARG_PRPH_WADDR    (IWM_HBUS_BASE+0x044)
518#define IWM_HBUS_TARG_PRPH_RADDR    (IWM_HBUS_BASE+0x048)
519#define IWM_HBUS_TARG_PRPH_WDAT     (IWM_HBUS_BASE+0x04c)
520#define IWM_HBUS_TARG_PRPH_RDAT     (IWM_HBUS_BASE+0x050)
521
522/* enable the ID buf for read */
523#define IWM_WFPM_PS_CTL_CLR			0xa0300c
524#define IWM_WFMP_MAC_ADDR_0			0xa03080
525#define IWM_WFMP_MAC_ADDR_1			0xa03084
526#define IWM_LMPM_PMG_EN				0xa01cec
527#define IWM_RADIO_REG_SYS_MANUAL_DFT_0		0xad4078
528#define IWM_RFIC_REG_RD				0xad0470
529#define IWM_WFPM_CTRL_REG			0xa03030
530#define IWM_WFPM_AUX_CTL_AUX_IF_MAC_OWNER_MSK	0x08000000
531#define IWM_ENABLE_WFPM				0x80000000
532
533#define IWM_AUX_MISC_REG			0xa200b0
534#define IWM_HW_STEP_LOCATION_BITS		24
535
536#define IWM_AUX_MISC_MASTER1_EN			0xa20818
537#define IWM_AUX_MISC_MASTER1_EN_SBE_MSK		0x1
538#define IWM_AUX_MISC_MASTER1_SMPHR_STATUS	0xa20800
539#define IWM_RSA_ENABLE				0xa24b08
540#define IWM_PREG_AUX_BUS_WPROT_0		0xa04cc0
541#define IWM_SB_CFG_OVERRIDE_ADDR		0xa26c78
542#define IWM_SB_CFG_OVERRIDE_ENABLE		0x8000
543#define IWM_SB_CFG_BASE_OVERRIDE		0xa20000
544#define IWM_SB_MODIFY_CFG_FLAG			0xa03088
545#define IWM_SB_CPU_1_STATUS			0xa01e30
546#define IWM_SB_CPU_2_STATUS			0Xa01e34
547
548/* Used to enable DBGM */
549#define IWM_HBUS_TARG_TEST_REG	(IWM_HBUS_BASE+0x05c)
550
551/*
552 * Per-Tx-queue write pointer (index, really!)
553 * Indicates index to next TFD that driver will fill (1 past latest filled).
554 * Bit usage:
555 *  0-7:  queue write index
556 * 11-8:  queue selector
557 */
558#define IWM_HBUS_TARG_WRPTR         (IWM_HBUS_BASE+0x060)
559
560/**********************************************************
561 * CSR values
562 **********************************************************/
563 /*
564 * host interrupt timeout value
565 * used with setting interrupt coalescing timer
566 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
567 *
568 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
569 */
570#define IWM_HOST_INT_TIMEOUT_MAX	(0xFF)
571#define IWM_HOST_INT_TIMEOUT_DEF	(0x40)
572#define IWM_HOST_INT_TIMEOUT_MIN	(0x0)
573#define IWM_HOST_INT_OPER_MODE		(1 << 31)
574
575/*****************************************************************************
576 *                        7000/3000 series SHR DTS addresses                 *
577 *****************************************************************************/
578
579/* Diode Results Register Structure: */
580enum iwm_dtd_diode_reg {
581	IWM_DTS_DIODE_REG_DIG_VAL		= 0x000000FF, /* bits [7:0] */
582	IWM_DTS_DIODE_REG_VREF_LOW		= 0x0000FF00, /* bits [15:8] */
583	IWM_DTS_DIODE_REG_VREF_HIGH		= 0x00FF0000, /* bits [23:16] */
584	IWM_DTS_DIODE_REG_VREF_ID		= 0x03000000, /* bits [25:24] */
585	IWM_DTS_DIODE_REG_PASS_ONCE		= 0x80000000, /* bits [31:31] */
586	IWM_DTS_DIODE_REG_FLAGS_MSK		= 0xFF000000, /* bits [31:24] */
587/* Those are the masks INSIDE the flags bit-field: */
588	IWM_DTS_DIODE_REG_FLAGS_VREFS_ID_POS	= 0,
589	IWM_DTS_DIODE_REG_FLAGS_VREFS_ID	= 0x00000003, /* bits [1:0] */
590	IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE_POS	= 7,
591	IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE	= 0x00000080, /* bits [7:7] */
592};
593
594/*
595 * END iwl-csr.h
596 */
597
598/*
599 * BEGIN iwl-fw.h
600 */
601
602/**
603 * enum iwm_ucode_tlv_flag - ucode API flags
604 * @IWM_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
605 *	was a separate TLV but moved here to save space.
606 * @IWM_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
607 *	treats good CRC threshold as a boolean
608 * @IWM_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
609 * @IWM_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
610 * @IWM_UCODE_TLV_FLAGS_DW_BC_TABLE: The SCD byte count table is in DWORDS
611 * @IWM_UCODE_TLV_FLAGS_UAPSD: This uCode image supports uAPSD
612 * @IWM_UCODE_TLV_FLAGS_SHORT_BL: 16 entries of black list instead of 64 in scan
613 *	offload profile config command.
614 * @IWM_UCODE_TLV_FLAGS_RX_ENERGY_API: supports rx signal strength api
615 * @IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2: using the new time event API.
616 * @IWM_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS: D3 image supports up to six
617 *	(rather than two) IPv6 addresses
618 * @IWM_UCODE_TLV_FLAGS_BF_UPDATED: new beacon filtering API
619 * @IWM_UCODE_TLV_FLAGS_NO_BASIC_SSID: not sending a probe with the SSID element
620 *	from the probe request template.
621 * @IWM_UCODE_TLV_FLAGS_D3_CONTINUITY_API: modified D3 API to allow keeping
622 *	connection when going back to D0
623 * @IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL: new NS offload (small version)
624 * @IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE: new NS offload (large version)
625 * @IWM_UCODE_TLV_FLAGS_SCHED_SCAN: this uCode image supports scheduled scan.
626 * @IWM_UCODE_TLV_FLAGS_STA_KEY_CMD: new ADD_STA and ADD_STA_KEY command API
627 * @IWM_UCODE_TLV_FLAGS_DEVICE_PS_CMD: support device wide power command
628 *	containing CAM (Continuous Active Mode) indication.
629 * @IWM_UCODE_TLV_FLAGS_P2P_PS: P2P client power save is supported (only on a
630 *	single bound interface).
631 * @IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD
632 * @IWM_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS.
633 * @IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save
634 * @IWM_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering.
635 * @IWM_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients
636 *
637 */
638enum iwm_ucode_tlv_flag {
639	IWM_UCODE_TLV_FLAGS_PAN			= (1 << 0),
640	IWM_UCODE_TLV_FLAGS_NEWSCAN		= (1 << 1),
641	IWM_UCODE_TLV_FLAGS_MFP			= (1 << 2),
642	IWM_UCODE_TLV_FLAGS_P2P			= (1 << 3),
643	IWM_UCODE_TLV_FLAGS_DW_BC_TABLE		= (1 << 4),
644	IWM_UCODE_TLV_FLAGS_NEWBT_COEX		= (1 << 5),
645	IWM_UCODE_TLV_FLAGS_PM_CMD_SUPPORT	= (1 << 6),
646	IWM_UCODE_TLV_FLAGS_SHORT_BL		= (1 << 7),
647	IWM_UCODE_TLV_FLAGS_RX_ENERGY_API	= (1 << 8),
648	IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2	= (1 << 9),
649	IWM_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS	= (1 << 10),
650	IWM_UCODE_TLV_FLAGS_BF_UPDATED		= (1 << 11),
651	IWM_UCODE_TLV_FLAGS_NO_BASIC_SSID	= (1 << 12),
652	IWM_UCODE_TLV_FLAGS_D3_CONTINUITY_API	= (1 << 14),
653	IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL	= (1 << 15),
654	IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE	= (1 << 16),
655	IWM_UCODE_TLV_FLAGS_SCHED_SCAN		= (1 << 17),
656	IWM_UCODE_TLV_FLAGS_STA_KEY_CMD		= (1 << 19),
657	IWM_UCODE_TLV_FLAGS_DEVICE_PS_CMD	= (1 << 20),
658	IWM_UCODE_TLV_FLAGS_P2P_PS		= (1 << 21),
659	IWM_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM	= (1 << 22),
660	IWM_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM	= (1 << 23),
661	IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT	= (1 << 24),
662	IWM_UCODE_TLV_FLAGS_EBS_SUPPORT		= (1 << 25),
663	IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD	= (1 << 26),
664	IWM_UCODE_TLV_FLAGS_BCAST_FILTERING	= (1 << 29),
665	IWM_UCODE_TLV_FLAGS_GO_UAPSD		= (1 << 30),
666	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1 << 31),
667};
668
669#define IWM_UCODE_TLV_FLAG_BITS \
670	"\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERG \
671Y\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFF \
672L_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30 \
673P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX"
674
675/**
676 * enum iwm_ucode_tlv_api - ucode api
677 * @IWM_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time
678 *	longer than the passive one, which is essential for fragmented scan.
679 * @IWM_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source.
680 * @IWM_UCODE_TLV_API_WIDE_CMD_HDR: ucode supports wide command header
681 * @IWM_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params
682 * @IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY: scan APIs use 8-level priority
683 *	instead of 3.
684 * @IWM_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size
685 *	(command version 3) that supports per-chain limits
686 *
687 * @IWM_NUM_UCODE_TLV_API: number of bits used
688 */
689enum iwm_ucode_tlv_api {
690	IWM_UCODE_TLV_API_FRAGMENTED_SCAN	= (1 << 8),
691	IWM_UCODE_TLV_API_WIFI_MCC_UPDATE	= (1 << 9),
692	IWM_UCODE_TLV_API_WIDE_CMD_HDR		= (1 << 14),
693	IWM_UCODE_TLV_API_LQ_SS_PARAMS		= (1 << 18),
694	IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY	= (1 << 24),
695	IWM_UCODE_TLV_API_TX_POWER_CHAIN	= (1 << 27),
696
697	IWM_NUM_UCODE_TLV_API = 32
698};
699
700#define IWM_UCODE_TLV_API_BITS \
701	"\020\10FRAGMENTED_SCAN\11WIFI_MCC_UPDATE\16WIDE_CMD_HDR\22LQ_SS_PARAMS\30EXT_SCAN_PRIO\33TX_POWER_CHAIN"
702
703/**
704 * enum iwm_ucode_tlv_capa - ucode capabilities
705 * @IWM_UCODE_TLV_CAPA_D0I3_SUPPORT: supports D0i3
706 * @IWM_UCODE_TLV_CAPA_LAR_SUPPORT: supports Location Aware Regulatory
707 * @IWM_UCODE_TLV_CAPA_UMAC_SCAN: supports UMAC scan.
708 * @IWM_UCODE_TLV_CAPA_BEAMFORMER: supports Beamformer
709 * @IWM_UCODE_TLV_CAPA_TOF_SUPPORT: supports Time of Flight (802.11mc FTM)
710 * @IWM_UCODE_TLV_CAPA_TDLS_SUPPORT: support basic TDLS functionality
711 * @IWM_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT: supports insertion of current
712 *	tx power value into TPC Report action frame and Link Measurement Report
713 *	action frame
714 * @IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT: supports updating current
715 *	channel in DS parameter set element in probe requests.
716 * @IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT: supports adding TPC Report IE in
717 *	probe requests.
718 * @IWM_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT: supports Quiet Period requests
719 * @IWM_UCODE_TLV_CAPA_DQA_SUPPORT: supports dynamic queue allocation (DQA),
720 *	which also implies support for the scheduler configuration command
721 * @IWM_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH: supports TDLS channel switching
722 * @IWM_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG: Consolidated D3-D0 image
723 * @IWM_UCODE_TLV_CAPA_HOTSPOT_SUPPORT: supports Hot Spot Command
724 * @IWM_UCODE_TLV_CAPA_DC2DC_SUPPORT: supports DC2DC Command
725 * @IWM_UCODE_TLV_CAPA_2G_COEX_SUPPORT: supports 2G coex Command
726 * @IWM_UCODE_TLV_CAPA_CSUM_SUPPORT: supports TCP Checksum Offload
727 * @IWM_UCODE_TLV_CAPA_RADIO_BEACON_STATS: support radio and beacon statistics
728 * @IWM_UCODE_TLV_CAPA_P2P_STANDALONE_UAPSD: support p2p standalone U-APSD
729 * @IWM_UCODE_TLV_CAPA_BT_COEX_PLCR: enabled BT Coex packet level co-running
730 * @IWM_UCODE_TLV_CAPA_LAR_MULTI_MCC: ucode supports LAR updates with different
731 *	sources for the MCC. This TLV bit is a future replacement to
732 *	IWM_UCODE_TLV_API_WIFI_MCC_UPDATE. When either is set, multi-source LAR
733 *	is supported.
734 * @IWM_UCODE_TLV_CAPA_BT_COEX_RRC: supports BT Coex RRC
735 * @IWM_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan
736 * @IWM_UCODE_TLV_CAPA_NAN_SUPPORT: supports NAN
737 * @IWM_UCODE_TLV_CAPA_UMAC_UPLOAD: supports upload mode in umac (1=supported,
738 *	0=no support)
739 * @IWM_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE: extended DTS measurement
740 * @IWM_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS: supports short PM timeouts
741 * @IWM_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT: supports bt-coex Multi-priority LUT
742 * @IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION: firmware will decide on what
743 *	antenna the beacon should be transmitted
744 * @IWM_UCODE_TLV_CAPA_BEACON_STORING: firmware will store the latest beacon
745 *	from AP and will send it upon d0i3 exit.
746 * @IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2: support LAR API V2
747 * @IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW: firmware responsible for CT-kill
748 * @IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT: supports temperature
749 *	thresholds reporting
750 * @IWM_UCODE_TLV_CAPA_CTDP_SUPPORT: supports cTDP command
751 * @IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED: supports usniffer enabled in
752 *	regular image.
753 * @IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG: support getting more shared
754 *	memory addresses from the firmware.
755 * @IWM_UCODE_TLV_CAPA_LQM_SUPPORT: supports Link Quality Measurement
756 * @IWM_UCODE_TLV_CAPA_LMAC_UPLOAD: supports upload mode in lmac (1=supported,
757 *	0=no support)
758 *
759 * @IWM_NUM_UCODE_TLV_CAPA: number of bits used
760 */
761enum iwm_ucode_tlv_capa {
762	IWM_UCODE_TLV_CAPA_D0I3_SUPPORT			= 0,
763	IWM_UCODE_TLV_CAPA_LAR_SUPPORT			= 1,
764	IWM_UCODE_TLV_CAPA_UMAC_SCAN			= 2,
765	IWM_UCODE_TLV_CAPA_BEAMFORMER			= 3,
766	IWM_UCODE_TLV_CAPA_TOF_SUPPORT                  = 5,
767	IWM_UCODE_TLV_CAPA_TDLS_SUPPORT			= 6,
768	IWM_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT	= 8,
769	IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT	= 9,
770	IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT	= 10,
771	IWM_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT		= 11,
772	IWM_UCODE_TLV_CAPA_DQA_SUPPORT			= 12,
773	IWM_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH		= 13,
774	IWM_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG		= 17,
775	IWM_UCODE_TLV_CAPA_HOTSPOT_SUPPORT		= 18,
776	IWM_UCODE_TLV_CAPA_DC2DC_CONFIG_SUPPORT		= 19,
777	IWM_UCODE_TLV_CAPA_2G_COEX_SUPPORT		= 20,
778	IWM_UCODE_TLV_CAPA_CSUM_SUPPORT			= 21,
779	IWM_UCODE_TLV_CAPA_RADIO_BEACON_STATS		= 22,
780	IWM_UCODE_TLV_CAPA_P2P_STANDALONE_UAPSD		= 26,
781	IWM_UCODE_TLV_CAPA_BT_COEX_PLCR			= 28,
782	IWM_UCODE_TLV_CAPA_LAR_MULTI_MCC		= 29,
783	IWM_UCODE_TLV_CAPA_BT_COEX_RRC			= 30,
784	IWM_UCODE_TLV_CAPA_GSCAN_SUPPORT		= 31,
785	IWM_UCODE_TLV_CAPA_NAN_SUPPORT			= 34,
786	IWM_UCODE_TLV_CAPA_UMAC_UPLOAD			= 35,
787	IWM_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE		= 64,
788	IWM_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS		= 65,
789	IWM_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT		= 67,
790	IWM_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT	= 68,
791	IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION		= 71,
792	IWM_UCODE_TLV_CAPA_BEACON_STORING		= 72,
793	IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2		= 73,
794	IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW		= 74,
795	IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT	= 75,
796	IWM_UCODE_TLV_CAPA_CTDP_SUPPORT			= 76,
797	IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED		= 77,
798	IWM_UCODE_TLV_CAPA_LMAC_UPLOAD			= 79,
799	IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG	= 80,
800	IWM_UCODE_TLV_CAPA_LQM_SUPPORT			= 81,
801
802	IWM_NUM_UCODE_TLV_CAPA = 128
803};
804
805/* The default calibrate table size if not specified by firmware file */
806#define IWM_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE	18
807#define IWM_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE		19
808#define IWM_MAX_PHY_CALIBRATE_TBL_SIZE			253
809
810/* The default max probe length if not specified by the firmware file */
811#define IWM_DEFAULT_MAX_PROBE_LENGTH	200
812
813/*
814 * enumeration of ucode section.
815 * This enumeration is used directly for older firmware (before 16.0).
816 * For new firmware, there can be up to 4 sections (see below) but the
817 * first one packaged into the firmware file is the DATA section and
818 * some debugging code accesses that.
819 */
820enum iwm_ucode_sec {
821	IWM_UCODE_SECTION_DATA,
822	IWM_UCODE_SECTION_INST,
823};
824/*
825 * For 16.0 uCode and above, there is no differentiation between sections,
826 * just an offset to the HW address.
827 */
828#define IWM_CPU1_CPU2_SEPARATOR_SECTION		0xFFFFCCCC
829#define IWM_PAGING_SEPARATOR_SECTION		0xAAAABBBB
830
831/* uCode version contains 4 values: Major/Minor/API/Serial */
832#define IWM_UCODE_MAJOR(ver)	(((ver) & 0xFF000000) >> 24)
833#define IWM_UCODE_MINOR(ver)	(((ver) & 0x00FF0000) >> 16)
834#define IWM_UCODE_API(ver)	(((ver) & 0x0000FF00) >> 8)
835#define IWM_UCODE_SERIAL(ver)	((ver) & 0x000000FF)
836
837/*
838 * Calibration control struct.
839 * Sent as part of the phy configuration command.
840 * @flow_trigger: bitmap for which calibrations to perform according to
841 *		flow triggers.
842 * @event_trigger: bitmap for which calibrations to perform according to
843 *		event triggers.
844 */
845struct iwm_tlv_calib_ctrl {
846	uint32_t flow_trigger;
847	uint32_t event_trigger;
848} __packed;
849
850enum iwm_fw_phy_cfg {
851	IWM_FW_PHY_CFG_RADIO_TYPE_POS = 0,
852	IWM_FW_PHY_CFG_RADIO_TYPE = 0x3 << IWM_FW_PHY_CFG_RADIO_TYPE_POS,
853	IWM_FW_PHY_CFG_RADIO_STEP_POS = 2,
854	IWM_FW_PHY_CFG_RADIO_STEP = 0x3 << IWM_FW_PHY_CFG_RADIO_STEP_POS,
855	IWM_FW_PHY_CFG_RADIO_DASH_POS = 4,
856	IWM_FW_PHY_CFG_RADIO_DASH = 0x3 << IWM_FW_PHY_CFG_RADIO_DASH_POS,
857	IWM_FW_PHY_CFG_TX_CHAIN_POS = 16,
858	IWM_FW_PHY_CFG_TX_CHAIN = 0xf << IWM_FW_PHY_CFG_TX_CHAIN_POS,
859	IWM_FW_PHY_CFG_RX_CHAIN_POS = 20,
860	IWM_FW_PHY_CFG_RX_CHAIN = 0xf << IWM_FW_PHY_CFG_RX_CHAIN_POS,
861};
862
863#define IWM_UCODE_MAX_CS		1
864
865/**
866 * struct iwm_fw_cipher_scheme - a cipher scheme supported by FW.
867 * @cipher: a cipher suite selector
868 * @flags: cipher scheme flags (currently reserved for a future use)
869 * @hdr_len: a size of MPDU security header
870 * @pn_len: a size of PN
871 * @pn_off: an offset of pn from the beginning of the security header
872 * @key_idx_off: an offset of key index byte in the security header
873 * @key_idx_mask: a bit mask of key_idx bits
874 * @key_idx_shift: bit shift needed to get key_idx
875 * @mic_len: mic length in bytes
876 * @hw_cipher: a HW cipher index used in host commands
877 */
878struct iwm_fw_cipher_scheme {
879	uint32_t cipher;
880	uint8_t flags;
881	uint8_t hdr_len;
882	uint8_t pn_len;
883	uint8_t pn_off;
884	uint8_t key_idx_off;
885	uint8_t key_idx_mask;
886	uint8_t key_idx_shift;
887	uint8_t mic_len;
888	uint8_t hw_cipher;
889} __packed;
890
891/**
892 * struct iwm_fw_cscheme_list - a cipher scheme list
893 * @size: a number of entries
894 * @cs: cipher scheme entries
895 */
896struct iwm_fw_cscheme_list {
897	uint8_t size;
898	struct iwm_fw_cipher_scheme cs[];
899} __packed;
900
901/*
902 * END iwl-fw.h
903 */
904
905/*
906 * BEGIN iwl-fw-file.h
907 */
908
909/* v1/v2 uCode file layout */
910struct iwm_ucode_header {
911	uint32_t ver;	/* major/minor/API/serial */
912	union {
913		struct {
914			uint32_t inst_size;	/* bytes of runtime code */
915			uint32_t data_size;	/* bytes of runtime data */
916			uint32_t init_size;	/* bytes of init code */
917			uint32_t init_data_size;	/* bytes of init data */
918			uint32_t boot_size;	/* bytes of bootstrap code */
919			uint8_t data[0];		/* in same order as sizes */
920		} v1;
921		struct {
922			uint32_t build;		/* build number */
923			uint32_t inst_size;	/* bytes of runtime code */
924			uint32_t data_size;	/* bytes of runtime data */
925			uint32_t init_size;	/* bytes of init code */
926			uint32_t init_data_size;	/* bytes of init data */
927			uint32_t boot_size;	/* bytes of bootstrap code */
928			uint8_t data[0];		/* in same order as sizes */
929		} v2;
930	} u;
931};
932
933/*
934 * new TLV uCode file layout
935 *
936 * The new TLV file format contains TLVs, that each specify
937 * some piece of data.
938 */
939
940enum iwm_ucode_tlv_type {
941	IWM_UCODE_TLV_INVALID		= 0, /* unused */
942	IWM_UCODE_TLV_INST		= 1,
943	IWM_UCODE_TLV_DATA		= 2,
944	IWM_UCODE_TLV_INIT		= 3,
945	IWM_UCODE_TLV_INIT_DATA		= 4,
946	IWM_UCODE_TLV_BOOT		= 5,
947	IWM_UCODE_TLV_PROBE_MAX_LEN	= 6, /* a uint32_t value */
948	IWM_UCODE_TLV_PAN		= 7,
949	IWM_UCODE_TLV_RUNT_EVTLOG_PTR	= 8,
950	IWM_UCODE_TLV_RUNT_EVTLOG_SIZE	= 9,
951	IWM_UCODE_TLV_RUNT_ERRLOG_PTR	= 10,
952	IWM_UCODE_TLV_INIT_EVTLOG_PTR	= 11,
953	IWM_UCODE_TLV_INIT_EVTLOG_SIZE	= 12,
954	IWM_UCODE_TLV_INIT_ERRLOG_PTR	= 13,
955	IWM_UCODE_TLV_ENHANCE_SENS_TBL	= 14,
956	IWM_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
957	IWM_UCODE_TLV_WOWLAN_INST	= 16,
958	IWM_UCODE_TLV_WOWLAN_DATA	= 17,
959	IWM_UCODE_TLV_FLAGS		= 18,
960	IWM_UCODE_TLV_SEC_RT		= 19,
961	IWM_UCODE_TLV_SEC_INIT		= 20,
962	IWM_UCODE_TLV_SEC_WOWLAN	= 21,
963	IWM_UCODE_TLV_DEF_CALIB		= 22,
964	IWM_UCODE_TLV_PHY_SKU		= 23,
965	IWM_UCODE_TLV_SECURE_SEC_RT	= 24,
966	IWM_UCODE_TLV_SECURE_SEC_INIT	= 25,
967	IWM_UCODE_TLV_SECURE_SEC_WOWLAN	= 26,
968	IWM_UCODE_TLV_NUM_OF_CPU	= 27,
969	IWM_UCODE_TLV_CSCHEME		= 28,
970
971	/*
972	 * Following two are not in our base tag, but allow
973	 * handling ucode version 9.
974	 */
975	IWM_UCODE_TLV_API_CHANGES_SET	= 29,
976	IWM_UCODE_TLV_ENABLED_CAPABILITIES = 30,
977
978	IWM_UCODE_TLV_N_SCAN_CHANNELS	= 31,
979	IWM_UCODE_TLV_PAGING		= 32,
980	IWM_UCODE_TLV_SEC_RT_USNIFFER	= 34,
981	IWM_UCODE_TLV_SDIO_ADMA_ADDR	= 35,
982	IWM_UCODE_TLV_FW_VERSION	= 36,
983	IWM_UCODE_TLV_FW_DBG_DEST	= 38,
984	IWM_UCODE_TLV_FW_DBG_CONF	= 39,
985	IWM_UCODE_TLV_FW_DBG_TRIGGER	= 40,
986	IWM_UCODE_TLV_FW_GSCAN_CAPA	= 50,
987};
988
989struct iwm_ucode_tlv {
990	uint32_t type;		/* see above */
991	uint32_t length;		/* not including type/length fields */
992	uint8_t data[0];
993};
994
995struct iwm_ucode_api {
996	uint32_t api_index;
997	uint32_t api_flags;
998} __packed;
999
1000struct iwm_ucode_capa {
1001	uint32_t api_index;
1002	uint32_t api_capa;
1003} __packed;
1004
1005#define IWM_TLV_UCODE_MAGIC	0x0a4c5749
1006
1007struct iwm_tlv_ucode_header {
1008	/*
1009	 * The TLV style ucode header is distinguished from
1010	 * the v1/v2 style header by first four bytes being
1011	 * zero, as such is an invalid combination of
1012	 * major/minor/API/serial versions.
1013	 */
1014	uint32_t zero;
1015	uint32_t magic;
1016	uint8_t human_readable[64];
1017	uint32_t ver;		/* major/minor/API/serial */
1018	uint32_t build;
1019	uint64_t ignore;
1020	/*
1021	 * The data contained herein has a TLV layout,
1022	 * see above for the TLV header and types.
1023	 * Note that each TLV is padded to a length
1024	 * that is a multiple of 4 for alignment.
1025	 */
1026	uint8_t data[0];
1027};
1028
1029/*
1030 * END iwl-fw-file.h
1031 */
1032
1033/*
1034 * BEGIN iwl-prph.h
1035 */
1036
1037/*
1038 * Registers in this file are internal, not PCI bus memory mapped.
1039 * Driver accesses these via IWM_HBUS_TARG_PRPH_* registers.
1040 */
1041#define IWM_PRPH_BASE	(0x00000)
1042#define IWM_PRPH_END	(0xFFFFF)
1043
1044/* APMG (power management) constants */
1045#define IWM_APMG_BASE			(IWM_PRPH_BASE + 0x3000)
1046#define IWM_APMG_CLK_CTRL_REG		(IWM_APMG_BASE + 0x0000)
1047#define IWM_APMG_CLK_EN_REG		(IWM_APMG_BASE + 0x0004)
1048#define IWM_APMG_CLK_DIS_REG		(IWM_APMG_BASE + 0x0008)
1049#define IWM_APMG_PS_CTRL_REG		(IWM_APMG_BASE + 0x000c)
1050#define IWM_APMG_PCIDEV_STT_REG		(IWM_APMG_BASE + 0x0010)
1051#define IWM_APMG_RFKILL_REG		(IWM_APMG_BASE + 0x0014)
1052#define IWM_APMG_RTC_INT_STT_REG	(IWM_APMG_BASE + 0x001c)
1053#define IWM_APMG_RTC_INT_MSK_REG	(IWM_APMG_BASE + 0x0020)
1054#define IWM_APMG_DIGITAL_SVR_REG	(IWM_APMG_BASE + 0x0058)
1055#define IWM_APMG_ANALOG_SVR_REG		(IWM_APMG_BASE + 0x006C)
1056
1057#define IWM_APMS_CLK_VAL_MRB_FUNC_MODE	(0x00000001)
1058#define IWM_APMG_CLK_VAL_DMA_CLK_RQT	(0x00000200)
1059#define IWM_APMG_CLK_VAL_BSM_CLK_RQT	(0x00000800)
1060
1061#define IWM_APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS	(0x00400000)
1062#define IWM_APMG_PS_CTRL_VAL_RESET_REQ			(0x04000000)
1063#define IWM_APMG_PS_CTRL_MSK_PWR_SRC			(0x03000000)
1064#define IWM_APMG_PS_CTRL_VAL_PWR_SRC_VMAIN		(0x00000000)
1065#define IWM_APMG_PS_CTRL_VAL_PWR_SRC_VAUX		(0x02000000)
1066#define IWM_APMG_SVR_VOLTAGE_CONFIG_BIT_MSK		(0x000001E0) /* bit 8:5 */
1067#define IWM_APMG_SVR_DIGITAL_VOLTAGE_1_32		(0x00000060)
1068
1069#define IWM_APMG_PCIDEV_STT_VAL_L1_ACT_DIS		(0x00000800)
1070
1071#define IWM_APMG_RTC_INT_STT_RFKILL			(0x10000000)
1072
1073/* Device system time */
1074#define IWM_DEVICE_SYSTEM_TIME_REG 0xA0206C
1075
1076/* Device NMI register */
1077#define IWM_DEVICE_SET_NMI_REG		0x00a01c30
1078#define IWM_DEVICE_SET_NMI_VAL_HW	0x01
1079#define IWM_DEVICE_SET_NMI_VAL_DRV	0x80
1080#define IWM_DEVICE_SET_NMI_8000_REG	0x00a01c24
1081#define IWM_DEVICE_SET_NMI_8000_VAL	0x1000000
1082
1083/*
1084 * Device reset for family 8000
1085 * write to bit 24 in order to reset the CPU
1086 */
1087#define IWM_RELEASE_CPU_RESET		0x300c
1088#define IWM_RELEASE_CPU_RESET_BIT	0x1000000
1089
1090
1091/*****************************************************************************
1092 *                        7000/3000 series SHR DTS addresses                 *
1093 *****************************************************************************/
1094
1095#define IWM_SHR_MISC_WFM_DTS_EN		(0x00a10024)
1096#define IWM_DTSC_CFG_MODE		(0x00a10604)
1097#define IWM_DTSC_VREF_AVG		(0x00a10648)
1098#define IWM_DTSC_VREF5_AVG		(0x00a1064c)
1099#define IWM_DTSC_CFG_MODE_PERIODIC	(0x2)
1100#define IWM_DTSC_PTAT_AVG		(0x00a10650)
1101
1102
1103/**
1104 * Tx Scheduler
1105 *
1106 * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs
1107 * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in
1108 * host DRAM.  It steers each frame's Tx command (which contains the frame
1109 * data) into one of up to 7 prioritized Tx DMA FIFO channels within the
1110 * device.  A queue maps to only one (selectable by driver) Tx DMA channel,
1111 * but one DMA channel may take input from several queues.
1112 *
1113 * Tx DMA FIFOs have dedicated purposes.
1114 *
1115 * For 5000 series and up, they are used differently
1116 * (cf. iwl5000_default_queue_to_tx_fifo in iwl-5000.c):
1117 *
1118 * 0 -- EDCA BK (background) frames, lowest priority
1119 * 1 -- EDCA BE (best effort) frames, normal priority
1120 * 2 -- EDCA VI (video) frames, higher priority
1121 * 3 -- EDCA VO (voice) and management frames, highest priority
1122 * 4 -- unused
1123 * 5 -- unused
1124 * 6 -- unused
1125 * 7 -- Commands
1126 *
1127 * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
1128 * In addition, driver can map the remaining queues to Tx DMA/FIFO
1129 * channels 0-3 to support 11n aggregation via EDCA DMA channels.
1130 *
1131 * The driver sets up each queue to work in one of two modes:
1132 *
1133 * 1)  Scheduler-Ack, in which the scheduler automatically supports a
1134 *     block-ack (BA) window of up to 64 TFDs.  In this mode, each queue
1135 *     contains TFDs for a unique combination of Recipient Address (RA)
1136 *     and Traffic Identifier (TID), that is, traffic of a given
1137 *     Quality-Of-Service (QOS) priority, destined for a single station.
1138 *
1139 *     In scheduler-ack mode, the scheduler keeps track of the Tx status of
1140 *     each frame within the BA window, including whether it's been transmitted,
1141 *     and whether it's been acknowledged by the receiving station.  The device
1142 *     automatically processes block-acks received from the receiving STA,
1143 *     and reschedules un-acked frames to be retransmitted (successful
1144 *     Tx completion may end up being out-of-order).
1145 *
1146 *     The driver must maintain the queue's Byte Count table in host DRAM
1147 *     for this mode.
1148 *     This mode does not support fragmentation.
1149 *
1150 * 2)  FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
1151 *     The device may automatically retry Tx, but will retry only one frame
1152 *     at a time, until receiving ACK from receiving station, or reaching
1153 *     retry limit and giving up.
1154 *
1155 *     The command queue (#4/#9) must use this mode!
1156 *     This mode does not require use of the Byte Count table in host DRAM.
1157 *
1158 * Driver controls scheduler operation via 3 means:
1159 * 1)  Scheduler registers
1160 * 2)  Shared scheduler data base in internal SRAM
1161 * 3)  Shared data in host DRAM
1162 *
1163 * Initialization:
1164 *
1165 * When loading, driver should allocate memory for:
1166 * 1)  16 TFD circular buffers, each with space for (typically) 256 TFDs.
1167 * 2)  16 Byte Count circular buffers in 16 KBytes contiguous memory
1168 *     (1024 bytes for each queue).
1169 *
1170 * After receiving "Alive" response from uCode, driver must initialize
1171 * the scheduler (especially for queue #4/#9, the command queue, otherwise
1172 * the driver can't issue commands!):
1173 */
1174#define IWM_SCD_MEM_LOWER_BOUND		(0x0000)
1175
1176/**
1177 * Max Tx window size is the max number of contiguous TFDs that the scheduler
1178 * can keep track of at one time when creating block-ack chains of frames.
1179 * Note that "64" matches the number of ack bits in a block-ack packet.
1180 */
1181#define IWM_SCD_WIN_SIZE				64
1182#define IWM_SCD_FRAME_LIMIT				64
1183
1184#define IWM_SCD_TXFIFO_POS_TID			(0)
1185#define IWM_SCD_TXFIFO_POS_RA			(4)
1186#define IWM_SCD_QUEUE_RA_TID_MAP_RATID_MSK	(0x01FF)
1187
1188/* agn SCD */
1189#define IWM_SCD_QUEUE_STTS_REG_POS_TXF		(0)
1190#define IWM_SCD_QUEUE_STTS_REG_POS_ACTIVE	(3)
1191#define IWM_SCD_QUEUE_STTS_REG_POS_WSL		(4)
1192#define IWM_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN	(19)
1193#define IWM_SCD_QUEUE_STTS_REG_MSK		(0x017F0000)
1194
1195#define IWM_SCD_QUEUE_CTX_REG1_CREDIT_POS	(8)
1196#define IWM_SCD_QUEUE_CTX_REG1_CREDIT_MSK	(0x00FFFF00)
1197#define IWM_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS	(24)
1198#define IWM_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK	(0xFF000000)
1199#define IWM_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS	(0)
1200#define IWM_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK	(0x0000007F)
1201#define IWM_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
1202#define IWM_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
1203#define IWM_SCD_GP_CTRL_ENABLE_31_QUEUES	(1 << 0)
1204#define IWM_SCD_GP_CTRL_AUTO_ACTIVE_MODE	(1 << 18)
1205
1206/* Context Data */
1207#define IWM_SCD_CONTEXT_MEM_LOWER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x600)
1208#define IWM_SCD_CONTEXT_MEM_UPPER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x6A0)
1209
1210/* Tx status */
1211#define IWM_SCD_TX_STTS_MEM_LOWER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x6A0)
1212#define IWM_SCD_TX_STTS_MEM_UPPER_BOUND	(IWM_SCD_MEM_LOWER_BOUND + 0x7E0)
1213
1214/* Translation Data */
1215#define IWM_SCD_TRANS_TBL_MEM_LOWER_BOUND (IWM_SCD_MEM_LOWER_BOUND + 0x7E0)
1216#define IWM_SCD_TRANS_TBL_MEM_UPPER_BOUND (IWM_SCD_MEM_LOWER_BOUND + 0x808)
1217
1218#define IWM_SCD_CONTEXT_QUEUE_OFFSET(x)\
1219	(IWM_SCD_CONTEXT_MEM_LOWER_BOUND + ((x) * 8))
1220
1221#define IWM_SCD_TX_STTS_QUEUE_OFFSET(x)\
1222	(IWM_SCD_TX_STTS_MEM_LOWER_BOUND + ((x) * 16))
1223
1224#define IWM_SCD_TRANS_TBL_OFFSET_QUEUE(x) \
1225	((IWM_SCD_TRANS_TBL_MEM_LOWER_BOUND + ((x) * 2)) & 0xfffc)
1226
1227#define IWM_SCD_BASE			(IWM_PRPH_BASE + 0xa02c00)
1228
1229#define IWM_SCD_SRAM_BASE_ADDR	(IWM_SCD_BASE + 0x0)
1230#define IWM_SCD_DRAM_BASE_ADDR	(IWM_SCD_BASE + 0x8)
1231#define IWM_SCD_AIT		(IWM_SCD_BASE + 0x0c)
1232#define IWM_SCD_TXFACT		(IWM_SCD_BASE + 0x10)
1233#define IWM_SCD_ACTIVE		(IWM_SCD_BASE + 0x14)
1234#define IWM_SCD_QUEUECHAIN_SEL	(IWM_SCD_BASE + 0xe8)
1235#define IWM_SCD_CHAINEXT_EN	(IWM_SCD_BASE + 0x244)
1236#define IWM_SCD_AGGR_SEL	(IWM_SCD_BASE + 0x248)
1237#define IWM_SCD_INTERRUPT_MASK	(IWM_SCD_BASE + 0x108)
1238#define IWM_SCD_GP_CTRL		(IWM_SCD_BASE + 0x1a8)
1239#define IWM_SCD_EN_CTRL		(IWM_SCD_BASE + 0x254)
1240
1241static inline unsigned int IWM_SCD_QUEUE_WRPTR(unsigned int chnl)
1242{
1243	if (chnl < 20)
1244		return IWM_SCD_BASE + 0x18 + chnl * 4;
1245	return IWM_SCD_BASE + 0x284 + (chnl - 20) * 4;
1246}
1247
1248static inline unsigned int IWM_SCD_QUEUE_RDPTR(unsigned int chnl)
1249{
1250	if (chnl < 20)
1251		return IWM_SCD_BASE + 0x68 + chnl * 4;
1252	return IWM_SCD_BASE + 0x2B4 + (chnl - 20) * 4;
1253}
1254
1255static inline unsigned int IWM_SCD_QUEUE_STATUS_BITS(unsigned int chnl)
1256{
1257	if (chnl < 20)
1258		return IWM_SCD_BASE + 0x10c + chnl * 4;
1259	return IWM_SCD_BASE + 0x384 + (chnl - 20) * 4;
1260}
1261
1262/*********************** END TX SCHEDULER *************************************/
1263
1264/* Oscillator clock */
1265#define IWM_OSC_CLK				(0xa04068)
1266#define IWM_OSC_CLK_FORCE_CONTROL		(0x8)
1267
1268/*
1269 * END iwl-prph.h
1270 */
1271
1272/*
1273 * BEGIN iwl-fh.h
1274 */
1275
1276/****************************/
1277/* Flow Handler Definitions */
1278/****************************/
1279
1280/**
1281 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
1282 * Addresses are offsets from device's PCI hardware base address.
1283 */
1284#define IWM_FH_MEM_LOWER_BOUND                   (0x1000)
1285#define IWM_FH_MEM_UPPER_BOUND                   (0x2000)
1286
1287/**
1288 * Keep-Warm (KW) buffer base address.
1289 *
1290 * Driver must allocate a 4KByte buffer that is for keeping the
1291 * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
1292 * DRAM access when doing Txing or Rxing.  The dummy accesses prevent host
1293 * from going into a power-savings mode that would cause higher DRAM latency,
1294 * and possible data over/under-runs, before all Tx/Rx is complete.
1295 *
1296 * Driver loads IWM_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
1297 * of the buffer, which must be 4K aligned.  Once this is set up, the device
1298 * automatically invokes keep-warm accesses when normal accesses might not
1299 * be sufficient to maintain fast DRAM response.
1300 *
1301 * Bit fields:
1302 *  31-0:  Keep-warm buffer physical base address [35:4], must be 4K aligned
1303 */
1304#define IWM_FH_KW_MEM_ADDR_REG		     (IWM_FH_MEM_LOWER_BOUND + 0x97C)
1305
1306
1307/**
1308 * TFD Circular Buffers Base (CBBC) addresses
1309 *
1310 * Device has 16 base pointer registers, one for each of 16 host-DRAM-resident
1311 * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
1312 * (see struct iwm_tfd_frame).  These 16 pointer registers are offset by 0x04
1313 * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
1314 * aligned (address bits 0-7 must be 0).
1315 * Later devices have 20 (5000 series) or 30 (higher) queues, but the registers
1316 * for them are in different places.
1317 *
1318 * Bit fields in each pointer register:
1319 *  27-0: TFD CB physical base address [35:8], must be 256-byte aligned
1320 */
1321#define IWM_FH_MEM_CBBC_0_15_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0x9D0)
1322#define IWM_FH_MEM_CBBC_0_15_UPPER_BOUN		(IWM_FH_MEM_LOWER_BOUND + 0xA10)
1323#define IWM_FH_MEM_CBBC_16_19_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xBF0)
1324#define IWM_FH_MEM_CBBC_16_19_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xC00)
1325#define IWM_FH_MEM_CBBC_20_31_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xB20)
1326#define IWM_FH_MEM_CBBC_20_31_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xB80)
1327
1328/* Find TFD CB base pointer for given queue */
1329static inline unsigned int IWM_FH_MEM_CBBC_QUEUE(unsigned int chnl)
1330{
1331	if (chnl < 16)
1332		return IWM_FH_MEM_CBBC_0_15_LOWER_BOUND + 4 * chnl;
1333	if (chnl < 20)
1334		return IWM_FH_MEM_CBBC_16_19_LOWER_BOUND + 4 * (chnl - 16);
1335	return IWM_FH_MEM_CBBC_20_31_LOWER_BOUND + 4 * (chnl - 20);
1336}
1337
1338
1339/**
1340 * Rx SRAM Control and Status Registers (RSCSR)
1341 *
1342 * These registers provide handshake between driver and device for the Rx queue
1343 * (this queue handles *all* command responses, notifications, Rx data, etc.
1344 * sent from uCode to host driver).  Unlike Tx, there is only one Rx
1345 * queue, and only one Rx DMA/FIFO channel.  Also unlike Tx, which can
1346 * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
1347 * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
1348 * mapping between RBDs and RBs.
1349 *
1350 * Driver must allocate host DRAM memory for the following, and set the
1351 * physical address of each into device registers:
1352 *
1353 * 1)  Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
1354 *     entries (although any power of 2, up to 4096, is selectable by driver).
1355 *     Each entry (1 dword) points to a receive buffer (RB) of consistent size
1356 *     (typically 4K, although 8K or 16K are also selectable by driver).
1357 *     Driver sets up RB size and number of RBDs in the CB via Rx config
1358 *     register IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG.
1359 *
1360 *     Bit fields within one RBD:
1361 *     27-0:  Receive Buffer physical address bits [35:8], 256-byte aligned
1362 *
1363 *     Driver sets physical address [35:8] of base of RBD circular buffer
1364 *     into IWM_FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
1365 *
1366 * 2)  Rx status buffer, 8 bytes, in which uCode indicates which Rx Buffers
1367 *     (RBs) have been filled, via a "write pointer", actually the index of
1368 *     the RB's corresponding RBD within the circular buffer.  Driver sets
1369 *     physical address [35:4] into IWM_FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
1370 *
1371 *     Bit fields in lower dword of Rx status buffer (upper dword not used
1372 *     by driver:
1373 *     31-12:  Not used by driver
1374 *     11- 0:  Index of last filled Rx buffer descriptor
1375 *             (device writes, driver reads this value)
1376 *
1377 * As the driver prepares Receive Buffers (RBs) for device to fill, driver must
1378 * enter pointers to these RBs into contiguous RBD circular buffer entries,
1379 * and update the device's "write" index register,
1380 * IWM_FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
1381 *
1382 * This "write" index corresponds to the *next* RBD that the driver will make
1383 * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
1384 * the circular buffer.  This value should initially be 0 (before preparing any
1385 * RBs), should be 8 after preparing the first 8 RBs (for example), and must
1386 * wrap back to 0 at the end of the circular buffer (but don't wrap before
1387 * "read" index has advanced past 1!  See below).
1388 * NOTE:  DEVICE EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
1389 *
1390 * As the device fills RBs (referenced from contiguous RBDs within the circular
1391 * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
1392 * to tell the driver the index of the latest filled RBD.  The driver must
1393 * read this "read" index from DRAM after receiving an Rx interrupt from device
1394 *
1395 * The driver must also internally keep track of a third index, which is the
1396 * next RBD to process.  When receiving an Rx interrupt, driver should process
1397 * all filled but unprocessed RBs up to, but not including, the RB
1398 * corresponding to the "read" index.  For example, if "read" index becomes "1",
1399 * driver may process the RB pointed to by RBD 0.  Depending on volume of
1400 * traffic, there may be many RBs to process.
1401 *
1402 * If read index == write index, device thinks there is no room to put new data.
1403 * Due to this, the maximum number of filled RBs is 255, instead of 256.  To
1404 * be safe, make sure that there is a gap of at least 2 RBDs between "write"
1405 * and "read" indexes; that is, make sure that there are no more than 254
1406 * buffers waiting to be filled.
1407 */
1408#define IWM_FH_MEM_RSCSR_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xBC0)
1409#define IWM_FH_MEM_RSCSR_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0xC00)
1410#define IWM_FH_MEM_RSCSR_CHNL0		(IWM_FH_MEM_RSCSR_LOWER_BOUND)
1411
1412/**
1413 * Physical base address of 8-byte Rx Status buffer.
1414 * Bit fields:
1415 *  31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
1416 */
1417#define IWM_FH_RSCSR_CHNL0_STTS_WPTR_REG	(IWM_FH_MEM_RSCSR_CHNL0)
1418
1419/**
1420 * Physical base address of Rx Buffer Descriptor Circular Buffer.
1421 * Bit fields:
1422 *  27-0:  RBD CD physical base address [35:8], must be 256-byte aligned.
1423 */
1424#define IWM_FH_RSCSR_CHNL0_RBDCB_BASE_REG	(IWM_FH_MEM_RSCSR_CHNL0 + 0x004)
1425
1426/**
1427 * Rx write pointer (index, really!).
1428 * Bit fields:
1429 *  11-0:  Index of driver's most recent prepared-to-be-filled RBD, + 1.
1430 *         NOTE:  For 256-entry circular buffer, use only bits [7:0].
1431 */
1432#define IWM_FH_RSCSR_CHNL0_RBDCB_WPTR_REG	(IWM_FH_MEM_RSCSR_CHNL0 + 0x008)
1433#define IWM_FH_RSCSR_CHNL0_WPTR		(IWM_FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
1434
1435#define IWM_FW_RSCSR_CHNL0_RXDCB_RDPTR_REG	(IWM_FH_MEM_RSCSR_CHNL0 + 0x00c)
1436#define IWM_FH_RSCSR_CHNL0_RDPTR		IWM_FW_RSCSR_CHNL0_RXDCB_RDPTR_REG
1437
1438/**
1439 * Rx Config/Status Registers (RCSR)
1440 * Rx Config Reg for channel 0 (only channel used)
1441 *
1442 * Driver must initialize IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
1443 * normal operation (see bit fields).
1444 *
1445 * Clearing IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
1446 * Driver should poll IWM_FH_MEM_RSSR_RX_STATUS_REG	for
1447 * IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
1448 *
1449 * Bit fields:
1450 * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1451 *        '10' operate normally
1452 * 29-24: reserved
1453 * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
1454 *        min "5" for 32 RBDs, max "12" for 4096 RBDs.
1455 * 19-18: reserved
1456 * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
1457 *        '10' 12K, '11' 16K.
1458 * 15-14: reserved
1459 * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
1460 * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
1461 *        typical value 0x10 (about 1/2 msec)
1462 *  3- 0: reserved
1463 */
1464#define IWM_FH_MEM_RCSR_LOWER_BOUND      (IWM_FH_MEM_LOWER_BOUND + 0xC00)
1465#define IWM_FH_MEM_RCSR_UPPER_BOUND      (IWM_FH_MEM_LOWER_BOUND + 0xCC0)
1466#define IWM_FH_MEM_RCSR_CHNL0            (IWM_FH_MEM_RCSR_LOWER_BOUND)
1467
1468#define IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG	(IWM_FH_MEM_RCSR_CHNL0)
1469#define IWM_FH_MEM_RCSR_CHNL0_RBDCB_WPTR	(IWM_FH_MEM_RCSR_CHNL0 + 0x8)
1470#define IWM_FH_MEM_RCSR_CHNL0_FLUSH_RB_REQ	(IWM_FH_MEM_RCSR_CHNL0 + 0x10)
1471
1472#define IWM_FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */
1473#define IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK   (0x00001000) /* bits 12 */
1474#define IWM_FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */
1475#define IWM_FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK   (0x00030000) /* bits 16-17 */
1476#define IWM_FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */
1477#define IWM_FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/
1478
1479#define IWM_FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS	(20)
1480#define IWM_FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS	(4)
1481#define IWM_RX_RB_TIMEOUT	(0x11)
1482
1483#define IWM_FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL         (0x00000000)
1484#define IWM_FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL     (0x40000000)
1485#define IWM_FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL        (0x80000000)
1486
1487#define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K    (0x00000000)
1488#define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K    (0x00010000)
1489#define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K   (0x00020000)
1490#define IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K   (0x00030000)
1491
1492#define IWM_FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY              (0x00000004)
1493#define IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL    (0x00000000)
1494#define IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL  (0x00001000)
1495
1496/**
1497 * Rx Shared Status Registers (RSSR)
1498 *
1499 * After stopping Rx DMA channel (writing 0 to
1500 * IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
1501 * IWM_FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
1502 *
1503 * Bit fields:
1504 *  24:  1 = Channel 0 is idle
1505 *
1506 * IWM_FH_MEM_RSSR_SHARED_CTRL_REG and IWM_FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
1507 * contain default values that should not be altered by the driver.
1508 */
1509#define IWM_FH_MEM_RSSR_LOWER_BOUND     (IWM_FH_MEM_LOWER_BOUND + 0xC40)
1510#define IWM_FH_MEM_RSSR_UPPER_BOUND     (IWM_FH_MEM_LOWER_BOUND + 0xD00)
1511
1512#define IWM_FH_MEM_RSSR_SHARED_CTRL_REG (IWM_FH_MEM_RSSR_LOWER_BOUND)
1513#define IWM_FH_MEM_RSSR_RX_STATUS_REG	(IWM_FH_MEM_RSSR_LOWER_BOUND + 0x004)
1514#define IWM_FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
1515					(IWM_FH_MEM_RSSR_LOWER_BOUND + 0x008)
1516
1517#define IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE	(0x01000000)
1518
1519#define IWM_FH_MEM_TFDIB_REG1_ADDR_BITSHIFT	28
1520
1521/* TFDB  Area - TFDs buffer table */
1522#define IWM_FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK      (0xFFFFFFFF)
1523#define IWM_FH_TFDIB_LOWER_BOUND       (IWM_FH_MEM_LOWER_BOUND + 0x900)
1524#define IWM_FH_TFDIB_UPPER_BOUND       (IWM_FH_MEM_LOWER_BOUND + 0x958)
1525#define IWM_FH_TFDIB_CTRL0_REG(_chnl)  (IWM_FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
1526#define IWM_FH_TFDIB_CTRL1_REG(_chnl)  (IWM_FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
1527
1528/**
1529 * Transmit DMA Channel Control/Status Registers (TCSR)
1530 *
1531 * Device has one configuration register for each of 8 Tx DMA/FIFO channels
1532 * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1533 * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1534 *
1535 * To use a Tx DMA channel, driver must initialize its
1536 * IWM_FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1537 *
1538 * IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1539 * IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1540 *
1541 * All other bits should be 0.
1542 *
1543 * Bit fields:
1544 * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1545 *        '10' operate normally
1546 * 29- 4: Reserved, set to "0"
1547 *     3: Enable internal DMA requests (1, normal operation), disable (0)
1548 *  2- 0: Reserved, set to "0"
1549 */
1550#define IWM_FH_TCSR_LOWER_BOUND  (IWM_FH_MEM_LOWER_BOUND + 0xD00)
1551#define IWM_FH_TCSR_UPPER_BOUND  (IWM_FH_MEM_LOWER_BOUND + 0xE60)
1552
1553/* Find Control/Status reg for given Tx DMA/FIFO channel */
1554#define IWM_FH_TCSR_CHNL_NUM                            (8)
1555
1556/* TCSR: tx_config register values */
1557#define IWM_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl)	\
1558		(IWM_FH_TCSR_LOWER_BOUND + 0x20 * (_chnl))
1559#define IWM_FH_TCSR_CHNL_TX_CREDIT_REG(_chnl)	\
1560		(IWM_FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
1561#define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl)	\
1562		(IWM_FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
1563
1564#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF	(0x00000000)
1565#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV	(0x00000001)
1566
1567#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE	(0x00000000)
1568#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE		(0x00000008)
1569
1570#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT	(0x00000000)
1571#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD	(0x00100000)
1572#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD	(0x00200000)
1573
1574#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT	(0x00000000)
1575#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD	(0x00400000)
1576#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD	(0x00800000)
1577
1578#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE		(0x00000000)
1579#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF	(0x40000000)
1580#define IWM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE		(0x80000000)
1581
1582#define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY	(0x00000000)
1583#define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT	(0x00002000)
1584#define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID	(0x00000003)
1585
1586#define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM		(20)
1587#define IWM_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX		(12)
1588
1589/**
1590 * Tx Shared Status Registers (TSSR)
1591 *
1592 * After stopping Tx DMA channel (writing 0 to
1593 * IWM_FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1594 * IWM_FH_TSSR_TX_STATUS_REG until selected Tx channel is idle
1595 * (channel's buffers empty | no pending requests).
1596 *
1597 * Bit fields:
1598 * 31-24:  1 = Channel buffers empty (channel 7:0)
1599 * 23-16:  1 = No pending requests (channel 7:0)
1600 */
1601#define IWM_FH_TSSR_LOWER_BOUND		(IWM_FH_MEM_LOWER_BOUND + 0xEA0)
1602#define IWM_FH_TSSR_UPPER_BOUND		(IWM_FH_MEM_LOWER_BOUND + 0xEC0)
1603
1604#define IWM_FH_TSSR_TX_STATUS_REG	(IWM_FH_TSSR_LOWER_BOUND + 0x010)
1605
1606/**
1607 * Bit fields for TSSR(Tx Shared Status & Control) error status register:
1608 * 31:  Indicates an address error when accessed to internal memory
1609 *	uCode/driver must write "1" in order to clear this flag
1610 * 30:  Indicates that Host did not send the expected number of dwords to FH
1611 *	uCode/driver must write "1" in order to clear this flag
1612 * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
1613 *	command was received from the scheduler while the TRB was already full
1614 *	with previous command
1615 *	uCode/driver must write "1" in order to clear this flag
1616 * 7-0: Each status bit indicates a channel's TxCredit error. When an error
1617 *	bit is set, it indicates that the FH has received a full indication
1618 *	from the RTC TxFIFO and the current value of the TxCredit counter was
1619 *	not equal to zero. This mean that the credit mechanism was not
1620 *	synchronized to the TxFIFO status
1621 *	uCode/driver must write "1" in order to clear this flag
1622 */
1623#define IWM_FH_TSSR_TX_ERROR_REG	(IWM_FH_TSSR_LOWER_BOUND + 0x018)
1624#define IWM_FH_TSSR_TX_MSG_CONFIG_REG	(IWM_FH_TSSR_LOWER_BOUND + 0x008)
1625
1626#define IWM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
1627
1628/* Tx service channels */
1629#define IWM_FH_SRVC_CHNL		(9)
1630#define IWM_FH_SRVC_LOWER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0x9C8)
1631#define IWM_FH_SRVC_UPPER_BOUND	(IWM_FH_MEM_LOWER_BOUND + 0x9D0)
1632#define IWM_FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
1633		(IWM_FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
1634
1635#define IWM_FH_TX_CHICKEN_BITS_REG	(IWM_FH_MEM_LOWER_BOUND + 0xE98)
1636#define IWM_FH_TX_TRB_REG(_chan)	(IWM_FH_MEM_LOWER_BOUND + 0x958 + \
1637					(_chan) * 4)
1638
1639/* Instruct FH to increment the retry count of a packet when
1640 * it is brought from the memory to TX-FIFO
1641 */
1642#define IWM_FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN	(0x00000002)
1643
1644#define IWM_RX_QUEUE_SIZE                         256
1645#define IWM_RX_QUEUE_MASK                         255
1646#define IWM_RX_QUEUE_SIZE_LOG                     8
1647
1648/*
1649 * RX related structures and functions
1650 */
1651#define IWM_RX_FREE_BUFFERS 64
1652#define IWM_RX_LOW_WATERMARK 8
1653
1654/**
1655 * struct iwm_rb_status - reseve buffer status
1656 * 	host memory mapped FH registers
1657 * @closed_rb_num [0:11] - Indicates the index of the RB which was closed
1658 * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed
1659 * @finished_rb_num [0:11] - Indicates the index of the current RB
1660 * 	in which the last frame was written to
1661 * @finished_fr_num [0:11] - Indicates the index of the RX Frame
1662 * 	which was transferred
1663 */
1664struct iwm_rb_status {
1665	uint16_t closed_rb_num;
1666	uint16_t closed_fr_num;
1667	uint16_t finished_rb_num;
1668	uint16_t finished_fr_nam;
1669	uint32_t unused;
1670} __packed;
1671
1672
1673#define IWM_TFD_QUEUE_SIZE_MAX		(256)
1674#define IWM_TFD_QUEUE_SIZE_BC_DUP	(64)
1675#define IWM_TFD_QUEUE_BC_SIZE		(IWM_TFD_QUEUE_SIZE_MAX + \
1676					IWM_TFD_QUEUE_SIZE_BC_DUP)
1677#define IWM_TX_DMA_MASK        DMA_BIT_MASK(36)
1678#define IWM_NUM_OF_TBS		20
1679
1680static inline uint8_t iwm_get_dma_hi_addr(bus_addr_t addr)
1681{
1682	return (sizeof(addr) > sizeof(uint32_t) ? (addr >> 16) >> 16 : 0) & 0xF;
1683}
1684/**
1685 * struct iwm_tfd_tb transmit buffer descriptor within transmit frame descriptor
1686 *
1687 * This structure contains dma address and length of transmission address
1688 *
1689 * @lo: low [31:0] portion of the dma address of TX buffer
1690 * 	every even is unaligned on 16 bit boundary
1691 * @hi_n_len 0-3 [35:32] portion of dma
1692 *	     4-15 length of the tx buffer
1693 */
1694struct iwm_tfd_tb {
1695	uint32_t lo;
1696	uint16_t hi_n_len;
1697} __packed;
1698
1699/**
1700 * struct iwm_tfd
1701 *
1702 * Transmit Frame Descriptor (TFD)
1703 *
1704 * @ __reserved1[3] reserved
1705 * @ num_tbs 0-4 number of active tbs
1706 *	     5   reserved
1707 * 	     6-7 padding (not used)
1708 * @ tbs[20]	transmit frame buffer descriptors
1709 * @ __pad 	padding
1710 *
1711 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
1712 * Both driver and device share these circular buffers, each of which must be
1713 * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
1714 *
1715 * Driver must indicate the physical address of the base of each
1716 * circular buffer via the IWM_FH_MEM_CBBC_QUEUE registers.
1717 *
1718 * Each TFD contains pointer/size information for up to 20 data buffers
1719 * in host DRAM.  These buffers collectively contain the (one) frame described
1720 * by the TFD.  Each buffer must be a single contiguous block of memory within
1721 * itself, but buffers may be scattered in host DRAM.  Each buffer has max size
1722 * of (4K - 4).  The concatenates all of a TFD's buffers into a single
1723 * Tx frame, up to 8 KBytes in size.
1724 *
1725 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
1726 */
1727struct iwm_tfd {
1728	uint8_t __reserved1[3];
1729	uint8_t num_tbs;
1730	struct iwm_tfd_tb tbs[IWM_NUM_OF_TBS];
1731	uint32_t __pad;
1732} __packed;
1733
1734/* Keep Warm Size */
1735#define IWM_KW_SIZE 0x1000	/* 4k */
1736
1737/* Fixed (non-configurable) rx data from phy */
1738
1739/**
1740 * struct iwm_agn_schedq_bc_tbl scheduler byte count table
1741 *	base physical address provided by IWM_SCD_DRAM_BASE_ADDR
1742 * @tfd_offset  0-12 - tx command byte count
1743 *	       12-16 - station index
1744 */
1745struct iwm_agn_scd_bc_tbl {
1746	uint16_t tfd_offset[IWM_TFD_QUEUE_BC_SIZE];
1747} __packed;
1748
1749/*
1750 * END iwl-fh.h
1751 */
1752
1753/*
1754 * BEGIN mvm/fw-api.h
1755 */
1756
1757/* Maximum number of Tx queues. */
1758#define IWM_MVM_MAX_QUEUES	31
1759
1760/* Tx queue numbers */
1761enum {
1762	IWM_MVM_OFFCHANNEL_QUEUE = 8,
1763	IWM_MVM_CMD_QUEUE = 9,
1764	IWM_MVM_AUX_QUEUE = 15,
1765};
1766
1767enum iwm_mvm_tx_fifo {
1768	IWM_MVM_TX_FIFO_BK = 0,
1769	IWM_MVM_TX_FIFO_BE,
1770	IWM_MVM_TX_FIFO_VI,
1771	IWM_MVM_TX_FIFO_VO,
1772	IWM_MVM_TX_FIFO_MCAST = 5,
1773	IWM_MVM_TX_FIFO_CMD = 7,
1774};
1775
1776#define IWM_MVM_STATION_COUNT	16
1777
1778/* commands */
1779enum {
1780	IWM_MVM_ALIVE = 0x1,
1781	IWM_REPLY_ERROR = 0x2,
1782
1783	IWM_INIT_COMPLETE_NOTIF = 0x4,
1784
1785	/* PHY context commands */
1786	IWM_PHY_CONTEXT_CMD = 0x8,
1787	IWM_DBG_CFG = 0x9,
1788
1789	/* UMAC scan commands */
1790	IWM_SCAN_ITERATION_COMPLETE_UMAC = 0xb5,
1791	IWM_SCAN_CFG_CMD = 0xc,
1792	IWM_SCAN_REQ_UMAC = 0xd,
1793	IWM_SCAN_ABORT_UMAC = 0xe,
1794	IWM_SCAN_COMPLETE_UMAC = 0xf,
1795
1796	/* station table */
1797	IWM_ADD_STA_KEY = 0x17,
1798	IWM_ADD_STA = 0x18,
1799	IWM_REMOVE_STA = 0x19,
1800
1801	/* TX */
1802	IWM_TX_CMD = 0x1c,
1803	IWM_TXPATH_FLUSH = 0x1e,
1804	IWM_MGMT_MCAST_KEY = 0x1f,
1805
1806	/* scheduler config */
1807	IWM_SCD_QUEUE_CFG = 0x1d,
1808
1809	/* global key */
1810	IWM_WEP_KEY = 0x20,
1811
1812	/* MAC and Binding commands */
1813	IWM_MAC_CONTEXT_CMD = 0x28,
1814	IWM_TIME_EVENT_CMD = 0x29, /* both CMD and response */
1815	IWM_TIME_EVENT_NOTIFICATION = 0x2a,
1816	IWM_BINDING_CONTEXT_CMD = 0x2b,
1817	IWM_TIME_QUOTA_CMD = 0x2c,
1818	IWM_NON_QOS_TX_COUNTER_CMD = 0x2d,
1819
1820	IWM_LQ_CMD = 0x4e,
1821
1822	/* Calibration */
1823	IWM_TEMPERATURE_NOTIFICATION = 0x62,
1824	IWM_CALIBRATION_CFG_CMD = 0x65,
1825	IWM_CALIBRATION_RES_NOTIFICATION = 0x66,
1826	IWM_CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
1827	IWM_RADIO_VERSION_NOTIFICATION = 0x68,
1828
1829	/* Scan offload */
1830	IWM_SCAN_OFFLOAD_REQUEST_CMD = 0x51,
1831	IWM_SCAN_OFFLOAD_ABORT_CMD = 0x52,
1832	IWM_HOT_SPOT_CMD = 0x53,
1833	IWM_SCAN_OFFLOAD_COMPLETE = 0x6d,
1834	IWM_SCAN_OFFLOAD_UPDATE_PROFILES_CMD = 0x6e,
1835	IWM_SCAN_OFFLOAD_CONFIG_CMD = 0x6f,
1836	IWM_MATCH_FOUND_NOTIFICATION = 0xd9,
1837	IWM_SCAN_ITERATION_COMPLETE = 0xe7,
1838
1839	/* Phy */
1840	IWM_PHY_CONFIGURATION_CMD = 0x6a,
1841	IWM_CALIB_RES_NOTIF_PHY_DB = 0x6b,
1842	/* IWM_PHY_DB_CMD = 0x6c, */
1843
1844	/* Power - legacy power table command */
1845	IWM_POWER_TABLE_CMD = 0x77,
1846	IWM_PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78,
1847
1848	/* Thermal Throttling*/
1849	IWM_REPLY_THERMAL_MNG_BACKOFF = 0x7e,
1850
1851	/* Scanning */
1852	IWM_SCAN_ABORT_CMD = 0x81,
1853	IWM_SCAN_START_NOTIFICATION = 0x82,
1854	IWM_SCAN_RESULTS_NOTIFICATION = 0x83,
1855
1856	/* NVM */
1857	IWM_NVM_ACCESS_CMD = 0x88,
1858
1859	IWM_SET_CALIB_DEFAULT_CMD = 0x8e,
1860
1861	IWM_BEACON_NOTIFICATION = 0x90,
1862	IWM_BEACON_TEMPLATE_CMD = 0x91,
1863	IWM_TX_ANT_CONFIGURATION_CMD = 0x98,
1864	IWM_BT_CONFIG = 0x9b,
1865	IWM_STATISTICS_NOTIFICATION = 0x9d,
1866	IWM_REDUCE_TX_POWER_CMD = 0x9f,
1867
1868	/* RF-KILL commands and notifications */
1869	IWM_CARD_STATE_CMD = 0xa0,
1870	IWM_CARD_STATE_NOTIFICATION = 0xa1,
1871
1872	IWM_MISSED_BEACONS_NOTIFICATION = 0xa2,
1873
1874	IWM_MFUART_LOAD_NOTIFICATION = 0xb1,
1875
1876	/* Power - new power table command */
1877	IWM_MAC_PM_POWER_TABLE = 0xa9,
1878
1879	IWM_REPLY_RX_PHY_CMD = 0xc0,
1880	IWM_REPLY_RX_MPDU_CMD = 0xc1,
1881	IWM_BA_NOTIF = 0xc5,
1882
1883	/* Location Aware Regulatory */
1884	IWM_MCC_UPDATE_CMD = 0xc8,
1885	IWM_MCC_CHUB_UPDATE_CMD = 0xc9,
1886
1887	/* BT Coex */
1888	IWM_BT_COEX_PRIO_TABLE = 0xcc,
1889	IWM_BT_COEX_PROT_ENV = 0xcd,
1890	IWM_BT_PROFILE_NOTIFICATION = 0xce,
1891	IWM_BT_COEX_CI = 0x5d,
1892
1893	IWM_REPLY_SF_CFG_CMD = 0xd1,
1894	IWM_REPLY_BEACON_FILTERING_CMD = 0xd2,
1895
1896	/* DTS measurements */
1897	IWM_CMD_DTS_MEASUREMENT_TRIGGER = 0xdc,
1898	IWM_DTS_MEASUREMENT_NOTIFICATION = 0xdd,
1899
1900	IWM_REPLY_DEBUG_CMD = 0xf0,
1901	IWM_DEBUG_LOG_MSG = 0xf7,
1902
1903	IWM_MCAST_FILTER_CMD = 0xd0,
1904
1905	/* D3 commands/notifications */
1906	IWM_D3_CONFIG_CMD = 0xd3,
1907	IWM_PROT_OFFLOAD_CONFIG_CMD = 0xd4,
1908	IWM_OFFLOADS_QUERY_CMD = 0xd5,
1909	IWM_REMOTE_WAKE_CONFIG_CMD = 0xd6,
1910
1911	/* for WoWLAN in particular */
1912	IWM_WOWLAN_PATTERNS = 0xe0,
1913	IWM_WOWLAN_CONFIGURATION = 0xe1,
1914	IWM_WOWLAN_TSC_RSC_PARAM = 0xe2,
1915	IWM_WOWLAN_TKIP_PARAM = 0xe3,
1916	IWM_WOWLAN_KEK_KCK_MATERIAL = 0xe4,
1917	IWM_WOWLAN_GET_STATUSES = 0xe5,
1918	IWM_WOWLAN_TX_POWER_PER_DB = 0xe6,
1919
1920	/* and for NetDetect */
1921	IWM_NET_DETECT_CONFIG_CMD = 0x54,
1922	IWM_NET_DETECT_PROFILES_QUERY_CMD = 0x56,
1923	IWM_NET_DETECT_PROFILES_CMD = 0x57,
1924	IWM_NET_DETECT_HOTSPOTS_CMD = 0x58,
1925	IWM_NET_DETECT_HOTSPOTS_QUERY_CMD = 0x59,
1926
1927	IWM_REPLY_MAX = 0xff,
1928};
1929
1930/**
1931 * struct iwm_cmd_response - generic response struct for most commands
1932 * @status: status of the command asked, changes for each one
1933 */
1934struct iwm_cmd_response {
1935	uint32_t status;
1936};
1937
1938/*
1939 * struct iwm_tx_ant_cfg_cmd
1940 * @valid: valid antenna configuration
1941 */
1942struct iwm_tx_ant_cfg_cmd {
1943	uint32_t valid;
1944} __packed;
1945
1946/**
1947 * struct iwm_reduce_tx_power_cmd - TX power reduction command
1948 * IWM_REDUCE_TX_POWER_CMD = 0x9f
1949 * @flags: (reserved for future implementation)
1950 * @mac_context_id: id of the mac ctx for which we are reducing TX power.
1951 * @pwr_restriction: TX power restriction in dBms.
1952 */
1953struct iwm_reduce_tx_power_cmd {
1954	uint8_t flags;
1955	uint8_t mac_context_id;
1956	uint16_t pwr_restriction;
1957} __packed; /* IWM_TX_REDUCED_POWER_API_S_VER_1 */
1958
1959/*
1960 * Calibration control struct.
1961 * Sent as part of the phy configuration command.
1962 * @flow_trigger: bitmap for which calibrations to perform according to
1963 *		flow triggers.
1964 * @event_trigger: bitmap for which calibrations to perform according to
1965 *		event triggers.
1966 */
1967struct iwm_calib_ctrl {
1968	uint32_t flow_trigger;
1969	uint32_t event_trigger;
1970} __packed;
1971
1972/* This enum defines the bitmap of various calibrations to enable in both
1973 * init ucode and runtime ucode through IWM_CALIBRATION_CFG_CMD.
1974 */
1975enum iwm_calib_cfg {
1976	IWM_CALIB_CFG_XTAL_IDX			= (1 << 0),
1977	IWM_CALIB_CFG_TEMPERATURE_IDX		= (1 << 1),
1978	IWM_CALIB_CFG_VOLTAGE_READ_IDX		= (1 << 2),
1979	IWM_CALIB_CFG_PAPD_IDX			= (1 << 3),
1980	IWM_CALIB_CFG_TX_PWR_IDX		= (1 << 4),
1981	IWM_CALIB_CFG_DC_IDX			= (1 << 5),
1982	IWM_CALIB_CFG_BB_FILTER_IDX		= (1 << 6),
1983	IWM_CALIB_CFG_LO_LEAKAGE_IDX		= (1 << 7),
1984	IWM_CALIB_CFG_TX_IQ_IDX			= (1 << 8),
1985	IWM_CALIB_CFG_TX_IQ_SKEW_IDX		= (1 << 9),
1986	IWM_CALIB_CFG_RX_IQ_IDX			= (1 << 10),
1987	IWM_CALIB_CFG_RX_IQ_SKEW_IDX		= (1 << 11),
1988	IWM_CALIB_CFG_SENSITIVITY_IDX		= (1 << 12),
1989	IWM_CALIB_CFG_CHAIN_NOISE_IDX		= (1 << 13),
1990	IWM_CALIB_CFG_DISCONNECTED_ANT_IDX	= (1 << 14),
1991	IWM_CALIB_CFG_ANT_COUPLING_IDX		= (1 << 15),
1992	IWM_CALIB_CFG_DAC_IDX			= (1 << 16),
1993	IWM_CALIB_CFG_ABS_IDX			= (1 << 17),
1994	IWM_CALIB_CFG_AGC_IDX			= (1 << 18),
1995};
1996
1997/*
1998 * Phy configuration command.
1999 */
2000struct iwm_phy_cfg_cmd {
2001	uint32_t	phy_cfg;
2002	struct iwm_calib_ctrl calib_control;
2003} __packed;
2004
2005#define IWM_PHY_CFG_RADIO_TYPE	((1 << 0) | (1 << 1))
2006#define IWM_PHY_CFG_RADIO_STEP	((1 << 2) | (1 << 3))
2007#define IWM_PHY_CFG_RADIO_DASH	((1 << 4) | (1 << 5))
2008#define IWM_PHY_CFG_PRODUCT_NUMBER	((1 << 6) | (1 << 7))
2009#define IWM_PHY_CFG_TX_CHAIN_A	(1 << 8)
2010#define IWM_PHY_CFG_TX_CHAIN_B	(1 << 9)
2011#define IWM_PHY_CFG_TX_CHAIN_C	(1 << 10)
2012#define IWM_PHY_CFG_RX_CHAIN_A	(1 << 12)
2013#define IWM_PHY_CFG_RX_CHAIN_B	(1 << 13)
2014#define IWM_PHY_CFG_RX_CHAIN_C	(1 << 14)
2015
2016
2017/* Target of the IWM_NVM_ACCESS_CMD */
2018enum {
2019	IWM_NVM_ACCESS_TARGET_CACHE = 0,
2020	IWM_NVM_ACCESS_TARGET_OTP = 1,
2021	IWM_NVM_ACCESS_TARGET_EEPROM = 2,
2022};
2023
2024/* Section types for IWM_NVM_ACCESS_CMD */
2025enum {
2026	IWM_NVM_SECTION_TYPE_HW = 0,
2027	IWM_NVM_SECTION_TYPE_SW,
2028	IWM_NVM_SECTION_TYPE_PAPD,
2029	IWM_NVM_SECTION_TYPE_REGULATORY,
2030	IWM_NVM_SECTION_TYPE_CALIBRATION,
2031	IWM_NVM_SECTION_TYPE_PRODUCTION,
2032	IWM_NVM_SECTION_TYPE_POST_FCS_CALIB,
2033	/* 7, 8, 9 unknown */
2034	IWM_NVM_SECTION_TYPE_HW_8000 = 10,
2035	IWM_NVM_SECTION_TYPE_MAC_OVERRIDE,
2036	IWM_NVM_SECTION_TYPE_PHY_SKU,
2037	IWM_NVM_NUM_OF_SECTIONS,
2038};
2039
2040/**
2041 * struct iwm_nvm_access_cmd_ver2 - Request the device to send an NVM section
2042 * @op_code: 0 - read, 1 - write
2043 * @target: IWM_NVM_ACCESS_TARGET_*
2044 * @type: IWM_NVM_SECTION_TYPE_*
2045 * @offset: offset in bytes into the section
2046 * @length: in bytes, to read/write
2047 * @data: if write operation, the data to write. On read its empty
2048 */
2049struct iwm_nvm_access_cmd {
2050	uint8_t op_code;
2051	uint8_t target;
2052	uint16_t type;
2053	uint16_t offset;
2054	uint16_t length;
2055	uint8_t data[];
2056} __packed; /* IWM_NVM_ACCESS_CMD_API_S_VER_2 */
2057
2058/**
2059 * struct iwm_nvm_access_resp_ver2 - response to IWM_NVM_ACCESS_CMD
2060 * @offset: offset in bytes into the section
2061 * @length: in bytes, either how much was written or read
2062 * @type: IWM_NVM_SECTION_TYPE_*
2063 * @status: 0 for success, fail otherwise
2064 * @data: if read operation, the data returned. Empty on write.
2065 */
2066struct iwm_nvm_access_resp {
2067	uint16_t offset;
2068	uint16_t length;
2069	uint16_t type;
2070	uint16_t status;
2071	uint8_t data[];
2072} __packed; /* IWM_NVM_ACCESS_CMD_RESP_API_S_VER_2 */
2073
2074/* IWM_MVM_ALIVE 0x1 */
2075
2076/* alive response is_valid values */
2077#define IWM_ALIVE_RESP_UCODE_OK	(1 << 0)
2078#define IWM_ALIVE_RESP_RFKILL	(1 << 1)
2079
2080/* alive response ver_type values */
2081enum {
2082	IWM_FW_TYPE_HW = 0,
2083	IWM_FW_TYPE_PROT = 1,
2084	IWM_FW_TYPE_AP = 2,
2085	IWM_FW_TYPE_WOWLAN = 3,
2086	IWM_FW_TYPE_TIMING = 4,
2087	IWM_FW_TYPE_WIPAN = 5
2088};
2089
2090/* alive response ver_subtype values */
2091enum {
2092	IWM_FW_SUBTYPE_FULL_FEATURE = 0,
2093	IWM_FW_SUBTYPE_BOOTSRAP = 1, /* Not valid */
2094	IWM_FW_SUBTYPE_REDUCED = 2,
2095	IWM_FW_SUBTYPE_ALIVE_ONLY = 3,
2096	IWM_FW_SUBTYPE_WOWLAN = 4,
2097	IWM_FW_SUBTYPE_AP_SUBTYPE = 5,
2098	IWM_FW_SUBTYPE_WIPAN = 6,
2099	IWM_FW_SUBTYPE_INITIALIZE = 9
2100};
2101
2102#define IWM_ALIVE_STATUS_ERR 0xDEAD
2103#define IWM_ALIVE_STATUS_OK 0xCAFE
2104
2105#define IWM_ALIVE_FLG_RFKILL	(1 << 0)
2106
2107struct iwm_mvm_alive_resp_v1 {
2108	uint16_t status;
2109	uint16_t flags;
2110	uint8_t ucode_minor;
2111	uint8_t ucode_major;
2112	uint16_t id;
2113	uint8_t api_minor;
2114	uint8_t api_major;
2115	uint8_t ver_subtype;
2116	uint8_t ver_type;
2117	uint8_t mac;
2118	uint8_t opt;
2119	uint16_t reserved2;
2120	uint32_t timestamp;
2121	uint32_t error_event_table_ptr;	/* SRAM address for error log */
2122	uint32_t log_event_table_ptr;	/* SRAM address for event log */
2123	uint32_t cpu_register_ptr;
2124	uint32_t dbgm_config_ptr;
2125	uint32_t alive_counter_ptr;
2126	uint32_t scd_base_ptr;		/* SRAM address for SCD */
2127} __packed; /* IWM_ALIVE_RES_API_S_VER_1 */
2128
2129struct iwm_mvm_alive_resp_v2 {
2130	uint16_t status;
2131	uint16_t flags;
2132	uint8_t ucode_minor;
2133	uint8_t ucode_major;
2134	uint16_t id;
2135	uint8_t api_minor;
2136	uint8_t api_major;
2137	uint8_t ver_subtype;
2138	uint8_t ver_type;
2139	uint8_t mac;
2140	uint8_t opt;
2141	uint16_t reserved2;
2142	uint32_t timestamp;
2143	uint32_t error_event_table_ptr;	/* SRAM address for error log */
2144	uint32_t log_event_table_ptr;	/* SRAM address for LMAC event log */
2145	uint32_t cpu_register_ptr;
2146	uint32_t dbgm_config_ptr;
2147	uint32_t alive_counter_ptr;
2148	uint32_t scd_base_ptr;		/* SRAM address for SCD */
2149	uint32_t st_fwrd_addr;		/* pointer to Store and forward */
2150	uint32_t st_fwrd_size;
2151	uint8_t umac_minor;			/* UMAC version: minor */
2152	uint8_t umac_major;			/* UMAC version: major */
2153	uint16_t umac_id;			/* UMAC version: id */
2154	uint32_t error_info_addr;		/* SRAM address for UMAC error log */
2155	uint32_t dbg_print_buff_addr;
2156} __packed; /* ALIVE_RES_API_S_VER_2 */
2157
2158struct iwm_mvm_alive_resp_v3 {
2159	uint16_t status;
2160	uint16_t flags;
2161	uint32_t ucode_minor;
2162	uint32_t ucode_major;
2163	uint8_t ver_subtype;
2164	uint8_t ver_type;
2165	uint8_t mac;
2166	uint8_t opt;
2167	uint32_t timestamp;
2168	uint32_t error_event_table_ptr;	/* SRAM address for error log */
2169	uint32_t log_event_table_ptr;	/* SRAM address for LMAC event log */
2170	uint32_t cpu_register_ptr;
2171	uint32_t dbgm_config_ptr;
2172	uint32_t alive_counter_ptr;
2173	uint32_t scd_base_ptr;		/* SRAM address for SCD */
2174	uint32_t st_fwrd_addr;		/* pointer to Store and forward */
2175	uint32_t st_fwrd_size;
2176	uint32_t umac_minor;		/* UMAC version: minor */
2177	uint32_t umac_major;		/* UMAC version: major */
2178	uint32_t error_info_addr;		/* SRAM address for UMAC error log */
2179	uint32_t dbg_print_buff_addr;
2180} __packed; /* ALIVE_RES_API_S_VER_3 */
2181
2182/* Error response/notification */
2183enum {
2184	IWM_FW_ERR_UNKNOWN_CMD = 0x0,
2185	IWM_FW_ERR_INVALID_CMD_PARAM = 0x1,
2186	IWM_FW_ERR_SERVICE = 0x2,
2187	IWM_FW_ERR_ARC_MEMORY = 0x3,
2188	IWM_FW_ERR_ARC_CODE = 0x4,
2189	IWM_FW_ERR_WATCH_DOG = 0x5,
2190	IWM_FW_ERR_WEP_GRP_KEY_INDX = 0x10,
2191	IWM_FW_ERR_WEP_KEY_SIZE = 0x11,
2192	IWM_FW_ERR_OBSOLETE_FUNC = 0x12,
2193	IWM_FW_ERR_UNEXPECTED = 0xFE,
2194	IWM_FW_ERR_FATAL = 0xFF
2195};
2196
2197/**
2198 * struct iwm_error_resp - FW error indication
2199 * ( IWM_REPLY_ERROR = 0x2 )
2200 * @error_type: one of IWM_FW_ERR_*
2201 * @cmd_id: the command ID for which the error occurred
2202 * @bad_cmd_seq_num: sequence number of the erroneous command
2203 * @error_service: which service created the error, applicable only if
2204 *	error_type = 2, otherwise 0
2205 * @timestamp: TSF in usecs.
2206 */
2207struct iwm_error_resp {
2208	uint32_t error_type;
2209	uint8_t cmd_id;
2210	uint8_t reserved1;
2211	uint16_t bad_cmd_seq_num;
2212	uint32_t error_service;
2213	uint64_t timestamp;
2214} __packed;
2215
2216
2217/* Common PHY, MAC and Bindings definitions */
2218
2219#define IWM_MAX_MACS_IN_BINDING	(3)
2220#define IWM_MAX_BINDINGS		(4)
2221#define IWM_AUX_BINDING_INDEX	(3)
2222#define IWM_MAX_PHYS		(4)
2223
2224/* Used to extract ID and color from the context dword */
2225#define IWM_FW_CTXT_ID_POS	  (0)
2226#define IWM_FW_CTXT_ID_MSK	  (0xff << IWM_FW_CTXT_ID_POS)
2227#define IWM_FW_CTXT_COLOR_POS (8)
2228#define IWM_FW_CTXT_COLOR_MSK (0xff << IWM_FW_CTXT_COLOR_POS)
2229#define IWM_FW_CTXT_INVALID	  (0xffffffff)
2230
2231#define IWM_FW_CMD_ID_AND_COLOR(_id, _color) ((_id << IWM_FW_CTXT_ID_POS) |\
2232					  (_color << IWM_FW_CTXT_COLOR_POS))
2233
2234/* Possible actions on PHYs, MACs and Bindings */
2235enum {
2236	IWM_FW_CTXT_ACTION_STUB = 0,
2237	IWM_FW_CTXT_ACTION_ADD,
2238	IWM_FW_CTXT_ACTION_MODIFY,
2239	IWM_FW_CTXT_ACTION_REMOVE,
2240	IWM_FW_CTXT_ACTION_NUM
2241}; /* COMMON_CONTEXT_ACTION_API_E_VER_1 */
2242
2243/* Time Events */
2244
2245/* Time Event types, according to MAC type */
2246enum iwm_time_event_type {
2247	/* BSS Station Events */
2248	IWM_TE_BSS_STA_AGGRESSIVE_ASSOC,
2249	IWM_TE_BSS_STA_ASSOC,
2250	IWM_TE_BSS_EAP_DHCP_PROT,
2251	IWM_TE_BSS_QUIET_PERIOD,
2252
2253	/* P2P Device Events */
2254	IWM_TE_P2P_DEVICE_DISCOVERABLE,
2255	IWM_TE_P2P_DEVICE_LISTEN,
2256	IWM_TE_P2P_DEVICE_ACTION_SCAN,
2257	IWM_TE_P2P_DEVICE_FULL_SCAN,
2258
2259	/* P2P Client Events */
2260	IWM_TE_P2P_CLIENT_AGGRESSIVE_ASSOC,
2261	IWM_TE_P2P_CLIENT_ASSOC,
2262	IWM_TE_P2P_CLIENT_QUIET_PERIOD,
2263
2264	/* P2P GO Events */
2265	IWM_TE_P2P_GO_ASSOC_PROT,
2266	IWM_TE_P2P_GO_REPETITIVE_NOA,
2267	IWM_TE_P2P_GO_CT_WINDOW,
2268
2269	/* WiDi Sync Events */
2270	IWM_TE_WIDI_TX_SYNC,
2271
2272	IWM_TE_MAX
2273}; /* IWM_MAC_EVENT_TYPE_API_E_VER_1 */
2274
2275
2276
2277/* Time event - defines for command API v1 */
2278
2279/*
2280 * @IWM_TE_V1_FRAG_NONE: fragmentation of the time event is NOT allowed.
2281 * @IWM_TE_V1_FRAG_SINGLE: fragmentation of the time event is allowed, but only
2282 *	the first fragment is scheduled.
2283 * @IWM_TE_V1_FRAG_DUAL: fragmentation of the time event is allowed, but only
2284 *	the first 2 fragments are scheduled.
2285 * @IWM_TE_V1_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
2286 *	number of fragments are valid.
2287 *
2288 * Other than the constant defined above, specifying a fragmentation value 'x'
2289 * means that the event can be fragmented but only the first 'x' will be
2290 * scheduled.
2291 */
2292enum {
2293	IWM_TE_V1_FRAG_NONE = 0,
2294	IWM_TE_V1_FRAG_SINGLE = 1,
2295	IWM_TE_V1_FRAG_DUAL = 2,
2296	IWM_TE_V1_FRAG_ENDLESS = 0xffffffff
2297};
2298
2299/* If a Time Event can be fragmented, this is the max number of fragments */
2300#define IWM_TE_V1_FRAG_MAX_MSK		0x0fffffff
2301/* Repeat the time event endlessly (until removed) */
2302#define IWM_TE_V1_REPEAT_ENDLESS	0xffffffff
2303/* If a Time Event has bounded repetitions, this is the maximal value */
2304#define IWM_TE_V1_REPEAT_MAX_MSK_V1	0x0fffffff
2305
2306/* Time Event dependencies: none, on another TE, or in a specific time */
2307enum {
2308	IWM_TE_V1_INDEPENDENT		= 0,
2309	IWM_TE_V1_DEP_OTHER		= (1 << 0),
2310	IWM_TE_V1_DEP_TSF		= (1 << 1),
2311	IWM_TE_V1_EVENT_SOCIOPATHIC	= (1 << 2),
2312}; /* IWM_MAC_EVENT_DEPENDENCY_POLICY_API_E_VER_2 */
2313
2314/*
2315 * @IWM_TE_V1_NOTIF_NONE: no notifications
2316 * @IWM_TE_V1_NOTIF_HOST_EVENT_START: request/receive notification on event start
2317 * @IWM_TE_V1_NOTIF_HOST_EVENT_END:request/receive notification on event end
2318 * @IWM_TE_V1_NOTIF_INTERNAL_EVENT_START: internal FW use
2319 * @IWM_TE_V1_NOTIF_INTERNAL_EVENT_END: internal FW use.
2320 * @IWM_TE_V1_NOTIF_HOST_FRAG_START: request/receive notification on frag start
2321 * @IWM_TE_V1_NOTIF_HOST_FRAG_END:request/receive notification on frag end
2322 * @IWM_TE_V1_NOTIF_INTERNAL_FRAG_START: internal FW use.
2323 * @IWM_TE_V1_NOTIF_INTERNAL_FRAG_END: internal FW use.
2324 *
2325 * Supported Time event notifications configuration.
2326 * A notification (both event and fragment) includes a status indicating weather
2327 * the FW was able to schedule the event or not. For fragment start/end
2328 * notification the status is always success. There is no start/end fragment
2329 * notification for monolithic events.
2330 */
2331enum {
2332	IWM_TE_V1_NOTIF_NONE = 0,
2333	IWM_TE_V1_NOTIF_HOST_EVENT_START = (1 << 0),
2334	IWM_TE_V1_NOTIF_HOST_EVENT_END = (1 << 1),
2335	IWM_TE_V1_NOTIF_INTERNAL_EVENT_START = (1 << 2),
2336	IWM_TE_V1_NOTIF_INTERNAL_EVENT_END = (1 << 3),
2337	IWM_TE_V1_NOTIF_HOST_FRAG_START = (1 << 4),
2338	IWM_TE_V1_NOTIF_HOST_FRAG_END = (1 << 5),
2339	IWM_TE_V1_NOTIF_INTERNAL_FRAG_START = (1 << 6),
2340	IWM_TE_V1_NOTIF_INTERNAL_FRAG_END = (1 << 7),
2341	IWM_T2_V2_START_IMMEDIATELY = (1 << 11),
2342}; /* IWM_MAC_EVENT_ACTION_API_E_VER_2 */
2343
2344
2345/**
2346 * struct iwm_time_event_cmd_api_v1 - configuring Time Events
2347 * with struct IWM_MAC_TIME_EVENT_DATA_API_S_VER_1 (see also
2348 * with version 2. determined by IWM_UCODE_TLV_FLAGS)
2349 * ( IWM_TIME_EVENT_CMD = 0x29 )
2350 * @id_and_color: ID and color of the relevant MAC
2351 * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2352 * @id: this field has two meanings, depending on the action:
2353 *	If the action is ADD, then it means the type of event to add.
2354 *	For all other actions it is the unique event ID assigned when the
2355 *	event was added by the FW.
2356 * @apply_time: When to start the Time Event (in GP2)
2357 * @max_delay: maximum delay to event's start (apply time), in TU
2358 * @depends_on: the unique ID of the event we depend on (if any)
2359 * @interval: interval between repetitions, in TU
2360 * @interval_reciprocal: 2^32 / interval
2361 * @duration: duration of event in TU
2362 * @repeat: how many repetitions to do, can be IWM_TE_REPEAT_ENDLESS
2363 * @dep_policy: one of IWM_TE_V1_INDEPENDENT, IWM_TE_V1_DEP_OTHER, IWM_TE_V1_DEP_TSF
2364 *	and IWM_TE_V1_EVENT_SOCIOPATHIC
2365 * @is_present: 0 or 1, are we present or absent during the Time Event
2366 * @max_frags: maximal number of fragments the Time Event can be divided to
2367 * @notify: notifications using IWM_TE_V1_NOTIF_* (whom to notify when)
2368 */
2369struct iwm_time_event_cmd_v1 {
2370	/* COMMON_INDEX_HDR_API_S_VER_1 */
2371	uint32_t id_and_color;
2372	uint32_t action;
2373	uint32_t id;
2374	/* IWM_MAC_TIME_EVENT_DATA_API_S_VER_1 */
2375	uint32_t apply_time;
2376	uint32_t max_delay;
2377	uint32_t dep_policy;
2378	uint32_t depends_on;
2379	uint32_t is_present;
2380	uint32_t max_frags;
2381	uint32_t interval;
2382	uint32_t interval_reciprocal;
2383	uint32_t duration;
2384	uint32_t repeat;
2385	uint32_t notify;
2386} __packed; /* IWM_MAC_TIME_EVENT_CMD_API_S_VER_1 */
2387
2388
2389/* Time event - defines for command API v2 */
2390
2391/*
2392 * @IWM_TE_V2_FRAG_NONE: fragmentation of the time event is NOT allowed.
2393 * @IWM_TE_V2_FRAG_SINGLE: fragmentation of the time event is allowed, but only
2394 *  the first fragment is scheduled.
2395 * @IWM_TE_V2_FRAG_DUAL: fragmentation of the time event is allowed, but only
2396 *  the first 2 fragments are scheduled.
2397 * @IWM_TE_V2_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
2398 *  number of fragments are valid.
2399 *
2400 * Other than the constant defined above, specifying a fragmentation value 'x'
2401 * means that the event can be fragmented but only the first 'x' will be
2402 * scheduled.
2403 */
2404enum {
2405	IWM_TE_V2_FRAG_NONE = 0,
2406	IWM_TE_V2_FRAG_SINGLE = 1,
2407	IWM_TE_V2_FRAG_DUAL = 2,
2408	IWM_TE_V2_FRAG_MAX = 0xfe,
2409	IWM_TE_V2_FRAG_ENDLESS = 0xff
2410};
2411
2412/* Repeat the time event endlessly (until removed) */
2413#define IWM_TE_V2_REPEAT_ENDLESS	0xff
2414/* If a Time Event has bounded repetitions, this is the maximal value */
2415#define IWM_TE_V2_REPEAT_MAX	0xfe
2416
2417#define IWM_TE_V2_PLACEMENT_POS	12
2418#define IWM_TE_V2_ABSENCE_POS	15
2419
2420/* Time event policy values (for time event cmd api v2)
2421 * A notification (both event and fragment) includes a status indicating weather
2422 * the FW was able to schedule the event or not. For fragment start/end
2423 * notification the status is always success. There is no start/end fragment
2424 * notification for monolithic events.
2425 *
2426 * @IWM_TE_V2_DEFAULT_POLICY: independent, social, present, unoticable
2427 * @IWM_TE_V2_NOTIF_HOST_EVENT_START: request/receive notification on event start
2428 * @IWM_TE_V2_NOTIF_HOST_EVENT_END:request/receive notification on event end
2429 * @IWM_TE_V2_NOTIF_INTERNAL_EVENT_START: internal FW use
2430 * @IWM_TE_V2_NOTIF_INTERNAL_EVENT_END: internal FW use.
2431 * @IWM_TE_V2_NOTIF_HOST_FRAG_START: request/receive notification on frag start
2432 * @IWM_TE_V2_NOTIF_HOST_FRAG_END:request/receive notification on frag end
2433 * @IWM_TE_V2_NOTIF_INTERNAL_FRAG_START: internal FW use.
2434 * @IWM_TE_V2_NOTIF_INTERNAL_FRAG_END: internal FW use.
2435 * @IWM_TE_V2_DEP_OTHER: depends on another time event
2436 * @IWM_TE_V2_DEP_TSF: depends on a specific time
2437 * @IWM_TE_V2_EVENT_SOCIOPATHIC: can't co-exist with other events of tha same MAC
2438 * @IWM_TE_V2_ABSENCE: are we present or absent during the Time Event.
2439 */
2440enum {
2441	IWM_TE_V2_DEFAULT_POLICY = 0x0,
2442
2443	/* notifications (event start/stop, fragment start/stop) */
2444	IWM_TE_V2_NOTIF_HOST_EVENT_START = (1 << 0),
2445	IWM_TE_V2_NOTIF_HOST_EVENT_END = (1 << 1),
2446	IWM_TE_V2_NOTIF_INTERNAL_EVENT_START = (1 << 2),
2447	IWM_TE_V2_NOTIF_INTERNAL_EVENT_END = (1 << 3),
2448
2449	IWM_TE_V2_NOTIF_HOST_FRAG_START = (1 << 4),
2450	IWM_TE_V2_NOTIF_HOST_FRAG_END = (1 << 5),
2451	IWM_TE_V2_NOTIF_INTERNAL_FRAG_START = (1 << 6),
2452	IWM_TE_V2_NOTIF_INTERNAL_FRAG_END = (1 << 7),
2453
2454	IWM_TE_V2_NOTIF_MSK = 0xff,
2455
2456	/* placement characteristics */
2457	IWM_TE_V2_DEP_OTHER = (1 << IWM_TE_V2_PLACEMENT_POS),
2458	IWM_TE_V2_DEP_TSF = (1 << (IWM_TE_V2_PLACEMENT_POS + 1)),
2459	IWM_TE_V2_EVENT_SOCIOPATHIC = (1 << (IWM_TE_V2_PLACEMENT_POS + 2)),
2460
2461	/* are we present or absent during the Time Event. */
2462	IWM_TE_V2_ABSENCE = (1 << IWM_TE_V2_ABSENCE_POS),
2463};
2464
2465/**
2466 * struct iwm_time_event_cmd_api_v2 - configuring Time Events
2467 * with struct IWM_MAC_TIME_EVENT_DATA_API_S_VER_2 (see also
2468 * with version 1. determined by IWM_UCODE_TLV_FLAGS)
2469 * ( IWM_TIME_EVENT_CMD = 0x29 )
2470 * @id_and_color: ID and color of the relevant MAC
2471 * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2472 * @id: this field has two meanings, depending on the action:
2473 *	If the action is ADD, then it means the type of event to add.
2474 *	For all other actions it is the unique event ID assigned when the
2475 *	event was added by the FW.
2476 * @apply_time: When to start the Time Event (in GP2)
2477 * @max_delay: maximum delay to event's start (apply time), in TU
2478 * @depends_on: the unique ID of the event we depend on (if any)
2479 * @interval: interval between repetitions, in TU
2480 * @duration: duration of event in TU
2481 * @repeat: how many repetitions to do, can be IWM_TE_REPEAT_ENDLESS
2482 * @max_frags: maximal number of fragments the Time Event can be divided to
2483 * @policy: defines whether uCode shall notify the host or other uCode modules
2484 *	on event and/or fragment start and/or end
2485 *	using one of IWM_TE_INDEPENDENT, IWM_TE_DEP_OTHER, IWM_TE_DEP_TSF
2486 *	IWM_TE_EVENT_SOCIOPATHIC
2487 *	using IWM_TE_ABSENCE and using IWM_TE_NOTIF_*
2488 */
2489struct iwm_time_event_cmd_v2 {
2490	/* COMMON_INDEX_HDR_API_S_VER_1 */
2491	uint32_t id_and_color;
2492	uint32_t action;
2493	uint32_t id;
2494	/* IWM_MAC_TIME_EVENT_DATA_API_S_VER_2 */
2495	uint32_t apply_time;
2496	uint32_t max_delay;
2497	uint32_t depends_on;
2498	uint32_t interval;
2499	uint32_t duration;
2500	uint8_t repeat;
2501	uint8_t max_frags;
2502	uint16_t policy;
2503} __packed; /* IWM_MAC_TIME_EVENT_CMD_API_S_VER_2 */
2504
2505/**
2506 * struct iwm_time_event_resp - response structure to iwm_time_event_cmd
2507 * @status: bit 0 indicates success, all others specify errors
2508 * @id: the Time Event type
2509 * @unique_id: the unique ID assigned (in ADD) or given (others) to the TE
2510 * @id_and_color: ID and color of the relevant MAC
2511 */
2512struct iwm_time_event_resp {
2513	uint32_t status;
2514	uint32_t id;
2515	uint32_t unique_id;
2516	uint32_t id_and_color;
2517} __packed; /* IWM_MAC_TIME_EVENT_RSP_API_S_VER_1 */
2518
2519/**
2520 * struct iwm_time_event_notif - notifications of time event start/stop
2521 * ( IWM_TIME_EVENT_NOTIFICATION = 0x2a )
2522 * @timestamp: action timestamp in GP2
2523 * @session_id: session's unique id
2524 * @unique_id: unique id of the Time Event itself
2525 * @id_and_color: ID and color of the relevant MAC
2526 * @action: one of IWM_TE_NOTIF_START or IWM_TE_NOTIF_END
2527 * @status: true if scheduled, false otherwise (not executed)
2528 */
2529struct iwm_time_event_notif {
2530	uint32_t timestamp;
2531	uint32_t session_id;
2532	uint32_t unique_id;
2533	uint32_t id_and_color;
2534	uint32_t action;
2535	uint32_t status;
2536} __packed; /* IWM_MAC_TIME_EVENT_NTFY_API_S_VER_1 */
2537
2538
2539/* Bindings and Time Quota */
2540
2541/**
2542 * struct iwm_binding_cmd - configuring bindings
2543 * ( IWM_BINDING_CONTEXT_CMD = 0x2b )
2544 * @id_and_color: ID and color of the relevant Binding
2545 * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2546 * @macs: array of MAC id and colors which belong to the binding
2547 * @phy: PHY id and color which belongs to the binding
2548 */
2549struct iwm_binding_cmd {
2550	/* COMMON_INDEX_HDR_API_S_VER_1 */
2551	uint32_t id_and_color;
2552	uint32_t action;
2553	/* IWM_BINDING_DATA_API_S_VER_1 */
2554	uint32_t macs[IWM_MAX_MACS_IN_BINDING];
2555	uint32_t phy;
2556} __packed; /* IWM_BINDING_CMD_API_S_VER_1 */
2557
2558/* The maximal number of fragments in the FW's schedule session */
2559#define IWM_MVM_MAX_QUOTA 128
2560
2561/**
2562 * struct iwm_time_quota_data - configuration of time quota per binding
2563 * @id_and_color: ID and color of the relevant Binding
2564 * @quota: absolute time quota in TU. The scheduler will try to divide the
2565 *	remainig quota (after Time Events) according to this quota.
2566 * @max_duration: max uninterrupted context duration in TU
2567 */
2568struct iwm_time_quota_data {
2569	uint32_t id_and_color;
2570	uint32_t quota;
2571	uint32_t max_duration;
2572} __packed; /* IWM_TIME_QUOTA_DATA_API_S_VER_1 */
2573
2574/**
2575 * struct iwm_time_quota_cmd - configuration of time quota between bindings
2576 * ( IWM_TIME_QUOTA_CMD = 0x2c )
2577 * @quotas: allocations per binding
2578 */
2579struct iwm_time_quota_cmd {
2580	struct iwm_time_quota_data quotas[IWM_MAX_BINDINGS];
2581} __packed; /* IWM_TIME_QUOTA_ALLOCATION_CMD_API_S_VER_1 */
2582
2583
2584/* PHY context */
2585
2586/* Supported bands */
2587#define IWM_PHY_BAND_5  (0)
2588#define IWM_PHY_BAND_24 (1)
2589
2590/* Supported channel width, vary if there is VHT support */
2591#define IWM_PHY_VHT_CHANNEL_MODE20	(0x0)
2592#define IWM_PHY_VHT_CHANNEL_MODE40	(0x1)
2593#define IWM_PHY_VHT_CHANNEL_MODE80	(0x2)
2594#define IWM_PHY_VHT_CHANNEL_MODE160	(0x3)
2595
2596/*
2597 * Control channel position:
2598 * For legacy set bit means upper channel, otherwise lower.
2599 * For VHT - bit-2 marks if the control is lower/upper relative to center-freq
2600 *   bits-1:0 mark the distance from the center freq. for 20Mhz, offset is 0.
2601 *                                   center_freq
2602 *                                        |
2603 * 40Mhz                          |_______|_______|
2604 * 80Mhz                  |_______|_______|_______|_______|
2605 * 160Mhz |_______|_______|_______|_______|_______|_______|_______|_______|
2606 * code      011     010     001     000  |  100     101     110    111
2607 */
2608#define IWM_PHY_VHT_CTRL_POS_1_BELOW  (0x0)
2609#define IWM_PHY_VHT_CTRL_POS_2_BELOW  (0x1)
2610#define IWM_PHY_VHT_CTRL_POS_3_BELOW  (0x2)
2611#define IWM_PHY_VHT_CTRL_POS_4_BELOW  (0x3)
2612#define IWM_PHY_VHT_CTRL_POS_1_ABOVE  (0x4)
2613#define IWM_PHY_VHT_CTRL_POS_2_ABOVE  (0x5)
2614#define IWM_PHY_VHT_CTRL_POS_3_ABOVE  (0x6)
2615#define IWM_PHY_VHT_CTRL_POS_4_ABOVE  (0x7)
2616
2617/*
2618 * @band: IWM_PHY_BAND_*
2619 * @channel: channel number
2620 * @width: PHY_[VHT|LEGACY]_CHANNEL_*
2621 * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_*
2622 */
2623struct iwm_fw_channel_info {
2624	uint8_t band;
2625	uint8_t channel;
2626	uint8_t width;
2627	uint8_t ctrl_pos;
2628} __packed;
2629
2630#define IWM_PHY_RX_CHAIN_DRIVER_FORCE_POS	(0)
2631#define IWM_PHY_RX_CHAIN_DRIVER_FORCE_MSK \
2632	(0x1 << IWM_PHY_RX_CHAIN_DRIVER_FORCE_POS)
2633#define IWM_PHY_RX_CHAIN_VALID_POS		(1)
2634#define IWM_PHY_RX_CHAIN_VALID_MSK \
2635	(0x7 << IWM_PHY_RX_CHAIN_VALID_POS)
2636#define IWM_PHY_RX_CHAIN_FORCE_SEL_POS	(4)
2637#define IWM_PHY_RX_CHAIN_FORCE_SEL_MSK \
2638	(0x7 << IWM_PHY_RX_CHAIN_FORCE_SEL_POS)
2639#define IWM_PHY_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
2640#define IWM_PHY_RX_CHAIN_FORCE_MIMO_SEL_MSK \
2641	(0x7 << IWM_PHY_RX_CHAIN_FORCE_MIMO_SEL_POS)
2642#define IWM_PHY_RX_CHAIN_CNT_POS		(10)
2643#define IWM_PHY_RX_CHAIN_CNT_MSK \
2644	(0x3 << IWM_PHY_RX_CHAIN_CNT_POS)
2645#define IWM_PHY_RX_CHAIN_MIMO_CNT_POS	(12)
2646#define IWM_PHY_RX_CHAIN_MIMO_CNT_MSK \
2647	(0x3 << IWM_PHY_RX_CHAIN_MIMO_CNT_POS)
2648#define IWM_PHY_RX_CHAIN_MIMO_FORCE_POS	(14)
2649#define IWM_PHY_RX_CHAIN_MIMO_FORCE_MSK \
2650	(0x1 << IWM_PHY_RX_CHAIN_MIMO_FORCE_POS)
2651
2652/* TODO: fix the value, make it depend on firmware at runtime? */
2653#define IWM_NUM_PHY_CTX	3
2654
2655/* TODO: complete missing documentation */
2656/**
2657 * struct iwm_phy_context_cmd - config of the PHY context
2658 * ( IWM_PHY_CONTEXT_CMD = 0x8 )
2659 * @id_and_color: ID and color of the relevant Binding
2660 * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
2661 * @apply_time: 0 means immediate apply and context switch.
2662 *	other value means apply new params after X usecs
2663 * @tx_param_color: ???
2664 * @channel_info:
2665 * @txchain_info: ???
2666 * @rxchain_info: ???
2667 * @acquisition_data: ???
2668 * @dsp_cfg_flags: set to 0
2669 */
2670struct iwm_phy_context_cmd {
2671	/* COMMON_INDEX_HDR_API_S_VER_1 */
2672	uint32_t id_and_color;
2673	uint32_t action;
2674	/* IWM_PHY_CONTEXT_DATA_API_S_VER_1 */
2675	uint32_t apply_time;
2676	uint32_t tx_param_color;
2677	struct iwm_fw_channel_info ci;
2678	uint32_t txchain_info;
2679	uint32_t rxchain_info;
2680	uint32_t acquisition_data;
2681	uint32_t dsp_cfg_flags;
2682} __packed; /* IWM_PHY_CONTEXT_CMD_API_VER_1 */
2683
2684#define IWM_RX_INFO_PHY_CNT 8
2685#define IWM_RX_INFO_ENERGY_ANT_ABC_IDX 1
2686#define IWM_RX_INFO_ENERGY_ANT_A_MSK 0x000000ff
2687#define IWM_RX_INFO_ENERGY_ANT_B_MSK 0x0000ff00
2688#define IWM_RX_INFO_ENERGY_ANT_C_MSK 0x00ff0000
2689#define IWM_RX_INFO_ENERGY_ANT_A_POS 0
2690#define IWM_RX_INFO_ENERGY_ANT_B_POS 8
2691#define IWM_RX_INFO_ENERGY_ANT_C_POS 16
2692
2693#define IWM_RX_INFO_AGC_IDX 1
2694#define IWM_RX_INFO_RSSI_AB_IDX 2
2695#define IWM_OFDM_AGC_A_MSK 0x0000007f
2696#define IWM_OFDM_AGC_A_POS 0
2697#define IWM_OFDM_AGC_B_MSK 0x00003f80
2698#define IWM_OFDM_AGC_B_POS 7
2699#define IWM_OFDM_AGC_CODE_MSK 0x3fe00000
2700#define IWM_OFDM_AGC_CODE_POS 20
2701#define IWM_OFDM_RSSI_INBAND_A_MSK 0x00ff
2702#define IWM_OFDM_RSSI_A_POS 0
2703#define IWM_OFDM_RSSI_ALLBAND_A_MSK 0xff00
2704#define IWM_OFDM_RSSI_ALLBAND_A_POS 8
2705#define IWM_OFDM_RSSI_INBAND_B_MSK 0xff0000
2706#define IWM_OFDM_RSSI_B_POS 16
2707#define IWM_OFDM_RSSI_ALLBAND_B_MSK 0xff000000
2708#define IWM_OFDM_RSSI_ALLBAND_B_POS 24
2709
2710/**
2711 * struct iwm_rx_phy_info - phy info
2712 * (IWM_REPLY_RX_PHY_CMD = 0xc0)
2713 * @non_cfg_phy_cnt: non configurable DSP phy data byte count
2714 * @cfg_phy_cnt: configurable DSP phy data byte count
2715 * @stat_id: configurable DSP phy data set ID
2716 * @reserved1:
2717 * @system_timestamp: GP2  at on air rise
2718 * @timestamp: TSF at on air rise
2719 * @beacon_time_stamp: beacon at on-air rise
2720 * @phy_flags: general phy flags: band, modulation, ...
2721 * @channel: channel number
2722 * @non_cfg_phy_buf: for various implementations of non_cfg_phy
2723 * @rate_n_flags: IWM_RATE_MCS_*
2724 * @byte_count: frame's byte-count
2725 * @frame_time: frame's time on the air, based on byte count and frame rate
2726 *	calculation
2727 * @mac_active_msk: what MACs were active when the frame was received
2728 *
2729 * Before each Rx, the device sends this data. It contains PHY information
2730 * about the reception of the packet.
2731 */
2732struct iwm_rx_phy_info {
2733	uint8_t non_cfg_phy_cnt;
2734	uint8_t cfg_phy_cnt;
2735	uint8_t stat_id;
2736	uint8_t reserved1;
2737	uint32_t system_timestamp;
2738	uint64_t timestamp;
2739	uint32_t beacon_time_stamp;
2740	uint16_t phy_flags;
2741#define IWM_PHY_INFO_FLAG_SHPREAMBLE	(1 << 2)
2742	uint16_t channel;
2743	uint32_t non_cfg_phy[IWM_RX_INFO_PHY_CNT];
2744	uint8_t rate;
2745	uint8_t rflags;
2746	uint16_t xrflags;
2747	uint32_t byte_count;
2748	uint16_t mac_active_msk;
2749	uint16_t frame_time;
2750} __packed;
2751
2752struct iwm_rx_mpdu_res_start {
2753	uint16_t byte_count;
2754	uint16_t reserved;
2755} __packed;
2756
2757/**
2758 * enum iwm_rx_phy_flags - to parse %iwm_rx_phy_info phy_flags
2759 * @IWM_RX_RES_PHY_FLAGS_BAND_24: true if the packet was received on 2.4 band
2760 * @IWM_RX_RES_PHY_FLAGS_MOD_CCK:
2761 * @IWM_RX_RES_PHY_FLAGS_SHORT_PREAMBLE: true if packet's preamble was short
2762 * @IWM_RX_RES_PHY_FLAGS_NARROW_BAND:
2763 * @IWM_RX_RES_PHY_FLAGS_ANTENNA: antenna on which the packet was received
2764 * @IWM_RX_RES_PHY_FLAGS_AGG: set if the packet was part of an A-MPDU
2765 * @IWM_RX_RES_PHY_FLAGS_OFDM_HT: The frame was an HT frame
2766 * @IWM_RX_RES_PHY_FLAGS_OFDM_GF: The frame used GF preamble
2767 * @IWM_RX_RES_PHY_FLAGS_OFDM_VHT: The frame was a VHT frame
2768 */
2769enum iwm_rx_phy_flags {
2770	IWM_RX_RES_PHY_FLAGS_BAND_24		= (1 << 0),
2771	IWM_RX_RES_PHY_FLAGS_MOD_CCK		= (1 << 1),
2772	IWM_RX_RES_PHY_FLAGS_SHORT_PREAMBLE	= (1 << 2),
2773	IWM_RX_RES_PHY_FLAGS_NARROW_BAND	= (1 << 3),
2774	IWM_RX_RES_PHY_FLAGS_ANTENNA		= (0x7 << 4),
2775	IWM_RX_RES_PHY_FLAGS_ANTENNA_POS	= 4,
2776	IWM_RX_RES_PHY_FLAGS_AGG		= (1 << 7),
2777	IWM_RX_RES_PHY_FLAGS_OFDM_HT		= (1 << 8),
2778	IWM_RX_RES_PHY_FLAGS_OFDM_GF		= (1 << 9),
2779	IWM_RX_RES_PHY_FLAGS_OFDM_VHT		= (1 << 10),
2780};
2781
2782/**
2783 * enum iwm_mvm_rx_status - written by fw for each Rx packet
2784 * @IWM_RX_MPDU_RES_STATUS_CRC_OK: CRC is fine
2785 * @IWM_RX_MPDU_RES_STATUS_OVERRUN_OK: there was no RXE overflow
2786 * @IWM_RX_MPDU_RES_STATUS_SRC_STA_FOUND:
2787 * @IWM_RX_MPDU_RES_STATUS_KEY_VALID:
2788 * @IWM_RX_MPDU_RES_STATUS_KEY_PARAM_OK:
2789 * @IWM_RX_MPDU_RES_STATUS_ICV_OK: ICV is fine, if not, the packet is destroyed
2790 * @IWM_RX_MPDU_RES_STATUS_MIC_OK: used for CCM alg only. TKIP MIC is checked
2791 *	in the driver.
2792 * @IWM_RX_MPDU_RES_STATUS_TTAK_OK: TTAK is fine
2793 * @IWM_RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR:  valid for alg = CCM_CMAC or
2794 *	alg = CCM only. Checks replay attack for 11w frames. Relevant only if
2795 *	%IWM_RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME is set.
2796 * @IWM_RX_MPDU_RES_STATUS_SEC_NO_ENC: this frame is not encrypted
2797 * @IWM_RX_MPDU_RES_STATUS_SEC_WEP_ENC: this frame is encrypted using WEP
2798 * @IWM_RX_MPDU_RES_STATUS_SEC_CCM_ENC: this frame is encrypted using CCM
2799 * @IWM_RX_MPDU_RES_STATUS_SEC_TKIP_ENC: this frame is encrypted using TKIP
2800 * @IWM_RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC: this frame is encrypted using CCM_CMAC
2801 * @IWM_RX_MPDU_RES_STATUS_SEC_ENC_ERR: this frame couldn't be decrypted
2802 * @IWM_RX_MPDU_RES_STATUS_SEC_ENC_MSK: bitmask of the encryption algorithm
2803 * @IWM_RX_MPDU_RES_STATUS_DEC_DONE: this frame has been successfully decrypted
2804 * @IWM_RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP:
2805 * @IWM_RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP:
2806 * @IWM_RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT:
2807 * @IWM_RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME: this frame is an 11w management frame
2808 * @IWM_RX_MPDU_RES_STATUS_HASH_INDEX_MSK:
2809 * @IWM_RX_MPDU_RES_STATUS_STA_ID_MSK:
2810 * @IWM_RX_MPDU_RES_STATUS_RRF_KILL:
2811 * @IWM_RX_MPDU_RES_STATUS_FILTERING_MSK:
2812 * @IWM_RX_MPDU_RES_STATUS2_FILTERING_MSK:
2813 */
2814enum iwm_mvm_rx_status {
2815	IWM_RX_MPDU_RES_STATUS_CRC_OK			= (1 << 0),
2816	IWM_RX_MPDU_RES_STATUS_OVERRUN_OK		= (1 << 1),
2817	IWM_RX_MPDU_RES_STATUS_SRC_STA_FOUND		= (1 << 2),
2818	IWM_RX_MPDU_RES_STATUS_KEY_VALID		= (1 << 3),
2819	IWM_RX_MPDU_RES_STATUS_KEY_PARAM_OK		= (1 << 4),
2820	IWM_RX_MPDU_RES_STATUS_ICV_OK			= (1 << 5),
2821	IWM_RX_MPDU_RES_STATUS_MIC_OK			= (1 << 6),
2822	IWM_RX_MPDU_RES_STATUS_TTAK_OK			= (1 << 7),
2823	IWM_RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR	= (1 << 7),
2824	IWM_RX_MPDU_RES_STATUS_SEC_NO_ENC		= (0 << 8),
2825	IWM_RX_MPDU_RES_STATUS_SEC_WEP_ENC		= (1 << 8),
2826	IWM_RX_MPDU_RES_STATUS_SEC_CCM_ENC		= (2 << 8),
2827	IWM_RX_MPDU_RES_STATUS_SEC_TKIP_ENC		= (3 << 8),
2828	IWM_RX_MPDU_RES_STATUS_SEC_EXT_ENC		= (4 << 8),
2829	IWM_RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC		= (6 << 8),
2830	IWM_RX_MPDU_RES_STATUS_SEC_ENC_ERR		= (7 << 8),
2831	IWM_RX_MPDU_RES_STATUS_SEC_ENC_MSK		= (7 << 8),
2832	IWM_RX_MPDU_RES_STATUS_DEC_DONE			= (1 << 11),
2833	IWM_RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP	= (1 << 12),
2834	IWM_RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP		= (1 << 13),
2835	IWM_RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT		= (1 << 14),
2836	IWM_RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME		= (1 << 15),
2837	IWM_RX_MPDU_RES_STATUS_HASH_INDEX_MSK		= (0x3F0000),
2838	IWM_RX_MPDU_RES_STATUS_STA_ID_MSK		= (0x1f000000),
2839	IWM_RX_MPDU_RES_STATUS_RRF_KILL			= (1 << 29),
2840	IWM_RX_MPDU_RES_STATUS_FILTERING_MSK		= (0xc00000),
2841	IWM_RX_MPDU_RES_STATUS2_FILTERING_MSK		= (0xc0000000),
2842};
2843
2844/**
2845 * struct iwm_radio_version_notif - information on the radio version
2846 * ( IWM_RADIO_VERSION_NOTIFICATION = 0x68 )
2847 * @radio_flavor:
2848 * @radio_step:
2849 * @radio_dash:
2850 */
2851struct iwm_radio_version_notif {
2852	uint32_t radio_flavor;
2853	uint32_t radio_step;
2854	uint32_t radio_dash;
2855} __packed; /* IWM_RADIO_VERSION_NOTOFICATION_S_VER_1 */
2856
2857enum iwm_card_state_flags {
2858	IWM_CARD_ENABLED		= 0x00,
2859	IWM_HW_CARD_DISABLED	= 0x01,
2860	IWM_SW_CARD_DISABLED	= 0x02,
2861	IWM_CT_KILL_CARD_DISABLED	= 0x04,
2862	IWM_HALT_CARD_DISABLED	= 0x08,
2863	IWM_CARD_DISABLED_MSK	= 0x0f,
2864	IWM_CARD_IS_RX_ON		= 0x10,
2865};
2866
2867/**
2868 * struct iwm_radio_version_notif - information on the radio version
2869 * (IWM_CARD_STATE_NOTIFICATION = 0xa1 )
2870 * @flags: %iwm_card_state_flags
2871 */
2872struct iwm_card_state_notif {
2873	uint32_t flags;
2874} __packed; /* CARD_STATE_NTFY_API_S_VER_1 */
2875
2876/**
2877 * struct iwm_missed_beacons_notif - information on missed beacons
2878 * ( IWM_MISSED_BEACONS_NOTIFICATION = 0xa2 )
2879 * @mac_id: interface ID
2880 * @consec_missed_beacons_since_last_rx: number of consecutive missed
2881 *	beacons since last RX.
2882 * @consec_missed_beacons: number of consecutive missed beacons
2883 * @num_expected_beacons:
2884 * @num_recvd_beacons:
2885 */
2886struct iwm_missed_beacons_notif {
2887	uint32_t mac_id;
2888	uint32_t consec_missed_beacons_since_last_rx;
2889	uint32_t consec_missed_beacons;
2890	uint32_t num_expected_beacons;
2891	uint32_t num_recvd_beacons;
2892} __packed; /* IWM_MISSED_BEACON_NTFY_API_S_VER_3 */
2893
2894/**
2895 * struct iwm_mfuart_load_notif - mfuart image version & status
2896 * ( IWM_MFUART_LOAD_NOTIFICATION = 0xb1 )
2897 * @installed_ver: installed image version
2898 * @external_ver: external image version
2899 * @status: MFUART loading status
2900 * @duration: MFUART loading time
2901*/
2902struct iwm_mfuart_load_notif {
2903	uint32_t installed_ver;
2904	uint32_t external_ver;
2905	uint32_t status;
2906	uint32_t duration;
2907} __packed; /*MFU_LOADER_NTFY_API_S_VER_1*/
2908
2909/**
2910 * struct iwm_set_calib_default_cmd - set default value for calibration.
2911 * ( IWM_SET_CALIB_DEFAULT_CMD = 0x8e )
2912 * @calib_index: the calibration to set value for
2913 * @length: of data
2914 * @data: the value to set for the calibration result
2915 */
2916struct iwm_set_calib_default_cmd {
2917	uint16_t calib_index;
2918	uint16_t length;
2919	uint8_t data[0];
2920} __packed; /* IWM_PHY_CALIB_OVERRIDE_VALUES_S */
2921
2922#define IWM_MAX_PORT_ID_NUM	2
2923#define IWM_MAX_MCAST_FILTERING_ADDRESSES 256
2924
2925/**
2926 * struct iwm_mcast_filter_cmd - configure multicast filter.
2927 * @filter_own: Set 1 to filter out multicast packets sent by station itself
2928 * @port_id:	Multicast MAC addresses array specifier. This is a strange way
2929 *		to identify network interface adopted in host-device IF.
2930 *		It is used by FW as index in array of addresses. This array has
2931 *		IWM_MAX_PORT_ID_NUM members.
2932 * @count:	Number of MAC addresses in the array
2933 * @pass_all:	Set 1 to pass all multicast packets.
2934 * @bssid:	current association BSSID.
2935 * @addr_list:	Place holder for array of MAC addresses.
2936 *		IMPORTANT: add padding if necessary to ensure DWORD alignment.
2937 */
2938struct iwm_mcast_filter_cmd {
2939	uint8_t filter_own;
2940	uint8_t port_id;
2941	uint8_t count;
2942	uint8_t pass_all;
2943	uint8_t bssid[6];
2944	uint8_t reserved[2];
2945	uint8_t addr_list[0];
2946} __packed; /* IWM_MCAST_FILTERING_CMD_API_S_VER_1 */
2947
2948struct iwm_mvm_statistics_dbg {
2949	uint32_t burst_check;
2950	uint32_t burst_count;
2951	uint32_t wait_for_silence_timeout_cnt;
2952	uint32_t reserved[3];
2953} __packed; /* IWM_STATISTICS_DEBUG_API_S_VER_2 */
2954
2955struct iwm_mvm_statistics_div {
2956	uint32_t tx_on_a;
2957	uint32_t tx_on_b;
2958	uint32_t exec_time;
2959	uint32_t probe_time;
2960	uint32_t rssi_ant;
2961	uint32_t reserved2;
2962} __packed; /* IWM_STATISTICS_SLOW_DIV_API_S_VER_2 */
2963
2964struct iwm_mvm_statistics_general_common {
2965	uint32_t temperature;   /* radio temperature */
2966	uint32_t temperature_m; /* radio voltage */
2967	struct iwm_mvm_statistics_dbg dbg;
2968	uint32_t sleep_time;
2969	uint32_t slots_out;
2970	uint32_t slots_idle;
2971	uint32_t ttl_timestamp;
2972	struct iwm_mvm_statistics_div div;
2973	uint32_t rx_enable_counter;
2974	/*
2975	 * num_of_sos_states:
2976	 *  count the number of times we have to re-tune
2977	 *  in order to get out of bad PHY status
2978	 */
2979	uint32_t num_of_sos_states;
2980} __packed; /* IWM_STATISTICS_GENERAL_API_S_VER_5 */
2981
2982struct iwm_mvm_statistics_rx_non_phy {
2983	uint32_t bogus_cts;	/* CTS received when not expecting CTS */
2984	uint32_t bogus_ack;	/* ACK received when not expecting ACK */
2985	uint32_t non_bssid_frames;	/* number of frames with BSSID that
2986					 * doesn't belong to the STA BSSID */
2987	uint32_t filtered_frames;	/* count frames that were dumped in the
2988				 * filtering process */
2989	uint32_t non_channel_beacons;	/* beacons with our bss id but not on
2990					 * our serving channel */
2991	uint32_t channel_beacons;	/* beacons with our bss id and in our
2992				 * serving channel */
2993	uint32_t num_missed_bcon;	/* number of missed beacons */
2994	uint32_t adc_rx_saturation_time;	/* count in 0.8us units the time the
2995					 * ADC was in saturation */
2996	uint32_t ina_detection_search_time;/* total time (in 0.8us) searched
2997					  * for INA */
2998	uint32_t beacon_silence_rssi[3];/* RSSI silence after beacon frame */
2999	uint32_t interference_data_flag;	/* flag for interference data
3000					 * availability. 1 when data is
3001					 * available. */
3002	uint32_t channel_load;		/* counts RX Enable time in uSec */
3003	uint32_t dsp_false_alarms;	/* DSP false alarm (both OFDM
3004					 * and CCK) counter */
3005	uint32_t beacon_rssi_a;
3006	uint32_t beacon_rssi_b;
3007	uint32_t beacon_rssi_c;
3008	uint32_t beacon_energy_a;
3009	uint32_t beacon_energy_b;
3010	uint32_t beacon_energy_c;
3011	uint32_t num_bt_kills;
3012	uint32_t mac_id;
3013	uint32_t directed_data_mpdu;
3014} __packed; /* IWM_STATISTICS_RX_NON_PHY_API_S_VER_3 */
3015
3016struct iwm_mvm_statistics_rx_phy {
3017	uint32_t ina_cnt;
3018	uint32_t fina_cnt;
3019	uint32_t plcp_err;
3020	uint32_t crc32_err;
3021	uint32_t overrun_err;
3022	uint32_t early_overrun_err;
3023	uint32_t crc32_good;
3024	uint32_t false_alarm_cnt;
3025	uint32_t fina_sync_err_cnt;
3026	uint32_t sfd_timeout;
3027	uint32_t fina_timeout;
3028	uint32_t unresponded_rts;
3029	uint32_t rxe_frame_limit_overrun;
3030	uint32_t sent_ack_cnt;
3031	uint32_t sent_cts_cnt;
3032	uint32_t sent_ba_rsp_cnt;
3033	uint32_t dsp_self_kill;
3034	uint32_t mh_format_err;
3035	uint32_t re_acq_main_rssi_sum;
3036	uint32_t reserved;
3037} __packed; /* IWM_STATISTICS_RX_PHY_API_S_VER_2 */
3038
3039struct iwm_mvm_statistics_rx_ht_phy {
3040	uint32_t plcp_err;
3041	uint32_t overrun_err;
3042	uint32_t early_overrun_err;
3043	uint32_t crc32_good;
3044	uint32_t crc32_err;
3045	uint32_t mh_format_err;
3046	uint32_t agg_crc32_good;
3047	uint32_t agg_mpdu_cnt;
3048	uint32_t agg_cnt;
3049	uint32_t unsupport_mcs;
3050} __packed;  /* IWM_STATISTICS_HT_RX_PHY_API_S_VER_1 */
3051
3052#define IWM_MAX_CHAINS 3
3053
3054struct iwm_mvm_statistics_tx_non_phy_agg {
3055	uint32_t ba_timeout;
3056	uint32_t ba_reschedule_frames;
3057	uint32_t scd_query_agg_frame_cnt;
3058	uint32_t scd_query_no_agg;
3059	uint32_t scd_query_agg;
3060	uint32_t scd_query_mismatch;
3061	uint32_t frame_not_ready;
3062	uint32_t underrun;
3063	uint32_t bt_prio_kill;
3064	uint32_t rx_ba_rsp_cnt;
3065	int8_t txpower[IWM_MAX_CHAINS];
3066	int8_t reserved;
3067	uint32_t reserved2;
3068} __packed; /* IWM_STATISTICS_TX_NON_PHY_AGG_API_S_VER_1 */
3069
3070struct iwm_mvm_statistics_tx_channel_width {
3071	uint32_t ext_cca_narrow_ch20[1];
3072	uint32_t ext_cca_narrow_ch40[2];
3073	uint32_t ext_cca_narrow_ch80[3];
3074	uint32_t ext_cca_narrow_ch160[4];
3075	uint32_t last_tx_ch_width_indx;
3076	uint32_t rx_detected_per_ch_width[4];
3077	uint32_t success_per_ch_width[4];
3078	uint32_t fail_per_ch_width[4];
3079}; /* IWM_STATISTICS_TX_CHANNEL_WIDTH_API_S_VER_1 */
3080
3081struct iwm_mvm_statistics_tx {
3082	uint32_t preamble_cnt;
3083	uint32_t rx_detected_cnt;
3084	uint32_t bt_prio_defer_cnt;
3085	uint32_t bt_prio_kill_cnt;
3086	uint32_t few_bytes_cnt;
3087	uint32_t cts_timeout;
3088	uint32_t ack_timeout;
3089	uint32_t expected_ack_cnt;
3090	uint32_t actual_ack_cnt;
3091	uint32_t dump_msdu_cnt;
3092	uint32_t burst_abort_next_frame_mismatch_cnt;
3093	uint32_t burst_abort_missing_next_frame_cnt;
3094	uint32_t cts_timeout_collision;
3095	uint32_t ack_or_ba_timeout_collision;
3096	struct iwm_mvm_statistics_tx_non_phy_agg agg;
3097	struct iwm_mvm_statistics_tx_channel_width channel_width;
3098} __packed; /* IWM_STATISTICS_TX_API_S_VER_4 */
3099
3100
3101struct iwm_mvm_statistics_bt_activity {
3102	uint32_t hi_priority_tx_req_cnt;
3103	uint32_t hi_priority_tx_denied_cnt;
3104	uint32_t lo_priority_tx_req_cnt;
3105	uint32_t lo_priority_tx_denied_cnt;
3106	uint32_t hi_priority_rx_req_cnt;
3107	uint32_t hi_priority_rx_denied_cnt;
3108	uint32_t lo_priority_rx_req_cnt;
3109	uint32_t lo_priority_rx_denied_cnt;
3110} __packed;  /* IWM_STATISTICS_BT_ACTIVITY_API_S_VER_1 */
3111
3112struct iwm_mvm_statistics_general {
3113	struct iwm_mvm_statistics_general_common common;
3114	uint32_t beacon_filtered;
3115	uint32_t missed_beacons;
3116	int8_t beacon_filter_average_energy;
3117	int8_t beacon_filter_reason;
3118	int8_t beacon_filter_current_energy;
3119	int8_t beacon_filter_reserved;
3120	uint32_t beacon_filter_delta_time;
3121	struct iwm_mvm_statistics_bt_activity bt_activity;
3122} __packed; /* IWM_STATISTICS_GENERAL_API_S_VER_5 */
3123
3124struct iwm_mvm_statistics_rx {
3125	struct iwm_mvm_statistics_rx_phy ofdm;
3126	struct iwm_mvm_statistics_rx_phy cck;
3127	struct iwm_mvm_statistics_rx_non_phy general;
3128	struct iwm_mvm_statistics_rx_ht_phy ofdm_ht;
3129} __packed; /* IWM_STATISTICS_RX_API_S_VER_3 */
3130
3131/*
3132 * IWM_STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3133 *
3134 * By default, uCode issues this notification after receiving a beacon
3135 * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
3136 * IWM_REPLY_STATISTICS_CMD 0x9c, above.
3137 *
3138 * Statistics counters continue to increment beacon after beacon, but are
3139 * cleared when changing channels or when driver issues IWM_REPLY_STATISTICS_CMD
3140 * 0x9c with CLEAR_STATS bit set (see above).
3141 *
3142 * uCode also issues this notification during scans.  uCode clears statistics
3143 * appropriately so that each notification contains statistics for only the
3144 * one channel that has just been scanned.
3145 */
3146
3147struct iwm_notif_statistics { /* IWM_STATISTICS_NTFY_API_S_VER_8 */
3148	uint32_t flag;
3149	struct iwm_mvm_statistics_rx rx;
3150	struct iwm_mvm_statistics_tx tx;
3151	struct iwm_mvm_statistics_general general;
3152} __packed;
3153
3154/***********************************
3155 * Smart Fifo API
3156 ***********************************/
3157/* Smart Fifo state */
3158enum iwm_sf_state {
3159	IWM_SF_LONG_DELAY_ON = 0, /* should never be called by driver */
3160	IWM_SF_FULL_ON,
3161	IWM_SF_UNINIT,
3162	IWM_SF_INIT_OFF,
3163	IWM_SF_HW_NUM_STATES
3164};
3165
3166/* Smart Fifo possible scenario */
3167enum iwm_sf_scenario {
3168	IWM_SF_SCENARIO_SINGLE_UNICAST,
3169	IWM_SF_SCENARIO_AGG_UNICAST,
3170	IWM_SF_SCENARIO_MULTICAST,
3171	IWM_SF_SCENARIO_BA_RESP,
3172	IWM_SF_SCENARIO_TX_RESP,
3173	IWM_SF_NUM_SCENARIO
3174};
3175
3176#define IWM_SF_TRANSIENT_STATES_NUMBER 2 /* IWM_SF_LONG_DELAY_ON and IWM_SF_FULL_ON */
3177#define IWM_SF_NUM_TIMEOUT_TYPES 2	/* Aging timer and Idle timer */
3178
3179/* smart FIFO default values */
3180#define IWM_SF_W_MARK_SISO 4096
3181#define IWM_SF_W_MARK_MIMO2 8192
3182#define IWM_SF_W_MARK_MIMO3 6144
3183#define IWM_SF_W_MARK_LEGACY 4096
3184#define IWM_SF_W_MARK_SCAN 4096
3185
3186/* SF Scenarios timers for default configuration (aligned to 32 uSec) */
3187#define IWM_SF_SINGLE_UNICAST_IDLE_TIMER_DEF 160	/* 150 uSec  */
3188#define IWM_SF_SINGLE_UNICAST_AGING_TIMER_DEF 400	/* 0.4 mSec */
3189#define IWM_SF_AGG_UNICAST_IDLE_TIMER_DEF 160		/* 150 uSec */
3190#define IWM_SF_AGG_UNICAST_AGING_TIMER_DEF 400		/* 0.4 mSec */
3191#define IWM_SF_MCAST_IDLE_TIMER_DEF 160			/* 150 uSec */
3192#define IWM_SF_MCAST_AGING_TIMER_DEF 400		/* 0.4 mSec */
3193#define IWM_SF_BA_IDLE_TIMER_DEF 160			/* 150 uSec */
3194#define IWM_SF_BA_AGING_TIMER_DEF 400			/* 0.4 mSec */
3195#define IWM_SF_TX_RE_IDLE_TIMER_DEF 160			/* 150 uSec */
3196#define IWM_SF_TX_RE_AGING_TIMER_DEF 400		/* 0.4 mSec */
3197
3198/* SF Scenarios timers for FULL_ON state (aligned to 32 uSec) */
3199#define IWM_SF_SINGLE_UNICAST_IDLE_TIMER 320	/* 300 uSec  */
3200#define IWM_SF_SINGLE_UNICAST_AGING_TIMER 2016	/* 2 mSec */
3201#define IWM_SF_AGG_UNICAST_IDLE_TIMER 320	/* 300 uSec */
3202#define IWM_SF_AGG_UNICAST_AGING_TIMER 2016	/* 2 mSec */
3203#define IWM_SF_MCAST_IDLE_TIMER 2016		/* 2 mSec */
3204#define IWM_SF_MCAST_AGING_TIMER 10016		/* 10 mSec */
3205#define IWM_SF_BA_IDLE_TIMER 320		/* 300 uSec */
3206#define IWM_SF_BA_AGING_TIMER 2016		/* 2 mSec */
3207#define IWM_SF_TX_RE_IDLE_TIMER 320		/* 300 uSec */
3208#define IWM_SF_TX_RE_AGING_TIMER 2016		/* 2 mSec */
3209
3210#define IWM_SF_LONG_DELAY_AGING_TIMER 1000000	/* 1 Sec */
3211
3212#define IWM_SF_CFG_DUMMY_NOTIF_OFF	(1 << 16)
3213
3214/**
3215 * Smart Fifo configuration command.
3216 * @state: smart fifo state, types listed in iwm_sf_state.
3217 * @watermark: Minimum allowed available free space in RXF for transient state.
3218 * @long_delay_timeouts: aging and idle timer values for each scenario
3219 * in long delay state.
3220 * @full_on_timeouts: timer values for each scenario in full on state.
3221 */
3222struct iwm_sf_cfg_cmd {
3223	uint32_t state;
3224	uint32_t watermark[IWM_SF_TRANSIENT_STATES_NUMBER];
3225	uint32_t long_delay_timeouts[IWM_SF_NUM_SCENARIO][IWM_SF_NUM_TIMEOUT_TYPES];
3226	uint32_t full_on_timeouts[IWM_SF_NUM_SCENARIO][IWM_SF_NUM_TIMEOUT_TYPES];
3227} __packed; /* IWM_SF_CFG_API_S_VER_2 */
3228
3229/*
3230 * END mvm/fw-api.h
3231 */
3232
3233/*
3234 * BEGIN mvm/fw-api-mac.h
3235 */
3236
3237/*
3238 * The first MAC indices (starting from 0)
3239 * are available to the driver, AUX follows
3240 */
3241#define IWM_MAC_INDEX_AUX		4
3242#define IWM_MAC_INDEX_MIN_DRIVER	0
3243#define IWM_NUM_MAC_INDEX_DRIVER	IWM_MAC_INDEX_AUX
3244
3245enum iwm_ac {
3246	IWM_AC_BK,
3247	IWM_AC_BE,
3248	IWM_AC_VI,
3249	IWM_AC_VO,
3250	IWM_AC_NUM,
3251};
3252
3253/**
3254 * enum iwm_mac_protection_flags - MAC context flags
3255 * @IWM_MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames,
3256 *	this will require CCK RTS/CTS2self.
3257 *	RTS/CTS will protect full burst time.
3258 * @IWM_MAC_PROT_FLG_HT_PROT: enable HT protection
3259 * @IWM_MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions
3260 * @IWM_MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self
3261 */
3262enum iwm_mac_protection_flags {
3263	IWM_MAC_PROT_FLG_TGG_PROTECT	= (1 << 3),
3264	IWM_MAC_PROT_FLG_HT_PROT		= (1 << 23),
3265	IWM_MAC_PROT_FLG_FAT_PROT		= (1 << 24),
3266	IWM_MAC_PROT_FLG_SELF_CTS_EN	= (1 << 30),
3267};
3268
3269#define IWM_MAC_FLG_SHORT_SLOT		(1 << 4)
3270#define IWM_MAC_FLG_SHORT_PREAMBLE		(1 << 5)
3271
3272/**
3273 * enum iwm_mac_types - Supported MAC types
3274 * @IWM_FW_MAC_TYPE_FIRST: lowest supported MAC type
3275 * @IWM_FW_MAC_TYPE_AUX: Auxiliary MAC (internal)
3276 * @IWM_FW_MAC_TYPE_LISTENER: monitor MAC type (?)
3277 * @IWM_FW_MAC_TYPE_PIBSS: Pseudo-IBSS
3278 * @IWM_FW_MAC_TYPE_IBSS: IBSS
3279 * @IWM_FW_MAC_TYPE_BSS_STA: BSS (managed) station
3280 * @IWM_FW_MAC_TYPE_P2P_DEVICE: P2P Device
3281 * @IWM_FW_MAC_TYPE_P2P_STA: P2P client
3282 * @IWM_FW_MAC_TYPE_GO: P2P GO
3283 * @IWM_FW_MAC_TYPE_TEST: ?
3284 * @IWM_FW_MAC_TYPE_MAX: highest support MAC type
3285 */
3286enum iwm_mac_types {
3287	IWM_FW_MAC_TYPE_FIRST = 1,
3288	IWM_FW_MAC_TYPE_AUX = IWM_FW_MAC_TYPE_FIRST,
3289	IWM_FW_MAC_TYPE_LISTENER,
3290	IWM_FW_MAC_TYPE_PIBSS,
3291	IWM_FW_MAC_TYPE_IBSS,
3292	IWM_FW_MAC_TYPE_BSS_STA,
3293	IWM_FW_MAC_TYPE_P2P_DEVICE,
3294	IWM_FW_MAC_TYPE_P2P_STA,
3295	IWM_FW_MAC_TYPE_GO,
3296	IWM_FW_MAC_TYPE_TEST,
3297	IWM_FW_MAC_TYPE_MAX = IWM_FW_MAC_TYPE_TEST
3298}; /* IWM_MAC_CONTEXT_TYPE_API_E_VER_1 */
3299
3300/**
3301 * enum iwm_tsf_id - TSF hw timer ID
3302 * @IWM_TSF_ID_A: use TSF A
3303 * @IWM_TSF_ID_B: use TSF B
3304 * @IWM_TSF_ID_C: use TSF C
3305 * @IWM_TSF_ID_D: use TSF D
3306 * @IWM_NUM_TSF_IDS: number of TSF timers available
3307 */
3308enum iwm_tsf_id {
3309	IWM_TSF_ID_A = 0,
3310	IWM_TSF_ID_B = 1,
3311	IWM_TSF_ID_C = 2,
3312	IWM_TSF_ID_D = 3,
3313	IWM_NUM_TSF_IDS = 4,
3314}; /* IWM_TSF_ID_API_E_VER_1 */
3315
3316/**
3317 * struct iwm_mac_data_ap - configuration data for AP MAC context
3318 * @beacon_time: beacon transmit time in system time
3319 * @beacon_tsf: beacon transmit time in TSF
3320 * @bi: beacon interval in TU
3321 * @bi_reciprocal: 2^32 / bi
3322 * @dtim_interval: dtim transmit time in TU
3323 * @dtim_reciprocal: 2^32 / dtim_interval
3324 * @mcast_qid: queue ID for multicast traffic
3325 * @beacon_template: beacon template ID
3326 */
3327struct iwm_mac_data_ap {
3328	uint32_t beacon_time;
3329	uint64_t beacon_tsf;
3330	uint32_t bi;
3331	uint32_t bi_reciprocal;
3332	uint32_t dtim_interval;
3333	uint32_t dtim_reciprocal;
3334	uint32_t mcast_qid;
3335	uint32_t beacon_template;
3336} __packed; /* AP_MAC_DATA_API_S_VER_1 */
3337
3338/**
3339 * struct iwm_mac_data_ibss - configuration data for IBSS MAC context
3340 * @beacon_time: beacon transmit time in system time
3341 * @beacon_tsf: beacon transmit time in TSF
3342 * @bi: beacon interval in TU
3343 * @bi_reciprocal: 2^32 / bi
3344 * @beacon_template: beacon template ID
3345 */
3346struct iwm_mac_data_ibss {
3347	uint32_t beacon_time;
3348	uint64_t beacon_tsf;
3349	uint32_t bi;
3350	uint32_t bi_reciprocal;
3351	uint32_t beacon_template;
3352} __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
3353
3354/**
3355 * struct iwm_mac_data_sta - configuration data for station MAC context
3356 * @is_assoc: 1 for associated state, 0 otherwise
3357 * @dtim_time: DTIM arrival time in system time
3358 * @dtim_tsf: DTIM arrival time in TSF
3359 * @bi: beacon interval in TU, applicable only when associated
3360 * @bi_reciprocal: 2^32 / bi , applicable only when associated
3361 * @dtim_interval: DTIM interval in TU, applicable only when associated
3362 * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
3363 * @listen_interval: in beacon intervals, applicable only when associated
3364 * @assoc_id: unique ID assigned by the AP during association
3365 */
3366struct iwm_mac_data_sta {
3367	uint32_t is_assoc;
3368	uint32_t dtim_time;
3369	uint64_t dtim_tsf;
3370	uint32_t bi;
3371	uint32_t bi_reciprocal;
3372	uint32_t dtim_interval;
3373	uint32_t dtim_reciprocal;
3374	uint32_t listen_interval;
3375	uint32_t assoc_id;
3376	uint32_t assoc_beacon_arrive_time;
3377} __packed; /* IWM_STA_MAC_DATA_API_S_VER_1 */
3378
3379/**
3380 * struct iwm_mac_data_go - configuration data for P2P GO MAC context
3381 * @ap: iwm_mac_data_ap struct with most config data
3382 * @ctwin: client traffic window in TU (period after TBTT when GO is present).
3383 *	0 indicates that there is no CT window.
3384 * @opp_ps_enabled: indicate that opportunistic PS allowed
3385 */
3386struct iwm_mac_data_go {
3387	struct iwm_mac_data_ap ap;
3388	uint32_t ctwin;
3389	uint32_t opp_ps_enabled;
3390} __packed; /* GO_MAC_DATA_API_S_VER_1 */
3391
3392/**
3393 * struct iwm_mac_data_p2p_sta - configuration data for P2P client MAC context
3394 * @sta: iwm_mac_data_sta struct with most config data
3395 * @ctwin: client traffic window in TU (period after TBTT when GO is present).
3396 *	0 indicates that there is no CT window.
3397 */
3398struct iwm_mac_data_p2p_sta {
3399	struct iwm_mac_data_sta sta;
3400	uint32_t ctwin;
3401} __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */
3402
3403/**
3404 * struct iwm_mac_data_pibss - Pseudo IBSS config data
3405 * @stats_interval: interval in TU between statistics notifications to host.
3406 */
3407struct iwm_mac_data_pibss {
3408	uint32_t stats_interval;
3409} __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */
3410
3411/*
3412 * struct iwm_mac_data_p2p_dev - configuration data for the P2P Device MAC
3413 * context.
3414 * @is_disc_extended: if set to true, P2P Device discoverability is enabled on
3415 *	other channels as well. This should be to true only in case that the
3416 *	device is discoverable and there is an active GO. Note that setting this
3417 *	field when not needed, will increase the number of interrupts and have
3418 *	effect on the platform power, as this setting opens the Rx filters on
3419 *	all macs.
3420 */
3421struct iwm_mac_data_p2p_dev {
3422	uint32_t is_disc_extended;
3423} __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */
3424
3425/**
3426 * enum iwm_mac_filter_flags - MAC context filter flags
3427 * @IWM_MAC_FILTER_IN_PROMISC: accept all data frames
3428 * @IWM_MAC_FILTER_IN_CONTROL_AND_MGMT: pass all mangement and
3429 *	control frames to the host
3430 * @IWM_MAC_FILTER_ACCEPT_GRP: accept multicast frames
3431 * @IWM_MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames
3432 * @IWM_MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames
3433 * @IWM_MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host
3434 *	(in station mode when associated)
3435 * @IWM_MAC_FILTER_OUT_BCAST: filter out all broadcast frames
3436 * @IWM_MAC_FILTER_IN_CRC32: extract FCS and append it to frames
3437 * @IWM_MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host
3438 */
3439enum iwm_mac_filter_flags {
3440	IWM_MAC_FILTER_IN_PROMISC		= (1 << 0),
3441	IWM_MAC_FILTER_IN_CONTROL_AND_MGMT	= (1 << 1),
3442	IWM_MAC_FILTER_ACCEPT_GRP		= (1 << 2),
3443	IWM_MAC_FILTER_DIS_DECRYPT		= (1 << 3),
3444	IWM_MAC_FILTER_DIS_GRP_DECRYPT		= (1 << 4),
3445	IWM_MAC_FILTER_IN_BEACON		= (1 << 6),
3446	IWM_MAC_FILTER_OUT_BCAST		= (1 << 8),
3447	IWM_MAC_FILTER_IN_CRC32			= (1 << 11),
3448	IWM_MAC_FILTER_IN_PROBE_REQUEST		= (1 << 12),
3449};
3450
3451/**
3452 * enum iwm_mac_qos_flags - QoS flags
3453 * @IWM_MAC_QOS_FLG_UPDATE_EDCA: ?
3454 * @IWM_MAC_QOS_FLG_TGN: HT is enabled
3455 * @IWM_MAC_QOS_FLG_TXOP_TYPE: ?
3456 *
3457 */
3458enum iwm_mac_qos_flags {
3459	IWM_MAC_QOS_FLG_UPDATE_EDCA	= (1 << 0),
3460	IWM_MAC_QOS_FLG_TGN		= (1 << 1),
3461	IWM_MAC_QOS_FLG_TXOP_TYPE	= (1 << 4),
3462};
3463
3464/**
3465 * struct iwm_ac_qos - QOS timing params for IWM_MAC_CONTEXT_CMD
3466 * @cw_min: Contention window, start value in numbers of slots.
3467 *	Should be a power-of-2, minus 1.  Device's default is 0x0f.
3468 * @cw_max: Contention window, max value in numbers of slots.
3469 *	Should be a power-of-2, minus 1.  Device's default is 0x3f.
3470 * @aifsn:  Number of slots in Arbitration Interframe Space (before
3471 *	performing random backoff timing prior to Tx).  Device default 1.
3472 * @fifos_mask: FIFOs used by this MAC for this AC
3473 * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
3474 *
3475 * One instance of this config struct for each of 4 EDCA access categories
3476 * in struct iwm_qosparam_cmd.
3477 *
3478 * Device will automatically increase contention window by (2*CW) + 1 for each
3479 * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
3480 * value, to cap the CW value.
3481 */
3482struct iwm_ac_qos {
3483	uint16_t cw_min;
3484	uint16_t cw_max;
3485	uint8_t aifsn;
3486	uint8_t fifos_mask;
3487	uint16_t edca_txop;
3488} __packed; /* IWM_AC_QOS_API_S_VER_2 */
3489
3490/**
3491 * struct iwm_mac_ctx_cmd - command structure to configure MAC contexts
3492 * ( IWM_MAC_CONTEXT_CMD = 0x28 )
3493 * @id_and_color: ID and color of the MAC
3494 * @action: action to perform, one of IWM_FW_CTXT_ACTION_*
3495 * @mac_type: one of IWM_FW_MAC_TYPE_*
3496 * @tsd_id: TSF HW timer, one of IWM_TSF_ID_*
3497 * @node_addr: MAC address
3498 * @bssid_addr: BSSID
3499 * @cck_rates: basic rates available for CCK
3500 * @ofdm_rates: basic rates available for OFDM
3501 * @protection_flags: combination of IWM_MAC_PROT_FLG_FLAG_*
3502 * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise
3503 * @short_slot: 0x10 for enabling short slots, 0 otherwise
3504 * @filter_flags: combination of IWM_MAC_FILTER_*
3505 * @qos_flags: from IWM_MAC_QOS_FLG_*
3506 * @ac: one iwm_mac_qos configuration for each AC
3507 * @mac_specific: one of struct iwm_mac_data_*, according to mac_type
3508 */
3509struct iwm_mac_ctx_cmd {
3510	/* COMMON_INDEX_HDR_API_S_VER_1 */
3511	uint32_t id_and_color;
3512	uint32_t action;
3513	/* IWM_MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */
3514	uint32_t mac_type;
3515	uint32_t tsf_id;
3516	uint8_t node_addr[6];
3517	uint16_t reserved_for_node_addr;
3518	uint8_t bssid_addr[6];
3519	uint16_t reserved_for_bssid_addr;
3520	uint32_t cck_rates;
3521	uint32_t ofdm_rates;
3522	uint32_t protection_flags;
3523	uint32_t cck_short_preamble;
3524	uint32_t short_slot;
3525	uint32_t filter_flags;
3526	/* IWM_MAC_QOS_PARAM_API_S_VER_1 */
3527	uint32_t qos_flags;
3528	struct iwm_ac_qos ac[IWM_AC_NUM+1];
3529	/* IWM_MAC_CONTEXT_COMMON_DATA_API_S */
3530	union {
3531		struct iwm_mac_data_ap ap;
3532		struct iwm_mac_data_go go;
3533		struct iwm_mac_data_sta sta;
3534		struct iwm_mac_data_p2p_sta p2p_sta;
3535		struct iwm_mac_data_p2p_dev p2p_dev;
3536		struct iwm_mac_data_pibss pibss;
3537		struct iwm_mac_data_ibss ibss;
3538	};
3539} __packed; /* IWM_MAC_CONTEXT_CMD_API_S_VER_1 */
3540
3541static inline uint32_t iwm_mvm_reciprocal(uint32_t v)
3542{
3543	if (!v)
3544		return 0;
3545	return 0xFFFFFFFF / v;
3546}
3547
3548#define IWM_NONQOS_SEQ_GET	0x1
3549#define IWM_NONQOS_SEQ_SET	0x2
3550struct iwm_nonqos_seq_query_cmd {
3551	uint32_t get_set_flag;
3552	uint32_t mac_id_n_color;
3553	uint16_t value;
3554	uint16_t reserved;
3555} __packed; /* IWM_NON_QOS_TX_COUNTER_GET_SET_API_S_VER_1 */
3556
3557/*
3558 * END mvm/fw-api-mac.h
3559 */
3560
3561/*
3562 * BEGIN mvm/fw-api-power.h
3563 */
3564
3565/* Power Management Commands, Responses, Notifications */
3566
3567/* Radio LP RX Energy Threshold measured in dBm */
3568#define IWM_POWER_LPRX_RSSI_THRESHOLD	75
3569#define IWM_POWER_LPRX_RSSI_THRESHOLD_MAX	94
3570#define IWM_POWER_LPRX_RSSI_THRESHOLD_MIN	30
3571
3572/**
3573 * enum iwm_scan_flags - masks for power table command flags
3574 * @IWM_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
3575 *		receiver and transmitter. '0' - does not allow.
3576 * @IWM_POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
3577 *		'1' Driver enables PM (use rest of parameters)
3578 * @IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM,
3579 *		'1' PM could sleep over DTIM till listen Interval.
3580 * @IWM_POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all
3581 *		access categories are both delivery and trigger enabled.
3582 * @IWM_POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and
3583 *		PBW Snoozing enabled
3584 * @IWM_POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
3585 * @IWM_POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
3586 * @IWM_POWER_FLAGS_AP_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
3587 *		detection enablement
3588*/
3589enum iwm_power_flags {
3590	IWM_POWER_FLAGS_POWER_SAVE_ENA_MSK		= (1 << 0),
3591	IWM_POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK	= (1 << 1),
3592	IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK		= (1 << 2),
3593	IWM_POWER_FLAGS_SNOOZE_ENA_MSK		= (1 << 5),
3594	IWM_POWER_FLAGS_BT_SCO_ENA			= (1 << 8),
3595	IWM_POWER_FLAGS_ADVANCE_PM_ENA_MSK		= (1 << 9),
3596	IWM_POWER_FLAGS_LPRX_ENA_MSK		= (1 << 11),
3597	IWM_POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK	= (1 << 12),
3598};
3599
3600#define IWM_POWER_VEC_SIZE 5
3601
3602/**
3603 * struct iwm_powertable_cmd - legacy power command. Beside old API support this
3604 *	is used also with a new	power API for device wide power settings.
3605 * IWM_POWER_TABLE_CMD = 0x77 (command, has simple generic response)
3606 *
3607 * @flags:		Power table command flags from IWM_POWER_FLAGS_*
3608 * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
3609 *			Minimum allowed:- 3 * DTIM. Keep alive period must be
3610 *			set regardless of power scheme or current power state.
3611 *			FW use this value also when PM is disabled.
3612 * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
3613 *			PSM transition - legacy PM
3614 * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
3615 *			PSM transition - legacy PM
3616 * @sleep_interval:	not in use
3617 * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
3618 *			is set. For example, if it is required to skip over
3619 *			one DTIM, this value need to be set to 2 (DTIM periods).
3620 * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
3621 *			Default: 80dbm
3622 */
3623struct iwm_powertable_cmd {
3624	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
3625	uint16_t flags;
3626	uint8_t keep_alive_seconds;
3627	uint8_t debug_flags;
3628	uint32_t rx_data_timeout;
3629	uint32_t tx_data_timeout;
3630	uint32_t sleep_interval[IWM_POWER_VEC_SIZE];
3631	uint32_t skip_dtim_periods;
3632	uint32_t lprx_rssi_threshold;
3633} __packed;
3634
3635/**
3636 * enum iwm_device_power_flags - masks for device power command flags
3637 * @DEVIC_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
3638 *	receiver and transmitter. '0' - does not allow. This flag should be
3639 *	always set to '1' unless one need to disable actual power down for debug
3640 *	purposes.
3641 * @IWM_DEVICE_POWER_FLAGS_CAM_MSK: '1' CAM (Continuous Active Mode) is set, meaning
3642 *	that power management is disabled. '0' Power management is enabled, one
3643 *	of power schemes is applied.
3644*/
3645enum iwm_device_power_flags {
3646	IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK	= (1 << 0),
3647	IWM_DEVICE_POWER_FLAGS_CAM_MSK		= (1 << 13),
3648};
3649
3650/**
3651 * struct iwm_device_power_cmd - device wide power command.
3652 * IWM_DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
3653 *
3654 * @flags:	Power table command flags from IWM_DEVICE_POWER_FLAGS_*
3655 */
3656struct iwm_device_power_cmd {
3657	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
3658	uint16_t flags;
3659	uint16_t reserved;
3660} __packed;
3661
3662/**
3663 * struct iwm_mac_power_cmd - New power command containing uAPSD support
3664 * IWM_MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
3665 * @id_and_color:	MAC contex identifier
3666 * @flags:		Power table command flags from POWER_FLAGS_*
3667 * @keep_alive_seconds:	Keep alive period in seconds. Default - 25 sec.
3668 *			Minimum allowed:- 3 * DTIM. Keep alive period must be
3669 *			set regardless of power scheme or current power state.
3670 *			FW use this value also when PM is disabled.
3671 * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
3672 *			PSM transition - legacy PM
3673 * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
3674 *			PSM transition - legacy PM
3675 * @sleep_interval:	not in use
3676 * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
3677 *			is set. For example, if it is required to skip over
3678 *			one DTIM, this value need to be set to 2 (DTIM periods).
3679 * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
3680 *			PSM transition - uAPSD
3681 * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
3682 *			PSM transition - uAPSD
3683 * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
3684 *			Default: 80dbm
3685 * @num_skip_dtim:	Number of DTIMs to skip if Skip over DTIM flag is set
3686 * @snooze_interval:	Maximum time between attempts to retrieve buffered data
3687 *			from the AP [msec]
3688 * @snooze_window:	A window of time in which PBW snoozing insures that all
3689 *			packets received. It is also the minimum time from last
3690 *			received unicast RX packet, before client stops snoozing
3691 *			for data. [msec]
3692 * @snooze_step:	TBD
3693 * @qndp_tid:		TID client shall use for uAPSD QNDP triggers
3694 * @uapsd_ac_flags:	Set trigger-enabled and delivery-enabled indication for
3695 *			each corresponding AC.
3696 *			Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
3697 * @uapsd_max_sp:	Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
3698 *			values.
3699 * @heavy_tx_thld_packets:	TX threshold measured in number of packets
3700 * @heavy_rx_thld_packets:	RX threshold measured in number of packets
3701 * @heavy_tx_thld_percentage:	TX threshold measured in load's percentage
3702 * @heavy_rx_thld_percentage:	RX threshold measured in load's percentage
3703 * @limited_ps_threshold:
3704*/
3705struct iwm_mac_power_cmd {
3706	/* CONTEXT_DESC_API_T_VER_1 */
3707	uint32_t id_and_color;
3708
3709	/* CLIENT_PM_POWER_TABLE_S_VER_1 */
3710	uint16_t flags;
3711	uint16_t keep_alive_seconds;
3712	uint32_t rx_data_timeout;
3713	uint32_t tx_data_timeout;
3714	uint32_t rx_data_timeout_uapsd;
3715	uint32_t tx_data_timeout_uapsd;
3716	uint8_t lprx_rssi_threshold;
3717	uint8_t skip_dtim_periods;
3718	uint16_t snooze_interval;
3719	uint16_t snooze_window;
3720	uint8_t snooze_step;
3721	uint8_t qndp_tid;
3722	uint8_t uapsd_ac_flags;
3723	uint8_t uapsd_max_sp;
3724	uint8_t heavy_tx_thld_packets;
3725	uint8_t heavy_rx_thld_packets;
3726	uint8_t heavy_tx_thld_percentage;
3727	uint8_t heavy_rx_thld_percentage;
3728	uint8_t limited_ps_threshold;
3729	uint8_t reserved;
3730} __packed;
3731
3732/*
3733 * struct iwm_uapsd_misbehaving_ap_notif - FW sends this notification when
3734 * associated AP is identified as improperly implementing uAPSD protocol.
3735 * IWM_PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
3736 * @sta_id: index of station in uCode's station table - associated AP ID in
3737 *	    this context.
3738 */
3739struct iwm_uapsd_misbehaving_ap_notif {
3740	uint32_t sta_id;
3741	uint8_t mac_id;
3742	uint8_t reserved[3];
3743} __packed;
3744
3745/**
3746 * struct iwm_beacon_filter_cmd
3747 * IWM_REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
3748 * @id_and_color: MAC contex identifier
3749 * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
3750 *      to driver if delta in Energy values calculated for this and last
3751 *      passed beacon is greater than this threshold. Zero value means that
3752 *      the Energy change is ignored for beacon filtering, and beacon will
3753 *      not be forced to be sent to driver regardless of this delta. Typical
3754 *      energy delta 5dB.
3755 * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
3756 *      Send beacon to driver if delta in Energy values calculated for this
3757 *      and last passed beacon is greater than this threshold. Zero value
3758 *      means that the Energy change is ignored for beacon filtering while in
3759 *      Roaming state, typical energy delta 1dB.
3760 * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
3761 *      calculated for current beacon is less than the threshold, use
3762 *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
3763 *      Threshold. Typical energy threshold is -72dBm.
3764 * @bf_temp_threshold: This threshold determines the type of temperature
3765 *	filtering (Slow or Fast) that is selected (Units are in Celsuis):
3766 *      If the current temperature is above this threshold - Fast filter
3767 *	will be used, If the current temperature is below this threshold -
3768 *	Slow filter will be used.
3769 * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
3770 *      calculated for this and the last passed beacon is greater than this
3771 *      threshold. Zero value means that the temperature change is ignored for
3772 *      beacon filtering; beacons will not be  forced to be sent to driver
3773 *      regardless of whether its temperature has been changed.
3774 * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
3775 *      calculated for this and the last passed beacon is greater than this
3776 *      threshold. Zero value means that the temperature change is ignored for
3777 *      beacon filtering; beacons will not be forced to be sent to driver
3778 *      regardless of whether its temperature has been changed.
3779 * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
3780 * @bf_filter_escape_timer: Send beacons to to driver if no beacons were passed
3781 *      for a specific period of time. Units: Beacons.
3782 * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
3783 *      for a longer period of time then this escape-timeout. Units: Beacons.
3784 * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
3785 */
3786struct iwm_beacon_filter_cmd {
3787	uint32_t bf_energy_delta;
3788	uint32_t bf_roaming_energy_delta;
3789	uint32_t bf_roaming_state;
3790	uint32_t bf_temp_threshold;
3791	uint32_t bf_temp_fast_filter;
3792	uint32_t bf_temp_slow_filter;
3793	uint32_t bf_enable_beacon_filter;
3794	uint32_t bf_debug_flag;
3795	uint32_t bf_escape_timer;
3796	uint32_t ba_escape_timer;
3797	uint32_t ba_enable_beacon_abort;
3798} __packed;
3799
3800/* Beacon filtering and beacon abort */
3801#define IWM_BF_ENERGY_DELTA_DEFAULT 5
3802#define IWM_BF_ENERGY_DELTA_MAX 255
3803#define IWM_BF_ENERGY_DELTA_MIN 0
3804
3805#define IWM_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
3806#define IWM_BF_ROAMING_ENERGY_DELTA_MAX 255
3807#define IWM_BF_ROAMING_ENERGY_DELTA_MIN 0
3808
3809#define IWM_BF_ROAMING_STATE_DEFAULT 72
3810#define IWM_BF_ROAMING_STATE_MAX 255
3811#define IWM_BF_ROAMING_STATE_MIN 0
3812
3813#define IWM_BF_TEMP_THRESHOLD_DEFAULT 112
3814#define IWM_BF_TEMP_THRESHOLD_MAX 255
3815#define IWM_BF_TEMP_THRESHOLD_MIN 0
3816
3817#define IWM_BF_TEMP_FAST_FILTER_DEFAULT 1
3818#define IWM_BF_TEMP_FAST_FILTER_MAX 255
3819#define IWM_BF_TEMP_FAST_FILTER_MIN 0
3820
3821#define IWM_BF_TEMP_SLOW_FILTER_DEFAULT 5
3822#define IWM_BF_TEMP_SLOW_FILTER_MAX 255
3823#define IWM_BF_TEMP_SLOW_FILTER_MIN 0
3824
3825#define IWM_BF_ENABLE_BEACON_FILTER_DEFAULT 1
3826
3827#define IWM_BF_DEBUG_FLAG_DEFAULT 0
3828
3829#define IWM_BF_ESCAPE_TIMER_DEFAULT 50
3830#define IWM_BF_ESCAPE_TIMER_MAX 1024
3831#define IWM_BF_ESCAPE_TIMER_MIN 0
3832
3833#define IWM_BA_ESCAPE_TIMER_DEFAULT 6
3834#define IWM_BA_ESCAPE_TIMER_D3 9
3835#define IWM_BA_ESCAPE_TIMER_MAX 1024
3836#define IWM_BA_ESCAPE_TIMER_MIN 0
3837
3838#define IWM_BA_ENABLE_BEACON_ABORT_DEFAULT 1
3839
3840#define IWM_BF_CMD_CONFIG_DEFAULTS					     \
3841	.bf_energy_delta = htole32(IWM_BF_ENERGY_DELTA_DEFAULT),	     \
3842	.bf_roaming_energy_delta =					     \
3843		htole32(IWM_BF_ROAMING_ENERGY_DELTA_DEFAULT),	     \
3844	.bf_roaming_state = htole32(IWM_BF_ROAMING_STATE_DEFAULT),	     \
3845	.bf_temp_threshold = htole32(IWM_BF_TEMP_THRESHOLD_DEFAULT),     \
3846	.bf_temp_fast_filter = htole32(IWM_BF_TEMP_FAST_FILTER_DEFAULT), \
3847	.bf_temp_slow_filter = htole32(IWM_BF_TEMP_SLOW_FILTER_DEFAULT), \
3848	.bf_debug_flag = htole32(IWM_BF_DEBUG_FLAG_DEFAULT),	     \
3849	.bf_escape_timer = htole32(IWM_BF_ESCAPE_TIMER_DEFAULT),	     \
3850	.ba_escape_timer = htole32(IWM_BA_ESCAPE_TIMER_DEFAULT)
3851
3852/*
3853 * END mvm/fw-api-power.h
3854 */
3855
3856/*
3857 * BEGIN mvm/fw-api-rs.h
3858 */
3859
3860/*
3861 * These serve as indexes into
3862 * struct iwm_rate_info fw_rate_idx_to_plcp[IWM_RATE_COUNT];
3863 * TODO: avoid overlap between legacy and HT rates
3864 */
3865enum {
3866	IWM_RATE_1M_INDEX = 0,
3867	IWM_FIRST_CCK_RATE = IWM_RATE_1M_INDEX,
3868	IWM_RATE_2M_INDEX,
3869	IWM_RATE_5M_INDEX,
3870	IWM_RATE_11M_INDEX,
3871	IWM_LAST_CCK_RATE = IWM_RATE_11M_INDEX,
3872	IWM_RATE_6M_INDEX,
3873	IWM_FIRST_OFDM_RATE = IWM_RATE_6M_INDEX,
3874	IWM_RATE_MCS_0_INDEX = IWM_RATE_6M_INDEX,
3875	IWM_FIRST_HT_RATE = IWM_RATE_MCS_0_INDEX,
3876	IWM_FIRST_VHT_RATE = IWM_RATE_MCS_0_INDEX,
3877	IWM_RATE_9M_INDEX,
3878	IWM_RATE_12M_INDEX,
3879	IWM_RATE_MCS_1_INDEX = IWM_RATE_12M_INDEX,
3880	IWM_RATE_18M_INDEX,
3881	IWM_RATE_MCS_2_INDEX = IWM_RATE_18M_INDEX,
3882	IWM_RATE_24M_INDEX,
3883	IWM_RATE_MCS_3_INDEX = IWM_RATE_24M_INDEX,
3884	IWM_RATE_36M_INDEX,
3885	IWM_RATE_MCS_4_INDEX = IWM_RATE_36M_INDEX,
3886	IWM_RATE_48M_INDEX,
3887	IWM_RATE_MCS_5_INDEX = IWM_RATE_48M_INDEX,
3888	IWM_RATE_54M_INDEX,
3889	IWM_RATE_MCS_6_INDEX = IWM_RATE_54M_INDEX,
3890	IWM_LAST_NON_HT_RATE = IWM_RATE_54M_INDEX,
3891	IWM_RATE_60M_INDEX,
3892	IWM_RATE_MCS_7_INDEX = IWM_RATE_60M_INDEX,
3893	IWM_LAST_HT_RATE = IWM_RATE_MCS_7_INDEX,
3894	IWM_RATE_MCS_8_INDEX,
3895	IWM_RATE_MCS_9_INDEX,
3896	IWM_LAST_VHT_RATE = IWM_RATE_MCS_9_INDEX,
3897	IWM_RATE_COUNT_LEGACY = IWM_LAST_NON_HT_RATE + 1,
3898	IWM_RATE_COUNT = IWM_LAST_VHT_RATE + 1,
3899};
3900
3901#define IWM_RATE_BIT_MSK(r) (1 << (IWM_RATE_##r##M_INDEX))
3902
3903/* fw API values for legacy bit rates, both OFDM and CCK */
3904enum {
3905	IWM_RATE_6M_PLCP  = 13,
3906	IWM_RATE_9M_PLCP  = 15,
3907	IWM_RATE_12M_PLCP = 5,
3908	IWM_RATE_18M_PLCP = 7,
3909	IWM_RATE_24M_PLCP = 9,
3910	IWM_RATE_36M_PLCP = 11,
3911	IWM_RATE_48M_PLCP = 1,
3912	IWM_RATE_54M_PLCP = 3,
3913	IWM_RATE_1M_PLCP  = 10,
3914	IWM_RATE_2M_PLCP  = 20,
3915	IWM_RATE_5M_PLCP  = 55,
3916	IWM_RATE_11M_PLCP = 110,
3917	IWM_RATE_INVM_PLCP = -1,
3918};
3919
3920/*
3921 * rate_n_flags bit fields
3922 *
3923 * The 32-bit value has different layouts in the low 8 bites depending on the
3924 * format. There are three formats, HT, VHT and legacy (11abg, with subformats
3925 * for CCK and OFDM).
3926 *
3927 * High-throughput (HT) rate format
3928 *	bit 8 is 1, bit 26 is 0, bit 9 is 0 (OFDM)
3929 * Very High-throughput (VHT) rate format
3930 *	bit 8 is 0, bit 26 is 1, bit 9 is 0 (OFDM)
3931 * Legacy OFDM rate format for bits 7:0
3932 *	bit 8 is 0, bit 26 is 0, bit 9 is 0 (OFDM)
3933 * Legacy CCK rate format for bits 7:0:
3934 *	bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK)
3935 */
3936
3937/* Bit 8: (1) HT format, (0) legacy or VHT format */
3938#define IWM_RATE_MCS_HT_POS 8
3939#define IWM_RATE_MCS_HT_MSK (1 << IWM_RATE_MCS_HT_POS)
3940
3941/* Bit 9: (1) CCK, (0) OFDM.  HT (bit 8) must be "0" for this bit to be valid */
3942#define IWM_RATE_MCS_CCK_POS 9
3943#define IWM_RATE_MCS_CCK_MSK (1 << IWM_RATE_MCS_CCK_POS)
3944
3945/* Bit 26: (1) VHT format, (0) legacy format in bits 8:0 */
3946#define IWM_RATE_MCS_VHT_POS 26
3947#define IWM_RATE_MCS_VHT_MSK (1 << IWM_RATE_MCS_VHT_POS)
3948
3949
3950/*
3951 * High-throughput (HT) rate format for bits 7:0
3952 *
3953 *  2-0:  MCS rate base
3954 *        0)   6 Mbps
3955 *        1)  12 Mbps
3956 *        2)  18 Mbps
3957 *        3)  24 Mbps
3958 *        4)  36 Mbps
3959 *        5)  48 Mbps
3960 *        6)  54 Mbps
3961 *        7)  60 Mbps
3962 *  4-3:  0)  Single stream (SISO)
3963 *        1)  Dual stream (MIMO)
3964 *        2)  Triple stream (MIMO)
3965 *    5:  Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
3966 *  (bits 7-6 are zero)
3967 *
3968 * Together the low 5 bits work out to the MCS index because we don't
3969 * support MCSes above 15/23, and 0-7 have one stream, 8-15 have two
3970 * streams and 16-23 have three streams. We could also support MCS 32
3971 * which is the duplicate 20 MHz MCS (bit 5 set, all others zero.)
3972 */
3973#define IWM_RATE_HT_MCS_RATE_CODE_MSK	0x7
3974#define IWM_RATE_HT_MCS_NSS_POS             3
3975#define IWM_RATE_HT_MCS_NSS_MSK             (3 << IWM_RATE_HT_MCS_NSS_POS)
3976
3977/* Bit 10: (1) Use Green Field preamble */
3978#define IWM_RATE_HT_MCS_GF_POS		10
3979#define IWM_RATE_HT_MCS_GF_MSK		(1 << IWM_RATE_HT_MCS_GF_POS)
3980
3981#define IWM_RATE_HT_MCS_INDEX_MSK		0x3f
3982
3983/*
3984 * Very High-throughput (VHT) rate format for bits 7:0
3985 *
3986 *  3-0:  VHT MCS (0-9)
3987 *  5-4:  number of streams - 1:
3988 *        0)  Single stream (SISO)
3989 *        1)  Dual stream (MIMO)
3990 *        2)  Triple stream (MIMO)
3991 */
3992
3993/* Bit 4-5: (0) SISO, (1) MIMO2 (2) MIMO3 */
3994#define IWM_RATE_VHT_MCS_RATE_CODE_MSK	0xf
3995#define IWM_RATE_VHT_MCS_NSS_POS		4
3996#define IWM_RATE_VHT_MCS_NSS_MSK		(3 << IWM_RATE_VHT_MCS_NSS_POS)
3997
3998/*
3999 * Legacy OFDM rate format for bits 7:0
4000 *
4001 *  3-0:  0xD)   6 Mbps
4002 *        0xF)   9 Mbps
4003 *        0x5)  12 Mbps
4004 *        0x7)  18 Mbps
4005 *        0x9)  24 Mbps
4006 *        0xB)  36 Mbps
4007 *        0x1)  48 Mbps
4008 *        0x3)  54 Mbps
4009 * (bits 7-4 are 0)
4010 *
4011 * Legacy CCK rate format for bits 7:0:
4012 * bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK):
4013 *
4014 *  6-0:   10)  1 Mbps
4015 *         20)  2 Mbps
4016 *         55)  5.5 Mbps
4017 *        110)  11 Mbps
4018 * (bit 7 is 0)
4019 */
4020#define IWM_RATE_LEGACY_RATE_MSK 0xff
4021
4022
4023/*
4024 * Bit 11-12: (0) 20MHz, (1) 40MHz, (2) 80MHz, (3) 160MHz
4025 * 0 and 1 are valid for HT and VHT, 2 and 3 only for VHT
4026 */
4027#define IWM_RATE_MCS_CHAN_WIDTH_POS		11
4028#define IWM_RATE_MCS_CHAN_WIDTH_MSK		(3 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4029#define IWM_RATE_MCS_CHAN_WIDTH_20		(0 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4030#define IWM_RATE_MCS_CHAN_WIDTH_40		(1 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4031#define IWM_RATE_MCS_CHAN_WIDTH_80		(2 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4032#define IWM_RATE_MCS_CHAN_WIDTH_160		(3 << IWM_RATE_MCS_CHAN_WIDTH_POS)
4033
4034/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
4035#define IWM_RATE_MCS_SGI_POS		13
4036#define IWM_RATE_MCS_SGI_MSK		(1 << IWM_RATE_MCS_SGI_POS)
4037
4038/* Bit 14-16: Antenna selection (1) Ant A, (2) Ant B, (4) Ant C */
4039#define IWM_RATE_MCS_ANT_POS		14
4040#define IWM_RATE_MCS_ANT_A_MSK		(1 << IWM_RATE_MCS_ANT_POS)
4041#define IWM_RATE_MCS_ANT_B_MSK		(2 << IWM_RATE_MCS_ANT_POS)
4042#define IWM_RATE_MCS_ANT_C_MSK		(4 << IWM_RATE_MCS_ANT_POS)
4043#define IWM_RATE_MCS_ANT_AB_MSK		(IWM_RATE_MCS_ANT_A_MSK | \
4044					 IWM_RATE_MCS_ANT_B_MSK)
4045#define IWM_RATE_MCS_ANT_ABC_MSK		(IWM_RATE_MCS_ANT_AB_MSK | \
4046					 IWM_RATE_MCS_ANT_C_MSK)
4047#define IWM_RATE_MCS_ANT_MSK		IWM_RATE_MCS_ANT_ABC_MSK
4048#define IWM_RATE_MCS_ANT_NUM 3
4049
4050/* Bit 17-18: (0) SS, (1) SS*2 */
4051#define IWM_RATE_MCS_STBC_POS		17
4052#define IWM_RATE_MCS_STBC_MSK		(1 << IWM_RATE_MCS_STBC_POS)
4053
4054/* Bit 19: (0) Beamforming is off, (1) Beamforming is on */
4055#define IWM_RATE_MCS_BF_POS			19
4056#define IWM_RATE_MCS_BF_MSK			(1 << IWM_RATE_MCS_BF_POS)
4057
4058/* Bit 20: (0) ZLF is off, (1) ZLF is on */
4059#define IWM_RATE_MCS_ZLF_POS		20
4060#define IWM_RATE_MCS_ZLF_MSK		(1 << IWM_RATE_MCS_ZLF_POS)
4061
4062/* Bit 24-25: (0) 20MHz (no dup), (1) 2x20MHz, (2) 4x20MHz, 3 8x20MHz */
4063#define IWM_RATE_MCS_DUP_POS		24
4064#define IWM_RATE_MCS_DUP_MSK		(3 << IWM_RATE_MCS_DUP_POS)
4065
4066/* Bit 27: (1) LDPC enabled, (0) LDPC disabled */
4067#define IWM_RATE_MCS_LDPC_POS		27
4068#define IWM_RATE_MCS_LDPC_MSK		(1 << IWM_RATE_MCS_LDPC_POS)
4069
4070
4071/* Link Quality definitions */
4072
4073/* # entries in rate scale table to support Tx retries */
4074#define  IWM_LQ_MAX_RETRY_NUM 16
4075
4076/* Link quality command flags bit fields */
4077
4078/* Bit 0: (0) Don't use RTS (1) Use RTS */
4079#define IWM_LQ_FLAG_USE_RTS_POS             0
4080#define IWM_LQ_FLAG_USE_RTS_MSK	        (1 << IWM_LQ_FLAG_USE_RTS_POS)
4081
4082/* Bit 1-3: LQ command color. Used to match responses to LQ commands */
4083#define IWM_LQ_FLAG_COLOR_POS               1
4084#define IWM_LQ_FLAG_COLOR_MSK               (7 << IWM_LQ_FLAG_COLOR_POS)
4085
4086/* Bit 4-5: Tx RTS BW Signalling
4087 * (0) No RTS BW signalling
4088 * (1) Static BW signalling
4089 * (2) Dynamic BW signalling
4090 */
4091#define IWM_LQ_FLAG_RTS_BW_SIG_POS          4
4092#define IWM_LQ_FLAG_RTS_BW_SIG_NONE         (0 << IWM_LQ_FLAG_RTS_BW_SIG_POS)
4093#define IWM_LQ_FLAG_RTS_BW_SIG_STATIC       (1 << IWM_LQ_FLAG_RTS_BW_SIG_POS)
4094#define IWM_LQ_FLAG_RTS_BW_SIG_DYNAMIC      (2 << IWM_LQ_FLAG_RTS_BW_SIG_POS)
4095
4096/* Bit 6: (0) No dynamic BW selection (1) Allow dynamic BW selection
4097 * Dyanmic BW selection allows Tx with narrower BW then requested in rates
4098 */
4099#define IWM_LQ_FLAG_DYNAMIC_BW_POS          6
4100#define IWM_LQ_FLAG_DYNAMIC_BW_MSK          (1 << IWM_LQ_FLAG_DYNAMIC_BW_POS)
4101
4102/**
4103 * struct iwm_lq_cmd - link quality command
4104 * @sta_id: station to update
4105 * @control: not used
4106 * @flags: combination of IWM_LQ_FLAG_*
4107 * @mimo_delim: the first SISO index in rs_table, which separates MIMO
4108 *	and SISO rates
4109 * @single_stream_ant_msk: best antenna for SISO (can be dual in CDD).
4110 *	Should be ANT_[ABC]
4111 * @dual_stream_ant_msk: best antennas for MIMO, combination of ANT_[ABC]
4112 * @initial_rate_index: first index from rs_table per AC category
4113 * @agg_time_limit: aggregation max time threshold in usec/100, meaning
4114 *	value of 100 is one usec. Range is 100 to 8000
4115 * @agg_disable_start_th: try-count threshold for starting aggregation.
4116 *	If a frame has higher try-count, it should not be selected for
4117 *	starting an aggregation sequence.
4118 * @agg_frame_cnt_limit: max frame count in an aggregation.
4119 *	0: no limit
4120 *	1: no aggregation (one frame per aggregation)
4121 *	2 - 0x3f: maximal number of frames (up to 3f == 63)
4122 * @rs_table: array of rates for each TX try, each is rate_n_flags,
4123 *	meaning it is a combination of IWM_RATE_MCS_* and IWM_RATE_*_PLCP
4124 * @bf_params: beam forming params, currently not used
4125 */
4126struct iwm_lq_cmd {
4127	uint8_t sta_id;
4128	uint8_t reserved1;
4129	uint16_t control;
4130	/* LINK_QUAL_GENERAL_PARAMS_API_S_VER_1 */
4131	uint8_t flags;
4132	uint8_t mimo_delim;
4133	uint8_t single_stream_ant_msk;
4134	uint8_t dual_stream_ant_msk;
4135	uint8_t initial_rate_index[IWM_AC_NUM];
4136	/* LINK_QUAL_AGG_PARAMS_API_S_VER_1 */
4137	uint16_t agg_time_limit;
4138	uint8_t agg_disable_start_th;
4139	uint8_t agg_frame_cnt_limit;
4140	uint32_t reserved2;
4141	uint32_t rs_table[IWM_LQ_MAX_RETRY_NUM];
4142	uint32_t bf_params;
4143}; /* LINK_QUALITY_CMD_API_S_VER_1 */
4144
4145/*
4146 * END mvm/fw-api-rs.h
4147 */
4148
4149/*
4150 * BEGIN mvm/fw-api-tx.h
4151 */
4152
4153/**
4154 * enum iwm_tx_flags - bitmasks for tx_flags in TX command
4155 * @IWM_TX_CMD_FLG_PROT_REQUIRE: use RTS or CTS-to-self to protect the frame
4156 * @IWM_TX_CMD_FLG_ACK: expect ACK from receiving station
4157 * @IWM_TX_CMD_FLG_STA_RATE: use RS table with initial index from the TX command.
4158 *	Otherwise, use rate_n_flags from the TX command
4159 * @IWM_TX_CMD_FLG_BA: this frame is a block ack
4160 * @IWM_TX_CMD_FLG_BAR: this frame is a BA request, immediate BAR is expected
4161 *	Must set IWM_TX_CMD_FLG_ACK with this flag.
4162 * @IWM_TX_CMD_FLG_TXOP_PROT: protect frame with full TXOP protection
4163 * @IWM_TX_CMD_FLG_VHT_NDPA: mark frame is NDPA for VHT beamformer sequence
4164 * @IWM_TX_CMD_FLG_HT_NDPA: mark frame is NDPA for HT beamformer sequence
4165 * @IWM_TX_CMD_FLG_CSI_FDBK2HOST: mark to send feedback to host (only if good CRC)
4166 * @IWM_TX_CMD_FLG_BT_DIS: disable BT priority for this frame
4167 * @IWM_TX_CMD_FLG_SEQ_CTL: set if FW should override the sequence control.
4168 *	Should be set for mgmt, non-QOS data, mcast, bcast and in scan command
4169 * @IWM_TX_CMD_FLG_MORE_FRAG: this frame is non-last MPDU
4170 * @IWM_TX_CMD_FLG_NEXT_FRAME: this frame includes information of the next frame
4171 * @IWM_TX_CMD_FLG_TSF: FW should calculate and insert TSF in the frame
4172 *	Should be set for beacons and probe responses
4173 * @IWM_TX_CMD_FLG_CALIB: activate PA TX power calibrations
4174 * @IWM_TX_CMD_FLG_KEEP_SEQ_CTL: if seq_ctl is set, don't increase inner seq count
4175 * @IWM_TX_CMD_FLG_AGG_START: allow this frame to start aggregation
4176 * @IWM_TX_CMD_FLG_MH_PAD: driver inserted 2 byte padding after MAC header.
4177 *	Should be set for 26/30 length MAC headers
4178 * @IWM_TX_CMD_FLG_RESP_TO_DRV: zero this if the response should go only to FW
4179 * @IWM_TX_CMD_FLG_CCMP_AGG: this frame uses CCMP for aggregation acceleration
4180 * @IWM_TX_CMD_FLG_TKIP_MIC_DONE: FW already performed TKIP MIC calculation
4181 * @IWM_TX_CMD_FLG_DUR: disable duration overwriting used in PS-Poll Assoc-id
4182 * @IWM_TX_CMD_FLG_FW_DROP: FW should mark frame to be dropped
4183 * @IWM_TX_CMD_FLG_EXEC_PAPD: execute PAPD
4184 * @IWM_TX_CMD_FLG_PAPD_TYPE: 0 for reference power, 1 for nominal power
4185 * @IWM_TX_CMD_FLG_HCCA_CHUNK: mark start of TSPEC chunk
4186 */
4187enum iwm_tx_flags {
4188	IWM_TX_CMD_FLG_PROT_REQUIRE	= (1 << 0),
4189	IWM_TX_CMD_FLG_ACK		= (1 << 3),
4190	IWM_TX_CMD_FLG_STA_RATE		= (1 << 4),
4191	IWM_TX_CMD_FLG_BA		= (1 << 5),
4192	IWM_TX_CMD_FLG_BAR		= (1 << 6),
4193	IWM_TX_CMD_FLG_TXOP_PROT	= (1 << 7),
4194	IWM_TX_CMD_FLG_VHT_NDPA		= (1 << 8),
4195	IWM_TX_CMD_FLG_HT_NDPA		= (1 << 9),
4196	IWM_TX_CMD_FLG_CSI_FDBK2HOST	= (1 << 10),
4197	IWM_TX_CMD_FLG_BT_DIS		= (1 << 12),
4198	IWM_TX_CMD_FLG_SEQ_CTL		= (1 << 13),
4199	IWM_TX_CMD_FLG_MORE_FRAG	= (1 << 14),
4200	IWM_TX_CMD_FLG_NEXT_FRAME	= (1 << 15),
4201	IWM_TX_CMD_FLG_TSF		= (1 << 16),
4202	IWM_TX_CMD_FLG_CALIB		= (1 << 17),
4203	IWM_TX_CMD_FLG_KEEP_SEQ_CTL	= (1 << 18),
4204	IWM_TX_CMD_FLG_AGG_START	= (1 << 19),
4205	IWM_TX_CMD_FLG_MH_PAD		= (1 << 20),
4206	IWM_TX_CMD_FLG_RESP_TO_DRV	= (1 << 21),
4207	IWM_TX_CMD_FLG_CCMP_AGG		= (1 << 22),
4208	IWM_TX_CMD_FLG_TKIP_MIC_DONE	= (1 << 23),
4209	IWM_TX_CMD_FLG_DUR		= (1 << 25),
4210	IWM_TX_CMD_FLG_FW_DROP		= (1 << 26),
4211	IWM_TX_CMD_FLG_EXEC_PAPD	= (1 << 27),
4212	IWM_TX_CMD_FLG_PAPD_TYPE	= (1 << 28),
4213	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1 << 31)
4214}; /* IWM_TX_FLAGS_BITS_API_S_VER_1 */
4215
4216/**
4217 * enum iwm_tx_pm_timeouts - pm timeout values in TX command
4218 * @IWM_PM_FRAME_NONE: no need to suspend sleep mode
4219 * @IWM_PM_FRAME_MGMT: fw suspend sleep mode for 100TU
4220 * @IWM_PM_FRAME_ASSOC: fw suspend sleep mode for 10sec
4221 */
4222enum iwm_tx_pm_timeouts {
4223	IWM_PM_FRAME_NONE           = 0,
4224	IWM_PM_FRAME_MGMT           = 2,
4225	IWM_PM_FRAME_ASSOC          = 3,
4226};
4227
4228/*
4229 * TX command security control
4230 */
4231#define IWM_TX_CMD_SEC_WEP		0x01
4232#define IWM_TX_CMD_SEC_CCM		0x02
4233#define IWM_TX_CMD_SEC_TKIP		0x03
4234#define IWM_TX_CMD_SEC_EXT		0x04
4235#define IWM_TX_CMD_SEC_MSK		0x07
4236#define IWM_TX_CMD_SEC_WEP_KEY_IDX_POS	6
4237#define IWM_TX_CMD_SEC_WEP_KEY_IDX_MSK	0xc0
4238#define IWM_TX_CMD_SEC_KEY128		0x08
4239
4240/* TODO: how does these values are OK with only 16 bit variable??? */
4241/*
4242 * TX command next frame info
4243 *
4244 * bits 0:2 - security control (IWM_TX_CMD_SEC_*)
4245 * bit 3 - immediate ACK required
4246 * bit 4 - rate is taken from STA table
4247 * bit 5 - frame belongs to BA stream
4248 * bit 6 - immediate BA response expected
4249 * bit 7 - unused
4250 * bits 8:15 - Station ID
4251 * bits 16:31 - rate
4252 */
4253#define IWM_TX_CMD_NEXT_FRAME_ACK_MSK		(0x8)
4254#define IWM_TX_CMD_NEXT_FRAME_STA_RATE_MSK	(0x10)
4255#define IWM_TX_CMD_NEXT_FRAME_BA_MSK		(0x20)
4256#define IWM_TX_CMD_NEXT_FRAME_IMM_BA_RSP_MSK	(0x40)
4257#define IWM_TX_CMD_NEXT_FRAME_FLAGS_MSK		(0xf8)
4258#define IWM_TX_CMD_NEXT_FRAME_STA_ID_MSK	(0xff00)
4259#define IWM_TX_CMD_NEXT_FRAME_STA_ID_POS	(8)
4260#define IWM_TX_CMD_NEXT_FRAME_RATE_MSK		(0xffff0000)
4261#define IWM_TX_CMD_NEXT_FRAME_RATE_POS		(16)
4262
4263/*
4264 * TX command Frame life time in us - to be written in pm_frame_timeout
4265 */
4266#define IWM_TX_CMD_LIFE_TIME_INFINITE	0xFFFFFFFF
4267#define IWM_TX_CMD_LIFE_TIME_DEFAULT	2000000 /* 2000 ms*/
4268#define IWM_TX_CMD_LIFE_TIME_PROBE_RESP	40000 /* 40 ms */
4269#define IWM_TX_CMD_LIFE_TIME_EXPIRED_FRAME	0
4270
4271/*
4272 * TID for non QoS frames - to be written in tid_tspec
4273 */
4274#define IWM_TID_NON_QOS	IWM_MAX_TID_COUNT
4275
4276/*
4277 * Limits on the retransmissions - to be written in {data,rts}_retry_limit
4278 */
4279#define IWM_DEFAULT_TX_RETRY			15
4280#define IWM_MGMT_DFAULT_RETRY_LIMIT		3
4281#define IWM_RTS_DFAULT_RETRY_LIMIT		60
4282#define IWM_BAR_DFAULT_RETRY_LIMIT		60
4283#define IWM_LOW_RETRY_LIMIT			7
4284
4285/* TODO: complete documentation for try_cnt and btkill_cnt */
4286/**
4287 * struct iwm_tx_cmd - TX command struct to FW
4288 * ( IWM_TX_CMD = 0x1c )
4289 * @len: in bytes of the payload, see below for details
4290 * @next_frame_len: same as len, but for next frame (0 if not applicable)
4291 *	Used for fragmentation and bursting, but not in 11n aggregation.
4292 * @tx_flags: combination of IWM_TX_CMD_FLG_*
4293 * @rate_n_flags: rate for *all* Tx attempts, if IWM_TX_CMD_FLG_STA_RATE_MSK is
4294 *	cleared. Combination of IWM_RATE_MCS_*
4295 * @sta_id: index of destination station in FW station table
4296 * @sec_ctl: security control, IWM_TX_CMD_SEC_*
4297 * @initial_rate_index: index into the rate table for initial TX attempt.
4298 *	Applied if IWM_TX_CMD_FLG_STA_RATE_MSK is set, normally 0 for data frames.
4299 * @key: security key
4300 * @next_frame_flags: IWM_TX_CMD_SEC_* and IWM_TX_CMD_NEXT_FRAME_*
4301 * @life_time: frame life time (usecs??)
4302 * @dram_lsb_ptr: Physical address of scratch area in the command (try_cnt +
4303 *	btkill_cnd + reserved), first 32 bits. "0" disables usage.
4304 * @dram_msb_ptr: upper bits of the scratch physical address
4305 * @rts_retry_limit: max attempts for RTS
4306 * @data_retry_limit: max attempts to send the data packet
4307 * @tid_spec: TID/tspec
4308 * @pm_frame_timeout: PM TX frame timeout
4309 * @driver_txop: duration od EDCA TXOP, in 32-usec units. Set this if not
4310 *	specified by HCCA protocol
4311 *
4312 * The byte count (both len and next_frame_len) includes MAC header
4313 * (24/26/30/32 bytes)
4314 * + 2 bytes pad if 26/30 header size
4315 * + 8 byte IV for CCM or TKIP (not used for WEP)
4316 * + Data payload
4317 * + 8-byte MIC (not used for CCM/WEP)
4318 * It does not include post-MAC padding, i.e.,
4319 * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.
4320 * Range of len: 14-2342 bytes.
4321 *
4322 * After the struct fields the MAC header is placed, plus any padding,
4323 * and then the actial payload.
4324 */
4325struct iwm_tx_cmd {
4326	uint16_t len;
4327	uint16_t next_frame_len;
4328	uint32_t tx_flags;
4329	struct {
4330		uint8_t try_cnt;
4331		uint8_t btkill_cnt;
4332		uint16_t reserved;
4333	} scratch; /* DRAM_SCRATCH_API_U_VER_1 */
4334	uint32_t rate_n_flags;
4335	uint8_t sta_id;
4336	uint8_t sec_ctl;
4337	uint8_t initial_rate_index;
4338	uint8_t reserved2;
4339	uint8_t key[16];
4340	uint16_t next_frame_flags;
4341	uint16_t reserved3;
4342	uint32_t life_time;
4343	uint32_t dram_lsb_ptr;
4344	uint8_t dram_msb_ptr;
4345	uint8_t rts_retry_limit;
4346	uint8_t data_retry_limit;
4347	uint8_t tid_tspec;
4348	uint16_t pm_frame_timeout;
4349	uint16_t driver_txop;
4350	uint8_t payload[0];
4351	struct ieee80211_frame hdr[0];
4352} __packed; /* IWM_TX_CMD_API_S_VER_3 */
4353
4354/*
4355 * TX response related data
4356 */
4357
4358/*
4359 * enum iwm_tx_status - status that is returned by the fw after attempts to Tx
4360 * @IWM_TX_STATUS_SUCCESS:
4361 * @IWM_TX_STATUS_DIRECT_DONE:
4362 * @IWM_TX_STATUS_POSTPONE_DELAY:
4363 * @IWM_TX_STATUS_POSTPONE_FEW_BYTES:
4364 * @IWM_TX_STATUS_POSTPONE_BT_PRIO:
4365 * @IWM_TX_STATUS_POSTPONE_QUIET_PERIOD:
4366 * @IWM_TX_STATUS_POSTPONE_CALC_TTAK:
4367 * @IWM_TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY:
4368 * @IWM_TX_STATUS_FAIL_SHORT_LIMIT:
4369 * @IWM_TX_STATUS_FAIL_LONG_LIMIT:
4370 * @IWM_TX_STATUS_FAIL_UNDERRUN:
4371 * @IWM_TX_STATUS_FAIL_DRAIN_FLOW:
4372 * @IWM_TX_STATUS_FAIL_RFKILL_FLUSH:
4373 * @IWM_TX_STATUS_FAIL_LIFE_EXPIRE:
4374 * @IWM_TX_STATUS_FAIL_DEST_PS:
4375 * @IWM_TX_STATUS_FAIL_HOST_ABORTED:
4376 * @IWM_TX_STATUS_FAIL_BT_RETRY:
4377 * @IWM_TX_STATUS_FAIL_STA_INVALID:
4378 * @IWM_TX_TATUS_FAIL_FRAG_DROPPED:
4379 * @IWM_TX_STATUS_FAIL_TID_DISABLE:
4380 * @IWM_TX_STATUS_FAIL_FIFO_FLUSHED:
4381 * @IWM_TX_STATUS_FAIL_SMALL_CF_POLL:
4382 * @IWM_TX_STATUS_FAIL_FW_DROP:
4383 * @IWM_TX_STATUS_FAIL_STA_COLOR_MISMATCH: mismatch between color of Tx cmd and
4384 *	STA table
4385 * @IWM_TX_FRAME_STATUS_INTERNAL_ABORT:
4386 * @IWM_TX_MODE_MSK:
4387 * @IWM_TX_MODE_NO_BURST:
4388 * @IWM_TX_MODE_IN_BURST_SEQ:
4389 * @IWM_TX_MODE_FIRST_IN_BURST:
4390 * @IWM_TX_QUEUE_NUM_MSK:
4391 *
4392 * Valid only if frame_count =1
4393 * TODO: complete documentation
4394 */
4395enum iwm_tx_status {
4396	IWM_TX_STATUS_MSK = 0x000000ff,
4397	IWM_TX_STATUS_SUCCESS = 0x01,
4398	IWM_TX_STATUS_DIRECT_DONE = 0x02,
4399	/* postpone TX */
4400	IWM_TX_STATUS_POSTPONE_DELAY = 0x40,
4401	IWM_TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
4402	IWM_TX_STATUS_POSTPONE_BT_PRIO = 0x42,
4403	IWM_TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
4404	IWM_TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
4405	/* abort TX */
4406	IWM_TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
4407	IWM_TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
4408	IWM_TX_STATUS_FAIL_LONG_LIMIT = 0x83,
4409	IWM_TX_STATUS_FAIL_UNDERRUN = 0x84,
4410	IWM_TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
4411	IWM_TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
4412	IWM_TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
4413	IWM_TX_STATUS_FAIL_DEST_PS = 0x88,
4414	IWM_TX_STATUS_FAIL_HOST_ABORTED = 0x89,
4415	IWM_TX_STATUS_FAIL_BT_RETRY = 0x8a,
4416	IWM_TX_STATUS_FAIL_STA_INVALID = 0x8b,
4417	IWM_TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
4418	IWM_TX_STATUS_FAIL_TID_DISABLE = 0x8d,
4419	IWM_TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
4420	IWM_TX_STATUS_FAIL_SMALL_CF_POLL = 0x8f,
4421	IWM_TX_STATUS_FAIL_FW_DROP = 0x90,
4422	IWM_TX_STATUS_FAIL_STA_COLOR_MISMATCH = 0x91,
4423	IWM_TX_STATUS_INTERNAL_ABORT = 0x92,
4424	IWM_TX_MODE_MSK = 0x00000f00,
4425	IWM_TX_MODE_NO_BURST = 0x00000000,
4426	IWM_TX_MODE_IN_BURST_SEQ = 0x00000100,
4427	IWM_TX_MODE_FIRST_IN_BURST = 0x00000200,
4428	IWM_TX_QUEUE_NUM_MSK = 0x0001f000,
4429	IWM_TX_NARROW_BW_MSK = 0x00060000,
4430	IWM_TX_NARROW_BW_1DIV2 = 0x00020000,
4431	IWM_TX_NARROW_BW_1DIV4 = 0x00040000,
4432	IWM_TX_NARROW_BW_1DIV8 = 0x00060000,
4433};
4434
4435/*
4436 * enum iwm_tx_agg_status - TX aggregation status
4437 * @IWM_AGG_TX_STATE_STATUS_MSK:
4438 * @IWM_AGG_TX_STATE_TRANSMITTED:
4439 * @IWM_AGG_TX_STATE_UNDERRUN:
4440 * @IWM_AGG_TX_STATE_BT_PRIO:
4441 * @IWM_AGG_TX_STATE_FEW_BYTES:
4442 * @IWM_AGG_TX_STATE_ABORT:
4443 * @IWM_AGG_TX_STATE_LAST_SENT_TTL:
4444 * @IWM_AGG_TX_STATE_LAST_SENT_TRY_CNT:
4445 * @IWM_AGG_TX_STATE_LAST_SENT_BT_KILL:
4446 * @IWM_AGG_TX_STATE_SCD_QUERY:
4447 * @IWM_AGG_TX_STATE_TEST_BAD_CRC32:
4448 * @IWM_AGG_TX_STATE_RESPONSE:
4449 * @IWM_AGG_TX_STATE_DUMP_TX:
4450 * @IWM_AGG_TX_STATE_DELAY_TX:
4451 * @IWM_AGG_TX_STATE_TRY_CNT_MSK: Retry count for 1st frame in aggregation (retries
4452 *	occur if tx failed for this frame when it was a member of a previous
4453 *	aggregation block). If rate scaling is used, retry count indicates the
4454 *	rate table entry used for all frames in the new agg.
4455 *@ IWM_AGG_TX_STATE_SEQ_NUM_MSK: Command ID and sequence number of Tx command for
4456 *	this frame
4457 *
4458 * TODO: complete documentation
4459 */
4460enum iwm_tx_agg_status {
4461	IWM_AGG_TX_STATE_STATUS_MSK = 0x00fff,
4462	IWM_AGG_TX_STATE_TRANSMITTED = 0x000,
4463	IWM_AGG_TX_STATE_UNDERRUN = 0x001,
4464	IWM_AGG_TX_STATE_BT_PRIO = 0x002,
4465	IWM_AGG_TX_STATE_FEW_BYTES = 0x004,
4466	IWM_AGG_TX_STATE_ABORT = 0x008,
4467	IWM_AGG_TX_STATE_LAST_SENT_TTL = 0x010,
4468	IWM_AGG_TX_STATE_LAST_SENT_TRY_CNT = 0x020,
4469	IWM_AGG_TX_STATE_LAST_SENT_BT_KILL = 0x040,
4470	IWM_AGG_TX_STATE_SCD_QUERY = 0x080,
4471	IWM_AGG_TX_STATE_TEST_BAD_CRC32 = 0x0100,
4472	IWM_AGG_TX_STATE_RESPONSE = 0x1ff,
4473	IWM_AGG_TX_STATE_DUMP_TX = 0x200,
4474	IWM_AGG_TX_STATE_DELAY_TX = 0x400,
4475	IWM_AGG_TX_STATE_TRY_CNT_POS = 12,
4476	IWM_AGG_TX_STATE_TRY_CNT_MSK = 0xf << IWM_AGG_TX_STATE_TRY_CNT_POS,
4477};
4478
4479#define IWM_AGG_TX_STATE_LAST_SENT_MSK  (IWM_AGG_TX_STATE_LAST_SENT_TTL| \
4480				     IWM_AGG_TX_STATE_LAST_SENT_TRY_CNT| \
4481				     IWM_AGG_TX_STATE_LAST_SENT_BT_KILL)
4482
4483/*
4484 * The mask below describes a status where we are absolutely sure that the MPDU
4485 * wasn't sent. For BA/Underrun we cannot be that sure. All we know that we've
4486 * written the bytes to the TXE, but we know nothing about what the DSP did.
4487 */
4488#define IWM_AGG_TX_STAT_FRAME_NOT_SENT (IWM_AGG_TX_STATE_FEW_BYTES | \
4489				    IWM_AGG_TX_STATE_ABORT | \
4490				    IWM_AGG_TX_STATE_SCD_QUERY)
4491
4492/*
4493 * IWM_REPLY_TX = 0x1c (response)
4494 *
4495 * This response may be in one of two slightly different formats, indicated
4496 * by the frame_count field:
4497 *
4498 * 1)	No aggregation (frame_count == 1).  This reports Tx results for a single
4499 *	frame. Multiple attempts, at various bit rates, may have been made for
4500 *	this frame.
4501 *
4502 * 2)	Aggregation (frame_count > 1).  This reports Tx results for two or more
4503 *	frames that used block-acknowledge.  All frames were transmitted at
4504 *	same rate. Rate scaling may have been used if first frame in this new
4505 *	agg block failed in previous agg block(s).
4506 *
4507 *	Note that, for aggregation, ACK (block-ack) status is not delivered
4508 *	here; block-ack has not been received by the time the device records
4509 *	this status.
4510 *	This status relates to reasons the tx might have been blocked or aborted
4511 *	within the device, rather than whether it was received successfully by
4512 *	the destination station.
4513 */
4514
4515/**
4516 * struct iwm_agg_tx_status - per packet TX aggregation status
4517 * @status: enum iwm_tx_agg_status
4518 * @sequence: Sequence # for this frame's Tx cmd (not SSN!)
4519 */
4520struct iwm_agg_tx_status {
4521	uint16_t status;
4522	uint16_t sequence;
4523} __packed;
4524
4525/*
4526 * definitions for initial rate index field
4527 * bits [3:0] initial rate index
4528 * bits [6:4] rate table color, used for the initial rate
4529 * bit-7 invalid rate indication
4530 */
4531#define IWM_TX_RES_INIT_RATE_INDEX_MSK 0x0f
4532#define IWM_TX_RES_RATE_TABLE_COLOR_MSK 0x70
4533#define IWM_TX_RES_INV_RATE_INDEX_MSK 0x80
4534
4535#define IWM_MVM_TX_RES_GET_TID(_ra_tid) ((_ra_tid) & 0x0f)
4536#define IWM_MVM_TX_RES_GET_RA(_ra_tid) ((_ra_tid) >> 4)
4537
4538/**
4539 * struct iwm_mvm_tx_resp - notifies that fw is TXing a packet
4540 * ( IWM_REPLY_TX = 0x1c )
4541 * @frame_count: 1 no aggregation, >1 aggregation
4542 * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
4543 * @failure_rts: num of failures due to unsuccessful RTS
4544 * @failure_frame: num failures due to no ACK (unused for agg)
4545 * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
4546 *	Tx of all the batch. IWM_RATE_MCS_*
4547 * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
4548 *	for agg: RTS + CTS + aggregation tx time + block-ack time.
4549 *	in usec.
4550 * @pa_status: tx power info
4551 * @pa_integ_res_a: tx power info
4552 * @pa_integ_res_b: tx power info
4553 * @pa_integ_res_c: tx power info
4554 * @measurement_req_id: tx power info
4555 * @tfd_info: TFD information set by the FH
4556 * @seq_ctl: sequence control from the Tx cmd
4557 * @byte_cnt: byte count from the Tx cmd
4558 * @tlc_info: TLC rate info
4559 * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
4560 * @frame_ctrl: frame control
4561 * @status: for non-agg:  frame status IWM_TX_STATUS_*
4562 *	for agg: status of 1st frame, IWM_AGG_TX_STATE_*; other frame status fields
4563 *	follow this one, up to frame_count.
4564 *
4565 * After the array of statuses comes the SSN of the SCD. Look at
4566 * %iwm_mvm_get_scd_ssn for more details.
4567 */
4568struct iwm_mvm_tx_resp {
4569	uint8_t frame_count;
4570	uint8_t bt_kill_count;
4571	uint8_t failure_rts;
4572	uint8_t failure_frame;
4573	uint32_t initial_rate;
4574	uint16_t wireless_media_time;
4575
4576	uint8_t pa_status;
4577	uint8_t pa_integ_res_a[3];
4578	uint8_t pa_integ_res_b[3];
4579	uint8_t pa_integ_res_c[3];
4580	uint16_t measurement_req_id;
4581	uint16_t reserved;
4582
4583	uint32_t tfd_info;
4584	uint16_t seq_ctl;
4585	uint16_t byte_cnt;
4586	uint8_t tlc_info;
4587	uint8_t ra_tid;
4588	uint16_t frame_ctrl;
4589
4590	struct iwm_agg_tx_status status;
4591} __packed; /* IWM_TX_RSP_API_S_VER_3 */
4592
4593/**
4594 * struct iwm_mvm_ba_notif - notifies about reception of BA
4595 * ( IWM_BA_NOTIF = 0xc5 )
4596 * @sta_addr_lo32: lower 32 bits of the MAC address
4597 * @sta_addr_hi16: upper 16 bits of the MAC address
4598 * @sta_id: Index of recipient (BA-sending) station in fw's station table
4599 * @tid: tid of the session
4600 * @seq_ctl:
4601 * @bitmap: the bitmap of the BA notification as seen in the air
4602 * @scd_flow: the tx queue this BA relates to
4603 * @scd_ssn: the index of the last contiguously sent packet
4604 * @txed: number of Txed frames in this batch
4605 * @txed_2_done: number of Acked frames in this batch
4606 */
4607struct iwm_mvm_ba_notif {
4608	uint32_t sta_addr_lo32;
4609	uint16_t sta_addr_hi16;
4610	uint16_t reserved;
4611
4612	uint8_t sta_id;
4613	uint8_t tid;
4614	uint16_t seq_ctl;
4615	uint64_t bitmap;
4616	uint16_t scd_flow;
4617	uint16_t scd_ssn;
4618	uint8_t txed;
4619	uint8_t txed_2_done;
4620	uint16_t reserved1;
4621} __packed;
4622
4623/*
4624 * struct iwm_mac_beacon_cmd - beacon template command
4625 * @tx: the tx commands associated with the beacon frame
4626 * @template_id: currently equal to the mac context id of the coresponding
4627 *  mac.
4628 * @tim_idx: the offset of the tim IE in the beacon
4629 * @tim_size: the length of the tim IE
4630 * @frame: the template of the beacon frame
4631 */
4632struct iwm_mac_beacon_cmd {
4633	struct iwm_tx_cmd tx;
4634	uint32_t template_id;
4635	uint32_t tim_idx;
4636	uint32_t tim_size;
4637	struct ieee80211_frame frame[0];
4638} __packed;
4639
4640struct iwm_beacon_notif {
4641	struct iwm_mvm_tx_resp beacon_notify_hdr;
4642	uint64_t tsf;
4643	uint32_t ibss_mgr_status;
4644} __packed;
4645
4646/**
4647 * enum iwm_dump_control - dump (flush) control flags
4648 * @IWM_DUMP_TX_FIFO_FLUSH: Dump MSDUs until the FIFO is empty
4649 *	and the TFD queues are empty.
4650 */
4651enum iwm_dump_control {
4652	IWM_DUMP_TX_FIFO_FLUSH	= (1 << 1),
4653};
4654
4655/**
4656 * struct iwm_tx_path_flush_cmd -- queue/FIFO flush command
4657 * @queues_ctl: bitmap of queues to flush
4658 * @flush_ctl: control flags
4659 * @reserved: reserved
4660 */
4661struct iwm_tx_path_flush_cmd {
4662	uint32_t queues_ctl;
4663	uint16_t flush_ctl;
4664	uint16_t reserved;
4665} __packed; /* IWM_TX_PATH_FLUSH_CMD_API_S_VER_1 */
4666
4667/**
4668 * iwm_mvm_get_scd_ssn - returns the SSN of the SCD
4669 * @tx_resp: the Tx response from the fw (agg or non-agg)
4670 *
4671 * When the fw sends an AMPDU, it fetches the MPDUs one after the other. Since
4672 * it can't know that everything will go well until the end of the AMPDU, it
4673 * can't know in advance the number of MPDUs that will be sent in the current
4674 * batch. This is why it writes the agg Tx response while it fetches the MPDUs.
4675 * Hence, it can't know in advance what the SSN of the SCD will be at the end
4676 * of the batch. This is why the SSN of the SCD is written at the end of the
4677 * whole struct at a variable offset. This function knows how to cope with the
4678 * variable offset and returns the SSN of the SCD.
4679 */
4680static inline uint32_t iwm_mvm_get_scd_ssn(struct iwm_mvm_tx_resp *tx_resp)
4681{
4682	return le32_to_cpup((uint32_t *)&tx_resp->status +
4683			    tx_resp->frame_count) & 0xfff;
4684}
4685
4686/*
4687 * END mvm/fw-api-tx.h
4688 */
4689
4690/*
4691 * BEGIN mvm/fw-api-scan.h
4692 */
4693
4694/**
4695 * struct iwm_scd_txq_cfg_cmd - New txq hw scheduler config command
4696 * @token:
4697 * @sta_id: station id
4698 * @tid:
4699 * @scd_queue: scheduler queue to confiug
4700 * @enable: 1 queue enable, 0 queue disable
4701 * @aggregate: 1 aggregated queue, 0 otherwise
4702 * @tx_fifo: %enum iwm_mvm_tx_fifo
4703 * @window: BA window size
4704 * @ssn: SSN for the BA agreement
4705 */
4706struct iwm_scd_txq_cfg_cmd {
4707	uint8_t token;
4708	uint8_t sta_id;
4709	uint8_t tid;
4710	uint8_t scd_queue;
4711	uint8_t enable;
4712	uint8_t aggregate;
4713	uint8_t tx_fifo;
4714	uint8_t window;
4715	uint16_t ssn;
4716	uint16_t reserved;
4717} __packed; /* SCD_QUEUE_CFG_CMD_API_S_VER_1 */
4718
4719/**
4720 * struct iwm_scd_txq_cfg_rsp
4721 * @token: taken from the command
4722 * @sta_id: station id from the command
4723 * @tid: tid from the command
4724 * @scd_queue: scd_queue from the command
4725 */
4726struct iwm_scd_txq_cfg_rsp {
4727	uint8_t token;
4728	uint8_t sta_id;
4729	uint8_t tid;
4730	uint8_t scd_queue;
4731} __packed; /* SCD_QUEUE_CFG_RSP_API_S_VER_1 */
4732
4733
4734/* Scan Commands, Responses, Notifications */
4735
4736/* Masks for iwm_scan_channel.type flags */
4737#define IWM_SCAN_CHANNEL_TYPE_ACTIVE	(1 << 0)
4738#define IWM_SCAN_CHANNEL_NSSIDS(x)	(((1 << (x)) - 1) << 1)
4739
4740/* Max number of IEs for direct SSID scans in a command */
4741#define IWM_PROBE_OPTION_MAX		20
4742
4743/**
4744 * struct iwm_ssid_ie - directed scan network information element
4745 *
4746 * Up to 20 of these may appear in IWM_REPLY_SCAN_CMD,
4747 * selected by "type" bit field in struct iwm_scan_channel;
4748 * each channel may select different ssids from among the 20 entries.
4749 * SSID IEs get transmitted in reverse order of entry.
4750 */
4751struct iwm_ssid_ie {
4752	uint8_t id;
4753	uint8_t len;
4754	uint8_t ssid[IEEE80211_NWID_LEN];
4755} __packed; /* IWM_SCAN_DIRECT_SSID_IE_API_S_VER_1 */
4756
4757/* scan offload */
4758#define IWM_SCAN_MAX_BLACKLIST_LEN	64
4759#define IWM_SCAN_SHORT_BLACKLIST_LEN	16
4760#define IWM_SCAN_MAX_PROFILES		11
4761#define IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE	512
4762
4763/* Default watchdog (in MS) for scheduled scan iteration */
4764#define IWM_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
4765
4766#define IWM_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
4767#define IWM_CAN_ABORT_STATUS 1
4768
4769#define IWM_FULL_SCAN_MULTIPLIER 5
4770#define IWM_FAST_SCHED_SCAN_ITERATIONS 3
4771#define IWM_MAX_SCHED_SCAN_PLANS 2
4772
4773/**
4774 * iwm_scan_schedule_lmac - schedule of scan offload
4775 * @delay:		delay between iterations, in seconds.
4776 * @iterations:		num of scan iterations
4777 * @full_scan_mul:	number of partial scans before each full scan
4778 */
4779struct iwm_scan_schedule_lmac {
4780	uint16_t delay;
4781	uint8_t iterations;
4782	uint8_t full_scan_mul;
4783} __packed; /* SCAN_SCHEDULE_API_S */
4784
4785/**
4786 * iwm_scan_req_tx_cmd - SCAN_REQ_TX_CMD_API_S
4787 * @tx_flags: combination of TX_CMD_FLG_*
4788 * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
4789 *	cleared. Combination of RATE_MCS_*
4790 * @sta_id: index of destination station in FW station table
4791 * @reserved: for alignment and future use
4792 */
4793struct iwm_scan_req_tx_cmd {
4794	uint32_t tx_flags;
4795	uint32_t rate_n_flags;
4796	uint8_t sta_id;
4797	uint8_t reserved[3];
4798} __packed;
4799
4800enum iwm_scan_channel_flags_lmac {
4801	IWM_UNIFIED_SCAN_CHANNEL_FULL		= (1 << 27),
4802	IWM_UNIFIED_SCAN_CHANNEL_PARTIAL	= (1 << 28),
4803};
4804
4805/**
4806 * iwm_scan_channel_cfg_lmac - SCAN_CHANNEL_CFG_S_VER2
4807 * @flags:		bits 1-20: directed scan to i'th ssid
4808 *			other bits &enum iwm_scan_channel_flags_lmac
4809 * @channel_number:	channel number 1-13 etc
4810 * @iter_count:		scan iteration on this channel
4811 * @iter_interval:	interval in seconds between iterations on one channel
4812 */
4813struct iwm_scan_channel_cfg_lmac {
4814	uint32_t flags;
4815	uint16_t channel_num;
4816	uint16_t iter_count;
4817	uint32_t iter_interval;
4818} __packed;
4819
4820/*
4821 * iwm_scan_probe_segment - PROBE_SEGMENT_API_S_VER_1
4822 * @offset: offset in the data block
4823 * @len: length of the segment
4824 */
4825struct iwm_scan_probe_segment {
4826	uint16_t offset;
4827	uint16_t len;
4828} __packed;
4829
4830/* iwm_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_2
4831 * @mac_header: first (and common) part of the probe
4832 * @band_data: band specific data
4833 * @common_data: last (and common) part of the probe
4834 * @buf: raw data block
4835 */
4836struct iwm_scan_probe_req {
4837	struct iwm_scan_probe_segment mac_header;
4838	struct iwm_scan_probe_segment band_data[2];
4839	struct iwm_scan_probe_segment common_data;
4840	uint8_t buf[IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE];
4841} __packed;
4842
4843enum iwm_scan_channel_flags {
4844	IWM_SCAN_CHANNEL_FLAG_EBS		= (1 << 0),
4845	IWM_SCAN_CHANNEL_FLAG_EBS_ACCURATE	= (1 << 1),
4846	IWM_SCAN_CHANNEL_FLAG_CACHE_ADD		= (1 << 2),
4847};
4848
4849/* iwm_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
4850 * @flags: enum iwm_scan_channel_flags
4851 * @non_ebs_ratio: defines the ratio of number of scan iterations where EBS is
4852 *	involved.
4853 *	1 - EBS is disabled.
4854 *	2 - every second scan will be full scan(and so on).
4855 */
4856struct iwm_scan_channel_opt {
4857	uint16_t flags;
4858	uint16_t non_ebs_ratio;
4859} __packed;
4860
4861/**
4862 * iwm_mvm_lmac_scan_flags
4863 * @IWM_MVM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
4864 *      without filtering.
4865 * @IWM_MVM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
4866 * @IWM_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
4867 * @IWM_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
4868 * @IWM_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS multiple SSID matching
4869 * @IWM_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
4870 * @IWM_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report
4871 *      and DS parameter set IEs into probe requests.
4872 * @IWM_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL: use extended dwell time on channels
4873 *      1, 6 and 11.
4874 * @IWM_MVM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches
4875 */
4876enum iwm_mvm_lmac_scan_flags {
4877	IWM_MVM_LMAC_SCAN_FLAG_PASS_ALL		= (1 << 0),
4878	IWM_MVM_LMAC_SCAN_FLAG_PASSIVE		= (1 << 1),
4879	IWM_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION	= (1 << 2),
4880	IWM_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE	= (1 << 3),
4881	IWM_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS	= (1 << 4),
4882	IWM_MVM_LMAC_SCAN_FLAG_FRAGMENTED	= (1 << 5),
4883	IWM_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED	= (1 << 6),
4884	IWM_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL	= (1 << 7),
4885	IWM_MVM_LMAC_SCAN_FLAG_MATCH		= (1 << 9),
4886};
4887
4888enum iwm_scan_priority {
4889	IWM_SCAN_PRIORITY_LOW,
4890	IWM_SCAN_PRIORITY_MEDIUM,
4891	IWM_SCAN_PRIORITY_HIGH,
4892};
4893
4894/**
4895 * iwm_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
4896 * @reserved1: for alignment and future use
4897 * @channel_num: num of channels to scan
4898 * @active-dwell: dwell time for active channels
4899 * @passive-dwell: dwell time for passive channels
4900 * @fragmented-dwell: dwell time for fragmented passive scan
4901 * @extended_dwell: dwell time for channels 1, 6 and 11 (in certain cases)
4902 * @reserved2: for alignment and future use
4903 * @rx_chain_selct: PHY_RX_CHAIN_* flags
4904 * @scan_flags: &enum iwm_mvm_lmac_scan_flags
4905 * @max_out_time: max time (in TU) to be out of associated channel
4906 * @suspend_time: pause scan this long (TUs) when returning to service channel
4907 * @flags: RXON flags
4908 * @filter_flags: RXON filter
4909 * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
4910 * @direct_scan: list of SSIDs for directed active scan
4911 * @scan_prio: enum iwm_scan_priority
4912 * @iter_num: number of scan iterations
4913 * @delay: delay in seconds before first iteration
4914 * @schedule: two scheduling plans. The first one is finite, the second one can
4915 *	be infinite.
4916 * @channel_opt: channel optimization options, for full and partial scan
4917 * @data: channel configuration and probe request packet.
4918 */
4919struct iwm_scan_req_lmac {
4920	/* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
4921	uint32_t reserved1;
4922	uint8_t n_channels;
4923	uint8_t active_dwell;
4924	uint8_t passive_dwell;
4925	uint8_t fragmented_dwell;
4926	uint8_t extended_dwell;
4927	uint8_t reserved2;
4928	uint16_t rx_chain_select;
4929	uint32_t scan_flags;
4930	uint32_t max_out_time;
4931	uint32_t suspend_time;
4932	/* RX_ON_FLAGS_API_S_VER_1 */
4933	uint32_t flags;
4934	uint32_t filter_flags;
4935	struct iwm_scan_req_tx_cmd tx_cmd[2];
4936	struct iwm_ssid_ie direct_scan[IWM_PROBE_OPTION_MAX];
4937	uint32_t scan_prio;
4938	/* SCAN_REQ_PERIODIC_PARAMS_API_S */
4939	uint32_t iter_num;
4940	uint32_t delay;
4941	struct iwm_scan_schedule_lmac schedule[IWM_MAX_SCHED_SCAN_PLANS];
4942	struct iwm_scan_channel_opt channel_opt[2];
4943	uint8_t data[];
4944} __packed;
4945
4946/**
4947 * iwm_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
4948 * @last_schedule_line: last schedule line executed (fast or regular)
4949 * @last_schedule_iteration: last scan iteration executed before scan abort
4950 * @status: enum iwm_scan_offload_complete_status
4951 * @ebs_status: EBS success status &enum iwm_scan_ebs_status
4952 * @time_after_last_iter; time in seconds elapsed after last iteration
4953 */
4954struct iwm_periodic_scan_complete {
4955	uint8_t last_schedule_line;
4956	uint8_t last_schedule_iteration;
4957	uint8_t status;
4958	uint8_t ebs_status;
4959	uint32_t time_after_last_iter;
4960	uint32_t reserved;
4961} __packed;
4962
4963/* How many statistics are gathered for each channel */
4964#define IWM_SCAN_RESULTS_STATISTICS 1
4965
4966/**
4967 * enum iwm_scan_complete_status - status codes for scan complete notifications
4968 * @IWM_SCAN_COMP_STATUS_OK:  scan completed successfully
4969 * @IWM_SCAN_COMP_STATUS_ABORT: scan was aborted by user
4970 * @IWM_SCAN_COMP_STATUS_ERR_SLEEP: sending null sleep packet failed
4971 * @IWM_SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT: timeout before channel is ready
4972 * @IWM_SCAN_COMP_STATUS_ERR_PROBE: sending probe request failed
4973 * @IWM_SCAN_COMP_STATUS_ERR_WAKEUP: sending null wakeup packet failed
4974 * @IWM_SCAN_COMP_STATUS_ERR_ANTENNAS: invalid antennas chosen at scan command
4975 * @IWM_SCAN_COMP_STATUS_ERR_INTERNAL: internal error caused scan abort
4976 * @IWM_SCAN_COMP_STATUS_ERR_COEX: medium was lost ot WiMax
4977 * @IWM_SCAN_COMP_STATUS_P2P_ACTION_OK: P2P public action frame TX was successful
4978 *	(not an error!)
4979 * @IWM_SCAN_COMP_STATUS_ITERATION_END: indicates end of one repeatition the driver
4980 *	asked for
4981 * @IWM_SCAN_COMP_STATUS_ERR_ALLOC_TE: scan could not allocate time events
4982*/
4983enum iwm_scan_complete_status {
4984	IWM_SCAN_COMP_STATUS_OK = 0x1,
4985	IWM_SCAN_COMP_STATUS_ABORT = 0x2,
4986	IWM_SCAN_COMP_STATUS_ERR_SLEEP = 0x3,
4987	IWM_SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT = 0x4,
4988	IWM_SCAN_COMP_STATUS_ERR_PROBE = 0x5,
4989	IWM_SCAN_COMP_STATUS_ERR_WAKEUP = 0x6,
4990	IWM_SCAN_COMP_STATUS_ERR_ANTENNAS = 0x7,
4991	IWM_SCAN_COMP_STATUS_ERR_INTERNAL = 0x8,
4992	IWM_SCAN_COMP_STATUS_ERR_COEX = 0x9,
4993	IWM_SCAN_COMP_STATUS_P2P_ACTION_OK = 0xA,
4994	IWM_SCAN_COMP_STATUS_ITERATION_END = 0x0B,
4995	IWM_SCAN_COMP_STATUS_ERR_ALLOC_TE = 0x0C,
4996};
4997
4998/**
4999 * struct iwm_scan_results_notif - scan results for one channel
5000 * ( IWM_SCAN_RESULTS_NOTIFICATION = 0x83 )
5001 * @channel: which channel the results are from
5002 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
5003 * @probe_status: IWM_SCAN_PROBE_STATUS_*, indicates success of probe request
5004 * @num_probe_not_sent: # of request that weren't sent due to not enough time
5005 * @duration: duration spent in channel, in usecs
5006 * @statistics: statistics gathered for this channel
5007 */
5008struct iwm_scan_results_notif {
5009	uint8_t channel;
5010	uint8_t band;
5011	uint8_t probe_status;
5012	uint8_t num_probe_not_sent;
5013	uint32_t duration;
5014	uint32_t statistics[IWM_SCAN_RESULTS_STATISTICS];
5015} __packed; /* IWM_SCAN_RESULT_NTF_API_S_VER_2 */
5016
5017enum iwm_scan_framework_client {
5018	IWM_SCAN_CLIENT_SCHED_SCAN	= (1 << 0),
5019	IWM_SCAN_CLIENT_NETDETECT	= (1 << 1),
5020	IWM_SCAN_CLIENT_ASSET_TRACKING	= (1 << 2),
5021};
5022
5023/**
5024 * iwm_scan_offload_blacklist - IWM_SCAN_OFFLOAD_BLACKLIST_S
5025 * @ssid:		MAC address to filter out
5026 * @reported_rssi:	AP rssi reported to the host
5027 * @client_bitmap: clients ignore this entry  - enum scan_framework_client
5028 */
5029struct iwm_scan_offload_blacklist {
5030	uint8_t ssid[IEEE80211_ADDR_LEN];
5031	uint8_t reported_rssi;
5032	uint8_t client_bitmap;
5033} __packed;
5034
5035enum iwm_scan_offload_network_type {
5036	IWM_NETWORK_TYPE_BSS	= 1,
5037	IWM_NETWORK_TYPE_IBSS	= 2,
5038	IWM_NETWORK_TYPE_ANY	= 3,
5039};
5040
5041enum iwm_scan_offload_band_selection {
5042	IWM_SCAN_OFFLOAD_SELECT_2_4	= 0x4,
5043	IWM_SCAN_OFFLOAD_SELECT_5_2	= 0x8,
5044	IWM_SCAN_OFFLOAD_SELECT_ANY	= 0xc,
5045};
5046
5047/**
5048 * iwm_scan_offload_profile - IWM_SCAN_OFFLOAD_PROFILE_S
5049 * @ssid_index:		index to ssid list in fixed part
5050 * @unicast_cipher:	encryption olgorithm to match - bitmap
5051 * @aut_alg:		authentication olgorithm to match - bitmap
5052 * @network_type:	enum iwm_scan_offload_network_type
5053 * @band_selection:	enum iwm_scan_offload_band_selection
5054 * @client_bitmap:	clients waiting for match - enum scan_framework_client
5055 */
5056struct iwm_scan_offload_profile {
5057	uint8_t ssid_index;
5058	uint8_t unicast_cipher;
5059	uint8_t auth_alg;
5060	uint8_t network_type;
5061	uint8_t band_selection;
5062	uint8_t client_bitmap;
5063	uint8_t reserved[2];
5064} __packed;
5065
5066/**
5067 * iwm_scan_offload_profile_cfg - IWM_SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_1
5068 * @blaclist:		AP list to filter off from scan results
5069 * @profiles:		profiles to search for match
5070 * @blacklist_len:	length of blacklist
5071 * @num_profiles:	num of profiles in the list
5072 * @match_notify:	clients waiting for match found notification
5073 * @pass_match:		clients waiting for the results
5074 * @active_clients:	active clients bitmap - enum scan_framework_client
5075 * @any_beacon_notify:	clients waiting for match notification without match
5076 */
5077struct iwm_scan_offload_profile_cfg {
5078	struct iwm_scan_offload_profile profiles[IWM_SCAN_MAX_PROFILES];
5079	uint8_t blacklist_len;
5080	uint8_t num_profiles;
5081	uint8_t match_notify;
5082	uint8_t pass_match;
5083	uint8_t active_clients;
5084	uint8_t any_beacon_notify;
5085	uint8_t reserved[2];
5086} __packed;
5087
5088enum iwm_scan_offload_complete_status {
5089	IWM_SCAN_OFFLOAD_COMPLETED	= 1,
5090	IWM_SCAN_OFFLOAD_ABORTED	= 2,
5091};
5092
5093/**
5094 * struct iwm_lmac_scan_complete_notif - notifies end of scanning (all channels)
5095 *	SCAN_COMPLETE_NTF_API_S_VER_3
5096 * @scanned_channels: number of channels scanned (and number of valid results)
5097 * @status: one of SCAN_COMP_STATUS_*
5098 * @bt_status: BT on/off status
5099 * @last_channel: last channel that was scanned
5100 * @tsf_low: TSF timer (lower half) in usecs
5101 * @tsf_high: TSF timer (higher half) in usecs
5102 * @results: an array of scan results, only "scanned_channels" of them are valid
5103 */
5104struct iwm_lmac_scan_complete_notif {
5105	uint8_t scanned_channels;
5106	uint8_t status;
5107	uint8_t bt_status;
5108	uint8_t last_channel;
5109	uint32_t tsf_low;
5110	uint32_t tsf_high;
5111	struct iwm_scan_results_notif results[];
5112} __packed;
5113
5114
5115/*
5116 * END mvm/fw-api-scan.h
5117 */
5118
5119/*
5120 * BEGIN mvm/fw-api-sta.h
5121 */
5122
5123/* UMAC Scan API */
5124
5125/* The maximum of either of these cannot exceed 8, because we use an
5126 * 8-bit mask (see IWM_MVM_SCAN_MASK).
5127 */
5128#define IWM_MVM_MAX_UMAC_SCANS 8
5129#define IWM_MVM_MAX_LMAC_SCANS 1
5130
5131enum iwm_scan_config_flags {
5132	IWM_SCAN_CONFIG_FLAG_ACTIVATE			= (1 << 0),
5133	IWM_SCAN_CONFIG_FLAG_DEACTIVATE			= (1 << 1),
5134	IWM_SCAN_CONFIG_FLAG_FORBID_CHUB_REQS		= (1 << 2),
5135	IWM_SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS		= (1 << 3),
5136	IWM_SCAN_CONFIG_FLAG_SET_TX_CHAINS		= (1 << 8),
5137	IWM_SCAN_CONFIG_FLAG_SET_RX_CHAINS		= (1 << 9),
5138	IWM_SCAN_CONFIG_FLAG_SET_AUX_STA_ID		= (1 << 10),
5139	IWM_SCAN_CONFIG_FLAG_SET_ALL_TIMES		= (1 << 11),
5140	IWM_SCAN_CONFIG_FLAG_SET_EFFECTIVE_TIMES	= (1 << 12),
5141	IWM_SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS		= (1 << 13),
5142	IWM_SCAN_CONFIG_FLAG_SET_LEGACY_RATES		= (1 << 14),
5143	IWM_SCAN_CONFIG_FLAG_SET_MAC_ADDR		= (1 << 15),
5144	IWM_SCAN_CONFIG_FLAG_SET_FRAGMENTED		= (1 << 16),
5145	IWM_SCAN_CONFIG_FLAG_CLEAR_FRAGMENTED		= (1 << 17),
5146	IWM_SCAN_CONFIG_FLAG_SET_CAM_MODE		= (1 << 18),
5147	IWM_SCAN_CONFIG_FLAG_CLEAR_CAM_MODE		= (1 << 19),
5148	IWM_SCAN_CONFIG_FLAG_SET_PROMISC_MODE		= (1 << 20),
5149	IWM_SCAN_CONFIG_FLAG_CLEAR_PROMISC_MODE		= (1 << 21),
5150
5151	/* Bits 26-31 are for num of channels in channel_array */
5152#define IWM_SCAN_CONFIG_N_CHANNELS(n) ((n) << 26)
5153};
5154
5155enum iwm_scan_config_rates {
5156	/* OFDM basic rates */
5157	IWM_SCAN_CONFIG_RATE_6M		= (1 << 0),
5158	IWM_SCAN_CONFIG_RATE_9M		= (1 << 1),
5159	IWM_SCAN_CONFIG_RATE_12M	= (1 << 2),
5160	IWM_SCAN_CONFIG_RATE_18M	= (1 << 3),
5161	IWM_SCAN_CONFIG_RATE_24M	= (1 << 4),
5162	IWM_SCAN_CONFIG_RATE_36M	= (1 << 5),
5163	IWM_SCAN_CONFIG_RATE_48M	= (1 << 6),
5164	IWM_SCAN_CONFIG_RATE_54M	= (1 << 7),
5165	/* CCK basic rates */
5166	IWM_SCAN_CONFIG_RATE_1M		= (1 << 8),
5167	IWM_SCAN_CONFIG_RATE_2M		= (1 << 9),
5168	IWM_SCAN_CONFIG_RATE_5M		= (1 << 10),
5169	IWM_SCAN_CONFIG_RATE_11M	= (1 << 11),
5170
5171	/* Bits 16-27 are for supported rates */
5172#define IWM_SCAN_CONFIG_SUPPORTED_RATE(rate)	((rate) << 16)
5173};
5174
5175enum iwm_channel_flags {
5176	IWM_CHANNEL_FLAG_EBS				= (1 << 0),
5177	IWM_CHANNEL_FLAG_ACCURATE_EBS			= (1 << 1),
5178	IWM_CHANNEL_FLAG_EBS_ADD			= (1 << 2),
5179	IWM_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE	= (1 << 3),
5180};
5181
5182/**
5183 * struct iwm_scan_config
5184 * @flags:			enum scan_config_flags
5185 * @tx_chains:			valid_tx antenna - ANT_* definitions
5186 * @rx_chains:			valid_rx antenna - ANT_* definitions
5187 * @legacy_rates:		default legacy rates - enum scan_config_rates
5188 * @out_of_channel_time:	default max out of serving channel time
5189 * @suspend_time:		default max suspend time
5190 * @dwell_active:		default dwell time for active scan
5191 * @dwell_passive:		default dwell time for passive scan
5192 * @dwell_fragmented:		default dwell time for fragmented scan
5193 * @dwell_extended:		default dwell time for channels 1, 6 and 11
5194 * @mac_addr:			default mac address to be used in probes
5195 * @bcast_sta_id:		the index of the station in the fw
5196 * @channel_flags:		default channel flags - enum iwm_channel_flags
5197 *				scan_config_channel_flag
5198 * @channel_array:		default supported channels
5199 */
5200struct iwm_scan_config {
5201	uint32_t flags;
5202	uint32_t tx_chains;
5203	uint32_t rx_chains;
5204	uint32_t legacy_rates;
5205	uint32_t out_of_channel_time;
5206	uint32_t suspend_time;
5207	uint8_t dwell_active;
5208	uint8_t dwell_passive;
5209	uint8_t dwell_fragmented;
5210	uint8_t dwell_extended;
5211	uint8_t mac_addr[IEEE80211_ADDR_LEN];
5212	uint8_t bcast_sta_id;
5213	uint8_t channel_flags;
5214	uint8_t channel_array[];
5215} __packed; /* SCAN_CONFIG_DB_CMD_API_S */
5216
5217/**
5218 * iwm_umac_scan_flags
5219 *@IWM_UMAC_SCAN_FLAG_PREEMPTIVE: scan process triggered by this scan request
5220 *	can be preempted by other scan requests with higher priority.
5221 *	The low priority scan will be resumed when the higher proirity scan is
5222 *	completed.
5223 *@IWM_UMAC_SCAN_FLAG_START_NOTIF: notification will be sent to the driver
5224 *	when scan starts.
5225 */
5226enum iwm_umac_scan_flags {
5227	IWM_UMAC_SCAN_FLAG_PREEMPTIVE		= (1 << 0),
5228	IWM_UMAC_SCAN_FLAG_START_NOTIF		= (1 << 1),
5229};
5230
5231enum iwm_umac_scan_uid_offsets {
5232	IWM_UMAC_SCAN_UID_TYPE_OFFSET		= 0,
5233	IWM_UMAC_SCAN_UID_SEQ_OFFSET		= 8,
5234};
5235
5236enum iwm_umac_scan_general_flags {
5237	IWM_UMAC_SCAN_GEN_FLAGS_PERIODIC	= (1 << 0),
5238	IWM_UMAC_SCAN_GEN_FLAGS_OVER_BT		= (1 << 1),
5239	IWM_UMAC_SCAN_GEN_FLAGS_PASS_ALL	= (1 << 2),
5240	IWM_UMAC_SCAN_GEN_FLAGS_PASSIVE		= (1 << 3),
5241	IWM_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT	= (1 << 4),
5242	IWM_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE	= (1 << 5),
5243	IWM_UMAC_SCAN_GEN_FLAGS_MULTIPLE_SSID	= (1 << 6),
5244	IWM_UMAC_SCAN_GEN_FLAGS_FRAGMENTED	= (1 << 7),
5245	IWM_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED	= (1 << 8),
5246	IWM_UMAC_SCAN_GEN_FLAGS_MATCH		= (1 << 9),
5247	IWM_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL	= (1 << 10),
5248};
5249
5250/**
5251 * struct iwm_scan_channel_cfg_umac
5252 * @flags:		bitmap - 0-19:	directed scan to i'th ssid.
5253 * @channel_num:	channel number 1-13 etc.
5254 * @iter_count:		repetition count for the channel.
5255 * @iter_interval:	interval between two scan iterations on one channel.
5256 */
5257struct iwm_scan_channel_cfg_umac {
5258	uint32_t flags;
5259#define IWM_SCAN_CHANNEL_UMAC_NSSIDS(x)		((1 << (x)) - 1)
5260
5261	uint8_t channel_num;
5262	uint8_t iter_count;
5263	uint16_t iter_interval;
5264} __packed; /* SCAN_CHANNEL_CFG_S_VER2 */
5265
5266/**
5267 * struct iwm_scan_umac_schedule
5268 * @interval: interval in seconds between scan iterations
5269 * @iter_count: num of scan iterations for schedule plan, 0xff for infinite loop
5270 * @reserved: for alignment and future use
5271 */
5272struct iwm_scan_umac_schedule {
5273	uint16_t interval;
5274	uint8_t iter_count;
5275	uint8_t reserved;
5276} __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
5277
5278/**
5279 * struct iwm_scan_req_umac_tail - the rest of the UMAC scan request command
5280 *      parameters following channels configuration array.
5281 * @schedule: two scheduling plans.
5282 * @delay: delay in TUs before starting the first scan iteration
5283 * @reserved: for future use and alignment
5284 * @preq: probe request with IEs blocks
5285 * @direct_scan: list of SSIDs for directed active scan
5286 */
5287struct iwm_scan_req_umac_tail {
5288	/* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
5289	struct iwm_scan_umac_schedule schedule[IWM_MAX_SCHED_SCAN_PLANS];
5290	uint16_t delay;
5291	uint16_t reserved;
5292	/* SCAN_PROBE_PARAMS_API_S_VER_1 */
5293	struct iwm_scan_probe_req preq;
5294	struct iwm_ssid_ie direct_scan[IWM_PROBE_OPTION_MAX];
5295} __packed;
5296
5297/**
5298 * struct iwm_scan_req_umac
5299 * @flags: &enum iwm_umac_scan_flags
5300 * @uid: scan id, &enum iwm_umac_scan_uid_offsets
5301 * @ooc_priority: out of channel priority - &enum iwm_scan_priority
5302 * @general_flags: &enum iwm_umac_scan_general_flags
5303 * @extended_dwell: dwell time for channels 1, 6 and 11
5304 * @active_dwell: dwell time for active scan
5305 * @passive_dwell: dwell time for passive scan
5306 * @fragmented_dwell: dwell time for fragmented passive scan
5307 * @max_out_time: max out of serving channel time
5308 * @suspend_time: max suspend time
5309 * @scan_priority: scan internal prioritization &enum iwm_scan_priority
5310 * @channel_flags: &enum iwm_scan_channel_flags
5311 * @n_channels: num of channels in scan request
5312 * @reserved: for future use and alignment
5313 * @data: &struct iwm_scan_channel_cfg_umac and
5314 *	&struct iwm_scan_req_umac_tail
5315 */
5316struct iwm_scan_req_umac {
5317	uint32_t flags;
5318	uint32_t uid;
5319	uint32_t ooc_priority;
5320	/* SCAN_GENERAL_PARAMS_API_S_VER_1 */
5321	uint32_t general_flags;
5322	uint8_t extended_dwell;
5323	uint8_t active_dwell;
5324	uint8_t passive_dwell;
5325	uint8_t fragmented_dwell;
5326	uint32_t max_out_time;
5327	uint32_t suspend_time;
5328	uint32_t scan_priority;
5329	/* SCAN_CHANNEL_PARAMS_API_S_VER_1 */
5330	uint8_t channel_flags;
5331	uint8_t n_channels;
5332	uint16_t reserved;
5333	uint8_t data[];
5334} __packed; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
5335
5336/**
5337 * struct iwm_umac_scan_abort
5338 * @uid: scan id, &enum iwm_umac_scan_uid_offsets
5339 * @flags: reserved
5340 */
5341struct iwm_umac_scan_abort {
5342	uint32_t uid;
5343	uint32_t flags;
5344} __packed; /* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */
5345
5346/**
5347 * struct iwm_umac_scan_complete
5348 * @uid: scan id, &enum iwm_umac_scan_uid_offsets
5349 * @last_schedule: last scheduling line
5350 * @last_iter:	last scan iteration number
5351 * @scan status: &enum iwm_scan_offload_complete_status
5352 * @ebs_status: &enum iwm_scan_ebs_status
5353 * @time_from_last_iter: time elapsed from last iteration
5354 * @reserved: for future use
5355 */
5356struct iwm_umac_scan_complete {
5357	uint32_t uid;
5358	uint8_t last_schedule;
5359	uint8_t last_iter;
5360	uint8_t status;
5361	uint8_t ebs_status;
5362	uint32_t time_from_last_iter;
5363	uint32_t reserved;
5364} __packed; /* SCAN_COMPLETE_NTF_UMAC_API_S_VER_1 */
5365
5366#define IWM_SCAN_OFFLOAD_MATCHING_CHANNELS_LEN 5
5367/**
5368 * struct iwm_scan_offload_profile_match - match information
5369 * @bssid: matched bssid
5370 * @channel: channel where the match occurred
5371 * @energy:
5372 * @matching_feature:
5373 * @matching_channels: bitmap of channels that matched, referencing
5374 *	the channels passed in tue scan offload request
5375 */
5376struct iwm_scan_offload_profile_match {
5377	uint8_t bssid[IEEE80211_ADDR_LEN];
5378	uint16_t reserved;
5379	uint8_t channel;
5380	uint8_t energy;
5381	uint8_t matching_feature;
5382	uint8_t matching_channels[IWM_SCAN_OFFLOAD_MATCHING_CHANNELS_LEN];
5383} __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_1 */
5384
5385/**
5386 * struct iwm_scan_offload_profiles_query - match results query response
5387 * @matched_profiles: bitmap of matched profiles, referencing the
5388 *	matches passed in the scan offload request
5389 * @last_scan_age: age of the last offloaded scan
5390 * @n_scans_done: number of offloaded scans done
5391 * @gp2_d0u: GP2 when D0U occurred
5392 * @gp2_invoked: GP2 when scan offload was invoked
5393 * @resume_while_scanning: not used
5394 * @self_recovery: obsolete
5395 * @reserved: reserved
5396 * @matches: array of match information, one for each match
5397 */
5398struct iwm_scan_offload_profiles_query {
5399	uint32_t matched_profiles;
5400	uint32_t last_scan_age;
5401	uint32_t n_scans_done;
5402	uint32_t gp2_d0u;
5403	uint32_t gp2_invoked;
5404	uint8_t resume_while_scanning;
5405	uint8_t self_recovery;
5406	uint16_t reserved;
5407	struct iwm_scan_offload_profile_match matches[IWM_SCAN_MAX_PROFILES];
5408} __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
5409
5410/**
5411 * struct iwm_umac_scan_iter_complete_notif - notifies end of scanning iteration
5412 * @uid: scan id, &enum iwm_umac_scan_uid_offsets
5413 * @scanned_channels: number of channels scanned and number of valid elements in
5414 *	results array
5415 * @status: one of SCAN_COMP_STATUS_*
5416 * @bt_status: BT on/off status
5417 * @last_channel: last channel that was scanned
5418 * @tsf_low: TSF timer (lower half) in usecs
5419 * @tsf_high: TSF timer (higher half) in usecs
5420 * @results: array of scan results, only "scanned_channels" of them are valid
5421 */
5422struct iwm_umac_scan_iter_complete_notif {
5423	uint32_t uid;
5424	uint8_t scanned_channels;
5425	uint8_t status;
5426	uint8_t bt_status;
5427	uint8_t last_channel;
5428	uint32_t tsf_low;
5429	uint32_t tsf_high;
5430	struct iwm_scan_results_notif results[];
5431} __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_1 */
5432
5433/* Please keep this enum *SORTED* by hex value.
5434 * Needed for binary search, otherwise a warning will be triggered.
5435 */
5436enum iwm_scan_subcmd_ids {
5437	IWM_GSCAN_START_CMD = 0x0,
5438	IWM_GSCAN_STOP_CMD = 0x1,
5439	IWM_GSCAN_SET_HOTLIST_CMD = 0x2,
5440	IWM_GSCAN_RESET_HOTLIST_CMD = 0x3,
5441	IWM_GSCAN_SET_SIGNIFICANT_CHANGE_CMD = 0x4,
5442	IWM_GSCAN_RESET_SIGNIFICANT_CHANGE_CMD = 0x5,
5443	IWM_GSCAN_SIGNIFICANT_CHANGE_EVENT = 0xFD,
5444	IWM_GSCAN_HOTLIST_CHANGE_EVENT = 0xFE,
5445	IWM_GSCAN_RESULTS_AVAILABLE_EVENT = 0xFF,
5446};
5447
5448/* STA API */
5449
5450/**
5451 * enum iwm_sta_flags - flags for the ADD_STA host command
5452 * @IWM_STA_FLG_REDUCED_TX_PWR_CTRL:
5453 * @IWM_STA_FLG_REDUCED_TX_PWR_DATA:
5454 * @IWM_STA_FLG_DISABLE_TX: set if TX should be disabled
5455 * @IWM_STA_FLG_PS: set if STA is in Power Save
5456 * @IWM_STA_FLG_INVALID: set if STA is invalid
5457 * @IWM_STA_FLG_DLP_EN: Direct Link Protocol is enabled
5458 * @IWM_STA_FLG_SET_ALL_KEYS: the current key applies to all key IDs
5459 * @IWM_STA_FLG_DRAIN_FLOW: drain flow
5460 * @IWM_STA_FLG_PAN: STA is for PAN interface
5461 * @IWM_STA_FLG_CLASS_AUTH:
5462 * @IWM_STA_FLG_CLASS_ASSOC:
5463 * @IWM_STA_FLG_CLASS_MIMO_PROT:
5464 * @IWM_STA_FLG_MAX_AGG_SIZE_MSK: maximal size for A-MPDU
5465 * @IWM_STA_FLG_AGG_MPDU_DENS_MSK: maximal MPDU density for Tx aggregation
5466 * @IWM_STA_FLG_FAT_EN_MSK: support for channel width (for Tx). This flag is
5467 *	initialised by driver and can be updated by fw upon reception of
5468 *	action frames that can change the channel width. When cleared the fw
5469 *	will send all the frames in 20MHz even when FAT channel is requested.
5470 * @IWM_STA_FLG_MIMO_EN_MSK: support for MIMO. This flag is initialised by the
5471 *	driver and can be updated by fw upon reception of action frames.
5472 * @IWM_STA_FLG_MFP_EN: Management Frame Protection
5473 */
5474enum iwm_sta_flags {
5475	IWM_STA_FLG_REDUCED_TX_PWR_CTRL	= (1 << 3),
5476	IWM_STA_FLG_REDUCED_TX_PWR_DATA	= (1 << 6),
5477
5478	IWM_STA_FLG_DISABLE_TX		= (1 << 4),
5479
5480	IWM_STA_FLG_PS			= (1 << 8),
5481	IWM_STA_FLG_DRAIN_FLOW		= (1 << 12),
5482	IWM_STA_FLG_PAN			= (1 << 13),
5483	IWM_STA_FLG_CLASS_AUTH		= (1 << 14),
5484	IWM_STA_FLG_CLASS_ASSOC		= (1 << 15),
5485	IWM_STA_FLG_RTS_MIMO_PROT	= (1 << 17),
5486
5487	IWM_STA_FLG_MAX_AGG_SIZE_SHIFT	= 19,
5488	IWM_STA_FLG_MAX_AGG_SIZE_8K	= (0 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5489	IWM_STA_FLG_MAX_AGG_SIZE_16K	= (1 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5490	IWM_STA_FLG_MAX_AGG_SIZE_32K	= (2 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5491	IWM_STA_FLG_MAX_AGG_SIZE_64K	= (3 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5492	IWM_STA_FLG_MAX_AGG_SIZE_128K	= (4 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5493	IWM_STA_FLG_MAX_AGG_SIZE_256K	= (5 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5494	IWM_STA_FLG_MAX_AGG_SIZE_512K	= (6 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5495	IWM_STA_FLG_MAX_AGG_SIZE_1024K	= (7 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5496	IWM_STA_FLG_MAX_AGG_SIZE_MSK	= (7 << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT),
5497
5498	IWM_STA_FLG_AGG_MPDU_DENS_SHIFT	= 23,
5499	IWM_STA_FLG_AGG_MPDU_DENS_2US	= (4 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT),
5500	IWM_STA_FLG_AGG_MPDU_DENS_4US	= (5 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT),
5501	IWM_STA_FLG_AGG_MPDU_DENS_8US	= (6 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT),
5502	IWM_STA_FLG_AGG_MPDU_DENS_16US	= (7 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT),
5503	IWM_STA_FLG_AGG_MPDU_DENS_MSK	= (7 << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT),
5504
5505	IWM_STA_FLG_FAT_EN_20MHZ	= (0 << 26),
5506	IWM_STA_FLG_FAT_EN_40MHZ	= (1 << 26),
5507	IWM_STA_FLG_FAT_EN_80MHZ	= (2 << 26),
5508	IWM_STA_FLG_FAT_EN_160MHZ	= (3 << 26),
5509	IWM_STA_FLG_FAT_EN_MSK		= (3 << 26),
5510
5511	IWM_STA_FLG_MIMO_EN_SISO	= (0 << 28),
5512	IWM_STA_FLG_MIMO_EN_MIMO2	= (1 << 28),
5513	IWM_STA_FLG_MIMO_EN_MIMO3	= (2 << 28),
5514	IWM_STA_FLG_MIMO_EN_MSK		= (3 << 28),
5515};
5516
5517/**
5518 * enum iwm_sta_key_flag - key flags for the ADD_STA host command
5519 * @IWM_STA_KEY_FLG_NO_ENC: no encryption
5520 * @IWM_STA_KEY_FLG_WEP: WEP encryption algorithm
5521 * @IWM_STA_KEY_FLG_CCM: CCMP encryption algorithm
5522 * @IWM_STA_KEY_FLG_TKIP: TKIP encryption algorithm
5523 * @IWM_STA_KEY_FLG_EXT: extended cipher algorithm (depends on the FW support)
5524 * @IWM_STA_KEY_FLG_CMAC: CMAC encryption algorithm
5525 * @IWM_STA_KEY_FLG_ENC_UNKNOWN: unknown encryption algorithm
5526 * @IWM_STA_KEY_FLG_EN_MSK: mask for encryption algorithmi value
5527 * @IWM_STA_KEY_FLG_WEP_KEY_MAP: wep is either a group key (0 - legacy WEP) or from
5528 *	station info array (1 - n 1X mode)
5529 * @IWM_STA_KEY_FLG_KEYID_MSK: the index of the key
5530 * @IWM_STA_KEY_NOT_VALID: key is invalid
5531 * @IWM_STA_KEY_FLG_WEP_13BYTES: set for 13 bytes WEP key
5532 * @IWM_STA_KEY_MULTICAST: set for multical key
5533 * @IWM_STA_KEY_MFP: key is used for Management Frame Protection
5534 */
5535enum iwm_sta_key_flag {
5536	IWM_STA_KEY_FLG_NO_ENC		= (0 << 0),
5537	IWM_STA_KEY_FLG_WEP		= (1 << 0),
5538	IWM_STA_KEY_FLG_CCM		= (2 << 0),
5539	IWM_STA_KEY_FLG_TKIP		= (3 << 0),
5540	IWM_STA_KEY_FLG_EXT		= (4 << 0),
5541	IWM_STA_KEY_FLG_CMAC		= (6 << 0),
5542	IWM_STA_KEY_FLG_ENC_UNKNOWN	= (7 << 0),
5543	IWM_STA_KEY_FLG_EN_MSK		= (7 << 0),
5544
5545	IWM_STA_KEY_FLG_WEP_KEY_MAP	= (1 << 3),
5546	IWM_STA_KEY_FLG_KEYID_POS	= 8,
5547	IWM_STA_KEY_FLG_KEYID_MSK	= (3 << IWM_STA_KEY_FLG_KEYID_POS),
5548	IWM_STA_KEY_NOT_VALID		= (1 << 11),
5549	IWM_STA_KEY_FLG_WEP_13BYTES	= (1 << 12),
5550	IWM_STA_KEY_MULTICAST		= (1 << 14),
5551	IWM_STA_KEY_MFP			= (1 << 15),
5552};
5553
5554/**
5555 * enum iwm_sta_modify_flag - indicate to the fw what flag are being changed
5556 * @IWM_STA_MODIFY_QUEUE_REMOVAL: this command removes a queue
5557 * @IWM_STA_MODIFY_TID_DISABLE_TX: this command modifies %tid_disable_tx
5558 * @IWM_STA_MODIFY_TX_RATE: unused
5559 * @IWM_STA_MODIFY_ADD_BA_TID: this command modifies %add_immediate_ba_tid
5560 * @IWM_STA_MODIFY_REMOVE_BA_TID: this command modifies %remove_immediate_ba_tid
5561 * @IWM_STA_MODIFY_SLEEPING_STA_TX_COUNT: this command modifies %sleep_tx_count
5562 * @IWM_STA_MODIFY_PROT_TH:
5563 * @IWM_STA_MODIFY_QUEUES: modify the queues used by this station
5564 */
5565enum iwm_sta_modify_flag {
5566	IWM_STA_MODIFY_QUEUE_REMOVAL		= (1 << 0),
5567	IWM_STA_MODIFY_TID_DISABLE_TX		= (1 << 1),
5568	IWM_STA_MODIFY_TX_RATE			= (1 << 2),
5569	IWM_STA_MODIFY_ADD_BA_TID		= (1 << 3),
5570	IWM_STA_MODIFY_REMOVE_BA_TID		= (1 << 4),
5571	IWM_STA_MODIFY_SLEEPING_STA_TX_COUNT	= (1 << 5),
5572	IWM_STA_MODIFY_PROT_TH			= (1 << 6),
5573	IWM_STA_MODIFY_QUEUES			= (1 << 7),
5574};
5575
5576#define IWM_STA_MODE_MODIFY	1
5577
5578/**
5579 * enum iwm_sta_sleep_flag - type of sleep of the station
5580 * @IWM_STA_SLEEP_STATE_AWAKE:
5581 * @IWM_STA_SLEEP_STATE_PS_POLL:
5582 * @IWM_STA_SLEEP_STATE_UAPSD:
5583 * @IWM_STA_SLEEP_STATE_MOREDATA: set more-data bit on
5584 *	(last) released frame
5585 */
5586enum iwm_sta_sleep_flag {
5587	IWM_STA_SLEEP_STATE_AWAKE	= 0,
5588	IWM_STA_SLEEP_STATE_PS_POLL	= (1 << 0),
5589	IWM_STA_SLEEP_STATE_UAPSD	= (1 << 1),
5590	IWM_STA_SLEEP_STATE_MOREDATA	= (1 << 2),
5591};
5592
5593/* STA ID and color bits definitions */
5594#define IWM_STA_ID_SEED		(0x0f)
5595#define IWM_STA_ID_POS		(0)
5596#define IWM_STA_ID_MSK		(IWM_STA_ID_SEED << IWM_STA_ID_POS)
5597
5598#define IWM_STA_COLOR_SEED	(0x7)
5599#define IWM_STA_COLOR_POS	(4)
5600#define IWM_STA_COLOR_MSK	(IWM_STA_COLOR_SEED << IWM_STA_COLOR_POS)
5601
5602#define IWM_STA_ID_N_COLOR_GET_COLOR(id_n_color) \
5603	(((id_n_color) & IWM_STA_COLOR_MSK) >> IWM_STA_COLOR_POS)
5604#define IWM_STA_ID_N_COLOR_GET_ID(id_n_color)    \
5605	(((id_n_color) & IWM_STA_ID_MSK) >> IWM_STA_ID_POS)
5606
5607#define IWM_STA_KEY_MAX_NUM (16)
5608#define IWM_STA_KEY_IDX_INVALID (0xff)
5609#define IWM_STA_KEY_MAX_DATA_KEY_NUM (4)
5610#define IWM_MAX_GLOBAL_KEYS (4)
5611#define IWM_STA_KEY_LEN_WEP40 (5)
5612#define IWM_STA_KEY_LEN_WEP104 (13)
5613
5614/**
5615 * struct iwm_mvm_keyinfo - key information
5616 * @key_flags: type %iwm_sta_key_flag
5617 * @tkip_rx_tsc_byte2: TSC[2] for key mix ph1 detection
5618 * @tkip_rx_ttak: 10-byte unicast TKIP TTAK for Rx
5619 * @key_offset: key offset in the fw's key table
5620 * @key: 16-byte unicast decryption key
5621 * @tx_secur_seq_cnt: initial RSC / PN needed for replay check
5622 * @hw_tkip_mic_rx_key: byte: MIC Rx Key - used for TKIP only
5623 * @hw_tkip_mic_tx_key: byte: MIC Tx Key - used for TKIP only
5624 */
5625struct iwm_mvm_keyinfo {
5626	uint16_t key_flags;
5627	uint8_t tkip_rx_tsc_byte2;
5628	uint8_t reserved1;
5629	uint16_t tkip_rx_ttak[5];
5630	uint8_t key_offset;
5631	uint8_t reserved2;
5632	uint8_t key[16];
5633	uint64_t tx_secur_seq_cnt;
5634	uint64_t hw_tkip_mic_rx_key;
5635	uint64_t hw_tkip_mic_tx_key;
5636} __packed;
5637
5638#define IWM_ADD_STA_STATUS_MASK		0xFF
5639#define IWM_ADD_STA_BAID_VALID_MASK	0x8000
5640#define IWM_ADD_STA_BAID_MASK		0x7F00
5641#define IWM_ADD_STA_BAID_SHIFT		8
5642
5643/**
5644 * struct iwm_mvm_add_sta_cmd_v7 - Add/modify a station in the fw's sta table.
5645 * ( REPLY_ADD_STA = 0x18 )
5646 * @add_modify: 1: modify existing, 0: add new station
5647 * @awake_acs:
5648 * @tid_disable_tx: is tid BIT(tid) enabled for Tx. Clear BIT(x) to enable
5649 *	AMPDU for tid x. Set %IWM_STA_MODIFY_TID_DISABLE_TX to change this field.
5650 * @mac_id_n_color: the Mac context this station belongs to
5651 * @addr[IEEE80211_ADDR_LEN]: station's MAC address
5652 * @sta_id: index of station in uCode's station table
5653 * @modify_mask: IWM_STA_MODIFY_*, selects which parameters to modify vs. leave
5654 *	alone. 1 - modify, 0 - don't change.
5655 * @station_flags: look at %iwm_sta_flags
5656 * @station_flags_msk: what of %station_flags have changed
5657 * @add_immediate_ba_tid: tid for which to add block-ack support (Rx)
5658 *	Set %IWM_STA_MODIFY_ADD_BA_TID to use this field, and also set
5659 *	add_immediate_ba_ssn.
5660 * @remove_immediate_ba_tid: tid for which to remove block-ack support (Rx)
5661 *	Set %IWM_STA_MODIFY_REMOVE_BA_TID to use this field
5662 * @add_immediate_ba_ssn: ssn for the Rx block-ack session. Used together with
5663 *	add_immediate_ba_tid.
5664 * @sleep_tx_count: number of packets to transmit to station even though it is
5665 *	asleep. Used to synchronise PS-poll and u-APSD responses while ucode
5666 *	keeps track of STA sleep state.
5667 * @sleep_state_flags: Look at %iwm_sta_sleep_flag.
5668 * @assoc_id: assoc_id to be sent in VHT PLCP (9-bit), for grp use 0, for AP
5669 *	mac-addr.
5670 * @beamform_flags: beam forming controls
5671 * @tfd_queue_msk: tfd queues used by this station
5672 *
5673 * The device contains an internal table of per-station information, with info
5674 * on security keys, aggregation parameters, and Tx rates for initial Tx
5675 * attempt and any retries (set by IWM_REPLY_TX_LINK_QUALITY_CMD).
5676 *
5677 * ADD_STA sets up the table entry for one station, either creating a new
5678 * entry, or modifying a pre-existing one.
5679 */
5680struct iwm_mvm_add_sta_cmd_v7 {
5681	uint8_t add_modify;
5682	uint8_t awake_acs;
5683	uint16_t tid_disable_tx;
5684	uint32_t mac_id_n_color;
5685	uint8_t addr[IEEE80211_ADDR_LEN]; /* _STA_ID_MODIFY_INFO_API_S_VER_1 */
5686	uint16_t reserved2;
5687	uint8_t sta_id;
5688	uint8_t modify_mask;
5689	uint16_t reserved3;
5690	uint32_t station_flags;
5691	uint32_t station_flags_msk;
5692	uint8_t add_immediate_ba_tid;
5693	uint8_t remove_immediate_ba_tid;
5694	uint16_t add_immediate_ba_ssn;
5695	uint16_t sleep_tx_count;
5696	uint16_t sleep_state_flags;
5697	uint16_t assoc_id;
5698	uint16_t beamform_flags;
5699	uint32_t tfd_queue_msk;
5700} __packed; /* ADD_STA_CMD_API_S_VER_7 */
5701
5702/**
5703 * struct iwm_mvm_add_sta_key_cmd - add/modify sta key
5704 * ( IWM_REPLY_ADD_STA_KEY = 0x17 )
5705 * @sta_id: index of station in uCode's station table
5706 * @key_offset: key offset in key storage
5707 * @key_flags: type %iwm_sta_key_flag
5708 * @key: key material data
5709 * @key2: key material data
5710 * @rx_secur_seq_cnt: RX security sequence counter for the key
5711 * @tkip_rx_tsc_byte2: TSC[2] for key mix ph1 detection
5712 * @tkip_rx_ttak: 10-byte unicast TKIP TTAK for Rx
5713 */
5714struct iwm_mvm_add_sta_key_cmd {
5715	uint8_t sta_id;
5716	uint8_t key_offset;
5717	uint16_t key_flags;
5718	uint8_t key[16];
5719	uint8_t key2[16];
5720	uint8_t rx_secur_seq_cnt[16];
5721	uint8_t tkip_rx_tsc_byte2;
5722	uint8_t reserved;
5723	uint16_t tkip_rx_ttak[5];
5724} __packed; /* IWM_ADD_MODIFY_STA_KEY_API_S_VER_1 */
5725
5726/**
5727 * enum iwm_mvm_add_sta_rsp_status - status in the response to ADD_STA command
5728 * @IWM_ADD_STA_SUCCESS: operation was executed successfully
5729 * @IWM_ADD_STA_STATIONS_OVERLOAD: no room left in the fw's station table
5730 * @IWM_ADD_STA_IMMEDIATE_BA_FAILURE: can't add Rx block ack session
5731 * @IWM_ADD_STA_MODIFY_NON_EXISTING_STA: driver requested to modify a station
5732 *	that doesn't exist.
5733 */
5734enum iwm_mvm_add_sta_rsp_status {
5735	IWM_ADD_STA_SUCCESS			= 0x1,
5736	IWM_ADD_STA_STATIONS_OVERLOAD		= 0x2,
5737	IWM_ADD_STA_IMMEDIATE_BA_FAILURE	= 0x4,
5738	IWM_ADD_STA_MODIFY_NON_EXISTING_STA	= 0x8,
5739};
5740
5741/**
5742 * struct iwm_mvm_rm_sta_cmd - Add / modify a station in the fw's station table
5743 * ( IWM_REMOVE_STA = 0x19 )
5744 * @sta_id: the station id of the station to be removed
5745 */
5746struct iwm_mvm_rm_sta_cmd {
5747	uint8_t sta_id;
5748	uint8_t reserved[3];
5749} __packed; /* IWM_REMOVE_STA_CMD_API_S_VER_2 */
5750
5751/**
5752 * struct iwm_mvm_mgmt_mcast_key_cmd
5753 * ( IWM_MGMT_MCAST_KEY = 0x1f )
5754 * @ctrl_flags: %iwm_sta_key_flag
5755 * @IGTK:
5756 * @K1: IGTK master key
5757 * @K2: IGTK sub key
5758 * @sta_id: station ID that support IGTK
5759 * @key_id:
5760 * @receive_seq_cnt: initial RSC/PN needed for replay check
5761 */
5762struct iwm_mvm_mgmt_mcast_key_cmd {
5763	uint32_t ctrl_flags;
5764	uint8_t IGTK[16];
5765	uint8_t K1[16];
5766	uint8_t K2[16];
5767	uint32_t key_id;
5768	uint32_t sta_id;
5769	uint64_t receive_seq_cnt;
5770} __packed; /* SEC_MGMT_MULTICAST_KEY_CMD_API_S_VER_1 */
5771
5772struct iwm_mvm_wep_key {
5773	uint8_t key_index;
5774	uint8_t key_offset;
5775	uint16_t reserved1;
5776	uint8_t key_size;
5777	uint8_t reserved2[3];
5778	uint8_t key[16];
5779} __packed;
5780
5781struct iwm_mvm_wep_key_cmd {
5782	uint32_t mac_id_n_color;
5783	uint8_t num_keys;
5784	uint8_t decryption_type;
5785	uint8_t flags;
5786	uint8_t reserved;
5787	struct iwm_mvm_wep_key wep_key[0];
5788} __packed; /* SEC_CURR_WEP_KEY_CMD_API_S_VER_2 */
5789
5790/*
5791 * END mvm/fw-api-sta.h
5792 */
5793
5794/*
5795 * BT coex
5796 */
5797
5798enum iwm_bt_coex_mode {
5799	IWM_BT_COEX_DISABLE		= 0x0,
5800	IWM_BT_COEX_NW			= 0x1,
5801	IWM_BT_COEX_BT			= 0x2,
5802	IWM_BT_COEX_WIFI		= 0x3,
5803}; /* BT_COEX_MODES_E */
5804
5805enum iwm_bt_coex_enabled_modules {
5806	IWM_BT_COEX_MPLUT_ENABLED	= (1 << 0),
5807	IWM_BT_COEX_MPLUT_BOOST_ENABLED	= (1 << 1),
5808	IWM_BT_COEX_SYNC2SCO_ENABLED	= (1 << 2),
5809	IWM_BT_COEX_CORUN_ENABLED	= (1 << 3),
5810	IWM_BT_COEX_HIGH_BAND_RET	= (1 << 4),
5811}; /* BT_COEX_MODULES_ENABLE_E_VER_1 */
5812
5813/**
5814 * struct iwm_bt_coex_cmd - bt coex configuration command
5815 * @mode: enum %iwm_bt_coex_mode
5816 * @enabled_modules: enum %iwm_bt_coex_enabled_modules
5817 *
5818 * The structure is used for the BT_COEX command.
5819 */
5820struct iwm_bt_coex_cmd {
5821	uint32_t mode;
5822	uint32_t enabled_modules;
5823} __packed; /* BT_COEX_CMD_API_S_VER_6 */
5824
5825
5826/*
5827 * Location Aware Regulatory (LAR) API - MCC updates
5828 */
5829
5830/**
5831 * struct iwm_mcc_update_cmd_v1 - Request the device to update geographic
5832 * regulatory profile according to the given MCC (Mobile Country Code).
5833 * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
5834 * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
5835 * MCC in the cmd response will be the relevant MCC in the NVM.
5836 * @mcc: given mobile country code
5837 * @source_id: the source from where we got the MCC, see iwm_mcc_source
5838 * @reserved: reserved for alignment
5839 */
5840struct iwm_mcc_update_cmd_v1 {
5841	uint16_t mcc;
5842	uint8_t source_id;
5843	uint8_t reserved;
5844} __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_1 */
5845
5846/**
5847 * struct iwm_mcc_update_cmd - Request the device to update geographic
5848 * regulatory profile according to the given MCC (Mobile Country Code).
5849 * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
5850 * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
5851 * MCC in the cmd response will be the relevant MCC in the NVM.
5852 * @mcc: given mobile country code
5853 * @source_id: the source from where we got the MCC, see iwm_mcc_source
5854 * @reserved: reserved for alignment
5855 * @key: integrity key for MCC API OEM testing
5856 * @reserved2: reserved
5857 */
5858struct iwm_mcc_update_cmd {
5859	uint16_t mcc;
5860	uint8_t source_id;
5861	uint8_t reserved;
5862	uint32_t key;
5863	uint32_t reserved2[5];
5864} __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_2 */
5865
5866/**
5867 * iwm_mcc_update_resp_v1  - response to MCC_UPDATE_CMD.
5868 * Contains the new channel control profile map, if changed, and the new MCC
5869 * (mobile country code).
5870 * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
5871 * @status: see &enum iwm_mcc_update_status
5872 * @mcc: the new applied MCC
5873 * @cap: capabilities for all channels which matches the MCC
5874 * @source_id: the MCC source, see iwm_mcc_source
5875 * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
5876 *		channels, depending on platform)
5877 * @channels: channel control data map, DWORD for each channel. Only the first
5878 *	16bits are used.
5879 */
5880struct iwm_mcc_update_resp_v1  {
5881	uint32_t status;
5882	uint16_t mcc;
5883	uint8_t cap;
5884	uint8_t source_id;
5885	uint32_t n_channels;
5886	uint32_t channels[0];
5887} __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_1 */
5888
5889/**
5890 * iwm_mcc_update_resp - response to MCC_UPDATE_CMD.
5891 * Contains the new channel control profile map, if changed, and the new MCC
5892 * (mobile country code).
5893 * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
5894 * @status: see &enum iwm_mcc_update_status
5895 * @mcc: the new applied MCC
5896 * @cap: capabilities for all channels which matches the MCC
5897 * @source_id: the MCC source, see iwm_mcc_source
5898 * @time: time elapsed from the MCC test start (in 30 seconds TU)
5899 * @reserved: reserved.
5900 * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
5901 *		channels, depending on platform)
5902 * @channels: channel control data map, DWORD for each channel. Only the first
5903 *	16bits are used.
5904 */
5905struct iwm_mcc_update_resp {
5906	uint32_t status;
5907	uint16_t mcc;
5908	uint8_t cap;
5909	uint8_t source_id;
5910	uint16_t time;
5911	uint16_t reserved;
5912	uint32_t n_channels;
5913	uint32_t channels[0];
5914} __packed; /* LAR_UPDATE_MCC_CMD_RESP_S_VER_2 */
5915
5916/**
5917 * struct iwm_mcc_chub_notif - chub notifies of mcc change
5918 * (MCC_CHUB_UPDATE_CMD = 0xc9)
5919 * The Chub (Communication Hub, CommsHUB) is a HW component that connects to
5920 * the cellular and connectivity cores that gets updates of the mcc, and
5921 * notifies the ucode directly of any mcc change.
5922 * The ucode requests the driver to request the device to update geographic
5923 * regulatory  profile according to the given MCC (Mobile Country Code).
5924 * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
5925 * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
5926 * MCC in the cmd response will be the relevant MCC in the NVM.
5927 * @mcc: given mobile country code
5928 * @source_id: identity of the change originator, see iwm_mcc_source
5929 * @reserved1: reserved for alignment
5930 */
5931struct iwm_mcc_chub_notif {
5932	uint16_t mcc;
5933	uint8_t source_id;
5934	uint8_t reserved1;
5935} __packed; /* LAR_MCC_NOTIFY_S */
5936
5937enum iwm_mcc_update_status {
5938	IWM_MCC_RESP_NEW_CHAN_PROFILE,
5939	IWM_MCC_RESP_SAME_CHAN_PROFILE,
5940	IWM_MCC_RESP_INVALID,
5941	IWM_MCC_RESP_NVM_DISABLED,
5942	IWM_MCC_RESP_ILLEGAL,
5943	IWM_MCC_RESP_LOW_PRIORITY,
5944	IWM_MCC_RESP_TEST_MODE_ACTIVE,
5945	IWM_MCC_RESP_TEST_MODE_NOT_ACTIVE,
5946	IWM_MCC_RESP_TEST_MODE_DENIAL_OF_SERVICE,
5947};
5948
5949enum iwm_mcc_source {
5950	IWM_MCC_SOURCE_OLD_FW = 0,
5951	IWM_MCC_SOURCE_ME = 1,
5952	IWM_MCC_SOURCE_BIOS = 2,
5953	IWM_MCC_SOURCE_3G_LTE_HOST = 3,
5954	IWM_MCC_SOURCE_3G_LTE_DEVICE = 4,
5955	IWM_MCC_SOURCE_WIFI = 5,
5956	IWM_MCC_SOURCE_RESERVED = 6,
5957	IWM_MCC_SOURCE_DEFAULT = 7,
5958	IWM_MCC_SOURCE_UNINITIALIZED = 8,
5959	IWM_MCC_SOURCE_MCC_API = 9,
5960	IWM_MCC_SOURCE_GET_CURRENT = 0x10,
5961	IWM_MCC_SOURCE_GETTING_MCC_TEST_MODE = 0x11,
5962};
5963
5964/*
5965 * Some cherry-picked definitions
5966 */
5967
5968#define IWM_FRAME_LIMIT	64
5969
5970/*
5971 * From Linux commit ab02165ccec4c78162501acedeef1a768acdb811:
5972 *   As the firmware is slowly running out of command IDs and grouping of
5973 *   commands is desirable anyway, the firmware is extending the command
5974 *   header from 4 bytes to 8 bytes to introduce a group (in place of the
5975 *   former flags field, since that's always 0 on commands and thus can
5976 *   be easily used to distinguish between the two).
5977 *
5978 * These functions retrieve specific information from the id field in
5979 * the iwm_host_cmd struct which contains the command id, the group id,
5980 * and the version of the command.
5981*/
5982static inline uint8_t
5983iwm_cmd_opcode(uint32_t cmdid)
5984{
5985	return cmdid & 0xff;
5986}
5987
5988static inline uint8_t
5989iwm_cmd_groupid(uint32_t cmdid)
5990{
5991	return ((cmdid & 0Xff00) >> 8);
5992}
5993
5994static inline uint8_t
5995iwm_cmd_version(uint32_t cmdid)
5996{
5997	return ((cmdid & 0xff0000) >> 16);
5998}
5999
6000static inline uint32_t
6001iwm_cmd_id(uint8_t opcode, uint8_t groupid, uint8_t version)
6002{
6003	return opcode + (groupid << 8) + (version << 16);
6004}
6005
6006/* make uint16_t wide id out of uint8_t group and opcode */
6007#define IWM_WIDE_ID(grp, opcode) ((grp << 8) | opcode)
6008
6009/* due to the conversion, this group is special */
6010#define IWM_ALWAYS_LONG_GROUP	1
6011
6012struct iwm_cmd_header {
6013	uint8_t code;
6014	uint8_t flags;
6015	uint8_t idx;
6016	uint8_t qid;
6017} __packed;
6018
6019struct iwm_cmd_header_wide {
6020	uint8_t opcode;
6021	uint8_t group_id;
6022	uint8_t idx;
6023	uint8_t qid;
6024	uint16_t length;
6025	uint8_t reserved;
6026	uint8_t version;
6027} __packed;
6028
6029enum iwm_power_scheme {
6030	IWM_POWER_SCHEME_CAM = 1,
6031	IWM_POWER_SCHEME_BPS,
6032	IWM_POWER_SCHEME_LP
6033};
6034
6035#define IWM_DEF_CMD_PAYLOAD_SIZE 320
6036#define IWM_MAX_CMD_PAYLOAD_SIZE ((4096 - 4) - sizeof(struct iwm_cmd_header))
6037#define IWM_CMD_FAILED_MSK 0x40
6038
6039/**
6040 * struct iwm_device_cmd
6041 *
6042 * For allocation of the command and tx queues, this establishes the overall
6043 * size of the largest command we send to uCode, except for commands that
6044 * aren't fully copied and use other TFD space.
6045 */
6046struct iwm_device_cmd {
6047	union {
6048		struct {
6049			struct iwm_cmd_header hdr;
6050			uint8_t data[IWM_DEF_CMD_PAYLOAD_SIZE];
6051		};
6052		struct {
6053			struct iwm_cmd_header_wide hdr_wide;
6054			uint8_t data_wide[IWM_DEF_CMD_PAYLOAD_SIZE -
6055					sizeof(struct iwm_cmd_header_wide) +
6056					sizeof(struct iwm_cmd_header)];
6057		};
6058	};
6059} __packed;
6060
6061struct iwm_rx_packet {
6062	/*
6063	 * The first 4 bytes of the RX frame header contain both the RX frame
6064	 * size and some flags.
6065	 * Bit fields:
6066	 * 31:    flag flush RB request
6067	 * 30:    flag ignore TC (terminal counter) request
6068	 * 29:    flag fast IRQ request
6069	 * 28-14: Reserved
6070	 * 13-00: RX frame size
6071	 */
6072	uint32_t len_n_flags;
6073	struct iwm_cmd_header hdr;
6074	uint8_t data[];
6075} __packed;
6076
6077#define	IWM_FH_RSCSR_FRAME_SIZE_MSK	0x00003fff
6078
6079static inline uint32_t
6080iwm_rx_packet_len(const struct iwm_rx_packet *pkt)
6081{
6082
6083	return le32toh(pkt->len_n_flags) & IWM_FH_RSCSR_FRAME_SIZE_MSK;
6084}
6085
6086static inline uint32_t
6087iwm_rx_packet_payload_len(const struct iwm_rx_packet *pkt)
6088{
6089
6090	return iwm_rx_packet_len(pkt) - sizeof(pkt->hdr);
6091}
6092
6093
6094#define IWM_MIN_DBM	-100
6095#define IWM_MAX_DBM	-33	/* realistic guess */
6096
6097#define IWM_READ(sc, reg)						\
6098	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
6099
6100#define IWM_WRITE(sc, reg, val)						\
6101	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
6102
6103#define IWM_WRITE_1(sc, reg, val)					\
6104	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
6105
6106#define IWM_SETBITS(sc, reg, mask)					\
6107	IWM_WRITE(sc, reg, IWM_READ(sc, reg) | (mask))
6108
6109#define IWM_CLRBITS(sc, reg, mask)					\
6110	IWM_WRITE(sc, reg, IWM_READ(sc, reg) & ~(mask))
6111
6112#define IWM_BARRIER_WRITE(sc)						\
6113	bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz,	\
6114	    BUS_SPACE_BARRIER_WRITE)
6115
6116#define IWM_BARRIER_READ_WRITE(sc)					\
6117	bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz,	\
6118	    BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
6119
6120#endif	/* __IF_IWM_REG_H__ */
6121