xref: /openbsd/sys/dev/pci/if_iwxvar.h (revision d415bd75)
1 /*	$OpenBSD: if_iwxvar.h,v 1.41 2023/03/06 11:53:24 stsp Exp $	*/
2 
3 /*
4  * Copyright (c) 2014 genua mbh <info@genua.de>
5  * Copyright (c) 2014 Fixup Software Ltd.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*-
21  * Based on BSD-licensed source modules in the Linux iwlwifi driver,
22  * which were used as the reference documentation for this implementation.
23  *
24  ******************************************************************************
25  *
26  * This file is provided under a dual BSD/GPLv2 license.  When using or
27  * redistributing this file, you may do so under either license.
28  *
29  * GPL LICENSE SUMMARY
30  *
31  * Copyright(c) 2017 Intel Deutschland GmbH
32  * Copyright(c) 2018 - 2019 Intel Corporation
33  *
34  * This program is free software; you can redistribute it and/or modify
35  * it under the terms of version 2 of the GNU General Public License as
36  * published by the Free Software Foundation.
37  *
38  * This program is distributed in the hope that it will be useful, but
39  * WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
41  * General Public License for more details.
42  *
43  * BSD LICENSE
44  *
45  * Copyright(c) 2017 Intel Deutschland GmbH
46  * Copyright(c) 2018 - 2019 Intel Corporation
47  * All rights reserved.
48  *
49  * Redistribution and use in source and binary forms, with or without
50  * modification, are permitted provided that the following conditions
51  * are met:
52  *
53  *  * Redistributions of source code must retain the above copyright
54  *    notice, this list of conditions and the following disclaimer.
55  *  * Redistributions in binary form must reproduce the above copyright
56  *    notice, this list of conditions and the following disclaimer in
57  *    the documentation and/or other materials provided with the
58  *    distribution.
59  *  * Neither the name Intel Corporation nor the names of its
60  *    contributors may be used to endorse or promote products derived
61  *    from this software without specific prior written permission.
62  *
63  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
64  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
65  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
66  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
67  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
68  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
69  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
70  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
71  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
72  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
73  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74  *
75  *****************************************************************************
76  */
77 
78 /*-
79  * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
80  *
81  * Permission to use, copy, modify, and distribute this software for any
82  * purpose with or without fee is hereby granted, provided that the above
83  * copyright notice and this permission notice appear in all copies.
84  *
85  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
86  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
87  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
88  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
89  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
90  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
91  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
92  */
93 
94 struct iwx_rx_radiotap_header {
95 	struct ieee80211_radiotap_header wr_ihdr;
96 	uint64_t	wr_tsft;
97 	uint8_t		wr_flags;
98 	uint8_t		wr_rate;
99 	uint16_t	wr_chan_freq;
100 	uint16_t	wr_chan_flags;
101 	int8_t		wr_dbm_antsignal;
102 	int8_t		wr_dbm_antnoise;
103 } __packed;
104 
105 #define IWX_RX_RADIOTAP_PRESENT						\
106 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
107 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
108 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
109 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
110 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
111 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
112 
113 struct iwx_tx_radiotap_header {
114 	struct ieee80211_radiotap_header wt_ihdr;
115 	uint8_t		wt_flags;
116 	uint8_t		wt_rate;
117 	uint16_t	wt_chan_freq;
118 	uint16_t	wt_chan_flags;
119 } __packed;
120 
121 #define IWX_TX_RADIOTAP_PRESENT						\
122 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
123 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
124 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
125 
126 #define IWX_UCODE_SECT_MAX 57
127 
128 /*
129  * fw_status is used to determine if we've already parsed the firmware file
130  *
131  * In addition to the following, status < 0 ==> -error
132  */
133 #define IWX_FW_STATUS_NONE		0
134 #define IWX_FW_STATUS_INPROGRESS	1
135 #define IWX_FW_STATUS_DONE		2
136 
137 enum iwx_ucode_type {
138 	IWX_UCODE_TYPE_REGULAR,
139 	IWX_UCODE_TYPE_INIT,
140 	IWX_UCODE_TYPE_WOW,
141 	IWX_UCODE_TYPE_REGULAR_USNIFFER,
142 	IWX_UCODE_TYPE_MAX
143 };
144 
145 struct iwx_fw_info {
146 	void *fw_rawdata;
147 	size_t fw_rawsize;
148 	int fw_status;
149 
150 	struct iwx_fw_sects {
151 		struct iwx_fw_onesect {
152 			void *fws_data;
153 			uint32_t fws_len;
154 			uint32_t fws_devoff;
155 		} fw_sect[IWX_UCODE_SECT_MAX];
156 		size_t fw_totlen;
157 		int fw_count;
158 	} fw_sects[IWX_UCODE_TYPE_MAX];
159 
160 	/* FW debug data parsed for driver usage */
161 	int dbg_dest_tlv_init;
162 	uint8_t *dbg_dest_ver;
163 	uint8_t n_dest_reg;
164 	struct iwx_fw_dbg_dest_tlv_v1 *dbg_dest_tlv_v1;
165 
166 	struct iwx_fw_dbg_conf_tlv *dbg_conf_tlv[IWX_FW_DBG_CONF_MAX];
167 	size_t dbg_conf_tlv_len[IWX_FW_DBG_CONF_MAX];
168 	struct iwx_fw_dbg_trigger_tlv *dbg_trigger_tlv[IWX_FW_DBG_TRIGGER_MAX];
169 	size_t dbg_trigger_tlv_len[IWX_FW_DBG_TRIGGER_MAX];
170 	struct iwx_fw_dbg_mem_seg_tlv *dbg_mem_tlv;
171 	size_t n_mem_tlv;
172 
173 	/* Copy of firmware image loader found in file. */
174 	uint8_t *iml;
175 	size_t iml_len;
176 };
177 
178 struct iwx_nvm_data {
179 	int n_hw_addrs;
180 	uint8_t hw_addr[ETHER_ADDR_LEN];
181 
182 	int sku_cap_band_24GHz_enable;
183 	int sku_cap_band_52GHz_enable;
184 	int sku_cap_11n_enable;
185 	int sku_cap_11ac_enable;
186 	int sku_cap_11ax_enable;
187 	int sku_cap_amt_enable;
188 	int sku_cap_ipan_enable;
189 	int sku_cap_mimo_disable;
190 	int lar_enabled;
191 
192 	uint8_t valid_tx_ant, valid_rx_ant;
193 
194 	uint16_t nvm_version;
195 };
196 
197 /* max bufs per tfd the driver will use */
198 #define IWX_MAX_CMD_TBS_PER_TFD 2
199 
200 struct iwx_host_cmd {
201 	const void *data[IWX_MAX_CMD_TBS_PER_TFD];
202 	struct iwx_rx_packet *resp_pkt;
203 	size_t resp_pkt_len;
204 	unsigned long _rx_page_addr;
205 	uint32_t _rx_page_order;
206 	int handler_status;
207 
208 	uint32_t flags;
209 	uint16_t len[IWX_MAX_CMD_TBS_PER_TFD];
210 	uint8_t dataflags[IWX_MAX_CMD_TBS_PER_TFD];
211 	uint32_t id;
212 };
213 
214 /*
215  * DMA glue is from iwn
216  */
217 
218 struct iwx_dma_info {
219 	bus_dma_tag_t		tag;
220 	bus_dmamap_t		map;
221 	bus_dma_segment_t	seg;
222 	bus_addr_t		paddr;
223 	void 			*vaddr;
224 	bus_size_t		size;
225 };
226 
227 #define IWX_TX_RING_COUNT	IWX_DEFAULT_QUEUE_SIZE
228 #define IWX_TX_RING_LOMARK	192
229 #define IWX_TX_RING_HIMARK	224
230 
231 struct iwx_tx_data {
232 	bus_dmamap_t	map;
233 	bus_addr_t	cmd_paddr;
234 	struct mbuf	*m;
235 	struct iwx_node *in;
236 	int flags;
237 #define IWX_TXDATA_FLAG_CMD_IS_NARROW	0x01
238 };
239 
240 struct iwx_tx_ring {
241 	struct iwx_dma_info	desc_dma;
242 	struct iwx_dma_info	cmd_dma;
243 	struct iwx_dma_info	bc_tbl;
244 	struct iwx_tfh_tfd	*desc;
245 	struct iwx_device_cmd	*cmd;
246 	struct iwx_tx_data	data[IWX_TX_RING_COUNT];
247 	int			qid;
248 	int			queued;
249 	int			cur;
250 	int			cur_hw;
251 	int			tail;
252 	int			tail_hw;
253 	int			tid;
254 };
255 
256 #define IWX_RX_MQ_RING_COUNT	512
257 /* Linux driver optionally uses 8k buffer */
258 #define IWX_RBUF_SIZE		4096
259 
260 struct iwx_rx_data {
261 	struct mbuf	*m;
262 	bus_dmamap_t	map;
263 };
264 
265 struct iwx_rx_ring {
266 	struct iwx_dma_info	free_desc_dma;
267 	struct iwx_dma_info	stat_dma;
268 	struct iwx_dma_info	used_desc_dma;
269 	void			*desc;
270 	struct iwx_rb_status	*stat;
271 	struct iwx_rx_data	data[IWX_RX_MQ_RING_COUNT];
272 	int			cur;
273 };
274 
275 #define IWX_FLAG_USE_ICT	0x01	/* using Interrupt Cause Table */
276 #define IWX_FLAG_RFKILL		0x02	/* radio kill switch is set */
277 #define IWX_FLAG_SCANNING	0x04	/* scan in progress */
278 #define IWX_FLAG_MAC_ACTIVE	0x08	/* MAC context added to firmware */
279 #define IWX_FLAG_BINDING_ACTIVE	0x10	/* MAC->PHY binding added to firmware */
280 #define IWX_FLAG_STA_ACTIVE	0x20	/* AP added to firmware station table */
281 #define IWX_FLAG_TE_ACTIVE	0x40	/* time event is scheduled */
282 #define IWX_FLAG_HW_ERR		0x80	/* hardware error occurred */
283 #define IWX_FLAG_SHUTDOWN	0x100	/* shutting down; new tasks forbidden */
284 #define IWX_FLAG_BGSCAN		0x200	/* background scan in progress */
285 #define IWX_FLAG_TXFLUSH	0x400	/* Tx queue flushing in progress */
286 
287 struct iwx_ucode_status {
288 	uint32_t uc_lmac_error_event_table[2];
289 	uint32_t uc_umac_error_event_table;
290 	uint32_t uc_log_event_table;
291 	unsigned int error_event_table_tlv_status;
292 
293 	int uc_ok;
294 	int uc_intr;
295 };
296 
297 #define IWX_ERROR_EVENT_TABLE_LMAC1	(1 << 0)
298 #define IWX_ERROR_EVENT_TABLE_LMAC2	(1 << 1)
299 #define IWX_ERROR_EVENT_TABLE_UMAC	(1 << 2)
300 
301 #define IWX_CMD_RESP_MAX PAGE_SIZE
302 
303 /* lower blocks contain EEPROM image and calibration data */
304 #define IWX_OTP_LOW_IMAGE_SIZE_FAMILY_7000 	16384
305 #define IWX_OTP_LOW_IMAGE_SIZE_FAMILY_8000	32768
306 
307 #define IWX_TE_SESSION_PROTECTION_MAX_TIME_MS 1000
308 #define IWX_TE_SESSION_PROTECTION_MIN_TIME_MS 400
309 
310 enum IWX_CMD_MODE {
311 	IWX_CMD_ASYNC		= (1 << 0),
312 	IWX_CMD_WANT_RESP	= (1 << 1),
313 	IWX_CMD_SEND_IN_RFKILL	= (1 << 2),
314 };
315 enum iwx_hcmd_dataflag {
316 	IWX_HCMD_DFL_NOCOPY     = (1 << 0),
317 	IWX_HCMD_DFL_DUP        = (1 << 1),
318 };
319 
320 #define IWX_NUM_PAPD_CH_GROUPS	9
321 #define IWX_NUM_TXP_CH_GROUPS	9
322 
323 struct iwx_phy_ctxt {
324 	uint16_t id;
325 	uint16_t color;
326 	uint32_t ref;
327 	struct ieee80211_channel *channel;
328 	uint8_t sco; /* 40 MHz secondary channel offset */
329 	uint8_t vht_chan_width;
330 };
331 
332 struct iwx_bf_data {
333 	int bf_enabled;		/* filtering	*/
334 	int ba_enabled;		/* abort	*/
335 	int ave_beacon_signal;
336 	int last_cqm_event;
337 };
338 
339 /**
340  * struct iwx_self_init_dram - dram data used by self init process
341  * @fw: lmac and umac dram data
342  * @lmac_cnt: number of lmac sections in fw image
343  * @umac_cnt: number of umac sections in fw image
344  * @paging: paging dram data
345  * @paging_cnt: number of paging sections needed by fw image
346  */
347 struct iwx_self_init_dram {
348 	struct iwx_dma_info *fw;
349 	int lmac_cnt;
350 	int umac_cnt;
351 	struct iwx_dma_info *paging;
352 	int paging_cnt;
353 };
354 
355 /**
356  * struct iwx_reorder_buffer - per ra/tid/queue reorder buffer
357  * @head_sn: reorder window head sn
358  * @num_stored: number of mpdus stored in the buffer
359  * @buf_size: the reorder buffer size as set by the last addba request
360  * @queue: queue of this reorder buffer
361  * @last_amsdu: track last ASMDU SN for duplication detection
362  * @last_sub_index: track ASMDU sub frame index for duplication detection
363  * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU
364  *	it is the time of last received sub-frame
365  * @removed: prevent timer re-arming
366  * @valid: reordering is valid for this queue
367  * @consec_oldsn_drops: consecutive drops due to old SN
368  * @consec_oldsn_ampdu_gp2: A-MPDU GP2 timestamp to track
369  *	when to apply old SN consecutive drop workaround
370  * @consec_oldsn_prev_drop: track whether or not an MPDU
371  *	that was single/part of the previous A-MPDU was
372  *	dropped due to old SN
373  */
374 struct iwx_reorder_buffer {
375 	uint16_t head_sn;
376 	uint16_t num_stored;
377 	uint16_t buf_size;
378 	uint16_t last_amsdu;
379 	uint8_t last_sub_index;
380 	struct timeout reorder_timer;
381 	int removed;
382 	int valid;
383 	unsigned int consec_oldsn_drops;
384 	uint32_t consec_oldsn_ampdu_gp2;
385 	unsigned int consec_oldsn_prev_drop;
386 #define IWX_AMPDU_CONSEC_DROPS_DELBA	10
387 };
388 
389 /**
390  * struct iwx_reorder_buf_entry - reorder buffer entry per frame sequence number
391  * @frames: list of mbufs stored (A-MSDU subframes share a sequence number)
392  * @reorder_time: time the packet was stored in the reorder buffer
393  */
394 struct iwx_reorder_buf_entry {
395 	struct mbuf_list frames;
396 	struct timeval reorder_time;
397 	uint32_t rx_pkt_status;
398 	int chanidx;
399 	int is_shortpre;
400 	uint32_t rate_n_flags;
401 	uint32_t device_timestamp;
402 	struct ieee80211_rxinfo rxi;
403 };
404 
405 /**
406  * struct iwx_rxba_data - BA session data
407  * @sta_id: station id
408  * @tid: tid of the session
409  * @baid: baid of the session
410  * @timeout: the timeout set in the addba request
411  * @entries_per_queue: # of buffers per queue
412  * @last_rx: last rx timestamp, updated only if timeout passed from last update
413  * @session_timer: timer to check if BA session expired, runs at 2 * timeout
414  * @sc: softc pointer, needed for timer context
415  * @reorder_buf: reorder buffer
416  * @reorder_buf_data: buffered frames, one entry per sequence number
417  */
418 struct iwx_rxba_data {
419 	uint8_t sta_id;
420 	uint8_t tid;
421 	uint8_t baid;
422 	uint16_t timeout;
423 	uint16_t entries_per_queue;
424 	struct timeval last_rx;
425 	struct timeout session_timer;
426 	struct iwx_softc *sc;
427 	struct iwx_reorder_buffer reorder_buf;
428 	struct iwx_reorder_buf_entry entries[IEEE80211_BA_MAX_WINSZ];
429 };
430 
431 static inline struct iwx_rxba_data *
432 iwx_rxba_data_from_reorder_buf(struct iwx_reorder_buffer *buf)
433 {
434 	return (void *)((uint8_t *)buf -
435 			offsetof(struct iwx_rxba_data, reorder_buf));
436 }
437 
438 /**
439  * struct iwx_rxq_dup_data - per station per rx queue data
440  * @last_seq: last sequence per tid for duplicate packet detection
441  * @last_sub_frame: last subframe packet
442  */
443 struct iwx_rxq_dup_data {
444 	uint16_t last_seq[IWX_MAX_TID_COUNT + 1];
445 	uint8_t last_sub_frame[IWX_MAX_TID_COUNT + 1];
446 };
447 
448 struct iwx_setkey_task_arg {
449 	int sta_id;
450 	struct ieee80211_node *ni;
451 	struct ieee80211_key *k;
452 };
453 
454 struct iwx_ba_task_data {
455 	uint32_t		start_tidmask;
456 	uint32_t		stop_tidmask;
457 };
458 
459 
460 /*
461  * Device configuration parameters which cannot be detected based on
462  * PCI vendor/product ID alone.
463  */
464 struct iwx_device_cfg {
465 	const char *fw_name;
466 	const char *pnvm_name;
467 	int 	    tx_with_siso_diversity;
468 	int 	    uhb_supported;
469 	int 	    xtal_latency;
470 	int 	    low_latency_xtal;
471 };
472 
473 /* Firmware listed here must be available in fw_update(8). */
474 #define IWX_CC_A_FW	    	"iwx-cc-a0-77"
475 #define IWX_TY_A_GF_A_FW	"iwx-ty-a0-gf-a0-77"
476 #define IWX_TY_A_GF_A_PNVM	"iwx-ty-a0-gf-a0.pnvm"
477 #define IWX_QU_B_HR_B_FW	"iwx-Qu-b0-hr-b0-77"
478 #define IWX_QU_B_JF_B_FW	"iwx-Qu-b0-jf-b0-77"
479 #define IWX_QU_C_HR_B_FW	"iwx-Qu-c0-hr-b0-77"
480 #define IWX_QU_C_JF_B_FW	"iwx-Qu-c0-jf-b0-77"
481 #define IWX_QUZ_A_HR_B_FW	"iwx-QuZ-a0-hr-b0-77"
482 #define IWX_QUZ_A_JF_B_FW	"iwx-QuZ-a0-jf-b0-77"
483 #define IWX_SO_A_GF_A_FW	"iwx-so-a0-gf-a0-77"
484 #define IWX_SO_A_GF_A_PNVM	"iwx-so-a0-gf-a0.pnvm"
485 #define IWX_SO_A_GF4_A_FW	"iwx-so-a0-gf4-a0-77"
486 #define IWX_SO_A_GF4_A_PNVM	"iwx-so-a0-gf4-a0.pnvm"
487 #define IWX_SO_A_HR_B_FW	"iwx-so-a0-hr-b0-77"
488 #define IWX_SO_A_JF_B_FW	"iwx-so-a0-jf-b0-77"
489 
490 const struct iwx_device_cfg iwx_9560_quz_a0_jf_b0_cfg = {
491 	.fw_name = IWX_QUZ_A_JF_B_FW,
492 };
493 
494 const struct iwx_device_cfg iwx_9560_qu_c0_jf_b0_cfg = {
495 	.fw_name = IWX_QU_C_JF_B_FW,
496 };
497 
498 const struct iwx_device_cfg iwx_qu_b0_hr1_b0 = {
499 	.fw_name = IWX_QU_B_HR_B_FW,
500 	.tx_with_siso_diversity = true,
501 };
502 
503 const struct iwx_device_cfg iwx_qu_b0_hr_b0 = {
504 	.fw_name = IWX_QU_B_HR_B_FW,
505 };
506 
507 const struct iwx_device_cfg iwx_ax201_cfg_qu_hr = {
508 	.fw_name = IWX_QU_B_HR_B_FW,
509 };
510 
511 const struct iwx_device_cfg iwx_qu_c0_hr1_b0 = {
512 	.fw_name = IWX_QU_C_HR_B_FW,
513 	.tx_with_siso_diversity = true,
514 };
515 
516 const struct iwx_device_cfg iwx_qu_c0_hr_b0 = {
517 	.fw_name = IWX_QU_C_HR_B_FW,
518 };
519 
520 const struct iwx_device_cfg iwx_ax201_cfg_qu_c0_hr_b0 = {
521 	.fw_name = IWX_QU_C_HR_B_FW,
522 };
523 
524 const struct iwx_device_cfg iwx_quz_a0_hr1_b0 = {
525 	.fw_name = IWX_QUZ_A_HR_B_FW,
526 };
527 
528 const struct iwx_device_cfg iwx_ax201_cfg_quz_hr = {
529 	.fw_name = IWX_QUZ_A_HR_B_FW,
530 };
531 
532 const struct iwx_device_cfg iwx_cfg_so_a0_hr_b0 = {
533 	.fw_name = IWX_SO_A_HR_B_FW,
534 };
535 
536 const struct iwx_device_cfg iwx_cfg_quz_a0_hr_b0 = {
537 	.fw_name = IWX_QUZ_A_HR_B_FW,
538 };
539 
540 const struct iwx_device_cfg iwx_2ax_cfg_so_gf_a0 = {
541 	.fw_name = IWX_SO_A_GF_A_FW,
542 	.pnvm_name = IWX_SO_A_GF_A_PNVM,
543 	.uhb_supported = 1,
544 };
545 
546 const struct iwx_device_cfg iwx_2ax_cfg_so_gf_a0_long = {
547 	.fw_name = IWX_SO_A_GF_A_FW,
548 	.pnvm_name = IWX_SO_A_GF_A_PNVM,
549 	.uhb_supported = 1,
550 	.xtal_latency = 12000,
551 	.low_latency_xtal = 1,
552 };
553 
554 const struct iwx_device_cfg iwx_2ax_cfg_so_gf4_a0 = {
555 	.fw_name = IWX_SO_A_GF4_A_FW,
556 	.pnvm_name = IWX_SO_A_GF4_A_PNVM,
557 	.uhb_supported = 1,
558 	.xtal_latency = 12000,
559 	.low_latency_xtal = 1,
560 };
561 
562 const struct iwx_device_cfg iwx_2ax_cfg_so_gf4_a0_long = {
563 	.fw_name = IWX_SO_A_GF4_A_FW,
564 	.pnvm_name = IWX_SO_A_GF4_A_PNVM,
565 	.uhb_supported = 1,
566 };
567 
568 const struct iwx_device_cfg iwx_2ax_cfg_ty_gf_a0 = {
569 	.fw_name = IWX_TY_A_GF_A_FW,
570 	.pnvm_name = IWX_TY_A_GF_A_PNVM,
571 };
572 
573 const struct iwx_device_cfg iwx_2ax_cfg_so_jf_b0 = {
574 	.fw_name = IWX_SO_A_JF_B_FW,
575 };
576 
577 #define IWX_CFG_ANY (~0)
578 
579 #define IWX_CFG_MAC_TYPE_QU		0x33
580 #define IWX_CFG_MAC_TYPE_QUZ		0x35
581 #define IWX_CFG_MAC_TYPE_QNJ		0x36
582 #define IWX_CFG_MAC_TYPE_SO		0x37
583 #define IWX_CFG_MAC_TYPE_SNJ		0x42
584 #define IWX_CFG_MAC_TYPE_SOF		0x43
585 #define IWX_CFG_MAC_TYPE_MA		0x44
586 #define IWX_CFG_MAC_TYPE_BZ		0x46
587 #define IWX_CFG_MAC_TYPE_GL		0x47
588 
589 #define IWX_CFG_RF_TYPE_JF2		0x105
590 #define IWX_CFG_RF_TYPE_JF1		0x108
591 #define IWX_CFG_RF_TYPE_HR2		0x10a
592 #define IWX_CFG_RF_TYPE_HR1		0x10c
593 #define IWX_CFG_RF_TYPE_GF		0x10d
594 #define IWX_CFG_RF_TYPE_MR		0x110
595 #define IWX_CFG_RF_TYPE_MS		0x111
596 #define IWX_CFG_RF_TYPE_FM		0x112
597 
598 #define IWX_CFG_RF_ID_JF		0x3
599 #define IWX_CFG_RF_ID_JF1		0x6
600 #define IWX_CFG_RF_ID_JF1_DIV		0xa
601 
602 #define IWX_CFG_NO_160			0x1
603 #define IWX_CFG_160			0x0
604 
605 #define IWX_CFG_CORES_BT		0x0
606 
607 #define IWX_CFG_NO_CDB			0x0
608 #define IWX_CFG_CDB			0x1
609 
610 #define IWX_SUBDEVICE_RF_ID(subdevice)	((uint16_t)((subdevice) & 0x00f0) >> 4)
611 #define IWX_SUBDEVICE_NO_160(subdevice)	((uint16_t)((subdevice) & 0x0200) >> 9)
612 #define IWX_SUBDEVICE_CORES(subdevice)	((uint16_t)((subdevice) & 0x1c00) >> 10)
613 
614 struct iwx_softc {
615 	struct device sc_dev;
616 	struct ieee80211com sc_ic;
617 	int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int);
618 	int sc_newstate_pending;
619 	int attached;
620 
621 	struct task		init_task; /* NB: not reference-counted */
622 	struct refcnt		task_refs;
623 	struct task		newstate_task;
624 	enum ieee80211_state	ns_nstate;
625 	int			ns_arg;
626 
627 	/* Task for firmware BlockAck setup/teardown and its arguments. */
628 	struct task		ba_task;
629 	struct iwx_ba_task_data	ba_rx;
630 	struct iwx_ba_task_data	ba_tx;
631 
632 	/* Task for setting encryption keys and its arguments. */
633 	struct task		setkey_task;
634 	/*
635 	 * At present we need to process at most two keys at once:
636 	 * Our pairwise key and a group key.
637 	 * When hostap mode is implemented this array needs to grow or
638 	 * it might become a bottleneck for associations that occur at
639 	 * roughly the same time.
640 	 */
641 	struct iwx_setkey_task_arg setkey_arg[2];
642 	int setkey_cur;
643 	int setkey_tail;
644 	int setkey_nkeys;
645 
646 	/* Task for ERP/HT prot/slot-time/EDCA updates. */
647 	struct task		mac_ctxt_task;
648 
649 	/* Task for HT 20/40 MHz channel width updates. */
650 	struct task		phy_ctxt_task;
651 
652 	bus_space_tag_t sc_st;
653 	bus_space_handle_t sc_sh;
654 	bus_size_t sc_sz;
655 	bus_dma_tag_t sc_dmat;
656 	pci_product_id_t sc_pid;
657 	pci_chipset_tag_t sc_pct;
658 	pcitag_t sc_pcitag;
659 	const void *sc_ih;
660 	int sc_msix;
661 
662 	/* TX/RX rings. */
663 	struct iwx_tx_ring txq[IWX_NUM_TX_QUEUES];
664 	struct iwx_rx_ring rxq;
665 	int qfullmsk;
666 	int qenablemsk;
667 	int first_data_qid;
668 	int aggqid[IEEE80211_NUM_TID];
669 	int max_tfd_queue_size;
670 
671 	int sc_sf_state;
672 
673 	/* ICT table. */
674 	struct iwx_dma_info	ict_dma;
675 	int			ict_cur;
676 
677 	int sc_hw_rev;
678 #define IWX_SILICON_A_STEP	0
679 #define IWX_SILICON_B_STEP	1
680 #define IWX_SILICON_C_STEP	2
681 #define IWX_SILICON_Z_STEP	0xf
682 	int sc_hw_id;
683 	int sc_hw_rf_id;
684 	int sc_device_family;
685 #define IWX_DEVICE_FAMILY_22000	1
686 #define IWX_DEVICE_FAMILY_AX210	2
687 	uint32_t sc_sku_id[3];
688 	uint32_t mac_addr_from_csr;
689 
690 	struct iwx_dma_info ctxt_info_dma;
691 	struct iwx_self_init_dram init_dram;
692 	struct iwx_dma_info prph_scratch_dma;
693 	struct iwx_dma_info prph_info_dma;
694 	struct iwx_dma_info iml_dma;
695 	struct iwx_dma_info pnvm_dma;
696 	uint32_t sc_pnvm_ver;
697 
698 	int sc_fw_chunk_done;
699 	int sc_init_complete;
700 #define IWX_INIT_COMPLETE	0x01
701 #define IWX_CALIB_COMPLETE	0x02
702 #define IWX_PNVM_COMPLETE	0x04
703 
704 	struct iwx_ucode_status sc_uc;
705 	char sc_fwver[32];
706 
707 	int sc_capaflags;
708 	int sc_capa_max_probe_len;
709 	int sc_capa_n_scan_channels;
710 	uint8_t sc_ucode_api[howmany(IWX_NUM_UCODE_TLV_API, NBBY)];
711 	uint8_t sc_enabled_capa[howmany(IWX_NUM_UCODE_TLV_CAPA, NBBY)];
712 #define IWX_MAX_FW_CMD_VERSIONS	704
713 	struct iwx_fw_cmd_version cmd_versions[IWX_MAX_FW_CMD_VERSIONS];
714 	int n_cmd_versions;
715 	int sc_rate_n_flags_version;
716 
717 	int sc_intmask;
718 	int sc_flags;
719 
720 	uint32_t sc_fh_init_mask;
721 	uint32_t sc_hw_init_mask;
722 	uint32_t sc_fh_mask;
723 	uint32_t sc_hw_mask;
724 
725 	int sc_generation;
726 
727 	struct rwlock ioctl_rwl;
728 
729 	int sc_cap_off; /* PCIe caps */
730 
731 	const char *sc_fwname;
732 	struct iwx_fw_info sc_fw;
733 	struct iwx_dma_info fw_mon;
734 	int sc_fw_phy_config;
735 	struct iwx_tlv_calib_ctrl sc_default_calib[IWX_UCODE_TYPE_MAX];
736 
737 	struct iwx_nvm_data sc_nvm;
738 	struct iwx_bf_data sc_bf;
739 	const char *sc_pnvm_name;
740 
741 	int sc_tx_timer[IWX_NUM_TX_QUEUES];
742 	int sc_rx_ba_sessions;
743 
744 	struct task bgscan_done_task;
745 	struct ieee80211_node_switch_bss_arg *bgscan_unref_arg;
746 	size_t	bgscan_unref_arg_size;
747 
748 	int sc_scan_last_antenna;
749 
750 	int sc_staid;
751 	int sc_nodecolor;
752 
753 	uint8_t *sc_cmd_resp_pkt[IWX_TX_RING_COUNT];
754 	size_t sc_cmd_resp_len[IWX_TX_RING_COUNT];
755 	int sc_nic_locks;
756 
757 	struct taskq *sc_nswq;
758 
759 	struct iwx_rx_phy_info sc_last_phy_info;
760 	int sc_ampdu_ref;
761 	struct iwx_rxba_data sc_rxba_data[IWX_MAX_BAID];
762 
763 	uint32_t sc_time_event_uid;
764 
765 	/* phy contexts.  we only use the first one */
766 	struct iwx_phy_ctxt sc_phyctxt[IWX_NUM_PHY_CTX];
767 
768 	struct iwx_notif_statistics sc_stats;
769 	int sc_noise;
770 
771 	int sc_pm_support;
772 	int sc_ltr_enabled;
773 
774 	int sc_integrated;
775 	int sc_tx_with_siso_diversity;
776 	int sc_max_tfd_queue_size;
777 	int sc_ltr_delay;
778 	int sc_xtal_latency;
779 	int sc_low_latency_xtal;
780 	int sc_uhb_supported;
781 	int sc_umac_prph_offset;
782 	int sc_imr_enabled;
783 
784 #if NBPFILTER > 0
785 	caddr_t			sc_drvbpf;
786 
787 	union {
788 		struct iwx_rx_radiotap_header th;
789 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
790 	} sc_rxtapu;
791 #define sc_rxtap	sc_rxtapu.th
792 	int			sc_rxtap_len;
793 
794 	union {
795 		struct iwx_tx_radiotap_header th;
796 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
797 	} sc_txtapu;
798 #define sc_txtap	sc_txtapu.th
799 	int			sc_txtap_len;
800 #endif
801 };
802 
803 struct iwx_node {
804 	struct ieee80211_node in_ni;
805 	struct iwx_phy_ctxt *in_phyctxt;
806 	uint8_t in_macaddr[ETHER_ADDR_LEN];
807 
808 	uint16_t in_id;
809 	uint16_t in_color;
810 
811 	struct iwx_rxq_dup_data dup_data;
812 
813 	int in_flags;
814 #define IWX_NODE_FLAG_HAVE_PAIRWISE_KEY	0x01
815 #define IWX_NODE_FLAG_HAVE_GROUP_KEY	0x02
816 };
817 #define IWX_STATION_ID 0
818 #define IWX_AUX_STA_ID 1
819 #define IWX_MONITOR_STA_ID 2
820 
821 #define IWX_ICT_SIZE		4096
822 #define IWX_ICT_COUNT		(IWX_ICT_SIZE / sizeof (uint32_t))
823 #define IWX_ICT_PADDR_SHIFT	12
824