1 /* $OpenBSD: if_iwmvar.h,v 1.7 2015/03/02 13:51:10 jsg Exp $ */
5 * Copyright (c) 2014 genua mbh <info@genua.de>
6 * Copyright (c) 2014 Fixup Software Ltd.
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Based on BSD-licensed source modules in the Linux iwlwifi driver,
23 * which were used as the reference documentation for this implementation.
25 * Driver version we are currently based off of is
26 * Linux 3.14.3 (tag id a2df521e42b1d9a23f620ac79dbfe8655a8391dd)
28 ***********************************************************************
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.
35 * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
37 * This program is free software; you can redistribute it and/or modify
38 * it under the terms of version 2 of the GNU General Public License as
39 * published by the Free Software Foundation.
41 * This program is distributed in the hope that it will be useful, but
42 * WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 * General Public License for more details.
46 * You should have received a copy of the GNU General Public License
47 * along with this program; if not, write to the Free Software
48 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
51 * The full GNU General Public License is included in this distribution
52 * in the file called COPYING.
54 * Contact Information:
55 * Intel Linux Wireless <ilw@linux.intel.com>
56 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
61 * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved.
62 * All rights reserved.
64 * Redistribution and use in source and binary forms, with or without
65 * modification, are permitted provided that the following conditions
68 * * Redistributions of source code must retain the above copyright
69 * notice, this list of conditions and the following disclaimer.
70 * * Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in
72 * the documentation and/or other materials provided with the
74 * * Neither the name Intel Corporation nor the names of its
75 * contributors may be used to endorse or promote products derived
76 * from this software without specific prior written permission.
78 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
79 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
80 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
81 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
82 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
83 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
84 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
85 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
86 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
87 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
88 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92 * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
94 * Permission to use, copy, modify, and distribute this software for any
95 * purpose with or without fee is hereby granted, provided that the above
96 * copyright notice and this permission notice appear in all copies.
98 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
100 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
101 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
102 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
103 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
104 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
107 struct iwm_rx_radiotap_header {
108 struct ieee80211_radiotap_header wr_ihdr;
112 uint16_t wr_chan_freq;
113 uint16_t wr_chan_flags;
114 int8_t wr_dbm_antsignal;
115 int8_t wr_dbm_antnoise;
118 #define IWM_RX_RADIOTAP_PRESENT \
119 ((1 << IEEE80211_RADIOTAP_TSFT) | \
120 (1 << IEEE80211_RADIOTAP_FLAGS) | \
121 (1 << IEEE80211_RADIOTAP_RATE) | \
122 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
123 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
124 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
126 struct iwm_tx_radiotap_header {
127 struct ieee80211_radiotap_header wt_ihdr;
130 uint16_t wt_chan_freq;
131 uint16_t wt_chan_flags;
134 #define IWM_TX_RADIOTAP_PRESENT \
135 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
136 (1 << IEEE80211_RADIOTAP_RATE) | \
137 (1 << IEEE80211_RADIOTAP_CHANNEL))
140 #define IWM_UCODE_SECT_MAX 16
141 #define IWM_FWDMASEGSZ (192*1024)
142 #define IWM_FWDMASEGSZ_8000 (320*1024)
143 /* sanity check value */
144 #define IWM_FWMAXSIZE (2*1024*1024)
147 * fw_status is used to determine if we've already parsed the firmware file
149 * In addition to the following, status < 0 ==> -error
151 #define IWM_FW_STATUS_NONE 0
152 #define IWM_FW_STATUS_INPROGRESS 1
153 #define IWM_FW_STATUS_DONE 2
155 enum iwm_ucode_type {
156 IWM_UCODE_TYPE_REGULAR,
159 IWM_UCODE_TYPE_REGULAR_USNIFFER,
164 const struct firmware *fw_fp;
167 struct iwm_fw_sects {
168 struct iwm_fw_onesect {
169 const void *fws_data;
172 } fw_sect[IWM_UCODE_SECT_MAX];
174 } fw_sects[IWM_UCODE_TYPE_MAX];
177 struct iwm_nvm_data {
179 uint8_t hw_addr[IEEE80211_ADDR_LEN];
181 int sku_cap_band_24GHz_enable;
182 int sku_cap_band_52GHz_enable;
183 int sku_cap_11n_enable;
184 int sku_cap_amt_enable;
185 int sku_cap_ipan_enable;
187 uint8_t radio_cfg_type;
188 uint8_t radio_cfg_step;
189 uint8_t radio_cfg_dash;
190 uint8_t radio_cfg_pnum;
191 uint8_t valid_tx_ant, valid_rx_ant;
192 #define IWM_NUM_CHANNELS 39
193 #define IWM_NUM_CHANNELS_8000 51
195 uint16_t nvm_version;
196 uint8_t max_tx_pwr_half_dbm;
198 uint16_t nvm_ch_flags[];
201 /* max bufs per tfd the driver will use */
202 #define IWM_MAX_CMD_TBS_PER_TFD 2
204 struct iwm_rx_packet;
205 struct iwm_host_cmd {
206 const void *data[IWM_MAX_CMD_TBS_PER_TFD];
207 struct iwm_rx_packet *resp_pkt;
208 unsigned long _rx_page_addr;
209 uint32_t _rx_page_order;
214 uint16_t len[IWM_MAX_CMD_TBS_PER_TFD];
215 uint8_t dataflags[IWM_MAX_CMD_TBS_PER_TFD];
219 * DMA glue is from iwn
222 typedef caddr_t iwm_caddr_t;
223 typedef void *iwm_hookarg_t;
225 struct iwm_dma_info {
228 bus_dma_segment_t seg;
234 #define IWM_TX_RING_COUNT 256
235 #define IWM_TX_RING_LOMARK 192
236 #define IWM_TX_RING_HIMARK 224
240 bus_addr_t cmd_paddr;
241 bus_addr_t scratch_paddr;
248 struct iwm_dma_info desc_dma;
249 struct iwm_dma_info cmd_dma;
250 struct iwm_tfd *desc;
251 struct iwm_device_cmd *cmd;
252 bus_dma_tag_t data_dmat;
253 struct iwm_tx_data data[IWM_TX_RING_COUNT];
259 #define IWM_RX_RING_COUNT 256
260 #define IWM_RBUF_COUNT (IWM_RX_RING_COUNT + 32)
261 /* Linux driver optionally uses 8k buffer */
262 #define IWM_RBUF_SIZE 4096
264 #define IWM_MAX_SCATTER 20
272 struct iwm_dma_info desc_dma;
273 struct iwm_dma_info stat_dma;
274 struct iwm_dma_info buf_dma;
276 struct iwm_rb_status *stat;
277 struct iwm_rx_data data[IWM_RX_RING_COUNT];
278 bus_dmamap_t spare_map; /* for iwm_rx_addbuf() */
279 bus_dma_tag_t data_dmat;
283 struct iwm_ucode_status {
284 uint32_t uc_error_event_table;
285 uint32_t uc_umac_error_event_table;
286 uint32_t uc_log_event_table;
292 #define IWM_CMD_RESP_MAX PAGE_SIZE
294 #define IWM_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 500
295 #define IWM_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400
298 * Command headers are in iwl-trans.h, which is full of all
299 * kinds of other junk, so we just replicate the structures here.
300 * First the software bits:
304 IWM_CMD_ASYNC = (1 << 0),
305 IWM_CMD_WANT_SKB = (1 << 1),
306 IWM_CMD_SEND_IN_RFKILL = (1 << 2),
308 enum iwm_hcmd_dataflag {
309 IWM_HCMD_DFL_NOCOPY = (1 << 0),
310 IWM_HCMD_DFL_DUP = (1 << 1),
315 uint32_t tfd_queue_msk;
318 struct iwm_mvm_phy_ctxt {
322 struct ieee80211_channel *channel;
326 int bf_enabled; /* filtering */
327 int ba_enabled; /* abort */
328 int ave_beacon_signal;
333 struct ieee80211vap iv_vap;
336 int (*iv_newstate)(struct ieee80211vap *,
337 enum ieee80211_state, int);
339 #define IWM_VAP(_vap) ((struct iwm_vap *)(_vap))
342 struct ieee80211_node in_ni;
343 struct iwm_mvm_phy_ctxt *in_phyctxt;
348 struct iwm_lq_cmd in_lq;
350 uint8_t in_ridx[IEEE80211_RATE_MAXSIZE];
352 #define IWM_NODE(_ni) ((struct iwm_node *)(_ni))
354 #define IWM_STATION_ID 0
355 #define IWM_AUX_STA_ID 1
357 #define IWM_DEFAULT_MACID 0
358 #define IWM_DEFAULT_COLOR 0
359 #define IWM_DEFAULT_TSFID 0
361 #define IWM_ICT_SIZE 4096
362 #define IWM_ICT_COUNT (IWM_ICT_SIZE / sizeof (uint32_t))
363 #define IWM_ICT_PADDR_SHIFT 12
372 struct ieee80211com sc_ic;
373 struct ieee80211_ratectl_tx_status sc_txs;
376 #define IWM_FLAG_USE_ICT (1 << 0)
377 #define IWM_FLAG_HW_INITED (1 << 1)
378 #define IWM_FLAG_STOPPED (1 << 2)
379 #define IWM_FLAG_RFKILL (1 << 3)
380 #define IWM_FLAG_BUSY (1 << 4)
381 #define IWM_FLAG_SCANNING (1 << 5)
383 struct intr_config_hook sc_preinit_hook;
384 struct callout sc_watchdog_to;
385 struct callout sc_led_blink_to;
387 struct task init_task;
389 struct resource *sc_irq;
390 struct resource *sc_mem;
391 bus_space_tag_t sc_st;
392 bus_space_handle_t sc_sh;
394 bus_dma_tag_t sc_dmat;
397 /* TX scheduler rings. */
398 struct iwm_dma_info sched_dma;
402 struct iwm_tx_ring txq[IWM_MVM_MAX_QUEUES];
403 struct iwm_rx_ring rxq;
409 struct iwm_dma_info ict_dma;
414 int sc_device_family;
415 #define IWM_DEVICE_FAMILY_7000 1
416 #define IWM_DEVICE_FAMILY_8000 2
418 struct iwm_dma_info kw_dma;
419 struct iwm_dma_info fw_dma;
421 int sc_fw_chunk_done;
422 int sc_init_complete;
424 struct iwm_ucode_status sc_uc;
425 enum iwm_ucode_type sc_uc_current;
429 int sc_capa_max_probe_len;
430 int sc_capa_n_scan_channels;
431 uint32_t sc_ucode_api;
432 uint8_t sc_enabled_capa[howmany(IWM_NUM_UCODE_TLV_CAPA, NBBY)];
438 * So why do we need a separate stopped flag and a generation?
439 * the former protects the device from issuing commands when it's
440 * stopped (duh). The latter protects against race from a very
441 * fast stop/unstop cycle where threads waiting for responses do
442 * not have a chance to run in between. Notably: we want to stop
443 * the device from interrupt context when it craps out, so we
444 * don't have the luxury of waiting for quiescense.
448 const char *sc_fwname;
449 bus_size_t sc_fwdmasegsz;
450 struct iwm_fw_info sc_fw;
451 int sc_fw_phy_config;
452 struct iwm_tlv_calib_ctrl sc_default_calib[IWM_UCODE_TYPE_MAX];
454 struct iwm_nvm_data *nvm_data;
455 struct iwm_phy_db *sc_phy_db;
457 struct iwm_bf_data sc_bf;
461 int sc_scan_last_antenna;
468 uint8_t sc_cmd_resp[IWM_CMD_RESP_MAX];
471 struct task sc_es_task;
473 struct iwm_rx_phy_info sc_last_phy_info;
476 struct iwm_int_sta sc_aux_sta;
478 /* phy contexts. we only use the first one */
479 struct iwm_mvm_phy_ctxt sc_phyctxt[IWM_NUM_PHY_CTX];
481 struct iwm_notif_statistics sc_stats;
484 int host_interrupt_operation_mode;
488 struct iwm_rx_radiotap_header sc_rxtap;
489 struct iwm_tx_radiotap_header sc_txtap;
493 uint16_t eeprom_size;
494 uint8_t nvm_hw_section_num;
497 #define IWM_LOCK_INIT(_sc) \
498 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
499 MTX_NETWORK_LOCK, MTX_DEF);
500 #define IWM_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
501 #define IWM_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
502 #define IWM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)