if_iwnvar.h revision 1.13 1 1.13 christos /* $NetBSD: if_iwnvar.h,v 1.13 2011/05/15 13:56:20 christos Exp $ */
2 1.11 christos /* $OpenBSD: if_iwnvar.h,v 1.19 2010/05/05 19:47:43 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.11 christos size_t size;
172 1.6 christos struct iwn_fw_part init;
173 1.6 christos struct iwn_fw_part main;
174 1.6 christos struct iwn_fw_part boot;
175 1.6 christos };
176 1.6 christos
177 1.13 christos struct iwn_ops {
178 1.6 christos int (*load_firmware)(struct iwn_softc *);
179 1.6 christos void (*read_eeprom)(struct iwn_softc *);
180 1.6 christos int (*post_alive)(struct iwn_softc *);
181 1.6 christos int (*nic_config)(struct iwn_softc *);
182 1.6 christos void (*update_sched)(struct iwn_softc *, int, int, uint8_t,
183 1.6 christos uint16_t);
184 1.6 christos int (*get_temperature)(struct iwn_softc *);
185 1.6 christos int (*get_rssi)(const struct iwn_rx_stat *);
186 1.6 christos int (*set_txpower)(struct iwn_softc *, int);
187 1.6 christos int (*init_gains)(struct iwn_softc *);
188 1.6 christos int (*set_gains)(struct iwn_softc *);
189 1.6 christos int (*add_node)(struct iwn_softc *, struct iwn_node_info *,
190 1.6 christos int);
191 1.6 christos void (*tx_done)(struct iwn_softc *, struct iwn_rx_desc *,
192 1.6 christos struct iwn_rx_data *);
193 1.6 christos #ifndef IEEE80211_NO_HT
194 1.6 christos void (*ampdu_tx_start)(struct iwn_softc *,
195 1.6 christos struct ieee80211_node *, uint8_t, uint16_t);
196 1.6 christos void (*ampdu_tx_stop)(struct iwn_softc *, uint8_t,
197 1.6 christos uint16_t);
198 1.6 christos #endif
199 1.6 christos };
200 1.6 christos
201 1.1 ober struct iwn_softc {
202 1.6 christos device_t sc_dev;
203 1.6 christos
204 1.6 christos struct ethercom sc_ec;
205 1.1 ober struct ieee80211com sc_ic;
206 1.1 ober int (*sc_newstate)(struct ieee80211com *,
207 1.6 christos enum ieee80211_state, int);
208 1.1 ober
209 1.1 ober struct ieee80211_amrr amrr;
210 1.6 christos uint8_t fixed_ridx;
211 1.1 ober
212 1.1 ober bus_dma_tag_t sc_dmat;
213 1.1 ober
214 1.6 christos u_int sc_flags;
215 1.6 christos #define IWN_FLAG_HAS_5GHZ (1 << 0)
216 1.9 christos #define IWN_FLAG_HAS_OTPROM (1 << 1)
217 1.9 christos #define IWN_FLAG_CALIB_DONE (1 << 2)
218 1.9 christos #define IWN_FLAG_USE_ICT (1 << 3)
219 1.9 christos #define IWN_FLAG_INTERNAL_PA (1 << 4)
220 1.13 christos #define IWN_FLAG_HAS_11N (1 << 6)
221 1.13 christos #define IWN_FLAG_ENH_SENS (1 << 7)
222 1.9 christos /* Added for NetBSD */
223 1.9 christos #define IWN_FLAG_SCANNING (1 << 8)
224 1.12 christos #define IWN_FLAG_HW_INITED (1 << 9)
225 1.6 christos
226 1.6 christos uint8_t hw_type;
227 1.13 christos
228 1.13 christos struct iwn_ops ops;
229 1.6 christos const char *fwname;
230 1.9 christos const struct iwn_sensitivity_limits
231 1.9 christos *limits;
232 1.13 christos int ntxqs;
233 1.13 christos int ndmachnls;
234 1.13 christos uint8_t broadcast_id;
235 1.13 christos int rxonsz;
236 1.13 christos int schedsz;
237 1.13 christos uint32_t fw_text_maxsz;
238 1.13 christos uint32_t fw_data_maxsz;
239 1.13 christos uint32_t fwsz;
240 1.13 christos bus_size_t sched_txfact_addr;
241 1.6 christos
242 1.6 christos /* TX scheduler rings. */
243 1.6 christos struct iwn_dma_info sched_dma;
244 1.6 christos uint16_t *sched;
245 1.6 christos uint32_t sched_base;
246 1.1 ober
247 1.6 christos /* "Keep Warm" page. */
248 1.1 ober struct iwn_dma_info kw_dma;
249 1.1 ober
250 1.6 christos /* Firmware DMA transfer. */
251 1.1 ober struct iwn_dma_info fw_dma;
252 1.1 ober
253 1.9 christos /* ICT table. */
254 1.9 christos struct iwn_dma_info ict_dma;
255 1.9 christos uint32_t *ict;
256 1.9 christos int ict_cur;
257 1.9 christos
258 1.6 christos /* TX/RX rings. */
259 1.6 christos struct iwn_tx_ring txq[IWN5000_NTXQUEUES];
260 1.1 ober struct iwn_rx_ring rxq;
261 1.1 ober
262 1.1 ober bus_space_tag_t sc_st;
263 1.1 ober bus_space_handle_t sc_sh;
264 1.1 ober void *sc_ih;
265 1.1 ober pci_chipset_tag_t sc_pct;
266 1.1 ober pcitag_t sc_pcitag;
267 1.1 ober bus_size_t sc_sz;
268 1.6 christos int sc_cap_off; /* PCIe Capabilities. */
269 1.9 christos struct sysmon_envsys *sc_sme;
270 1.9 christos envsys_data_t sc_sensor;
271 1.6 christos callout_t calib_to;
272 1.1 ober int calib_cnt;
273 1.1 ober struct iwn_calib_state calib;
274 1.1 ober
275 1.6 christos struct iwn_fw_info fw;
276 1.6 christos struct iwn_calib_info calibcmd[5];
277 1.6 christos uint32_t errptr;
278 1.6 christos
279 1.1 ober struct iwn_rx_stat last_rx_stat;
280 1.1 ober int last_rx_valid;
281 1.1 ober struct iwn_ucode_info ucode_info;
282 1.6 christos struct iwn_rxon rxon;
283 1.1 ober uint32_t rawtemp;
284 1.1 ober int temp;
285 1.1 ober int noise;
286 1.6 christos uint32_t qfullmsk;
287 1.1 ober
288 1.9 christos uint32_t prom_base;
289 1.6 christos struct iwn4965_eeprom_band
290 1.6 christos bands[IWN_NBANDS];
291 1.6 christos uint16_t rfcfg;
292 1.9 christos uint8_t calib_ver;
293 1.6 christos char eeprom_domain[4];
294 1.6 christos uint32_t eeprom_crystal;
295 1.13 christos int16_t eeprom_temp;
296 1.1 ober int16_t eeprom_voltage;
297 1.1 ober int8_t maxpwr2GHz;
298 1.1 ober int8_t maxpwr5GHz;
299 1.1 ober int8_t maxpwr[IEEE80211_CHAN_MAX];
300 1.9 christos int8_t enh_maxpwr[35];
301 1.1 ober
302 1.9 christos int32_t temp_off;
303 1.9 christos uint32_t int_mask;
304 1.6 christos uint8_t ntxchains;
305 1.6 christos uint8_t nrxchains;
306 1.9 christos uint8_t txchainmask;
307 1.9 christos uint8_t rxchainmask;
308 1.9 christos uint8_t chainmask;
309 1.6 christos
310 1.1 ober int sc_tx_timer;
311 1.6 christos void *powerhook;
312 1.1 ober
313 1.7 pooka struct bpf_if * sc_drvbpf;
314 1.1 ober
315 1.1 ober union {
316 1.1 ober struct iwn_rx_radiotap_header th;
317 1.1 ober uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
318 1.1 ober } sc_rxtapu;
319 1.1 ober #define sc_rxtap sc_rxtapu.th
320 1.1 ober int sc_rxtap_len;
321 1.1 ober
322 1.1 ober union {
323 1.1 ober struct iwn_tx_radiotap_header th;
324 1.1 ober uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
325 1.1 ober } sc_txtapu;
326 1.1 ober #define sc_txtap sc_txtapu.th
327 1.1 ober int sc_txtap_len;
328 1.12 christos
329 1.12 christos kmutex_t sc_mtx; /* mutex for init/stop */
330 1.12 christos
331 1.1 ober };
332 1.9 christos
333