2 /* $OpenBSD: if_iwnvar.h,v 1.17 2010/02/17 18:23:00 damien Exp $ */
5 * Copyright (c) 2007, 2008
6 * Damien Bergamini <damien.bergamini@free.fr>
7 * Copyright (c) 2008 Sam Leffler, Errno Consulting
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <netproto/802_11/ieee80211_amrr.h>
24 struct iwn_rx_radiotap_header {
25 struct ieee80211_radiotap_header wr_ihdr;
29 uint16_t wr_chan_freq;
30 uint16_t wr_chan_flags;
31 int8_t wr_dbm_antsignal;
32 int8_t wr_dbm_antnoise;
35 #define IWN_RX_RADIOTAP_PRESENT \
36 ((1 << IEEE80211_RADIOTAP_TSFT) | \
37 (1 << IEEE80211_RADIOTAP_FLAGS) | \
38 (1 << IEEE80211_RADIOTAP_RATE) | \
39 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
40 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
41 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
43 struct iwn_tx_radiotap_header {
44 struct ieee80211_radiotap_header wt_ihdr;
47 uint16_t wt_chan_freq;
48 uint16_t wt_chan_flags;
51 #define IWN_TX_RADIOTAP_PRESENT \
52 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
53 (1 << IEEE80211_RADIOTAP_RATE) | \
54 (1 << IEEE80211_RADIOTAP_CHANNEL))
59 bus_dma_segment_t seg;
68 bus_addr_t scratch_paddr;
70 struct ieee80211_node *ni;
74 struct iwn_dma_info desc_dma;
75 struct iwn_dma_info cmd_dma;
76 struct iwn_tx_desc *desc;
77 struct iwn_tx_cmd *cmd;
78 struct iwn_tx_data data[IWN_TX_RING_COUNT];
79 bus_dma_tag_t data_dmat;
86 struct ieee80211_node ni; /* must be the first */
90 int success_threshold;
102 struct iwn_dma_info desc_dma;
103 struct iwn_dma_info stat_dma;
105 struct iwn_rx_status *stat;
106 struct iwn_rx_data data[IWN_RX_RING_COUNT];
107 bus_dma_tag_t data_dmat;
112 struct ieee80211_node ni; /* must be the first */
113 uint16_t disable_tid;
115 uint8_t ridx[IEEE80211_RATE_MAXSIZE];
116 struct ieee80211_amrr_node amn;
119 struct iwn_calib_state {
121 #define IWN_CALIB_STATE_INIT 0
122 #define IWN_CALIB_STATE_ASSOC 1
123 #define IWN_CALIB_STATE_RUN 2
129 uint32_t ofdm_mrc_x1;
131 uint32_t ofdm_mrc_x4;
134 uint32_t bad_plcp_ofdm;
136 uint32_t bad_plcp_cck;
140 #define IWN_CCK_STATE_INIT 0
141 #define IWN_CCK_STATE_LOFA 1
142 #define IWN_CCK_STATE_HIFA 2
144 uint8_t noise_samples[20];
145 u_int cur_noise_sample;
147 uint32_t energy_samples[10];
148 u_int cur_energy_sample;
152 struct iwn_calib_info {
166 struct iwn_fw_part init;
167 struct iwn_fw_part main;
168 struct iwn_fw_part boot;
172 int (*load_firmware)(struct iwn_softc *);
173 void (*read_eeprom)(struct iwn_softc *);
174 int (*post_alive)(struct iwn_softc *);
175 int (*nic_config)(struct iwn_softc *);
176 void (*update_sched)(struct iwn_softc *, int, int, uint8_t,
178 int (*get_temperature)(struct iwn_softc *);
179 int (*get_rssi)(struct iwn_softc *, struct iwn_rx_stat *);
180 int (*set_txpower)(struct iwn_softc *,
181 struct ieee80211_channel *, int);
182 int (*init_gains)(struct iwn_softc *);
183 int (*set_gains)(struct iwn_softc *);
184 int (*add_node)(struct iwn_softc *, struct iwn_node_info *,
186 void (*tx_done)(struct iwn_softc *, struct iwn_rx_desc *,
187 struct iwn_rx_data *);
189 void (*ampdu_tx_start)(struct iwn_softc *,
190 struct ieee80211_node *, uint8_t, uint16_t);
191 void (*ampdu_tx_stop)(struct iwn_softc *, uint8_t,
196 uint8_t broadcast_id;
199 uint32_t fw_text_maxsz;
200 uint32_t fw_data_maxsz;
202 bus_size_t sched_txfact_addr;
206 struct ieee80211vap iv_vap;
209 int (*iv_newstate)(struct ieee80211vap *,
210 enum ieee80211_state, int);
211 struct ieee80211_amrr iv_amrr;
213 #define IWN_VAP(_vap) ((struct iwn_vap *)(_vap))
216 struct arpcom arpcom;
217 struct ifnet *sc_ifp;
227 struct resource *mem;
228 struct resource *irq;
229 bus_dma_tag_t sc_dmat;
232 #define IWN_FLAG_HAS_5GHZ (1 << 0)
233 #define IWN_FLAG_HAS_OTPROM (1 << 1)
234 #define IWN_FLAG_CALIB_DONE (1 << 2)
235 #define IWN_FLAG_USE_ICT (1 << 3)
236 #define IWN_FLAG_INTERNAL_PA (1 << 4)
239 const struct iwn_hal *sc_hal;
241 const struct iwn_sensitivity_limits
244 /* TX scheduler rings. */
245 struct iwn_dma_info sched_dma;
249 /* "Keep Warm" page. */
250 struct iwn_dma_info kw_dma;
252 /* Firmware image. */
253 const struct firmware *fw_fp;
255 /* Firmware DMA transfer. */
256 struct iwn_dma_info fw_dma;
259 struct iwn_dma_info ict_dma;
264 struct iwn_tx_ring txq[IWN5000_NTXQUEUES];
265 struct iwn_rx_ring rxq;
267 bus_space_tag_t sc_st;
268 bus_space_handle_t sc_sh;
271 int sc_cap_off; /* PCIe Capabilities. */
273 /* Tasks used by the driver */
274 struct task sc_reinit_task;
275 struct task sc_radioon_task;
276 struct task sc_radiooff_task;
279 struct iwn_calib_state calib;
281 struct iwn_fw_info fw;
282 struct iwn_calib_info calibcmd[5];
285 struct iwn_rx_stat last_rx_stat;
287 struct iwn_ucode_info ucode_info;
288 struct iwn_rxon rxon;
295 struct iwn4965_eeprom_band
297 struct iwn_eeprom_chan eeprom_channels[IWN_NBANDS][IWN_MAX_CHAN_PER_BAND];
300 char eeprom_domain[4];
301 uint32_t eeprom_crystal;
302 int16_t eeprom_voltage;
305 int8_t maxpwr[IEEE80211_CHAN_MAX];
306 int8_t enh_maxpwr[35];
316 struct callout sc_timer_to;
319 struct iwn_rx_radiotap_header sc_rxtap;
320 struct iwn_tx_radiotap_header sc_txtap;
322 struct sysctl_ctx_list sc_sysctl_ctx;
323 struct sysctl_oid *sc_sysctl_tree;