if_iwnvar.h revision 1.9 1 1.9 christos /* $NetBSD: if_iwnvar.h,v 1.9 2010/04/16 01:40:41 christos Exp $ */
2 1.9 christos /* $OpenBSD: if_iwnvar.h,v 1.17 2010/02/17 18:23:00 damien Exp $ */
3 1.1 ober
4 1.1 ober /*-
5 1.6 christos * Copyright (c) 2007, 2008
6 1.1 ober * Damien Bergamini <damien.bergamini (at) free.fr>
7 1.1 ober *
8 1.1 ober * Permission to use, copy, modify, and distribute this software for any
9 1.1 ober * purpose with or without fee is hereby granted, provided that the above
10 1.1 ober * copyright notice and this permission notice appear in all copies.
11 1.1 ober *
12 1.1 ober * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 1.1 ober * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 1.1 ober * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 1.1 ober * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 1.1 ober * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 1.1 ober * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 1.1 ober * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 1.1 ober */
20 1.1 ober
21 1.9 christos /* XXX Added for NetBSD */
22 1.6 christos #define IEEE80211_NO_HT
23 1.6 christos
24 1.1 ober struct iwn_rx_radiotap_header {
25 1.1 ober struct ieee80211_radiotap_header wr_ihdr;
26 1.1 ober uint64_t wr_tsft;
27 1.1 ober uint8_t wr_flags;
28 1.1 ober uint8_t wr_rate;
29 1.1 ober uint16_t wr_chan_freq;
30 1.1 ober uint16_t wr_chan_flags;
31 1.1 ober int8_t wr_dbm_antsignal;
32 1.1 ober int8_t wr_dbm_antnoise;
33 1.1 ober } __packed;
34 1.1 ober
35 1.1 ober #define IWN_RX_RADIOTAP_PRESENT \
36 1.1 ober ((1 << IEEE80211_RADIOTAP_TSFT) | \
37 1.6 christos (1 << IEEE80211_RADIOTAP_FLAGS) | \
38 1.6 christos (1 << IEEE80211_RADIOTAP_RATE) | \
39 1.6 christos (1 << IEEE80211_RADIOTAP_CHANNEL) | \
40 1.6 christos (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
41 1.6 christos (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
42 1.1 ober
43 1.1 ober struct iwn_tx_radiotap_header {
44 1.1 ober struct ieee80211_radiotap_header wt_ihdr;
45 1.1 ober uint8_t wt_flags;
46 1.1 ober uint8_t wt_rate;
47 1.1 ober uint16_t wt_chan_freq;
48 1.1 ober uint16_t wt_chan_flags;
49 1.1 ober uint8_t wt_hwqueue;
50 1.1 ober } __packed;
51 1.1 ober
52 1.9 christos #define IWN_TX_RADIOTAP_PRESENT \
53 1.9 christos ((1 << IEEE80211_RADIOTAP_FLAGS) | \
54 1.9 christos (1 << IEEE80211_RADIOTAP_RATE) | \
55 1.6 christos (1 << IEEE80211_RADIOTAP_CHANNEL))
56 1.9 christos /* XXX OpenBSD also includes IEEE80211_RADIOTAP_HWQUEUE */
57 1.1 ober
58 1.1 ober struct iwn_dma_info {
59 1.1 ober bus_dma_tag_t tag;
60 1.1 ober bus_dmamap_t map;
61 1.1 ober bus_dma_segment_t seg;
62 1.1 ober bus_addr_t paddr;
63 1.1 ober void * vaddr;
64 1.1 ober bus_size_t size;
65 1.1 ober };
66 1.1 ober
67 1.1 ober struct iwn_tx_data {
68 1.1 ober bus_dmamap_t map;
69 1.6 christos bus_addr_t cmd_paddr;
70 1.6 christos bus_addr_t scratch_paddr;
71 1.1 ober struct mbuf *m;
72 1.1 ober struct ieee80211_node *ni;
73 1.1 ober };
74 1.1 ober
75 1.1 ober struct iwn_tx_ring {
76 1.1 ober struct iwn_dma_info desc_dma;
77 1.1 ober struct iwn_dma_info cmd_dma;
78 1.1 ober struct iwn_tx_desc *desc;
79 1.1 ober struct iwn_tx_cmd *cmd;
80 1.6 christos struct iwn_tx_data data[IWN_TX_RING_COUNT];
81 1.1 ober int qid;
82 1.1 ober int queued;
83 1.1 ober int cur;
84 1.1 ober };
85 1.1 ober
86 1.9 christos #define IWN_RBUF_COUNT (IWN_RX_RING_COUNT + 32)
87 1.1 ober
88 1.1 ober struct iwn_softc;
89 1.1 ober
90 1.1 ober struct iwn_rbuf {
91 1.1 ober struct iwn_softc *sc;
92 1.1 ober void * vaddr;
93 1.1 ober bus_addr_t paddr;
94 1.1 ober SLIST_ENTRY(iwn_rbuf) next;
95 1.1 ober };
96 1.1 ober
97 1.1 ober struct iwn_rx_data {
98 1.1 ober struct mbuf *m;
99 1.6 christos bus_dmamap_t map;
100 1.1 ober };
101 1.1 ober
102 1.1 ober struct iwn_rx_ring {
103 1.1 ober struct iwn_dma_info desc_dma;
104 1.6 christos struct iwn_dma_info stat_dma;
105 1.1 ober struct iwn_dma_info buf_dma;
106 1.1 ober uint32_t *desc;
107 1.6 christos struct iwn_rx_status *stat;
108 1.1 ober struct iwn_rx_data data[IWN_RX_RING_COUNT];
109 1.1 ober struct iwn_rbuf rbuf[IWN_RBUF_COUNT];
110 1.6 christos kmutex_t freelist_mtx;
111 1.1 ober SLIST_HEAD(, iwn_rbuf) freelist;
112 1.1 ober int nb_free_entries;
113 1.1 ober int cur;
114 1.1 ober };
115 1.1 ober
116 1.1 ober struct iwn_node {
117 1.1 ober struct ieee80211_node ni; /* must be the first */
118 1.1 ober struct ieee80211_amrr_node amn;
119 1.6 christos uint16_t disable_tid;
120 1.6 christos uint8_t id;
121 1.6 christos uint8_t ridx[IEEE80211_RATE_MAXSIZE];
122 1.1 ober };
123 1.1 ober
124 1.1 ober struct iwn_calib_state {
125 1.1 ober uint8_t state;
126 1.1 ober #define IWN_CALIB_STATE_INIT 0
127 1.1 ober #define IWN_CALIB_STATE_ASSOC 1
128 1.1 ober #define IWN_CALIB_STATE_RUN 2
129 1.1 ober
130 1.1 ober u_int nbeacons;
131 1.1 ober uint32_t noise[3];
132 1.1 ober uint32_t rssi[3];
133 1.6 christos uint32_t ofdm_x1;
134 1.6 christos uint32_t ofdm_mrc_x1;
135 1.6 christos uint32_t ofdm_x4;
136 1.6 christos uint32_t ofdm_mrc_x4;
137 1.6 christos uint32_t cck_x4;
138 1.6 christos uint32_t cck_mrc_x4;
139 1.1 ober uint32_t bad_plcp_ofdm;
140 1.1 ober uint32_t fa_ofdm;
141 1.1 ober uint32_t bad_plcp_cck;
142 1.1 ober uint32_t fa_cck;
143 1.1 ober uint32_t low_fa;
144 1.1 ober uint8_t cck_state;
145 1.1 ober #define IWN_CCK_STATE_INIT 0
146 1.1 ober #define IWN_CCK_STATE_LOFA 1
147 1.1 ober #define IWN_CCK_STATE_HIFA 2
148 1.1 ober
149 1.1 ober uint8_t noise_samples[20];
150 1.1 ober u_int cur_noise_sample;
151 1.1 ober uint8_t noise_ref;
152 1.1 ober uint32_t energy_samples[10];
153 1.1 ober u_int cur_energy_sample;
154 1.1 ober uint32_t energy_cck;
155 1.1 ober };
156 1.1 ober
157 1.6 christos struct iwn_calib_info {
158 1.6 christos uint8_t *buf;
159 1.6 christos u_int len;
160 1.6 christos };
161 1.6 christos
162 1.6 christos struct iwn_fw_part {
163 1.6 christos const uint8_t *text;
164 1.6 christos uint32_t textsz;
165 1.6 christos const uint8_t *data;
166 1.6 christos uint32_t datasz;
167 1.6 christos };
168 1.6 christos
169 1.6 christos struct iwn_fw_info {
170 1.6 christos u_char *data;
171 1.6 christos struct iwn_fw_part init;
172 1.6 christos struct iwn_fw_part main;
173 1.6 christos struct iwn_fw_part boot;
174 1.6 christos };
175 1.6 christos
176 1.6 christos struct iwn_hal {
177 1.6 christos int (*load_firmware)(struct iwn_softc *);
178 1.6 christos void (*read_eeprom)(struct iwn_softc *);
179 1.6 christos int (*post_alive)(struct iwn_softc *);
180 1.6 christos int (*nic_config)(struct iwn_softc *);
181 1.6 christos void (*update_sched)(struct iwn_softc *, int, int, uint8_t,
182 1.6 christos uint16_t);
183 1.6 christos int (*get_temperature)(struct iwn_softc *);
184 1.6 christos int (*get_rssi)(const struct iwn_rx_stat *);
185 1.6 christos int (*set_txpower)(struct iwn_softc *, int);
186 1.6 christos int (*init_gains)(struct iwn_softc *);
187 1.6 christos int (*set_gains)(struct iwn_softc *);
188 1.6 christos int (*add_node)(struct iwn_softc *, struct iwn_node_info *,
189 1.6 christos int);
190 1.6 christos void (*tx_done)(struct iwn_softc *, struct iwn_rx_desc *,
191 1.6 christos struct iwn_rx_data *);
192 1.6 christos #ifndef IEEE80211_NO_HT
193 1.6 christos void (*ampdu_tx_start)(struct iwn_softc *,
194 1.6 christos struct ieee80211_node *, uint8_t, uint16_t);
195 1.6 christos void (*ampdu_tx_stop)(struct iwn_softc *, uint8_t,
196 1.6 christos uint16_t);
197 1.6 christos #endif
198 1.6 christos int ntxqs;
199 1.9 christos int ndmachnls;
200 1.6 christos uint8_t broadcast_id;
201 1.6 christos int rxonsz;
202 1.6 christos int schedsz;
203 1.6 christos uint32_t fw_text_maxsz;
204 1.6 christos uint32_t fw_data_maxsz;
205 1.6 christos uint32_t fwsz;
206 1.6 christos bus_size_t sched_txfact_addr;
207 1.6 christos };
208 1.6 christos
209 1.1 ober struct iwn_softc {
210 1.6 christos device_t sc_dev;
211 1.6 christos
212 1.6 christos struct ethercom sc_ec;
213 1.1 ober struct ieee80211com sc_ic;
214 1.1 ober int (*sc_newstate)(struct ieee80211com *,
215 1.6 christos enum ieee80211_state, int);
216 1.1 ober
217 1.1 ober struct ieee80211_amrr amrr;
218 1.6 christos uint8_t fixed_ridx;
219 1.1 ober
220 1.1 ober bus_dma_tag_t sc_dmat;
221 1.1 ober
222 1.6 christos u_int sc_flags;
223 1.6 christos #define IWN_FLAG_HAS_5GHZ (1 << 0)
224 1.9 christos #define IWN_FLAG_HAS_OTPROM (1 << 1)
225 1.9 christos #define IWN_FLAG_CALIB_DONE (1 << 2)
226 1.9 christos #define IWN_FLAG_USE_ICT (1 << 3)
227 1.9 christos #define IWN_FLAG_INTERNAL_PA (1 << 4)
228 1.9 christos /* Added for NetBSD */
229 1.9 christos #define IWN_FLAG_SCANNING (1 << 8)
230 1.6 christos
231 1.6 christos uint8_t hw_type;
232 1.6 christos const struct iwn_hal *sc_hal;
233 1.6 christos const char *fwname;
234 1.9 christos const struct iwn_sensitivity_limits
235 1.9 christos *limits;
236 1.6 christos
237 1.6 christos /* TX scheduler rings. */
238 1.6 christos struct iwn_dma_info sched_dma;
239 1.6 christos uint16_t *sched;
240 1.6 christos uint32_t sched_base;
241 1.1 ober
242 1.6 christos /* "Keep Warm" page. */
243 1.1 ober struct iwn_dma_info kw_dma;
244 1.1 ober
245 1.6 christos /* Firmware DMA transfer. */
246 1.1 ober struct iwn_dma_info fw_dma;
247 1.1 ober
248 1.9 christos /* ICT table. */
249 1.9 christos struct iwn_dma_info ict_dma;
250 1.9 christos uint32_t *ict;
251 1.9 christos int ict_cur;
252 1.9 christos
253 1.6 christos /* TX/RX rings. */
254 1.6 christos struct iwn_tx_ring txq[IWN5000_NTXQUEUES];
255 1.1 ober struct iwn_rx_ring rxq;
256 1.1 ober
257 1.1 ober bus_space_tag_t sc_st;
258 1.1 ober bus_space_handle_t sc_sh;
259 1.1 ober void *sc_ih;
260 1.1 ober pci_chipset_tag_t sc_pct;
261 1.1 ober pcitag_t sc_pcitag;
262 1.1 ober bus_size_t sc_sz;
263 1.6 christos int sc_cap_off; /* PCIe Capabilities. */
264 1.9 christos struct sysmon_envsys *sc_sme;
265 1.9 christos envsys_data_t sc_sensor;
266 1.6 christos callout_t calib_to;
267 1.1 ober int calib_cnt;
268 1.1 ober struct iwn_calib_state calib;
269 1.1 ober
270 1.6 christos struct iwn_fw_info fw;
271 1.6 christos struct iwn_calib_info calibcmd[5];
272 1.6 christos uint32_t errptr;
273 1.6 christos
274 1.1 ober struct iwn_rx_stat last_rx_stat;
275 1.1 ober int last_rx_valid;
276 1.1 ober struct iwn_ucode_info ucode_info;
277 1.6 christos struct iwn_rxon rxon;
278 1.1 ober uint32_t rawtemp;
279 1.1 ober int temp;
280 1.1 ober int noise;
281 1.6 christos uint32_t qfullmsk;
282 1.1 ober
283 1.9 christos uint32_t prom_base;
284 1.6 christos struct iwn4965_eeprom_band
285 1.6 christos bands[IWN_NBANDS];
286 1.6 christos uint16_t rfcfg;
287 1.9 christos uint8_t calib_ver;
288 1.6 christos char eeprom_domain[4];
289 1.6 christos uint32_t eeprom_crystal;
290 1.1 ober int16_t eeprom_voltage;
291 1.1 ober int8_t maxpwr2GHz;
292 1.1 ober int8_t maxpwr5GHz;
293 1.1 ober int8_t maxpwr[IEEE80211_CHAN_MAX];
294 1.9 christos int8_t enh_maxpwr[35];
295 1.1 ober
296 1.9 christos int32_t temp_off;
297 1.9 christos uint32_t int_mask;
298 1.6 christos uint8_t ntxchains;
299 1.6 christos uint8_t nrxchains;
300 1.9 christos uint8_t txchainmask;
301 1.9 christos uint8_t rxchainmask;
302 1.9 christos uint8_t chainmask;
303 1.6 christos
304 1.1 ober int sc_tx_timer;
305 1.6 christos void *powerhook;
306 1.1 ober
307 1.7 pooka struct bpf_if * sc_drvbpf;
308 1.1 ober
309 1.1 ober union {
310 1.1 ober struct iwn_rx_radiotap_header th;
311 1.1 ober uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
312 1.1 ober } sc_rxtapu;
313 1.1 ober #define sc_rxtap sc_rxtapu.th
314 1.1 ober int sc_rxtap_len;
315 1.1 ober
316 1.1 ober union {
317 1.1 ober struct iwn_tx_radiotap_header th;
318 1.1 ober uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
319 1.1 ober } sc_txtapu;
320 1.1 ober #define sc_txtap sc_txtapu.th
321 1.1 ober int sc_txtap_len;
322 1.1 ober };
323 1.9 christos
324