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