xref: /openbsd-src/sys/dev/ic/if_wireg.h (revision 7bb4d3220c8c9b30e349540aeb02304ce7019ce9)
1*7bb4d322Stedu /*	$OpenBSD: if_wireg.h,v 1.40 2011/06/21 16:52:45 tedu Exp $	*/
22cf71003Smillert 
32cf71003Smillert /*
42cf71003Smillert  * Copyright (c) 1997, 1998, 1999
52cf71003Smillert  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
62cf71003Smillert  *
72cf71003Smillert  * Redistribution and use in source and binary forms, with or without
82cf71003Smillert  * modification, are permitted provided that the following conditions
92cf71003Smillert  * are met:
102cf71003Smillert  * 1. Redistributions of source code must retain the above copyright
112cf71003Smillert  *    notice, this list of conditions and the following disclaimer.
122cf71003Smillert  * 2. Redistributions in binary form must reproduce the above copyright
132cf71003Smillert  *    notice, this list of conditions and the following disclaimer in the
142cf71003Smillert  *    documentation and/or other materials provided with the distribution.
152cf71003Smillert  * 3. All advertising materials mentioning features or use of this software
162cf71003Smillert  *    must display the following acknowledgement:
172cf71003Smillert  *	This product includes software developed by Bill Paul.
182cf71003Smillert  * 4. Neither the name of the author nor the names of any co-contributors
192cf71003Smillert  *    may be used to endorse or promote products derived from this software
202cf71003Smillert  *    without specific prior written permission.
212cf71003Smillert  *
222cf71003Smillert  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
232cf71003Smillert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
242cf71003Smillert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
252cf71003Smillert  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
262cf71003Smillert  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
272cf71003Smillert  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
282cf71003Smillert  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
292cf71003Smillert  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
302cf71003Smillert  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
312cf71003Smillert  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
322cf71003Smillert  * THE POSSIBILITY OF SUCH DAMAGE.
332cf71003Smillert  *
341de77e4fSmickey  *	From: if_wireg.h,v 1.8.2.2 2001/08/25 00:48:25 nsayer Exp $
352cf71003Smillert  */
362cf71003Smillert 
37375f9aaeSmillert #define WI_DELAY	5
38375f9aaeSmillert #define WI_TIMEOUT	(500000/WI_DELAY)	/* 500ms */
392cf71003Smillert 
402cf71003Smillert #define WI_PORT0	0
412cf71003Smillert #define WI_PORT1	1
422cf71003Smillert #define WI_PORT2	2
432cf71003Smillert #define WI_PORT3	3
442cf71003Smillert #define WI_PORT4	4
452cf71003Smillert #define WI_PORT5	5
462cf71003Smillert 
472cf71003Smillert /* Default port: 0 (only 0 exists on stations) */
482cf71003Smillert #define WI_DEFAULT_PORT	(WI_PORT0 << 8)
492cf71003Smillert 
502cf71003Smillert /* Default TX rate: 2Mbps, auto fallback */
512cf71003Smillert #define WI_DEFAULT_TX_RATE	3
522cf71003Smillert 
532cf71003Smillert /* Default network name (wildcard) */
542cf71003Smillert #define WI_DEFAULT_NETNAME	""
552cf71003Smillert 
562cf71003Smillert #define WI_DEFAULT_AP_DENSITY	1
572cf71003Smillert 
582cf71003Smillert #define WI_DEFAULT_RTS_THRESH	2347
592cf71003Smillert 
602cf71003Smillert #define WI_DEFAULT_DATALEN	2304
612cf71003Smillert 
622cf71003Smillert #define WI_DEFAULT_CREATE_IBSS	0
632cf71003Smillert 
642cf71003Smillert #define WI_DEFAULT_PM_ENABLED	0
652cf71003Smillert 
662cf71003Smillert #define WI_DEFAULT_MAX_SLEEP	100
672cf71003Smillert 
682cf71003Smillert #define WI_DEFAULT_NODENAME	"WaveLAN/IEEE node"
692cf71003Smillert 
702cf71003Smillert #define WI_DEFAULT_IBSS		"IBSS"
712cf71003Smillert 
722cf71003Smillert #define WI_DEFAULT_CHAN		3
732cf71003Smillert 
745123e574Smickey #define	WI_DEFAULT_ROAMING	1
755123e574Smickey 
765123e574Smickey #define	WI_DEFAULT_AUTHTYPE	1
775123e574Smickey 
78a458d0e6Smillert #define	WI_DEFAULT_DIVERSITY	0
79a458d0e6Smillert 
802cf71003Smillert /*
812cf71003Smillert  * register space access macros
822cf71003Smillert  */
837d8f85a8Sfgsch 
842cf71003Smillert #define CSR_WRITE_4(sc, reg, val)				\
85ad850669Smickey 	bus_space_write_4(sc->wi_btag, sc->wi_bhandle,		\
862061b6efSkettenis 	    (sc->sc_pci ? reg * 2: reg), (val))
872cf71003Smillert #define CSR_WRITE_2(sc, reg, val)				\
88ad850669Smickey 	bus_space_write_2(sc->wi_btag, sc->wi_bhandle,		\
892061b6efSkettenis 	    (sc->sc_pci ? reg * 2: reg), (val))
902cf71003Smillert #define CSR_WRITE_1(sc, reg, val)				\
91ad850669Smickey 	bus_space_write_1(sc->wi_btag, sc->wi_bhandle,		\
92ad850669Smickey 	    (sc->sc_pci ? reg * 2: reg), val)
932cf71003Smillert 
942cf71003Smillert #define CSR_READ_4(sc, reg)					\
95ad850669Smickey 	bus_space_read_4(sc->wi_btag, sc->wi_bhandle,		\
962061b6efSkettenis 	    (sc->sc_pci ? reg * 2: reg))
972cf71003Smillert #define CSR_READ_2(sc, reg)					\
98ad850669Smickey 	bus_space_read_2(sc->wi_btag, sc->wi_bhandle,		\
992061b6efSkettenis 	    (sc->sc_pci ? reg * 2: reg))
1002cf71003Smillert #define CSR_READ_1(sc, reg)					\
101ad850669Smickey 	bus_space_read_1(sc->wi_btag, sc->wi_bhandle,		\
102ad850669Smickey 	    (sc->sc_pci ? reg * 2: reg))
1032cf71003Smillert 
104436c27eaSdrahn #define CSR_READ_RAW_2(sc, ba, dst, sz)				\
1059aa798e0Sderaadt 	bus_space_read_raw_multi_2((sc)->wi_btag,		\
1069aa798e0Sderaadt 	    (sc)->wi_bhandle,					\
107ad850669Smickey 	    (sc->sc_pci? ba * 2: ba), (dst), (sz))
108436c27eaSdrahn #define CSR_WRITE_RAW_2(sc, ba, dst, sz)			\
1099aa798e0Sderaadt 	bus_space_write_raw_multi_2((sc)->wi_btag,		\
1109aa798e0Sderaadt 	    (sc)->wi_bhandle,					\
111ad850669Smickey 	    (sc->sc_pci? ba * 2: ba), (dst), (sz))
112436c27eaSdrahn 
1132cf71003Smillert /*
1142cf71003Smillert  * The WaveLAN/IEEE cards contain an 802.11 MAC controller which Lucent
1152cf71003Smillert  * calls 'Hermes.' In typical fashion, getting documentation about this
1162cf71003Smillert  * controller is about as easy as squeezing blood from a stone. Here
1172cf71003Smillert  * is more or less what I know:
1182cf71003Smillert  *
1192cf71003Smillert  * - The Hermes controller is firmware driven, and the host interacts
1202cf71003Smillert  *   with the Hermes via a firmware interface, which can change.
1212cf71003Smillert  *
1222cf71003Smillert  * - The Hermes is described in a document called: "Hermes Firmware
1232cf71003Smillert  *   WaveLAN/IEEE Station Functions," document #010245, which of course
1242cf71003Smillert  *   Lucent will not release without an NDA.
1252cf71003Smillert  *
1262cf71003Smillert  * - Lucent has created a library called HCF (Hardware Control Functions)
1272cf71003Smillert  *   though which it wants developers to interact with the card. The HCF
1282cf71003Smillert  *   is needlessly complex, ill conceived and badly documented. Actually,
1292408ed96Sjmc  *   the comments in the HCP code itself aren't bad, but the publicly
1302cf71003Smillert  *   available manual that comes with it is awful, probably due largely to
1312cf71003Smillert  *   the fact that it has been emasculated in order to hide information
1322cf71003Smillert  *   that Lucent wants to keep proprietary. The purpose of the HCF seems
1332cf71003Smillert  *   to be to insulate the driver programmer from the Hermes itself so that
1342cf71003Smillert  *   Lucent has an excuse not to release programming in for it.
1352cf71003Smillert  *
1362cf71003Smillert  * - Lucent only makes available documentation and code for 'HCF Light'
1372cf71003Smillert  *   which is a stripped down version of HCF with certain features not
1382cf71003Smillert  *   implemented, most notably support for 802.11 frames.
1392cf71003Smillert  *
1402cf71003Smillert  * - The HCF code which I have seen blows goats. Whoever decided to
1412cf71003Smillert  *   use a 132 column format should be shot.
1422cf71003Smillert  *
1432cf71003Smillert  * Rather than actually use the Lucent HCF library, I have stripped all
1442cf71003Smillert  * the useful information from it and used it to create a driver in the
1452cf71003Smillert  * usual BSD form. Note: I don't want to hear anybody whining about the
1462cf71003Smillert  * fact that the Lucent code is GPLed and mine isn't. I did not actually
1472cf71003Smillert  * put any of Lucent's code in this driver: I only used it as a reference
1482cf71003Smillert  * to obtain information about the underlying hardware. The Hermes
1492cf71003Smillert  * programming interface is not GPLed, so bite me.
1502cf71003Smillert  */
1512cf71003Smillert 
1522cf71003Smillert /*
153a43355a6Smillert  * Size of Hermes & Prism2 I/O space.
1542cf71003Smillert  */
1552cf71003Smillert #define WI_IOSIZ		0x40
1562cf71003Smillert 
1572cf71003Smillert /*
1582cf71003Smillert  * Hermes register definitions and what little I know about them.
1592cf71003Smillert  */
1602cf71003Smillert 
1612cf71003Smillert /* Hermes command/status registers. */
1622cf71003Smillert #define WI_COMMAND		0x00
1632cf71003Smillert #define WI_PARAM0		0x02
1642cf71003Smillert #define WI_PARAM1		0x04
1652cf71003Smillert #define WI_PARAM2		0x06
1662cf71003Smillert #define WI_STATUS		0x08
1672cf71003Smillert #define WI_RESP0		0x0A
1682cf71003Smillert #define WI_RESP1		0x0C
1692cf71003Smillert #define WI_RESP2		0x0E
1702cf71003Smillert 
1712cf71003Smillert /* Command register values. */
1722cf71003Smillert #define WI_CMD_BUSY		0x8000 /* busy bit */
1732cf71003Smillert #define WI_CMD_INI		0x0000 /* initialize */
1742cf71003Smillert #define WI_CMD_ENABLE		0x0001 /* enable */
1752cf71003Smillert #define WI_CMD_DISABLE		0x0002 /* disable */
1762cf71003Smillert #define WI_CMD_DIAG		0x0003
1772cf71003Smillert #define WI_CMD_ALLOC_MEM	0x000A /* allocate NIC memory */
1782cf71003Smillert #define WI_CMD_TX		0x000B /* transmit */
1792cf71003Smillert #define WI_CMD_NOTIFY		0x0010
1802cf71003Smillert #define WI_CMD_INQUIRE		0x0011
1812cf71003Smillert #define WI_CMD_ACCESS		0x0021
1822cf71003Smillert #define WI_CMD_PROGRAM		0x0022
183eb215967Sreyk #define WI_CMD_READ_MIF		0x0030 /* prism2 */
184eb215967Sreyk #define WI_CMD_WRITE_MIF	0x0031 /* prism2 */
1852cf71003Smillert 
1862cf71003Smillert #define WI_CMD_CODE_MASK	0x003F
1872cf71003Smillert 
1882cf71003Smillert /*
1892cf71003Smillert  * Reclaim qualifier bit, applicable to the
1902cf71003Smillert  * TX and INQUIRE commands.
1912cf71003Smillert  */
1922cf71003Smillert #define WI_RECLAIM		0x0100 /* reclaim NIC memory */
1932cf71003Smillert 
1942cf71003Smillert /*
1952cf71003Smillert  * ACCESS command qualifier bits.
1962cf71003Smillert  */
1972cf71003Smillert #define WI_ACCESS_READ		0x0000
1982cf71003Smillert #define WI_ACCESS_WRITE		0x0100
1992cf71003Smillert 
2002cf71003Smillert /*
2012cf71003Smillert  * PROGRAM command qualifier bits.
2022cf71003Smillert  */
2032cf71003Smillert #define WI_PROGRAM_DISABLE	0x0000
2042cf71003Smillert #define WI_PROGRAM_ENABLE_RAM	0x0100
2052cf71003Smillert #define WI_PROGRAM_ENABLE_NVRAM	0x0200
2062cf71003Smillert #define WI_PROGRAM_NVRAM	0x0300
2072cf71003Smillert 
2082cf71003Smillert /* Status register values */
2092cf71003Smillert #define WI_STAT_CMD_CODE	0x003F
2102cf71003Smillert #define WI_STAT_DIAG_ERR	0x0100
2112cf71003Smillert #define WI_STAT_INQ_ERR		0x0500
2122cf71003Smillert #define WI_STAT_CMD_RESULT	0x7F00
2132cf71003Smillert 
2142cf71003Smillert /* memory handle management registers */
2152cf71003Smillert #define WI_INFO_FID		0x10
2162cf71003Smillert #define WI_RX_FID		0x20
2172cf71003Smillert #define WI_ALLOC_FID		0x22
2182cf71003Smillert #define WI_TX_CMP_FID		0x24
2192cf71003Smillert 
2202cf71003Smillert /*
2212cf71003Smillert  * Buffer Access Path (BAP) registers.
2222cf71003Smillert  * These are I/O channels. I believe you can use each one for
2232cf71003Smillert  * any desired purpose independently of the other. In general
2242cf71003Smillert  * though, we use BAP1 for reading and writing LTV records and
2252cf71003Smillert  * reading received data frames, and BAP0 for writing transmit
2262cf71003Smillert  * frames. This is a convention though, not a rule.
2272cf71003Smillert  */
2282cf71003Smillert #define WI_SEL0			0x18
2292cf71003Smillert #define WI_SEL1			0x1A
2302cf71003Smillert #define WI_OFF0			0x1C
2312cf71003Smillert #define WI_OFF1			0x1E
2322cf71003Smillert #define WI_DATA0		0x36
2332cf71003Smillert #define WI_DATA1		0x38
2342cf71003Smillert #define WI_BAP0			WI_DATA0
2352cf71003Smillert #define WI_BAP1			WI_DATA1
2362cf71003Smillert 
2372cf71003Smillert #define WI_OFF_BUSY		0x8000
2382cf71003Smillert #define WI_OFF_ERR		0x4000
2392cf71003Smillert #define WI_OFF_DATAOFF		0x0FFF
2402cf71003Smillert 
2412cf71003Smillert /* Event registers */
2422cf71003Smillert #define WI_EVENT_STAT		0x30	/* Event status */
2432cf71003Smillert #define WI_INT_EN		0x32	/* Interrupt enable/disable */
2442cf71003Smillert #define WI_EVENT_ACK		0x34	/* Ack event */
2452cf71003Smillert 
2462cf71003Smillert /* Events */
2472cf71003Smillert #define WI_EV_TICK		0x8000	/* aux timer tick */
2482cf71003Smillert #define WI_EV_RES		0x4000	/* controller h/w error (time out) */
2492cf71003Smillert #define WI_EV_INFO_DROP		0x2000	/* no RAM to build unsolicited frame */
2502cf71003Smillert #define WI_EV_NO_CARD		0x0800	/* card removed (hunh?) */
2512cf71003Smillert #define WI_EV_DUIF_RX		0x0400	/* wavelan management packet received */
2522cf71003Smillert #define WI_EV_INFO		0x0080	/* async info frame */
2532cf71003Smillert #define WI_EV_CMD		0x0010	/* command completed */
2542cf71003Smillert #define WI_EV_ALLOC		0x0008	/* async alloc/reclaim completed */
2552cf71003Smillert #define WI_EV_TX_EXC		0x0004	/* async xmit completed with failure */
2562408ed96Sjmc #define WI_EV_TX		0x0002	/* async xmit completed successfully */
2572cf71003Smillert #define WI_EV_RX		0x0001	/* async rx completed */
2582cf71003Smillert 
2592cf71003Smillert #define WI_INTRS	\
2602cf71003Smillert 	(WI_EV_RX|WI_EV_TX|WI_EV_TX_EXC|WI_EV_ALLOC|WI_EV_INFO|WI_EV_INFO_DROP)
2612cf71003Smillert 
2622cf71003Smillert /* Host software registers */
2632cf71003Smillert #define WI_SW0			0x28
2642cf71003Smillert #define WI_SW1			0x2A
2652cf71003Smillert #define WI_SW2			0x2C
2662cf71003Smillert #define WI_SW3			0x2E
2672cf71003Smillert 
2682cf71003Smillert #define WI_CNTL			0x14
2692cf71003Smillert 
2702cf71003Smillert #define WI_CNTL_AUX_ENA		0xC000
2712cf71003Smillert #define WI_CNTL_AUX_ENA_STAT	0xC000
2722cf71003Smillert #define WI_CNTL_AUX_DIS_STAT	0x0000
2732cf71003Smillert #define WI_CNTL_AUX_ENA_CNTL	0x8000
2742cf71003Smillert #define WI_CNTL_AUX_DIS_CNTL	0x4000
2752cf71003Smillert 
2762cf71003Smillert #define WI_AUX_PAGE		0x3A
2772cf71003Smillert #define WI_AUX_OFFSET		0x3C
2782cf71003Smillert #define WI_AUX_DATA		0x3E
2792cf71003Smillert 
280357ccf35Smillert #define WI_COR_OFFSET		0x40	/* COR attribute offset of card */
28133acde5dSmillert #define WI_COR_IOMODE		0x41	/* Enable i/o mode with level irqs */
2827c600ae8Smillert 
2837c600ae8Smillert #define WI_PLX_LOCALRES		0x14	/* PLX chip's local registers */
2847c600ae8Smillert #define WI_PLX_MEMRES		0x18	/* Prism attribute memory (PLX) */
2857c600ae8Smillert #define WI_PLX_IORES		0x1C	/* Prism I/O space (PLX) */
286a43355a6Smillert #define WI_PLX_INTCSR		0x4C	/* PLX Interrupt CSR */
28733acde5dSmillert #define WI_PLX_INTEN		0x40	/* PCI Interrupt Enable bit */
28833acde5dSmillert #define WI_PLX_LINT1STAT	0x04	/* Local interrupt 1 status bit */
289357ccf35Smillert #define WI_PLX_COR_OFFSET	0x3E0	/* COR attribute offset of card */
290ef559c21Smickey 
291645c5b8eSmillert #define	WI_ACEX_CMDRES		0x10	/* BAR0 (I/O) for ACEX-based bridge */
292645c5b8eSmillert #define	WI_ACEX_LOCALRES	0x14	/* BAR1 (I/O) for ACEX-based bridge */
293645c5b8eSmillert #define	WI_ACEX_IORES		0x18	/* BAR2 (I/O) for ACEX-based bridge */
294645c5b8eSmillert #define	WI_ACEX_COR_OFFSET	0xe0	/* COR attribute offset of card */
29533acde5dSmillert 
2967c600ae8Smillert #define WI_TMD_LOCALRES		0x14	/* TMD chip's local registers */
2977c600ae8Smillert #define WI_TMD_IORES		0x18	/* Prism I/O space (TMD) */
298da7f6812Smillert 
299645c5b8eSmillert #define	WI_DRVR_MAGIC		0x4A2D	/* Magic number for card detection */
300645c5b8eSmillert 
301ef559c21Smickey /*
302ef559c21Smickey  * PCI Host Interface Registers (HFA3842 Specific)
303ef559c21Smickey  * The value of all Register's Offset, such as WI_INFO_FID and WI_PARAM0,
304ef559c21Smickey  * has doubled.
305ef559c21Smickey  * About WI_PCI_COR: In this Register, only soft-reset bit implement; Bit(7).
306ef559c21Smickey  */
307a43355a6Smillert #define WI_PCI_CBMA		0x10
3087c600ae8Smillert #define WI_PCI_COR_OFFSET	0x4C
309ef559c21Smickey #define WI_PCI_HCR		0x5C
310ef559c21Smickey #define WI_PCI_MASTER0_ADDRH	0x80
311ef559c21Smickey #define WI_PCI_MASTER0_ADDRL	0x84
312ef559c21Smickey #define WI_PCI_MASTER0_LEN	0x88
313ef559c21Smickey #define WI_PCI_MASTER0_CON	0x8C
314ef559c21Smickey 
315ef559c21Smickey #define WI_PCI_STATUS		0x98
316ef559c21Smickey 
317ef559c21Smickey #define WI_PCI_MASTER1_ADDRH	0xA0
318ef559c21Smickey #define WI_PCI_MASTER1_ADDRL	0xA4
319ef559c21Smickey #define WI_PCI_MASTER1_LEN	0xA8
320ef559c21Smickey #define WI_PCI_MASTER1_CON	0xAC
321ef559c21Smickey 
3227c600ae8Smillert #define WI_COR_SOFT_RESET	(1 << 7)
3237c600ae8Smillert #define WI_COR_CLEAR		0x00
324d330165cSmillert 
3252cf71003Smillert /*
3262cf71003Smillert  * One form of communication with the Hermes is with what Lucent calls
3272cf71003Smillert  * LTV records, where LTV stands for Length, Type and Value. The length
3282cf71003Smillert  * and type are 16 bits and are in native byte order. The value is in
3292cf71003Smillert  * multiples of 16 bits and is in little endian byte order.
3302cf71003Smillert  */
3312cf71003Smillert struct wi_ltv_gen {
3322cf71003Smillert 	u_int16_t		wi_len;
3332cf71003Smillert 	u_int16_t		wi_type;
3342cf71003Smillert 	u_int16_t		wi_val;
3352cf71003Smillert };
3362cf71003Smillert 
3372cf71003Smillert struct wi_ltv_str {
3382cf71003Smillert 	u_int16_t		wi_len;
3392cf71003Smillert 	u_int16_t		wi_type;
3402cf71003Smillert 	u_int16_t		wi_str[17];
3412cf71003Smillert };
3422cf71003Smillert 
3432cf71003Smillert #define WI_SETVAL(recno, val)			\
3442cf71003Smillert 	do {					\
3452cf71003Smillert 		struct wi_ltv_gen	g;	\
3462cf71003Smillert 						\
3472cf71003Smillert 		g.wi_len = 2;			\
3482cf71003Smillert 		g.wi_type = recno;		\
349436c27eaSdrahn 		g.wi_val = htole16(val);	\
3502cf71003Smillert 		wi_write_record(sc, &g);	\
3512cf71003Smillert 	} while (0)
3522cf71003Smillert 
3532cf71003Smillert #define WI_SETSTR(recno, str)					\
3542cf71003Smillert 	do {							\
3552cf71003Smillert 		struct wi_ltv_str	s;			\
3568744b008Smillert 		int			l;			\
3572cf71003Smillert 								\
3588744b008Smillert 		l = (str.i_len + 1) & ~0x1;			\
359*7bb4d322Stedu 		bzero(&s, sizeof(s));				\
3608744b008Smillert 		s.wi_len = (l / 2) + 2;				\
3612cf71003Smillert 		s.wi_type = recno;				\
3623f497931Smickey 		s.wi_str[0] = htole16(str.i_len);		\
3633f497931Smickey 		bcopy(str.i_nwid, &s.wi_str[1], str.i_len);	\
3642cf71003Smillert 		wi_write_record(sc, (struct wi_ltv_gen *)&s);	\
3652cf71003Smillert 	} while (0)
3662cf71003Smillert 
3672cf71003Smillert /*
3682cf71003Smillert  * Download buffer location and length (0xFD01).
3692cf71003Smillert  */
3702cf71003Smillert #define WI_RID_DNLD_BUF		0xFD01
3712cf71003Smillert struct wi_ltv_dnld_buf {
3722cf71003Smillert 	u_int16_t		wi_len;
3732cf71003Smillert 	u_int16_t		wi_type;
3742cf71003Smillert 	u_int16_t		wi_buf_pg; /* page addr of intermediate dl buf*/
3752cf71003Smillert 	u_int16_t		wi_buf_off; /* offset of idb */
3762cf71003Smillert 	u_int16_t		wi_buf_len; /* len of idb */
3772cf71003Smillert };
3782cf71003Smillert 
3792cf71003Smillert /*
3802cf71003Smillert  * Mem sizes (0xFD02).
3812cf71003Smillert  */
3822cf71003Smillert #define WI_RID_MEMSZ		0xFD02
3832cf71003Smillert struct wi_ltv_memsz {
3842cf71003Smillert 	u_int16_t		wi_len;
3852cf71003Smillert 	u_int16_t		wi_type;
3862cf71003Smillert 	u_int16_t		wi_mem_ram;
3872cf71003Smillert 	u_int16_t		wi_mem_nvram;
3882cf71003Smillert };
3892cf71003Smillert 
3902cf71003Smillert /*
3913d599b1aSmillert  * NIC Identification (0xFD0B == WI_RID_CARD_ID)
3925123e574Smickey  */
3935123e574Smickey struct wi_ltv_ver {
3945123e574Smickey 	u_int16_t	wi_len;
3955123e574Smickey 	u_int16_t	wi_type;
3965123e574Smickey 	u_int16_t	wi_ver[4];
3975123e574Smickey };
3985123e574Smickey 
3995123e574Smickey /*
4003d599b1aSmillert  * List of intended regulatory domains (WI_RID_DOMAINS = 0xFD11).
4012cf71003Smillert  */
4022cf71003Smillert struct wi_ltv_domains {
4032cf71003Smillert 	u_int16_t		wi_len;
4042cf71003Smillert 	u_int16_t		wi_type;
4052cf71003Smillert 	u_int16_t		wi_domains[6];
4062cf71003Smillert };
4072cf71003Smillert 
4082cf71003Smillert /*
4093d599b1aSmillert  * CIS struct (0xFD13 == WI_RID_CIS).
4102cf71003Smillert  */
4112cf71003Smillert struct wi_ltv_cis {
4122cf71003Smillert 	u_int16_t		wi_len;
4132cf71003Smillert 	u_int16_t		wi_type;
4142cf71003Smillert 	u_int16_t		wi_cis[240];
4152cf71003Smillert };
4162cf71003Smillert 
4172cf71003Smillert /*
4183d599b1aSmillert  * Communications quality (0xFD43 == WI_RID_COMMQUAL).
4192cf71003Smillert  */
4202cf71003Smillert struct wi_ltv_commqual {
4212cf71003Smillert 	u_int16_t		wi_len;
4222cf71003Smillert 	u_int16_t		wi_type;
4232cf71003Smillert 	u_int16_t		wi_coms_qual;
4242cf71003Smillert 	u_int16_t		wi_sig_lvl;
4252cf71003Smillert 	u_int16_t		wi_noise_lvl;
4262cf71003Smillert };
4272cf71003Smillert 
4282cf71003Smillert /*
4293d599b1aSmillert  * Actual system scale thresholds (0xFD46 == WI_RID_SCALETHRESH).
4302cf71003Smillert  */
4312cf71003Smillert struct wi_ltv_scalethresh {
4322cf71003Smillert 	u_int16_t		wi_len;
4332cf71003Smillert 	u_int16_t		wi_type;
4342cf71003Smillert 	u_int16_t		wi_energy_detect;
4352cf71003Smillert 	u_int16_t		wi_carrier_detect;
4362cf71003Smillert 	u_int16_t		wi_defer;
4372cf71003Smillert 	u_int16_t		wi_cell_search;
4382cf71003Smillert 	u_int16_t		wi_out_of_range;
4392cf71003Smillert 	u_int16_t		wi_delta_snr;
4402cf71003Smillert };
4412cf71003Smillert 
4422cf71003Smillert /*
4433d599b1aSmillert  * PCF info struct (0xFD87 == WI_RID_PCF).
4442cf71003Smillert  */
4452cf71003Smillert struct wi_ltv_pcf {
4462cf71003Smillert 	u_int16_t		wi_len;
4472cf71003Smillert 	u_int16_t		wi_type;
4482cf71003Smillert 	u_int16_t		wi_energy_detect;
4492cf71003Smillert 	u_int16_t		wi_carrier_detect;
4502cf71003Smillert 	u_int16_t		wi_defer;
4512cf71003Smillert 	u_int16_t		wi_cell_search;
4522cf71003Smillert 	u_int16_t		wi_range;
4532cf71003Smillert };
4542cf71003Smillert 
4552cf71003Smillert /*
4563d599b1aSmillert  * Connection control characteristics (0xFC00 == WI_RID_PORTTYPE).
4572cf71003Smillert  * 1 == Basic Service Set (BSS)
4582408ed96Sjmc  * 2 == Wireless Distribution System (WDS)
459d4021147Smillert  * 3 == Pseudo IBSS (aka ad-hoc demo)
460d4021147Smillert  * 4 == IBSS
4612cf71003Smillert  */
4622cf71003Smillert #define WI_PORTTYPE_BSS		0x1
4632cf71003Smillert #define WI_PORTTYPE_WDS		0x2
4642cf71003Smillert #define WI_PORTTYPE_ADHOC	0x3
465d4021147Smillert #define WI_PORTTYPE_IBSS	0x4
466d92c1547Smillert #define WI_PORTTYPE_HOSTAP	0x6
4672cf71003Smillert 
4682cf71003Smillert /*
4692cf71003Smillert  * Mac addresses.
4702cf71003Smillert  */
4712cf71003Smillert struct wi_ltv_macaddr {
4722cf71003Smillert 	u_int16_t		wi_len;
4732cf71003Smillert 	u_int16_t		wi_type;
4742cf71003Smillert 	u_int16_t		wi_mac_addr[3];
4752cf71003Smillert };
4762cf71003Smillert 
4772cf71003Smillert /*
4782cf71003Smillert  * Station set identification (SSID).
4792cf71003Smillert  */
4802cf71003Smillert struct wi_ltv_ssid {
4812cf71003Smillert 	u_int16_t		wi_len;
4822cf71003Smillert 	u_int16_t		wi_type;
4832cf71003Smillert 	u_int16_t		wi_id[17];
4842cf71003Smillert };
4852cf71003Smillert 
4862cf71003Smillert /*
4873d599b1aSmillert  * Set our station name (0xFC0E == WI_RID_NODENAME).
4882cf71003Smillert  */
4892cf71003Smillert struct wi_ltv_nodename {
4902cf71003Smillert 	u_int16_t		wi_len;
4912cf71003Smillert 	u_int16_t		wi_type;
4922cf71003Smillert 	u_int16_t		wi_nodename[17];
4932cf71003Smillert };
4942cf71003Smillert 
4952cf71003Smillert /*
4963d599b1aSmillert  * Multicast addresses to be put in filter. We're allowed up
4973d599b1aSmillert  * to 16 addresses in the filter (0xFC80 == WI_RID_MCAST).
4982cf71003Smillert  */
4992cf71003Smillert struct wi_ltv_mcast {
5002cf71003Smillert 	u_int16_t		wi_len;
5012cf71003Smillert 	u_int16_t		wi_type;
5022cf71003Smillert 	struct ether_addr	wi_mcast[16];
5032cf71003Smillert };
5042cf71003Smillert 
50586222df8Sfgsch 
50686222df8Sfgsch /*
50786222df8Sfgsch  * Get supported data rates (0xFDC6 == WI_RID_DATA_RATES).
50886222df8Sfgsch  */
50986222df8Sfgsch struct wi_ltv_rates {
51086222df8Sfgsch 	u_int16_t		wi_len;
51186222df8Sfgsch 	u_int16_t		wi_type;
51286222df8Sfgsch 	u_int8_t		wi_rates[10];
51386222df8Sfgsch };
51486222df8Sfgsch 
5152cf71003Smillert /*
5161de77e4fSmickey  * Supported rates.
5171de77e4fSmickey  */
5181de77e4fSmickey #define WI_SUPPRATES_1M		0x0001
5191de77e4fSmickey #define WI_SUPPRATES_2M		0x0002
5201de77e4fSmickey #define WI_SUPPRATES_5M		0x0004
5211de77e4fSmickey #define WI_SUPPRATES_11M	0x0008
522963166e4Smickey #define	WI_RATES_BITS	"\20\0011M\0022M\0035.5M\00411M"
5231de77e4fSmickey 
5241de77e4fSmickey /*
5252cf71003Smillert  * Information frame types.
5262cf71003Smillert  */
5272cf71003Smillert #define WI_INFO_NOTIFY		0xF000	/* Handover address */
5282cf71003Smillert #define WI_INFO_COUNTERS	0xF100	/* Statistics counters */
5292cf71003Smillert #define WI_INFO_SCAN_RESULTS	0xF101	/* Scan results */
5302cf71003Smillert #define WI_INFO_LINK_STAT	0xF200	/* Link status */
5312cf71003Smillert #define WI_INFO_ASSOC_STAT	0xF201	/* Association status */
5322cf71003Smillert 
5332cf71003Smillert /*
5342cf71003Smillert  * Hermes transmit/receive frame structure
5352cf71003Smillert  */
5362cf71003Smillert struct wi_frame {
5372cf71003Smillert 	u_int16_t		wi_status;	/* 0x00 */
5382cf71003Smillert 	u_int16_t		wi_rsvd0;	/* 0x02 */
5392cf71003Smillert 	u_int16_t		wi_rsvd1;	/* 0x04 */
5402cf71003Smillert 	u_int16_t		wi_q_info;	/* 0x06 */
5412cf71003Smillert 	u_int16_t		wi_rsvd2;	/* 0x08 */
5421de77e4fSmickey 	u_int8_t		wi_tx_rtry;	/* 0x0A */
5431de77e4fSmickey 	u_int8_t		wi_tx_rate;	/* 0x0A */
5442cf71003Smillert 	u_int16_t		wi_tx_ctl;	/* 0x0C */
5452cf71003Smillert 	u_int16_t		wi_frame_ctl;	/* 0x0E */
5462cf71003Smillert 	u_int16_t		wi_id;		/* 0x10 */
5472cf71003Smillert 	u_int8_t		wi_addr1[6];	/* 0x12 */
5482cf71003Smillert 	u_int8_t		wi_addr2[6];	/* 0x18 */
5492cf71003Smillert 	u_int8_t		wi_addr3[6];	/* 0x1E */
5502cf71003Smillert 	u_int16_t		wi_seq_ctl;	/* 0x24 */
5512cf71003Smillert 	u_int8_t		wi_addr4[6];	/* 0x26 */
5522cf71003Smillert 	u_int16_t		wi_dat_len;	/* 0x2C */
5532cf71003Smillert 	u_int8_t		wi_dst_addr[6];	/* 0x2E */
5542cf71003Smillert 	u_int8_t		wi_src_addr[6];	/* 0x34 */
5552cf71003Smillert 	u_int16_t		wi_len;		/* 0x3A */
5562cf71003Smillert 	u_int16_t		wi_dat[3];	/* 0x3C */ /* SNAP header */
5572cf71003Smillert 	u_int16_t		wi_type;	/* 0x42 */
5582cf71003Smillert };
5592cf71003Smillert 
5602cf71003Smillert #define WI_802_3_OFFSET		0x2E
5612cf71003Smillert #define WI_802_11_OFFSET	0x44
5622cf71003Smillert #define WI_802_11_OFFSET_RAW	0x3C
5631de77e4fSmickey #define WI_802_11_OFFSET_HDR	0x0E
5642cf71003Smillert 
5652cf71003Smillert #define WI_STAT_BADCRC		0x0001
5662cf71003Smillert #define WI_STAT_UNDECRYPTABLE	0x0002
5672cf71003Smillert #define WI_STAT_ERRSTAT		0x0003
5682cf71003Smillert #define WI_STAT_MAC_PORT	0x0700
5692cf71003Smillert #define WI_STAT_1042		0x2000	/* RFC1042 encoded */
5702cf71003Smillert #define WI_STAT_TUNNEL		0x4000	/* Bridge-tunnel encoded */
5712cf71003Smillert #define WI_STAT_WMP_MSG		0x6000	/* WaveLAN-II management protocol */
5721de77e4fSmickey #define WI_STAT_MGMT		0x8000	/* 802.11b management frames */
5732cf71003Smillert #define WI_RXSTAT_MSG_TYPE	0xE000
5742cf71003Smillert 
5752cf71003Smillert #define WI_ENC_TX_802_3		0x00
5762cf71003Smillert #define WI_ENC_TX_802_11	0x11
5771de77e4fSmickey #define	WI_ENC_TX_MGMT		0x08
5782cf71003Smillert #define WI_ENC_TX_E_II		0x0E
5792cf71003Smillert 
5802cf71003Smillert #define WI_ENC_TX_1042		0x00
5812cf71003Smillert #define WI_ENC_TX_TUNNEL	0xF8
5822cf71003Smillert 
5832cf71003Smillert #define WI_TXCNTL_MACPORT	0x00FF
5842cf71003Smillert #define WI_TXCNTL_STRUCTTYPE	0xFF00
5851de77e4fSmickey #define WI_TXCNTL_TX_EX		0x0004
5861de77e4fSmickey #define WI_TXCNTL_TX_OK		0x0002
5871de77e4fSmickey #define WI_TXCNTL_NOCRYPT	0x0080
5881de77e4fSmickey 
5892cf71003Smillert 
5902cf71003Smillert /*
5912cf71003Smillert  * SNAP (sub-network access protocol) constants for transmission
5922cf71003Smillert  * of IP datagrams over IEEE 802 networks, taken from RFC1042.
5932cf71003Smillert  * We need these for the LLC/SNAP header fields in the TX/RX frame
5942cf71003Smillert  * structure.
5952cf71003Smillert  */
5962cf71003Smillert #define WI_SNAP_K1		0xaa	/* assigned global SAP for SNAP */
5972cf71003Smillert #define WI_SNAP_K2		0x00
5982cf71003Smillert #define WI_SNAP_CONTROL		0x03	/* unnumbered information format */
5992cf71003Smillert #define WI_SNAP_WORD0		(WI_SNAP_K1 | (WI_SNAP_K1 << 8))
6002cf71003Smillert #define WI_SNAP_WORD1		(WI_SNAP_K2 | (WI_SNAP_CONTROL << 8))
6012cf71003Smillert #define WI_SNAPHDR_LEN		0x6
6021de77e4fSmickey #define WI_FCS_LEN		0x4
603822260fcSmillert 
604822260fcSmillert #define	WI_ETHERTYPE_LEN	0x2
605eb215967Sreyk 
606eb215967Sreyk /*
607eb215967Sreyk  * HFA3861/3863 (BBP) Control Registers
608eb215967Sreyk  */
609eb215967Sreyk #define WI_HFA384X_CR_A_D_TEST_MODES2	0x1a
610eb215967Sreyk #define WI_HFA384X_CR_MANUAL_TX_POWER	0x3e
611