Home | History | Annotate | Line # | Download | only in pci
if_wpireg.h revision 1.10
      1  1.10  jakllsch /*	$NetBSD: if_wpireg.h,v 1.10 2014/06/30 21:17:18 jakllsch Exp $	*/
      2  1.10  jakllsch /*	$OpenBSD: if_wpireg.h,v 1.16 2007/07/10 18:29:38 damien Exp $	*/
      3   1.1    simonb 
      4   1.1    simonb /*-
      5  1.10  jakllsch  * Copyright (c) 2006, 2007
      6   1.1    simonb  *	Damien Bergamini <damien.bergamini (at) free.fr>
      7   1.1    simonb  *
      8   1.1    simonb  * Permission to use, copy, modify, and distribute this software for any
      9   1.1    simonb  * purpose with or without fee is hereby granted, provided that the above
     10   1.1    simonb  * copyright notice and this permission notice appear in all copies.
     11   1.1    simonb  *
     12   1.1    simonb  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13   1.1    simonb  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14   1.1    simonb  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15   1.1    simonb  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16   1.1    simonb  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17   1.1    simonb  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18   1.1    simonb  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19   1.1    simonb  */
     20   1.1    simonb 
     21   1.1    simonb #define WPI_TX_RING_COUNT	256
     22   1.1    simonb #define WPI_CMD_RING_COUNT	256
     23   1.1    simonb #define WPI_RX_RING_COUNT	64
     24   1.1    simonb 
     25  1.10  jakllsch #define WPI_BUF_ALIGN		4096
     26   1.3  degroote 
     27   1.1    simonb /*
     28  1.10  jakllsch  * Rings must be aligned on a 16K boundary.
     29   1.1    simonb  * I had a hard time figuring this out.
     30   1.1    simonb  */
     31   1.1    simonb #define WPI_RING_DMA_ALIGN	0x4000
     32   1.1    simonb 
     33   1.1    simonb /* maximum scatter/gather */
     34   1.1    simonb #define WPI_MAX_SCATTER	4
     35   1.1    simonb 
     36   1.4  degroote /* maximum Rx buffer size (larger than MCLBYTES) */
     37   1.3  degroote #define WPI_RBUF_SIZE	(3 * 1024)	/* XXX 3000 but must be aligned! */
     38   1.3  degroote 
     39   1.1    simonb /*
     40   1.1    simonb  * Control and status registers.
     41   1.1    simonb  */
     42   1.1    simonb #define WPI_HWCONFIG		0x000
     43   1.1    simonb #define WPI_INTR		0x008
     44   1.1    simonb #define WPI_MASK		0x00c
     45   1.1    simonb #define WPI_INTR_STATUS		0x010
     46   1.1    simonb #define WPI_GPIO_STATUS		0x018
     47   1.1    simonb #define WPI_RESET		0x020
     48   1.1    simonb #define WPI_GPIO_CTL		0x024
     49   1.1    simonb #define WPI_EEPROM_CTL		0x02c
     50   1.1    simonb #define WPI_EEPROM_STATUS	0x030
     51   1.1    simonb #define WPI_UCODE_CLR		0x05c
     52   1.1    simonb #define WPI_TEMPERATURE		0x060
     53   1.1    simonb #define WPI_CHICKEN		0x100
     54   1.1    simonb #define WPI_PLL_CTL		0x20c
     55  1.10  jakllsch #define WPI_WRITE_MEM_ADDR	0x444
     56  1.10  jakllsch #define WPI_READ_MEM_ADDR	0x448
     57  1.10  jakllsch #define WPI_WRITE_MEM_DATA	0x44c
     58  1.10  jakllsch #define WPI_READ_MEM_DATA	0x450
     59   1.1    simonb #define WPI_TX_WIDX		0x460
     60   1.1    simonb #define WPI_TX_CTL(qid)		(0x940 + (qid) * 8)
     61   1.1    simonb #define WPI_TX_BASE(qid)	(0x944 + (qid) * 8)
     62   1.1    simonb #define WPI_TX_DESC(qid)	(0x980 + (qid) * 80)
     63   1.1    simonb #define WPI_RX_CONFIG		0xc00
     64   1.1    simonb #define WPI_RX_BASE		0xc04
     65   1.1    simonb #define WPI_RX_WIDX		0xc20
     66   1.1    simonb #define WPI_RX_RIDX_PTR		0xc24
     67   1.1    simonb #define WPI_RX_CTL		0xcc0
     68   1.1    simonb #define WPI_RX_STATUS		0xcc4
     69   1.1    simonb #define WPI_TX_CONFIG(qid)	(0xd00 + (qid) * 32)
     70   1.1    simonb #define WPI_TX_CREDIT(qid)	(0xd04 + (qid) * 32)
     71   1.1    simonb #define WPI_TX_STATE(qid)	(0xd08 + (qid) * 32)
     72   1.1    simonb #define WPI_TX_BASE_PTR		0xe80
     73   1.1    simonb #define WPI_MSG_CONFIG		0xe88
     74   1.1    simonb #define WPI_TX_STATUS		0xe90
     75   1.1    simonb 
     76   1.1    simonb 
     77   1.1    simonb /*
     78   1.1    simonb  * NIC internal memory offsets.
     79   1.1    simonb  */
     80   1.1    simonb #define WPI_MEM_MODE		0x2e00
     81   1.1    simonb #define WPI_MEM_RA		0x2e04
     82   1.1    simonb #define WPI_MEM_TXCFG		0x2e10
     83   1.1    simonb #define WPI_MEM_MAGIC4		0x2e14
     84   1.1    simonb #define WPI_MEM_MAGIC5		0x2e20
     85   1.1    simonb #define WPI_MEM_BYPASS1		0x2e2c
     86   1.1    simonb #define WPI_MEM_BYPASS2		0x2e30
     87   1.1    simonb #define WPI_MEM_CLOCK1		0x3004
     88   1.1    simonb #define WPI_MEM_CLOCK2		0x3008
     89   1.1    simonb #define WPI_MEM_POWER		0x300c
     90   1.1    simonb #define WPI_MEM_PCIDEV		0x3010
     91   1.8  degroote #define WPI_MEM_RFKILL		0x3014
     92   1.1    simonb #define WPI_MEM_UCODE_CTL	0x3400
     93   1.1    simonb #define WPI_MEM_UCODE_SRC	0x3404
     94   1.1    simonb #define WPI_MEM_UCODE_DST	0x3408
     95   1.1    simonb #define WPI_MEM_UCODE_SIZE	0x340c
     96   1.1    simonb #define WPI_MEM_UCODE_BASE	0x3800
     97   1.1    simonb 
     98   1.5  degroote #define WPI_MEM_TEXT_BASE	0x3490
     99   1.5  degroote #define WPI_MEM_TEXT_SIZE	0x3494
    100   1.5  degroote #define WPI_MEM_DATA_BASE	0x3498
    101   1.5  degroote #define WPI_MEM_DATA_SIZE	0x349c
    102   1.1    simonb 
    103  1.10  jakllsch 
    104   1.1    simonb /* possible flags for register WPI_HWCONFIG */
    105   1.1    simonb #define WPI_HW_ALM_MB	(1 << 8)
    106   1.1    simonb #define WPI_HW_ALM_MM	(1 << 9)
    107   1.1    simonb #define WPI_HW_SKU_MRC	(1 << 10)
    108   1.1    simonb #define WPI_HW_REV_D	(1 << 11)
    109   1.1    simonb #define WPI_HW_TYPE_B	(1 << 12)
    110   1.1    simonb 
    111   1.1    simonb /* possible flags for registers WPI_READ_MEM_ADDR/WPI_WRITE_MEM_ADDR */
    112   1.1    simonb #define WPI_MEM_4	((sizeof (uint32_t) - 1) << 24)
    113   1.1    simonb 
    114   1.5  degroote /* possible values for WPI_MEM_UCODE_DST */
    115   1.1    simonb #define WPI_FW_TEXT	0x00000000
    116   1.1    simonb 
    117   1.1    simonb /* possible flags for WPI_GPIO_STATUS */
    118   1.1    simonb #define WPI_POWERED		(1 << 9)
    119   1.1    simonb 
    120   1.1    simonb /* possible flags for register WPI_RESET */
    121   1.1    simonb #define WPI_NEVO_RESET		(1 << 0)
    122   1.1    simonb #define WPI_SW_RESET		(1 << 7)
    123   1.1    simonb #define WPI_MASTER_DISABLED	(1 << 8)
    124   1.1    simonb #define WPI_STOP_MASTER		(1 << 9)
    125   1.1    simonb 
    126   1.1    simonb /* possible flags for register WPI_GPIO_CTL */
    127   1.1    simonb #define WPI_GPIO_CLOCK		(1 << 0)
    128   1.1    simonb #define WPI_GPIO_INIT		(1 << 2)
    129   1.1    simonb #define WPI_GPIO_MAC		(1 << 3)
    130   1.1    simonb #define WPI_GPIO_SLEEP		(1 << 4)
    131   1.1    simonb #define WPI_GPIO_PWR_STATUS	0x07000000
    132   1.1    simonb #define WPI_GPIO_PWR_SLEEP	(4 << 24)
    133   1.1    simonb 
    134   1.1    simonb /* possible flags for register WPI_CHICKEN */
    135   1.1    simonb #define WPI_CHICKEN_RXNOLOS	(1 << 23)
    136   1.1    simonb 
    137   1.1    simonb /* possible flags for register WPI_PLL_CTL */
    138   1.1    simonb #define WPI_PLL_INIT		(1 << 24)
    139   1.1    simonb 
    140   1.1    simonb /* possible flags for register WPI_UCODE_CLR */
    141   1.1    simonb #define WPI_RADIO_OFF		(1 << 1)
    142   1.1    simonb #define WPI_DISABLE_CMD		(1 << 2)
    143   1.1    simonb 
    144   1.1    simonb /* possible flags for WPI_RX_STATUS */
    145   1.1    simonb #define	WPI_RX_IDLE	(1 << 24)
    146   1.1    simonb 
    147   1.1    simonb /* possible flags for register WPI_UC_CTL */
    148   1.5  degroote #define WPI_UC_ENABLE	(1 << 30)
    149  1.10  jakllsch #define WPI_UC_RUN	(1 << 31)
    150   1.1    simonb 
    151   1.1    simonb /* possible flags for register WPI_INTR_CSR */
    152   1.1    simonb #define WPI_ALIVE_INTR	(1 << 0)
    153   1.1    simonb #define WPI_WAKEUP_INTR	(1 << 1)
    154   1.1    simonb #define WPI_SW_ERROR	(1 << 25)
    155   1.1    simonb #define WPI_TX_INTR	(1 << 27)
    156   1.1    simonb #define WPI_HW_ERROR	(1 << 29)
    157   1.1    simonb #define WPI_RX_INTR	(1 << 31)
    158   1.1    simonb 
    159   1.1    simonb #define WPI_INTR_MASK							\
    160   1.1    simonb 	(WPI_SW_ERROR | WPI_HW_ERROR | WPI_TX_INTR | WPI_RX_INTR |	\
    161   1.1    simonb 	 WPI_ALIVE_INTR | WPI_WAKEUP_INTR)
    162   1.1    simonb 
    163   1.1    simonb /* possible flags for register WPI_TX_STATUS */
    164   1.1    simonb #define WPI_TX_IDLE(qid)	(1 << ((qid) + 24) | 1 << ((qid) + 16))
    165   1.1    simonb 
    166   1.1    simonb /* possible flags for register WPI_EEPROM_CTL */
    167   1.1    simonb #define WPI_EEPROM_READY	(1 << 0)
    168   1.1    simonb 
    169   1.1    simonb /* possible flags for register WPI_EEPROM_STATUS */
    170   1.1    simonb #define WPI_EEPROM_VERSION	0x00000007
    171   1.1    simonb #define WPI_EEPROM_LOCKED	0x00000180
    172   1.1    simonb 
    173   1.1    simonb 
    174   1.1    simonb struct wpi_shared {
    175   1.1    simonb 	uint32_t	txbase[8];
    176   1.1    simonb 	uint32_t	next;
    177   1.1    simonb 	uint32_t	reserved[2];
    178   1.9     perry } __packed;
    179   1.1    simonb 
    180   1.1    simonb #define WPI_MAX_SEG_LEN	65520
    181   1.1    simonb struct wpi_tx_desc {
    182   1.1    simonb 	uint32_t	flags;
    183   1.1    simonb #define WPI_PAD32(x)	((((x) + 3) & ~3) - (x))
    184   1.1    simonb 
    185   1.1    simonb 	struct {
    186   1.1    simonb 		uint32_t	addr;
    187   1.1    simonb 		uint32_t	len;
    188   1.9     perry 	} __packed	segs[WPI_MAX_SCATTER];
    189   1.1    simonb 	uint8_t		reserved[28];
    190   1.9     perry } __packed;
    191   1.1    simonb 
    192   1.1    simonb struct wpi_tx_stat {
    193   1.1    simonb 	uint8_t		nrts;
    194   1.1    simonb 	uint8_t		ntries;
    195   1.1    simonb 	uint8_t		nkill;
    196   1.1    simonb 	uint8_t		rate;
    197   1.1    simonb 	uint32_t	duration;
    198   1.1    simonb 	uint32_t	status;
    199   1.9     perry } __packed;
    200   1.1    simonb 
    201   1.1    simonb struct wpi_rx_desc {
    202   1.1    simonb 	uint32_t	len;
    203   1.1    simonb 	uint8_t		type;
    204   1.1    simonb #define WPI_UC_READY		  1
    205   1.1    simonb #define WPI_RX_DONE		 27
    206   1.1    simonb #define WPI_TX_DONE		 28
    207   1.1    simonb #define WPI_START_SCAN		130
    208   1.1    simonb #define WPI_STOP_SCAN		132
    209   1.1    simonb #define WPI_STATE_CHANGED	161
    210   1.1    simonb 
    211   1.1    simonb 	uint8_t		flags;
    212   1.1    simonb 	uint8_t		idx;
    213   1.1    simonb 	uint8_t		qid;
    214   1.9     perry } __packed;
    215   1.1    simonb 
    216   1.1    simonb struct wpi_rx_stat {
    217   1.1    simonb 	uint8_t		len;
    218   1.1    simonb #define WPI_STAT_MAXLEN	20
    219   1.1    simonb 
    220   1.1    simonb 	uint8_t		id;
    221   1.1    simonb 	uint8_t		rssi;	/* received signal strength */
    222   1.1    simonb #define WPI_RSSI_OFFSET	95
    223   1.1    simonb 
    224   1.1    simonb 	uint8_t		agc;	/* access gain control */
    225   1.1    simonb 	uint16_t	signal;
    226   1.1    simonb 	uint16_t	noise;
    227   1.9     perry } __packed;
    228   1.1    simonb 
    229   1.1    simonb struct wpi_rx_head {
    230   1.1    simonb 	uint16_t	chan;
    231   1.1    simonb 	uint16_t	flags;
    232   1.1    simonb 	uint8_t		reserved;
    233   1.1    simonb 	uint8_t		rate;
    234   1.1    simonb 	uint16_t	len;
    235   1.9     perry } __packed;
    236   1.1    simonb 
    237   1.1    simonb struct wpi_rx_tail {
    238   1.1    simonb 	uint32_t	flags;
    239   1.1    simonb #define WPI_RX_NO_CRC_ERR	(1 << 0)
    240   1.1    simonb #define WPI_RX_NO_OVFL_ERR	(1 << 1)
    241   1.1    simonb /* shortcut for the above */
    242   1.1    simonb #define WPI_RX_NOERROR		(WPI_RX_NO_CRC_ERR | WPI_RX_NO_OVFL_ERR)
    243   1.1    simonb 
    244   1.1    simonb 	uint64_t	tstamp;
    245   1.1    simonb 	uint32_t	tbeacon;
    246   1.9     perry } __packed;
    247   1.1    simonb 
    248   1.1    simonb struct wpi_tx_cmd {
    249   1.1    simonb 	uint8_t	code;
    250   1.1    simonb #define WPI_CMD_CONFIGURE	 16
    251   1.1    simonb #define WPI_CMD_ASSOCIATE	 17
    252  1.10  jakllsch #define WPI_CMD_SET_WME		 19
    253   1.1    simonb #define WPI_CMD_TSF		 20
    254   1.1    simonb #define WPI_CMD_ADD_NODE	 24
    255   1.1    simonb #define WPI_CMD_TX_DATA		 28
    256   1.1    simonb #define WPI_CMD_MRR_SETUP	 71
    257   1.1    simonb #define WPI_CMD_SET_LED		 72
    258   1.1    simonb #define WPI_CMD_SET_POWER_MODE	119
    259   1.1    simonb #define WPI_CMD_SCAN		128
    260   1.1    simonb #define WPI_CMD_SET_BEACON	145
    261   1.4  degroote #define WPI_CMD_TXPOWER		151
    262   1.1    simonb #define WPI_CMD_BLUETOOTH	155
    263   1.1    simonb 
    264   1.1    simonb 	uint8_t	flags;
    265   1.1    simonb 	uint8_t	idx;
    266   1.1    simonb 	uint8_t	qid;
    267   1.1    simonb 	uint8_t	data[124];
    268   1.9     perry } __packed;
    269   1.1    simonb 
    270   1.1    simonb /* structure for WPI_CMD_CONFIGURE */
    271   1.1    simonb struct wpi_config {
    272   1.1    simonb 	uint8_t		myaddr[IEEE80211_ADDR_LEN];
    273   1.1    simonb 	uint16_t	reserved1;
    274   1.1    simonb 	uint8_t		bssid[IEEE80211_ADDR_LEN];
    275   1.1    simonb 	uint16_t	reserved2;
    276   1.1    simonb 	uint32_t	reserved3[2];
    277   1.1    simonb 	uint8_t		mode;
    278   1.1    simonb #define WPI_MODE_HOSTAP		1
    279   1.1    simonb #define WPI_MODE_STA		3
    280   1.1    simonb #define WPI_MODE_IBSS		4
    281   1.1    simonb #define WPI_MODE_MONITOR	6
    282   1.1    simonb 
    283   1.1    simonb 	uint8_t		reserved4[3];
    284   1.1    simonb 	uint8_t		ofdm_mask;
    285   1.1    simonb 	uint8_t		cck_mask;
    286   1.4  degroote 	uint16_t	associd;
    287   1.1    simonb 	uint32_t	flags;
    288   1.1    simonb #define WPI_CONFIG_24GHZ	(1 << 0)
    289   1.1    simonb #define WPI_CONFIG_CCK		(1 << 1)
    290   1.1    simonb #define WPI_CONFIG_AUTO		(1 << 2)
    291   1.1    simonb #define WPI_CONFIG_SHSLOT	(1 << 4)
    292   1.1    simonb #define WPI_CONFIG_SHPREAMBLE	(1 << 5)
    293   1.1    simonb #define WPI_CONFIG_NODIVERSITY	(1 << 7)
    294   1.1    simonb #define WPI_CONFIG_ANTENNA_A	(1 << 8)
    295   1.1    simonb #define WPI_CONFIG_ANTENNA_B	(1 << 9)
    296   1.1    simonb #define WPI_CONFIG_TSF		(1 << 15)
    297   1.1    simonb 
    298   1.1    simonb 	uint32_t	filter;
    299   1.1    simonb #define WPI_FILTER_PROMISC	(1 << 0)
    300   1.1    simonb #define WPI_FILTER_CTL		(1 << 1)
    301   1.1    simonb #define WPI_FILTER_MULTICAST	(1 << 2)
    302   1.1    simonb #define WPI_FILTER_NODECRYPT	(1 << 3)
    303   1.1    simonb #define WPI_FILTER_BSS		(1 << 5)
    304   1.1    simonb #define WPI_FILTER_BEACON	(1 << 6)
    305   1.1    simonb 
    306   1.1    simonb 	uint8_t		chan;
    307   1.1    simonb 	uint8_t		reserved6[3];
    308   1.9     perry } __packed;
    309   1.1    simonb 
    310   1.1    simonb /* structure for command WPI_CMD_ASSOCIATE */
    311   1.1    simonb struct wpi_assoc {
    312   1.1    simonb 	uint32_t	flags;
    313   1.1    simonb 	uint32_t	filter;
    314   1.1    simonb 	uint8_t		ofdm_mask;
    315   1.1    simonb 	uint8_t		cck_mask;
    316   1.1    simonb 	uint16_t	reserved;
    317   1.9     perry } __packed;
    318   1.1    simonb 
    319   1.1    simonb /* structure for command WPI_CMD_SET_WME */
    320   1.1    simonb struct wpi_wme_setup {
    321   1.1    simonb 	uint32_t	flags;
    322   1.1    simonb 	struct {
    323   1.1    simonb 		uint16_t	cwmin;
    324   1.1    simonb 		uint16_t	cwmax;
    325   1.1    simonb 		uint8_t		aifsn;
    326   1.1    simonb 		uint8_t		reserved;
    327   1.1    simonb 		uint16_t	txop;
    328   1.1    simonb 	} __packed	ac[WME_NUM_AC];
    329   1.9     perry } __packed;
    330   1.1    simonb 
    331   1.1    simonb /* structure for command WPI_CMD_TSF */
    332   1.1    simonb struct wpi_cmd_tsf {
    333   1.1    simonb 	uint64_t	tstamp;
    334   1.1    simonb 	uint16_t	bintval;
    335   1.1    simonb 	uint16_t	atim;
    336   1.1    simonb 	uint32_t	binitval;
    337   1.1    simonb 	uint16_t	lintval;
    338   1.1    simonb 	uint16_t	reserved;
    339   1.9     perry } __packed;
    340   1.1    simonb 
    341   1.1    simonb /* structure for WPI_CMD_ADD_NODE */
    342   1.2     joerg struct wpi_node_info {
    343   1.1    simonb 	uint8_t		control;
    344   1.1    simonb #define WPI_NODE_UPDATE	(1 << 0)
    345   1.1    simonb 
    346   1.1    simonb 	uint8_t		reserved1[3];
    347   1.1    simonb 	uint8_t		bssid[IEEE80211_ADDR_LEN];
    348   1.1    simonb 	uint16_t	reserved2;
    349   1.1    simonb 	uint8_t		id;
    350   1.1    simonb #define WPI_ID_BSS		0
    351   1.1    simonb #define WPI_ID_BROADCAST	24
    352   1.1    simonb 
    353   1.4  degroote 	uint8_t		flags;
    354   1.1    simonb 	uint16_t	reserved3;
    355   1.1    simonb 	uint16_t	key_flags;
    356   1.1    simonb 	uint8_t		tkip;
    357   1.1    simonb 	uint8_t		reserved4;
    358   1.1    simonb 	uint16_t	ttak[5];
    359   1.1    simonb 	uint16_t	reserved5;
    360   1.1    simonb 	uint8_t		key[IEEE80211_KEYBUF_SIZE];
    361   1.4  degroote 	uint32_t	action;
    362   1.4  degroote #define WPI_ACTION_SET_RATE	4
    363   1.4  degroote 
    364   1.1    simonb 	uint32_t	mask;
    365   1.1    simonb 	uint16_t	tid;
    366   1.1    simonb 	uint8_t		rate;
    367   1.4  degroote 	uint8_t		antenna;
    368   1.4  degroote #define WPI_ANTENNA_A		(1 << 6)
    369   1.4  degroote #define WPI_ANTENNA_B		(1 << 7)
    370   1.4  degroote #define WPI_ANTENNA_BOTH	(WPI_ANTENNA_A | WPI_ANTENNA_B)
    371   1.4  degroote 
    372   1.1    simonb 	uint8_t		add_imm;
    373   1.1    simonb 	uint8_t		del_imm;
    374   1.1    simonb 	uint16_t	add_imm_start;
    375   1.9     perry } __packed;
    376   1.1    simonb 
    377   1.1    simonb /* structure for command WPI_CMD_TX_DATA */
    378   1.1    simonb struct wpi_cmd_data {
    379   1.1    simonb 	uint16_t	len;
    380   1.1    simonb 	uint16_t	lnext;
    381   1.1    simonb 	uint32_t	flags;
    382   1.1    simonb #define WPI_TX_NEED_RTS		(1 <<  1)
    383  1.10  jakllsch #define WPI_TX_NEED_CTS		(1 <<  2)
    384   1.1    simonb #define WPI_TX_NEED_ACK		(1 <<  3)
    385   1.1    simonb #define WPI_TX_FULL_TXOP	(1 <<  7)
    386   1.4  degroote #define WPI_TX_BT_DISABLE	(1 << 12)	/* bluetooth coexistence */
    387   1.1    simonb #define WPI_TX_AUTO_SEQ		(1 << 13)
    388   1.1    simonb #define WPI_TX_INSERT_TSTAMP	(1 << 16)
    389   1.1    simonb 
    390   1.1    simonb 	uint8_t		rate;
    391   1.1    simonb 	uint8_t		id;
    392   1.1    simonb 	uint8_t		tid;
    393   1.1    simonb 	uint8_t		security;
    394   1.1    simonb 	uint8_t		key[IEEE80211_KEYBUF_SIZE];
    395   1.1    simonb 	uint8_t		tkip[IEEE80211_WEP_MICLEN];
    396   1.1    simonb 	uint32_t	fnext;
    397   1.1    simonb 	uint32_t	lifetime;
    398   1.4  degroote #define WPI_LIFETIME_INFINITE	0xffffffff
    399   1.4  degroote 
    400   1.1    simonb 	uint8_t		ofdm_mask;
    401   1.1    simonb 	uint8_t		cck_mask;
    402   1.1    simonb 	uint8_t		rts_ntries;
    403   1.1    simonb 	uint8_t		data_ntries;
    404   1.1    simonb 	uint16_t	timeout;
    405   1.1    simonb 	uint16_t	txop;
    406   1.9     perry } __packed;
    407   1.1    simonb 
    408   1.1    simonb /* structure for command WPI_CMD_SET_BEACON */
    409   1.1    simonb struct wpi_cmd_beacon {
    410   1.1    simonb 	uint16_t	len;
    411   1.1    simonb 	uint16_t	reserved1;
    412   1.1    simonb 	uint32_t	flags;	/* same as wpi_cmd_data */
    413   1.1    simonb 	uint8_t		rate;
    414   1.1    simonb 	uint8_t		id;
    415   1.1    simonb 	uint8_t		reserved2[30];
    416   1.1    simonb 	uint32_t	lifetime;
    417   1.1    simonb 	uint8_t		ofdm_mask;
    418   1.1    simonb 	uint8_t		cck_mask;
    419   1.1    simonb 	uint16_t	reserved3[3];
    420   1.1    simonb 	uint16_t	tim;
    421   1.1    simonb 	uint8_t		timsz;
    422   1.1    simonb 	uint8_t		reserved4;
    423   1.1    simonb 	struct		ieee80211_frame wh;
    424   1.9     perry } __packed;
    425   1.1    simonb 
    426   1.1    simonb /* structure for WPI_CMD_MRR_SETUP */
    427   1.1    simonb struct wpi_mrr_setup {
    428   1.1    simonb 	uint32_t	which;
    429   1.1    simonb #define WPI_MRR_CTL	0
    430   1.1    simonb #define WPI_MRR_DATA	1
    431   1.1    simonb 
    432   1.1    simonb 	struct {
    433   1.1    simonb 		uint8_t	plcp;
    434   1.1    simonb 		uint8_t	flags;
    435   1.1    simonb 		uint8_t	ntries;
    436   1.1    simonb 		uint8_t	next;
    437   1.1    simonb #define WPI_OFDM6	0
    438   1.1    simonb #define WPI_OFDM54	7
    439   1.1    simonb #define WPI_CCK1	8
    440   1.1    simonb #define WPI_CCK2	9
    441   1.1    simonb #define WPI_CCK11	11
    442   1.1    simonb 
    443   1.9     perry 	} __packed	rates[WPI_CCK11 + 1];
    444   1.9     perry } __packed;
    445   1.1    simonb 
    446   1.1    simonb /* structure for WPI_CMD_SET_LED */
    447   1.1    simonb struct wpi_cmd_led {
    448   1.1    simonb 	uint32_t	unit;	/* multiplier (in usecs) */
    449   1.1    simonb 	uint8_t		which;
    450   1.1    simonb #define WPI_LED_ACTIVITY	1
    451   1.1    simonb #define WPI_LED_LINK		2
    452   1.1    simonb 
    453   1.1    simonb 	uint8_t		off;
    454   1.1    simonb 	uint8_t		on;
    455   1.1    simonb 	uint8_t		reserved;
    456   1.9     perry } __packed;
    457   1.1    simonb 
    458   1.1    simonb /* structure for WPI_CMD_SET_POWER_MODE */
    459   1.1    simonb struct wpi_power {
    460   1.1    simonb 	uint32_t	flags;
    461   1.4  degroote #define WPI_POWER_CAM	0	/* constantly awake mode */
    462   1.4  degroote 
    463   1.1    simonb 	uint32_t	rx_timeout;
    464   1.1    simonb 	uint32_t	tx_timeout;
    465   1.1    simonb 	uint32_t	sleep[5];
    466   1.9     perry } __packed;
    467   1.1    simonb 
    468  1.10  jakllsch /* structures for command WPI_CMD_SCAN */
    469   1.4  degroote struct wpi_scan_essid {
    470   1.4  degroote 	uint8_t	id;
    471   1.4  degroote 	uint8_t	len;
    472   1.4  degroote 	uint8_t	data[IEEE80211_NWID_LEN];
    473   1.9     perry } __packed;
    474   1.4  degroote 
    475   1.1    simonb struct wpi_scan_hdr {
    476   1.4  degroote 	uint16_t	len;
    477   1.1    simonb 	uint8_t		reserved1;
    478   1.1    simonb 	uint8_t		nchan;
    479   1.1    simonb 	uint16_t	quiet;
    480   1.4  degroote 	uint16_t	plcp_threshold;
    481   1.4  degroote 	uint16_t	crc_threshold;
    482   1.4  degroote 	uint16_t	reserved2;
    483   1.4  degroote 	uint32_t	max_svc;	/* background scans */
    484   1.4  degroote 	uint32_t	pause_svc;	/* background scans */
    485   1.1    simonb 	uint32_t	flags;
    486   1.1    simonb 	uint32_t	filter;
    487   1.4  degroote 
    488   1.4  degroote 	/* wpi_cmd_data structure */
    489   1.4  degroote 	uint16_t	paylen;
    490   1.4  degroote 	uint16_t	lnext;
    491   1.4  degroote 	uint32_t	txflags;
    492   1.1    simonb 	uint8_t		rate;
    493   1.1    simonb 	uint8_t		id;
    494   1.4  degroote 	uint8_t		tid;
    495   1.4  degroote 	uint8_t		security;
    496   1.4  degroote 	uint8_t		key[IEEE80211_KEYBUF_SIZE];
    497   1.4  degroote 	uint8_t		tkip[IEEE80211_WEP_MICLEN];
    498   1.4  degroote 	uint32_t	fnext;
    499   1.4  degroote 	uint32_t	lifetime;
    500   1.4  degroote 	uint8_t		ofdm_mask;
    501   1.4  degroote 	uint8_t		cck_mask;
    502   1.4  degroote 	uint8_t		rts_ntries;
    503   1.4  degroote 	uint8_t		data_ntries;
    504   1.4  degroote 	uint16_t	timeout;
    505   1.4  degroote 	uint16_t	txop;
    506   1.4  degroote 
    507   1.4  degroote 	struct		wpi_scan_essid essid[4];
    508   1.1    simonb 
    509   1.1    simonb 	/* followed by probe request body */
    510   1.1    simonb 	/* followed by nchan x wpi_scan_chan */
    511   1.9     perry } __packed;
    512   1.1    simonb 
    513   1.1    simonb struct wpi_scan_chan {
    514   1.1    simonb 	uint8_t		flags;
    515   1.4  degroote #define WPI_CHAN_ACTIVE	(1 << 0)
    516   1.4  degroote #define WPI_CHAN_DIRECT	(1 << 1)
    517   1.4  degroote 
    518  1.10  jakllsch 	uint8_t		chan;
    519   1.4  degroote 	uint8_t		rf_gain;
    520   1.4  degroote 	uint8_t		dsp_gain;
    521   1.1    simonb 	uint16_t	active;		/* msecs */
    522   1.1    simonb 	uint16_t	passive;	/* msecs */
    523   1.9     perry } __packed;
    524   1.1    simonb 
    525   1.4  degroote /* structure for WPI_CMD_TXPOWER */
    526   1.4  degroote struct wpi_cmd_txpower {
    527   1.4  degroote 	uint8_t		band;
    528   1.4  degroote #define WPI_BAND_5GHZ	0
    529   1.4  degroote #define WPI_BAND_2GHZ	1
    530   1.4  degroote 
    531   1.4  degroote 	uint8_t		reserved;
    532   1.4  degroote 	uint16_t	chan;
    533   1.4  degroote 	struct {
    534   1.4  degroote 		uint8_t	plcp;
    535   1.4  degroote 		uint8_t	rf_gain;
    536   1.4  degroote 		uint8_t	dsp_gain;
    537   1.4  degroote 		uint8_t	reserved;
    538  1.10  jakllsch 	} __packed	rates[WPI_CCK11 + 1];
    539   1.9     perry } __packed;
    540   1.4  degroote 
    541   1.1    simonb /* structure for WPI_CMD_BLUETOOTH */
    542   1.1    simonb struct wpi_bluetooth {
    543   1.1    simonb 	uint8_t		flags;
    544   1.1    simonb 	uint8_t		lead;
    545   1.1    simonb 	uint8_t		kill;
    546   1.1    simonb 	uint8_t		reserved;
    547   1.1    simonb 	uint32_t	ack;
    548   1.1    simonb 	uint32_t	cts;
    549   1.9     perry } __packed;
    550   1.1    simonb 
    551   1.1    simonb 
    552   1.1    simonb /* structure for WPI_UC_READY notification */
    553   1.1    simonb struct wpi_ucode_info {
    554   1.1    simonb 	uint32_t	version;
    555   1.1    simonb 	uint8_t		revision[8];
    556   1.1    simonb 	uint8_t		type;
    557   1.1    simonb 	uint8_t		subtype;
    558   1.1    simonb 	uint16_t	reserved;
    559   1.1    simonb 	uint32_t	logptr;
    560   1.1    simonb 	uint32_t	errorptr;
    561   1.1    simonb 	uint32_t	timestamp;
    562   1.1    simonb 	uint32_t	valid;
    563   1.9     perry } __packed;
    564   1.1    simonb 
    565   1.1    simonb /* structure for WPI_START_SCAN notification */
    566   1.1    simonb struct wpi_start_scan {
    567   1.1    simonb 	uint64_t	tstamp;
    568   1.1    simonb 	uint32_t	tbeacon;
    569   1.1    simonb 	uint8_t		chan;
    570   1.1    simonb 	uint8_t		band;
    571   1.1    simonb 	uint16_t	reserved;
    572   1.1    simonb 	uint32_t	status;
    573   1.9     perry } __packed;
    574   1.1    simonb 
    575   1.1    simonb /* structure for WPI_STOP_SCAN notification */
    576   1.1    simonb struct wpi_stop_scan {
    577   1.1    simonb 	uint8_t		nchan;
    578   1.1    simonb 	uint8_t		status;
    579   1.1    simonb 	uint8_t		reserved;
    580   1.1    simonb 	uint8_t		chan;
    581   1.1    simonb 	uint64_t	tsf;
    582   1.9     perry } __packed;
    583   1.4  degroote 
    584  1.10  jakllsch 
    585   1.4  degroote /* firmware image header */
    586   1.4  degroote struct wpi_firmware_hdr {
    587   1.4  degroote 	uint32_t	version;
    588   1.4  degroote 	uint32_t	main_textsz;
    589   1.4  degroote 	uint32_t	main_datasz;
    590  1.10  jakllsch 	uint32_t	init_textsz;
    591   1.5  degroote 	uint32_t	init_datasz;
    592   1.4  degroote 	uint32_t	boot_textsz;
    593   1.9     perry } __packed;
    594   1.4  degroote 
    595   1.4  degroote #define WPI_FW_MAIN_TEXT_MAXSZ	(80 * 1024)
    596   1.4  degroote #define WPI_FW_MAIN_DATA_MAXSZ	(32 * 1024)
    597  1.10  jakllsch #define WPI_FW_INIT_TEXT_MAXSZ	(80 * 1024)
    598  1.10  jakllsch #define WPI_FW_INIT_DATA_MAXSZ	(32 * 1024)
    599   1.4  degroote #define WPI_FW_BOOT_TEXT_MAXSZ	(80 * 1024)
    600   1.4  degroote 
    601  1.10  jakllsch #define WPI_FW_UPDATED	(1 << 31)
    602  1.10  jakllsch 
    603   1.4  degroote /*
    604  1.10  jakllsch  * Offsets into EEPROM.
    605  1.10  jakllsch  */
    606   1.1    simonb #define WPI_EEPROM_MAC		0x015
    607   1.1    simonb #define WPI_EEPROM_REVISION	0x035
    608   1.1    simonb #define WPI_EEPROM_CAPABILITIES	0x045
    609   1.1    simonb #define WPI_EEPROM_TYPE		0x04a
    610  1.10  jakllsch #define WPI_EEPROM_DOMAIN	0x060
    611   1.4  degroote #define WPI_EEPROM_BAND1	0x063
    612   1.4  degroote #define WPI_EEPROM_BAND2	0x072
    613   1.4  degroote #define WPI_EEPROM_BAND3	0x080
    614   1.4  degroote #define WPI_EEPROM_BAND4	0x08d
    615   1.4  degroote #define WPI_EEPROM_BAND5	0x099
    616   1.4  degroote #define WPI_EEPROM_POWER_GRP	0x100
    617   1.4  degroote 
    618   1.4  degroote struct wpi_eeprom_chan {
    619   1.4  degroote 	uint8_t	flags;
    620   1.4  degroote #define WPI_EEPROM_CHAN_VALID	(1 << 0)
    621   1.4  degroote #define WPI_EEPROM_CHAN_IBSS	(1 << 1)
    622   1.4  degroote #define WPI_EEPROM_CHAN_ACTIVE	(1 << 3)
    623   1.4  degroote #define WPI_EEPROM_CHAN_RADAR	(1 << 4)
    624   1.4  degroote 
    625   1.4  degroote 	int8_t	maxpwr;
    626   1.9     perry } __packed;
    627   1.4  degroote 
    628   1.4  degroote struct wpi_eeprom_sample {
    629   1.4  degroote 	uint8_t		index;
    630   1.4  degroote 	int8_t		power;
    631   1.4  degroote 	uint16_t	volt;
    632   1.9     perry } __packed;
    633   1.4  degroote 
    634   1.4  degroote #define WPI_POWER_GROUPS_COUNT	5
    635   1.4  degroote struct wpi_eeprom_group {
    636   1.4  degroote 	struct		wpi_eeprom_sample samples[5];
    637   1.4  degroote 	int32_t		coef[5];
    638   1.4  degroote 	int32_t		corr[5];
    639   1.4  degroote 	int8_t		maxpwr;
    640   1.4  degroote 	uint8_t		chan;
    641   1.4  degroote 	int16_t		temp;
    642   1.9     perry } __packed;
    643   1.4  degroote 
    644   1.4  degroote #define WPI_CHAN_BANDS_COUNT	5
    645   1.4  degroote #define WPI_MAX_CHAN_PER_BAND	14
    646   1.4  degroote static const struct wpi_chan_band {
    647   1.4  degroote 	uint32_t	addr;	/* offset in EEPROM */
    648   1.4  degroote 	uint8_t		nchan;
    649   1.4  degroote 	uint8_t		chan[WPI_MAX_CHAN_PER_BAND];
    650   1.4  degroote } wpi_bands[5] = {
    651   1.4  degroote 	{ WPI_EEPROM_BAND1, 14,
    652   1.4  degroote 	    { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 } },
    653   1.4  degroote 	{ WPI_EEPROM_BAND2, 13,
    654   1.4  degroote 	    { 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 } },
    655   1.4  degroote 	{ WPI_EEPROM_BAND3, 12,
    656   1.4  degroote 	    { 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 } },
    657   1.4  degroote 	{ WPI_EEPROM_BAND4, 11,
    658   1.4  degroote 	    { 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 } },
    659   1.4  degroote 	{ WPI_EEPROM_BAND5, 6,
    660   1.4  degroote 	    { 145, 149, 153, 157, 161, 165 } }
    661   1.4  degroote };
    662   1.4  degroote 
    663   1.4  degroote /* convert rate index (device view) into rate in 500Kbps unit */
    664   1.4  degroote static const uint8_t wpi_ridx_to_rate[] = {
    665   1.4  degroote 	12, 18, 24, 36, 48, 72, 96, 108, /* OFDM */
    666   1.4  degroote 	2, 4, 11, 22 /* CCK */
    667   1.4  degroote };
    668   1.4  degroote 
    669   1.4  degroote /* convert rate index (device view) into PLCP code */
    670   1.4  degroote static const uint8_t wpi_ridx_to_plcp[] = {
    671   1.4  degroote 	0xd, 0xf, 0x5, 0x7, 0x9, 0xb, 0x1, 0x3, /* OFDM R1-R4 */
    672   1.4  degroote 	10, 20, 55, 110 /* CCK */
    673   1.4  degroote };
    674   1.4  degroote 
    675   1.4  degroote #define WPI_MAX_PWR_INDEX	77
    676   1.4  degroote /*
    677   1.4  degroote  * RF Tx gain values from highest to lowest power (values obtained from
    678   1.4  degroote  * the reference driver.)
    679   1.4  degroote  */
    680   1.4  degroote static const uint8_t wpi_rf_gain_2ghz[WPI_MAX_PWR_INDEX + 1] = {
    681   1.4  degroote 	0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xbb, 0xbb, 0xbb,
    682   1.4  degroote 	0xbb, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xd3, 0xd3, 0xb3, 0xb3, 0xb3,
    683   1.4  degroote 	0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x73, 0xeb, 0xeb, 0xeb,
    684   1.4  degroote 	0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xab, 0xab, 0xab, 0x8b,
    685   1.4  degroote 	0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xc3, 0xc3, 0xc3, 0xc3, 0xa3,
    686   1.4  degroote 	0xa3, 0xa3, 0xa3, 0x83, 0x83, 0x83, 0x83, 0x63, 0x63, 0x63, 0x63,
    687   1.4  degroote 	0x43, 0x43, 0x43, 0x43, 0x23, 0x23, 0x23, 0x23, 0x03, 0x03, 0x03,
    688   1.4  degroote 	0x03
    689   1.4  degroote };
    690   1.4  degroote 
    691   1.4  degroote static const uint8_t wpi_rf_gain_5ghz[WPI_MAX_PWR_INDEX + 1] = {
    692   1.4  degroote 	0xfb, 0xfb, 0xfb, 0xdb, 0xdb, 0xbb, 0xbb, 0x9b, 0x9b, 0x7b, 0x7b,
    693   1.4  degroote 	0x7b, 0x7b, 0x5b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x1b, 0x1b,
    694   1.4  degroote 	0x1b, 0x73, 0x73, 0x73, 0x53, 0x53, 0x53, 0x53, 0x53, 0x33, 0x33,
    695   1.4  degroote 	0x33, 0x33, 0x13, 0x13, 0x13, 0x13, 0x13, 0xab, 0xab, 0xab, 0x8b,
    696   1.4  degroote 	0x8b, 0x8b, 0x8b, 0x6b, 0x6b, 0x6b, 0x6b, 0x4b, 0x4b, 0x4b, 0x4b,
    697   1.4  degroote 	0x2b, 0x2b, 0x2b, 0x2b, 0x0b, 0x0b, 0x0b, 0x0b, 0x83, 0x83, 0x63,
    698   1.4  degroote 	0x63, 0x63, 0x63, 0x43, 0x43, 0x43, 0x43, 0x23, 0x23, 0x23, 0x23,
    699   1.4  degroote 	0x03
    700   1.4  degroote };
    701   1.4  degroote 
    702   1.4  degroote /*
    703   1.4  degroote  * DSP pre-DAC gain values from highest to lowest power (values obtained
    704   1.4  degroote  * from the reference driver.)
    705   1.4  degroote  */
    706   1.4  degroote static const uint8_t wpi_dsp_gain_2ghz[WPI_MAX_PWR_INDEX + 1] = {
    707   1.4  degroote 	0x7f, 0x7f, 0x7f, 0x7f, 0x7d, 0x6e, 0x69, 0x62, 0x7d, 0x73, 0x6c,
    708   1.4  degroote 	0x63, 0x77, 0x6f, 0x69, 0x61, 0x5c, 0x6a, 0x64, 0x78, 0x71, 0x6b,
    709   1.4  degroote 	0x7d, 0x77, 0x70, 0x6a, 0x65, 0x61, 0x5b, 0x6b, 0x79, 0x73, 0x6d,
    710   1.4  degroote 	0x7f, 0x79, 0x73, 0x6c, 0x66, 0x60, 0x5c, 0x6e, 0x68, 0x62, 0x74,
    711   1.4  degroote 	0x7d, 0x77, 0x71, 0x6b, 0x65, 0x60, 0x71, 0x6a, 0x66, 0x5f, 0x71,
    712   1.4  degroote 	0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f,
    713   1.4  degroote 	0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66,
    714   1.4  degroote 	0x5f
    715   1.4  degroote };
    716   1.4  degroote 
    717   1.4  degroote static const uint8_t wpi_dsp_gain_5ghz[WPI_MAX_PWR_INDEX + 1] = {
    718   1.4  degroote 	0x7f, 0x78, 0x72, 0x77, 0x65, 0x71, 0x66, 0x72, 0x67, 0x75, 0x6b,
    719   1.4  degroote 	0x63, 0x5c, 0x6c, 0x7d, 0x76, 0x6d, 0x66, 0x60, 0x5a, 0x68, 0x62,
    720   1.4  degroote 	0x5c, 0x76, 0x6f, 0x68, 0x7e, 0x79, 0x71, 0x69, 0x63, 0x76, 0x6f,
    721   1.4  degroote 	0x68, 0x62, 0x74, 0x6d, 0x66, 0x62, 0x5d, 0x71, 0x6b, 0x63, 0x78,
    722   1.4  degroote 	0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63,
    723   1.4  degroote 	0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x6b, 0x63, 0x78,
    724   1.4  degroote 	0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63,
    725   1.4  degroote 	0x78
    726   1.4  degroote };
    727   1.1    simonb 
    728   1.1    simonb #define WPI_READ(sc, reg)						\
    729   1.1    simonb 	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
    730   1.1    simonb 
    731   1.1    simonb #define WPI_WRITE(sc, reg, val)						\
    732   1.1    simonb 	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
    733   1.1    simonb 
    734   1.1    simonb #define WPI_WRITE_REGION_4(sc, offset, datap, count)			\
    735   1.1    simonb 	bus_space_write_region_4((sc)->sc_st, (sc)->sc_sh, (offset),	\
    736  1.10  jakllsch 	    (datap), (count))
    737