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