xref: /onnv-gate/usr/src/uts/common/io/ipw/ipw2100_impl.h (revision 8550:0cc93b5e7ddc)
13847Seh146360 /*
2*8550SSeth.Goldberg@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
33847Seh146360  * Use is subject to license terms.
43847Seh146360  */
53847Seh146360 
63847Seh146360 /*
73847Seh146360  * Copyright(c) 2004
83847Seh146360  *	Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
93847Seh146360  *
103847Seh146360  * Redistribution and use in source and binary forms, with or without
113847Seh146360  * modification, are permitted provided that the following conditions
123847Seh146360  * are met:
133847Seh146360  * 1. Redistributions of source code must retain the above copyright
143847Seh146360  *    notice unmodified, this list of conditions, and the following
153847Seh146360  *    disclaimer.
163847Seh146360  * 2. Redistributions in binary form must reproduce the above copyright
173847Seh146360  *    notice, this list of conditions and the following disclaimer in the
183847Seh146360  *    documentation and/or other materials provided with the distribution.
193847Seh146360  *
203847Seh146360  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
213847Seh146360  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
223847Seh146360  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
233847Seh146360  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
243847Seh146360  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
253847Seh146360  * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
263847Seh146360  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
273847Seh146360  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
283847Seh146360  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
293847Seh146360  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
303847Seh146360  * SUCH DAMAGE.
313847Seh146360  */
323847Seh146360 
333847Seh146360 #ifndef _SYS_IPW2100_IMPL_H
343847Seh146360 #define	_SYS_IPW2100_IMPL_H
353847Seh146360 
363847Seh146360 #ifdef __cplusplus
373847Seh146360 extern "C" {
383847Seh146360 #endif
393847Seh146360 
403847Seh146360 /*
413847Seh146360  * Intel Wireless PRO/2100 mini-PCI adapter driver
423847Seh146360  * ipw2100_impl.h includes:
433847Seh146360  * 	. implementation of ipw2100
443847Seh146360  * 	. hardware operation and interface define for ipw2100
453847Seh146360  * 	. firmware operation and interface define for ipw2100
463847Seh146360  */
473847Seh146360 #include <sys/ddi.h>
483847Seh146360 #include <sys/sunddi.h>
493847Seh146360 #include <sys/mac.h>
503847Seh146360 #include <sys/net80211.h>
513847Seh146360 
523847Seh146360 /*
533847Seh146360  * Implementation of ipw2100
543847Seh146360  */
553847Seh146360 #define	IPW2100_NODENAME	"ipw"
563847Seh146360 
573847Seh146360 #define	IPW2100_PCI_CFG_RNUM	(0) /* pci config space */
583847Seh146360 #define	IPW2100_PCI_CSR_RNUM	(1) /* device CSR space */
593847Seh146360 
603847Seh146360 #define	IPW2100_NUM_TXBD    (128)
613847Seh146360 #define	IPW2100_TXBD_SIZE   (IPW2100_NUM_TXBD * sizeof (struct ipw2100_bd))
623847Seh146360 #define	IPW2100_NUM_TXBUF   (IPW2100_NUM_TXBD/2)  /* ipw2100_txb number */
633847Seh146360 #define	IPW2100_TXBUF_SIZE  (sizeof (struct ipw2100_txb))
643847Seh146360 
653847Seh146360 #define	IPW2100_NUM_RXBD    (128)
663847Seh146360 #define	IPW2100_STATUS_SIZE (IPW2100_NUM_RXBD * sizeof (struct ipw2100_status))
673847Seh146360 #define	IPW2100_RXBD_SIZE   (IPW2100_NUM_RXBD * sizeof (struct ipw2100_bd))
683847Seh146360 #define	IPW2100_NUM_RXBUF   (IPW2100_NUM_RXBD)
693847Seh146360 #define	IPW2100_RXBUF_SIZE  (sizeof (struct ipw2100_rxb))
703847Seh146360 
713847Seh146360 #define	IPW2100_CMD_SIZE    (sizeof (struct ipw2100_cmd))
723847Seh146360 
733847Seh146360 struct dma_region {
743847Seh146360 	ddi_dma_handle_t	dr_hnd;
753847Seh146360 	ddi_acc_handle_t	dr_acc;
763847Seh146360 	ddi_dma_cookie_t	dr_cookie;
773847Seh146360 	uint_t			dr_ccnt;
783847Seh146360 	uint32_t		dr_pbase;
793847Seh146360 	caddr_t			dr_base;
803847Seh146360 	size_t			dr_size;
813847Seh146360 	const char		*dr_name;
823847Seh146360 };
833847Seh146360 
843847Seh146360 struct ipw2100_firmware {
853847Seh146360 	uint8_t			*bin_base; /* image */
863847Seh146360 	size_t			bin_size;
873847Seh146360 	uint8_t			*fw_base; /* firmware code */
883847Seh146360 	size_t			fw_size;
893847Seh146360 	uint8_t			*uc_base; /* u-controller code */
903847Seh146360 	size_t			uc_size;
913847Seh146360 };
923847Seh146360 
933847Seh146360 /*
943847Seh146360  * per-instance soft-state structure
953847Seh146360  */
963847Seh146360 struct ipw2100_softc {
973847Seh146360 	struct ieee80211com	sc_ic;
983847Seh146360 	dev_info_t		*sc_dip;
993847Seh146360 	int	(*sc_newstate)(struct ieee80211com *,
1003847Seh146360 	    enum ieee80211_state, int);
1013847Seh146360 	int			sc_authmode;
102*8550SSeth.Goldberg@Sun.COM 	int			sc_suspended;
1033847Seh146360 	/* CSR */
1043847Seh146360 	ddi_acc_handle_t	sc_ioh;
1053847Seh146360 	caddr_t			sc_regs;
1063847Seh146360 	/* interrupt */
1073847Seh146360 	ddi_iblock_cookie_t	sc_iblk;
1083847Seh146360 	/* soft interrupt */
1093847Seh146360 	ddi_softintr_t		sc_link_softint;
1103847Seh146360 	/* link state */
1113847Seh146360 	int32_t			sc_linkstate;
1123847Seh146360 	/* mutex to protect interrupt handler */
1133847Seh146360 	kmutex_t		sc_ilock;
1143847Seh146360 	kcondvar_t		sc_fw_cond;
1153847Seh146360 	/* flags */
1163847Seh146360 	uint_t			sc_flags;
1173847Seh146360 #define	IPW2100_FLAG_FW_CACHED		(1 << 0)
1183847Seh146360 #define	IPW2100_FLAG_FW_INITED		(1 << 1)
1193847Seh146360 #define	IPW2100_FLAG_RUNNING		(1 << 2)
1203847Seh146360 #define	IPW2100_FLAG_LINK_CHANGE	(1 << 3)
1213847Seh146360 #define	IPW2100_FLAG_TX_SCHED		(1 << 4)
1223847Seh146360 #define	IPW2100_FLAG_CMD_WAIT		(1 << 5)
1233847Seh146360 #define	IPW2100_FLAG_SCAN_COMPLETE	(1 << 6)
1243847Seh146360 #define	IPW2100_FLAG_HW_ERR_RECOVER	(1 << 7)
1257804SKonstantin.Ananyev@Sun.COM #define	IPW2100_FLAG_QUIESCED		(1 << 8)
1263847Seh146360 #define	IPW2100_FLAG_HAS_RADIO_SWITCH	(1 << 16)
1273847Seh146360 	/* command */
1283847Seh146360 	struct ipw2100_cmd	*sc_cmd;
1293847Seh146360 	int			sc_done; /* command is done */
1303847Seh146360 	kcondvar_t		sc_cmd_cond;
1313847Seh146360 	/* reschedule lock */
1323847Seh146360 	kmutex_t		sc_resched_lock;
1333847Seh146360 	/* tx ring, bd->hdr&buf */
1343847Seh146360 	kmutex_t		sc_tx_lock;
1353847Seh146360 	kcondvar_t		sc_tx_cond;
1363847Seh146360 	uint32_t		sc_tx_cur;
1373847Seh146360 	uint32_t		sc_tx_free;
1383847Seh146360 	struct ipw2100_bd	*sc_txbd;
1393847Seh146360 	struct ipw2100_txb	*sc_txbufs[IPW2100_NUM_TXBUF];
1403847Seh146360 	/* rx ring, status, bd->buf */
1413847Seh146360 	uint32_t		sc_rx_cur;
1423847Seh146360 	uint32_t		sc_rx_free;
1433847Seh146360 	struct ipw2100_status	*sc_status;
1443847Seh146360 	struct ipw2100_bd	*sc_rxbd;
1453847Seh146360 	struct ipw2100_rxb	*sc_rxbufs[IPW2100_NUM_RXBUF];
1463847Seh146360 	/* DMA resources */
1473847Seh146360 	struct dma_region	sc_dma_txbd; /* tx buffer descriptor */
1483847Seh146360 	struct dma_region	sc_dma_txbufs[IPW2100_NUM_TXBUF];
1493847Seh146360 	struct dma_region	sc_dma_rxbd; /* rx buffer descriptor */
1503847Seh146360 	struct dma_region	sc_dma_rxbufs[IPW2100_NUM_RXBUF];
1513847Seh146360 	struct dma_region	sc_dma_status;
1523847Seh146360 	struct dma_region	sc_dma_cmd; /* command */
1533847Seh146360 	/* hw configuration values */
1543847Seh146360 	uint8_t			sc_macaddr[IEEE80211_ADDR_LEN];
1553847Seh146360 	uint16_t		sc_chmask;
1563847Seh146360 	/* MAC address string */
1573847Seh146360 	char			sc_macstr[32];
1583847Seh146360 	/* tables */
1593847Seh146360 	uint32_t		sc_table1_base;
1603847Seh146360 	uint32_t		sc_table2_base;
1613847Seh146360 	/* firmware */
1623847Seh146360 	struct			ipw2100_firmware sc_fw;
1633847Seh146360 	/* mfthread related */
1643847Seh146360 	kmutex_t		sc_mflock;
1653847Seh146360 	kcondvar_t		sc_mfthread_cv;
1663847Seh146360 	kcondvar_t		sc_scan_cv; /* used for active scan */
1673847Seh146360 	kthread_t		*sc_mf_thread;
1683847Seh146360 	uint32_t		sc_mfthread_switch; /* 0/1 indicate off/on */
1693847Seh146360 	int			if_flags;
1703847Seh146360 };
1713847Seh146360 
1723847Seh146360 /*
1733847Seh146360  * RING_BACKWARD  - move 'x' backward 's' steps in a 'b'-sized ring
1743847Seh146360  * RING_FORWARD   - move 'x' forward 's' steps in a 'b'-sized ring
1753847Seh146360  *
1763847Seh146360  * note that there must be 0 <= 'x' < 'b' && 0 <= 's' < 'b'
1773847Seh146360  */
1783847Seh146360 #define	RING_FLEN(x, y, b)	((((x) > (y)) ? ((b)+(y)-(x)) : ((y)-(x))))
1793847Seh146360 #define	RING_FORWARD(x, s, b)	(((x)+(s))%(b))
1803847Seh146360 #define	RING_BACKWARD(x, s, b)	RING_FORWARD((x), (b)-(s), (b))
1813847Seh146360 
1823847Seh146360 /*
1833847Seh146360  * field_offset
1843847Seh146360  */
1853847Seh146360 #define	OFFSETOF(s, m)		((size_t)(&(((s *)0)->m)))
1863847Seh146360 
1873847Seh146360 extern int ipw2100_init(struct ipw2100_softc *sc);
1883847Seh146360 extern int ipw2100_disable(struct ipw2100_softc *sc);
1893847Seh146360 
1903847Seh146360 /*
1913847Seh146360  * Below structure and functions will be used for statistic
1923847Seh146360  */
1933847Seh146360 struct statistic {
1943847Seh146360 	int		index;
1953847Seh146360 	const char	*desc;
1963847Seh146360 	int		unit;
1973847Seh146360 #define	INT		1
1983847Seh146360 #define	HEX		2
1993847Seh146360 #define	MASK		HEX
2003847Seh146360 #define	PERCENTAGE	3
2013847Seh146360 #define	BOOL		4
2023847Seh146360 };
2033847Seh146360 extern void ipw2100_get_statistics(struct ipw2100_softc *sc);
2043847Seh146360 
2053847Seh146360 /*
2063847Seh146360  * Hardware related definations and interfaces.
2073847Seh146360  */
2083847Seh146360 #define	IPW2100_CSR_INTR		(0x0008)
2093847Seh146360 #define	IPW2100_CSR_INTR_MASK		(0x000c)
2103847Seh146360 #define	IPW2100_CSR_INDIRECT_ADDR	(0x0010)
2113847Seh146360 #define	IPW2100_CSR_INDIRECT_DATA	(0x0014)
2123847Seh146360 #define	IPW2100_CSR_AUTOINC_ADDR	(0x0018)
2133847Seh146360 #define	IPW2100_CSR_AUTOINC_DATA	(0x001c)
2143847Seh146360 #define	IPW2100_CSR_RST			(0x0020)
2153847Seh146360 #define	IPW2100_CSR_CTL			(0x0024)
2163847Seh146360 #define	IPW2100_CSR_IO			(0x0030)
2173847Seh146360 #define	IPW2100_CSR_DEBUG_AREA		(0x0090)
2183847Seh146360 
2193847Seh146360 #define	IPW2100_CSR_TX_BD_BASE		(0x0200)
2203847Seh146360 #define	IPW2100_CSR_TX_BD_SIZE		(0x0204)
2213847Seh146360 #define	IPW2100_CSR_RX_BD_BASE		(0x0240)
2223847Seh146360 #define	IPW2100_CSR_RX_STATUS_BASE	(0x0244)
2233847Seh146360 #define	IPW2100_CSR_RX_BD_SIZE		(0x0248)
2243847Seh146360 #define	IPW2100_CSR_TABLE1_BASE		(0x0380)
2253847Seh146360 #define	IPW2100_CSR_TABLE2_BASE		(0x0384)
2263847Seh146360 /*
2273847Seh146360  * tx-rd-index  the entry to be processed by HW, i.e. empty tx buffer
2283847Seh146360  * tx-wr-index  the entry just being filled by SW with new data to transmit
2293847Seh146360  */
2303847Seh146360 #define	IPW2100_CSR_TX_READ_INDEX	(0x0280)
2313847Seh146360 #define	IPW2100_CSR_TX_WRITE_INDEX	(0x0f80)
2323847Seh146360 /*
2333847Seh146360  * rx-rd-index  the entry just being processed by HW, i.e. new received data
2343847Seh146360  * rx-wr-index  the entry just being set by SW to empty buffer to receive
2353847Seh146360  */
2363847Seh146360 #define	IPW2100_CSR_RX_READ_INDEX	(0x02a0)
2373847Seh146360 #define	IPW2100_CSR_RX_WRITE_INDEX	(0x0fa0)
2383847Seh146360 
2393847Seh146360 /*
2403847Seh146360  * CSR flags: IPW2100_CSR_INTR
2413847Seh146360  * The interrupt register is used to indicate the h/w status
2423847Seh146360  */
2433847Seh146360 #define	IPW2100_INTR_TX_TRANSFER	(0x00000001)
2443847Seh146360 #define	IPW2100_INTR_RX_TRANSFER	(0x00000002)
2453847Seh146360 #define	IPW2100_INTR_STATUS_CHANGE	(0x00000010)
2463847Seh146360 #define	IPW2100_INTR_COMMAND_DONE	(0x00010000)
2473847Seh146360 #define	IPW2100_INTR_FW_INIT_DONE	(0x01000000)
2483847Seh146360 #define	IPW2100_INTR_FATAL_ERROR	(0x40000000)
2493847Seh146360 #define	IPW2100_INTR_PARITY_ERROR	(0x80000000)
2503847Seh146360 #define	IPW2100_INTR_MASK_ALL	(IPW2100_INTR_TX_TRANSFER | \
2513847Seh146360 				IPW2100_INTR_RX_TRANSFER | \
2523847Seh146360 				IPW2100_INTR_STATUS_CHANGE | \
2533847Seh146360 				IPW2100_INTR_COMMAND_DONE | \
2543847Seh146360 				IPW2100_INTR_FW_INIT_DONE | \
2553847Seh146360 				IPW2100_INTR_FATAL_ERROR | \
2563847Seh146360 				IPW2100_INTR_PARITY_ERROR)
2573847Seh146360 #define	IPW2100_INTR_MASK_ERR	(IPW2100_INTR_FATAL_ERROR | \
2583847Seh146360 				IPW2100_INTR_PARITY_ERROR)
2593847Seh146360 
2603847Seh146360 /*
2613847Seh146360  * CSR flags: IPW2100_CSR_RST
2623847Seh146360  * The reset register is used to reset hardware
2633847Seh146360  */
2643847Seh146360 #define	IPW2100_RST_PRINCETON_RESET	(0x00000001)
2653847Seh146360 #define	IPW2100_RST_SW_RESET		(0x00000080)
2663847Seh146360 #define	IPW2100_RST_MASTER_DISABLED	(0x00000100)
2673847Seh146360 #define	IPW2100_RST_STOP_MASTER		(0x00000200)
2683847Seh146360 
2693847Seh146360 /*
2703847Seh146360  * CSR flags: IPW2100_CSR_CTL
2713847Seh146360  */
2723847Seh146360 #define	IPW2100_CTL_CLOCK_READY		(0x00000001)
2733847Seh146360 #define	IPW2100_CTL_ALLOW_STANDBY	(0x00000002)
2743847Seh146360 #define	IPW2100_CTL_INIT		(0x00000004)
2753847Seh146360 
2763847Seh146360 /*
2773847Seh146360  * CSR flags: IPW2100_CSR_IO
2783847Seh146360  */
2793847Seh146360 #define	IPW2100_IO_GPIO1_ENABLE		(0x00000008)
2803847Seh146360 #define	IPW2100_IO_GPIO1_MASK		(0x0000000c)
2813847Seh146360 #define	IPW2100_IO_GPIO3_MASK		(0x000000c0)
2823847Seh146360 #define	IPW2100_IO_LED_OFF		(0x00002000)
2833847Seh146360 #define	IPW2100_IO_RADIO_DISABLED	(0x00010000)
2843847Seh146360 
2853847Seh146360 /*
2863847Seh146360  * States code
2873847Seh146360  */
2883847Seh146360 #define	IPW2100_STATE_ASSOCIATED	(0x0004)
2893847Seh146360 #define	IPW2100_STATE_ASSOCIATION_LOST	(0x0008)
2903847Seh146360 #define	IPW2100_STATE_SCAN_COMPLETE	(0x0020)
2913847Seh146360 #define	IPW2100_STATE_RADIO_DISABLED	(0x0100)
2923847Seh146360 #define	IPW2100_STATE_DISABLED		(0x0200)
2933847Seh146360 #define	IPW2100_STATE_SCANNING		(0x0800)
2943847Seh146360 
2953847Seh146360 /*
2963847Seh146360  * table1 offsets
2973847Seh146360  */
2983847Seh146360 #define	IPW2100_INFO_LOCK		(480)
2993847Seh146360 #define	IPW2100_INFO_APS_CNT		(604)
3003847Seh146360 #define	IPW2100_INFO_APS_BASE		(608)
3013847Seh146360 #define	IPW2100_INFO_CARD_DISABLED	(628)
3023847Seh146360 #define	IPW2100_INFO_CURRENT_CHANNEL	(756)
3033847Seh146360 #define	IPW2100_INFO_CURRENT_TX_RATE	(768)
3043847Seh146360 
3053847Seh146360 /*
3063847Seh146360  * table2 offsets
3073847Seh146360  */
3083847Seh146360 #define	IPW2100_INFO_CURRENT_SSID	(48)
3093847Seh146360 #define	IPW2100_INFO_CURRENT_BSSID	(112)
3103847Seh146360 
3113847Seh146360 /*
3123847Seh146360  * supported rates
3133847Seh146360  */
3143847Seh146360 #define	IPW2100_RATE_DS1		(1)
3153847Seh146360 #define	IPW2100_RATE_DS2		(2)
3163847Seh146360 #define	IPW2100_RATE_DS5		(4)
3173847Seh146360 #define	IPW2100_RATE_DS11		(8)
3183847Seh146360 
3193847Seh146360 /* hw structures, packed */
3203847Seh146360 #pragma pack(1)
3213847Seh146360 /*
3223847Seh146360  * firmware binary image header
3233847Seh146360  */
3243847Seh146360 struct ipw2100_firmware_hdr {
3253847Seh146360 	uint32_t	version;
3263847Seh146360 	uint32_t	fw_size;
3273847Seh146360 	uint32_t	uc_size;
3283847Seh146360 };
3293847Seh146360 
3303847Seh146360 /*
3313847Seh146360  * buffer descriptor
3323847Seh146360  */
3333847Seh146360 struct ipw2100_bd {
3343847Seh146360 	uint32_t	phyaddr;
3353847Seh146360 	uint32_t	len;
3363847Seh146360 	uint8_t		flags;
3373847Seh146360 /* flags */
3383847Seh146360 #define	IPW2100_BD_FLAG_TX_LAST_FRAGMENT	(0x08)
3393847Seh146360 #define	IPW2100_BD_FLAG_TX_NOT_LAST_FRAGMENT	(0x01)
3403847Seh146360 /* data content */
3413847Seh146360 #define	IPW2100_BD_FLAG_TX_FRAME_802_3		(0x00)
3423847Seh146360 #define	IPW2100_BD_FLAG_TX_FRAME_COMMAND	(0x02)
3433847Seh146360 #define	IPW2100_BD_FLAG_TX_FRAME_802_11		(0x04)
3443847Seh146360 	/* number of fragments, only 1st BD is needed */
3453847Seh146360 	uint8_t		nfrag;
3463847Seh146360 	uint8_t		reserved[6];
3473847Seh146360 };
3483847Seh146360 
3493847Seh146360 /*
3503847Seh146360  * status descriptor
3513847Seh146360  */
3523847Seh146360 struct ipw2100_status {
3533847Seh146360 	uint32_t	len;
3543847Seh146360 	uint16_t	code;
3553847Seh146360 #define	IPW2100_STATUS_CODE_COMMAND		(0)
3563847Seh146360 #define	IPW2100_STATUS_CODE_NEWSTATE		(1)
3573847Seh146360 #define	IPW2100_STATUS_CODE_DATA_802_11		(2)
3583847Seh146360 #define	IPW2100_STATUS_CODE_DATA_802_3		(3)
3593847Seh146360 #define	IPW2100_STATUS_CODE_NOTIFICATION	(4)
3603847Seh146360 	uint8_t		flags;
3613847Seh146360 #define	IPW2100_STATUS_FLAG_DECRYPTED		(0x01)
3623847Seh146360 #define	IPW2100_STATUS_FLAG_WEP_ENCRYPTED	(0x02)
3633847Seh146360 #define	IPW2100_STATUS_FLAG_CRC_ERROR		(0x04)
3643847Seh146360 	/* received signal strength indicator */
3653847Seh146360 	uint8_t		rssi;
3663847Seh146360 };
3673847Seh146360 
3683847Seh146360 /*
3693847Seh146360  * data header
3703847Seh146360  */
3713847Seh146360 struct ipw2100_hdr {
3723847Seh146360 	uint32_t	type;
3733847Seh146360 	uint32_t	subtype;
3743847Seh146360 	uint8_t		encrypted;
3753847Seh146360 	uint8_t		encrypt;
3763847Seh146360 	uint8_t		keyidx;
3773847Seh146360 	uint8_t		keysz;
3783847Seh146360 	uint8_t		key[IEEE80211_KEYBUF_SIZE];
3793847Seh146360 	uint8_t		reserved[10];
3803847Seh146360 	uint8_t		saddr[IEEE80211_ADDR_LEN];
3813847Seh146360 	uint8_t		daddr[IEEE80211_ADDR_LEN];
3823847Seh146360 	uint16_t	fragsz;
3833847Seh146360 };
3843847Seh146360 
3853847Seh146360 /*
3863847Seh146360  * command
3873847Seh146360  */
3883847Seh146360 struct ipw2100_cmd {
3893847Seh146360 	uint32_t	type;
3903847Seh146360 #define	IPW2100_CMD_ENABLE			(2)
3913847Seh146360 #define	IPW2100_CMD_SET_CONFIGURATION		(6)
3923847Seh146360 #define	IPW2100_CMD_SET_ESSID			(8)
3933847Seh146360 #define	IPW2100_CMD_SET_MANDATORY_BSSID		(9)
3943847Seh146360 #define	IPW2100_CMD_SET_AUTH_TYPE		(10)
3953847Seh146360 #define	IPW2100_CMD_SET_MAC_ADDRESS		(11)
3963847Seh146360 #define	IPW2100_CMD_SET_MODE			(12)
3973847Seh146360 #define	IPW2100_CMD_SET_I18N_MODE		(13)
3983847Seh146360 #define	IPW2100_CMD_SET_CHANNEL			(14)
3993847Seh146360 #define	IPW2100_CMD_SET_RTS_THRESHOLD		(15)
4003847Seh146360 #define	IPW2100_CMD_SET_FRAG_THRESHOLD		(16)
4013847Seh146360 #define	IPW2100_CMD_SET_POWER_MODE		(17)
4023847Seh146360 #define	IPW2100_CMD_SET_TX_RATES		(18)
4033847Seh146360 #define	IPW2100_CMD_SET_BASIC_TX_RATES		(19)
4043847Seh146360 #define	IPW2100_CMD_SET_WEP_KEY			(20)
4053847Seh146360 #define	IPW2100_CMD_SET_WEP_KEY_INDEX		(25)
4063847Seh146360 #define	IPW2100_CMD_SET_WEP_FLAGS		(26)
4073847Seh146360 #define	IPW2100_CMD_ADD_MULTICAST		(27)
4083847Seh146360 #define	IPW2100_CMD_CLR_MULTICAST		(28)
4093847Seh146360 #define	IPW2100_CMD_SET_BEACON_INTERVAL		(29)
4103847Seh146360 #define	IPW2100_CMD_CLR_STATISTICS		(31)
4113847Seh146360 #define	IPW2100_CMD_SEND			(33)
4123847Seh146360 #define	IPW2100_CMD_SET_TX_POWER_INDEX		(36)
4133847Seh146360 #define	IPW2100_CMD_BROADCAST_SCAN		(43)
4143847Seh146360 #define	IPW2100_CMD_DISABLE			(44)
4153847Seh146360 #define	IPW2100_CMD_SET_DESIRED_BSSID		(45)
4163847Seh146360 #define	IPW2100_CMD_SET_SCAN_OPTIONS		(46)
4173847Seh146360 #define	IPW2100_CMD_PREPARE_POWER_DOWN		(58)
4183847Seh146360 #define	IPW2100_CMD_DISABLE_PHY			(61)
4193847Seh146360 #define	IPW2100_CMD_SET_SECURITY_INFORMATION	(67)
4203847Seh146360 #define	IPW2100_CMD_SET_WPA_IE			(69)
4213847Seh146360 	uint32_t	subtype;
4223847Seh146360 	uint32_t	seq;
4233847Seh146360 	uint32_t	len;
4243847Seh146360 	uint8_t		data[400];
4253847Seh146360 	uint32_t	status;
4263847Seh146360 	uint8_t		reserved[68];
4273847Seh146360 };
4283847Seh146360 
4293847Seh146360 /*
4303847Seh146360  * IPW2100_CMD_SET_POWER_MODE
4313847Seh146360  */
4323847Seh146360 #define	IPW2100_POWER_MODE_CAM	(0)
4333847Seh146360 #define	IPW2100_POWER_AUTOMATIC	(6)
4343847Seh146360 
4353847Seh146360 /*
4363847Seh146360  * IPW2100_CMD_SET_MODE
4373847Seh146360  */
4383847Seh146360 #define	IPW2100_MODE_BSS	(0)
4393847Seh146360 #define	IPW2100_MODE_IBSS	(1)
4403847Seh146360 #define	IPW2100_MODE_MONITOR	(2)
4413847Seh146360 
4423847Seh146360 /*
4433847Seh146360  * structure for IPW2100_CMD_SET_WEP_KEY
4443847Seh146360  */
4453847Seh146360 struct ipw2100_wep_key {
4463847Seh146360 	uint8_t		idx;
4473847Seh146360 	uint8_t		len;
4483847Seh146360 	uint8_t		key[13];
4493847Seh146360 };
4503847Seh146360 
4513847Seh146360 /*
4523847Seh146360  * structure for IPW2100_CMD_SET_SECURITY_INFORMATION
4533847Seh146360  */
4543847Seh146360 struct ipw2100_security {
4553847Seh146360 	uint32_t	ciphers;
4563847Seh146360 #define	IPW2100_CIPHER_NONE	(0x00000001)
4573847Seh146360 #define	IPW2100_CIPHER_WEP40	(0x00000002)
4583847Seh146360 #define	IPW2100_CIPHER_WEP104	(0x00000020)
4593847Seh146360 	uint16_t	version;
4603847Seh146360 	uint8_t		authmode;
4613847Seh146360 #define	IPW2100_AUTH_OPEN	(0)
4623847Seh146360 #define	IPW2100_AUTH_SHARED	(1)
4633847Seh146360 	uint8_t		replay_counters_number;
4643847Seh146360 	uint8_t		unicast_using_group;
4653847Seh146360 };
4663847Seh146360 
4673847Seh146360 /*
4683847Seh146360  * structure for IPW2100_CMD_SET_SCAN_OPTIONS
4693847Seh146360  */
4703847Seh146360 struct ipw2100_scan_options {
4713847Seh146360 	uint32_t	flags;
4723847Seh146360 #define	IPW2100_SCAN_DO_NOT_ASSOCIATE	(0x00000001)
4733847Seh146360 #define	IPW2100_SCAN_PASSIVE		(0x00000008)
4743847Seh146360 	uint32_t	channels;
4753847Seh146360 };
4763847Seh146360 
4773847Seh146360 /*
4783847Seh146360  * structure for IPW2100_CMD_SET_CONFIGURATION
4793847Seh146360  */
4803847Seh146360 struct ipw2100_configuration {
4813847Seh146360 	uint32_t	flags;
4823847Seh146360 #define	IPW2100_CFG_PROMISCUOUS		(0x00000004)
4833847Seh146360 #define	IPW2100_CFG_PREAMBLE_AUTO	(0x00000010)
4843847Seh146360 #define	IPW2100_CFG_IBSS_AUTO_START	(0x00000020)
4853847Seh146360 #define	IPW2100_CFG_802_1x_ENABLE	(0x00004000)
4863847Seh146360 #define	IPW2100_CFG_BSS_MASK		(0x00008000)
4873847Seh146360 #define	IPW2100_CFG_IBSS_MASK		(0x00010000)
4883847Seh146360 	uint32_t	bss_chan;
4893847Seh146360 	uint32_t	ibss_chan;
4903847Seh146360 };
4913847Seh146360 
4923847Seh146360 /*
4933847Seh146360  * element in AP table
4943847Seh146360  */
4953847Seh146360 struct ipw2100_node {
4963847Seh146360 	uint32_t	reserved_1[2];
4973847Seh146360 	uint8_t		bssid[IEEE80211_ADDR_LEN];
4983847Seh146360 	uint8_t		chan;
4993847Seh146360 	uint8_t		rates;
5003847Seh146360 	uint16_t	reserved_2;
5013847Seh146360 	uint16_t	capinfo;
5023847Seh146360 	uint16_t	reserved_3;
5033847Seh146360 	uint16_t	intval;
5043847Seh146360 	uint8_t		reserved_4[28];
5053847Seh146360 	uint8_t		essid[IEEE80211_NWID_LEN];
5063847Seh146360 	uint16_t	reserved_5;
5073847Seh146360 	uint8_t		esslen;
5083847Seh146360 	uint8_t		reserved_6[7];
5093847Seh146360 	uint8_t		rssi;
5103847Seh146360 };
5113847Seh146360 #pragma pack()
5123847Seh146360 
5133847Seh146360 /*
5143847Seh146360  * transmit buffer block
5153847Seh146360  */
5163847Seh146360 struct ipw2100_txb {
5173847Seh146360 	struct ipw2100_hdr	txb_hdr; /* header */
5183847Seh146360 	uint8_t			txb_dat[IEEE80211_MAX_LEN]; /* payload */
5193847Seh146360 };
5203847Seh146360 
5213847Seh146360 /*
5223847Seh146360  * maximum frame header lenght: 4 MAC addresses + 1 fc + 1 id + 1 seqctl
5233847Seh146360  */
5243847Seh146360 #define	IEEE80211_MAX_FHLEN	(4*6+2+2+2)
5253847Seh146360 
5263847Seh146360 /*
5273847Seh146360  * receive buffer block
5283847Seh146360  */
5293847Seh146360 struct ipw2100_rxb {
5303847Seh146360 	uint8_t		rxb_dat[IEEE80211_MAX_FHLEN   /* frame */
5313847Seh146360 				+ IEEE80211_MAX_LEN   /* payload */
5323847Seh146360 				+ IEEE80211_CRC_LEN]; /* FCS */
5333847Seh146360 };
5343847Seh146360 
5353847Seh146360 /*
5363847Seh146360  * ROM entries
5373847Seh146360  */
5383847Seh146360 #define	IPW2100_ROM_RADIO		(0x11)
5393847Seh146360 #define	IPW2100_ROM_MAC			(0x21)
5403847Seh146360 #define	IPW2100_ROM_CHANNEL_LIST	(0x37)
5413847Seh146360 
5423847Seh146360 /*
5433847Seh146360  * EEPROM controls
5443847Seh146360  */
5453847Seh146360 #define	IPW2100_IMEM_EEPROM_CTL		(0x00300040)
5463847Seh146360 #define	IPW2100_EEPROM_DELAY		(1)
5473847Seh146360 
5483847Seh146360 /*
5493847Seh146360  * CSR access routines
5503847Seh146360  */
5513847Seh146360 extern uint8_t ipw2100_csr_get8(struct ipw2100_softc *sc, uint32_t off);
5523847Seh146360 extern uint16_t ipw2100_csr_get16(struct ipw2100_softc *sc, uint32_t off);
5533847Seh146360 extern uint32_t ipw2100_csr_get32(struct ipw2100_softc *sc, uint32_t off);
5543847Seh146360 extern void ipw2100_csr_rep_get16(struct ipw2100_softc *sc, uint32_t off,
5553847Seh146360     uint16_t *buf, size_t cnt);
5563847Seh146360 extern void ipw2100_csr_put8(struct ipw2100_softc *sc, uint32_t off,
5573847Seh146360     uint8_t val);
5583847Seh146360 extern void ipw2100_csr_put16(struct ipw2100_softc *sc,
5593847Seh146360     uint32_t off, uint16_t val);
5603847Seh146360 extern void ipw2100_csr_put32(struct ipw2100_softc *sc,
5613847Seh146360     uint32_t off, uint32_t val);
5623847Seh146360 extern void ipw2100_csr_rep_put8(struct ipw2100_softc *sc,
5633847Seh146360     uint32_t off, uint8_t *buf, size_t cnt);
5643847Seh146360 extern uint8_t ipw2100_imem_get8(struct ipw2100_softc *sc, int32_t addr);
5653847Seh146360 extern uint16_t ipw2100_imem_get16(struct ipw2100_softc *sc,
5663847Seh146360     uint32_t addr);
5673847Seh146360 extern uint32_t ipw2100_imem_get32(struct ipw2100_softc *sc,
5683847Seh146360     uint32_t addr);
5693847Seh146360 extern void ipw2100_imem_rep_get16(struct ipw2100_softc *sc,
5703847Seh146360     uint32_t addr, uint16_t *buf, size_t cnt);
5713847Seh146360 extern void ipw2100_imem_put8(struct ipw2100_softc *sc,
5723847Seh146360     uint32_t addr, uint8_t val);
5733847Seh146360 extern void ipw2100_imem_put16(struct ipw2100_softc *sc,
5743847Seh146360     uint32_t addr, uint16_t val);
5753847Seh146360 extern void ipw2100_imem_put32(struct ipw2100_softc *sc,
5763847Seh146360     uint32_t addr, uint32_t val);
5773847Seh146360 extern void ipw2100_imem_rep_put8(struct ipw2100_softc *sc,
5783847Seh146360     uint32_t addr, uint8_t *buf, size_t cnt);
5793847Seh146360 extern void ipw2100_imem_getbuf(struct ipw2100_softc *sc,
5803847Seh146360     uint32_t addr, uint8_t *buf, size_t cnt);
5813847Seh146360 extern void ipw2100_imem_putbuf(struct ipw2100_softc *sc,
5823847Seh146360     uint32_t addr, uint8_t *buf, size_t cnt);
5833847Seh146360 extern void ipw2100_rom_control(struct ipw2100_softc *sc, uint32_t val);
5843847Seh146360 extern uint8_t ipw2100_table1_get8(struct ipw2100_softc *sc, uint32_t off);
5853847Seh146360 extern uint32_t ipw2100_table1_get32(struct ipw2100_softc *sc,
5863847Seh146360     uint32_t off);
5873847Seh146360 extern void ipw2100_table1_put32(struct ipw2100_softc *sc,
5883847Seh146360     uint32_t off, uint32_t val);
5893847Seh146360 extern int ipw2100_table2_getbuf(struct ipw2100_softc *sc,
5903847Seh146360     uint32_t off, uint8_t *buf, uint32_t *len);
5913847Seh146360 
5923847Seh146360 extern uint16_t ipw2100_rom_get16(struct ipw2100_softc *sc, uint8_t addr);
5933847Seh146360 
5943847Seh146360 /*
5953847Seh146360  * Firmware related definations and interfaces.
5963847Seh146360  */
5973847Seh146360 extern int ipw2100_cache_firmware(struct ipw2100_softc *sc);
5983847Seh146360 extern int ipw2100_free_firmware(struct ipw2100_softc *sc);
5993847Seh146360 extern int ipw2100_load_uc(struct ipw2100_softc *sc);
6003847Seh146360 extern int ipw2100_load_fw(struct ipw2100_softc *sc);
6013847Seh146360 
6023847Seh146360 #ifdef __cplusplus
6033847Seh146360 }
6043847Seh146360 #endif
6053847Seh146360 
6063847Seh146360 #endif /* _SYS_IPW2100_IMPL_H */
607