Home | History | Annotate | Line # | Download | only in usb
if_urtwreg.h revision 1.3
      1  1.1  christos /*	$OpenBSD: if_urtwreg.h,v 1.13 2010/08/27 17:08:01 jsg Exp $	*/
      2  1.1  christos 
      3  1.1  christos /*-
      4  1.1  christos  * Copyright (c) 2009 Martynas Venckus <martynas (at) openbsd.org>
      5  1.1  christos  * Copyright (c) 2008 Weongyo Jeong <weongyo (at) FreeBSD.org>
      6  1.1  christos  *
      7  1.1  christos  * Permission to use, copy, modify, and distribute this software for any
      8  1.1  christos  * purpose with or without fee is hereby granted, provided that the above
      9  1.1  christos  * copyright notice and this permission notice appear in all copies.
     10  1.1  christos  *
     11  1.1  christos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  1.1  christos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  1.1  christos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  1.1  christos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  1.1  christos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  1.1  christos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  1.1  christos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  1.1  christos  */
     19  1.1  christos 
     20  1.1  christos #define	URTW_CONFIG_NO			1
     21  1.1  christos #define	URTW_IFACE_INDEX		0
     22  1.1  christos 
     23  1.1  christos /*
     24  1.1  christos  * Known hardware revisions.
     25  1.1  christos  */
     26  1.1  christos #define	URTW_HWREV_8187			0x01
     27  1.1  christos #define	URTW_HWREV_8187_B		0x02
     28  1.1  christos #define	URTW_HWREV_8187_D		0x04
     29  1.1  christos #define	URTW_HWREV_8187B		0x08
     30  1.1  christos #define	URTW_HWREV_8187B_B		0x10
     31  1.1  christos #define	URTW_HWREV_8187B_D		0x20
     32  1.1  christos #define	URTW_HWREV_8187B_E		0x40
     33  1.1  christos 
     34  1.1  christos /*
     35  1.1  christos  * Registers specific to RTL8187 and RTL8187B.
     36  1.1  christos  */
     37  1.1  christos #define	URTW_MAC0			0x0000		/* 1 byte */
     38  1.1  christos #define	URTW_MAC1			0x0001		/* 1 byte */
     39  1.1  christos #define	URTW_MAC2			0x0002		/* 1 byte */
     40  1.1  christos #define	URTW_MAC3			0x0003		/* 1 byte */
     41  1.1  christos #define	URTW_MAC4			0x0004		/* 1 byte */
     42  1.1  christos #define	URTW_MAC5			0x0005		/* 1 byte */
     43  1.1  christos #define	URTW_8187_BRSR			0x002c		/* 2 byte */
     44  1.1  christos #define	URTW_BRSR_MBR_8185		(0x0fff)
     45  1.1  christos #define	URTW_8187B_EIFS			0x002d		/* 1 byte */
     46  1.1  christos #define	URTW_BSSID			0x002e		/* 6 byte */
     47  1.1  christos #define	URTW_RESP_RATE			0x0034		/* 1 byte */
     48  1.1  christos #define	URTW_8187B_BRSR			0x0034		/* 2 byte */
     49  1.1  christos #define	URTW_RESP_MAX_RATE_SHIFT	(4)
     50  1.1  christos #define	URTW_RESP_MIN_RATE_SHIFT	(0)
     51  1.1  christos #define	URTW_8187_EIFS			0x0035		/* 1 byte */
     52  1.1  christos #define	URTW_INTR_MASK			0x003c		/* 2 byte */
     53  1.1  christos #define	URTW_CMD			0x0037		/* 1 byte */
     54  1.1  christos #define	URTW_CMD_TX_ENABLE		(0x4)
     55  1.1  christos #define	URTW_CMD_RX_ENABLE		(0x8)
     56  1.1  christos #define	URTW_CMD_RST			(0x10)
     57  1.1  christos #define	URTW_TX_CONF			0x0040		/* 4 byte */
     58  1.1  christos #define	URTW_TX_HWREV_MASK		(7 << 25)
     59  1.1  christos #define	URTW_TX_HWREV_8187_D		(5 << 25)
     60  1.1  christos #define	URTW_TX_HWREV_8187B_D		(6 << 25)
     61  1.1  christos #define	URTW_TX_DURPROCMODE		(1 << 30)
     62  1.1  christos #define	URTW_TX_DISREQQSIZE		(1 << 28)
     63  1.1  christos #define	URTW_TX_SHORTRETRY		(7 << 8)
     64  1.1  christos #define	URTW_TX_LONGRETRY		(7 << 0)
     65  1.1  christos #define	URTW_TX_LOOPBACK_SHIFT		(17)
     66  1.1  christos #define	URTW_TX_LOOPBACK_NONE		(0 << URTW_TX_LOOPBACK_SHIFT)
     67  1.1  christos #define	URTW_TX_LOOPBACK_MAC		(1 << URTW_TX_LOOPBACK_SHIFT)
     68  1.1  christos #define	URTW_TX_LOOPBACK_BASEBAND	(2 << URTW_TX_LOOPBACK_SHIFT)
     69  1.1  christos #define	URTW_TX_LOOPBACK_CONTINUE	(3 << URTW_TX_LOOPBACK_SHIFT)
     70  1.1  christos #define	URTW_TX_LOOPBACK_MASK		(0x60000)
     71  1.1  christos #define	URTW_TX_DPRETRY_MASK		(0xff00)
     72  1.1  christos #define	URTW_TX_RTSRETRY_MASK		(0xff)
     73  1.1  christos #define	URTW_TX_DPRETRY_SHIFT		(0)
     74  1.1  christos #define	URTW_TX_RTSRETRY_SHIFT		(8)
     75  1.1  christos #define	URTW_TX_NOCRC			(0x10000)
     76  1.1  christos #define	URTW_TX_MXDMA_MASK		(0xe00000)
     77  1.1  christos #define	URTW_TX_MXDMA_1024		(6 << URTW_TX_MXDMA_SHIFT)
     78  1.1  christos #define	URTW_TX_MXDMA_2048		(7 << URTW_TX_MXDMA_SHIFT)
     79  1.1  christos #define	URTW_TX_MXDMA_SHIFT		(21)
     80  1.1  christos #define	URTW_TX_CWMIN			(1 << 31)
     81  1.1  christos #define	URTW_TX_DISCW			(1 << 20)
     82  1.1  christos #define	URTW_TX_SWPLCPLEN		(1 << 24)
     83  1.1  christos #define	URTW_TX_NOICV			(0x80000)
     84  1.1  christos #define	URTW_RX				0x0044		/* 4 byte */
     85  1.1  christos #define	URTW_RX_9356SEL			(1 << 6)
     86  1.1  christos #define	URTW_RX_FILTER_MASK			\
     87  1.1  christos 	(URTW_RX_FILTER_ALLMAC | URTW_RX_FILTER_NICMAC | URTW_RX_FILTER_MCAST | \
     88  1.1  christos 	URTW_RX_FILTER_BCAST | URTW_RX_FILTER_CRCERR | URTW_RX_FILTER_ICVERR | \
     89  1.1  christos 	URTW_RX_FILTER_DATA | URTW_RX_FILTER_CTL | URTW_RX_FILTER_MNG |	\
     90  1.1  christos 	(1 << 21) |							\
     91  1.1  christos 	URTW_RX_FILTER_PWR | URTW_RX_CHECK_BSSID)
     92  1.1  christos #define	URTW_RX_FILTER_ALLMAC		(0x00000001)
     93  1.1  christos #define	URTW_RX_FILTER_NICMAC		(0x00000002)
     94  1.1  christos #define	URTW_RX_FILTER_MCAST		(0x00000004)
     95  1.1  christos #define	URTW_RX_FILTER_BCAST		(0x00000008)
     96  1.1  christos #define	URTW_RX_FILTER_CRCERR		(0x00000020)
     97  1.1  christos #define	URTW_RX_FILTER_ICVERR		(0x00001000)
     98  1.1  christos #define	URTW_RX_FILTER_DATA		(0x00040000)
     99  1.1  christos #define	URTW_RX_FILTER_CTL		(0x00080000)
    100  1.1  christos #define	URTW_RX_FILTER_MNG		(0x00100000)
    101  1.1  christos #define	URTW_RX_FILTER_PWR		(0x00400000)
    102  1.1  christos #define	URTW_RX_CHECK_BSSID		(0x00800000)
    103  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_MASK	((1 << 13) | (1 << 14) | (1 << 15))
    104  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_SHIFT	(13)
    105  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_128	(3)
    106  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_256	(4)
    107  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_512	(5)
    108  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_1024	(6)
    109  1.1  christos #define	URTW_RX_FIFO_THRESHOLD_NONE	(7 << URTW_RX_FIFO_THRESHOLD_SHIFT)
    110  1.1  christos #define	URTW_RX_AUTORESETPHY		(1 << URTW_RX_AUTORESETPHY_SHIFT)
    111  1.1  christos #define	URTW_RX_AUTORESETPHY_SHIFT	(28)
    112  1.1  christos #define	URTW_MAX_RX_DMA_MASK		((1<<8) | (1<<9) | (1<<10))
    113  1.1  christos #define	URTW_MAX_RX_DMA_2048		(7 << URTW_MAX_RX_DMA_SHIFT)
    114  1.1  christos #define	URTW_MAX_RX_DMA_1024		(6)
    115  1.1  christos #define	URTW_MAX_RX_DMA_SHIFT		(10)
    116  1.1  christos #define	URTW_RCR_ONLYERLPKT		(1 << 31)
    117  1.1  christos #define	URTW_INT_TIMEOUT		0x0048		/* 4 byte */
    118  1.1  christos #define	URTW_EPROM_CMD			0x0050		/* 1 byte */
    119  1.1  christos #define	URTW_EPROM_CMD_NORMAL		(0x0)
    120  1.1  christos #define	URTW_EPROM_CMD_NORMAL_MODE				\
    121  1.1  christos 	(URTW_EPROM_CMD_NORMAL << URTW_EPROM_CMD_SHIFT)
    122  1.1  christos #define	URTW_EPROM_CMD_LOAD		(0x1)
    123  1.1  christos #define	URTW_EPROM_CMD_PROGRAM		(0x2)
    124  1.1  christos #define	URTW_EPROM_CMD_PROGRAM_MODE				\
    125  1.1  christos 	(URTW_EPROM_CMD_PROGRAM << URTW_EPROM_CMD_SHIFT)
    126  1.1  christos #define	URTW_EPROM_CMD_CONFIG		(0x3)
    127  1.1  christos #define	URTW_EPROM_CMD_SHIFT		(6)
    128  1.1  christos #define	URTW_EPROM_CMD_MASK		((1 << 7) | (1 << 6))
    129  1.1  christos #define	URTW_EPROM_READBIT		(0x1)
    130  1.1  christos #define	URTW_EPROM_WRITEBIT		(0x2)
    131  1.1  christos #define	URTW_EPROM_CK			(0x4)
    132  1.1  christos #define	URTW_EPROM_CS			(0x8)
    133  1.1  christos #define	URTW_CONFIG1			0x0052		/* 1 byte */
    134  1.1  christos #define	URTW_CONFIG2			0x0053		/* 1 byte */
    135  1.1  christos #define	URTW_ANAPARAM			0x0054		/* 4 byte */
    136  1.1  christos #define	URTW_8187_8225_ANAPARAM_ON	(0xa0000a59)
    137  1.1  christos #define	URTW_8187B_8225_ANAPARAM_ON	(0x45090658)
    138  1.1  christos #define	URTW_MSR			0x0058		/* 1 byte */
    139  1.1  christos #define	URTW_MSR_LINK_MASK		((1 << 2) | (1 << 3))
    140  1.1  christos #define	URTW_MSR_LINK_SHIFT		(2)
    141  1.1  christos #define	URTW_MSR_LINK_NONE		(0 << URTW_MSR_LINK_SHIFT)
    142  1.1  christos #define	URTW_MSR_LINK_ADHOC		(1 << URTW_MSR_LINK_SHIFT)
    143  1.1  christos #define	URTW_MSR_LINK_STA		(2 << URTW_MSR_LINK_SHIFT)
    144  1.1  christos #define	URTW_MSR_LINK_HOSTAP		(3 << URTW_MSR_LINK_SHIFT)
    145  1.1  christos #define	URTW_MSR_LINK_ENEDCA		(4 << URTW_MSR_LINK_SHIFT)
    146  1.1  christos #define	URTW_CONFIG3			0x0059		/* 1 byte */
    147  1.1  christos #define	URTW_CONFIG3_ANAPARAM_WRITE	(0x40)
    148  1.1  christos #define	URTW_CONFIG3_ANAPARAM_W_SHIFT	(6)
    149  1.1  christos #define	URTW_CONFIG3_GNT_SELECT		(0x80)
    150  1.1  christos #define	URTW_PSR			0x005e		/* 1 byte */
    151  1.1  christos #define	URTW_ANAPARAM2			0x0060		/* 4 byte */
    152  1.1  christos #define	URTW_8187_8225_ANAPARAM2_ON	(0x860c7312)
    153  1.1  christos #define	URTW_8187B_8225_ANAPARAM2_ON	(0x727f3f52)
    154  1.1  christos #define	URTW_BEACON_INTERVAL		0x0070		/* 2 byte */
    155  1.1  christos #define	URTW_ATIM_WND			0x0072		/* 2 byte */
    156  1.1  christos #define	URTW_BEACON_INTERVAL_TIME	0x0074		/* 2 byte */
    157  1.1  christos #define	URTW_ATIM_TR_ITV		0x0076		/* 2 byte */
    158  1.1  christos #define	URTW_RF_PINS_OUTPUT		0x0080		/* 2 byte */
    159  1.1  christos #define	URTW_BB_HOST_BANG_CLK		(1 << 1)
    160  1.1  christos #define	URTW_BB_HOST_BANG_EN		(1 << 2)
    161  1.1  christos #define	URTW_BB_HOST_BANG_RW		(1 << 3)
    162  1.1  christos #define	URTW_RF_PINS_ENABLE		0x0082		/* 2 byte */
    163  1.1  christos #define	URTW_RF_PINS_SELECT		0x0084		/* 2 byte */
    164  1.1  christos #define	URTW_RF_PINS_INPUT		0x0086		/* 2 byte */
    165  1.1  christos #define	URTW_RF_PARA			0x0088		/* 4 byte */
    166  1.1  christos #define	URTW_RF_TIMING			0x008c		/* 4 byte */
    167  1.1  christos #define	URTW_GP_ENABLE			0x0090		/* 1 byte */
    168  1.1  christos #define	URTW_GPIO			0x0091		/* 1 byte */
    169  1.1  christos #define	URTW_HSSI_PARA			0x0094		/* 4 byte */
    170  1.1  christos #define	URTW_TX_AGC_CTL			0x009c		/* 1 byte */
    171  1.1  christos #define	URTW_TX_AGC_CTL_PERPACKET_GAIN	(0x1)
    172  1.1  christos #define	URTW_TX_AGC_CTL_PERPACKET_ANTSEL	(0x2)
    173  1.1  christos #define	URTW_TX_AGC_CTL_FEEDBACK_ANT	(0x4)
    174  1.1  christos #define	URTW_TX_GAIN_CCK		0x009d		/* 1 byte */
    175  1.1  christos #define	URTW_TX_GAIN_OFDM		0x009e		/* 1 byte */
    176  1.1  christos #define	URTW_TX_ANTENNA			0x009f		/* 1 byte */
    177  1.1  christos #define	URTW_WPA_CONFIG			0x00b0		/* 1 byte */
    178  1.1  christos #define	URTW_SIFS			0x00b4		/* 1 byte */
    179  1.1  christos #define	URTW_DIFS			0x00b5		/* 1 byte */
    180  1.1  christos #define	URTW_SLOT			0x00b6		/* 1 byte */
    181  1.1  christos #define	URTW_CW_CONF			0x00bc		/* 1 byte */
    182  1.1  christos #define	URTW_CW_CONF_PERPACKET_RETRY	(0x2)
    183  1.1  christos #define	URTW_CW_CONF_PERPACKET_CW	(0x1)
    184  1.1  christos #define	URTW_CW_VAL			0x00bd		/* 1 byte */
    185  1.1  christos #define	URTW_RATE_FALLBACK		0x00be		/* 1 byte */
    186  1.1  christos #define	URTW_RATE_FALLBACK_ENABLE	(0x80)
    187  1.1  christos #define	URTW_ACM_CONTROL		0x00bf		/* 1 byte */
    188  1.1  christos #define	URTW_8187B_HWREV		0x00e1		/* 1 byte */
    189  1.1  christos #define	URTW_8187B_HWREV_8187B_B	(0x0)
    190  1.1  christos #define	URTW_8187B_HWREV_8187B_D	(0x1)
    191  1.1  christos #define	URTW_8187B_HWREV_8187B_E	(0x2)
    192  1.1  christos #define	URTW_INT_MIG			0x00e2		/* 2 byte */
    193  1.1  christos #define	URTW_TID_AC_MAP			0x00e8		/* 2 byte */
    194  1.1  christos #define	URTW_ANAPARAM3			0x00ee		/* 4 byte */
    195  1.1  christos #define	URTW_8187B_8225_ANAPARAM3_ON	(0x0)
    196  1.1  christos #define	URTW_TALLY_SEL			0x00fc		/* 1 byte */
    197  1.1  christos #define	URTW_AC_VO			0x00f0		/* 1 byte */
    198  1.1  christos #define	URTW_AC_VI			0x00f4		/* 1 byte */
    199  1.1  christos #define	URTW_AC_BE			0x00f8		/* 1 byte */
    200  1.1  christos #define	URTW_AC_BK			0x00fc		/* 1 byte */
    201  1.1  christos #define	URTW_FEMR			0x01d4		/* 2 byte */
    202  1.1  christos #define	URTW_ARFR			0x01e0		/* 2 byte */
    203  1.1  christos #define	URTW_RFSW_CTRL			0x0272		/* 2 byte */
    204  1.1  christos 
    205  1.1  christos /* for EEPROM */
    206  1.1  christos #define	URTW_EPROM_TXPW_BASE		0x05
    207  1.1  christos #define	URTW_EPROM_RFCHIPID		0x06
    208  1.1  christos #define	URTW_EPROM_RFCHIPID_RTL8225U	(5)
    209  1.1  christos #define	URTW_EPROM_MACADDR		0x07
    210  1.1  christos #define	URTW_EPROM_TXPW0		0x16
    211  1.1  christos #define	URTW_EPROM_TXPW2		0x1b
    212  1.1  christos #define	URTW_EPROM_TXPW1		0x3d
    213  1.1  christos #define	URTW_EPROM_SWREV		0x3f
    214  1.1  christos #define	URTW_EPROM_CID_MASK		(0xff)
    215  1.1  christos #define	URTW_EPROM_CID_RSVD0		(0x00)
    216  1.1  christos #define	URTW_EPROM_CID_RSVD1		(0xff)
    217  1.1  christos #define	URTW_EPROM_CID_ALPHA0		(0x01)
    218  1.1  christos #define	URTW_EPROM_CID_SERCOMM_PS	(0x02)
    219  1.1  christos #define	URTW_EPROM_CID_HW_LED		(0x03)
    220  1.1  christos 
    221  1.1  christos /* LED */
    222  1.1  christos #define	URTW_CID_DEFAULT		0
    223  1.1  christos #define	URTW_CID_8187_ALPHA0		1
    224  1.1  christos #define	URTW_CID_8187_SERCOMM_PS	2
    225  1.1  christos #define	URTW_CID_8187_HW_LED		3
    226  1.1  christos #define	URTW_SW_LED_MODE0		0
    227  1.1  christos #define	URTW_SW_LED_MODE1		1
    228  1.1  christos #define	URTW_SW_LED_MODE2		2
    229  1.1  christos #define	URTW_SW_LED_MODE3		3
    230  1.1  christos #define	URTW_HW_LED			4
    231  1.1  christos #define	URTW_LED_CTL_POWER_ON		0
    232  1.1  christos #define	URTW_LED_CTL_LINK		2
    233  1.1  christos #define	URTW_LED_CTL_TX			4
    234  1.1  christos #define	URTW_LED_PIN_GPIO0		0
    235  1.1  christos #define	URTW_LED_PIN_LED0		1
    236  1.1  christos #define	URTW_LED_PIN_LED1		2
    237  1.1  christos #define	URTW_LED_UNKNOWN		0
    238  1.1  christos #define	URTW_LED_ON			1
    239  1.1  christos #define	URTW_LED_OFF			2
    240  1.1  christos #define	URTW_LED_BLINK_NORMAL		3
    241  1.1  christos #define	URTW_LED_BLINK_SLOWLY		4
    242  1.1  christos #define	URTW_LED_POWER_ON_BLINK		5
    243  1.1  christos #define	URTW_LED_SCAN_BLINK		6
    244  1.1  christos #define	URTW_LED_NO_LINK_BLINK		7
    245  1.1  christos #define	URTW_LED_BLINK_CM3		8
    246  1.1  christos 
    247  1.1  christos /* for extra area */
    248  1.1  christos #define	URTW_EPROM_DISABLE		0
    249  1.1  christos #define	URTW_EPROM_ENABLE		1
    250  1.1  christos #define	URTW_EPROM_DELAY		10
    251  1.1  christos #define	URTW_8187_GETREGS_REQ		5
    252  1.1  christos #define	URTW_8187_SETREGS_REQ		5
    253  1.1  christos #define	URTW_8225_RF_MAX_SENS		6
    254  1.1  christos #define	URTW_8225_RF_DEF_SENS		4
    255  1.1  christos #define	URTW_DEFAULT_RTS_RETRY		7
    256  1.1  christos #define	URTW_DEFAULT_TX_RETRY		7
    257  1.1  christos #define	URTW_DEFAULT_RTS_THRESHOLD	2342U
    258  1.1  christos 
    259  1.1  christos #define	URTW_MAX_CHANNELS		15
    260  1.1  christos 
    261  1.1  christos struct urtw_tx_data {
    262  1.1  christos 	struct urtw_softc	*sc;
    263  1.2     skrll 	struct usbd_xfer	*xfer;
    264  1.1  christos 	uint8_t			*buf;
    265  1.1  christos 	struct ieee80211_node	*ni;
    266  1.1  christos };
    267  1.1  christos 
    268  1.1  christos struct urtw_rx_data {
    269  1.1  christos 	struct urtw_softc	*sc;
    270  1.2     skrll 	struct usbd_xfer	*xfer;
    271  1.1  christos 	uint8_t			*buf;
    272  1.1  christos 	struct mbuf		*m;
    273  1.1  christos };
    274  1.1  christos 
    275  1.1  christos /* XXX not correct.. */
    276  1.1  christos #define	URTW_MIN_RXBUFSZ						\
    277  1.1  christos 	(sizeof(struct ieee80211_frame_min))
    278  1.1  christos 
    279  1.1  christos #define	URTW_RX_DATA_LIST_COUNT		1
    280  1.1  christos #define	URTW_TX_DATA_LIST_COUNT		16
    281  1.1  christos #define	URTW_RX_MAXSIZE			0x9c4
    282  1.1  christos #define	URTW_TX_MAXSIZE			0x9c4
    283  1.1  christos 
    284  1.1  christos struct urtw_rx_radiotap_header {
    285  1.1  christos 	struct ieee80211_radiotap_header wr_ihdr;
    286  1.1  christos 	uint8_t		wr_flags;
    287  1.1  christos 	uint16_t	wr_chan_freq;
    288  1.1  christos 	uint16_t	wr_chan_flags;
    289  1.1  christos 	int8_t		wr_dbm_antsignal;
    290  1.1  christos } __packed;
    291  1.1  christos 
    292  1.1  christos #define	URTW_RX_RADIOTAP_PRESENT					\
    293  1.1  christos 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
    294  1.1  christos 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
    295  1.1  christos 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL))
    296  1.1  christos 
    297  1.1  christos struct urtw_tx_radiotap_header {
    298  1.1  christos 	struct ieee80211_radiotap_header wt_ihdr;
    299  1.1  christos 	uint8_t		wt_flags;
    300  1.1  christos 	uint8_t		wt_rate;
    301  1.1  christos 	uint16_t	wt_chan_freq;
    302  1.1  christos 	uint16_t	wt_chan_flags;
    303  1.1  christos } __packed;
    304  1.1  christos 
    305  1.1  christos #define	URTW_TX_RADIOTAP_PRESENT					\
    306  1.1  christos 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
    307  1.1  christos 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
    308  1.1  christos 
    309  1.1  christos struct urtw_rf {
    310  1.1  christos 	/* RF methods */
    311  1.1  christos 	usbd_status			(*init)(struct urtw_rf *);
    312  1.1  christos 	usbd_status			(*set_chan)(struct urtw_rf *, int);
    313  1.1  christos 	usbd_status			(*set_sens)(struct urtw_rf *);
    314  1.1  christos 
    315  1.1  christos 	/* RF attributes */
    316  1.1  christos 	struct urtw_softc		*rf_sc;
    317  1.1  christos 	uint32_t			max_sens;
    318  1.1  christos 	uint32_t			sens;
    319  1.1  christos };
    320  1.1  christos 
    321  1.1  christos struct urtw_softc {
    322  1.1  christos 	device_t			sc_dev;
    323  1.1  christos 	struct ieee80211com		sc_ic;
    324  1.1  christos 	struct ethercom			sc_ec;
    325  1.1  christos #define sc_if	sc_ec.ec_if
    326  1.3      maxv 
    327  1.3      maxv 	enum {
    328  1.3      maxv 		URTW_INIT_NONE,
    329  1.3      maxv 		URTW_INIT_INITED
    330  1.3      maxv 	} sc_init_state;
    331  1.1  christos 	int				(*sc_newstate)(struct ieee80211com *,
    332  1.1  christos 					    enum ieee80211_state, int);
    333  1.1  christos 	struct urtw_rf			sc_rf;
    334  1.1  christos 
    335  1.1  christos 	bool				sc_dying;
    336  1.1  christos 
    337  1.1  christos 	struct usb_task			sc_task;
    338  1.2     skrll 	struct usbd_device *		sc_udev;
    339  1.2     skrll 	struct usbd_interface *		sc_iface;
    340  1.1  christos 
    341  1.1  christos 	enum ieee80211_state		sc_state;
    342  1.1  christos 	int				sc_arg;
    343  1.1  christos 
    344  1.1  christos 	uint8_t				sc_hwrev;
    345  1.1  christos 	int				sc_flags;
    346  1.1  christos #define	URTW_INIT_ONCE			(1 << 1)
    347  1.1  christos 	int				sc_epromtype;
    348  1.1  christos #define	URTW_EEPROM_93C46		0
    349  1.1  christos #define	URTW_EEPROM_93C56		1
    350  1.1  christos 	uint8_t				sc_crcmon;
    351  1.1  christos 	uint8_t				sc_bssid[IEEE80211_ADDR_LEN];
    352  1.1  christos 
    353  1.1  christos 	/* for LED */
    354  1.1  christos 	struct callout			sc_led_ch;
    355  1.1  christos 	struct usb_task			sc_ledtask;
    356  1.1  christos 	uint8_t				sc_psr;
    357  1.1  christos 	uint8_t				sc_strategy;
    358  1.1  christos #define	URTW_LED_GPIO			1
    359  1.1  christos 	uint8_t				sc_gpio_ledon;
    360  1.1  christos 	uint8_t				sc_gpio_ledinprogress;
    361  1.1  christos 	uint8_t				sc_gpio_ledstate;
    362  1.1  christos 	uint8_t				sc_gpio_ledpin;
    363  1.1  christos 	uint8_t				sc_gpio_blinktime;
    364  1.1  christos 	uint8_t				sc_gpio_blinkstate;
    365  1.1  christos 	/* RX/TX */
    366  1.2     skrll 	struct usbd_pipe *		sc_rxpipe;
    367  1.2     skrll 	struct usbd_pipe *		sc_txpipe_low;
    368  1.2     skrll 	struct usbd_pipe *		sc_txpipe_normal;
    369  1.1  christos #define	URTW_PRIORITY_LOW		0
    370  1.1  christos #define	URTW_PRIORITY_NORMAL		1
    371  1.2     skrll #define	URTW_PRIORITY_MAX		2
    372  1.1  christos #define	URTW_DATA_TIMEOUT		10000		/* 10 sec */
    373  1.1  christos 	struct urtw_rx_data		sc_rx_data[URTW_RX_DATA_LIST_COUNT];
    374  1.2     skrll 	struct urtw_tx_data		sc_tx_data[URTW_PRIORITY_MAX][URTW_TX_DATA_LIST_COUNT];
    375  1.2     skrll 	uint32_t			sc_tx_queued[URTW_PRIORITY_MAX];;
    376  1.2     skrll 	uint32_t			sc_txidx[URTW_PRIORITY_MAX];
    377  1.1  christos 	uint8_t				sc_rts_retry;
    378  1.1  christos 	uint8_t				sc_tx_retry;
    379  1.1  christos 	uint8_t				sc_preamble_mode;
    380  1.1  christos 	struct callout			scan_to;
    381  1.1  christos 	int				sc_txtimer;
    382  1.1  christos 	int				sc_currate;
    383  1.1  christos 	/* TX power */
    384  1.1  christos 	uint8_t				sc_txpwr_cck[URTW_MAX_CHANNELS];
    385  1.1  christos 	uint8_t				sc_txpwr_cck_base;
    386  1.1  christos 	uint8_t				sc_txpwr_ofdm[URTW_MAX_CHANNELS];
    387  1.1  christos 	uint8_t				sc_txpwr_ofdm_base;
    388  1.1  christos 
    389  1.1  christos 	struct bpf_if *			sc_drvbpf;
    390  1.1  christos 
    391  1.1  christos 	union {
    392  1.1  christos 		struct urtw_rx_radiotap_header th;
    393  1.1  christos 		uint8_t pad[64];
    394  1.1  christos 	}				sc_rxtapu;
    395  1.1  christos #define	sc_rxtap	sc_rxtapu.th
    396  1.1  christos 	int				sc_rxtap_len;
    397  1.1  christos 
    398  1.1  christos 	union {
    399  1.1  christos 		struct urtw_tx_radiotap_header th;
    400  1.1  christos 		uint8_t pad[64];
    401  1.1  christos 	}				sc_txtapu;
    402  1.1  christos #define	sc_txtap	sc_txtapu.th
    403  1.1  christos 	int				sc_txtap_len;
    404  1.1  christos };
    405  1.1  christos 
    406