1/*	$OpenBSD: if_iwmvar.h,v 1.77 2022/03/19 14:50:01 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 * Driver version we are currently based off of is
25 * Linux 3.14.3 (tag id a2df521e42b1d9a23f620ac79dbfe8655a8391dd)
26 *
27 ***********************************************************************
28 *
29 * This file is provided under a dual BSD/GPLv2 license.  When using or
30 * redistributing this file, you may do so under either license.
31 *
32 * GPL LICENSE SUMMARY
33 *
34 * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
35 *
36 * This program is free software; you can redistribute it and/or modify
37 * it under the terms of version 2 of the GNU General Public License as
38 * published by the Free Software Foundation.
39 *
40 * This program is distributed in the hope that it will be useful, but
41 * WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
43 * General Public License for more details.
44 *
45 * You should have received a copy of the GNU General Public License
46 * along with this program; if not, write to the Free Software
47 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
48 * USA
49 *
50 * The full GNU General Public License is included in this distribution
51 * in the file called COPYING.
52 *
53 * Contact Information:
54 *  Intel Linux Wireless <ilw@linux.intel.com>
55 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
56 *
57 *
58 * BSD LICENSE
59 *
60 * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved.
61 * All rights reserved.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 *
67 *  * Redistributions of source code must retain the above copyright
68 *    notice, this list of conditions and the following disclaimer.
69 *  * Redistributions in binary form must reproduce the above copyright
70 *    notice, this list of conditions and the following disclaimer in
71 *    the documentation and/or other materials provided with the
72 *    distribution.
73 *  * Neither the name Intel Corporation nor the names of its
74 *    contributors may be used to endorse or promote products derived
75 *    from this software without specific prior written permission.
76 *
77 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
78 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
79 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
80 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
81 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
82 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
83 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
84 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
85 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
86 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
87 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88 */
89
90/*-
91 * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
92 *
93 * Permission to use, copy, modify, and distribute this software for any
94 * purpose with or without fee is hereby granted, provided that the above
95 * copyright notice and this permission notice appear in all copies.
96 *
97 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
98 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
99 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
100 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
101 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
102 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
103 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
104 */
105
106struct iwm_rx_radiotap_header {
107	struct ieee80211_radiotap_header wr_ihdr;
108	uint64_t	wr_tsft;
109	uint8_t		wr_flags;
110	uint8_t		wr_rate;
111	uint16_t	wr_chan_freq;
112	uint16_t	wr_chan_flags;
113	int8_t		wr_dbm_antsignal;
114	int8_t		wr_dbm_antnoise;
115} __packed;
116
117#define IWM_RX_RADIOTAP_PRESENT						\
118	((1 << IEEE80211_RADIOTAP_TSFT) |				\
119	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
120	 (1 << IEEE80211_RADIOTAP_RATE) |				\
121	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
122	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
123	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
124
125struct iwm_tx_radiotap_header {
126	struct ieee80211_radiotap_header wt_ihdr;
127	uint8_t		wt_flags;
128	uint8_t		wt_rate;
129	uint16_t	wt_chan_freq;
130	uint16_t	wt_chan_flags;
131} __packed;
132
133#define IWM_TX_RADIOTAP_PRESENT						\
134	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
135	 (1 << IEEE80211_RADIOTAP_RATE) |				\
136	 (1 << IEEE80211_RADIOTAP_CHANNEL))
137
138#define IWM_UCODE_SECT_MAX 16
139#define IWM_FWDMASEGSZ (192*1024)
140#define IWM_FWDMASEGSZ_8000 (320*1024)
141/* sanity check value */
142#define IWM_FWMAXSIZE (2*1024*1024)
143
144/*
145 * fw_status is used to determine if we've already parsed the firmware file
146 *
147 * In addition to the following, status < 0 ==> -error
148 */
149#define IWM_FW_STATUS_NONE		0
150#define IWM_FW_STATUS_INPROGRESS	1
151#define IWM_FW_STATUS_DONE		2
152
153enum iwm_ucode_type {
154	IWM_UCODE_TYPE_REGULAR,
155	IWM_UCODE_TYPE_INIT,
156	IWM_UCODE_TYPE_WOW,
157	IWM_UCODE_TYPE_REGULAR_USNIFFER,
158	IWM_UCODE_TYPE_MAX
159};
160
161struct iwm_fw_info {
162	void *fw_rawdata;
163	size_t fw_rawsize;
164	int fw_status;
165
166	struct iwm_fw_sects {
167		struct iwm_fw_onesect {
168			void *fws_data;
169			uint32_t fws_len;
170			uint32_t fws_devoff;
171		} fw_sect[IWM_UCODE_SECT_MAX];
172		size_t fw_totlen;
173		int fw_count;
174		uint32_t paging_mem_size;
175	} fw_sects[IWM_UCODE_TYPE_MAX];
176};
177
178struct iwm_nvm_data {
179	int n_hw_addrs;
180	uint8_t hw_addr[ETHER_ADDR_LEN];
181
182	uint8_t calib_version;
183	uint16_t calib_voltage;
184
185	uint16_t raw_temperature;
186	uint16_t kelvin_temperature;
187	uint16_t kelvin_voltage;
188	uint16_t xtal_calib[2];
189
190	int sku_cap_band_24GHz_enable;
191	int sku_cap_band_52GHz_enable;
192	int sku_cap_11n_enable;
193	int sku_cap_11ac_enable;
194	int sku_cap_amt_enable;
195	int sku_cap_ipan_enable;
196	int sku_cap_mimo_disable;
197
198	uint8_t radio_cfg_type;
199	uint8_t radio_cfg_step;
200	uint8_t radio_cfg_dash;
201	uint8_t radio_cfg_pnum;
202	uint8_t valid_tx_ant, valid_rx_ant;
203
204	uint16_t nvm_version;
205	uint8_t max_tx_pwr_half_dbm;
206
207	int lar_enabled;
208};
209
210/* max bufs per tfd the driver will use */
211#define IWM_MAX_CMD_TBS_PER_TFD 2
212
213struct iwm_host_cmd {
214	const void *data[IWM_MAX_CMD_TBS_PER_TFD];
215	struct iwm_rx_packet *resp_pkt;
216	size_t resp_pkt_len;
217	unsigned long _rx_page_addr;
218	uint32_t _rx_page_order;
219	int handler_status;
220
221	uint32_t flags;
222	uint16_t len[IWM_MAX_CMD_TBS_PER_TFD];
223	uint8_t dataflags[IWM_MAX_CMD_TBS_PER_TFD];
224	uint32_t id;
225};
226
227/*
228 * DMA glue is from iwn
229 */
230
231struct iwm_dma_info {
232	bus_dma_tag_t		tag;
233	bus_dmamap_t		map;
234	bus_dma_segment_t	seg;
235	bus_addr_t		paddr;
236	void 			*vaddr;
237	bus_size_t		size;
238};
239
240/**
241 * struct iwm_fw_paging
242 * @fw_paging_block: dma memory info
243 * @fw_paging_size: page size
244 */
245struct iwm_fw_paging {
246	struct iwm_dma_info fw_paging_block;
247	uint32_t fw_paging_size;
248};
249
250#define IWM_TX_RING_COUNT	256
251#define IWM_TX_RING_LOMARK	192
252#define IWM_TX_RING_HIMARK	224
253
254/* For aggregation queues, index must be aligned to frame sequence number. */
255#define IWM_AGG_SSN_TO_TXQ_IDX(x)	((x) & (IWM_TX_RING_COUNT - 1))
256
257struct iwm_tx_data {
258	bus_dmamap_t	map;
259	bus_addr_t	cmd_paddr;
260	bus_addr_t	scratch_paddr;
261	struct mbuf	*m;
262	struct iwm_node *in;
263	int txmcs;
264	int txrate;
265
266	/* A-MPDU subframes */
267	int ampdu_txmcs;
268	int ampdu_txnss;
269	int ampdu_nframes;
270};
271
272struct iwm_tx_ring {
273	struct iwm_dma_info	desc_dma;
274	struct iwm_dma_info	cmd_dma;
275	struct iwm_tfd		*desc;
276	struct iwm_device_cmd	*cmd;
277	struct iwm_tx_data	data[IWM_TX_RING_COUNT];
278	int			qid;
279	int			queued;
280	int			cur;
281	int			tail;
282};
283
284#define IWM_RX_MQ_RING_COUNT	512
285#define IWM_RX_RING_COUNT	256
286/* Linux driver optionally uses 8k buffer */
287#define IWM_RBUF_SIZE		4096
288
289struct iwm_rx_data {
290	struct mbuf	*m;
291	bus_dmamap_t	map;
292};
293
294struct iwm_rx_ring {
295	struct iwm_dma_info	free_desc_dma;
296	struct iwm_dma_info	stat_dma;
297	struct iwm_dma_info	used_desc_dma;
298	void			*desc;
299	struct iwm_rb_status	*stat;
300	struct iwm_rx_data	data[IWM_RX_MQ_RING_COUNT];
301	int			cur;
302};
303
304#define IWM_FLAG_USE_ICT	0x01	/* using Interrupt Cause Table */
305#define IWM_FLAG_RFKILL		0x02	/* radio kill switch is set */
306#define IWM_FLAG_SCANNING	0x04	/* scan in progress */
307#define IWM_FLAG_MAC_ACTIVE	0x08	/* MAC context added to firmware */
308#define IWM_FLAG_BINDING_ACTIVE	0x10	/* MAC->PHY binding added to firmware */
309#define IWM_FLAG_STA_ACTIVE	0x20	/* AP added to firmware station table */
310#define IWM_FLAG_TE_ACTIVE	0x40	/* time event is scheduled */
311#define IWM_FLAG_HW_ERR		0x80	/* hardware error occurred */
312#define IWM_FLAG_SHUTDOWN	0x100	/* shutting down; new tasks forbidden */
313#define IWM_FLAG_BGSCAN		0x200	/* background scan in progress */
314#define IWM_FLAG_TXFLUSH	0x400	/* Tx queue flushing in progress */
315
316struct iwm_ucode_status {
317	uint32_t uc_error_event_table;
318	uint32_t uc_umac_error_event_table;
319	uint32_t uc_log_event_table;
320
321	int uc_ok;
322	int uc_intr;
323};
324
325#define IWM_CMD_RESP_MAX PAGE_SIZE
326
327/* lower blocks contain EEPROM image and calibration data */
328#define IWM_OTP_LOW_IMAGE_SIZE_FAMILY_7000 	16384
329#define IWM_OTP_LOW_IMAGE_SIZE_FAMILY_8000	32768
330
331#define IWM_TE_SESSION_PROTECTION_MAX_TIME_MS 1000
332#define IWM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
333
334enum IWM_CMD_MODE {
335	IWM_CMD_ASYNC		= (1 << 0),
336	IWM_CMD_WANT_RESP	= (1 << 1),
337	IWM_CMD_SEND_IN_RFKILL	= (1 << 2),
338};
339enum iwm_hcmd_dataflag {
340	IWM_HCMD_DFL_NOCOPY     = (1 << 0),
341	IWM_HCMD_DFL_DUP        = (1 << 1),
342};
343
344#define IWM_NUM_PAPD_CH_GROUPS	9
345#define IWM_NUM_TXP_CH_GROUPS	9
346
347struct iwm_phy_db_entry {
348	uint16_t size;
349	uint8_t *data;
350};
351
352struct iwm_phy_db {
353	struct iwm_phy_db_entry	cfg;
354	struct iwm_phy_db_entry	calib_nch;
355	struct iwm_phy_db_entry	calib_ch_group_papd[IWM_NUM_PAPD_CH_GROUPS];
356	struct iwm_phy_db_entry	calib_ch_group_txp[IWM_NUM_TXP_CH_GROUPS];
357};
358
359struct iwm_phy_ctxt {
360	uint16_t id;
361	uint16_t color;
362	uint32_t ref;
363	struct ieee80211_channel *channel;
364	uint8_t sco; /* 40 MHz secondary channel offset */
365	uint8_t vht_chan_width;
366};
367
368struct iwm_bf_data {
369	int bf_enabled;		/* filtering	*/
370	int ba_enabled;		/* abort	*/
371	int ave_beacon_signal;
372	int last_cqm_event;
373};
374
375/**
376 * struct iwm_reorder_buffer - per ra/tid/queue reorder buffer
377 * @head_sn: reorder window head sn
378 * @num_stored: number of mpdus stored in the buffer
379 * @buf_size: the reorder buffer size as set by the last addba request
380 * @queue: queue of this reorder buffer
381 * @last_amsdu: track last ASMDU SN for duplication detection
382 * @last_sub_index: track ASMDU sub frame index for duplication detection
383 * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU
384 *	it is the time of last received sub-frame
385 * @removed: prevent timer re-arming
386 * @valid: reordering is valid for this queue
387 * @consec_oldsn_drops: consecutive drops due to old SN
388 * @consec_oldsn_ampdu_gp2: A-MPDU GP2 timestamp to track
389 *	when to apply old SN consecutive drop workaround
390 * @consec_oldsn_prev_drop: track whether or not an MPDU
391 *	that was single/part of the previous A-MPDU was
392 *	dropped due to old SN
393 */
394struct iwm_reorder_buffer {
395	uint16_t head_sn;
396	uint16_t num_stored;
397	uint16_t buf_size;
398	uint16_t last_amsdu;
399	uint8_t last_sub_index;
400	struct timeout reorder_timer;
401	int removed;
402	int valid;
403	unsigned int consec_oldsn_drops;
404	uint32_t consec_oldsn_ampdu_gp2;
405	unsigned int consec_oldsn_prev_drop;
406#define IWM_AMPDU_CONSEC_DROPS_DELBA	10
407};
408
409/**
410 * struct iwm_reorder_buf_entry - reorder buffer entry per frame sequence number
411 * @frames: list of mbufs stored (A-MSDU subframes share a sequence number)
412 * @reorder_time: time the packet was stored in the reorder buffer
413 */
414struct iwm_reorder_buf_entry {
415	struct mbuf_list frames;
416	struct timeval reorder_time;
417	uint32_t rx_pkt_status;
418	int chanidx;
419	int is_shortpre;
420	uint32_t rate_n_flags;
421	uint32_t device_timestamp;
422	struct ieee80211_rxinfo rxi;
423};
424
425/**
426 * struct iwm_rxba_data - BA session data
427 * @sta_id: station id
428 * @tid: tid of the session
429 * @baid: baid of the session
430 * @timeout: the timeout set in the addba request
431 * @entries_per_queue: # of buffers per queue
432 * @last_rx: last rx timestamp, updated only if timeout passed from last update
433 * @session_timer: timer to check if BA session expired, runs at 2 * timeout
434 * @sc: softc pointer, needed for timer context
435 * @reorder_buf: reorder buffer
436 * @reorder_buf_data: buffered frames, one entry per sequence number
437 */
438struct iwm_rxba_data {
439	uint8_t sta_id;
440	uint8_t tid;
441	uint8_t baid;
442	uint16_t timeout;
443	uint16_t entries_per_queue;
444	struct timeval last_rx;
445	struct timeout session_timer;
446	struct iwm_softc *sc;
447	struct iwm_reorder_buffer reorder_buf;
448	struct iwm_reorder_buf_entry entries[IEEE80211_BA_MAX_WINSZ];
449};
450
451static inline struct iwm_rxba_data *
452iwm_rxba_data_from_reorder_buf(struct iwm_reorder_buffer *buf)
453{
454	return (void *)((uint8_t *)buf -
455			offsetof(struct iwm_rxba_data, reorder_buf));
456}
457
458/**
459 * struct iwm_rxq_dup_data - per station per rx queue data
460 * @last_seq: last sequence per tid for duplicate packet detection
461 * @last_sub_frame: last subframe packet
462 */
463struct iwm_rxq_dup_data {
464	uint16_t last_seq[IWM_MAX_TID_COUNT + 1];
465	uint8_t last_sub_frame[IWM_MAX_TID_COUNT + 1];
466};
467
468struct iwm_ba_task_data {
469	uint32_t		start_tidmask;
470	uint32_t		stop_tidmask;
471};
472
473struct iwm_softc {
474#ifdef __FreeBSD_version
475	device_t sc_dev;
476#else
477	struct device sc_dev;
478#endif
479	struct ieee80211com sc_ic;
480	int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int);
481	int sc_newstate_pending;
482	int attached;
483
484	struct ieee80211_amrr sc_amrr;
485	struct timeout sc_calib_to;
486	struct timeout sc_led_blink_to;
487
488	struct task		init_task; /* NB: not reference-counted */
489	struct refcnt		task_refs;
490	struct task		newstate_task;
491	enum ieee80211_state	ns_nstate;
492	int			ns_arg;
493
494	/* Task for firmware BlockAck setup/teardown and its arguments. */
495	struct task		ba_task;
496	struct iwm_ba_task_data	ba_rx;
497	struct iwm_ba_task_data	ba_tx;
498
499	/* Task for ERP/HT prot/slot-time/EDCA updates. */
500	struct task		mac_ctxt_task;
501
502	/* Task for HT 20/40 MHz channel width updates. */
503	struct task		phy_ctxt_task;
504
505	bus_space_tag_t sc_st;
506	bus_space_handle_t sc_sh;
507	bus_size_t sc_sz;
508	bus_dma_tag_t sc_dmat;
509#ifndef __FreeBSD_version
510	pci_chipset_tag_t sc_pct;
511	pcitag_t sc_pcitag;
512#endif
513	const void *sc_ih;
514	int sc_msix;
515
516	/* TX scheduler rings. */
517	struct iwm_dma_info		sched_dma;
518	uint32_t			sched_base;
519
520	/* TX/RX rings. */
521	struct iwm_tx_ring txq[IWM_MAX_QUEUES];
522	struct iwm_rx_ring rxq;
523	int qfullmsk;
524	int qenablemsk;
525	int cmdqid;
526
527	int sc_sf_state;
528
529	/* ICT table. */
530	struct iwm_dma_info	ict_dma;
531	int			ict_cur;
532
533	int sc_hw_rev;
534#define IWM_SILICON_A_STEP	0
535#define IWM_SILICON_B_STEP	1
536#define IWM_SILICON_C_STEP	2
537#define IWM_SILICON_D_STEP	3
538	int sc_hw_id;
539	int sc_device_family;
540#define IWM_DEVICE_FAMILY_7000	1
541#define IWM_DEVICE_FAMILY_8000	2
542#define IWM_DEVICE_FAMILY_9000	3
543
544	struct iwm_dma_info kw_dma;
545	struct iwm_dma_info fw_dma;
546
547	int sc_fw_chunk_done;
548	int sc_init_complete;
549#define IWM_INIT_COMPLETE	0x01
550#define IWM_CALIB_COMPLETE	0x02
551
552	struct iwm_ucode_status sc_uc;
553	enum iwm_ucode_type sc_uc_current;
554	char sc_fwver[32];
555
556	int sc_capaflags;
557	int sc_capa_max_probe_len;
558	int sc_capa_n_scan_channels;
559	uint8_t sc_ucode_api[howmany(IWM_NUM_UCODE_TLV_API, NBBY)];
560	uint8_t sc_enabled_capa[howmany(IWM_NUM_UCODE_TLV_CAPA, NBBY)];
561#define IWM_MAX_FW_CMD_VERSIONS	64
562	struct iwm_fw_cmd_version cmd_versions[IWM_MAX_FW_CMD_VERSIONS];
563	int n_cmd_versions;
564
565	int sc_intmask;
566	int sc_flags;
567
568	uint32_t sc_fh_init_mask;
569	uint32_t sc_hw_init_mask;
570	uint32_t sc_fh_mask;
571	uint32_t sc_hw_mask;
572
573	/*
574	 * So why do we need a separate stopped flag and a generation?
575	 * the former protects the device from issuing commands when it's
576	 * stopped (duh).  The latter protects against race from a very
577	 * fast stop/unstop cycle where threads waiting for responses do
578	 * not have a chance to run in between.  Notably: we want to stop
579	 * the device from interrupt context when it craps out, so we
580	 * don't have the luxury of waiting for quiescence.
581	 */
582	int sc_generation;
583
584	struct rwlock ioctl_rwl;
585
586	int sc_cap_off; /* PCIe caps */
587
588	const char *sc_fwname;
589	bus_size_t sc_fwdmasegsz;
590	size_t sc_nvm_max_section_size;
591	struct iwm_fw_info sc_fw;
592	uint32_t sc_fw_phy_config;
593	uint32_t sc_extra_phy_config;
594	struct iwm_tlv_calib_ctrl sc_default_calib[IWM_UCODE_TYPE_MAX];
595
596	struct iwm_nvm_data sc_nvm;
597	struct iwm_phy_db sc_phy_db;
598
599	struct iwm_bf_data sc_bf;
600
601	int sc_tx_timer[IWM_MAX_QUEUES];
602	int sc_rx_ba_sessions;
603	int tx_ba_queue_mask;
604
605	struct task bgscan_done_task;
606	struct ieee80211_node_switch_bss_arg *bgscan_unref_arg;
607	size_t	bgscan_unref_arg_size;
608
609	int sc_scan_last_antenna;
610
611	int sc_fixed_ridx;
612
613	int sc_staid;
614	int sc_nodecolor;
615
616	uint8_t *sc_cmd_resp_pkt[IWM_TX_RING_COUNT];
617	size_t sc_cmd_resp_len[IWM_TX_RING_COUNT];
618	int sc_nic_locks;
619
620	struct taskq *sc_nswq;
621
622	struct iwm_rx_phy_info sc_last_phy_info;
623	int sc_ampdu_ref;
624#define IWM_MAX_BAID	32
625	struct iwm_rxba_data sc_rxba_data[IWM_MAX_BAID];
626
627	uint32_t sc_time_event_uid;
628
629	/* phy contexts.  we only use the first one */
630	struct iwm_phy_ctxt sc_phyctxt[IWM_NUM_PHY_CTX];
631
632	struct iwm_notif_statistics sc_stats;
633	int sc_noise;
634
635	int host_interrupt_operation_mode;
636	int sc_ltr_enabled;
637	enum iwm_nvm_type nvm_type;
638
639	int sc_mqrx_supported;
640	int sc_integrated;
641	int sc_ltr_delay;
642	int sc_xtal_latency;
643	int sc_low_latency_xtal;
644
645	/*
646	 * Paging parameters - All of the parameters should be set by the
647	 * opmode when paging is enabled
648	 */
649	struct iwm_fw_paging fw_paging_db[IWM_NUM_OF_FW_PAGING_BLOCKS];
650	uint16_t num_of_paging_blk;
651	uint16_t num_of_pages_in_last_blk;
652
653#if NBPFILTER > 0
654	caddr_t			sc_drvbpf;
655
656	union {
657		struct iwm_rx_radiotap_header th;
658		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
659	} sc_rxtapu;
660#define sc_rxtap	sc_rxtapu.th
661	int			sc_rxtap_len;
662
663	union {
664		struct iwm_tx_radiotap_header th;
665		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
666	} sc_txtapu;
667#define sc_txtap	sc_txtapu.th
668	int			sc_txtap_len;
669#endif
670};
671
672struct iwm_node {
673	struct ieee80211_node in_ni;
674	struct iwm_phy_ctxt *in_phyctxt;
675	uint8_t in_macaddr[ETHER_ADDR_LEN];
676
677	uint16_t in_id;
678	uint16_t in_color;
679
680	struct ieee80211_amrr_node in_amn;
681	struct ieee80211_ra_node in_rn;
682	struct ieee80211_ra_vht_node in_rn_vht;
683	int lq_rate_mismatch;
684
685	struct iwm_rxq_dup_data dup_data;
686
687	/* For use with the ADD_STA command. */
688	uint32_t tfd_queue_msk;
689	uint16_t tid_disable_ampdu;
690};
691#define IWM_STATION_ID 0
692#define IWM_AUX_STA_ID 1
693#define IWM_MONITOR_STA_ID 2
694
695#define IWM_ICT_SIZE		4096
696#define IWM_ICT_COUNT		(IWM_ICT_SIZE / sizeof (uint32_t))
697#define IWM_ICT_PADDR_SHIFT	12
698