1 | /* $NetBSD: if_malo_pcmciavar.h,v 1.2 2014/05/12 02:26:19 christos Exp $ */ |
2 | /* $OpenBSD: if_malovar.h,v 1.27 2007/10/09 20:37:32 mglocker Exp $ */ |
3 | |
4 | /* |
5 | * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> |
6 | * |
7 | * Permission to use, copy, modify, and distribute this software for any |
8 | * purpose with or without fee is hereby granted, provided that the above |
9 | * copyright notice and this permission notice appear in all copies. |
10 | * |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | */ |
19 | |
20 | /* simplify bus space access */ |
21 | #define MALO_READ_1(sc, reg) \ |
22 | bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, (reg)) |
23 | #define MALO_READ_2(sc, reg) \ |
24 | bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, (reg)) |
25 | #ifdef __BUS_SPACE_HAS_STREAM_METHODS |
26 | #define MALO_READ_MULTI_2(sc, reg, off, size) \ |
27 | bus_space_read_multi_stream_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (off), (size)) |
28 | #else |
29 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
30 | #define MALO_READ_MULTI_2(sc, reg, off, size) \ |
31 | bus_space_read_multi_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (off), (size)) |
32 | #else |
33 | #error not support bus_space_write_multi_stream_2() |
34 | #endif |
35 | #endif |
36 | #define MALO_WRITE_1(sc, reg, val) \ |
37 | bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, (reg), (val)) |
38 | #define MALO_WRITE_2(sc, reg, val) \ |
39 | bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (val)) |
40 | #ifdef __BUS_SPACE_HAS_STREAM_METHODS |
41 | #define MALO_WRITE_MULTI_2(sc, reg, off, size) \ |
42 | bus_space_write_multi_stream_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (off), (size)) |
43 | #else |
44 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
45 | #define MALO_WRITE_MULTI_2(sc, reg, off, size) \ |
46 | bus_space_write_multi_2((sc)->sc_iot, (sc)->sc_ioh, (reg), (off), (size)) |
47 | #else |
48 | #error not support bus_space_write_multi_stream_2() |
49 | #endif |
50 | #endif |
51 | |
52 | /* miscellaneous */ |
53 | #define MALO_FW_HELPER_BSIZE 256 /* helper FW block size */ |
54 | #define MALO_FW_HELPER_LOADED 0x10 /* helper FW loaded */ |
55 | #define MALO_FW_MAIN_MAXRETRY 20 /* main FW block resend max retry */ |
56 | #define MALO_CMD_BUFFER_SIZE 4096 /* cmd buffer */ |
57 | #define MALO_DATA_BUFFER_SIZE 4096 /* data buffer */ |
58 | |
59 | /* device flags */ |
60 | #define MALO_DEVICE_ATTACHED (1 << 0) |
61 | #define MALO_DEVICE_ENABLED (1 << 1) |
62 | #define MALO_FW_LOADED (1 << 2) |
63 | #define MALO_ASSOC_FAILED (1 << 3) |
64 | |
65 | /* |
66 | * FW command structures |
67 | */ |
68 | struct { |
69 | uint16_t ; |
70 | uint16_t ; |
71 | uint16_t ; |
72 | uint16_t ; |
73 | /* malo_cmd_body */ |
74 | }; |
75 | |
76 | struct malo_cmd_body_spec { |
77 | uint16_t hw_if_version; |
78 | uint16_t hw_version; |
79 | uint16_t num_of_wcb; |
80 | uint16_t num_of_mcast; |
81 | uint8_t macaddr[ETHER_ADDR_LEN]; |
82 | uint16_t regioncode; |
83 | uint16_t num_of_antenna; |
84 | uint32_t fw_version; |
85 | uint32_t wcbbase; |
86 | uint32_t rxpdrdptr; |
87 | uint32_t rxpdwrptr; |
88 | uint32_t fw_capinfo; |
89 | } __packed; |
90 | |
91 | struct malo_cmd_body_scan { |
92 | uint8_t bsstype; |
93 | uint8_t bssid[ETHER_ADDR_LEN]; |
94 | /* malo_cmd_tlv_ssid */ |
95 | /* malo_cmd_tlv_chanlist */ |
96 | /* malo_cmd_tlv_rates */ |
97 | /* malo_cmd_tlv_numprobes */ |
98 | } __packed; |
99 | |
100 | struct malo_cmd_body_rsp_scan { |
101 | uint16_t bufsize; |
102 | uint8_t numofset; |
103 | } __packed; |
104 | struct malo_cmd_body_rsp_scan_set { |
105 | uint16_t size; |
106 | uint8_t bssid[ETHER_ADDR_LEN]; |
107 | uint8_t rssi; |
108 | uint8_t timestamp[8]; |
109 | uint16_t beaconintvl; |
110 | uint16_t capinfo; |
111 | uint8_t data[0]; |
112 | } __packed; |
113 | |
114 | struct malo_cmd_body_auth { |
115 | uint8_t peermac[ETHER_ADDR_LEN]; |
116 | uint8_t authtype; |
117 | } __packed; |
118 | |
119 | #define MALO_WEP_ACTION_TYPE_ADD 0x02 |
120 | #define MALO_WEP_ACTION_TYPE_REMOVE 0x04 |
121 | #define MALO_WEP_ACTION_TYPE_DEFAULT 0x08 |
122 | #define MALO_WEP_KEY_TYPE_40BIT 0x01 |
123 | #define MALO_WEP_KEY_TYPE_104BIT 0x02 |
124 | struct malo_cmd_body_wep { |
125 | uint16_t action; |
126 | uint16_t key_index; |
127 | uint8_t key_type_1; |
128 | uint8_t key_type_2; |
129 | uint8_t key_type_3; |
130 | uint8_t key_type_4; |
131 | uint8_t key_value_1[16]; |
132 | uint8_t key_value_2[16]; |
133 | uint8_t key_value_3[16]; |
134 | uint8_t key_value_4[16]; |
135 | } __packed; |
136 | |
137 | #define MALO_OID_BSS 0x00 |
138 | #define MALO_OID_RATE 0x01 |
139 | #define MALO_OID_BCNPERIOD 0x02 |
140 | #define MALO_OID_DTIMPERIOD 0x03 |
141 | #define MALO_OID_ASSOCTIMEOUT 0x04 |
142 | #define MALO_OID_RTSTRESH 0x05 |
143 | #define MALO_OID_SHORTRETRY 0x06 |
144 | #define MALO_OID_LONGRETRY 0x07 |
145 | #define MALO_OID_FRAGTRESH 0x08 |
146 | #define MALO_OID_80211D 0x09 |
147 | #define MALO_OID_80211H 0x0a |
148 | struct malo_cmd_body_snmp { |
149 | uint16_t action; |
150 | uint16_t oid; |
151 | uint16_t size; |
152 | uint8_t data[128]; |
153 | } __packed; |
154 | |
155 | struct malo_cmd_body_radio { |
156 | uint16_t action; |
157 | uint16_t control; |
158 | } __packed; |
159 | |
160 | struct malo_cmd_body_channel { |
161 | uint16_t action; |
162 | uint16_t channel; |
163 | uint16_t rftype; |
164 | uint16_t reserved; |
165 | uint8_t channel_list[32]; |
166 | } __packed; |
167 | |
168 | struct malo_cmd_body_txpower { |
169 | uint16_t action; |
170 | int16_t txpower; |
171 | } __packed; |
172 | |
173 | struct malo_cmd_body_antenna { |
174 | uint16_t action; |
175 | uint16_t antenna_mode; |
176 | } __packed; |
177 | |
178 | struct malo_cmd_body_macctrl { |
179 | uint16_t action; |
180 | uint16_t reserved; |
181 | } __packed; |
182 | |
183 | struct malo_cmd_body_macaddr { |
184 | uint16_t action; |
185 | uint8_t macaddr[ETHER_ADDR_LEN]; |
186 | } __packed; |
187 | |
188 | struct malo_cmd_body_assoc { |
189 | uint8_t peermac[ETHER_ADDR_LEN]; |
190 | uint16_t capinfo; |
191 | uint16_t listenintrv; |
192 | uint16_t bcnperiod; |
193 | uint8_t dtimperiod; |
194 | /* malo_cmd_tlv_ssid */ |
195 | /* malo_cmd_tlv_phy */ |
196 | /* malo_cmd_tlv_cf */ |
197 | /* malo_cmd_tlv_rate */ |
198 | } __packed; |
199 | |
200 | struct malo_cmd_body_rsp_assoc { |
201 | uint16_t capinfo; |
202 | uint16_t status; |
203 | uint16_t assoc_id; |
204 | uint16_t info_len; |
205 | /* uint8_t info[270] */ |
206 | } __packed; |
207 | |
208 | struct malo_cmd_body_80211d { |
209 | uint16_t action; |
210 | /* malo_cmd_tlv_80211d */ |
211 | } __packed; |
212 | |
213 | struct malo_cmd_body_bgscan_config { |
214 | uint16_t action; |
215 | uint8_t enable; |
216 | uint8_t bsstype; |
217 | uint8_t chperscan; |
218 | uint8_t discard; |
219 | uint16_t reserved; |
220 | uint32_t scanintvl; |
221 | uint32_t storecond; |
222 | uint32_t reportcond; |
223 | uint16_t maxscanres; |
224 | } __packed; |
225 | |
226 | struct malo_cmd_body_bgscan_query { |
227 | uint8_t flush; |
228 | } __packed; |
229 | |
230 | #define MALO_RATE_BITMAP_DS1 (1 << 0) |
231 | #define MALO_RATE_BITMAP_DS2 (1 << 1) |
232 | #define MALO_RATE_BITMAP_DS5 (1 << 2) |
233 | #define MALO_RATE_BITMAP_DS11 (1 << 3) |
234 | #define MALO_RATE_BITMAP_OFDM6 (1 << 5) |
235 | #define MALO_RATE_BITMAP_OFDM9 (1 << 6) |
236 | #define MALO_RATE_BITMAP_OFDM12 (1 << 7) |
237 | #define MALO_RATE_BITMAP_OFDM18 (1 << 8) |
238 | #define MALO_RATE_BITMAP_OFDM24 (1 << 9) |
239 | #define MALO_RATE_BITMAP_OFDM36 (1 << 10) |
240 | #define MALO_RATE_BITMAP_OFDM48 (1 << 11) |
241 | #define MALO_RATE_BITMAP_OFDM54 (1 << 12) |
242 | #define MALO_RATE_BITMAP_AUTO 0x1fef |
243 | struct malo_cmd_body_rate { |
244 | uint16_t action; |
245 | uint16_t hwauto; |
246 | uint16_t ratebitmap; |
247 | } __packed; |
248 | |
249 | /* |
250 | * FW command TLV structures |
251 | */ |
252 | #define MALO_TLV_TYPE_SSID 0x0000 |
253 | #define MALO_TLV_TYPE_RATES 0x0001 |
254 | #define MALO_TLV_TYPE_PHY 0x0003 |
255 | #define MALO_TLV_TYPE_CF 0x0004 |
256 | #define MALO_TLV_TYPE_80211D 0x0007 |
257 | #define MALO_TLV_TYPE_CHANLIST 0x0101 |
258 | #define MALO_TLV_TYPE_NUMPROBES 0x0102 |
259 | #define MALO_TLV_TYPE_PASSEID 0x010a |
260 | |
261 | struct malo_cmd_tlv_ssid { |
262 | uint16_t type; |
263 | uint16_t size; |
264 | uint8_t data[0]; |
265 | } __packed; |
266 | |
267 | struct malo_cmd_tlv_rates { |
268 | uint16_t type; |
269 | uint16_t size; |
270 | uint8_t data[0]; |
271 | } __packed; |
272 | |
273 | struct malo_cmd_tlv_phy { |
274 | uint16_t type; |
275 | uint16_t size; |
276 | uint8_t data[0]; |
277 | } __packed; |
278 | |
279 | struct malo_cmd_tlv_cf { |
280 | uint16_t type; |
281 | uint16_t size; |
282 | uint8_t data[0]; |
283 | } __packed; |
284 | |
285 | struct malo_cmd_tlv_80211d_param { |
286 | uint8_t firstchannel; |
287 | uint8_t numchannels; |
288 | uint8_t maxtxpower; |
289 | } __packed; |
290 | struct malo_cmd_tlv_80211d { |
291 | uint16_t type; |
292 | uint16_t size; |
293 | uint8_t countrycode[3]; |
294 | struct malo_cmd_tlv_80211d_param data[12]; |
295 | } __packed; |
296 | |
297 | struct malo_cmd_tlv_chanlist_param { |
298 | uint8_t radiotype; |
299 | uint8_t channumber; |
300 | uint8_t scantype; |
301 | uint16_t minscantime; |
302 | uint16_t maxscantime; |
303 | } __packed; |
304 | #define CHANNELS 12 |
305 | struct malo_cmd_tlv_chanlist { |
306 | uint16_t type; |
307 | uint16_t size; |
308 | struct malo_cmd_tlv_chanlist_param data[CHANNELS]; |
309 | } __packed; |
310 | |
311 | struct malo_cmd_tlv_numprobes { |
312 | uint16_t type; |
313 | uint16_t size; |
314 | uint16_t numprobes; |
315 | } __packed; |
316 | |
317 | struct malo_cmd_tlv_passeid { |
318 | uint16_t type; |
319 | uint16_t size; |
320 | uint8_t data[0]; |
321 | } __packed; |
322 | |
323 | /* RX descriptor */ |
324 | #define MALO_RX_STATUS_OK 0x0001 |
325 | struct malo_rx_desc { |
326 | uint16_t status; |
327 | uint8_t snr; |
328 | uint8_t control; |
329 | uint16_t pkglen; |
330 | uint8_t nf; |
331 | uint8_t rate; |
332 | uint32_t pkgoffset; |
333 | uint32_t reserved1; |
334 | uint8_t priority; |
335 | uint8_t reserved2[3]; |
336 | } __packed; |
337 | |
338 | /* TX descriptor */ |
339 | struct malo_tx_desc { |
340 | uint32_t status; |
341 | uint32_t control; |
342 | uint32_t pkgoffset; |
343 | uint16_t pkglen; |
344 | uint8_t dstaddr[ETHER_ADDR_LEN]; |
345 | uint8_t priority; |
346 | uint8_t flags; |
347 | uint8_t reserved[2]; |
348 | } __packed; |
349 | |
350 | /* scanned network */ |
351 | struct malo_networks { |
352 | uint8_t bssid[ETHER_ADDR_LEN]; |
353 | uint8_t ; |
354 | uint8_t timestamp[8]; |
355 | uint16_t beaconintvl; |
356 | uint16_t capinfo; |
357 | uint8_t ssid[32]; |
358 | uint8_t rates[14]; |
359 | uint8_t channel; |
360 | } __packed; |
361 | |
362 | /* |
363 | * Softc |
364 | */ |
365 | struct malo_softc { |
366 | device_t sc_dev; |
367 | struct ethercom sc_ec; |
368 | #define sc_if sc_ec.ec_if |
369 | struct ieee80211com sc_ic; |
370 | bus_space_tag_t sc_iot; |
371 | bus_space_handle_t sc_ioh; |
372 | int (*sc_newstate) |
373 | (struct ieee80211com *, enum ieee80211_state, |
374 | int); |
375 | |
376 | int sc_flags; |
377 | uint8_t *sc_fw_h; |
378 | uint8_t *sc_fw_m; |
379 | size_t sc_fw_h_size; |
380 | size_t sc_fw_m_size; |
381 | int sc_cmd_ctxsave; |
382 | uint8_t *sc_cmd; |
383 | uint8_t *sc_data; |
384 | uint8_t sc_curchan; |
385 | int sc_net_num; |
386 | int sc_net_cur; |
387 | struct malo_networks sc_net[12]; |
388 | callout_t sc_scan_ch; |
389 | #if NBPFILTER > 0 |
390 | void *sc_drvbpf; |
391 | #endif |
392 | kcondvar_t sc_cv; |
393 | kmutex_t sc_mtx; |
394 | }; |
395 | |