xref: /titanic_51/usr/src/uts/common/io/ipw/ipw2100_impl.h (revision dfb96a4f56fb431b915bc67e5d9d5c8d4f4f6679)
1 /*
2  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright(c) 2004
8  *	Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice unmodified, this list of conditions, and the following
15  *    disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 #ifndef _SYS_IPW2100_IMPL_H
34 #define	_SYS_IPW2100_IMPL_H
35 
36 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Intel Wireless PRO/2100 mini-PCI adapter driver
44  * ipw2100_impl.h includes:
45  * 	. implementation of ipw2100
46  * 	. hardware operation and interface define for ipw2100
47  * 	. firmware operation and interface define for ipw2100
48  */
49 #include <sys/ddi.h>
50 #include <sys/sunddi.h>
51 #include <sys/mac.h>
52 #include <sys/net80211.h>
53 
54 /*
55  * Implementation of ipw2100
56  */
57 #define	IPW2100_NODENAME	"ipw"
58 
59 #define	IPW2100_PCI_CFG_RNUM	(0) /* pci config space */
60 #define	IPW2100_PCI_CSR_RNUM	(1) /* device CSR space */
61 
62 #define	IPW2100_NUM_TXBD    (128)
63 #define	IPW2100_TXBD_SIZE   (IPW2100_NUM_TXBD * sizeof (struct ipw2100_bd))
64 #define	IPW2100_NUM_TXBUF   (IPW2100_NUM_TXBD/2)  /* ipw2100_txb number */
65 #define	IPW2100_TXBUF_SIZE  (sizeof (struct ipw2100_txb))
66 
67 #define	IPW2100_NUM_RXBD    (128)
68 #define	IPW2100_STATUS_SIZE (IPW2100_NUM_RXBD * sizeof (struct ipw2100_status))
69 #define	IPW2100_RXBD_SIZE   (IPW2100_NUM_RXBD * sizeof (struct ipw2100_bd))
70 #define	IPW2100_NUM_RXBUF   (IPW2100_NUM_RXBD)
71 #define	IPW2100_RXBUF_SIZE  (sizeof (struct ipw2100_rxb))
72 
73 #define	IPW2100_CMD_SIZE    (sizeof (struct ipw2100_cmd))
74 
75 struct dma_region {
76 	ddi_dma_handle_t	dr_hnd;
77 	ddi_acc_handle_t	dr_acc;
78 	ddi_dma_cookie_t	dr_cookie;
79 	uint_t			dr_ccnt;
80 	uint32_t		dr_pbase;
81 	caddr_t			dr_base;
82 	size_t			dr_size;
83 	const char		*dr_name;
84 };
85 
86 struct ipw2100_firmware {
87 	uint8_t			*bin_base; /* image */
88 	size_t			bin_size;
89 	uint8_t			*fw_base; /* firmware code */
90 	size_t			fw_size;
91 	uint8_t			*uc_base; /* u-controller code */
92 	size_t			uc_size;
93 };
94 
95 /*
96  * per-instance soft-state structure
97  */
98 struct ipw2100_softc {
99 	struct ieee80211com	sc_ic;
100 	dev_info_t		*sc_dip;
101 	int	(*sc_newstate)(struct ieee80211com *,
102 	    enum ieee80211_state, int);
103 	int			sc_authmode;
104 	/* CSR */
105 	ddi_acc_handle_t	sc_ioh;
106 	caddr_t			sc_regs;
107 	/* interrupt */
108 	ddi_iblock_cookie_t	sc_iblk;
109 	/* soft interrupt */
110 	ddi_softintr_t		sc_link_softint;
111 	/* link state */
112 	int32_t			sc_linkstate;
113 	/* mutex to protect interrupt handler */
114 	kmutex_t		sc_ilock;
115 	kcondvar_t		sc_fw_cond;
116 	/* flags */
117 	uint_t			sc_flags;
118 #define	IPW2100_FLAG_FW_CACHED		(1 << 0)
119 #define	IPW2100_FLAG_FW_INITED		(1 << 1)
120 #define	IPW2100_FLAG_RUNNING		(1 << 2)
121 #define	IPW2100_FLAG_LINK_CHANGE	(1 << 3)
122 #define	IPW2100_FLAG_TX_SCHED		(1 << 4)
123 #define	IPW2100_FLAG_CMD_WAIT		(1 << 5)
124 #define	IPW2100_FLAG_SCAN_COMPLETE	(1 << 6)
125 #define	IPW2100_FLAG_HW_ERR_RECOVER	(1 << 7)
126 #define	IPW2100_FLAG_HAS_RADIO_SWITCH	(1 << 16)
127 	/* command */
128 	struct ipw2100_cmd	*sc_cmd;
129 	int			sc_done; /* command is done */
130 	kcondvar_t		sc_cmd_cond;
131 	/* reschedule lock */
132 	kmutex_t		sc_resched_lock;
133 	/* tx ring, bd->hdr&buf */
134 	kmutex_t		sc_tx_lock;
135 	kcondvar_t		sc_tx_cond;
136 	uint32_t		sc_tx_cur;
137 	uint32_t		sc_tx_free;
138 	struct ipw2100_bd	*sc_txbd;
139 	struct ipw2100_txb	*sc_txbufs[IPW2100_NUM_TXBUF];
140 	/* rx ring, status, bd->buf */
141 	uint32_t		sc_rx_cur;
142 	uint32_t		sc_rx_free;
143 	struct ipw2100_status	*sc_status;
144 	struct ipw2100_bd	*sc_rxbd;
145 	struct ipw2100_rxb	*sc_rxbufs[IPW2100_NUM_RXBUF];
146 	/* DMA resources */
147 	struct dma_region	sc_dma_txbd; /* tx buffer descriptor */
148 	struct dma_region	sc_dma_txbufs[IPW2100_NUM_TXBUF];
149 	struct dma_region	sc_dma_rxbd; /* rx buffer descriptor */
150 	struct dma_region	sc_dma_rxbufs[IPW2100_NUM_RXBUF];
151 	struct dma_region	sc_dma_status;
152 	struct dma_region	sc_dma_cmd; /* command */
153 	/* hw configuration values */
154 	uint8_t			sc_macaddr[IEEE80211_ADDR_LEN];
155 	uint16_t		sc_chmask;
156 	/* MAC address string */
157 	char			sc_macstr[32];
158 	/* tables */
159 	uint32_t		sc_table1_base;
160 	uint32_t		sc_table2_base;
161 	/* firmware */
162 	struct			ipw2100_firmware sc_fw;
163 	/* mfthread related */
164 	kmutex_t		sc_mflock;
165 	kcondvar_t		sc_mfthread_cv;
166 	kcondvar_t		sc_scan_cv; /* used for active scan */
167 	kthread_t		*sc_mf_thread;
168 	uint32_t		sc_mfthread_switch; /* 0/1 indicate off/on */
169 
170 	int			if_flags;
171 #define	IFF_DEBUG		(0x0004)
172 #define	IFF_PROMISC		(0x0100)
173 #define	IFF_SIMPLEX		(0x0800)
174 
175 };
176 
177 /*
178  * RING_BACKWARD  - move 'x' backward 's' steps in a 'b'-sized ring
179  * RING_FORWARD   - move 'x' forward 's' steps in a 'b'-sized ring
180  *
181  * note that there must be 0 <= 'x' < 'b' && 0 <= 's' < 'b'
182  */
183 #define	RING_FLEN(x, y, b)	((((x) > (y)) ? ((b)+(y)-(x)) : ((y)-(x))))
184 #define	RING_FORWARD(x, s, b)	(((x)+(s))%(b))
185 #define	RING_BACKWARD(x, s, b)	RING_FORWARD((x), (b)-(s), (b))
186 
187 /*
188  * field_offset
189  */
190 #define	OFFSETOF(s, m)		((size_t)(&(((s *)0)->m)))
191 
192 extern int ipw2100_init(struct ipw2100_softc *sc);
193 extern int ipw2100_disable(struct ipw2100_softc *sc);
194 
195 /*
196  * Below structure and functions will be used for statistic
197  */
198 struct statistic {
199 	int		index;
200 	const char	*desc;
201 	int		unit;
202 #define	INT		1
203 #define	HEX		2
204 #define	MASK		HEX
205 #define	PERCENTAGE	3
206 #define	BOOL		4
207 };
208 extern void ipw2100_get_statistics(struct ipw2100_softc *sc);
209 
210 /*
211  * Hardware related definations and interfaces.
212  */
213 #define	IPW2100_CSR_INTR		(0x0008)
214 #define	IPW2100_CSR_INTR_MASK		(0x000c)
215 #define	IPW2100_CSR_INDIRECT_ADDR	(0x0010)
216 #define	IPW2100_CSR_INDIRECT_DATA	(0x0014)
217 #define	IPW2100_CSR_AUTOINC_ADDR	(0x0018)
218 #define	IPW2100_CSR_AUTOINC_DATA	(0x001c)
219 #define	IPW2100_CSR_RST			(0x0020)
220 #define	IPW2100_CSR_CTL			(0x0024)
221 #define	IPW2100_CSR_IO			(0x0030)
222 #define	IPW2100_CSR_DEBUG_AREA		(0x0090)
223 
224 #define	IPW2100_CSR_TX_BD_BASE		(0x0200)
225 #define	IPW2100_CSR_TX_BD_SIZE		(0x0204)
226 #define	IPW2100_CSR_RX_BD_BASE		(0x0240)
227 #define	IPW2100_CSR_RX_STATUS_BASE	(0x0244)
228 #define	IPW2100_CSR_RX_BD_SIZE		(0x0248)
229 #define	IPW2100_CSR_TABLE1_BASE		(0x0380)
230 #define	IPW2100_CSR_TABLE2_BASE		(0x0384)
231 /*
232  * tx-rd-index  the entry to be processed by HW, i.e. empty tx buffer
233  * tx-wr-index  the entry just being filled by SW with new data to transmit
234  */
235 #define	IPW2100_CSR_TX_READ_INDEX	(0x0280)
236 #define	IPW2100_CSR_TX_WRITE_INDEX	(0x0f80)
237 /*
238  * rx-rd-index  the entry just being processed by HW, i.e. new received data
239  * rx-wr-index  the entry just being set by SW to empty buffer to receive
240  */
241 #define	IPW2100_CSR_RX_READ_INDEX	(0x02a0)
242 #define	IPW2100_CSR_RX_WRITE_INDEX	(0x0fa0)
243 
244 /*
245  * CSR flags: IPW2100_CSR_INTR
246  * The interrupt register is used to indicate the h/w status
247  */
248 #define	IPW2100_INTR_TX_TRANSFER	(0x00000001)
249 #define	IPW2100_INTR_RX_TRANSFER	(0x00000002)
250 #define	IPW2100_INTR_STATUS_CHANGE	(0x00000010)
251 #define	IPW2100_INTR_COMMAND_DONE	(0x00010000)
252 #define	IPW2100_INTR_FW_INIT_DONE	(0x01000000)
253 #define	IPW2100_INTR_FATAL_ERROR	(0x40000000)
254 #define	IPW2100_INTR_PARITY_ERROR	(0x80000000)
255 #define	IPW2100_INTR_MASK_ALL	(IPW2100_INTR_TX_TRANSFER | \
256 				IPW2100_INTR_RX_TRANSFER | \
257 				IPW2100_INTR_STATUS_CHANGE | \
258 				IPW2100_INTR_COMMAND_DONE | \
259 				IPW2100_INTR_FW_INIT_DONE | \
260 				IPW2100_INTR_FATAL_ERROR | \
261 				IPW2100_INTR_PARITY_ERROR)
262 #define	IPW2100_INTR_MASK_ERR	(IPW2100_INTR_FATAL_ERROR | \
263 				IPW2100_INTR_PARITY_ERROR)
264 
265 /*
266  * CSR flags: IPW2100_CSR_RST
267  * The reset register is used to reset hardware
268  */
269 #define	IPW2100_RST_PRINCETON_RESET	(0x00000001)
270 #define	IPW2100_RST_SW_RESET		(0x00000080)
271 #define	IPW2100_RST_MASTER_DISABLED	(0x00000100)
272 #define	IPW2100_RST_STOP_MASTER		(0x00000200)
273 
274 /*
275  * CSR flags: IPW2100_CSR_CTL
276  */
277 #define	IPW2100_CTL_CLOCK_READY		(0x00000001)
278 #define	IPW2100_CTL_ALLOW_STANDBY	(0x00000002)
279 #define	IPW2100_CTL_INIT		(0x00000004)
280 
281 /*
282  * CSR flags: IPW2100_CSR_IO
283  */
284 #define	IPW2100_IO_GPIO1_ENABLE		(0x00000008)
285 #define	IPW2100_IO_GPIO1_MASK		(0x0000000c)
286 #define	IPW2100_IO_GPIO3_MASK		(0x000000c0)
287 #define	IPW2100_IO_LED_OFF		(0x00002000)
288 #define	IPW2100_IO_RADIO_DISABLED	(0x00010000)
289 
290 /*
291  * States code
292  */
293 #define	IPW2100_STATE_ASSOCIATED	(0x0004)
294 #define	IPW2100_STATE_ASSOCIATION_LOST	(0x0008)
295 #define	IPW2100_STATE_SCAN_COMPLETE	(0x0020)
296 #define	IPW2100_STATE_RADIO_DISABLED	(0x0100)
297 #define	IPW2100_STATE_DISABLED		(0x0200)
298 #define	IPW2100_STATE_SCANNING		(0x0800)
299 
300 /*
301  * table1 offsets
302  */
303 #define	IPW2100_INFO_LOCK		(480)
304 #define	IPW2100_INFO_APS_CNT		(604)
305 #define	IPW2100_INFO_APS_BASE		(608)
306 #define	IPW2100_INFO_CARD_DISABLED	(628)
307 #define	IPW2100_INFO_CURRENT_CHANNEL	(756)
308 #define	IPW2100_INFO_CURRENT_TX_RATE	(768)
309 
310 /*
311  * table2 offsets
312  */
313 #define	IPW2100_INFO_CURRENT_SSID	(48)
314 #define	IPW2100_INFO_CURRENT_BSSID	(112)
315 
316 /*
317  * supported rates
318  */
319 #define	IPW2100_RATE_DS1		(1)
320 #define	IPW2100_RATE_DS2		(2)
321 #define	IPW2100_RATE_DS5		(4)
322 #define	IPW2100_RATE_DS11		(8)
323 
324 /* hw structures, packed */
325 #pragma pack(1)
326 /*
327  * firmware binary image header
328  */
329 struct ipw2100_firmware_hdr {
330 	uint32_t	version;
331 	uint32_t	fw_size;
332 	uint32_t	uc_size;
333 };
334 
335 /*
336  * buffer descriptor
337  */
338 struct ipw2100_bd {
339 	uint32_t	phyaddr;
340 	uint32_t	len;
341 	uint8_t		flags;
342 /* flags */
343 #define	IPW2100_BD_FLAG_TX_LAST_FRAGMENT	(0x08)
344 #define	IPW2100_BD_FLAG_TX_NOT_LAST_FRAGMENT	(0x01)
345 /* data content */
346 #define	IPW2100_BD_FLAG_TX_FRAME_802_3		(0x00)
347 #define	IPW2100_BD_FLAG_TX_FRAME_COMMAND	(0x02)
348 #define	IPW2100_BD_FLAG_TX_FRAME_802_11		(0x04)
349 	/* number of fragments, only 1st BD is needed */
350 	uint8_t		nfrag;
351 	uint8_t		reserved[6];
352 };
353 
354 /*
355  * status descriptor
356  */
357 struct ipw2100_status {
358 	uint32_t	len;
359 	uint16_t	code;
360 #define	IPW2100_STATUS_CODE_COMMAND		(0)
361 #define	IPW2100_STATUS_CODE_NEWSTATE		(1)
362 #define	IPW2100_STATUS_CODE_DATA_802_11		(2)
363 #define	IPW2100_STATUS_CODE_DATA_802_3		(3)
364 #define	IPW2100_STATUS_CODE_NOTIFICATION	(4)
365 	uint8_t		flags;
366 #define	IPW2100_STATUS_FLAG_DECRYPTED		(0x01)
367 #define	IPW2100_STATUS_FLAG_WEP_ENCRYPTED	(0x02)
368 #define	IPW2100_STATUS_FLAG_CRC_ERROR		(0x04)
369 	/* received signal strength indicator */
370 	uint8_t		rssi;
371 };
372 
373 /*
374  * data header
375  */
376 struct ipw2100_hdr {
377 	uint32_t	type;
378 	uint32_t	subtype;
379 	uint8_t		encrypted;
380 	uint8_t		encrypt;
381 	uint8_t		keyidx;
382 	uint8_t		keysz;
383 	uint8_t		key[IEEE80211_KEYBUF_SIZE];
384 	uint8_t		reserved[10];
385 	uint8_t		saddr[IEEE80211_ADDR_LEN];
386 	uint8_t		daddr[IEEE80211_ADDR_LEN];
387 	uint16_t	fragsz;
388 };
389 
390 /*
391  * command
392  */
393 struct ipw2100_cmd {
394 	uint32_t	type;
395 #define	IPW2100_CMD_ENABLE			(2)
396 #define	IPW2100_CMD_SET_CONFIGURATION		(6)
397 #define	IPW2100_CMD_SET_ESSID			(8)
398 #define	IPW2100_CMD_SET_MANDATORY_BSSID		(9)
399 #define	IPW2100_CMD_SET_AUTH_TYPE		(10)
400 #define	IPW2100_CMD_SET_MAC_ADDRESS		(11)
401 #define	IPW2100_CMD_SET_MODE			(12)
402 #define	IPW2100_CMD_SET_I18N_MODE		(13)
403 #define	IPW2100_CMD_SET_CHANNEL			(14)
404 #define	IPW2100_CMD_SET_RTS_THRESHOLD		(15)
405 #define	IPW2100_CMD_SET_FRAG_THRESHOLD		(16)
406 #define	IPW2100_CMD_SET_POWER_MODE		(17)
407 #define	IPW2100_CMD_SET_TX_RATES		(18)
408 #define	IPW2100_CMD_SET_BASIC_TX_RATES		(19)
409 #define	IPW2100_CMD_SET_WEP_KEY			(20)
410 #define	IPW2100_CMD_SET_WEP_KEY_INDEX		(25)
411 #define	IPW2100_CMD_SET_WEP_FLAGS		(26)
412 #define	IPW2100_CMD_ADD_MULTICAST		(27)
413 #define	IPW2100_CMD_CLR_MULTICAST		(28)
414 #define	IPW2100_CMD_SET_BEACON_INTERVAL		(29)
415 #define	IPW2100_CMD_CLR_STATISTICS		(31)
416 #define	IPW2100_CMD_SEND			(33)
417 #define	IPW2100_CMD_SET_TX_POWER_INDEX		(36)
418 #define	IPW2100_CMD_BROADCAST_SCAN		(43)
419 #define	IPW2100_CMD_DISABLE			(44)
420 #define	IPW2100_CMD_SET_DESIRED_BSSID		(45)
421 #define	IPW2100_CMD_SET_SCAN_OPTIONS		(46)
422 #define	IPW2100_CMD_PREPARE_POWER_DOWN		(58)
423 #define	IPW2100_CMD_DISABLE_PHY			(61)
424 #define	IPW2100_CMD_SET_SECURITY_INFORMATION	(67)
425 #define	IPW2100_CMD_SET_WPA_IE			(69)
426 	uint32_t	subtype;
427 	uint32_t	seq;
428 	uint32_t	len;
429 	uint8_t		data[400];
430 	uint32_t	status;
431 	uint8_t		reserved[68];
432 };
433 
434 /*
435  * IPW2100_CMD_SET_POWER_MODE
436  */
437 #define	IPW2100_POWER_MODE_CAM	(0)
438 #define	IPW2100_POWER_AUTOMATIC	(6)
439 
440 /*
441  * IPW2100_CMD_SET_MODE
442  */
443 #define	IPW2100_MODE_BSS	(0)
444 #define	IPW2100_MODE_IBSS	(1)
445 #define	IPW2100_MODE_MONITOR	(2)
446 
447 /*
448  * structure for IPW2100_CMD_SET_WEP_KEY
449  */
450 struct ipw2100_wep_key {
451 	uint8_t		idx;
452 	uint8_t		len;
453 	uint8_t		key[13];
454 };
455 
456 /*
457  * structure for IPW2100_CMD_SET_SECURITY_INFORMATION
458  */
459 struct ipw2100_security {
460 	uint32_t	ciphers;
461 #define	IPW2100_CIPHER_NONE	(0x00000001)
462 #define	IPW2100_CIPHER_WEP40	(0x00000002)
463 #define	IPW2100_CIPHER_WEP104	(0x00000020)
464 	uint16_t	version;
465 	uint8_t		authmode;
466 #define	IPW2100_AUTH_OPEN	(0)
467 #define	IPW2100_AUTH_SHARED	(1)
468 	uint8_t		replay_counters_number;
469 	uint8_t		unicast_using_group;
470 };
471 
472 /*
473  * structure for IPW2100_CMD_SET_SCAN_OPTIONS
474  */
475 struct ipw2100_scan_options {
476 	uint32_t	flags;
477 #define	IPW2100_SCAN_DO_NOT_ASSOCIATE	(0x00000001)
478 #define	IPW2100_SCAN_PASSIVE		(0x00000008)
479 	uint32_t	channels;
480 };
481 
482 /*
483  * structure for IPW2100_CMD_SET_CONFIGURATION
484  */
485 struct ipw2100_configuration {
486 	uint32_t	flags;
487 #define	IPW2100_CFG_PROMISCUOUS		(0x00000004)
488 #define	IPW2100_CFG_PREAMBLE_AUTO	(0x00000010)
489 #define	IPW2100_CFG_IBSS_AUTO_START	(0x00000020)
490 #define	IPW2100_CFG_802_1x_ENABLE	(0x00004000)
491 #define	IPW2100_CFG_BSS_MASK		(0x00008000)
492 #define	IPW2100_CFG_IBSS_MASK		(0x00010000)
493 	uint32_t	bss_chan;
494 	uint32_t	ibss_chan;
495 };
496 
497 /*
498  * element in AP table
499  */
500 struct ipw2100_node {
501 	uint32_t	reserved_1[2];
502 	uint8_t		bssid[IEEE80211_ADDR_LEN];
503 	uint8_t		chan;
504 	uint8_t		rates;
505 	uint16_t	reserved_2;
506 	uint16_t	capinfo;
507 	uint16_t	reserved_3;
508 	uint16_t	intval;
509 	uint8_t		reserved_4[28];
510 	uint8_t		essid[IEEE80211_NWID_LEN];
511 	uint16_t	reserved_5;
512 	uint8_t		esslen;
513 	uint8_t		reserved_6[7];
514 	uint8_t		rssi;
515 };
516 #pragma pack()
517 
518 /*
519  * transmit buffer block
520  */
521 struct ipw2100_txb {
522 	struct ipw2100_hdr	txb_hdr; /* header */
523 	uint8_t			txb_dat[IEEE80211_MAX_LEN]; /* payload */
524 };
525 
526 /*
527  * maximum frame header lenght: 4 MAC addresses + 1 fc + 1 id + 1 seqctl
528  */
529 #define	IEEE80211_MAX_FHLEN	(4*6+2+2+2)
530 
531 /*
532  * receive buffer block
533  */
534 struct ipw2100_rxb {
535 	uint8_t		rxb_dat[IEEE80211_MAX_FHLEN   /* frame */
536 				+ IEEE80211_MAX_LEN   /* payload */
537 				+ IEEE80211_CRC_LEN]; /* FCS */
538 };
539 
540 /*
541  * ROM entries
542  */
543 #define	IPW2100_ROM_RADIO		(0x11)
544 #define	IPW2100_ROM_MAC			(0x21)
545 #define	IPW2100_ROM_CHANNEL_LIST	(0x37)
546 
547 /*
548  * EEPROM controls
549  */
550 #define	IPW2100_IMEM_EEPROM_CTL		(0x00300040)
551 #define	IPW2100_EEPROM_DELAY		(1)
552 
553 /*
554  * CSR access routines
555  */
556 extern uint8_t ipw2100_csr_get8(struct ipw2100_softc *sc, uint32_t off);
557 extern uint16_t ipw2100_csr_get16(struct ipw2100_softc *sc, uint32_t off);
558 extern uint32_t ipw2100_csr_get32(struct ipw2100_softc *sc, uint32_t off);
559 extern void ipw2100_csr_rep_get16(struct ipw2100_softc *sc, uint32_t off,
560     uint16_t *buf, size_t cnt);
561 extern void ipw2100_csr_put8(struct ipw2100_softc *sc, uint32_t off,
562     uint8_t val);
563 extern void ipw2100_csr_put16(struct ipw2100_softc *sc,
564     uint32_t off, uint16_t val);
565 extern void ipw2100_csr_put32(struct ipw2100_softc *sc,
566     uint32_t off, uint32_t val);
567 extern void ipw2100_csr_rep_put8(struct ipw2100_softc *sc,
568     uint32_t off, uint8_t *buf, size_t cnt);
569 extern uint8_t ipw2100_imem_get8(struct ipw2100_softc *sc, int32_t addr);
570 extern uint16_t ipw2100_imem_get16(struct ipw2100_softc *sc,
571     uint32_t addr);
572 extern uint32_t ipw2100_imem_get32(struct ipw2100_softc *sc,
573     uint32_t addr);
574 extern void ipw2100_imem_rep_get16(struct ipw2100_softc *sc,
575     uint32_t addr, uint16_t *buf, size_t cnt);
576 extern void ipw2100_imem_put8(struct ipw2100_softc *sc,
577     uint32_t addr, uint8_t val);
578 extern void ipw2100_imem_put16(struct ipw2100_softc *sc,
579     uint32_t addr, uint16_t val);
580 extern void ipw2100_imem_put32(struct ipw2100_softc *sc,
581     uint32_t addr, uint32_t val);
582 extern void ipw2100_imem_rep_put8(struct ipw2100_softc *sc,
583     uint32_t addr, uint8_t *buf, size_t cnt);
584 extern void ipw2100_imem_getbuf(struct ipw2100_softc *sc,
585     uint32_t addr, uint8_t *buf, size_t cnt);
586 extern void ipw2100_imem_putbuf(struct ipw2100_softc *sc,
587     uint32_t addr, uint8_t *buf, size_t cnt);
588 extern void ipw2100_rom_control(struct ipw2100_softc *sc, uint32_t val);
589 extern uint8_t ipw2100_table1_get8(struct ipw2100_softc *sc, uint32_t off);
590 extern uint32_t ipw2100_table1_get32(struct ipw2100_softc *sc,
591     uint32_t off);
592 extern void ipw2100_table1_put32(struct ipw2100_softc *sc,
593     uint32_t off, uint32_t val);
594 extern int ipw2100_table2_getbuf(struct ipw2100_softc *sc,
595     uint32_t off, uint8_t *buf, uint32_t *len);
596 
597 extern uint16_t ipw2100_rom_get16(struct ipw2100_softc *sc, uint8_t addr);
598 
599 /*
600  * Firmware related definations and interfaces.
601  */
602 extern int ipw2100_cache_firmware(struct ipw2100_softc *sc);
603 extern int ipw2100_free_firmware(struct ipw2100_softc *sc);
604 extern int ipw2100_load_uc(struct ipw2100_softc *sc);
605 extern int ipw2100_load_fw(struct ipw2100_softc *sc);
606 
607 #ifdef __cplusplus
608 }
609 #endif
610 
611 #endif /* _SYS_IPW2100_IMPL_H */
612