xref: /onnv-gate/usr/src/uts/common/io/pcwl/pcwl.h (revision 11101:69561cde8165)
13737Shx147065 /*
2*11101SMikore.Li@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
33737Shx147065  * Use is subject to license terms.
43737Shx147065  */
53737Shx147065 
63737Shx147065 /*
73737Shx147065  * Copyright (c) 1997, 1998, 1999
83737Shx147065  *      Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
93737Shx147065  *
103737Shx147065  * Redistribution and use in source and binary forms, with or without
113737Shx147065  * modification, are permitted provided that the following conditions
123737Shx147065  * are met:
133737Shx147065  * 1. Redistributions of source code must retain the above copyright
143737Shx147065  *    notice, this list of conditions and the following disclaimer.
153737Shx147065  * 2. Redistributions in binary form must reproduce the above copyright
163737Shx147065  *    notice, this list of conditions and the following disclaimer in the
173737Shx147065  *    documentation and/or other materials provided with the distribution.
183737Shx147065  * 3. All advertising materials mentioning features or use of this software
193737Shx147065  *    must display the following acknowledgement:
203737Shx147065  *      This product includes software developed by Bill Paul.
213737Shx147065  * 4. Neither the name of the author nor the names of any co-contributors
223737Shx147065  *    may be used to endorse or promote products derived from this software
233737Shx147065  *    without specific prior written permission.
243737Shx147065  *
253737Shx147065  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
263737Shx147065  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
273737Shx147065  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
283737Shx147065  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
293737Shx147065  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
303737Shx147065  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
313737Shx147065  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
323737Shx147065  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
333737Shx147065  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
343737Shx147065  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
353737Shx147065  * THE POSSIBILITY OF SUCH DAMAGE.
363737Shx147065  */
373737Shx147065 
383737Shx147065 /*
393737Shx147065  * Hardware specific driver declarations for Lucent and PrismII
403737Shx147065  * chipsets.
413737Shx147065  */
423737Shx147065 
433737Shx147065 #ifndef _SYS_PCWL_H
443737Shx147065 #define	_SYS_PCWL_H
453737Shx147065 
463737Shx147065 #ifdef	__cplusplus
473737Shx147065 extern "C" {
483737Shx147065 #endif
493737Shx147065 
503737Shx147065 #include <sys/list.h>
513737Shx147065 
523737Shx147065 /*
533737Shx147065  * Encryption controls. We can enable or disable encryption as
543737Shx147065  * well as specify up to 4 encryption keys. We can also specify
553737Shx147065  * which of the four keys will be used for transmit encryption.
563737Shx147065  */
573737Shx147065 #define	WL_RID_ENCRYPTION	0xFC20
583737Shx147065 #define	WL_RID_ENCRYPTION_P2	0xFC28
593737Shx147065 #define	WL_RID_DEFLT_CRYPT_KEYS 0xFCB0
603737Shx147065 #define	WL_RID_CRYPT_KEY0_P2	0xFC24
613737Shx147065 #define	WL_RID_TX_CRYPT_KEY	0xFCB1
623737Shx147065 #define	WL_RID_TX_CRYPT_KEY_P2	0xFC23
633737Shx147065 #define	WL_RID_COMP_IDENT	0xFD20	/* version */
643737Shx147065 #define	WL_RID_WEP_AVAIL	0xFD4F
653737Shx147065 
663737Shx147065 #define	WL_RID_AUTHTYPE_P2	0xFC2A	/* PRISM-II */
673737Shx147065 #define	WL_RID_AUTHTYPE_L	0xFC21	/* 0xFC21 on Lucent */
683737Shx147065 #define	WL_AUTHTYPE_SYS_P2	0x1
693737Shx147065 #define	WL_AUTHTYPE_KEY_P2	0x2
703737Shx147065 #define	WL_AUTHTYPE_ALL_P2	(WL_AUTHTYPE_SYS_P2 | WL_AUTHTYPE_KEY_P2)
713737Shx147065 
723737Shx147065 #define	WL_SPEED_1Mbps_P2	0x1
733737Shx147065 #define	WL_SPEED_2Mbps_P2	0x2
743737Shx147065 #define	WL_SPEED_55Mbps_P2	0x4
753737Shx147065 #define	WL_SPEED_11Mbps_P2	0x8
763737Shx147065 
773737Shx147065 /*
783737Shx147065  * PrismII Tx rate
793737Shx147065  */
803737Shx147065 #define	WL_P_TX_RATE_FIX_1M	WL_SPEED_1Mbps_P2
813737Shx147065 #define	WL_P_TX_RATE_FIX_2M	WL_SPEED_2Mbps_P2
823737Shx147065 #define	WL_P_TX_RATE_FIX_5M	WL_SPEED_55Mbps_P2
833737Shx147065 #define	WL_P_TX_RATE_FIX_11M	WL_SPEED_11Mbps_P2
843737Shx147065 #define	WL_P_TX_RATE_AUTO_H	\
853737Shx147065 	(WL_SPEED_11Mbps_P2 | WL_SPEED_55Mbps_P2 | \
863737Shx147065 	WL_SPEED_2Mbps_P2 | WL_SPEED_1Mbps_P2)
873737Shx147065 #define	WL_P_TX_RATE_AUTO_M	\
883737Shx147065 	(WL_SPEED_55Mbps_P2 | WL_SPEED_2Mbps_P2 | \
893737Shx147065 	WL_SPEED_1Mbps_P2)
903737Shx147065 #define	WL_P_TX_RATE_AUTO_L	\
913737Shx147065 	(WL_SPEED_2Mbps_P2 | WL_SPEED_1Mbps_P2)
923737Shx147065 
933737Shx147065 
943737Shx147065 #define	WL_TIMEOUT	500000
953737Shx147065 
963737Shx147065 /*
973737Shx147065  * Default port: 0 (only 0 exists on stations)
983737Shx147065  */
993737Shx147065 #define	WL_DEFAULT_PORT		0
1003737Shx147065 
1013737Shx147065 /*
1023737Shx147065  * Lucent TX rate: Default 11Mbps
1033737Shx147065  */
1043737Shx147065 #define	WL_L_TX_RATE_FIX_1M	1
1053737Shx147065 #define	WL_L_TX_RATE_FIX_2M	2
1063737Shx147065 #define	WL_L_TX_RATE_AUTO_H	3
1073737Shx147065 #define	WL_L_TX_RATE_FIX_5M	4 /* 5.5M */
1083737Shx147065 #define	WL_L_TX_RATE_FIX_11M	5
1093737Shx147065 #define	WL_L_TX_RATE_AUTO_L	6
1103737Shx147065 #define	WL_L_TX_RATE_AUTO_M	7
1113737Shx147065 
1123737Shx147065 #define	WL_TX_RATE_FIX_1M(p) \
1133737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1143737Shx147065 	WL_P_TX_RATE_FIX_1M : WL_L_TX_RATE_FIX_1M)
1153737Shx147065 #define	WL_TX_RATE_FIX_2M(p) \
1163737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1173737Shx147065 	WL_P_TX_RATE_FIX_2M : WL_L_TX_RATE_FIX_2M)
1183737Shx147065 #define	WL_TX_RATE_AUTO_H(p) \
1193737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1203737Shx147065 	WL_P_TX_RATE_AUTO_H : WL_L_TX_RATE_AUTO_H)
1213737Shx147065 #define	WL_TX_RATE_FIX_5M(p) \
1223737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1233737Shx147065 	WL_P_TX_RATE_FIX_5M : WL_L_TX_RATE_FIX_5M)
1243737Shx147065 #define	WL_TX_RATE_FIX_11M(p) \
1253737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1263737Shx147065 	WL_P_TX_RATE_FIX_11M : WL_L_TX_RATE_FIX_11M)
1273737Shx147065 #define	WL_TX_RATE_AUTO_L(p) \
1283737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1293737Shx147065 	WL_P_TX_RATE_AUTO_L : WL_L_TX_RATE_AUTO_L)
1303737Shx147065 #define	WL_TX_RATE_AUTO_M(p) \
1313737Shx147065 	(p->pcwl_chip_type == PCWL_CHIP_PRISMII ? \
1323737Shx147065 	WL_P_TX_RATE_AUTO_M : WL_L_TX_RATE_AUTO_M)
1333737Shx147065 
1343737Shx147065 /*
1353737Shx147065  * Default network name: empty string implies any
1363737Shx147065  */
1373737Shx147065 #define	WL_DEFAULT_NETNAME	("")
1383737Shx147065 #define	WL_DEFAULT_NODENAME	("solaris node")
1393737Shx147065 #define	WL_DEFAULT_AP_DENSITY	1
1403737Shx147065 #define	WL_DEFAULT_RTS_THRESH	2347
1413737Shx147065 #define	WL_DEFAULT_DATALEN	2304
1423737Shx147065 #define	WL_DEFAULT_CREATE_IBSS	0
1433737Shx147065 #define	WL_DEFAULT_PM_ENABLED	0
1443737Shx147065 #define	WL_DEFAULT_MAX_SLEEP	100
1453737Shx147065 #define	WL_DEFAULT_CHAN		3
1463737Shx147065 #define	WL_DEFAULT_TX_CRYPT_KEY	0
1473737Shx147065 
1483737Shx147065 /*
1493737Shx147065  * Size of Hermes I/O space.
1503737Shx147065  */
1513737Shx147065 #define	WL_IOSIZ	0x40
1523737Shx147065 
1533737Shx147065 /*
1543737Shx147065  * Hermes command/status registers.
1553737Shx147065  */
1563737Shx147065 #define	WL_COMMAND	0x00
1573737Shx147065 #define	WL_PARAM0	0x02
1583737Shx147065 #define	WL_PARAM1	0x04
1593737Shx147065 #define	WL_PARAM2	0x06
1603737Shx147065 #define	WL_STATUS	0x08
1613737Shx147065 #define	WL_RESP0	0x0A
1623737Shx147065 #define	WL_RESP1	0x0C
1633737Shx147065 #define	WL_RESP2	0x0E
1643737Shx147065 
1653737Shx147065 /*
1663737Shx147065  * Command register values.
1673737Shx147065  */
1683737Shx147065 #define	WL_CMD_BUSY		0x8000 /* busy bit */
1693737Shx147065 #define	WL_CMD_INI		0x0000 /* initialize */
1703737Shx147065 #define	WL_CMD_ENABLE		0x0001 /* enable */
1713737Shx147065 #define	WL_CMD_DISABLE		0x0002 /* disable */
1723737Shx147065 #define	WL_CMD_DIAG		0x0003
1733737Shx147065 #define	WL_CMD_ALLOC_MEM	0x000A /* allocate NIC memory */
1743737Shx147065 #define	WL_CMD_TX		0x000B /* transmit */
1753737Shx147065 #define	WL_CMD_NOTIFY		0x0010
1763737Shx147065 #define	WL_CMD_INQUIRE		0x0011
1773737Shx147065 #define	WL_CMD_ACCESS		0x0021
1783737Shx147065 #define	WL_CMD_PROGRAM		0x0022
1793737Shx147065 
1803737Shx147065 #define	WL_CMD_CODE_MASK	0x003F
1813737Shx147065 
1823737Shx147065 /*
1833737Shx147065  * Reclaim qualifier bit, applicable to the
1843737Shx147065  * TX and INQUIRE commands.
1853737Shx147065  */
1863737Shx147065 #define	WL_RECLAIM		0x0100 /* reclaim NIC memory */
1873737Shx147065 
1883737Shx147065 /*
1893737Shx147065  * ACCESS command qualifier bits.
1903737Shx147065  */
1913737Shx147065 #define	WL_ACCESS_READ		0x0000
1923737Shx147065 #define	WL_ACCESS_WRITE		0x0100
1933737Shx147065 
1943737Shx147065 /*
1953737Shx147065  * PROGRAM command qualifier bits.
1963737Shx147065  */
1973737Shx147065 #define	WL_PROGRAM_DISABLE	0x0000
1983737Shx147065 #define	WL_PROGRAM_ENABLE_RAM	0x0100
1993737Shx147065 #define	WL_PROGRAM_ENABLE_NVRAM	0x0200
2003737Shx147065 #define	WL_PROGRAM_NVRAM	0x0300
2013737Shx147065 
2023737Shx147065 /*
2033737Shx147065  * Status register values
2043737Shx147065  */
2053737Shx147065 #define	WL_STAT_CMD_CODE	0x003F
2063737Shx147065 #define	WL_STAT_DIAG_ERR	0x0100
2073737Shx147065 #define	WL_STAT_INQ_ERR		0x0500
2083737Shx147065 #define	WL_STAT_CMD_RESULT	0x7F00
2093737Shx147065 
2103737Shx147065 /*
2113737Shx147065  * memory handle management registers
2123737Shx147065  */
2133737Shx147065 #define	WL_INFO_FID		0x10
2143737Shx147065 #define	WL_RX_FID		0x20
2153737Shx147065 #define	WL_ALLOC_FID		0x22
2163737Shx147065 #define	WL_TX_CMP_FID		0x24
2173737Shx147065 
2183737Shx147065 #define	WL_INVALID_FID		0xffff
2193737Shx147065 
2203737Shx147065 /*
2213737Shx147065  * Buffer Access Path (BAP) registers.
2223737Shx147065  * These are I/O channels.  you can use each one for
2233737Shx147065  * any desired purpose independently of the other. In general
2243737Shx147065  * though, we use BAP1 for reading and writing LTV records and
2253737Shx147065  * reading received data frames, and BAP0 for writing transmit
2263737Shx147065  * frames. This is a convention though, not a rule.
2273737Shx147065  * For PrismII chip, frequently overlap between BAP0 and BAP1
2283737Shx147065  * may hang the hardware. this is a known bug, so just use BAP1
2293737Shx147065  * for PrismII.
2303737Shx147065  */
2313737Shx147065 #define	WL_SEL0			0x18
2323737Shx147065 #define	WL_SEL1			0x1A
2333737Shx147065 #define	WL_OFF0			0x1C
2343737Shx147065 #define	WL_OFF1			0x1E
2353737Shx147065 #define	WL_DATA0		0x36
2363737Shx147065 #define	WL_DATA1		0x38
2373737Shx147065 #define	WL_BAP0			WL_DATA0
2383737Shx147065 #define	WL_BAP1			WL_DATA1
2393737Shx147065 
2403737Shx147065 #define	WL_OFF_BUSY		0x8000
2413737Shx147065 #define	WL_OFF_ERR		0x4000
2423737Shx147065 #define	WL_OFF_DATAOFF		0x0FFF
2433737Shx147065 
2443737Shx147065 /*
2453737Shx147065  * Event registers
2463737Shx147065  */
2473737Shx147065 #define	WL_EVENT_STAT		0x30	/* Event status */
2483737Shx147065 #define	WL_INT_EN		0x32	/* Interrupt enable/disable */
2493737Shx147065 #define	WL_EVENT_ACK		0x34	/* Ack event */
2503737Shx147065 
2513737Shx147065 /*
2523737Shx147065  * Events
2533737Shx147065  */
2543737Shx147065 #define	WL_EV_TICK		0x8000	/* aux timer tick */
2553737Shx147065 #define	WL_EV_RES		0x4000	/* controller h/w error (time out) */
2563737Shx147065 #define	WL_EV_INFO_DROP		0x2000	/* no RAM to build unsolicited frame */
2573737Shx147065 #define	WL_EV_NO_CARD		0x0800	/* card removed (hunh?) */
2583737Shx147065 #define	WL_EV_DUIF_RX		0x0400	/* wavelan management packet received */
2593737Shx147065 #define	WL_EV_INFO		0x0080	/* async info frame */
2603737Shx147065 #define	WL_EV_CMD		0x0010	/* command completed */
2613737Shx147065 #define	WL_EV_ALLOC		0x0008	/* async alloc/reclaim completed */
2623737Shx147065 #define	WL_EV_TX_EXC		0x0004	/* async xmit completed with failure */
2633737Shx147065 #define	WL_EV_TX		0x0002	/* async xmit completed succesfully */
2643737Shx147065 #define	WL_EV_RX		0x0001	/* async rx completed */
2653737Shx147065 
2663737Shx147065 #define	WL_EV_ALL		0xffff	/* all events */
2673737Shx147065 #define	WL_INTRS	\
2683737Shx147065 	(WL_EV_RX|WL_EV_TX|WL_EV_TX_EXC|WL_EV_ALLOC|WL_EV_INFO|WL_EV_INFO_DROP)
2693737Shx147065 
2703737Shx147065 /*
2713737Shx147065  * Host software registers
2723737Shx147065  */
2733737Shx147065 #define	WL_SW0			0x28
2743737Shx147065 #define	WL_SW1			0x2A
2753737Shx147065 #define	WL_SW2			0x2C
2763737Shx147065 #define	WL_SW3			0x2E
2773737Shx147065 
2783737Shx147065 #define	WL_CNTL			0x14
2793737Shx147065 
2803737Shx147065 #define	WL_CNTL_AUX_ENA		0xC000
2813737Shx147065 #define	WL_CNTL_AUX_ENA_STAT	0xC000
2823737Shx147065 #define	WL_CNTL_AUX_DIS_STAT	0x0000
2833737Shx147065 #define	WL_CNTL_AUX_ENA_CNTL	0x8000
2843737Shx147065 #define	WL_CNTL_AUX_DIS_CNTL	0x4000
2853737Shx147065 
2863737Shx147065 #define	WL_AUX_PAGE		0x3A
2873737Shx147065 #define	WL_AUX_OFFSET		0x3C
2883737Shx147065 #define	WL_AUX_DATA		0x3E
2893737Shx147065 
2903737Shx147065 #define	WL_RID_DNLD_BUF		0xFD01
2913737Shx147065 
2923737Shx147065 /*
2933737Shx147065  * Mem sizes (0xFD02).
2943737Shx147065  */
2953737Shx147065 #define	WL_RID_MEMSZ		0xFD02
2963737Shx147065 #define	WL_RID_FWIDENT_P2	0xFD02
2973737Shx147065 
2983737Shx147065 /*
2993737Shx147065  * NIC Identification (0xFD0B).
3003737Shx147065  */
3013737Shx147065 #define	WL_RID_CARD_ID	0xFD0B
3023737Shx147065 
3033737Shx147065 typedef struct pcwl_ltv_ver {
3043737Shx147065 	uint16_t	wl_compid;
3053737Shx147065 	uint16_t	wl_variant;
3063737Shx147065 	uint16_t	wl_major;
3073737Shx147065 	uint16_t	wl_minor;
3083737Shx147065 } pcwl_ltv_ver_t;
3093737Shx147065 
3103737Shx147065 #define	WL_RID_FWVER	0xFFFF
3113737Shx147065 typedef struct pcwl_ltv_fwver {
3123737Shx147065 	uint16_t	pri[7];
3133737Shx147065 	uint16_t	st[7];
3143737Shx147065 } pcwl_ltv_fwver_t;
3153737Shx147065 
3163737Shx147065 #define	WI_NIC_EVB2	0x8000
3173737Shx147065 #define	WI_NIC_HWB3763	0x8001
3183737Shx147065 #define	WI_NIC_HWB3163	0x8002
3193737Shx147065 #define	WI_NIC_HWB3163B	0x8003
3203737Shx147065 #define	WI_NIC_EVB3	0x8004
3213737Shx147065 #define	WI_NIC_HWB1153	0x8007
3223737Shx147065 #define	WI_NIC_P2_SST	0x8008	/* Prism2 with SST flush */
3233737Shx147065 #define	WI_NIC_PRISM2_5	0x800C
3243737Shx147065 #define	WI_NIC_3874A	0x8013	/* Prism2.5 Mini-PCI */
3253737Shx147065 
3263737Shx147065 /*
3273737Shx147065  * List of intended regulatory domains (0xFD11).
3283737Shx147065  */
3293737Shx147065 #define	WL_RID_DOMAINS		0xFD11
3303737Shx147065 /*
3313737Shx147065  * CIS struct (0xFD13).
3323737Shx147065  */
3333737Shx147065 #define	WL_RID_CIS		0xFD13
3343737Shx147065 
3353737Shx147065 /*
3363737Shx147065  * Current MAC port connection status
3373737Shx147065  */
3383737Shx147065 #define	WL_RID_PORTSTATUS	0xFD40
3393737Shx147065 #define	WL_PORT_DISABLED	1
3403737Shx147065 #define	WL_PORT_INITIAL		2
3413737Shx147065 #define	WL_PORT_TO_IBSS		3
3423737Shx147065 #define	WL_PORT_TO_BSS		4
3433737Shx147065 #define	WL_PORT_OOR		5
3443737Shx147065 #define	WL_PORT_RADIO_OFF	7 /* only for miniPci */
3453737Shx147065 
3463737Shx147065 /*
3473737Shx147065  * Current Service Set the station is connected to
3483737Shx147065  */
3493737Shx147065 #define	WL_RID_SSID		0xFD41
3503737Shx147065 
3513737Shx147065 /*
3523737Shx147065  * MAC address used as identifier of the BSS the station
3533737Shx147065  * is connected to
3543737Shx147065  */
3553737Shx147065 #define	WL_RID_BSSID		0xFD42
3563737Shx147065 
3573737Shx147065 /*
3583737Shx147065  * Communications quality (0xFD43).
3593737Shx147065  */
3603737Shx147065 #define	WL_RID_COMMQUAL		0xFD43
3613737Shx147065 
3623737Shx147065 /*
3633737Shx147065  * Actual system scale thresholds (0xFD46).
3643737Shx147065  */
3653737Shx147065 #define	WL_RID_SYSTEM_SCALE	0xFC06
3663737Shx147065 
3673737Shx147065 /*
3683737Shx147065  * Actual current transmission rate
3693737Shx147065  */
3703737Shx147065 #define	WL_RID_CUR_TX_RATE	0xFD44
3713737Shx147065 
3723737Shx147065 /*
3733737Shx147065  * Connection control characteristics.
3743737Shx147065  * 1 == Basic Service Set (BSS), a.k.a IEEE 802.11 Infrastructure
3753737Shx147065  * 2 == Wireless Distribudion System (WDS), Access Point only
3763737Shx147065  * 3 == Pseudo IBSS / Ad Hoc
3773737Shx147065  */
3783737Shx147065 #define	WL_RID_PORTTYPE		0xFC00
3793737Shx147065 #define	WL_PORTTYPE_BSS		0x1
3803737Shx147065 #define	WL_PORTTYPE_WDS		0x2
3813737Shx147065 #define	WL_PORTTYPE_ADHOC	0x3
3823737Shx147065 
3833737Shx147065 /*
3843737Shx147065  * Mac addresses.
3853737Shx147065  */
3863737Shx147065 #define	WL_RID_MAC_NODE		0xFC01
3873737Shx147065 #define	WL_RID_MAC_WDS		0xFC08
3883737Shx147065 
3893737Shx147065 /*
3903737Shx147065  * Station set identification (SSID).
3913737Shx147065  */
3923737Shx147065 #define	WL_RID_DESIRED_SSID	0xFC02
3933737Shx147065 #define	WL_RID_OWN_SSID		0xFC04
3943737Shx147065 
3953737Shx147065 /*
3963737Shx147065  * Set communications channel (radio frequency).
3973737Shx147065  */
3983737Shx147065 #define	WL_RID_OWN_CHNL		0xFC03
3993737Shx147065 #define	WL_RID_CURRENT_CHNL	0xFDC1
4003737Shx147065 
4013737Shx147065 /*
4023737Shx147065  * Frame data size.
4033737Shx147065  */
4043737Shx147065 #define	WL_RID_MAX_DATALEN	0xFC07
4053737Shx147065 
4063737Shx147065 /*
4073737Shx147065  * ESS power management enable
4083737Shx147065  */
4093737Shx147065 #define	WL_RID_PM_ENABLED	0xFC09
4103737Shx147065 
4113737Shx147065 /*
4123737Shx147065  * ESS max PM sleep internal
4133737Shx147065  */
4143737Shx147065 #define	WL_RID_MAX_SLEEP	0xFC0C
4153737Shx147065 
4163737Shx147065 /*
4173737Shx147065  * Set our station name.
4183737Shx147065  */
4193737Shx147065 #define	WL_RID_NODENAME		0xFC0E
4203737Shx147065 
4213737Shx147065 /*
4223737Shx147065  * Multicast addresses to be put in filter. We're
4233737Shx147065  * allowed up to 16 addresses in the filter.
4243737Shx147065  */
4253737Shx147065 #define	WL_RID_MCAST		0xFC80
4263737Shx147065 
4273737Shx147065 /*
4283737Shx147065  * Create IBSS.
4293737Shx147065  */
4303737Shx147065 #define	WL_RID_CREATE_IBSS	0xFC81
4313737Shx147065 
4323737Shx147065 #define	WL_RID_FRAG_THRESH	0xFC82
4333737Shx147065 #define	WL_RID_RTS_THRESH	0xFC83
4343737Shx147065 
4353737Shx147065 /*
4363737Shx147065  * TX rate control
4373737Shx147065  * 0 == Fixed 1mbps
4383737Shx147065  * 1 == Fixed 2mbps
4393737Shx147065  * 2 == auto fallback
4403737Shx147065  */
4413737Shx147065 #define	WL_RID_TX_RATE		0xFC84
4423737Shx147065 
4433737Shx147065 /*
4443737Shx147065  * promiscuous mode.
4453737Shx147065  */
4463737Shx147065 #define	WL_RID_PROMISC		0xFC85
4473737Shx147065 
4483737Shx147065 /*
4493737Shx147065  * scan ssid
4503737Shx147065  */
4513737Shx147065 #define	WL_RID_SCAN_SSID	0xFCB2
4523737Shx147065 
4533737Shx147065 /*
4543737Shx147065  * Auxiliary Timer tick interval
4553737Shx147065  */
4563737Shx147065 #define	WL_RID_TICK_TIME	0xFCE0
4573737Shx147065 
4583737Shx147065 /*
4593737Shx147065  * PrismII scan
4603737Shx147065  */
4613737Shx147065 #define	WL_RID_SCAN_REQUEST	0xFCE1
4623737Shx147065 #define	WL_RID_HSCAN_REQUEST	0xFCE5
4633737Shx147065 
4643737Shx147065 /*
4653737Shx147065  * Information frame types.
4663737Shx147065  */
4673737Shx147065 #define	WL_INFO_NOTIFY		0xF000	/* Handover address */
4683737Shx147065 #define	WL_INFO_COUNTERS	0xF100	/* Statistics counters */
4693737Shx147065 #define	WL_INFO_SCAN_RESULTS	0xF101	/* Scan results */
4703737Shx147065 #define	WL_INFO_HSCAN_RESULTS	0xF103	/* HostScan results */
4713737Shx147065 #define	WL_INFO_LINK_STAT	0xF200	/* Link status */
4723737Shx147065 #define	WL_INFO_ASSOC_STAT	0xF201	/* Association status */
4733737Shx147065 
4743737Shx147065 /*
4753737Shx147065  * Link status
4763737Shx147065  */
4773737Shx147065 #define	WL_LINK_CONNECT		1
4783737Shx147065 #define	WL_LINK_DISCONNECT	2
4793737Shx147065 #define	WL_LINK_AP_CR		3 /* AP change */
4803737Shx147065 #define	WL_LINK_AP_OOR		4 /* AP out of range */
4813737Shx147065 #define	WL_LINK_AP_IR		5 /* AP in range */
4823737Shx147065 
4833737Shx147065 typedef struct wl_scan_result {
4843737Shx147065 	uint16_t		wl_srt_chid;  /* bss channel id */
4853737Shx147065 	uint16_t		wl_srt_anl;   /* noise level */
4863737Shx147065 	uint16_t		wl_srt_sl;    /* signal level */
4873737Shx147065 	uint8_t			wl_srt_bssid[6];  /* mac address of the bss */
4883737Shx147065 	uint16_t		wl_srt_bcnint; /* bss beacon interval */
4893737Shx147065 	uint16_t		wl_srt_cap;    /* bss capability */
4903737Shx147065 
4913737Shx147065 	uint16_t		wl_srt_ssidlen;  /* ssid name length */
4923737Shx147065 	char			wl_srt_ssid[32]; /* ssid */
4933737Shx147065 
4943737Shx147065 	uint16_t		wl_srt_suprates[5]; /* supported rates */
4953737Shx147065 	uint16_t		wl_srt_rate; /* actual data rate of the probe */
4963737Shx147065 	uint16_t		wl_srt_atim;
4973737Shx147065 } wl_scan_result_t;
4983737Shx147065 
4993737Shx147065 #define	WL_SRT_MAX_NUM		32 /* max number of scan result stored */
5003737Shx147065 #define	WL_SCAN_TIMEOUT_MAX	30 /* seconds after which the scan item ages */
5013737Shx147065 #define	WL_SCAN_AGAIN_THRESHOLD	5 /* threshold below which card scan again */
5023737Shx147065 #define	WL_MAX_SCAN_TIMES	2 /* max scan times per scan command */
5033737Shx147065 
5043737Shx147065 typedef struct wl_scan_list {
5053737Shx147065 	wl_scan_result_t	wl_val;
5063737Shx147065 	uint32_t		wl_timeout;
5073737Shx147065 	list_node_t		wl_scan_node;
5083737Shx147065 } wl_scan_list_t;
5093737Shx147065 
5103737Shx147065 #define	WL_FTYPE_MGMT		0x0000
5113737Shx147065 #define	WL_FTYPE_CTL		0x0004
5123737Shx147065 #define	WL_FTYPE_DATA		0x0008
5133737Shx147065 
5143737Shx147065 /*
5153737Shx147065  * SNAP (sub-network access protocol) constants for transmission
5163737Shx147065  * of IP datagrams over IEEE 802 networks, taken from RFC1042.
5173737Shx147065  * We need these for the LLC/SNAP header fields in the TX/RX frame
5183737Shx147065  * structure.
5193737Shx147065  */
5203737Shx147065 #define	WL_SNAP_K1		0xaa	/* assigned global SAP for SNAP */
5213737Shx147065 #define	WL_SNAP_K2		0x00
5223737Shx147065 #define	WL_SNAP_CONTROL		0x03	/* unnumbered information format */
5233737Shx147065 #define	WL_SNAP_WORD0		(WL_SNAP_K1 | (WL_SNAP_K1 << 8))
5243737Shx147065 #define	WL_SNAP_WORD1		(WL_SNAP_K2 | (WL_SNAP_CONTROL << 8))
5253737Shx147065 #define	WL_SNAPHDR_LEN		0x6
5263737Shx147065 
5273737Shx147065 /*
5283737Shx147065  * Hermes transmit/receive frame structure
5293737Shx147065  */
5303737Shx147065 typedef struct wl_frame {
5313737Shx147065 	uint16_t		wl_status;	/* 0x00 */
5323737Shx147065 	uint16_t		wl_rsvd0;	/* 0x02 */
5333737Shx147065 	uint16_t		wl_rsvd1;	/* 0x04 */
5343737Shx147065 	uint16_t		wl_q_info;	/* 0x06 */
5353737Shx147065 	uint16_t		wl_rsvd2;	/* 0x08 */
5363737Shx147065 	uint16_t		wl_rsvd3;	/* 0x0A */
5373737Shx147065 	uint16_t		wl_tx_ctl;	/* 0x0C */
5383737Shx147065 	uint16_t		wl_frame_ctl;	/* 0x0E */
5393737Shx147065 	uint16_t		wl_id;		/* 0x10 */
5403737Shx147065 	uint8_t			wl_addr1[6];	/* 0x12 */
5413737Shx147065 	uint8_t			wl_addr2[6];	/* 0x18 */
5423737Shx147065 	uint8_t			wl_addr3[6];	/* 0x1E */
5433737Shx147065 	uint16_t		wl_seq_ctl;	/* 0x24 */
5443737Shx147065 	uint8_t			wl_addr4[6];	/* 0x26 */
5453737Shx147065 	uint16_t		wl_dat_len;	/* 0x2C */
5463737Shx147065 
5473737Shx147065 	uint8_t			wl_dst_addr[6];	/* 0x2E */
5483737Shx147065 	uint8_t			wl_src_addr[6];	/* 0x34 */
5493737Shx147065 	uint16_t		wl_len;		/* 0x3A */
5503737Shx147065 	uint16_t		wl_dat[3];	/* 0x3C */ /* SNAP header */
5513737Shx147065 	uint16_t		wl_type;	/* 0x42 */
5523737Shx147065 } wl_frame_t;
5533737Shx147065 
5543737Shx147065 static wl_frame_t wl_frame_default = {
5553737Shx147065 	0,			/* wl_status	   0x00 */
5563737Shx147065 	0,			/* wl_rsvd0	   0x02 */
5573737Shx147065 	0,			/* wl_rsvd1	   0x04 */
5583737Shx147065 	0,			/* wl_q_info	   0x06 */
5593737Shx147065 	0,			/* wl_rsvd2	   0x08 */
5603737Shx147065 	0,			/* wl_rsvd3	   0x0A */
5613737Shx147065 	0,			/* wl_tx_ctl	   0x0C */
5623737Shx147065 	WL_FTYPE_DATA,		/* wl_frame_ctl	   0x0E */
5633737Shx147065 	0,			/* wl_id	   0x10 */
5643737Shx147065 	{ 0, 0, 0, 0, 0, 0 },	/* wl_addr1[6]	   0x12 */
5653737Shx147065 	{ 0, 0, 0, 0, 0, 0 },	/* wl_addr2[6]	   0x18 */
5663737Shx147065 	{ 0, 0, 0, 0, 0, 0 },	/* wl_addr3[6]	   0x1E */
5673737Shx147065 	0,			/* wl_seq_ctl	   0x24 */
5683737Shx147065 	{ 0, 0, 0, 0, 0, 0 },	/* wl_addr4[6]	   0x26 */
5693737Shx147065 	(uint16_t)-WL_SNAPHDR_LEN, /* wl_dat_len	   0x2C */
5703737Shx147065 
5713737Shx147065 	{ 0, 0, 0, 0, 0, 0 },	/* wl_dst_addr[6]  0x2E */
5723737Shx147065 	{ 0, 0, 0, 0, 0, 0 },	/* wl_src_addr[6]  0x34 */
5733737Shx147065 	(uint16_t)-WL_SNAPHDR_LEN, /* wl_len	   0x3A */
5743737Shx147065 	{ WL_SNAP_WORD0,
5753737Shx147065 	WL_SNAP_WORD1, 0 },	/* wl_dat[3]	   0x3C */ /* SNAP header */
5763737Shx147065 	0			/* wl_type	   0x42 */
5773737Shx147065 };
5783737Shx147065 
5793737Shx147065 #define	MLEN(mp)		((mp)->b_wptr - (mp)->b_rptr)
5803737Shx147065 #define	ETH_HDRLEN		(sizeof (struct ether_header))
5813737Shx147065 #define	WL_802_3_HDRLEN		0x2E
5823737Shx147065 #define	WL_802_11_HDRLEN	0x44
5833737Shx147065 #define	WL_802_11_RAW_HDRLEN	0x3C
5843737Shx147065 
5853737Shx147065 #define	WL_STAT_BADCRC		0x0001
5863737Shx147065 #define	WL_STAT_UNDECRYPTABLE	0x0002
5873737Shx147065 #define	WL_STAT_ERRSTAT		0x0003
5883737Shx147065 #define	WL_STAT_MAC_PORT	0x0700
5893737Shx147065 #define	WL_STAT_1042		0x2000	/* RFC1042 encoded */
5903737Shx147065 #define	WL_STAT_TUNNEL		0x4000	/* Bridge-tunnel encoded */
5913737Shx147065 #define	WL_STAT_WMP_MSG		0x6000	/* WaveLAN-II management protocol */
5923737Shx147065 #define	WL_RXSTAT_MSG_TYPE	0xE000
5933737Shx147065 
5943737Shx147065 #define	WL_ENC_TX_802_3		0x00
5953737Shx147065 #define	WL_ENC_TX_802_11	0x11
5963737Shx147065 #define	WL_ENC_TX_E_II		0x0E
5973737Shx147065 
5983737Shx147065 #define	WL_ENC_TX_1042		0x00
5993737Shx147065 #define	WL_ENC_TX_TUNNEL	0xF8
6003737Shx147065 
6013737Shx147065 #define	WL_TXCNTL_MACPORT	0x00FF
6023737Shx147065 #define	WL_TXCNTL_STRUCTTYPE	0xFF00
6033737Shx147065 #define	WL_TXCNTL_TXOK		0x2
6043737Shx147065 #define	WL_TXCNTL_TXEX		0x4
6053737Shx147065 #define	WL_TXCNTL_SET	(WL_TXCNTL_TXOK | WL_TXCNTL_TXEX)
6063737Shx147065 
6073737Shx147065 typedef struct rf_ckey {
6083737Shx147065 	uint16_t	ckey_len;
6093737Shx147065 	uint8_t		ckey_dat[14];
6103737Shx147065 } rf_ckey_t;
6113737Shx147065 
6123737Shx147065 /*
6133737Shx147065  * Configurable parameters of the RF interface
6143737Shx147065  * All the info here is passed to the card through PIO.
6153737Shx147065  */
6163737Shx147065 typedef struct pcwl_rf {
6173737Shx147065 	uint16_t	rf_max_datalen;
6183737Shx147065 	uint16_t	rf_create_ibss;
6193737Shx147065 	uint16_t	rf_porttype;
6203737Shx147065 	uint16_t	rf_rts_thresh;
6213737Shx147065 	uint16_t	rf_tx_rate;
6223737Shx147065 	uint16_t	rf_system_scale;
6233737Shx147065 	uint16_t	rf_pm_enabled;
6243737Shx147065 	uint16_t	rf_max_sleep;
6253737Shx147065 	uint16_t	rf_own_chnl;
6263737Shx147065 	uint16_t	rf_port_no;
6273737Shx147065 	char		rf_own_ssid[34];
6283737Shx147065 	char		rf_desired_ssid[34];
6293737Shx147065 	char		rf_nodename[34];
6303737Shx147065 	uint16_t	rf_promiscuous;
6313737Shx147065 	uint16_t	rf_encryption;		/* use encryption? */
6323737Shx147065 	uint16_t	rf_authtype;		/* prism2 only */
6333737Shx147065 	uint16_t	rf_tx_crypt_key;
6343737Shx147065 	rf_ckey_t	rf_ckeys[4];
6353737Shx147065 } pcwl_rf_t;
6363737Shx147065 
6373737Shx147065 #define	PCWL_MCAST_ENTSHIFT	4
6383737Shx147065 #define	PCWL_MCAST_ENTRIES	(1 << PCWL_MCAST_ENTSHIFT)
6393737Shx147065 #define	PCWL_MCBUF_LEN		(ETHERADDRL << PCWL_MCAST_ENTSHIFT)
6403737Shx147065 #define	PCWL_MCBUF_WORDS	(PCWL_MCBUF_LEN >> 1)
6413737Shx147065 
6423737Shx147065 typedef enum {
6433737Shx147065 	WLC_TX_UNICAST_FRAMES,		/*  0+ */
6443737Shx147065 	WLC_TX_MULTICAST_FRAMES,	/*  1+ */
6453737Shx147065 	WLC_TX_FRAGMENTS,		/*  2+ */
6463737Shx147065 	WLC_TX_UNICAST_OCTETS,		/*  3+ */
6473737Shx147065 	WLC_TX_MULTICAST_OCTETS,	/*  4  */
6483737Shx147065 	WLC_TX_DEFERRED_XMITS,		/*  5+ */
6493737Shx147065 	WLC_TX_SINGLE_RETRIES,		/*  6+ */
6503737Shx147065 	WLC_TX_MULTI_RETRIES,		/*  7+ */
6513737Shx147065 	WLC_TX_RETRY_LIMIT,		/*  8+ */
6523737Shx147065 	WLC_TX_DISCARDS,		/*  9+ */
6533737Shx147065 	WLC_RX_UNICAST_FRAMES,		/* 10+ */
6543737Shx147065 	WLC_RX_MULTICAST_FRAMES,	/* 11+ */
6553737Shx147065 	WLC_RX_FRAGMENTS,		/* 12+ */
6563737Shx147065 	WLC_RX_UNICAST_OCTETS,		/* 13+ */
6573737Shx147065 	WLC_RX_MULTICAST_OCTETS,	/* 14  */
6583737Shx147065 	WLC_RX_FCS_ERRORS,		/* 15+ */
6593737Shx147065 	WLC_RX_DISCARDS_NOBUF,		/* 16+ */
6603737Shx147065 	WLC_TX_DISCARDS_WRONG_SA,	/* 17+ */
6613737Shx147065 	WLC_RX_WEP_CANT_DECRYPT,	/* 18+ */
6623737Shx147065 	WLC_RX_MSG_IN_MSG_FRAGS,	/* 19+ */
6633737Shx147065 	WLC_RX_MSG_IN_BAD_MSG_FRAGS,	/* 20+ */
6643737Shx147065 	WLC_STAT_CNT			/* 21 - keep it as the last entry */
6653737Shx147065 } pcwl_cntr_offset;
6663737Shx147065 
6673737Shx147065 #define	WL_XMT_BUF_NUM	8
6683737Shx147065 typedef struct	wl_tx_ring_data {
6693737Shx147065 	uint16_t		wl_tx_fids[WL_XMT_BUF_NUM];
6703737Shx147065 	uint16_t		wl_tx_ring[WL_XMT_BUF_NUM];
6713737Shx147065 	int			wl_tx_prod;
6723737Shx147065 	int			wl_tx_cons;
6733737Shx147065 	kmutex_t		wl_tx_lock;	/* for send only */
6743737Shx147065 } pcwl_txring_t;
6753737Shx147065 
6763737Shx147065 #define	PCWL_DEVICE_PCI		0
6773737Shx147065 #define	PCWL_DEVICE_PCCARD	1
6783737Shx147065 
6793737Shx147065 /*
6803737Shx147065  * The macinfo is really used as the softstate structure.
6813737Shx147065  *
6823737Shx147065  * pcwl_mh	 - mac_handle_t structure
6833737Shx147065  * pcwl_cslock	 - lock for card services request. Used with pcwl_cscv
6843737Shx147065  * pcwl_cscv	 - condition variable to wait for card events
6853737Shx147065  * pcwl_chdl	 - client handle, an uint32_t bit mask encoding for socket,
6863737Shx147065  *			function, and client info.
6873737Shx147065  *			See cs_priv.h MAKE_CLIENT_HANDLE.
6883737Shx147065  * pcwl_log_sock - holds the logical to physical translation for this card.
6893737Shx147065  *			Specifically has physical adapter and socket #.
6903737Shx147065  *			Socket # is the same as part of the pcwl_chdl encoding.
6913737Shx147065  *			Physical adapter # is from card service socket impl.
6923737Shx147065  */
6933737Shx147065 typedef struct pcwl_macinfo {
6943737Shx147065 	mac_handle_t		pcwl_mh;
6953737Shx147065 	dev_info_t		*pcwl_dip;
6963737Shx147065 	int			pcwl_device_type; /* pci or pcmcia card */
6973737Shx147065 	kmutex_t		pcwl_cslock;	/* for card services */
6983737Shx147065 	kcondvar_t		pcwl_cscv;	/* for card services */
6993737Shx147065 	client_handle_t		pcwl_chdl;	/* s,f,c encoding, cs_priv.h */
7003737Shx147065 	map_log_socket_t	pcwl_log_sock;	/* logical/phys socket map */
7013737Shx147065 
7023737Shx147065 	int			pcwl_socket;    /* socket number */
7033737Shx147065 	int			pcwl_config_hi;	/* cfttbl index */
7043737Shx147065 	int			pcwl_config;	/* default config index */
7053737Shx147065 	int			pcwl_vcc;	/* vcc level */
7063737Shx147065 	int			pcwl_iodecode;	/* # of address lines */
7073737Shx147065 	int			pcwl_chip_type;	/* Lucent or Prism-II */
7083737Shx147065 
7093737Shx147065 	uint8_t 		pcwl_mac_addr[ETHERADDRL];
7103737Shx147065 	uint8_t 		pcwl_bssid[ETHERADDRL];
7113737Shx147065 	uint16_t		pcwl_has_wep;	/* has encryption capability */
7123737Shx147065 	uint32_t		pcwl_flag;
7133737Shx147065 	uint32_t		pcwl_reschedule_need;
7143737Shx147065 	pcwl_rf_t		pcwl_rf;	/* RF interface parameters */
7153737Shx147065 
7163737Shx147065 	uint16_t		pcwl_dmem_id;	/* nic mem id for tx buffer */
7173737Shx147065 	uint16_t		pcwl_mgmt_id;	/* nic mem id for mgmt buffer */
7183737Shx147065 	pcwl_txring_t		pcwl_txring;
7193737Shx147065 
7203737Shx147065 	uint16_t		pcwl_mcast[PCWL_MCBUF_WORDS]; /* MC filters */
7213737Shx147065 
7223737Shx147065 	kmutex_t		pcwl_scanlist_lock;	/* scanlist lock */
7233737Shx147065 	kmutex_t		pcwl_glock;	/* generic lock */
7243737Shx147065 
7253737Shx147065 	caddr_t			pcwl_bar;	/* for pci device only */
7263737Shx147065 	ddi_acc_handle_t	pcwl_handle;
7273737Shx147065 	caddr_t			pcwl_cfg_base;
7283737Shx147065 	ddi_acc_handle_t	pcwl_cfg_handle;
7293737Shx147065 
7303737Shx147065 	ddi_acc_handle_t	pcwl_port;	/* for pcmcia device only */
7313737Shx147065 
7323737Shx147065 	ddi_iblock_cookie_t	pcwl_ib_cookie;
7333737Shx147065 	ddi_softintr_t		pcwl_softint_id; /* pcwl_intr soft intr id */
7343737Shx147065 
7353737Shx147065 	uint16_t		pcwl_cntrs_t[WLC_STAT_CNT];
7363737Shx147065 	uint64_t		pcwl_cntrs_s[WLC_STAT_CNT];
7373737Shx147065 	uint64_t		pcwl_noxmtbuf;
7383737Shx147065 	timeout_id_t		pcwl_scanlist_timeout_id;
7393737Shx147065 	list_t			pcwl_scan_list;
7403737Shx147065 	uint16_t		pcwl_scan_num;
7413737Shx147065 	uint16_t		pcwl_rssi;
7423737Shx147065 	timeout_id_t		pcwl_connect_timeout_id;
7433737Shx147065 } pcwl_maci_t;
7443737Shx147065 
7453737Shx147065 #define	PCWL_IDENT_STRING	modldrv.drv_linkinfo
7463737Shx147065 #define	PCWL_CHIP_LUCENT	0
7473737Shx147065 #define	PCWL_CHIP_PRISMII	1
7483737Shx147065 #define	HDL(pcwl_p)		((pcwl_p)->pcwl_port)
7493737Shx147065 #define	GLD3(pcwl_p)		((pcwl_p)->pcwl_mh)
7503737Shx147065 #define	DIP(pcwl_p)		((pcwl_p)->pcwl_dip)
7513737Shx147065 #define	RF(pcwl_p)		(&(pcwl_p)->pcwl_rf)
7523737Shx147065 
7533737Shx147065 #define	PCWL_CARD_INTREN	0x1
7543737Shx147065 #define	PCWL_SOFTINTR		0x2	/* high level and soft intr enabled */
7553737Shx147065 #define	PCWL_CARD_LINKUP	0x4	/* link status of the STA */
7563737Shx147065 #define	PCWL_CARD_GSTAT		0x8
7573737Shx147065 #define	PCWL_ATTACHED		0x10
7583737Shx147065 #define	PCWL_CS_REGISTERED	0x20
7593737Shx147065 #define	PCWL_ENABLED		0x40
7603737Shx147065 #define	PCWL_CARD_READY		0x80
7613737Shx147065 #define	PCWL_CARD_FAILED	0x100
7623737Shx147065 #define	PCWL_CARD_INTR		0x200
763*11101SMikore.Li@Sun.COM #define	PCWL_CARD_PLUMBED	0x400
764*11101SMikore.Li@Sun.COM #define	PCWL_CARD_SUSPEND	0x800
7653737Shx147065 
7663737Shx147065 #define	PCWL_STATE_IDLE		0x1
7673737Shx147065 
7683737Shx147065 #define	PCWL_NICMEM_SZ		(2048) /* 80211MTU set as 1500, so 2k here */
7693737Shx147065 
7703737Shx147065 static int	pcwl_probe(dev_info_t *dip);
7713737Shx147065 static int	pcwl_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
7723737Shx147065 static int	pcwl_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
7733737Shx147065 
7743737Shx147065 static int	pcwl_register_cs(dev_info_t *dip, pcwl_maci_t *pcwl_p);
7753737Shx147065 static void	pcwl_unregister_cs(pcwl_maci_t *pcwl_p);
7763737Shx147065 static void	pcwl_destroy_locks(pcwl_maci_t *pcwl_p);
7773737Shx147065 static int	pcwl_reset_backend(pcwl_maci_t *pcwl_p);
7783737Shx147065 static int	pcwl_get_cap(pcwl_maci_t *pcwl_p);
7793737Shx147065 static int	pcwl_card_insert(pcwl_maci_t *pcwl_p);
7803737Shx147065 static int	pcwl_ev_hdlr(event_t ev, int pri, event_callback_args_t *arg);
7813737Shx147065 static void	pcwl_card_remove(pcwl_maci_t *pcwl_p);
7823737Shx147065 static int	pcwl_init_nicmem(pcwl_maci_t *pcwl_p);
7833737Shx147065 
7843737Shx147065 /*
7853737Shx147065  * high level device access primitives, glock must held before calling
7863737Shx147065  */
7873737Shx147065 static uint16_t	pcwl_set_cmd(pcwl_maci_t *pcwl_p, uint16_t mode, uint16_t type);
7883737Shx147065 static uint16_t pcwl_set_ch(pcwl_maci_t *, uint16_t, uint16_t, uint16_t);
7893737Shx147065 static uint16_t	pcwl_get_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type,
7903737Shx147065 			uint16_t *val_p);
7913737Shx147065 static uint16_t	pcwl_put_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type,
7923737Shx147065 			uint16_t *val_p);
7933737Shx147065 static uint16_t	pcwl_fil_ltv(pcwl_maci_t *pcwl_p, uint16_t len, uint16_t type,
7943737Shx147065 			uint16_t val);
7953737Shx147065 static uint16_t	pcwl_put_str(pcwl_maci_t *pcwl_p, uint16_t type, char *str_p);
7963737Shx147065 static uint16_t pcwl_rdch0(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off,
7973737Shx147065 			uint16_t *buf_p, int len, int order);
7983737Shx147065 static uint16_t pcwl_wrch1(pcwl_maci_t *pcwl_p, uint16_t type, uint16_t off,
7993737Shx147065 			uint16_t *buf_p, int len, int order);
8003737Shx147065 static int	pcwl_config_rf(pcwl_maci_t *pcwl_p);
8013737Shx147065 static int	pcwl_loaddef_rf(pcwl_maci_t *pcwl_p);
8023737Shx147065 static void	pcwl_start_locked(pcwl_maci_t *pcwl_p);
8033737Shx147065 static void	pcwl_stop_locked(pcwl_maci_t *pcwl_p);
8043737Shx147065 static int	pcwl_saddr_locked(pcwl_maci_t *pcwl_p);
8053737Shx147065 static uint16_t	pcwl_alloc_nicmem(pcwl_maci_t *pcwl_p, uint16_t len,
8063737Shx147065 			uint16_t *id_p);
8073737Shx147065 static void	pcwl_chip_type(pcwl_maci_t *pcwl_p);
8083737Shx147065 
8093737Shx147065 /*
8103737Shx147065  * Required driver entry points for mac
8113737Shx147065  */
8123737Shx147065 static int	pcwl_start(void *);
8133737Shx147065 static void	pcwl_stop(void *);
8143737Shx147065 static int	pcwl_saddr(void *, const uint8_t *);
8153737Shx147065 static mblk_t	*pcwl_tx(void *, mblk_t *);
8163737Shx147065 static int	pcwl_send(pcwl_maci_t *, mblk_t *);
8173737Shx147065 static int	pcwl_prom(void *, boolean_t);
8183737Shx147065 static int	pcwl_gstat(void *, uint_t, uint64_t *);
8193737Shx147065 static int	pcwl_sdmulti(void *, boolean_t, const uint8_t *);
8203737Shx147065 static void 	pcwl_ioctl(void *, queue_t *, mblk_t *);
8213737Shx147065 
8223737Shx147065 static uint_t	pcwl_intr(caddr_t arg);
8233737Shx147065 static uint_t	pcwl_intr_hi(caddr_t arg);
8243737Shx147065 static void	pcwl_rcv(pcwl_maci_t *pcwl_p);
8253737Shx147065 static uint32_t pcwl_txdone(pcwl_maci_t *pcwl_p);
8263737Shx147065 static void pcwl_infodone(pcwl_maci_t *pcwl_p);
8273737Shx147065 static void 	pcwl_ssid_scan(pcwl_maci_t *, uint16_t, uint16_t, uint16_t);
8283737Shx147065 
8293737Shx147065 /*
8303737Shx147065  * prototypes of the function for wifi ioctl
8313737Shx147065  */
8323737Shx147065 static int	pcwl_cfg_essid(mblk_t *, pcwl_maci_t *, uint32_t);
8333737Shx147065 static int	pcwl_cfg_bssid(mblk_t *, pcwl_maci_t *, uint32_t);
8343737Shx147065 static int	pcwl_cfg_scan(mblk_t *, pcwl_maci_t *, uint32_t);
8353737Shx147065 static int	pcwl_cfg_linkstatus(mblk_t *, pcwl_maci_t *, uint32_t);
8363737Shx147065 static int	pcwl_cfg_bsstype(mblk_t *, pcwl_maci_t *, uint32_t);
8373737Shx147065 static int	pcwl_cfg_phy(mblk_t *, pcwl_maci_t *, uint32_t);
8383737Shx147065 static int	pcwl_cfg_desiredrates(mblk_t *, pcwl_maci_t *, uint32_t);
8393737Shx147065 static int	pcwl_cfg_supportrates(mblk_t *, pcwl_maci_t *, uint32_t);
8403737Shx147065 static int	pcwl_cfg_powermode(mblk_t *, pcwl_maci_t *, uint32_t);
8413737Shx147065 static int	pcwl_cfg_authmode(mblk_t *, pcwl_maci_t *, uint32_t);
8423737Shx147065 static int	pcwl_cfg_encryption(mblk_t *, pcwl_maci_t *, uint32_t);
8433737Shx147065 static int	pcwl_cfg_wepkeyid(mblk_t *, pcwl_maci_t *, uint32_t);
8443737Shx147065 static int	pcwl_cfg_createibss(mblk_t *, pcwl_maci_t *, uint32_t);
8453737Shx147065 static int	pcwl_cfg_rssi(mblk_t *, pcwl_maci_t *, uint32_t);
8463737Shx147065 static int	pcwl_cfg_radio(mblk_t *, pcwl_maci_t *, uint32_t);
8473737Shx147065 static int	pcwl_cfg_wepkey(mblk_t *, pcwl_maci_t *, uint32_t);
8483737Shx147065 static void	pcwl_wlan_ioctl(pcwl_maci_t *, queue_t *, mblk_t *, uint32_t);
8493737Shx147065 static int	pcwl_getset(mblk_t *, pcwl_maci_t *, uint32_t);
8503737Shx147065 
8513737Shx147065 static void	pcwl_scanlist_timeout(void *);
8523737Shx147065 static void	pcwl_delete_scan_item(pcwl_maci_t *, wl_scan_list_t *);
8533737Shx147065 static int	pcwl_add_scan_item(pcwl_maci_t *, wl_scan_result_t);
8543737Shx147065 static void	pcwl_get_rssi(pcwl_maci_t *);
8553737Shx147065 static void 	pcwl_connect_timeout(void *arg);
8563737Shx147065 
8573737Shx147065 #define	RDCH0(h, t, o, b_p, l)	pcwl_rdch0(h, t, o, b_p, l, 1)
8583737Shx147065 #define	WRCH1(h, t, o, b_p, l)	pcwl_wrch1(h, t, o, b_p, l, 1)
8593737Shx147065 #define	RDPKT(h, t, o, b_p, l)	pcwl_rdch0(h, t, o, b_p, l, 0)
8603737Shx147065 #define	WRPKT(h, t, o, b_p, l)	pcwl_wrch1(h, t, o, b_p, l, 0)
8613737Shx147065 
8623737Shx147065 #define	FIL_LTV(pcwl_p, len, type, val)	 \
8633737Shx147065 	(void) pcwl_fil_ltv(pcwl_p, len, type, val)
8643737Shx147065 #define	PUT_LTV(pcwl_p, len, type, v_p)	 \
8653737Shx147065 	(void) pcwl_put_ltv(pcwl_p, len, type, v_p)
8663737Shx147065 #define	PUT_STR(pcwl_p, type, str_p)	\
8673737Shx147065 	(void) pcwl_put_str(pcwl_p, type, str_p)
8683737Shx147065 
8693737Shx147065 #define	PCWL_READ(p, o, v)	{ \
8703737Shx147065 	if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \
8713737Shx147065 		uint16_t t = ddi_get16(p->pcwl_handle, \
8723737Shx147065 		    (uint16_t *)(p->pcwl_bar + 2*(o))); \
8733737Shx147065 		v = LE_16(t); \
8743737Shx147065 	} else { \
8753737Shx147065 		uint16_t t = csx_Get16(HDL(p), o); \
8763737Shx147065 		v = LE_16(t); \
8773737Shx147065 	}\
8783737Shx147065 }
8793737Shx147065 #define	PCWL_WRITE(p, o, v)	{ \
8803737Shx147065 	if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \
8813737Shx147065 		ddi_put16(p->pcwl_handle, \
8823737Shx147065 		    (uint16_t *)(p->pcwl_bar + 2*(o)), LE_16(v)); \
8833737Shx147065 	} else { \
8843737Shx147065 		csx_Put16(HDL(p), o, LE_16(v)); \
8853737Shx147065 	}\
8863737Shx147065 }
8873737Shx147065 #define	PCWL_READ_P(p, o, v, h)	{ \
8883737Shx147065 	if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \
8893737Shx147065 		uint16_t t = ddi_get16(p->pcwl_handle, \
8903737Shx147065 		    (uint16_t *)(p->pcwl_bar + 2*(o))); \
8913737Shx147065 		*(v) = h ? LE_16(t) : t; \
8923737Shx147065 	} else { \
8933737Shx147065 		uint16_t t = csx_Get16(HDL(p), o); \
8943737Shx147065 		*(v) = h ? LE_16(t) : t; \
8953737Shx147065 	}\
8963737Shx147065 }
8973737Shx147065 #define	PCWL_WRITE_P(p, o, v, h)	{ \
8983737Shx147065 	if (p->pcwl_device_type == PCWL_DEVICE_PCI) { \
8993737Shx147065 		ddi_put16(p->pcwl_handle, (uint16_t *)(p->pcwl_bar + 2*(o)), \
9003737Shx147065 		    h ? LE_16(*(v)) : (*(v))); \
9013737Shx147065 	} else {\
9023737Shx147065 		csx_Put16(HDL(p), o, h ? LE_16(*(v)) : (*(v))); \
9033737Shx147065 	}\
9043737Shx147065 }
9053737Shx147065 
9063737Shx147065 #ifdef _BIG_ENDIAN
9073737Shx147065 #define	PCWL_SWAP16(buf_p, len) { \
9083737Shx147065 	int pcwl_swap_len = len; \
9093737Shx147065 	for (pcwl_swap_len = (pcwl_swap_len + 1) >> 1; pcwl_swap_len; ) { \
9103737Shx147065 		uint16_t val; \
9113737Shx147065 		pcwl_swap_len--; \
9123737Shx147065 		val = *((uint16_t *)(buf_p) + pcwl_swap_len); \
9133737Shx147065 		*((uint16_t *)(buf_p) + pcwl_swap_len) = LE_16(val); \
9143737Shx147065 	} \
9153737Shx147065 }
9163737Shx147065 #else /* _BIG_ENDIAN */
9173737Shx147065 #define	PCWL_SWAP16(buf_p, len)
9183737Shx147065 #endif /* _BIG_ENDIAN */
9193737Shx147065 
9203737Shx147065 #define	PCWL_ENABLE_INTR(pcwl_p)	{\
9213737Shx147065 	PCWL_WRITE(pcwl_p, WL_INT_EN, WL_INTRS);\
9223737Shx147065 }
9233737Shx147065 #define	PCWL_DISABLE_INTR(pcwl_p)	{ \
9243737Shx147065 	PCWL_WRITE(pcwl_p, WL_INT_EN, 0); \
9253737Shx147065 	PCWL_WRITE(pcwl_p, WL_EVENT_ACK, 0xffff);\
9263737Shx147065 }
9273737Shx147065 
9283737Shx147065 /*
9293737Shx147065  * 16-bit driver private status code
9303737Shx147065  */
9313737Shx147065 #define	PCWL_SUCCESS		0x0
9323737Shx147065 #define	PCWL_FAIL		0x1
9333737Shx147065 #define	PCWL_TIMEDOUT_CMD	0x10
9343737Shx147065 #define	PCWL_TIMEDOUT_ACCESS	0x11
9353737Shx147065 #define	PCWL_TIMEDOUT_TARGET	0x12
9363737Shx147065 #define	PCWL_BADLEN		0x13
9373737Shx147065 #define	PCWL_BADTYPE		0x14
9383737Shx147065 #define	PCWL_TIMEDOUT_ALLOC	0x15
9393737Shx147065 #define	PCWL_FAILURE_CMD	0x16
9403737Shx147065 
9413737Shx147065 #define	PCWL_STATUS_MAX		0xffff
9423737Shx147065 #define	N_PCWL			2
9433737Shx147065 
9443737Shx147065 #ifdef	__cplusplus
9453737Shx147065 }
9463737Shx147065 #endif
9473737Shx147065 
9483737Shx147065 #endif	/* _SYS_PCWL_H */
949