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