2 /* $OpenBSD: if_iwnvar.h,v 1.18 2010/04/30 16:06:46 damien Exp $ */
5 * Copyright (c) 2013 Cedric GROSS <cg@cgross.info>
6 * Copyright (c) 2011 Intel Corporation
7 * Copyright (c) 2007, 2008
8 * Damien Bergamini <damien.bergamini@free.fr>
9 * Copyright (c) 2008 Sam Leffler, Errno Consulting
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.
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.
23 enum iwn_rxon_ctx_id {
35 struct iwn_pan_params_cmd {
37 #define IWN_PAN_PARAMS_FLG_SLOTTED_MODE (1 << 3)
41 struct iwn_pan_slot slots[10];
50 uint64_t led_last_tpt;
56 struct iwn_rx_radiotap_header {
57 struct ieee80211_radiotap_header wr_ihdr;
61 uint16_t wr_chan_freq;
62 uint16_t wr_chan_flags;
63 int8_t wr_dbm_antsignal;
64 int8_t wr_dbm_antnoise;
67 #define IWN_RX_RADIOTAP_PRESENT \
68 ((1 << IEEE80211_RADIOTAP_TSFT) | \
69 (1 << IEEE80211_RADIOTAP_FLAGS) | \
70 (1 << IEEE80211_RADIOTAP_RATE) | \
71 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
72 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
73 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
75 struct iwn_tx_radiotap_header {
76 struct ieee80211_radiotap_header wt_ihdr;
79 uint16_t wt_chan_freq;
80 uint16_t wt_chan_flags;
83 #define IWN_TX_RADIOTAP_PRESENT \
84 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
85 (1 << IEEE80211_RADIOTAP_RATE) | \
86 (1 << IEEE80211_RADIOTAP_CHANNEL))
91 bus_dma_segment_t seg;
100 bus_addr_t scratch_paddr;
102 struct ieee80211_node *ni;
106 struct iwn_dma_info desc_dma;
107 struct iwn_dma_info cmd_dma;
108 struct iwn_tx_desc *desc;
109 struct iwn_tx_cmd *cmd;
110 struct iwn_tx_data data[IWN_TX_RING_COUNT];
111 bus_dma_tag_t data_dmat;
126 struct iwn_dma_info desc_dma;
127 struct iwn_dma_info stat_dma;
129 struct iwn_rx_status *stat;
130 struct iwn_rx_data data[IWN_RX_RING_COUNT];
131 bus_dma_tag_t data_dmat;
136 struct ieee80211_node ni; /* must be the first */
137 uint16_t disable_tid;
143 } agg[IEEE80211_TID_SIZE];
146 struct iwn_calib_state {
148 #define IWN_CALIB_STATE_INIT 0
149 #define IWN_CALIB_STATE_ASSOC 1
150 #define IWN_CALIB_STATE_RUN 2
156 uint32_t ofdm_mrc_x1;
158 uint32_t ofdm_mrc_x4;
161 uint32_t bad_plcp_ofdm;
163 uint32_t bad_plcp_cck;
167 #define IWN_CCK_STATE_INIT 0
168 #define IWN_CCK_STATE_LOFA 1
169 #define IWN_CCK_STATE_HIFA 2
171 uint8_t noise_samples[20];
172 u_int cur_noise_sample;
174 uint32_t energy_samples[10];
175 u_int cur_energy_sample;
179 struct iwn_calib_info {
194 struct iwn_fw_part init;
195 struct iwn_fw_part main;
196 struct iwn_fw_part boot;
200 int (*load_firmware)(struct iwn_softc *);
201 void (*read_eeprom)(struct iwn_softc *);
202 int (*post_alive)(struct iwn_softc *);
203 int (*nic_config)(struct iwn_softc *);
204 void (*update_sched)(struct iwn_softc *, int, int, uint8_t,
206 int (*get_temperature)(struct iwn_softc *);
207 int (*get_rssi)(struct iwn_softc *, struct iwn_rx_stat *);
208 int (*set_txpower)(struct iwn_softc *,
209 struct ieee80211_channel *, int);
210 int (*init_gains)(struct iwn_softc *);
211 int (*set_gains)(struct iwn_softc *);
212 int (*add_node)(struct iwn_softc *, struct iwn_node_info *,
214 void (*tx_done)(struct iwn_softc *, struct iwn_rx_desc *,
215 struct iwn_rx_data *);
216 void (*ampdu_tx_start)(struct iwn_softc *,
217 struct ieee80211_node *, int, uint8_t, uint16_t);
218 void (*ampdu_tx_stop)(struct iwn_softc *, int, uint8_t,
223 struct ieee80211vap iv_vap;
226 int (*iv_newstate)(struct ieee80211vap *,
227 enum ieee80211_state, int);
230 uint8_t macaddr[IEEE80211_ADDR_LEN];
233 #define IWN_VAP(_vap) ((struct iwn_vap *)(_vap))
238 struct ifnet *sc_ifp;
244 #define IWN_FLAG_HAS_OTPROM (1 << 1)
245 #define IWN_FLAG_CALIB_DONE (1 << 2)
246 #define IWN_FLAG_USE_ICT (1 << 3)
247 #define IWN_FLAG_INTERNAL_PA (1 << 4)
248 #define IWN_FLAG_HAS_11N (1 << 6)
249 #define IWN_FLAG_ENH_SENS (1 << 7)
250 #define IWN_FLAG_ADV_BTCOEX (1 << 8)
251 #define IWN_FLAG_PAN_SUPPORT (1 << 9)
254 /* subdevice_id used to adjust configuration */
255 uint16_t subdevice_id;
259 const struct iwn_sensitivity_limits
264 uint8_t broadcast_id;
267 uint32_t fw_text_maxsz;
268 uint32_t fw_data_maxsz;
270 bus_size_t sched_txfact_addr;
271 uint32_t reset_noise_gain;
274 /* TX scheduler rings. */
275 struct iwn_dma_info sched_dma;
279 /* "Keep Warm" page. */
280 struct iwn_dma_info kw_dma;
282 /* Firmware image. */
283 const struct firmware *fw_fp;
285 /* Firmware DMA transfer. */
286 struct iwn_dma_info fw_dma;
289 struct iwn_dma_info ict_dma;
294 struct iwn_tx_ring txq[IWN5000_NTXQUEUES];
295 struct iwn_rx_ring rxq;
297 struct resource *mem;
298 bus_space_tag_t sc_st;
299 bus_space_handle_t sc_sh;
300 struct resource *irq;
303 int sc_cap_off; /* PCIe Capabilities. */
305 /* Tasks used by the driver */
306 struct task sc_reinit_task;
307 struct task sc_radioon_task;
308 struct task sc_radiooff_task;
310 struct callout calib_to;
312 struct iwn_calib_state calib;
313 struct callout watchdog_to;
314 struct callout ct_kill_exit_to;
315 struct iwn_fw_info fw;
316 struct iwn_calib_info calibcmd[5];
319 struct iwn_rx_stat last_rx_stat;
321 struct iwn_ucode_info ucode_info;
322 struct iwn_rxon rx_on[IWN_NUM_RXON_CTX];
323 struct iwn_rxon *rxon;
325 struct ieee80211vap *ivap[IWN_NUM_RXON_CTX];
327 uint8_t uc_scan_progress;
334 struct iwn4965_eeprom_band
336 struct iwn_eeprom_chan eeprom_channels[IWN_NBANDS][IWN_MAX_CHAN_PER_BAND];
339 char eeprom_domain[4];
340 uint32_t eeprom_crystal;
342 int16_t eeprom_temp_high;
343 int16_t eeprom_voltage;
346 int8_t maxpwr[IEEE80211_CHAN_MAX];
348 uint32_t tlv_feature_flags;
361 struct ieee80211_tx_ampdu *qid2tap[IWN5000_NTXQUEUES];
363 int (*sc_ampdu_rx_start)(struct ieee80211_node *,
364 struct ieee80211_rx_ampdu *, int, int, int);
365 void (*sc_ampdu_rx_stop)(struct ieee80211_node *,
366 struct ieee80211_rx_ampdu *);
367 int (*sc_addba_request)(struct ieee80211_node *,
368 struct ieee80211_tx_ampdu *, int, int, int);
369 int (*sc_addba_response)(struct ieee80211_node *,
370 struct ieee80211_tx_ampdu *, int, int, int);
371 void (*sc_addba_stop)(struct ieee80211_node *,
372 struct ieee80211_tx_ampdu *);
374 struct iwn_led_mode sc_led;
376 struct iwn_rx_radiotap_header sc_rxtap;
377 struct iwn_tx_radiotap_header sc_txtap;
379 /* The power save level originally configured by user */
380 int desired_pwrsave_level;
383 * The current power save level, this may differ from the
384 * configured value due to thermal throttling etc.
386 int current_pwrsave_level;
388 /* For specifique params */
389 struct iwn_base_params *base_params;
392 #define IWN_LOCK_INIT(_sc) \
393 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
394 MTX_NETWORK_LOCK, MTX_DEF)
395 #define IWN_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
396 #define IWN_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
397 #define IWN_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
398 #define IWN_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)