- In command RX intr, if the command number returned is 0, then hardware
[dragonfly.git] / sys / dev / netif / iwl / iwl2100var.h
blob433bf21eb8fdba755cbbaed52571eb69ae7bce00
1 /*
2 * Copyright (c) 2008 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Sepherosa Ziehau <sepherosa@gmail.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * $DragonFly: src/sys/dev/netif/iwl/iwl2100var.h,v 1.2 2008/03/08 06:43:52 sephe Exp $
37 #ifndef _IWL2100VAR_H
38 #define _IWL2100VAR_H
40 #define IWL2100_DEBUG
42 #define IWL2100_NSEG_MAX 6
43 #define IWL2100_TX_NDESC 256
44 #define IWL2100_RX_NDESC 256
46 #define IWL2100_SPARE_NDESC 6
47 #define IWL2100_TX_USED_MAX (IWL2100_TX_NDESC - IWL2100_SPARE_NDESC)
49 #define IWL2100_TXRING_SIZE (IWL2100_TX_NDESC * sizeof(struct iwl2100_desc))
50 #define IWL2100_RXRING_SIZE (IWL2100_RX_NDESC * sizeof(struct iwl2100_desc))
51 #define IWL2100_RXSTATUS_SIZE \
52 (IWL2100_RX_NDESC * sizeof(struct iwl2100_rx_status))
54 #ifndef IWL2100_DEBUG
55 #define DPRINTF(sc, flags, fmt, ...) ((void)0)
56 #else
57 #define DPRINTF(sc, flags, fmt, ...) \
58 do { \
59 if ((sc)->sc_debug & (flags)) \
60 if_printf(&(sc)->sc_ic.ic_if, fmt, __VA_ARGS__); \
61 } while (0)
62 #endif /* !IWL2100_DEBUG */
64 struct iwl2100_desc {
65 uint32_t d_paddr;
66 uint32_t d_len;
67 uint8_t d_flags; /* IWL2100_TXD_F_ */
68 uint8_t d_nfrag;
69 uint8_t d_reserved[6];
70 } __packed;
72 #define IWL2100_TXD_F_NOTLAST 0x1
73 #define IWL2100_TXD_F_CMD 0x2
74 #define IWL2100_TXD_F_INTR 0x8
76 struct iwl2100_tx_hdr {
77 uint32_t th_cmd;
78 uint32_t th_cmd1;
79 uint8_t th_host_enc;
80 uint8_t th_enc;
81 uint8_t th_keyidx;
82 uint8_t th_keysz;
83 uint8_t th_key[IEEE80211_KEYBUF_SIZE];
84 uint8_t th_reserved[10];
85 uint8_t th_src[IEEE80211_ADDR_LEN];
86 uint8_t th_dst[IEEE80211_ADDR_LEN];
87 uint16_t th_frag_size;
88 } __packed;
90 struct iwl2100_rx_status {
91 uint32_t r_len;
92 uint16_t r_status; /* IWL2100_RXS_ */
93 uint8_t r_flags;
94 uint8_t r_rssi;
95 } __packed;
97 #define IWL2100_RXS_TYPE_MASK 0xf
98 #define IWL2100_RXS_TYPE_CMD 0
99 #define IWL2100_RXS_TYPE_STATUS 1
100 #define IWL2100_RXS_TYPE_DATA 2
101 #define IWL2100_RXS_TYPE_DATA1 3
102 #define IWL2100_RXS_TYPE_NOTE 4
104 #define IWL2100_STATUS_RUNNING (1 << 2)
105 #define IWL2100_STATUS_BMISS (1 << 3)
106 #define IWL2100_STATUS_SCANDONE (1 << 5)
107 #define IWL2100_STATUS_SCANNING (1 << 11)
109 struct iwl2100_note {
110 uint32_t nt_subtype;
111 uint32_t nt_size;
112 } __packed;
114 #define IWL2100_CMD_PARAMSZ 100
116 struct iwl2100_cmd {
117 uint32_t c_cmd;
118 uint32_t c_cmd1;
119 uint32_t c_seq;
120 uint32_t c_param_len;
121 uint32_t c_param[IWL2100_CMD_PARAMSZ];
122 uint32_t c_status;
123 uint32_t c_unused[17];
124 } __packed;
126 struct iwl2100_cmdparam_sec {
127 uint32_t sec_cipher_mask; /* IWL2100_CIPHER_ */
128 uint16_t sec_ver;
129 uint8_t sec_authmode; /* IWL2100_AUTH_ */
130 uint8_t sec_replay_counter;
131 uint8_t sec_unused;
132 } __packed;
134 #define IWL2100_CIPHER_NONE (1 << 0)
135 #define IWL2100_CIPHER_WEP40 (1 << 1)
136 #define IWL2100_CIPHER_TKIP (1 << 2)
137 #define IWL2100_CIPHER_CCMP (1 << 4)
138 #define IWL2100_CIPHER_WEP104 (1 << 5)
140 #define IWL2100_AUTH_OPEN 0
141 #define IWL2100_AUTH_SHARED 1
143 #define IWL2100_KEYDATA_SIZE 13
145 struct iwl2100_cmdparam_wepkey {
146 uint8_t key_index;
147 uint8_t key_len;
148 uint8_t key_data[IWL2100_KEYDATA_SIZE];
149 } __packed;
151 /* 16: ie_fixed_mask + ie_fixed + ie_optlen */
152 #define IWL2100_OPTIE_MAX ((IWL2100_CMD_PARAMSZ * sizeof(uint32_t)) - 16)
154 struct iwl2100_cmdparam_ie {
155 uint16_t ie_fixed_mask;
156 struct {
157 uint16_t cap_info;
158 uint16_t lintval;
159 uint8_t bssid[IEEE80211_ADDR_LEN];
160 } ie_fixed;
161 uint32_t ie_optlen;
162 uint8_t ie_opt[IWL2100_OPTIE_MAX];
163 } __packed;
165 struct iwl2100_ucode_resp {
166 uint8_t cmd_id;
167 uint8_t seq_no;
168 uint8_t ucode_rev;
169 uint8_t eeprom_valid;
170 uint16_t valid_flags;
171 uint8_t addr[6];
172 uint16_t flags;
173 uint16_t pcb_rev;
174 uint16_t clk_settle_time;
175 uint16_t pwr_settle_time;
176 uint16_t hop_settle_time;
177 uint8_t date_time[5];
178 uint8_t ucode_valid;
179 } __packed;
181 struct iwl2100_fwdata_hdr {
182 uint32_t addr;
183 uint16_t len;
184 uint8_t data[1];
185 } __packed;
187 struct iwl2100_fwimg_hdr {
188 uint16_t version;
189 uint16_t mode; /* IWL2100_FW_M_ */
190 uint32_t data_size;
191 uint32_t ucode_size;
192 } __packed;
194 #define IWL2100_FW_M_STA 0
195 #define IWL2100_FW_M_IBSS 1
196 #define IWL2100_FW_M_MONITOR 2
198 struct iwl2100_txbuf {
199 struct mbuf *tb_mbuf;
200 bus_dmamap_t tb_dmap;
201 uint32_t tb_flags; /* IWL2100_TBF_ */
204 #define IWL2100_TBF_CMDBUF 0x1
206 struct iwl2100_rxbuf {
207 struct mbuf *rb_mbuf;
208 bus_dmamap_t rb_dmap;
209 bus_addr_t rb_paddr;
212 struct iwl2100_tx_ring {
213 bus_dma_tag_t tr_dtag;
214 bus_dmamap_t tr_dmap;
215 bus_addr_t tr_paddr;
216 struct iwl2100_desc *tr_desc;
218 int tr_used;
219 int tr_index;
220 int tr_coll;
222 struct iwl2100_txbuf tr_buf[IWL2100_TX_NDESC];
225 struct iwl2100_rx_ring {
226 bus_dma_tag_t rr_dtag;
227 bus_dmamap_t rr_dmap;
228 bus_addr_t rr_paddr;
229 struct iwl2100_desc *rr_desc;
231 bus_dma_tag_t rr_st_dtag;
232 bus_dmamap_t rr_st_dmap;
233 bus_addr_t rr_st_paddr;
234 struct iwl2100_rx_status *rr_status;
236 int rr_index;
238 bus_dmamap_t rr_tmp_dmap;
239 struct iwl2100_rxbuf rr_buf[IWL2100_RX_NDESC];
242 struct fw_image;
244 struct iwl2100_firmware {
245 struct fw_image *fw_image;
246 const uint8_t *fw_data;
247 int fw_data_size;
248 const uint8_t *fw_ucode;
249 int fw_ucode_size;
252 #define IWL2100_TX_RADIOTAP_PRESENT \
253 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
254 (1 << IEEE80211_RADIOTAP_CHANNEL))
256 struct iwl2100_tx_radiotap_hdr {
257 struct ieee80211_radiotap_header wt_ihdr;
258 uint8_t wt_flags;
259 uint16_t wt_chan_freq;
260 uint16_t wt_chan_flags;
263 #define IWL2100_RX_RADIOTAP_PRESENT \
264 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
265 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
266 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
267 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
269 struct iwl2100_rx_radiotap_hdr {
270 struct ieee80211_radiotap_header wr_ihdr;
271 uint8_t wr_flags;
272 uint16_t wr_chan_freq;
273 uint16_t wr_chan_flags;
274 int8_t wr_antsignal;
275 int8_t wr_antnoise;
278 struct iwl2100_softc {
279 struct iwlcom iwlcom;
281 uint32_t sc_ord1;
282 uint32_t sc_ord2;
283 uint32_t sc_caps; /* IWL2100_C_ */
284 uint32_t sc_flags; /* IWL2100_F_ */
285 int sc_state_age;
287 uint16_t sc_ibss_chans;
288 uint16_t sc_bss_chans;
290 bus_dma_tag_t sc_dtag;
291 bus_dma_tag_t sc_mbuf_dtag;
292 struct iwl2100_tx_ring sc_txring;
293 struct iwl2100_rx_ring sc_rxring;
295 struct iwl2100_firmware sc_fw_sta;
296 struct iwl2100_firmware sc_fw_ibss;
297 struct iwl2100_firmware sc_fw_monitor;
299 struct mbuf *sc_cmd;
301 struct callout sc_restart_bmiss;
302 struct callout sc_ibss;
303 struct callout sc_reinit;
305 struct iwlmsg sc_scanend_msg;
306 struct iwlmsg sc_assoc_msg;
307 struct iwlmsg sc_run_msg;
308 struct iwlmsg sc_restart_msg;
309 struct iwlmsg sc_bmiss_msg;
310 struct iwlmsg sc_reinit_msg;
312 struct bpf_if *sc_drvbpf;
314 union {
315 struct iwl2100_tx_radiotap_hdr u_tx_th;
316 uint8_t u_pad[IEEE80211_RADIOTAP_HDRLEN];
317 } sc_u_tx_th;
318 int sc_tx_th_len;
320 union {
321 struct iwl2100_rx_radiotap_hdr u_rx_th;
322 uint8_t u_pad[IEEE80211_RADIOTAP_HDRLEN];
323 } sc_u_rx_th;
324 int sc_rx_th_len;
326 int (*sc_newstate)
327 (struct ieee80211com *,
328 enum ieee80211_state, int);
331 * Sysctl variables
333 uint32_t sc_debug; /* IWL2100_DBG_ */
336 #define IWL2100_C_RFKILL 0x1
338 #define IWL2100_F_WAITCMD 0x1
339 #define IWL2100_F_INITED 0x2
340 #define IWL2100_F_IN_INTR 0x4 /* for sanity check */
341 #define IWL2100_F_SCANNING 0x8
342 #define IWL2100_F_RESTARTING 0x10
343 #define IWL2100_F_IFSTART 0x20 /* if_start could run */
344 #define IWL2100_F_ERROR 0x40
345 #define IWL2100_F_ZERO_CMD 0x80
346 #define IWL2100_F_DETACH 0x100 /* detaching */
348 #define IWL2100_DBG_IBSS 0x01
349 #define IWL2100_DBG_SCAN 0x02
350 #define IWL2100_DBG_STATUS 0x04
351 #define IWL2100_DBG_RESTART 0x08
352 #define IWL2100_DBG_NOTE 0x10
353 #define IWL2100_DBG_CMD 0x20
355 #define IWL2100_PCIR_BAR PCIR_BAR(0)
356 #define IWL2100_DESC "Intel PRO/Wireless LAN 2100"
357 #define IWL2100_FW_PATH IWL_FW_PATH "2100/1.3/ipw2100-1.3%s.fw"
359 int iwl2100_attach(device_t);
360 void iwl2100_detach(device_t);
361 int iwl2100_shutdown(device_t);
363 #endif /* _IWL2100VAR_H */